diff options
author | Shane Lontis <shane.lontis@oracle.com> | 2020-09-10 14:01:30 +1000 |
---|---|---|
committer | Pauli <paul.dale@oracle.com> | 2020-09-12 16:46:51 +1000 |
commit | 35e6ea3bdc2741c1818337e75756b45d6a2a6122 (patch) | |
tree | 5e3220d285fb8cbc899c7e7565475c832c00943e /crypto | |
parent | 801ed9edbad11b3f0646b396c672dbae33353de2 (diff) |
keygen: add FIPS error state management to conditional self tests
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/12801)
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/dsa/dsa_key.c | 2 | ||||
-rw-r--r-- | crypto/ec/ec_key.c | 2 | ||||
-rw-r--r-- | crypto/err/openssl.txt | 3 | ||||
-rw-r--r-- | crypto/rsa/rsa_gen.c | 2 |
4 files changed, 8 insertions, 1 deletions
diff --git a/crypto/dsa/dsa_key.c b/crypto/dsa/dsa_key.c index b537ec0b3c..bf9d8a269c 100644 --- a/crypto/dsa/dsa_key.c +++ b/crypto/dsa/dsa_key.c @@ -18,6 +18,7 @@ #include "internal/cryptlib.h" #include <openssl/bn.h> #include <openssl/self_test.h> +#include "prov/providercommon.h" #include "crypto/dsa.h" #include "dsa_local.h" @@ -113,6 +114,7 @@ static int dsa_keygen(DSA *dsa, int pairwise_test) OSSL_SELF_TEST_get_callback(dsa->libctx, &cb, &cbarg); ok = dsa_keygen_pairwise_test(dsa, cb, cbarg); if (!ok) { + ossl_set_error_state(OSSL_SELF_TEST_TYPE_PCT); BN_free(dsa->pub_key); BN_clear_free(dsa->priv_key); dsa->pub_key = NULL; diff --git a/crypto/ec/ec_key.c b/crypto/ec/ec_key.c index 84ce095693..84e1b96c48 100644 --- a/crypto/ec/ec_key.c +++ b/crypto/ec/ec_key.c @@ -21,6 +21,7 @@ #include <openssl/err.h> #include <openssl/engine.h> #include <openssl/self_test.h> +#include "prov/providercommon.h" #include "crypto/bn.h" static int ecdsa_keygen_pairwise_test(EC_KEY *eckey, OSSL_CALLBACK *cb, @@ -330,6 +331,7 @@ int ec_generate_key(OPENSSL_CTX *libctx, EC_KEY *eckey, int pairwise_test) err: /* Step (9): If there is an error return an invalid keypair. */ if (!ok) { + ossl_set_error_state(OSSL_SELF_TEST_TYPE_PCT); BN_clear(eckey->priv_key); if (eckey->pub_key != NULL) EC_POINT_set_to_infinity(group, eckey->pub_key); diff --git a/crypto/err/openssl.txt b/crypto/err/openssl.txt index 6c2e81efb9..35c1dd6bdc 100644 --- a/crypto/err/openssl.txt +++ b/crypto/err/openssl.txt @@ -2877,6 +2877,7 @@ PROV_R_FAILED_TO_GENERATE_KEY:121:failed to generate key PROV_R_FAILED_TO_GET_PARAMETER:103:failed to get parameter PROV_R_FAILED_TO_SET_PARAMETER:104:failed to set parameter PROV_R_FAILED_TO_SIGN:175:failed to sign +PROV_R_FIPS_MODULE_CONDITIONAL_ERROR:227:fips module conditional error PROV_R_FIPS_MODULE_ENTERING_ERROR_STATE:224:fips module entering error state PROV_R_FIPS_MODULE_IN_ERROR_STATE:225:fips module in error state PROV_R_GENERATE_ERROR:191:generate error @@ -2936,7 +2937,7 @@ PROV_R_MODULE_INTEGRITY_FAILURE:214:module integrity failure PROV_R_NOT_A_PRIVATE_KEY:221:not a private key PROV_R_NOT_A_PUBLIC_KEY:220:not a public key PROV_R_NOT_INSTANTIATED:193:not instantiated -PROV_R_NOT_PARAMETERS:224:not parameters +PROV_R_NOT_PARAMETERS:226:not parameters PROV_R_NOT_SUPPORTED:136:not supported PROV_R_NOT_XOF_OR_INVALID_LENGTH:113:not xof or invalid length PROV_R_NO_KEY_SET:114:no key set diff --git a/crypto/rsa/rsa_gen.c b/crypto/rsa/rsa_gen.c index b7a37b77a2..dc4ec0a8d3 100644 --- a/crypto/rsa/rsa_gen.c +++ b/crypto/rsa/rsa_gen.c @@ -24,6 +24,7 @@ #include "internal/cryptlib.h" #include <openssl/bn.h> #include <openssl/self_test.h> +#include "prov/providercommon.h" #include "rsa_local.h" static int rsa_keygen_pairwise_test(RSA *rsa, OSSL_CALLBACK *cb, void *cbarg); @@ -444,6 +445,7 @@ static int rsa_keygen(OPENSSL_CTX *libctx, RSA *rsa, int bits, int primes, OSSL_SELF_TEST_get_callback(libctx, &stcb, &stcbarg); ok = rsa_keygen_pairwise_test(rsa, stcb, stcbarg); if (!ok) { + ossl_set_error_state(OSSL_SELF_TEST_TYPE_PCT); /* Clear intermediate results */ BN_clear_free(rsa->d); BN_clear_free(rsa->p); |