diff options
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--) { |