mirror of https://github.com/openssl/openssl.git
EVP: Implement data-driven translation between known ctrl and OSSL_PARAMs
The idea is to make it as transparent as possible to call things like EVP_PKEY_CTX_ctrl() with a provider backed EVP_PKEY_CTX, or things like EVP_PKEY_get_bn_param() with a legacy EVP_PKEY. All these sorts of calls demand that we translate between ctrl commands and OSSL_PARAM keys, and treat the arguments appropriately. This implementation has it being as data driven as possible, thereby centralizing everything into one table of translation data, which supports both directions. Fixes #13528 Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/13913)
This commit is contained in:
parent
4d4928edd0
commit
9a1c4e41e8
|
@ -15,7 +15,7 @@ SOURCE[../../libcrypto]=$COMMON\
|
|||
evp_pkey.c evp_pbe.c p5_crpt.c p5_crpt2.c pbe_scrypt.c \
|
||||
e_aes_cbc_hmac_sha1.c e_aes_cbc_hmac_sha256.c e_rc4_hmac_md5.c \
|
||||
e_chacha20_poly1305.c \
|
||||
legacy_sha.c
|
||||
legacy_sha.c ctrl_params_translate.c
|
||||
|
||||
# Diverse type specific ctrl functions. They are kinda sorta legacy, kinda
|
||||
# sorta not.
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -705,6 +705,9 @@ struct evp_pkey_st {
|
|||
((ctx)->operation == EVP_PKEY_OP_PARAMGEN \
|
||||
|| (ctx)->operation == EVP_PKEY_OP_KEYGEN)
|
||||
|
||||
#define EVP_PKEY_CTX_IS_FROMDATA_OP(ctx) \
|
||||
((ctx)->operation == EVP_PKEY_OP_FROMDATA)
|
||||
|
||||
#define EVP_PKEY_CTX_IS_KEM_OP(ctx) \
|
||||
((ctx)->operation == EVP_PKEY_OP_ENCAPSULATE \
|
||||
|| (ctx)->operation == EVP_PKEY_OP_DECAPSULATE)
|
||||
|
@ -869,4 +872,18 @@ EVP_PKEY *evp_privatekey_from_binary(int keytype, EVP_PKEY **a,
|
|||
# define EVP_PKEY_STATE_PROVIDER 2
|
||||
int evp_pkey_ctx_state(const EVP_PKEY_CTX *ctx);
|
||||
|
||||
/* These two must ONLY be called for provider side operations */
|
||||
int evp_pkey_ctx_ctrl_to_param(EVP_PKEY_CTX *ctx,
|
||||
int keytype, int optype,
|
||||
int cmd, int p1, void *p2);
|
||||
int evp_pkey_ctx_ctrl_str_to_param(EVP_PKEY_CTX *ctx,
|
||||
const char *name, const char *value);
|
||||
|
||||
/* These two must ONLY be called for legacy operations */
|
||||
int evp_pkey_ctx_set_params_to_ctrl(EVP_PKEY_CTX *ctx, OSSL_PARAM *params);
|
||||
int evp_pkey_ctx_get_params_to_ctrl(EVP_PKEY_CTX *ctx, OSSL_PARAM *params);
|
||||
|
||||
/* This must ONLY be called for legacy EVP_PKEYs */
|
||||
int evp_pkey_get_params_to_ctrl(const EVP_PKEY *pkey, OSSL_PARAM *params);
|
||||
|
||||
#endif /* OSSL_CRYPTO_EVP_H */
|
||||
|
|
Loading…
Reference in New Issue