summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheo Buehler <tb@cvs.openbsd.org>2023-10-11 12:51:08 +0000
committerTheo Buehler <tb@cvs.openbsd.org>2023-10-11 12:51:08 +0000
commit103e213dc684e667f659b18cc8cbc52cc6777530 (patch)
treec39c73712fcf9563b2262085c26fcceabb791a70
parent0dfbee1ec101c14cac0569942d1e4cbe6d4de4d0 (diff)
Clean up X509_ALGOR_cmp()
This is currently written in what is likely the most stupid way possible. Rewrite this function in a more straightforward way. ok jsing
-rw-r--r--lib/libcrypto/asn1/x_algor.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/lib/libcrypto/asn1/x_algor.c b/lib/libcrypto/asn1/x_algor.c
index 0f1cd9cb65e..a6383379390 100644
--- a/lib/libcrypto/asn1/x_algor.c
+++ b/lib/libcrypto/asn1/x_algor.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: x_algor.c,v 1.25 2023/07/07 19:37:52 beck Exp $ */
+/* $OpenBSD: x_algor.c,v 1.26 2023/10/11 12:51:07 tb Exp $ */
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
* project 2000.
*/
@@ -205,16 +205,16 @@ X509_ALGOR_set_md(X509_ALGOR *alg, const EVP_MD *md)
X509_ALGOR_set0(alg, OBJ_nid2obj(EVP_MD_type(md)), param_type, NULL);
}
-/* Returns 0 if they are equal, != 0 otherwise. */
int
X509_ALGOR_cmp(const X509_ALGOR *a, const X509_ALGOR *b)
{
- int rv = OBJ_cmp(a->algorithm, b->algorithm);
- if (!rv) {
- if (!a->parameter && !b->parameter)
- rv = 0;
- else
- rv = ASN1_TYPE_cmp(a->parameter, b->parameter);
- }
- return(rv);
+ int cmp;
+
+ if ((cmp = OBJ_cmp(a->algorithm, b->algorithm)) != 0)
+ return cmp;
+
+ if (a->parameter == NULL && b->parameter == NULL)
+ return 0;
+
+ return ASN1_TYPE_cmp(a->parameter, b->parameter);
}