From e08aad1d14765aea1c391cf5b72967b41c801a83 Mon Sep 17 00:00:00 2001 From: "Dr. Stephen Henson" Date: Tue, 10 Aug 2004 17:40:14 +0000 Subject: [PATCH] Make ASN1_INTEGER_cmp() work as expected with negative integers. --- crypto/asn1/a_int.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/crypto/asn1/a_int.c b/crypto/asn1/a_int.c index c81fa00c4c..78a6cb0d29 100644 --- a/crypto/asn1/a_int.c +++ b/crypto/asn1/a_int.c @@ -65,7 +65,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. -- 2.34.1