All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vinicius Costa Gomes <vinicius.gomes@openbossa.org>
To: linux-bluetooth@vger.kernel.org
Cc: Anderson Briglia <anderson.briglia@openbossa.org>,
	Vinicius Costa Gomes <vinicius.gomes@openbossa.org>
Subject: [bluetooth-next v3 06/16] Bluetooth: Add SMP confirmation structs
Date: Tue,  7 Jun 2011 18:46:35 -0300	[thread overview]
Message-ID: <1307483205-1518-7-git-send-email-vinicius.gomes@openbossa.org> (raw)
In-Reply-To: <1307483205-1518-1-git-send-email-vinicius.gomes@openbossa.org>

From: Anderson Briglia <anderson.briglia@openbossa.org>

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>
---
 include/net/bluetooth/l2cap.h |    5 +++++
 net/bluetooth/smp.c           |   17 +++++++++++++++++
 2 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
index 0529d27..36f5b0d 100644
--- a/include/net/bluetooth/l2cap.h
+++ b/include/net/bluetooth/l2cap.h
@@ -379,6 +379,11 @@ struct l2cap_conn {
 
 	__u8		disc_reason;
 
+	__u8		preq[7]; /* SMP Pairing Request */
+	__u8		prsp[7]; /* SMP Pairing Response */
+	__u8		prnd[16]; /* SMP Pairing Random */
+	__u8		pcnf[16]; /* SMP Pairing Confirm */
+
 	struct list_head chan_l;
 	rwlock_t	chan_lock;
 };
diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c
index 57fc7d0..fa22f4a 100644
--- a/net/bluetooth/smp.c
+++ b/net/bluetooth/smp.c
@@ -187,6 +187,8 @@ static void smp_cmd_pairing_req(struct l2cap_conn *conn, struct sk_buff *skb)
 
 	BT_DBG("conn %p", conn);
 
+	conn->preq[0] = SMP_CMD_PAIRING_REQ;
+	memcpy(&conn->preq[1], rp, sizeof(*rp));
 	skb_pull(skb, sizeof(*rp));
 
 	rp->io_capability = 0x00;
@@ -196,17 +198,25 @@ static void smp_cmd_pairing_req(struct l2cap_conn *conn, struct sk_buff *skb)
 	rp->resp_key_dist = 0x00;
 	rp->auth_req &= (SMP_AUTH_BONDING | SMP_AUTH_MITM);
 
+	conn->prsp[0] = SMP_CMD_PAIRING_RSP;
+	memcpy(&conn->prsp[1], rp, sizeof(*rp));
+
 	smp_send_cmd(conn, SMP_CMD_PAIRING_RSP, sizeof(*rp), rp);
 }
 
 static void smp_cmd_pairing_rsp(struct l2cap_conn *conn, struct sk_buff *skb)
 {
+	struct smp_cmd_pairing *rp = (void *) skb->data;
 	struct smp_cmd_pairing_confirm cp;
 
 	BT_DBG("conn %p", conn);
 
 	memset(&cp, 0, sizeof(cp));
 
+	conn->prsp[0] = SMP_CMD_PAIRING_RSP;
+	memcpy(&conn->prsp[1], rp, sizeof(*rp));
+	skb_pull(skb, sizeof(*rp));
+
 	smp_send_cmd(conn, SMP_CMD_PAIRING_CONFIRM, sizeof(cp), &cp);
 }
 
@@ -266,6 +276,9 @@ static void smp_cmd_security_req(struct l2cap_conn *conn, struct sk_buff *skb)
 	cp.resp_key_dist = 0x00;
 	cp.auth_req = rp->auth_req & (SMP_AUTH_BONDING | SMP_AUTH_MITM);
 
+	conn->preq[0] = SMP_CMD_PAIRING_REQ;
+	memcpy(&conn->preq[1], &cp, sizeof(cp));
+
 	smp_send_cmd(conn, SMP_CMD_PAIRING_REQ, sizeof(cp), &cp);
 }
 
@@ -303,6 +316,10 @@ int smp_conn_security(struct l2cap_conn *conn, __u8 sec_level)
 		cp.init_key_dist = 0x00;
 		cp.resp_key_dist = 0x00;
 		cp.auth_req = authreq;
+
+		conn->preq[0] = SMP_CMD_PAIRING_REQ;
+		memcpy(&conn->preq[1], &cp, sizeof(cp));
+
 		smp_send_cmd(conn, SMP_CMD_PAIRING_REQ, sizeof(cp), &cp);
 	} else {
 		struct smp_cmd_security_req cp;
-- 
1.7.5.4


  parent reply	other threads:[~2011-06-07 21:46 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-07 21:46 [bluetooth-next v3 00/16] SMP Just Works implementation Vinicius Costa Gomes
2011-06-07 21:46 ` [bluetooth-next v3 01/16] Bluetooth: Implement the first SMP commands Vinicius Costa Gomes
2011-06-07 21:46 ` [bluetooth-next v3 02/16] Bluetooth: Start SMP procedure Vinicius Costa Gomes
2011-06-07 21:46 ` [bluetooth-next v3 03/16] Bluetooth: Add simple SMP pairing negotiation Vinicius Costa Gomes
2011-06-07 21:46 ` [bluetooth-next v3 04/16] Bluetooth: Add support for using the crypto subsystem Vinicius Costa Gomes
2011-06-07 21:46 ` [bluetooth-next v3 05/16] Bluetooth: Add LE SMP Cryptoolbox functions Vinicius Costa Gomes
2011-06-07 21:46 ` Vinicius Costa Gomes [this message]
2011-06-08 18:46   ` [bluetooth-next v3 06/16] Bluetooth: Add SMP confirmation structs Gustavo F. Padovan
2011-06-09 19:36     ` Gustavo F. Padovan
2011-06-07 21:46 ` [bluetooth-next v3 07/16] Bluetooth: Add SMP confirmation checks methods Vinicius Costa Gomes
2011-06-08  2:26   ` Johan Hedberg
2011-06-08  4:16     ` Luiz Augusto von Dentz
2011-06-08 14:38       ` Vinicius Costa Gomes
2011-06-07 21:46 ` [bluetooth-next v3 08/16] Bluetooth: Add support for LE Start Encryption Vinicius Costa Gomes
2011-06-07 21:46 ` [bluetooth-next v3 09/16] Bluetooth: Remove debug statements Vinicius Costa Gomes
2011-06-07 21:46 ` [bluetooth-next v3 10/16] Bluetooth: Add support for resuming socket when SMP is finished Vinicius Costa Gomes
2011-06-07 21:46 ` [bluetooth-next v3 11/16] Bluetooth: Fix initial security level of LE links Vinicius Costa Gomes
2011-06-07 21:46 ` [bluetooth-next v3 12/16] Bluetooth: Update the security level when link is encrypted Vinicius Costa Gomes
2011-06-07 21:46 ` [bluetooth-next v3 13/16] Bluetooth: Add support for building pairing commands Vinicius Costa Gomes
2011-06-07 21:46 ` [bluetooth-next v3 14/16] Bluetooth: Add support for Pairing features exchange Vinicius Costa Gomes
2011-06-07 21:46 ` [bluetooth-next v3 15/16] Bluetooth: Add support for SMP timeout Vinicius Costa Gomes
2011-06-07 21:46 ` [bluetooth-next v3 16/16] Bluetooth: Add key size checks for SMP Vinicius Costa Gomes

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1307483205-1518-7-git-send-email-vinicius.gomes@openbossa.org \
    --to=vinicius.gomes@openbossa.org \
    --cc=anderson.briglia@openbossa.org \
    --cc=linux-bluetooth@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.