Skip to content

Commit 4d8a88c

Browse files
xry111paulidale
authored andcommitted
rsa: fix bn_reduce_once_in_place call for rsaz_mod_exp_avx512_x2
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)
1 parent eea820f commit 4d8a88c

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

crypto/bn/rsaz_exp_x2.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,9 @@ int ossl_rsaz_mod_exp_avx512_x2(BN_ULONG *res1,
257257
from_words52(res1, factor_size, rr1_red);
258258
from_words52(res2, factor_size, rr2_red);
259259

260+
/* bn_reduce_once_in_place expects number of BN_ULONG, not bit size */
261+
factor_size /= sizeof(BN_ULONG) * 8;
262+
260263
bn_reduce_once_in_place(res1, /*carry=*/0, m1, storage, factor_size);
261264
bn_reduce_once_in_place(res2, /*carry=*/0, m2, storage, factor_size);
262265

0 commit comments

Comments
 (0)