diff options
author | Nils Larsch <nils@openssl.org> | 2005-07-25 22:57:54 +0000 |
---|---|---|
committer | Nils Larsch <nils@openssl.org> | 2005-07-25 22:57:54 +0000 |
commit | 0260405c6861ebe27a960b098d4a7da739e535ec (patch) | |
tree | ed361b2ac719e8248ced9e97b6441ccd3e4397f1 /crypto/bn/bn_word.c | |
parent | 0537f9689c299a149304414589cbe4db3b7ed204 (diff) | |
download | openssl-0260405c6861ebe27a960b098d4a7da739e535ec.tar.gz |
fix BN_mod_word and give a more reasonable return value if an error occurred
Diffstat (limited to 'crypto/bn/bn_word.c')
-rw-r--r-- | crypto/bn/bn_word.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/crypto/bn/bn_word.c b/crypto/bn/bn_word.c index bc5905fef4..ee7b87c45c 100644 --- a/crypto/bn/bn_word.c +++ b/crypto/bn/bn_word.c @@ -69,6 +69,9 @@ BN_ULONG BN_mod_word(const BIGNUM *a, BN_ULONG w) #endif int i; + if (w == 0) + return (BN_ULONG)-1; + bn_check_top(a); w&=BN_MASK2; for (i=a->top-1; i>=0; i--) @@ -94,7 +97,7 @@ BN_ULONG BN_div_word(BIGNUM *a, BN_ULONG w) if (!w) /* actually this an error (division by zero) */ - return 0; + return (BN_ULONG)-1; if (a->top == 0) return 0; @@ -102,7 +105,7 @@ BN_ULONG BN_div_word(BIGNUM *a, BN_ULONG w) j = BN_BITS2 - BN_num_bits_word(w); w <<= j; if (!BN_lshift(a, a, j)) - return 0; + return (BN_ULONG)-1; for (i=a->top-1; i>=0; i--) { |