summaryrefslogtreecommitdiffstats
path: root/providers
diff options
context:
space:
mode:
authorShane Lontis <shane.lontis@oracle.com>2020-12-14 05:36:48 +0100
committerPauli <ppzgs1@gmail.com>2021-02-10 03:31:31 +0100
commit36978c19a9a5bfd514b1c6f9db66fda4b39ed2c3 (patch)
tree1b255108eeaa6078bb565b7d7c71f04eca189fe8 /providers
parentChange the ASN1 variant of x942kdf so that it can test acvp data. (diff)
downloadopenssl-36978c19a9a5bfd514b1c6f9db66fda4b39ed2c3.tar.xz
openssl-36978c19a9a5bfd514b1c6f9db66fda4b39ed2c3.zip
Replace MAC flags OSSL_MAC_PARAM_FLAGS with separate param fields.
Fixes #12992 Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/13830)
Diffstat (limited to 'providers')
-rw-r--r--providers/implementations/macs/hmac_prov.c38
1 files changed, 28 insertions, 10 deletions
diff --git a/providers/implementations/macs/hmac_prov.c b/providers/implementations/macs/hmac_prov.c
index 993e36ae34..3f9a862458 100644
--- a/providers/implementations/macs/hmac_prov.c
+++ b/providers/implementations/macs/hmac_prov.c
@@ -83,7 +83,6 @@ static void *hmac_new(void *provctx)
OPENSSL_free(macctx);
return NULL;
}
- /* TODO(3.0) Should we do something more with that context? */
macctx->provctx = provctx;
return macctx;
@@ -239,7 +238,8 @@ static const OSSL_PARAM known_settable_ctx_params[] = {
OSSL_PARAM_utf8_string(OSSL_MAC_PARAM_DIGEST, NULL, 0),
OSSL_PARAM_utf8_string(OSSL_MAC_PARAM_PROPERTIES, NULL, 0),
OSSL_PARAM_octet_string(OSSL_MAC_PARAM_KEY, NULL, 0),
- OSSL_PARAM_int(OSSL_MAC_PARAM_FLAGS, NULL),
+ OSSL_PARAM_int(OSSL_MAC_PARAM_DIGEST_NOINIT, NULL),
+ OSSL_PARAM_int(OSSL_MAC_PARAM_DIGEST_ONESHOT, NULL),
OSSL_PARAM_size_t(OSSL_MAC_PARAM_TLS_DATA_SIZE, NULL),
OSSL_PARAM_END
};
@@ -248,6 +248,23 @@ static const OSSL_PARAM *hmac_settable_ctx_params(ossl_unused void *provctx)
return known_settable_ctx_params;
}
+static int set_flag(const OSSL_PARAM params[], const char *key, int mask,
+ int *flags)
+{
+ const OSSL_PARAM *p = OSSL_PARAM_locate_const(params, key);
+ int flag = 0;
+
+ if (p != NULL) {
+ if (!OSSL_PARAM_get_int(p, &flag))
+ return 0;
+ if (flag == 0)
+ *flags &= ~mask;
+ else
+ *flags |= mask;
+ }
+ return 1;
+}
+
/*
* ALL parameters should be set before init().
*/
@@ -256,19 +273,20 @@ static int hmac_set_ctx_params(void *vmacctx, const OSSL_PARAM params[])
struct hmac_data_st *macctx = vmacctx;
OSSL_LIB_CTX *ctx = PROV_LIBCTX_OF(macctx->provctx);
const OSSL_PARAM *p;
+ int flags = 0;
if (!ossl_prov_digest_load_from_params(&macctx->digest, params, ctx))
return 0;
- /* TODO(3.0) formalize the meaning of "flags", perhaps as other params */
- if ((p = OSSL_PARAM_locate_const(params,
- OSSL_MAC_PARAM_FLAGS)) != NULL) {
- int flags = 0;
-
- if (!OSSL_PARAM_get_int(p, &flags))
- return 0;
+ if (!set_flag(params, OSSL_MAC_PARAM_DIGEST_NOINIT, EVP_MD_CTX_FLAG_NO_INIT,
+ &flags))
+ return 0;
+ if (!set_flag(params, OSSL_MAC_PARAM_DIGEST_ONESHOT, EVP_MD_CTX_FLAG_ONESHOT,
+ &flags))
+ return 0;
+ if (flags)
HMAC_CTX_set_flags(macctx->ctx, flags);
- }
+
if ((p = OSSL_PARAM_locate_const(params, OSSL_MAC_PARAM_KEY)) != NULL) {
if (p->data_type != OSSL_PARAM_OCTET_STRING)
return 0;