Skip to content

Commit

Permalink
Merge pull request #737 from prashanth-nayak/hkdf_expand_label
Browse files Browse the repository at this point in the history
nvme: Add length field to Hkdf-Expand-Label computation
  • Loading branch information
hreinecke authored Nov 15, 2023
2 parents eb857fb + 0d20547 commit 2dffc6e
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/nvme/linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,7 @@ static int derive_retained_key(const EVP_MD *md, const char *hostnqn,
size_t key_len)
{
EVP_PKEY_CTX *ctx;
uint16_t length = key_len & 0xFFFF;
int ret;

ctx = EVP_PKEY_CTX_new_id(EVP_PKEY_HKDF, NULL);
Expand All @@ -573,6 +574,9 @@ static int derive_retained_key(const EVP_MD *md, const char *hostnqn,
goto out_free_ctx;
if (EVP_PKEY_CTX_set1_hkdf_key(ctx, generated, key_len) <= 0)
goto out_free_ctx;
if (EVP_PKEY_CTX_add1_hkdf_info(ctx,
(const unsigned char *)&length, 2) <= 0)
goto out_free_ctx;
if (EVP_PKEY_CTX_add1_hkdf_info(ctx,
(const unsigned char *)"tls13 ", 6) <= 0)
goto out_free_ctx;
Expand Down Expand Up @@ -600,6 +604,7 @@ static int derive_tls_key(const EVP_MD *md, const char *identity,
unsigned char *psk, size_t key_len)
{
EVP_PKEY_CTX *ctx;
uint16_t length = key_len & 0xFFFF;
int ret;

ctx = EVP_PKEY_CTX_new_id(EVP_PKEY_HKDF, NULL);
Expand All @@ -617,6 +622,9 @@ static int derive_tls_key(const EVP_MD *md, const char *identity,
goto out_free_ctx;
if (EVP_PKEY_CTX_set1_hkdf_key(ctx, retained, key_len) <= 0)
goto out_free_ctx;
if (EVP_PKEY_CTX_add1_hkdf_info(ctx,
(const unsigned char *)&length, 2) <= 0)
goto out_free_ctx;
if (EVP_PKEY_CTX_add1_hkdf_info(ctx,
(const unsigned char *)"tls13 ", 6) <= 0)
goto out_free_ctx;
Expand Down

0 comments on commit 2dffc6e

Please sign in to comment.