Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/boringssl.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Benjamin <davidben@chromium.org>2015-04-21 02:52:31 +0300
committerAdam Langley <agl@google.com>2015-04-23 23:53:24 +0300
commitc85573ccd84def3ea0bf0722b4fa7efc7df7dcc1 (patch)
tree72cfa28d3d9e69eaca7121831b6166fb6566bffb /crypto/asn1
parent9626f26320444bfd4d63cab18cf667c2c6b5dc56 (diff)
Ensure BN_asc2bn, BN_dec2bn, and BN_hex2bn never give -0.
See upstream's a0eed48d37a4b7beea0c966caf09ad46f4a92a44. Rather than import that, we should just ensure neg + zero isn't a possible state. Add some tests for asc2bn and dec2bn while we're here. Also fix a bug with dec2bn where it doesn't actually ignore trailing data as it's supposed to. Change-Id: I2385b67b740e57020c75a247bee254085ab7ce15 Reviewed-on: https://boringssl-review.googlesource.com/4484 Reviewed-by: Adam Langley <agl@google.com>
Diffstat (limited to 'crypto/asn1')
-rw-r--r--crypto/asn1/a_int.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/crypto/asn1/a_int.c b/crypto/asn1/a_int.c
index eb0887a1..2ecccc53 100644
--- a/crypto/asn1/a_int.c
+++ b/crypto/asn1/a_int.c
@@ -416,7 +416,7 @@ ASN1_INTEGER *BN_to_ASN1_INTEGER(const BIGNUM *bn, ASN1_INTEGER *ai)
OPENSSL_PUT_ERROR(ASN1, BN_to_ASN1_INTEGER, ASN1_R_NESTED_ASN1_ERROR);
goto err;
}
- if (BN_is_negative(bn))
+ if (BN_is_negative(bn) && !BN_is_zero(bn))
ret->type = V_ASN1_NEG_INTEGER;
else ret->type=V_ASN1_INTEGER;
j=BN_num_bits(bn);