diff options
author | Andrei Emeltchenko <andrei.emeltchenko@intel.com> | 2015-05-15 16:46:20 +0300 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@intel.com> | 2015-05-17 10:39:08 +0300 |
commit | 9626d1e5b63916b80989ef6926b0d12d4ffe33b0 (patch) | |
tree | 8b5473710a5f5f73eee11c28a93fed843c05f779 /emulator/btdev.c | |
parent | 1c8f39a843bb1326a7b547b1d178bdec1ccfa44c (diff) | |
download | bluez-9626d1e5b63916b80989ef6926b0d12d4ffe33b0.tar.gz |
btdev: Refactor Le Rand using Linux crypto infrastructure
Use standard Linux crypto infrastructure for emulating HCI LE Rand
command.
Diffstat (limited to 'emulator/btdev.c')
-rw-r--r-- | emulator/btdev.c | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/emulator/btdev.c b/emulator/btdev.c index 18edac605..f4108b30b 100644 --- a/emulator/btdev.c +++ b/emulator/btdev.c @@ -2895,6 +2895,19 @@ static void default_cmd(struct btdev *btdev, uint16_t opcode, cmd_complete(btdev, opcode, &lenc, sizeof(lenc)); break; + case BT_HCI_CMD_LE_RAND: + if (btdev->type == BTDEV_TYPE_BREDR) + goto unsupported; + if (!bt_crypto_random_bytes(btdev->crypto, + (uint8_t *)&lr.number, 8)) { + cmd_status(btdev, BT_HCI_ERR_COMMAND_DISALLOWED, + opcode); + break; + } + lr.status = BT_HCI_ERR_SUCCESS; + cmd_complete(btdev, opcode, &lr, sizeof(lr)); + break; + case BT_HCI_CMD_LE_READ_SUPPORTED_STATES: if (btdev->type == BTDEV_TYPE_BREDR) goto unsupported; @@ -2923,14 +2936,6 @@ static void default_cmd(struct btdev *btdev, uint16_t opcode, cmd_complete(btdev, opcode, &status, sizeof(status)); break; - case BT_HCI_CMD_LE_RAND: - if (btdev->type == BTDEV_TYPE_BREDR) - goto unsupported; - lr.status = BT_HCI_ERR_SUCCESS; - lr.number = rand(); - cmd_complete(btdev, opcode, &lr, sizeof(lr)); - break; - case BT_HCI_CMD_LE_READ_REMOTE_FEATURES: if (btdev->type == BTDEV_TYPE_BREDR) goto unsupported; |