Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 13 additions & 27 deletions src/nvme/linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@
#define _cleanup_evp_pkey_ctx_ __cleanup__(cleanup_evp_pkey_ctx)

/*
* hkdf_info_printf()
* hkdf_expand_labelf()
*
* Helper function to append variable length label and context to an HkdfLabel
*
Expand All @@ -635,8 +635,8 @@
* Returns the number of bytes appended to the HKDF info buffer, or -1 on an
* error.
*/
__attribute__((format(printf, 2, 3)))
static int hkdf_info_printf(EVP_PKEY_CTX *ctx, char *fmt, ...)
__attribute__((format(printf, 3, 4)))
static int hkdf_expand_label(EVP_PKEY_CTX *ctx, char *label, char *fmt, ...)

Check failure on line 639 in src/nvme/linux.c

View workflow job for this annotation

GitHub Actions / checkpatch review

ERROR: need consistent spacing around '*' (ctx:WxV)

Check failure on line 639 in src/nvme/linux.c

View workflow job for this annotation

GitHub Actions / checkpatch review

WARNING: please, no spaces at the start of a line
{
_cleanup_free_ char *str = NULL;
va_list myargs;
Expand All @@ -651,11 +651,14 @@
if (ret > 255)
return -1;
len = ret;
if (EVP_PKEY_CTX_add1_hkdf_info(ctx, (unsigned char *)&len, 1) <= 0)
if (EVP_PKEY_CTX_add1_hkdf_info(ctx, (unsigned char *)&len, 2) <= 0)
return -1;
if (EVP_PKEY_CTX_add1_hkdf_info(ctx, (unsigned char *)label,
strlen(label)) <= 0)
return -1;
if (EVP_PKEY_CTX_add1_hkdf_info(ctx, (unsigned char *)str, len) <= 0)
return -1;
return (ret + 1);
return (ret + strlen(label) + 2);
}

/*
Expand Down Expand Up @@ -725,20 +728,10 @@
errno = ENOKEY;
return -1;
}
if (EVP_PKEY_CTX_add1_hkdf_info(ctx,
(const unsigned char *)&length, 2) <= 0) {
errno = ENOKEY;
return -1;
}
if (hkdf_info_printf(ctx, "tls13 HostNQN") <= 0) {
errno = ENOKEY;
return -1;
}
if (hkdf_info_printf(ctx, "%s", hostnqn) <= 0) {
if (hkdf_expand_label(ctx, "tls13 HostNQN", %s", hostnqn) <= 0) {

Check failure on line 731 in src/nvme/linux.c

View workflow job for this annotation

GitHub Actions / checkpatch review

ERROR: need consistent spacing around '%' (ctx:WxV)
errno = ENOKEY;
return -1;
}

if (EVP_PKEY_derive(ctx, retained, &key_len) <= 0) {
errno = ENOKEY;
return -1;
Expand Down Expand Up @@ -803,24 +796,17 @@
errno = ENOKEY;
return -1;
}
if (EVP_PKEY_CTX_add1_hkdf_info(ctx,
(const unsigned char *)&length, 2) <= 0) {
errno = ENOKEY;
return -1;
}
if (hkdf_info_printf(ctx, "tls13 nvme-tls-psk") <= 0) {
errno = ENOKEY;
return -1;
}
switch (version) {
case 0:
if (hkdf_info_printf(ctx, "%s", context) <= 0) {
if (hkdf_expand_label(ctx, "tls13 nvme-tls-psk",
"%s", context) <= 0) {
errno = ENOKEY;
return -1;
}
break;
case 1:
if (hkdf_info_printf(ctx, "%02d %s", cipher, context) <= 0) {
if (hkdf_expand_label(ctx, "tls13 nvme-tls-psk"
"%02d %s", cipher, context) <= 0) {

Check failure on line 809 in src/nvme/linux.c

View workflow job for this annotation

GitHub Actions / checkpatch review

WARNING: quoted string split across lines
errno = ENOKEY;
return -1;
}
Expand Down
Loading