From: johan.hedberg@gmail.com
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH v2 02/10] Bluetooth: Add SMP function for generating RPAs
Date: Sun, 23 Feb 2014 16:23:50 +0200 [thread overview]
Message-ID: <1393165438-13610-3-git-send-email-johan.hedberg@gmail.com> (raw)
In-Reply-To: <1393165438-13610-1-git-send-email-johan.hedberg@gmail.com>
From: Johan Hedberg <johan.hedberg@intel.com>
We need a function in smp.c to generate Resolvable Random Addresses in
order to support privacy. The local RPA will need to be generated before
advertising, scanning or connecting and regenerated at periodic
intervals. This patch adds the necessary function for RPA generation.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
net/bluetooth/smp.c | 18 ++++++++++++++++++
net/bluetooth/smp.h | 1 +
2 files changed, 19 insertions(+)
diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c
index ce2c461d07e3..71a15233d1b6 100644
--- a/net/bluetooth/smp.c
+++ b/net/bluetooth/smp.c
@@ -124,6 +124,24 @@ bool smp_irk_matches(struct crypto_blkcipher *tfm, u8 irk[16],
return !memcmp(bdaddr->b, hash, 3);
}
+int smp_generate_rpa(struct crypto_blkcipher *tfm, u8 irk[16], bdaddr_t *rpa)
+{
+ int err;
+
+ get_random_bytes(&rpa->b[3], 3);
+
+ rpa->b[5] &= 0x3f;
+ rpa->b[5] |= 0x40;
+
+ err = smp_ah(tfm, irk, &rpa->b[3], rpa->b);
+ if (err < 0)
+ return err;
+
+ BT_DBG("RPA %pMR", rpa);
+
+ return 0;
+}
+
static int smp_c1(struct crypto_blkcipher *tfm, u8 k[16], u8 r[16],
u8 preq[7], u8 pres[7], u8 _iat, bdaddr_t *ia,
u8 _rat, bdaddr_t *ra, u8 res[16])
diff --git a/net/bluetooth/smp.h b/net/bluetooth/smp.h
index d8cc543f523c..f32f1212f650 100644
--- a/net/bluetooth/smp.h
+++ b/net/bluetooth/smp.h
@@ -152,5 +152,6 @@ void smp_chan_destroy(struct l2cap_conn *conn);
bool smp_irk_matches(struct crypto_blkcipher *tfm, u8 irk[16],
bdaddr_t *bdaddr);
+int smp_generate_rpa(struct crypto_blkcipher *tfm, u8 irk[16], bdaddr_t *rpa);
#endif /* __SMP_H */
--
1.8.5.3
next prev parent reply other threads:[~2014-02-23 14:23 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-23 14:23 [PATCH v2 00/10] LE Privacy support johan.hedberg
2014-02-23 14:23 ` [PATCH v2 01/10] Bluetooth: Set the correct address type in Identity Address Information johan.hedberg
2014-02-23 14:46 ` Marcel Holtmann
2014-02-23 14:23 ` johan.hedberg [this message]
2014-02-23 14:23 ` [PATCH v2 03/10] Bluetooth: Add timer for regenerating local RPA johan.hedberg
2014-02-23 14:23 ` [PATCH v2 04/10] Bluetooth: Add hci_get_own_address_type() convenience function johan.hedberg
2014-02-23 14:23 ` [PATCH v2 05/10] Bluetooth: Use hci_get_own_address_type() when connecting LE johan.hedberg
2014-02-23 14:23 ` [PATCH v2 06/10] Bluetooth: Use hci_get_own_address_type() for enabling advertising johan.hedberg
2014-02-23 14:23 ` [PATCH v2 07/10] Bluetooth: Use hci_get_own_address_type() for initiating LE scan johan.hedberg
2014-02-23 14:23 ` [PATCH v2 08/10] Bluetooth: Don't write static address during power on johan.hedberg
2014-02-23 14:23 ` [PATCH v2 09/10] Bluetooth: Add debugfs entry for RPA regeneration timeout johan.hedberg
2014-02-23 14:23 ` [PATCH v2 10/10] Bluetooth: Add support for Set Privacy command johan.hedberg
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=1393165438-13610-3-git-send-email-johan.hedberg@gmail.com \
--to=johan.hedberg@gmail.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox