diff options
author | Pauli <paul.dale@oracle.com> | 2019-09-04 11:27:08 +0200 |
---|---|---|
committer | Pauli <paul.dale@oracle.com> | 2019-09-04 11:41:22 +0200 |
commit | 7f588d20cd9ed2bb0ee2577a4523453964f532b0 (patch) | |
tree | 02b81ea1b5152c87e1b0ebe802dc2581df6fcfa5 /crypto | |
parent | New function EVP_CIPHER_free() (diff) | |
download | openssl-7f588d20cd9ed2bb0ee2577a4523453964f532b0.tar.xz openssl-7f588d20cd9ed2bb0ee2577a4523453964f532b0.zip |
OSSL_PARAM_construct_utf8_string computes the string length.
If the passed string length is zero, the function computes the string length
from the passed string.
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/9760)
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/crmf/crmf_pbm.c | 2 | ||||
-rw-r--r-- | crypto/evp/p_lib.c | 6 | ||||
-rw-r--r-- | crypto/evp/pkey_mac.c | 13 | ||||
-rw-r--r-- | crypto/kdf/sskdf.c | 3 | ||||
-rw-r--r-- | crypto/kdf/tls1_prf.c | 3 | ||||
-rw-r--r-- | crypto/modes/siv128.c | 3 | ||||
-rw-r--r-- | crypto/params.c | 2 |
7 files changed, 12 insertions, 20 deletions
diff --git a/crypto/crmf/crmf_pbm.c b/crypto/crmf/crmf_pbm.c index aef676f252..a3ac45557d 100644 --- a/crypto/crmf/crmf_pbm.c +++ b/crypto/crmf/crmf_pbm.c @@ -208,7 +208,7 @@ int OSSL_CRMF_pbm_new(const OSSL_CRMF_PBMPARAMETER *pbmp, macparams[0] = OSSL_PARAM_construct_utf8_string(OSSL_MAC_PARAM_DIGEST, - (char *)mdname, strlen(mdname) + 1); + (char *)mdname, 0); macparams[1] = OSSL_PARAM_construct_octet_string(OSSL_MAC_PARAM_KEY, basekey, bklen); if ((mac = EVP_MAC_fetch(NULL, "HMAC", NULL)) == NULL diff --git a/crypto/evp/p_lib.c b/crypto/evp/p_lib.c index 5691fffae3..5ec519d27c 100644 --- a/crypto/evp/p_lib.c +++ b/crypto/evp/p_lib.c @@ -345,14 +345,12 @@ EVP_PKEY *EVP_PKEY_new_CMAC_key(ENGINE *e, const unsigned char *priv, if (engine_id != NULL) params[paramsn++] = OSSL_PARAM_construct_utf8_string(OSSL_MAC_PARAM_ENGINE, - (char *)engine_id, - strlen(engine_id) + 1); + (char *)engine_id, 0); # endif params[paramsn++] = OSSL_PARAM_construct_utf8_string(OSSL_MAC_PARAM_CIPHER, - (char *)cipher_name, - strlen(cipher_name) + 1); + (char *)cipher_name, 0); params[paramsn++] = OSSL_PARAM_construct_octet_string(OSSL_MAC_PARAM_KEY, (char *)priv, len); diff --git a/crypto/evp/pkey_mac.c b/crypto/evp/pkey_mac.c index 05eb2b1b3a..fc600fb845 100644 --- a/crypto/evp/pkey_mac.c +++ b/crypto/evp/pkey_mac.c @@ -279,13 +279,11 @@ static int pkey_mac_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2) params[params_n++] = OSSL_PARAM_construct_utf8_string(OSSL_MAC_PARAM_ENGINE, - engineid, - strlen(engineid) + 1); + engineid, 0); #endif params[params_n++] = OSSL_PARAM_construct_utf8_string(OSSL_MAC_PARAM_CIPHER, - ciphname, - strlen(ciphname) + 1); + ciphname, 0); params[params_n] = OSSL_PARAM_construct_end(); if (!EVP_MAC_CTX_set_params(hctx->ctx, params) @@ -403,17 +401,14 @@ static int pkey_mac_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2) ? NULL : (char *)ENGINE_get_id(ctx->engine); if (engineid != NULL) { - size_t engineid_l = strlen(engineid) + 1; params[params_n++] = OSSL_PARAM_construct_utf8_string(OSSL_MAC_PARAM_ENGINE, - engineid, - engineid_l); + engineid, 0); } #endif params[params_n++] = OSSL_PARAM_construct_utf8_string(OSSL_MAC_PARAM_DIGEST, - mdname, - strlen(mdname) + 1); + mdname, 0); params[params_n++] = OSSL_PARAM_construct_octet_string(OSSL_MAC_PARAM_KEY, key->data, key->length); diff --git a/crypto/kdf/sskdf.c b/crypto/kdf/sskdf.c index 916a06e5a1..b20eff2865 100644 --- a/crypto/kdf/sskdf.c +++ b/crypto/kdf/sskdf.c @@ -223,8 +223,7 @@ static int SSKDF_mac_kdm(EVP_MAC *kdf_mac, const EVP_MD *hmac_md, const char *mdname = EVP_MD_name(hmac_md); params[params_n++] = OSSL_PARAM_construct_utf8_string(OSSL_MAC_PARAM_DIGEST, - (char *)mdname, - strlen(mdname) + 1); + (char *)mdname, 0); } params[params_n++] = OSSL_PARAM_construct_octet_string(OSSL_MAC_PARAM_KEY, (void *)salt, diff --git a/crypto/kdf/tls1_prf.c b/crypto/kdf/tls1_prf.c index f5d2314681..edd7f05ce0 100644 --- a/crypto/kdf/tls1_prf.c +++ b/crypto/kdf/tls1_prf.c @@ -252,8 +252,7 @@ static int tls1_prf_P_hash(const EVP_MD *md, 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_DIGEST, - (char *)mdname, - strlen(mdname) + 1); + (char *)mdname, 0); params[2] = OSSL_PARAM_construct_octet_string(OSSL_MAC_PARAM_KEY, (void *)sec, sec_len); params[3] = OSSL_PARAM_construct_end(); diff --git a/crypto/modes/siv128.c b/crypto/modes/siv128.c index de6a3b853f..1d91ee78ee 100644 --- a/crypto/modes/siv128.c +++ b/crypto/modes/siv128.c @@ -173,8 +173,7 @@ int CRYPTO_siv128_init(SIV128_CONTEXT *ctx, const unsigned char *key, int klen, const char *cbc_name = EVP_CIPHER_name(cbc); params[0] = OSSL_PARAM_construct_utf8_string(OSSL_MAC_PARAM_CIPHER, - (char *)cbc_name, - strlen(cbc_name) + 1); + (char *)cbc_name, 0); params[1] = OSSL_PARAM_construct_octet_string(OSSL_MAC_PARAM_KEY, (void *)key, klen); params[2] = OSSL_PARAM_construct_end(); diff --git a/crypto/params.c b/crypto/params.c index b3fbb12b9b..20082ad90b 100644 --- a/crypto/params.c +++ b/crypto/params.c @@ -808,6 +808,8 @@ int OSSL_PARAM_set_octet_string(OSSL_PARAM *p, const void *val, OSSL_PARAM OSSL_PARAM_construct_utf8_string(const char *key, char *buf, size_t bsize) { + if (buf != NULL && bsize == 0) + bsize = strlen(buf) + 1; return ossl_param_construct(key, OSSL_PARAM_UTF8_STRING, buf, bsize); } |