diff options
author | Richard Levitte <levitte@openssl.org> | 2019-08-22 12:50:00 +0200 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2019-08-24 13:01:15 +0200 |
commit | 703170d4b9da1b3adc0e4d87719a5156080b2dca (patch) | |
tree | 5223ce61f34a098ed497c54ac271ee26a3d30f15 /crypto | |
parent | 9f57e2184de330e83d0636586e88a8524c513b8e (diff) |
Get rid of the diversity of names for MAC parameters
The EVP_PKEY MAC implementations had a diversity of controls that were
really the same thing. We did reproduce that for the provider based
MACs, but are changing our minds on this. Instead of that, we now use
one parameter name for passing the name of the underlying ciphers or
digests to a MAC implementation, "cipher" and "digest", and one
parameter name for passing the output size of the MAC, "size".
Then we leave it to the EVP_PKEY->EVP_MAC bridge to translate "md"
to "digest", and "digestsize" to "size".
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/9667)
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/crmf/crmf_pbm.c | 2 | ||||
-rw-r--r-- | crypto/evp/mac_lib.c | 2 | ||||
-rw-r--r-- | crypto/evp/p_lib.c | 2 | ||||
-rw-r--r-- | crypto/evp/pkey_mac.c | 22 | ||||
-rw-r--r-- | crypto/kdf/sskdf.c | 4 | ||||
-rw-r--r-- | crypto/kdf/tls1_prf.c | 2 | ||||
-rw-r--r-- | crypto/modes/siv128.c | 2 |
7 files changed, 25 insertions, 11 deletions
diff --git a/crypto/crmf/crmf_pbm.c b/crypto/crmf/crmf_pbm.c index 40c12dd32a..aef676f252 100644 --- a/crypto/crmf/crmf_pbm.c +++ b/crypto/crmf/crmf_pbm.c @@ -207,7 +207,7 @@ int OSSL_CRMF_pbm_new(const OSSL_CRMF_PBMPARAMETER *pbmp, } macparams[0] = - OSSL_PARAM_construct_utf8_string(OSSL_MAC_PARAM_ALGORITHM, + OSSL_PARAM_construct_utf8_string(OSSL_MAC_PARAM_DIGEST, (char *)mdname, strlen(mdname) + 1); macparams[1] = OSSL_PARAM_construct_octet_string(OSSL_MAC_PARAM_KEY, basekey, bklen); diff --git a/crypto/evp/mac_lib.c b/crypto/evp/mac_lib.c index a416687577..cf704ba4fc 100644 --- a/crypto/evp/mac_lib.c +++ b/crypto/evp/mac_lib.c @@ -89,7 +89,7 @@ size_t EVP_MAC_size(EVP_MAC_CTX *ctx) if (ctx->data != NULL) { OSSL_PARAM params[2] = { OSSL_PARAM_END, OSSL_PARAM_END }; - params[0] = OSSL_PARAM_construct_size_t(OSSL_MAC_PARAM_OUTLEN, &sz); + params[0] = OSSL_PARAM_construct_size_t(OSSL_MAC_PARAM_SIZE, &sz); if (ctx->meth->get_ctx_params != NULL) { if (ctx->meth->get_ctx_params(ctx->data, params)) return sz; diff --git a/crypto/evp/p_lib.c b/crypto/evp/p_lib.c index bc573d0208..ead1d4ffd3 100644 --- a/crypto/evp/p_lib.c +++ b/crypto/evp/p_lib.c @@ -345,7 +345,7 @@ EVP_PKEY *EVP_PKEY_new_CMAC_key(ENGINE *e, const unsigned char *priv, (char *)engine_name, strlen(engine_name) + 1); params[paramsn++] = - OSSL_PARAM_construct_utf8_string(OSSL_MAC_PARAM_ALGORITHM, + OSSL_PARAM_construct_utf8_string(OSSL_MAC_PARAM_CIPHER, (char *)cipher_name, strlen(cipher_name) + 1); params[paramsn++] = diff --git a/crypto/evp/pkey_mac.c b/crypto/evp/pkey_mac.c index 07421183ea..3750220416 100644 --- a/crypto/evp/pkey_mac.c +++ b/crypto/evp/pkey_mac.c @@ -281,7 +281,7 @@ static int pkey_mac_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2) engineid, strlen(engineid) + 1); params[params_n++] = - OSSL_PARAM_construct_utf8_string(OSSL_MAC_PARAM_ALGORITHM, + OSSL_PARAM_construct_utf8_string(OSSL_MAC_PARAM_CIPHER, ciphname, strlen(ciphname) + 1); params[params_n] = OSSL_PARAM_construct_end(); @@ -336,13 +336,13 @@ static int pkey_mac_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2) */ params[0] = - OSSL_PARAM_construct_size_t(OSSL_MAC_PARAM_OUTLEN, &size); + OSSL_PARAM_construct_size_t(OSSL_MAC_PARAM_SIZE, &size); if (!EVP_MAC_CTX_set_params(hctx->ctx, params)) return 0; params[0] = - OSSL_PARAM_construct_size_t(OSSL_MAC_PARAM_OUTLEN, &verify); + OSSL_PARAM_construct_size_t(OSSL_MAC_PARAM_SIZE, &verify); if (!EVP_MAC_CTX_get_params(hctx->ctx, params)) return 0; @@ -407,7 +407,7 @@ static int pkey_mac_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2) engineid_l); } params[params_n++] = - OSSL_PARAM_construct_utf8_string(OSSL_MAC_PARAM_ALGORITHM, + OSSL_PARAM_construct_utf8_string(OSSL_MAC_PARAM_DIGEST, mdname, strlen(mdname) + 1); params[params_n++] = @@ -441,6 +441,20 @@ static int pkey_mac_ctrl_str(EVP_PKEY_CTX *ctx, OSSL_PARAM params[2]; int ok = 0; + /* + * Translation of some control names that are equivalent to a single + * parameter name. + * + * "md" and "digest" are the same thing, we use the single "digest" + * + * "digestsize" was a setting control in siphash, but naming wise, + * it's really the same as "size". + */ + if (strcmp(type, "md") == 0) + type = OSSL_MAC_PARAM_DIGEST; + else if (strcmp(type, "digestsize") == 0) + type = OSSL_MAC_PARAM_SIZE; + if (!OSSL_PARAM_allocate_from_text(¶ms[0], EVP_MAC_CTX_settable_params(mac), type, value, strlen(value) + 1)) diff --git a/crypto/kdf/sskdf.c b/crypto/kdf/sskdf.c index a4a9abff5a..916a06e5a1 100644 --- a/crypto/kdf/sskdf.c +++ b/crypto/kdf/sskdf.c @@ -168,7 +168,7 @@ static int kmac_init(EVP_MAC_CTX *ctx, const unsigned char *custom, || kmac_out_len == 64)) return 0; - params[0] = OSSL_PARAM_construct_size_t(OSSL_MAC_PARAM_OUTLEN, + params[0] = OSSL_PARAM_construct_size_t(OSSL_MAC_PARAM_SIZE, &kmac_out_len); if (EVP_MAC_CTX_set_params(ctx, params) <= 0) @@ -222,7 +222,7 @@ static int SSKDF_mac_kdm(EVP_MAC *kdf_mac, const EVP_MD *hmac_md, if (hmac_md != NULL) { const char *mdname = EVP_MD_name(hmac_md); params[params_n++] = - OSSL_PARAM_construct_utf8_string(OSSL_MAC_PARAM_ALGORITHM, + OSSL_PARAM_construct_utf8_string(OSSL_MAC_PARAM_DIGEST, (char *)mdname, strlen(mdname) + 1); } diff --git a/crypto/kdf/tls1_prf.c b/crypto/kdf/tls1_prf.c index b53c417737..f5d2314681 100644 --- a/crypto/kdf/tls1_prf.c +++ b/crypto/kdf/tls1_prf.c @@ -251,7 +251,7 @@ static int tls1_prf_P_hash(const EVP_MD *md, /* TODO(3.0) rethink "flags", also see hmac.c in providers */ mac_flags = EVP_MD_CTX_FLAG_NON_FIPS_ALLOW; params[0] = OSSL_PARAM_construct_int(OSSL_MAC_PARAM_FLAGS, &mac_flags); - params[1] = OSSL_PARAM_construct_utf8_string(OSSL_MAC_PARAM_ALGORITHM, + params[1] = OSSL_PARAM_construct_utf8_string(OSSL_MAC_PARAM_DIGEST, (char *)mdname, strlen(mdname) + 1); params[2] = OSSL_PARAM_construct_octet_string(OSSL_MAC_PARAM_KEY, diff --git a/crypto/modes/siv128.c b/crypto/modes/siv128.c index 626d2f37ec..de6a3b853f 100644 --- a/crypto/modes/siv128.c +++ b/crypto/modes/siv128.c @@ -172,7 +172,7 @@ int CRYPTO_siv128_init(SIV128_CONTEXT *ctx, const unsigned char *key, int klen, OSSL_PARAM params[3]; const char *cbc_name = EVP_CIPHER_name(cbc); - params[0] = OSSL_PARAM_construct_utf8_string(OSSL_MAC_PARAM_ALGORITHM, + params[0] = OSSL_PARAM_construct_utf8_string(OSSL_MAC_PARAM_CIPHER, (char *)cbc_name, strlen(cbc_name) + 1); params[1] = OSSL_PARAM_construct_octet_string(OSSL_MAC_PARAM_KEY, |