summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjsing <>2022-06-25 14:22:54 +0000
committerjsing <>2022-06-25 14:22:54 +0000
commit07a0e24fbcc811580c51bdba7ac4be5b3a8129de (patch)
treec76ff2c2309b8ad6854c660049dfe088e23fe1b1 /src
parentf3be0e605bb315d9af376aa2c6a9729a3a8db06c (diff)
downloadopenbsd-07a0e24fbcc811580c51bdba7ac4be5b3a8129de.tar.gz
openbsd-07a0e24fbcc811580c51bdba7ac4be5b3a8129de.tar.bz2
openbsd-07a0e24fbcc811580c51bdba7ac4be5b3a8129de.zip
Simplify ASN1_INTEGER_cmp()
ok beck@ tb@
Diffstat (limited to 'src')
-rw-r--r--src/lib/libcrypto/asn1/a_int.c25
1 files changed, 9 insertions, 16 deletions
diff --git a/src/lib/libcrypto/asn1/a_int.c b/src/lib/libcrypto/asn1/a_int.c
index aa4421c0e0..6ad0df3d1e 100644
--- a/src/lib/libcrypto/asn1/a_int.c
+++ b/src/lib/libcrypto/asn1/a_int.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: a_int.c,v 1.39 2022/04/27 17:42:08 jsing Exp $ */ 1/* $OpenBSD: a_int.c,v 1.40 2022/06/25 14:22:54 jsing Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -102,25 +102,18 @@ ASN1_INTEGER_dup(const ASN1_INTEGER *x)
102} 102}
103 103
104int 104int
105ASN1_INTEGER_cmp(const ASN1_INTEGER *x, const ASN1_INTEGER *y) 105ASN1_INTEGER_cmp(const ASN1_INTEGER *a, const ASN1_INTEGER *b)
106{ 106{
107 int neg, ret; 107 int ret = 1;
108 108
109 /* Compare signs */ 109 /* Compare sign, then content. */
110 neg = x->type & V_ASN1_NEG; 110 if ((a->type & V_ASN1_NEG) == (b->type & V_ASN1_NEG))
111 if (neg != (y->type & V_ASN1_NEG)) { 111 ret = ASN1_STRING_cmp(a, b);
112 if (neg)
113 return -1;
114 else
115 return 1;
116 }
117 112
118 ret = ASN1_STRING_cmp(x, y); 113 if ((a->type & V_ASN1_NEG) != 0)
119
120 if (neg)
121 return -ret; 114 return -ret;
122 else 115
123 return ret; 116 return ret;
124} 117}
125 118
126int 119int