Bluetooth: SMP: Add local random number generation support

The SMP procedures require us to establish a local random number. Use
the HCI_LE_Rand command to generate the necessary 16 bytes (the
command needs to be called twice since it only returns 8 bytes at a
time). Store this number in the SMP context.

To help debugging with various crypto related values add a local h()
helper function for printk/BT_DBG to do hexadecimal conversion.

Change-Id: Id3e8793a77ac635023b3cc3a94e8679170455870
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This commit is contained in:
Johan Hedberg 2015-05-19 21:12:30 +03:00 committed by Anas Nashif
commit a648bbe9a1
3 changed files with 101 additions and 6 deletions

View file

@ -238,6 +238,12 @@ struct bt_hci_rp_le_encrypt {
uint8_t enc_data[16];
} PACK_STRUCT;
#define BT_HCI_OP_LE_RAND BT_OP(BT_OGF_LE, 0x0018)
struct bt_hci_rp_le_rand {
uint8_t status;
uint8_t rand[8];
} PACK_STRUCT;
/* Event definitions */
#define BT_HCI_EVT_DISCONN_COMPLETE 0x05