From: Dr. Stephen Henson Date: Tue, 10 Aug 2004 17:40:31 +0000 (+0000) Subject: Make ASN1_INTEGER_cmp() work as expected with negative integers. X-Git-Tag: OpenSSL_0_9_7e~28 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=8c172bce1cc106f6e2fb90ef6f9557f80e3044bc;p=oweals%2Fopenssl.git Make ASN1_INTEGER_cmp() work as expected with negative integers. --- diff --git a/crypto/asn1/a_int.c b/crypto/asn1/a_int.c index edb243c021..21cc64bb23 100644 --- a/crypto/asn1/a_int.c +++ b/crypto/asn1/a_int.c @@ -64,7 +64,26 @@ ASN1_INTEGER *ASN1_INTEGER_dup(ASN1_INTEGER *x) { return M_ASN1_INTEGER_dup(x);} int ASN1_INTEGER_cmp(ASN1_INTEGER *x, ASN1_INTEGER *y) -{ return M_ASN1_INTEGER_cmp(x,y);} + { + int neg, ret; + /* Compare signs */ + neg = x->type & V_ASN1_NEG; + if (neg != (y->type & V_ASN1_NEG)) + { + if (neg) + return -1; + else + return 1; + } + + ret = ASN1_STRING_cmp(x, y); + + if (neg) + return -ret; + else + return ret; + } + /* * This converts an ASN1 INTEGER into its content encoding.