summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2021-01-20 23:04:53 +0100
committerRichard Levitte <levitte@openssl.org>2021-02-23 13:41:48 +0100
commit9a1c4e41e8d3fd8fe9d1bd8eeb8b1e1df21da37f (patch)
treee7e936eba2359e076f5c73c6b8b24ab22b934386 /include
parent4d4928edd0758753e43294816ae6095975a6e5fa (diff)
downloadopenssl-new-9a1c4e41e8d3fd8fe9d1bd8eeb8b1e1df21da37f.tar.gz
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)
Diffstat (limited to 'include')
-rw-r--r--include/crypto/evp.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/include/crypto/evp.h b/include/crypto/evp.h
index b0e82f6c81..0ed9a02396 100644
--- a/include/crypto/evp.h
+++ b/include/crypto/evp.h
@@ -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 */