diff options
author | Shane Lontis <shane.lontis@oracle.com> | 2021-06-03 19:09:38 +1000 |
---|---|---|
committer | Pauli <pauli@openssl.org> | 2021-06-08 15:16:06 +1000 |
commit | f41fd10d90fb5202f4c05f8842b4a4f25afd51d0 (patch) | |
tree | 09106bd79af443731ff67bee224ec5609d632c7a /crypto | |
parent | 5135a9bd9280301a24640a6bf5125c144e28cfdd (diff) |
Add a gettable for provider ciphers to return the EVP_CIPH_RAND_KEY flag
Fixes #15531
DES and TDES set this flag which could possibly be used by applications.
The gettable cipher param OSSL_CIPHER_PARAM_HAS_RAND_KEY has been added.
Note that EVP_CIPHER_CTX_rand_key() uses this flag.
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15606)
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/evp/evp_lib.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/crypto/evp/evp_lib.c b/crypto/evp/evp_lib.c index bb91b22678..0b08c9adfd 100644 --- a/crypto/evp/evp_lib.c +++ b/crypto/evp/evp_lib.c @@ -340,12 +340,12 @@ int EVP_CIPHER_get_type(const EVP_CIPHER *cipher) int evp_cipher_cache_constants(EVP_CIPHER *cipher) { - int ok, aead = 0, custom_iv = 0, cts = 0, multiblock = 0; + int ok, aead = 0, custom_iv = 0, cts = 0, multiblock = 0, randkey = 0; size_t ivlen = 0; size_t blksz = 0; size_t keylen = 0; unsigned int mode = 0; - OSSL_PARAM params[9]; + OSSL_PARAM params[10]; params[0] = OSSL_PARAM_construct_size_t(OSSL_CIPHER_PARAM_BLOCK_SIZE, &blksz); params[1] = OSSL_PARAM_construct_size_t(OSSL_CIPHER_PARAM_IVLEN, &ivlen); @@ -357,7 +357,9 @@ int evp_cipher_cache_constants(EVP_CIPHER *cipher) params[6] = OSSL_PARAM_construct_int(OSSL_CIPHER_PARAM_CTS, &cts); params[7] = OSSL_PARAM_construct_int(OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK, &multiblock); - params[8] = OSSL_PARAM_construct_end(); + params[8] = OSSL_PARAM_construct_int(OSSL_CIPHER_PARAM_HAS_RAND_KEY, + &randkey); + params[9] = OSSL_PARAM_construct_end(); ok = evp_do_ciph_getparams(cipher, params) > 0; if (ok) { cipher->block_size = blksz; @@ -374,6 +376,8 @@ int evp_cipher_cache_constants(EVP_CIPHER *cipher) cipher->flags |= EVP_CIPH_FLAG_TLS1_1_MULTIBLOCK; if (cipher->ccipher != NULL) cipher->flags |= EVP_CIPH_FLAG_CUSTOM_CIPHER; + if (randkey) + cipher->flags |= EVP_CIPH_RAND_KEY; if (OSSL_PARAM_locate_const(EVP_CIPHER_gettable_ctx_params(cipher), OSSL_CIPHER_PARAM_ALGORITHM_ID_PARAMS)) cipher->flags |= EVP_CIPH_FLAG_CUSTOM_ASN1; |