@@ -324,7 +324,7 @@ int BN_mod_mul_montgomery(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
324
324
}
325
325
326
326
#if defined(OPENSSL_BN_ASM_MONT)
327
- // |bn_mul_mont| requires at least 128 bits of limbs, at least for x86 .
327
+ // |bn_mul_mont| requires at least 128 bits of limbs.
328
328
int num = mont->N .width ;
329
329
if (num >= (128 / BN_BITS2) && a->width == num && b->width == num) {
330
330
if (!bn_wexpand (r, num)) {
@@ -333,12 +333,7 @@ int BN_mod_mul_montgomery(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
333
333
// This bound is implied by |bn_mont_ctx_set_N_and_n0|. |bn_mul_mont|
334
334
// allocates |num| words on the stack, so |num| cannot be too large.
335
335
assert ((size_t )num <= BN_MONTGOMERY_MAX_WORDS);
336
- if (!bn_mul_mont (r->d , a->d , b->d , mont->N .d , mont->n0 , num)) {
337
- // The check above ensures this won't happen.
338
- assert (0 );
339
- OPENSSL_PUT_ERROR (BN, ERR_R_INTERNAL_ERROR);
340
- return 0 ;
341
- }
336
+ bn_mul_mont (r->d , a->d , b->d , mont->N .d , mont->n0 , num);
342
337
r->neg = 0 ;
343
338
r->width = num;
344
339
return 1 ;
@@ -379,11 +374,9 @@ void bn_mod_mul_montgomery_small(BN_ULONG *r, const BN_ULONG *a,
379
374
}
380
375
381
376
#if defined(OPENSSL_BN_ASM_MONT)
382
- // |bn_mul_mont| requires at least 128 bits of limbs, at least for x86 .
377
+ // |bn_mul_mont| requires at least 128 bits of limbs.
383
378
if (num >= (128 / BN_BITS2)) {
384
- if (!bn_mul_mont (r, a, b, mont->N .d , mont->n0 , num)) {
385
- abort (); // The check above ensures this won't happen.
386
- }
379
+ bn_mul_mont (r, a, b, mont->N .d , mont->n0 , num);
387
380
return ;
388
381
}
389
382
#endif
@@ -404,27 +397,27 @@ void bn_mod_mul_montgomery_small(BN_ULONG *r, const BN_ULONG *a,
404
397
}
405
398
406
399
#if defined(OPENSSL_BN_ASM_MONT) && defined(OPENSSL_X86_64)
407
- int bn_mul_mont (BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,
400
+ void bn_mul_mont (BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,
408
401
const BN_ULONG *np, const BN_ULONG *n0, size_t num) {
409
402
if (ap == bp && bn_sqr8x_mont_capable (num)) {
410
- return bn_sqr8x_mont (rp, ap, bn_mulx_adx_capable (), np, n0, num);
411
- }
412
- if ( bn_mulx4x_mont_capable ( num)) {
413
- return bn_mulx4x_mont (rp, ap, bp, np, n0, num);
414
- }
415
- if ( bn_mul4x_mont_capable (num)) {
416
- return bn_mul4x_mont (rp, ap, bp, np, n0, num);
403
+ bn_sqr8x_mont (rp, ap, bn_mulx_adx_capable (), np, n0, num);
404
+ } else if ( bn_mulx4x_mont_capable (num)) {
405
+ bn_mulx4x_mont (rp, ap, bp, np, n0, num);
406
+ } else if ( bn_mul4x_mont_capable ( num)) {
407
+ bn_mul4x_mont (rp, ap, bp, np, n0, num);
408
+ } else {
409
+ bn_mul_mont_nohw (rp, ap, bp, np, n0, num);
417
410
}
418
- return bn_mul_mont_nohw (rp, ap, bp, np, n0, num);
419
411
}
420
412
#endif
421
413
422
414
#if defined(OPENSSL_BN_ASM_MONT) && defined(OPENSSL_ARM)
423
- int bn_mul_mont (BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,
424
- const BN_ULONG *np, const BN_ULONG *n0, size_t num) {
415
+ void bn_mul_mont (BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,
416
+ const BN_ULONG *np, const BN_ULONG *n0, size_t num) {
425
417
if (bn_mul8x_mont_neon_capable (num)) {
426
- return bn_mul8x_mont_neon (rp, ap, bp, np, n0, num);
418
+ bn_mul8x_mont_neon (rp, ap, bp, np, n0, num);
419
+ } else {
420
+ bn_mul_mont_nohw (rp, ap, bp, np, n0, num);
427
421
}
428
- return bn_mul_mont_nohw (rp, ap, bp, np, n0, num);
429
422
}
430
423
#endif
0 commit comments