Latest update (add quic)
This commit is contained in:
@@ -29,7 +29,7 @@
|
||||
#include "prov/provider_util.h"
|
||||
#include "e_os.h"
|
||||
|
||||
#define HKDF_MAXBUF 1024
|
||||
#define HKDF_MAXBUF 2048
|
||||
|
||||
static OSSL_OP_kdf_newctx_fn kdf_hkdf_new;
|
||||
static OSSL_OP_kdf_freectx_fn kdf_hkdf_free;
|
||||
|
||||
@@ -123,7 +123,7 @@ static void kbkdf_reset(void *vctx)
|
||||
{
|
||||
KBKDF *ctx = (KBKDF *)vctx;
|
||||
|
||||
EVP_MAC_CTX_free(ctx->ctx_init);
|
||||
EVP_MAC_free_ctx(ctx->ctx_init);
|
||||
OPENSSL_clear_free(ctx->context, ctx->context_len);
|
||||
OPENSSL_clear_free(ctx->label, ctx->label_len);
|
||||
OPENSSL_clear_free(ctx->ki, ctx->ki_len);
|
||||
@@ -151,7 +151,7 @@ static int derive(EVP_MAC_CTX *ctx_init, kbkdf_mode mode, unsigned char *iv,
|
||||
for (counter = 1; written < ko_len; counter++) {
|
||||
i = be32(counter);
|
||||
|
||||
ctx = EVP_MAC_CTX_dup(ctx_init);
|
||||
ctx = EVP_MAC_dup_ctx(ctx_init);
|
||||
if (ctx == NULL)
|
||||
goto done;
|
||||
|
||||
@@ -172,13 +172,13 @@ static int derive(EVP_MAC_CTX *ctx_init, kbkdf_mode mode, unsigned char *iv,
|
||||
written += h;
|
||||
|
||||
k_i_len = h;
|
||||
EVP_MAC_CTX_free(ctx);
|
||||
EVP_MAC_free_ctx(ctx);
|
||||
ctx = NULL;
|
||||
}
|
||||
|
||||
ret = 1;
|
||||
done:
|
||||
EVP_MAC_CTX_free(ctx);
|
||||
EVP_MAC_free_ctx(ctx);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -247,9 +247,9 @@ static int kbkdf_set_ctx_params(void *vctx, const OSSL_PARAM params[])
|
||||
NULL, NULL, libctx))
|
||||
return 0;
|
||||
else if (ctx->ctx_init != NULL
|
||||
&& !EVP_MAC_is_a(EVP_MAC_CTX_mac(ctx->ctx_init),
|
||||
&& !EVP_MAC_is_a(EVP_MAC_get_ctx_mac(ctx->ctx_init),
|
||||
OSSL_MAC_NAME_HMAC)
|
||||
&& !EVP_MAC_is_a(EVP_MAC_CTX_mac(ctx->ctx_init),
|
||||
&& !EVP_MAC_is_a(EVP_MAC_get_ctx_mac(ctx->ctx_init),
|
||||
OSSL_MAC_NAME_CMAC)) {
|
||||
ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_MAC);
|
||||
return 0;
|
||||
@@ -288,7 +288,7 @@ static int kbkdf_set_ctx_params(void *vctx, const OSSL_PARAM params[])
|
||||
ctx->ki, ctx->ki_len);
|
||||
mparams[1] = OSSL_PARAM_construct_end();
|
||||
|
||||
if (!EVP_MAC_CTX_set_params(ctx->ctx_init, mparams)
|
||||
if (!EVP_MAC_set_ctx_params(ctx->ctx_init, mparams)
|
||||
|| !EVP_MAC_init(ctx->ctx_init))
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -168,7 +168,7 @@ static int kmac_init(EVP_MAC_CTX *ctx, const unsigned char *custom,
|
||||
(void *)custom, custom_len);
|
||||
params[1] = OSSL_PARAM_construct_end();
|
||||
|
||||
if (!EVP_MAC_CTX_set_params(ctx, params))
|
||||
if (!EVP_MAC_set_ctx_params(ctx, params))
|
||||
return 0;
|
||||
|
||||
/* By default only do one iteration if kmac_out_len is not specified */
|
||||
@@ -186,7 +186,7 @@ static int kmac_init(EVP_MAC_CTX *ctx, const unsigned char *custom,
|
||||
params[0] = OSSL_PARAM_construct_size_t(OSSL_MAC_PARAM_SIZE,
|
||||
&kmac_out_len);
|
||||
|
||||
if (EVP_MAC_CTX_set_params(ctx, params) <= 0)
|
||||
if (EVP_MAC_set_ctx_params(ctx, params) <= 0)
|
||||
return 0;
|
||||
|
||||
/*
|
||||
@@ -233,7 +233,7 @@ static int SSKDF_mac_kdm(EVP_MAC_CTX *ctx_init,
|
||||
(void *)salt, salt_len);
|
||||
*p = OSSL_PARAM_construct_end();
|
||||
|
||||
if (!EVP_MAC_CTX_set_params(ctx_init, params))
|
||||
if (!EVP_MAC_set_ctx_params(ctx_init, params))
|
||||
goto end;
|
||||
|
||||
if (!kmac_init(ctx_init, kmac_custom, kmac_custom_len, kmac_out_len,
|
||||
@@ -256,7 +256,7 @@ static int SSKDF_mac_kdm(EVP_MAC_CTX *ctx_init,
|
||||
c[2] = (unsigned char)((counter >> 8) & 0xff);
|
||||
c[3] = (unsigned char)(counter & 0xff);
|
||||
|
||||
ctx = EVP_MAC_CTX_dup(ctx_init);
|
||||
ctx = EVP_MAC_dup_ctx(ctx_init);
|
||||
if (!(ctx != NULL
|
||||
&& EVP_MAC_update(ctx, c, sizeof(c))
|
||||
&& EVP_MAC_update(ctx, z, z_len)
|
||||
@@ -275,7 +275,7 @@ static int SSKDF_mac_kdm(EVP_MAC_CTX *ctx_init,
|
||||
memcpy(out, mac, len);
|
||||
break;
|
||||
}
|
||||
EVP_MAC_CTX_free(ctx);
|
||||
EVP_MAC_free_ctx(ctx);
|
||||
ctx = NULL;
|
||||
}
|
||||
ret = 1;
|
||||
@@ -285,7 +285,7 @@ end:
|
||||
else
|
||||
OPENSSL_cleanse(mac_buf, sizeof(mac_buf));
|
||||
|
||||
EVP_MAC_CTX_free(ctx);
|
||||
EVP_MAC_free_ctx(ctx);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -303,7 +303,7 @@ static void sskdf_reset(void *vctx)
|
||||
{
|
||||
KDF_SSKDF *ctx = (KDF_SSKDF *)vctx;
|
||||
|
||||
EVP_MAC_CTX_free(ctx->macctx);
|
||||
EVP_MAC_free_ctx(ctx->macctx);
|
||||
ossl_prov_digest_reset(&ctx->digest);
|
||||
OPENSSL_clear_free(ctx->secret, ctx->secret_len);
|
||||
OPENSSL_clear_free(ctx->info, ctx->info_len);
|
||||
@@ -360,7 +360,7 @@ static int sskdf_derive(void *vctx, unsigned char *key, size_t keylen)
|
||||
const unsigned char *custom = NULL;
|
||||
size_t custom_len = 0;
|
||||
int default_salt_len;
|
||||
EVP_MAC *mac = EVP_MAC_CTX_mac(ctx->macctx);
|
||||
EVP_MAC *mac = EVP_MAC_get_ctx_mac(ctx->macctx);
|
||||
|
||||
/*
|
||||
* TODO(3.0) investigate the necessity to have all these controls.
|
||||
|
||||
@@ -116,8 +116,8 @@ static void kdf_tls1_prf_reset(void *vctx)
|
||||
{
|
||||
TLS1_PRF *ctx = (TLS1_PRF *)vctx;
|
||||
|
||||
EVP_MAC_CTX_free(ctx->P_hash);
|
||||
EVP_MAC_CTX_free(ctx->P_sha1);
|
||||
EVP_MAC_free_ctx(ctx->P_hash);
|
||||
EVP_MAC_free_ctx(ctx->P_sha1);
|
||||
OPENSSL_clear_free(ctx->sec, ctx->seclen);
|
||||
OPENSSL_cleanse(ctx->seed, ctx->seedlen);
|
||||
memset(ctx, 0, sizeof(*ctx));
|
||||
@@ -163,7 +163,7 @@ static int kdf_tls1_prf_set_ctx_params(void *vctx, const OSSL_PARAM params[])
|
||||
NULL, SN_sha1, libctx))
|
||||
return 0;
|
||||
} else {
|
||||
EVP_MAC_CTX_free(ctx->P_sha1);
|
||||
EVP_MAC_free_ctx(ctx->P_sha1);
|
||||
if (!ossl_prov_macctx_load_from_params(&ctx->P_hash, params,
|
||||
OSSL_MAC_NAME_HMAC,
|
||||
NULL, NULL, libctx))
|
||||
@@ -280,7 +280,7 @@ static int tls1_prf_P_hash(EVP_MAC_CTX *ctx_init,
|
||||
*p++ = OSSL_PARAM_construct_octet_string(OSSL_MAC_PARAM_KEY,
|
||||
(void *)sec, sec_len);
|
||||
*p = OSSL_PARAM_construct_end();
|
||||
if (!EVP_MAC_CTX_set_params(ctx_init, params))
|
||||
if (!EVP_MAC_set_ctx_params(ctx_init, params))
|
||||
goto err;
|
||||
if (!EVP_MAC_init(ctx_init))
|
||||
goto err;
|
||||
@@ -288,7 +288,7 @@ static int tls1_prf_P_hash(EVP_MAC_CTX *ctx_init,
|
||||
if (chunk == 0)
|
||||
goto err;
|
||||
/* A(0) = seed */
|
||||
ctx_Ai = EVP_MAC_CTX_dup(ctx_init);
|
||||
ctx_Ai = EVP_MAC_dup_ctx(ctx_init);
|
||||
if (ctx_Ai == NULL)
|
||||
goto err;
|
||||
if (seed != NULL && !EVP_MAC_update(ctx_Ai, seed, seed_len))
|
||||
@@ -298,18 +298,18 @@ static int tls1_prf_P_hash(EVP_MAC_CTX *ctx_init,
|
||||
/* calc: A(i) = HMAC_<hash>(secret, A(i-1)) */
|
||||
if (!EVP_MAC_final(ctx_Ai, Ai, &Ai_len, sizeof(Ai)))
|
||||
goto err;
|
||||
EVP_MAC_CTX_free(ctx_Ai);
|
||||
EVP_MAC_free_ctx(ctx_Ai);
|
||||
ctx_Ai = NULL;
|
||||
|
||||
/* calc next chunk: HMAC_<hash>(secret, A(i) + seed) */
|
||||
ctx = EVP_MAC_CTX_dup(ctx_init);
|
||||
ctx = EVP_MAC_dup_ctx(ctx_init);
|
||||
if (ctx == NULL)
|
||||
goto err;
|
||||
if (!EVP_MAC_update(ctx, Ai, Ai_len))
|
||||
goto err;
|
||||
/* save state for calculating next A(i) value */
|
||||
if (olen > chunk) {
|
||||
ctx_Ai = EVP_MAC_CTX_dup(ctx);
|
||||
ctx_Ai = EVP_MAC_dup_ctx(ctx);
|
||||
if (ctx_Ai == NULL)
|
||||
goto err;
|
||||
}
|
||||
@@ -324,15 +324,15 @@ static int tls1_prf_P_hash(EVP_MAC_CTX *ctx_init,
|
||||
}
|
||||
if (!EVP_MAC_final(ctx, out, NULL, olen))
|
||||
goto err;
|
||||
EVP_MAC_CTX_free(ctx);
|
||||
EVP_MAC_free_ctx(ctx);
|
||||
ctx = NULL;
|
||||
out += chunk;
|
||||
olen -= chunk;
|
||||
}
|
||||
ret = 1;
|
||||
err:
|
||||
EVP_MAC_CTX_free(ctx);
|
||||
EVP_MAC_CTX_free(ctx_Ai);
|
||||
EVP_MAC_free_ctx(ctx);
|
||||
EVP_MAC_free_ctx(ctx_Ai);
|
||||
OPENSSL_cleanse(Ai, sizeof(Ai));
|
||||
return ret;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user