diff options
Diffstat (limited to 'net/bluetooth/amp.c')
-rw-r--r-- | net/bluetooth/amp.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/net/bluetooth/amp.c b/net/bluetooth/amp.c index 8ef912c36224..ea4d5ffc1151 100644 --- a/net/bluetooth/amp.c +++ b/net/bluetooth/amp.c | |||
@@ -16,6 +16,7 @@ | |||
16 | #include <net/bluetooth/hci_core.h> | 16 | #include <net/bluetooth/hci_core.h> |
17 | #include <net/bluetooth/a2mp.h> | 17 | #include <net/bluetooth/a2mp.h> |
18 | #include <net/bluetooth/amp.h> | 18 | #include <net/bluetooth/amp.h> |
19 | #include <crypto/hash.h> | ||
19 | 20 | ||
20 | /* Remote AMP Controllers interface */ | 21 | /* Remote AMP Controllers interface */ |
21 | static void amp_ctrl_get(struct amp_ctrl *ctrl) | 22 | static void amp_ctrl_get(struct amp_ctrl *ctrl) |
@@ -125,6 +126,41 @@ struct hci_conn *phylink_add(struct hci_dev *hdev, struct amp_mgr *mgr, | |||
125 | return hcon; | 126 | return hcon; |
126 | } | 127 | } |
127 | 128 | ||
129 | /* AMP crypto key generation interface */ | ||
130 | static int hmac_sha256(u8 *key, u8 ksize, char *plaintext, u8 psize, u8 *output) | ||
131 | { | ||
132 | int ret = 0; | ||
133 | struct crypto_shash *tfm; | ||
134 | |||
135 | if (!ksize) | ||
136 | return -EINVAL; | ||
137 | |||
138 | tfm = crypto_alloc_shash("hmac(sha256)", 0, 0); | ||
139 | if (IS_ERR(tfm)) { | ||
140 | BT_DBG("crypto_alloc_ahash failed: err %ld", PTR_ERR(tfm)); | ||
141 | return PTR_ERR(tfm); | ||
142 | } | ||
143 | |||
144 | ret = crypto_shash_setkey(tfm, key, ksize); | ||
145 | if (ret) { | ||
146 | BT_DBG("crypto_ahash_setkey failed: err %d", ret); | ||
147 | } else { | ||
148 | struct { | ||
149 | struct shash_desc shash; | ||
150 | char ctx[crypto_shash_descsize(tfm)]; | ||
151 | } desc; | ||
152 | |||
153 | desc.shash.tfm = tfm; | ||
154 | desc.shash.flags = CRYPTO_TFM_REQ_MAY_SLEEP; | ||
155 | |||
156 | ret = crypto_shash_digest(&desc.shash, plaintext, psize, | ||
157 | output); | ||
158 | } | ||
159 | |||
160 | crypto_free_shash(tfm); | ||
161 | return ret; | ||
162 | } | ||
163 | |||
128 | void amp_read_loc_assoc_frag(struct hci_dev *hdev, u8 phy_handle) | 164 | void amp_read_loc_assoc_frag(struct hci_dev *hdev, u8 phy_handle) |
129 | { | 165 | { |
130 | struct hci_cp_read_local_amp_assoc cp; | 166 | struct hci_cp_read_local_amp_assoc cp; |