Skip to content

Commit

Permalink
rsa: fix bn_reduce_once_in_place call for rsaz_mod_exp_avx512_x2
Browse files Browse the repository at this point in the history
bn_reduce_once_in_place expects the number of BN_ULONG, but factor_size
is moduli bit size.

Fixes #18625.

Signed-off-by: Xi Ruoyao <xry111@xry111.site>

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from #18626)
  • Loading branch information
xry111 authored and paulidale committed Jun 23, 2022
1 parent eea820f commit 4d8a88c
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions crypto/bn/rsaz_exp_x2.c
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,9 @@ int ossl_rsaz_mod_exp_avx512_x2(BN_ULONG *res1,
from_words52(res1, factor_size, rr1_red);
from_words52(res2, factor_size, rr2_red);

/* bn_reduce_once_in_place expects number of BN_ULONG, not bit size */
factor_size /= sizeof(BN_ULONG) * 8;

bn_reduce_once_in_place(res1, /*carry=*/0, m1, storage, factor_size);
bn_reduce_once_in_place(res2, /*carry=*/0, m2, storage, factor_size);

Expand Down

0 comments on commit 4d8a88c

Please sign in to comment.