aboutsummaryrefslogtreecommitdiff
path: root/test/rsa_sp800_56b_test.c
diff options
context:
space:
mode:
authorClemens Lang <cllang@redhat.com>2023-10-16 15:30:26 +0200
committerMatt Caswell <matt@openssl.org>2023-10-25 09:26:51 +0100
commit8b268541d9aabee51699aef22963407362830ef9 (patch)
tree97e0b588645924b1f0d44cca06f9583ffbeda400 /test/rsa_sp800_56b_test.c
parentdf5f419b14de9ff47082c42f2a2db6557ceca84f (diff)
downloadopenssl-8b268541d9aabee51699aef22963407362830ef9.zip
openssl-8b268541d9aabee51699aef22963407362830ef9.tar.gz
openssl-8b268541d9aabee51699aef22963407362830ef9.tar.bz2
rsa: Add SP800-56Br2 6.4.1.2.1 (3.c) check
The code did not yet check that the length of the RSA key is positive and even. Signed-off-by: Clemens Lang <cllang@redhat.com> Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com> Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com> (Merged from https://github.com/openssl/openssl/pull/22403)
Diffstat (limited to 'test/rsa_sp800_56b_test.c')
-rw-r--r--test/rsa_sp800_56b_test.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/test/rsa_sp800_56b_test.c b/test/rsa_sp800_56b_test.c
index 7660019..aa58bbb 100644
--- a/test/rsa_sp800_56b_test.c
+++ b/test/rsa_sp800_56b_test.c
@@ -458,6 +458,10 @@ static int test_invalid_keypair(void)
&& TEST_true(BN_add_word(n, 1))
&& TEST_false(ossl_rsa_sp800_56b_check_keypair(key, NULL, -1, 2048))
&& TEST_true(BN_sub_word(n, 1))
+ /* check that validation fails if len(n) is not even */
+ && TEST_true(BN_lshift1(n, n))
+ && TEST_false(ossl_rsa_sp800_56b_check_keypair(key, NULL, -1, 2049))
+ && TEST_true(BN_rshift1(n, n))
/* check p */
&& TEST_true(BN_sub_word(p, 2))
&& TEST_true(BN_mul(n, p, q, ctx))