diff options
author | Matt Caswell <matt@openssl.org> | 2020-08-10 09:16:01 +0100 |
---|---|---|
committer | Pauli <paul.dale@oracle.com> | 2020-08-29 17:40:10 +1000 |
commit | 5d51925a90734226f804a7b928326f8ba4bd0434 (patch) | |
tree | 81c1553c0f7731f334409c6131b4c23aa8cdd984 /crypto/evp | |
parent | 1bf625040c9a1f02782c9b4f993e1a58e6e70448 (diff) |
Convert EVP_PKEY_CTX_set_mac_key() into a function
Previously it was a macro. We now make it into a function that is params
aware.
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/12637)
Diffstat (limited to 'crypto/evp')
-rw-r--r-- | crypto/evp/pmeth_lib.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/crypto/evp/pmeth_lib.c b/crypto/evp/pmeth_lib.c index efec516ac2..1d5585583e 100644 --- a/crypto/evp/pmeth_lib.c +++ b/crypto/evp/pmeth_lib.c @@ -844,7 +844,7 @@ static int evp_pkey_ctx_set1_octet_string(EVP_PKEY_CTX *ctx, int fallback, { OSSL_PARAM octet_string_params[2], *p = octet_string_params; - if (ctx == NULL || !EVP_PKEY_CTX_IS_DERIVE_OP(ctx)) { + if (ctx == NULL || (ctx->operation & op) == 0) { ERR_raise(ERR_LIB_EVP, EVP_R_COMMAND_NOT_SUPPORTED); /* Uses the same return values as EVP_PKEY_CTX_ctrl */ return -2; @@ -1026,6 +1026,16 @@ int EVP_PKEY_CTX_set_scrypt_maxmem_bytes(EVP_PKEY_CTX *ctx, maxmem_bytes); } +int EVP_PKEY_CTX_set_mac_key(EVP_PKEY_CTX *ctx, const unsigned char *key, + int keylen) +{ + return evp_pkey_ctx_set1_octet_string(ctx, ctx->op.keymgmt.genctx == NULL, + OSSL_PKEY_PARAM_PRIV_KEY, + EVP_PKEY_OP_KEYGEN, + EVP_PKEY_CTRL_SET_MAC_KEY, + key, keylen); +} + static int legacy_ctrl_to_param(EVP_PKEY_CTX *ctx, int keytype, int optype, int cmd, int p1, void *p2) { |