diff options
Diffstat (limited to '')
-rw-r--r-- | src/lib/libcrypto/bn/bn_div.c | 8 | ||||
-rw-r--r-- | src/lib/libcrypto/bn/bn_mont.c | 6 | ||||
-rw-r--r-- | src/lib/libcrypto/bn/bn_mul.c | 14 |
3 files changed, 14 insertions, 14 deletions
diff --git a/src/lib/libcrypto/bn/bn_div.c b/src/lib/libcrypto/bn/bn_div.c index ac1a09615a..f9a095e3b3 100644 --- a/src/lib/libcrypto/bn/bn_div.c +++ b/src/lib/libcrypto/bn/bn_div.c | |||
@@ -200,10 +200,10 @@ int BN_div(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, const BIGNUM *divisor, | |||
200 | 200 | ||
201 | /* First we normalise the numbers */ | 201 | /* First we normalise the numbers */ |
202 | norm_shift=BN_BITS2-((BN_num_bits(divisor))%BN_BITS2); | 202 | norm_shift=BN_BITS2-((BN_num_bits(divisor))%BN_BITS2); |
203 | BN_lshift(sdiv,divisor,norm_shift); | 203 | if (!(BN_lshift(sdiv,divisor,norm_shift))) goto err; |
204 | sdiv->neg=0; | 204 | sdiv->neg=0; |
205 | norm_shift+=BN_BITS2; | 205 | norm_shift+=BN_BITS2; |
206 | BN_lshift(snum,num,norm_shift); | 206 | if (!(BN_lshift(snum,num,norm_shift))) goto err; |
207 | snum->neg=0; | 207 | snum->neg=0; |
208 | div_n=sdiv->top; | 208 | div_n=sdiv->top; |
209 | num_n=snum->top; | 209 | num_n=snum->top; |
@@ -327,7 +327,7 @@ int BN_div(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, const BIGNUM *divisor, | |||
327 | tmp->top=j; | 327 | tmp->top=j; |
328 | 328 | ||
329 | j=wnum.top; | 329 | j=wnum.top; |
330 | BN_sub(&wnum,&wnum,tmp); | 330 | if (!BN_sub(&wnum,&wnum,tmp)) goto err; |
331 | 331 | ||
332 | snum->top=snum->top+wnum.top-j; | 332 | snum->top=snum->top+wnum.top-j; |
333 | 333 | ||
@@ -335,7 +335,7 @@ int BN_div(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, const BIGNUM *divisor, | |||
335 | { | 335 | { |
336 | q--; | 336 | q--; |
337 | j=wnum.top; | 337 | j=wnum.top; |
338 | BN_add(&wnum,&wnum,sdiv); | 338 | if (!BN_add(&wnum,&wnum,sdiv)) goto err; |
339 | snum->top+=wnum.top-j; | 339 | snum->top+=wnum.top-j; |
340 | } | 340 | } |
341 | *(resp--)=q; | 341 | *(resp--)=q; |
diff --git a/src/lib/libcrypto/bn/bn_mont.c b/src/lib/libcrypto/bn/bn_mont.c index 82942a4759..c9ebdbaabe 100644 --- a/src/lib/libcrypto/bn/bn_mont.c +++ b/src/lib/libcrypto/bn/bn_mont.c | |||
@@ -221,7 +221,7 @@ int BN_from_montgomery(BIGNUM *ret, const BIGNUM *a, BN_MONT_CTX *mont, | |||
221 | 221 | ||
222 | if (!BN_mul(t1,t2,&mont->N,ctx)) goto err; | 222 | if (!BN_mul(t1,t2,&mont->N,ctx)) goto err; |
223 | if (!BN_add(t2,a,t1)) goto err; | 223 | if (!BN_add(t2,a,t1)) goto err; |
224 | BN_rshift(ret,t2,mont->ri); | 224 | if (!BN_rshift(ret,t2,mont->ri)) goto err; |
225 | #endif /* MONT_WORD */ | 225 | #endif /* MONT_WORD */ |
226 | 226 | ||
227 | if (BN_ucmp(ret, &(mont->N)) >= 0) | 227 | if (BN_ucmp(ret, &(mont->N)) >= 0) |
@@ -282,8 +282,8 @@ int BN_MONT_CTX_set(BN_MONT_CTX *mont, const BIGNUM *mod, BN_CTX *ctx) | |||
282 | BN_ULONG buf[2]; | 282 | BN_ULONG buf[2]; |
283 | 283 | ||
284 | mont->ri=(BN_num_bits(mod)+(BN_BITS2-1))/BN_BITS2*BN_BITS2; | 284 | mont->ri=(BN_num_bits(mod)+(BN_BITS2-1))/BN_BITS2*BN_BITS2; |
285 | BN_zero(R); | 285 | if (!(BN_zero(R))) goto err; |
286 | BN_set_bit(R,BN_BITS2); /* R */ | 286 | if (!(BN_set_bit(R,BN_BITS2))) goto err; /* R */ |
287 | 287 | ||
288 | buf[0]=mod->d[0]; /* tmod = N mod word size */ | 288 | buf[0]=mod->d[0]; /* tmod = N mod word size */ |
289 | buf[1]=0; | 289 | buf[1]=0; |
diff --git a/src/lib/libcrypto/bn/bn_mul.c b/src/lib/libcrypto/bn/bn_mul.c index 7bffc9c16a..fd598b8b3d 100644 --- a/src/lib/libcrypto/bn/bn_mul.c +++ b/src/lib/libcrypto/bn/bn_mul.c | |||
@@ -964,7 +964,7 @@ int BN_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx) | |||
964 | 964 | ||
965 | if ((al == 0) || (bl == 0)) | 965 | if ((al == 0) || (bl == 0)) |
966 | { | 966 | { |
967 | BN_zero(r); | 967 | if (!BN_zero(r)) goto err; |
968 | return(1); | 968 | return(1); |
969 | } | 969 | } |
970 | top=al+bl; | 970 | top=al+bl; |
@@ -1044,7 +1044,7 @@ int BN_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx) | |||
1044 | if (i == 1 && !BN_get_flags(b,BN_FLG_STATIC_DATA)) | 1044 | if (i == 1 && !BN_get_flags(b,BN_FLG_STATIC_DATA)) |
1045 | { | 1045 | { |
1046 | BIGNUM *tmp_bn = (BIGNUM *)b; | 1046 | BIGNUM *tmp_bn = (BIGNUM *)b; |
1047 | bn_wexpand(tmp_bn,al); | 1047 | if (bn_wexpand(tmp_bn,al) == NULL) goto err; |
1048 | tmp_bn->d[bl]=0; | 1048 | tmp_bn->d[bl]=0; |
1049 | bl++; | 1049 | bl++; |
1050 | i--; | 1050 | i--; |
@@ -1052,7 +1052,7 @@ int BN_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx) | |||
1052 | else if (i == -1 && !BN_get_flags(a,BN_FLG_STATIC_DATA)) | 1052 | else if (i == -1 && !BN_get_flags(a,BN_FLG_STATIC_DATA)) |
1053 | { | 1053 | { |
1054 | BIGNUM *tmp_bn = (BIGNUM *)a; | 1054 | BIGNUM *tmp_bn = (BIGNUM *)a; |
1055 | bn_wexpand(tmp_bn,bl); | 1055 | if (bn_wexpand(tmp_bn,bl) == NULL) goto err; |
1056 | tmp_bn->d[al]=0; | 1056 | tmp_bn->d[al]=0; |
1057 | al++; | 1057 | al++; |
1058 | i++; | 1058 | i++; |
@@ -1067,14 +1067,14 @@ int BN_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx) | |||
1067 | t = BN_CTX_get(ctx); | 1067 | t = BN_CTX_get(ctx); |
1068 | if (al == j) /* exact multiple */ | 1068 | if (al == j) /* exact multiple */ |
1069 | { | 1069 | { |
1070 | bn_wexpand(t,k*2); | 1070 | if (bn_wexpand(t,k*2) == NULL) goto err; |
1071 | bn_wexpand(rr,k*2); | 1071 | if (bn_wexpand(rr,k*2) == NULL) goto err; |
1072 | bn_mul_recursive(rr->d,a->d,b->d,al,t->d); | 1072 | bn_mul_recursive(rr->d,a->d,b->d,al,t->d); |
1073 | } | 1073 | } |
1074 | else | 1074 | else |
1075 | { | 1075 | { |
1076 | bn_wexpand(t,k*4); | 1076 | if (bn_wexpand(t,k*4) == NULL) goto err; |
1077 | bn_wexpand(rr,k*4); | 1077 | if (bn_wexpand(rr,k*4) == NULL) goto err; |
1078 | bn_mul_part_recursive(rr->d,a->d,b->d,al-j,j,t->d); | 1078 | bn_mul_part_recursive(rr->d,a->d,b->d,al-j,j,t->d); |
1079 | } | 1079 | } |
1080 | rr->top=top; | 1080 | rr->top=top; |