summaryrefslogtreecommitdiffstats
path: root/crypto/bn
diff options
context:
space:
mode:
authorslontis <shane.lontis@oracle.com>2022-05-30 18:07:40 +1000
committerTomas Mraz <tomas@openssl.org>2022-06-13 10:58:06 +0200
commit7b92153cfb8ffe1c90ac0a02be8e8d271b342caa (patch)
tree9d9337a5aa5e3c34fbea3b3c9f355650137e8cf7 /crypto/bn
parentd5a749b883eb7bcf8bbf28d8be1ef64353b4f7aa (diff)
RSA keygen update: Raise an error if no prime candidate q is found.
Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de> Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/18429) (cherry picked from commit d2399d8cd29f56e6614f0b3db4e7e563a745902a)
Diffstat (limited to 'crypto/bn')
-rw-r--r--crypto/bn/bn_err.c3
-rw-r--r--crypto/bn/bn_rsa_fips186_4.c6
2 files changed, 7 insertions, 2 deletions
diff --git a/crypto/bn/bn_err.c b/crypto/bn/bn_err.c
index 67095a83c0..953be9ed47 100644
--- a/crypto/bn/bn_err.c
+++ b/crypto/bn/bn_err.c
@@ -1,6 +1,6 @@
/*
* Generated by util/mkerr.pl DO NOT EDIT
- * Copyright 1995-2021 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 1995-2022 The OpenSSL Project Authors. All Rights Reserved.
*
* Licensed under the Apache License 2.0 (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
@@ -32,6 +32,7 @@ static const ERR_STRING_DATA BN_str_reasons[] = {
{ERR_PACK(ERR_LIB_BN, 0, BN_R_NOT_A_SQUARE), "not a square"},
{ERR_PACK(ERR_LIB_BN, 0, BN_R_NOT_INITIALIZED), "not initialized"},
{ERR_PACK(ERR_LIB_BN, 0, BN_R_NO_INVERSE), "no inverse"},
+ {ERR_PACK(ERR_LIB_BN, 0, BN_R_NO_PRIME_CANDIDATE), "no prime candidate"},
{ERR_PACK(ERR_LIB_BN, 0, BN_R_NO_SOLUTION), "no solution"},
{ERR_PACK(ERR_LIB_BN, 0, BN_R_NO_SUITABLE_DIGEST), "no suitable digest"},
{ERR_PACK(ERR_LIB_BN, 0, BN_R_PRIVATE_KEY_TOO_LARGE),
diff --git a/crypto/bn/bn_rsa_fips186_4.c b/crypto/bn/bn_rsa_fips186_4.c
index b297ddbda9..5fb50a9cba 100644
--- a/crypto/bn/bn_rsa_fips186_4.c
+++ b/crypto/bn/bn_rsa_fips186_4.c
@@ -349,7 +349,11 @@ int ossl_bn_rsa_fips186_4_derive_prime(BIGNUM *Y, BIGNUM *X, const BIGNUM *Xin,
goto err;
}
/* (Step 8-10) */
- if (++i >= imax || !BN_add(Y, Y, r1r2x2))
+ if (++i >= imax) {
+ ERR_raise(ERR_LIB_BN, BN_R_NO_PRIME_CANDIDATE);
+ goto err;
+ }
+ if (!BN_add(Y, Y, r1r2x2))
goto err;
}
}