diff options
author | Bob Beck <beck@cvs.openbsd.org> | 2000-12-15 02:58:48 +0000 |
---|---|---|
committer | Bob Beck <beck@cvs.openbsd.org> | 2000-12-15 02:58:48 +0000 |
commit | 01c37e03996dffeff1618614755c6cc676899acb (patch) | |
tree | 988002fb9b1d859c10890511aa5273cfb00662dc /lib/libcrypto/bn/bn_word.c | |
parent | 9865f3ff77de9cfef0c5c8b0470daf6faa2f14af (diff) |
openssl-engine-0.9.6 merge
Diffstat (limited to 'lib/libcrypto/bn/bn_word.c')
-rw-r--r-- | lib/libcrypto/bn/bn_word.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/lib/libcrypto/bn/bn_word.c b/lib/libcrypto/bn/bn_word.c index 73157a7d43f..cd59baa2c49 100644 --- a/lib/libcrypto/bn/bn_word.c +++ b/lib/libcrypto/bn/bn_word.c @@ -115,7 +115,7 @@ int BN_add_word(BIGNUM *a, BN_ULONG w) a->neg=0; i=BN_sub_word(a,w); if (!BN_is_zero(a)) - a->neg=1; + a->neg=!(a->neg); return(i); } w&=BN_MASK2; @@ -140,7 +140,7 @@ int BN_sub_word(BIGNUM *a, BN_ULONG w) { int i; - if (a->neg) + if (BN_is_zero(a) || a->neg) { a->neg=0; i=BN_add_word(a,w); @@ -182,11 +182,16 @@ int BN_mul_word(BIGNUM *a, BN_ULONG w) w&=BN_MASK2; if (a->top) { - ll=bn_mul_words(a->d,a->d,a->top,w); - if (ll) + if (w == 0) + BN_zero(a); + else { - if (bn_wexpand(a,a->top+1) == NULL) return(0); - a->d[a->top++]=ll; + ll=bn_mul_words(a->d,a->d,a->top,w); + if (ll) + { + if (bn_wexpand(a,a->top+1) == NULL) return(0); + a->d[a->top++]=ll; + } } } return(1); |