Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

nvme-auth: add NVME_AUTH_MAX_DIGEST_SIZE constant

Define a NVME_AUTH_MAX_DIGEST_SIZE constant and use it in the
appropriate places.

Acked-by: Ard Biesheuvel <ardb@kernel.org>
Acked-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Eric Biggers <ebiggers@kernel.org>
Signed-off-by: Keith Busch <kbusch@kernel.org>

authored by

Eric Biggers and committed by
Keith Busch
9100a28c 67807fba

+10 -7
+2 -4
drivers/nvme/common/auth.c
··· 15 15 #include <linux/nvme.h> 16 16 #include <linux/nvme-auth.h> 17 17 18 - #define HKDF_MAX_HASHLEN 64 19 - 20 18 static u32 nvme_dhchap_seqnum; 21 19 static DEFINE_MUTEX(nvme_dhchap_mutex); 22 20 ··· 767 769 struct crypto_shash *hmac_tfm; 768 770 const char *hmac_name; 769 771 const char *label = "nvme-tls-psk"; 770 - static const char default_salt[HKDF_MAX_HASHLEN]; 772 + static const char default_salt[NVME_AUTH_MAX_DIGEST_SIZE]; 771 773 size_t prk_len; 772 774 const char *ctx; 773 775 unsigned char *prk, *tls_key; ··· 796 798 goto out_free_shash; 797 799 } 798 800 799 - if (WARN_ON(prk_len > HKDF_MAX_HASHLEN)) { 801 + if (WARN_ON(prk_len > NVME_AUTH_MAX_DIGEST_SIZE)) { 800 802 ret = -EINVAL; 801 803 goto out_free_prk; 802 804 }
+3 -3
drivers/nvme/host/auth.c
··· 38 38 u8 hash_id; 39 39 u8 sc_c; 40 40 size_t hash_len; 41 - u8 c1[64]; 42 - u8 c2[64]; 43 - u8 response[64]; 41 + u8 c1[NVME_AUTH_MAX_DIGEST_SIZE]; 42 + u8 c2[NVME_AUTH_MAX_DIGEST_SIZE]; 43 + u8 response[NVME_AUTH_MAX_DIGEST_SIZE]; 44 44 u8 *ctrl_key; 45 45 u8 *host_key; 46 46 u8 *sess_key;
+5
include/linux/nvme.h
··· 1837 1837 NVME_AUTH_HASH_INVALID = 0xff, 1838 1838 }; 1839 1839 1840 + /* Maximum digest size for any NVME_AUTH_HASH_* value */ 1841 + enum { 1842 + NVME_AUTH_MAX_DIGEST_SIZE = 64, 1843 + }; 1844 + 1840 1845 /* Defined Diffie-Hellman group identifiers for DH-HMAC-CHAP authentication */ 1841 1846 enum { 1842 1847 NVME_AUTH_DHGROUP_NULL = 0x00,