summaryrefslogtreecommitdiffstats
path: root/crypto/asn1/a_int.c
diff options
context:
space:
mode:
authorDr. Stephen Henson <steve@openssl.org>2004-08-10 17:40:14 +0000
committerDr. Stephen Henson <steve@openssl.org>2004-08-10 17:40:14 +0000
commite08aad1d14765aea1c391cf5b72967b41c801a83 (patch)
tree4039d7d69a22a56bc3dd6c36f122f2a335b6a80e /crypto/asn1/a_int.c
parentb5a93e22504ecdc86861c448f560645a3605d4d2 (diff)
Make ASN1_INTEGER_cmp() work as expected with negative integers.
Diffstat (limited to 'crypto/asn1/a_int.c')
-rw-r--r--crypto/asn1/a_int.c21
1 files changed, 20 insertions, 1 deletions
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.