diff options
| author | Eric Biggers <ebiggers@kernel.org> | 2026-03-01 23:59:45 -0800 |
|---|---|---|
| committer | Keith Busch <kbusch@kernel.org> | 2026-03-27 07:35:01 -0700 |
| commit | 4263ca1cae5cebc09ba95375c4a8927bf4b39d49 (patch) | |
| tree | f1f118f61556c4a21329fae5fce7d608431ab559 /include | |
| parent | 4454820b4ee59154d0c271722bbe48bb4f554e3e (diff) | |
nvme-auth: common: add HMAC helper functions
Add some helper functions for computing HMAC-SHA256, HMAC-SHA384, or
HMAC-SHA512 values using the crypto library instead of crypto_shash.
These will enable some significant simplifications and performance
improvements in nvme-auth.
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>
Diffstat (limited to 'include')
| -rw-r--r-- | include/linux/nvme-auth.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/include/linux/nvme-auth.h b/include/linux/nvme-auth.h index 02ca9a7162565..940d0703eb1df 100644 --- a/include/linux/nvme-auth.h +++ b/include/linux/nvme-auth.h @@ -7,6 +7,7 @@ #define _NVME_AUTH_H #include <crypto/kpp.h> +#include <crypto/sha2.h> struct nvme_dhchap_key { size_t len; @@ -23,6 +24,19 @@ const char *nvme_auth_hmac_name(u8 hmac_id); const char *nvme_auth_digest_name(u8 hmac_id); size_t nvme_auth_hmac_hash_len(u8 hmac_id); u8 nvme_auth_hmac_id(const char *hmac_name); +struct nvme_auth_hmac_ctx { + u8 hmac_id; + union { + struct hmac_sha256_ctx sha256; + struct hmac_sha384_ctx sha384; + struct hmac_sha512_ctx sha512; + }; +}; +int nvme_auth_hmac_init(struct nvme_auth_hmac_ctx *hmac, u8 hmac_id, + const u8 *key, size_t key_len); +void nvme_auth_hmac_update(struct nvme_auth_hmac_ctx *hmac, const u8 *data, + size_t data_len); +void nvme_auth_hmac_final(struct nvme_auth_hmac_ctx *hmac, u8 *out); u32 nvme_auth_key_struct_size(u32 key_len); struct nvme_dhchap_key *nvme_auth_extract_key(const char *secret, u8 key_hash); |
