summaryrefslogtreecommitdiff
path: root/lib/libcrypto/rsa/rsa_chk.c
diff options
context:
space:
mode:
authorTheo Buehler <tb@cvs.openbsd.org>2022-01-10 00:03:03 +0000
committerTheo Buehler <tb@cvs.openbsd.org>2022-01-10 00:03:03 +0000
commit599316907cd4d1ae7239ce774bd91d2207231c4d (patch)
tree03028d9ab3d6aa52a2ffa5d5561334011424d3f3 /lib/libcrypto/rsa/rsa_chk.c
parent41168c2138a8cab6680ebc12ec786fc6306a8d17 (diff)
Check that the RSA exponent is neither even nor 1 in RSA_check_key()
Part of OpenSSL commit 464d59a5 ok inoguchi jsing
Diffstat (limited to 'lib/libcrypto/rsa/rsa_chk.c')
-rw-r--r--lib/libcrypto/rsa/rsa_chk.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/libcrypto/rsa/rsa_chk.c b/lib/libcrypto/rsa/rsa_chk.c
index 337728d61e7..807eae084eb 100644
--- a/lib/libcrypto/rsa/rsa_chk.c
+++ b/lib/libcrypto/rsa/rsa_chk.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rsa_chk.c,v 1.14 2022/01/07 09:55:32 tb Exp $ */
+/* $OpenBSD: rsa_chk.c,v 1.15 2022/01/10 00:03:02 tb Exp $ */
/* ====================================================================
* Copyright (c) 1999 The OpenSSL Project. All rights reserved.
*
@@ -81,6 +81,15 @@ RSA_check_key(const RSA *key)
goto err;
}
+ if (BN_is_one(key->e)) {
+ ret = 0;
+ RSAerror(RSA_R_BAD_E_VALUE);
+ }
+ if (!BN_is_odd(key->e)) {
+ ret = 0;
+ RSAerror(RSA_R_BAD_E_VALUE);
+ }
+
/* p prime? */
r = BN_is_prime_ex(key->p, BN_prime_checks, NULL, NULL);
if (r != 1) {