mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2025-01-09 15:29:16 +00:00
Bluetooth: use crypto_shash_tfm_digest()
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: linux-bluetooth@vger.kernel.org Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
parent
f80df38512
commit
ec0bf6edc4
@ -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])
|
size_t len, u8 mac[16])
|
||||||
{
|
{
|
||||||
uint8_t tmp[16], mac_msb[16], msg_msb[CMAC_MSG_MAX];
|
uint8_t tmp[16], mac_msb[16], msg_msb[CMAC_MSG_MAX];
|
||||||
SHASH_DESC_ON_STACK(desc, tfm);
|
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
if (len > CMAC_MSG_MAX)
|
if (len > CMAC_MSG_MAX)
|
||||||
@ -181,8 +180,6 @@ static int aes_cmac(struct crypto_shash *tfm, const u8 k[16], const u8 *m,
|
|||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
desc->tfm = tfm;
|
|
||||||
|
|
||||||
/* Swap key and message from LSB to MSB */
|
/* Swap key and message from LSB to MSB */
|
||||||
swap_buf(k, tmp, 16);
|
swap_buf(k, tmp, 16);
|
||||||
swap_buf(m, msg_msb, len);
|
swap_buf(m, msg_msb, len);
|
||||||
@ -196,8 +193,7 @@ static int aes_cmac(struct crypto_shash *tfm, const u8 k[16], const u8 *m,
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = crypto_shash_digest(desc, msg_msb, len, mac_msb);
|
err = crypto_shash_tfm_digest(tfm, msg_msb, len, mac_msb);
|
||||||
shash_desc_zero(desc);
|
|
||||||
if (err) {
|
if (err) {
|
||||||
BT_ERR("Hash computation error %d", err);
|
BT_ERR("Hash computation error %d", err);
|
||||||
return err;
|
return err;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user