diff options
author | Eric Biggers <ebiggers@google.com> | 2023-10-28 22:00:40 -0700 |
---|---|---|
committer | Keith Busch <kbusch@kernel.org> | 2023-11-06 08:05:53 -0800 |
commit | 744eac783f9e105358eed05b42dcc5c5789744b3 (patch) | |
tree | 35a2b579ae2e4be169070556b2a577fbb2690b87 /drivers/nvme | |
parent | d2f51b3516dade79269ff45eae2a7668ae711b25 (diff) | |
download | linux-744eac783f9e105358eed05b42dcc5c5789744b3.tar.gz linux-744eac783f9e105358eed05b42dcc5c5789744b3.tar.bz2 linux-744eac783f9e105358eed05b42dcc5c5789744b3.zip |
nvme-auth: use crypto_shash_tfm_digest()
Simplify nvme_auth_augmented_challenge() by using
crypto_shash_tfm_digest() instead of an alloc+init+update+final
sequence. This should also improve performance.
Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Keith Busch <kbusch@kernel.org>
Diffstat (limited to 'drivers/nvme')
-rw-r--r-- | drivers/nvme/common/auth.c | 23 |
1 files changed, 2 insertions, 21 deletions
diff --git a/drivers/nvme/common/auth.c b/drivers/nvme/common/auth.c index a8e87dfbeab2..a23ab5c968b9 100644 --- a/drivers/nvme/common/auth.c +++ b/drivers/nvme/common/auth.c @@ -341,7 +341,6 @@ int nvme_auth_augmented_challenge(u8 hmac_id, u8 *skey, size_t skey_len, u8 *challenge, u8 *aug, size_t hlen) { struct crypto_shash *tfm; - struct shash_desc *desc; u8 *hashed_key; const char *hmac_name; int ret; @@ -369,29 +368,11 @@ int nvme_auth_augmented_challenge(u8 hmac_id, u8 *skey, size_t skey_len, goto out_free_key; } - desc = kmalloc(sizeof(struct shash_desc) + crypto_shash_descsize(tfm), - GFP_KERNEL); - if (!desc) { - ret = -ENOMEM; - goto out_free_hash; - } - desc->tfm = tfm; - ret = crypto_shash_setkey(tfm, hashed_key, hlen); if (ret) - goto out_free_desc; - - ret = crypto_shash_init(desc); - if (ret) - goto out_free_desc; - - ret = crypto_shash_update(desc, challenge, hlen); - if (ret) - goto out_free_desc; + goto out_free_hash; - ret = crypto_shash_final(desc, aug); -out_free_desc: - kfree_sensitive(desc); + ret = crypto_shash_tfm_digest(tfm, challenge, hlen, aug); out_free_hash: crypto_free_shash(tfm); out_free_key: |