Commit f01ead315785768cdb6e928646f90a47640bcdd9
Committed by
Gustavo F. Padovan
1 parent
d22ef0bc83
Exists in
master
and in
6 other branches
Bluetooth: Add SMP confirmation structs
This patch adds initial support for verifying the confirmation value that the remote side has sent. Signed-off-by: Anderson Briglia <anderson.briglia@openbossa.org> Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@openbossa.org> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Showing 2 changed files with 22 additions and 0 deletions Side-by-side Diff
include/net/bluetooth/l2cap.h
... | ... | @@ -395,6 +395,11 @@ |
395 | 395 | |
396 | 396 | __u8 disc_reason; |
397 | 397 | |
398 | + __u8 preq[7]; /* SMP Pairing Request */ | |
399 | + __u8 prsp[7]; /* SMP Pairing Response */ | |
400 | + __u8 prnd[16]; /* SMP Pairing Random */ | |
401 | + __u8 pcnf[16]; /* SMP Pairing Confirm */ | |
402 | + | |
398 | 403 | struct list_head chan_l; |
399 | 404 | rwlock_t chan_lock; |
400 | 405 | }; |
net/bluetooth/smp.c
... | ... | @@ -187,6 +187,8 @@ |
187 | 187 | |
188 | 188 | BT_DBG("conn %p", conn); |
189 | 189 | |
190 | + conn->preq[0] = SMP_CMD_PAIRING_REQ; | |
191 | + memcpy(&conn->preq[1], rp, sizeof(*rp)); | |
190 | 192 | skb_pull(skb, sizeof(*rp)); |
191 | 193 | |
192 | 194 | rp->io_capability = 0x00; |
193 | 195 | |
194 | 196 | |
... | ... | @@ -196,17 +198,25 @@ |
196 | 198 | rp->resp_key_dist = 0x00; |
197 | 199 | rp->auth_req &= (SMP_AUTH_BONDING | SMP_AUTH_MITM); |
198 | 200 | |
201 | + conn->prsp[0] = SMP_CMD_PAIRING_RSP; | |
202 | + memcpy(&conn->prsp[1], rp, sizeof(*rp)); | |
203 | + | |
199 | 204 | smp_send_cmd(conn, SMP_CMD_PAIRING_RSP, sizeof(*rp), rp); |
200 | 205 | } |
201 | 206 | |
202 | 207 | static void smp_cmd_pairing_rsp(struct l2cap_conn *conn, struct sk_buff *skb) |
203 | 208 | { |
209 | + struct smp_cmd_pairing *rp = (void *) skb->data; | |
204 | 210 | struct smp_cmd_pairing_confirm cp; |
205 | 211 | |
206 | 212 | BT_DBG("conn %p", conn); |
207 | 213 | |
208 | 214 | memset(&cp, 0, sizeof(cp)); |
209 | 215 | |
216 | + conn->prsp[0] = SMP_CMD_PAIRING_RSP; | |
217 | + memcpy(&conn->prsp[1], rp, sizeof(*rp)); | |
218 | + skb_pull(skb, sizeof(*rp)); | |
219 | + | |
210 | 220 | smp_send_cmd(conn, SMP_CMD_PAIRING_CONFIRM, sizeof(cp), &cp); |
211 | 221 | } |
212 | 222 | |
... | ... | @@ -266,6 +276,9 @@ |
266 | 276 | cp.resp_key_dist = 0x00; |
267 | 277 | cp.auth_req = rp->auth_req & (SMP_AUTH_BONDING | SMP_AUTH_MITM); |
268 | 278 | |
279 | + conn->preq[0] = SMP_CMD_PAIRING_REQ; | |
280 | + memcpy(&conn->preq[1], &cp, sizeof(cp)); | |
281 | + | |
269 | 282 | smp_send_cmd(conn, SMP_CMD_PAIRING_REQ, sizeof(cp), &cp); |
270 | 283 | } |
271 | 284 | |
... | ... | @@ -303,6 +316,10 @@ |
303 | 316 | cp.init_key_dist = 0x00; |
304 | 317 | cp.resp_key_dist = 0x00; |
305 | 318 | cp.auth_req = authreq; |
319 | + | |
320 | + conn->preq[0] = SMP_CMD_PAIRING_REQ; | |
321 | + memcpy(&conn->preq[1], &cp, sizeof(cp)); | |
322 | + | |
306 | 323 | smp_send_cmd(conn, SMP_CMD_PAIRING_REQ, sizeof(cp), &cp); |
307 | 324 | } else { |
308 | 325 | struct smp_cmd_security_req cp; |