summaryrefslogtreecommitdiffstats
path: root/crypto/openssl/crypto/bn/bn_word.c
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/openssl/crypto/bn/bn_word.c')
-rw-r--r--crypto/openssl/crypto/bn/bn_word.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/crypto/openssl/crypto/bn/bn_word.c b/crypto/openssl/crypto/bn/bn_word.c
index 73157a7..cd59baa 100644
--- a/crypto/openssl/crypto/bn/bn_word.c
+++ b/crypto/openssl/crypto/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);
OpenPOWER on IntegriCloud