Skip to content

Commit

Permalink
Bluetooth: use crypto_shash_tfm_digest()
Browse files Browse the repository at this point in the history
Instead of manually allocating a 'struct shash_desc' on the stack and
calling crypto_shash_digest(), switch to using the new helper function
crypto_shash_tfm_digest() which does this for us.

Cc: [email protected]
Signed-off-by: Eric Biggers <[email protected]>
Signed-off-by: Herbert Xu <[email protected]>
  • Loading branch information
ebiggers authored and herbertx committed May 8, 2020
1 parent f80df38 commit ec0bf6e
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions net/bluetooth/smp.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@ static int aes_cmac(struct crypto_shash *tfm, const u8 k[16], const u8 *m,
size_t len, u8 mac[16])
{
uint8_t tmp[16], mac_msb[16], msg_msb[CMAC_MSG_MAX];
SHASH_DESC_ON_STACK(desc, tfm);
int err;

if (len > CMAC_MSG_MAX)
Expand All @@ -181,8 +180,6 @@ static int aes_cmac(struct crypto_shash *tfm, const u8 k[16], const u8 *m,
return -EINVAL;
}

desc->tfm = tfm;

/* Swap key and message from LSB to MSB */
swap_buf(k, tmp, 16);
swap_buf(m, msg_msb, len);
Expand All @@ -196,8 +193,7 @@ static int aes_cmac(struct crypto_shash *tfm, const u8 k[16], const u8 *m,
return err;
}

err = crypto_shash_digest(desc, msg_msb, len, mac_msb);
shash_desc_zero(desc);
err = crypto_shash_tfm_digest(tfm, msg_msb, len, mac_msb);
if (err) {
BT_ERR("Hash computation error %d", err);
return err;
Expand Down

0 comments on commit ec0bf6e

Please sign in to comment.