From b41e0bf168d855789e287553e873f4ccff28bfb5 Mon Sep 17 00:00:00 2001 From: Zhiguo Zhou Date: Mon, 20 Jan 2025 11:29:50 +0800 Subject: [PATCH] Fix the checks of factor_size/modulus_bitsize MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The factor_size/modulus_bitsize are required to be 1024/1536/2048. Reviewed-by: Neil Horman Reviewed-by: Saša Nedvědický (Merged from https://github.com/openssl/openssl/pull/25751) --- crypto/bn/rsaz_exp_x2.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crypto/bn/rsaz_exp_x2.c b/crypto/bn/rsaz_exp_x2.c index b19cbf62a6..74d87e6b25 100644 --- a/crypto/bn/rsaz_exp_x2.c +++ b/crypto/bn/rsaz_exp_x2.c @@ -231,7 +231,7 @@ int ossl_rsaz_mod_exp_avx512_x2(BN_ULONG *res1, AMM amm = NULL; int avx512ifma = !!ossl_rsaz_avx512ifma_eligible(); - if (factor_size % 512) + if (factor_size != 1024 && factor_size != 1536 && factor_size != 2048) goto err; amm = ossl_rsaz_amm52_x1[(factor_size / 512 - 2) * 2 + avx512ifma]; @@ -382,7 +382,7 @@ int RSAZ_mod_exp_x2_ifma256(BN_ULONG *out, */ # define DAMS(r,a,m,k0) damm((r),(a),(a),(m),(k0)) - if (modulus_bitsize % 512) + if (modulus_bitsize != 1024 && modulus_bitsize != 1536 && modulus_bitsize != 2048) goto err; damm = ossl_rsaz_amm52_x2[(modulus_bitsize / 512 - 2) * 2 + avx512ifma];