diff options
author | Johan Hedberg <johan.hedberg@intel.com> | 2014-05-02 07:19:47 -0400 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2014-12-03 10:51:16 -0500 |
commit | 407cecf6c71e13da04f6b591bdbec76ab9a251c2 (patch) | |
tree | 84ea05ef859c33cfd6cc3827851b555168db7e0b | |
parent | df8e1a4c7339f6447e75430e7c8172deddb489a9 (diff) |
Bluetooth: Add basic support for AES-CMAC
Most of the LE Secure Connections SMP crypto functions build on top of
the AES-CMAC function. This patch adds access to AES-CMAC in the kernel
crypto subsystem by allocating a crypto_hash handle for it in a similar
way that we have one for AES-CBC.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
-rw-r--r-- | net/bluetooth/Kconfig | 1 | ||||
-rw-r--r-- | net/bluetooth/smp.c | 10 |
2 files changed, 11 insertions, 0 deletions
diff --git a/net/bluetooth/Kconfig b/net/bluetooth/Kconfig index 5e97a8ff850b..29bcafc41adf 100644 --- a/net/bluetooth/Kconfig +++ b/net/bluetooth/Kconfig | |||
@@ -10,6 +10,7 @@ menuconfig BT | |||
10 | select CRYPTO | 10 | select CRYPTO |
11 | select CRYPTO_BLKCIPHER | 11 | select CRYPTO_BLKCIPHER |
12 | select CRYPTO_AES | 12 | select CRYPTO_AES |
13 | select CRYPTO_CMAC | ||
13 | select CRYPTO_ECB | 14 | select CRYPTO_ECB |
14 | select CRYPTO_SHA256 | 15 | select CRYPTO_SHA256 |
15 | help | 16 | help |
diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c index d993d7d4fcc8..4fed367da380 100644 --- a/net/bluetooth/smp.c +++ b/net/bluetooth/smp.c | |||
@@ -72,6 +72,7 @@ struct smp_chan { | |||
72 | unsigned long flags; | 72 | unsigned long flags; |
73 | 73 | ||
74 | struct crypto_blkcipher *tfm_aes; | 74 | struct crypto_blkcipher *tfm_aes; |
75 | struct crypto_hash *tfm_cmac; | ||
75 | }; | 76 | }; |
76 | 77 | ||
77 | static inline void swap_buf(const u8 *src, u8 *dst, size_t len) | 78 | static inline void swap_buf(const u8 *src, u8 *dst, size_t len) |
@@ -396,6 +397,7 @@ static void smp_chan_destroy(struct l2cap_conn *conn) | |||
396 | kfree(smp->slave_csrk); | 397 | kfree(smp->slave_csrk); |
397 | 398 | ||
398 | crypto_free_blkcipher(smp->tfm_aes); | 399 | crypto_free_blkcipher(smp->tfm_aes); |
400 | crypto_free_hash(smp->tfm_cmac); | ||
399 | 401 | ||
400 | /* If pairing failed clean up any keys we might have */ | 402 | /* If pairing failed clean up any keys we might have */ |
401 | if (!complete) { | 403 | if (!complete) { |
@@ -861,6 +863,14 @@ static struct smp_chan *smp_chan_create(struct l2cap_conn *conn) | |||
861 | return NULL; | 863 | return NULL; |
862 | } | 864 | } |
863 | 865 | ||
866 | smp->tfm_cmac = crypto_alloc_hash("cmac(aes)", 0, CRYPTO_ALG_ASYNC); | ||
867 | if (IS_ERR(smp->tfm_cmac)) { | ||
868 | BT_ERR("Unable to create CMAC crypto context"); | ||
869 | crypto_free_blkcipher(smp->tfm_aes); | ||
870 | kfree(smp); | ||
871 | return NULL; | ||
872 | } | ||
873 | |||
864 | smp->conn = conn; | 874 | smp->conn = conn; |
865 | chan->data = smp; | 875 | chan->data = smp; |
866 | 876 | ||