summaryrefslogtreecommitdiffstats
path: root/crypto/bn
diff options
context:
space:
mode:
authorRich Salz <rsalz@akamai.com>2015-08-10 12:45:25 -0400
committerRich Salz <rsalz@openssl.org>2015-08-26 07:00:43 -0400
commit22dc08d00ae9517048b1ca44cd3810128eba0273 (patch)
tree49f25f457422749d9888865e1afc8f05c945ed5a /crypto/bn
parentddcc5e5b60e2e14a7f65cc8faff0642cb68f4343 (diff)
BN_bin2bn handle leading zero's
If a binary sequence is all zero's, call BN_zero. Reviewed-by: Matt Caswell <matt@openssl.org>
Diffstat (limited to 'crypto/bn')
-rw-r--r--crypto/bn/bn_lib.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/crypto/bn/bn_lib.c b/crypto/bn/bn_lib.c
index 4e133ce8ca..c8e8519d8b 100644
--- a/crypto/bn/bn_lib.c
+++ b/crypto/bn/bn_lib.c
@@ -552,7 +552,9 @@ BIGNUM *BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret)
if (ret == NULL)
return (NULL);
bn_check_top(ret);
- l = 0;
+ /* Skip leading zero's. */
+ for ( ; *s == 0 && len > 0; s++, len--)
+ continue;
n = len;
if (n == 0) {
ret->top = 0;
@@ -566,6 +568,7 @@ BIGNUM *BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret)
}
ret->top = i;
ret->neg = 0;
+ l = 0;
while (n--) {
l = (l << 8L) | *(s++);
if (m-- == 0) {