From 07a0e24fbcc811580c51bdba7ac4be5b3a8129de Mon Sep 17 00:00:00 2001 From: jsing <> Date: Sat, 25 Jun 2022 14:22:54 +0000 Subject: Simplify ASN1_INTEGER_cmp() ok beck@ tb@ --- src/lib/libcrypto/asn1/a_int.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) (limited to 'src') 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 @@ -/* $OpenBSD: a_int.c,v 1.39 2022/04/27 17:42:08 jsing Exp $ */ +/* $OpenBSD: a_int.c,v 1.40 2022/06/25 14:22:54 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -102,25 +102,18 @@ ASN1_INTEGER_dup(const ASN1_INTEGER *x) } int -ASN1_INTEGER_cmp(const ASN1_INTEGER *x, const ASN1_INTEGER *y) +ASN1_INTEGER_cmp(const ASN1_INTEGER *a, const ASN1_INTEGER *b) { - int neg, ret; + int ret = 1; - /* Compare signs */ - neg = x->type & V_ASN1_NEG; - if (neg != (y->type & V_ASN1_NEG)) { - if (neg) - return -1; - else - return 1; - } + /* Compare sign, then content. */ + if ((a->type & V_ASN1_NEG) == (b->type & V_ASN1_NEG)) + ret = ASN1_STRING_cmp(a, b); - ret = ASN1_STRING_cmp(x, y); - - if (neg) + if ((a->type & V_ASN1_NEG) != 0) return -ret; - else - return ret; + + return ret; } int -- cgit v1.2.3-55-g6feb