Bluetooth: Refactor ECC emulation supported commands bits
Refactor the ECC emulation setting the supported command bits in order to group the supported commands together with the implementation of these commands. Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
This commit is contained in:
parent
5412f61ac6
commit
9235b1b8b3
4 changed files with 14 additions and 6 deletions
|
@ -22,6 +22,8 @@
|
|||
#include <bluetooth/buf.h>
|
||||
#include <bluetooth/bluetooth.h>
|
||||
|
||||
#include "../host/hci_ecc.h"
|
||||
|
||||
#include "util/util.h"
|
||||
#include "util/memq.h"
|
||||
#include "hal/ecb.h"
|
||||
|
@ -754,8 +756,7 @@ static void read_supported_commands(struct net_buf *buf, struct net_buf **evt)
|
|||
#endif /* CONFIG_BT_CTLR_PRIVACY */
|
||||
|
||||
#if defined(CONFIG_BT_HCI_RAW) && defined(CONFIG_BT_TINYCRYPT_ECC)
|
||||
/* LE Read Local P256 Public Key and LE Generate DH Key*/
|
||||
rp->commands[34] |= BIT(1) | BIT(2);
|
||||
bt_hci_ecc_supported_commands(rp->commands);
|
||||
#endif /* CONFIG_BT_HCI_RAW && CONFIG_BT_TINYCRYPT_ECC */
|
||||
|
||||
/* LE Read TX Power. */
|
||||
|
|
|
@ -5394,13 +5394,11 @@ static void read_supported_commands_complete(struct net_buf *buf)
|
|||
memcpy(bt_dev.supported_commands, rp->commands,
|
||||
sizeof(bt_dev.supported_commands));
|
||||
|
||||
/*
|
||||
* Report "LE Read Local P-256 Public Key" and "LE Generate DH Key" as
|
||||
/* Report additional HCI commands used for ECDH as
|
||||
* supported if TinyCrypt ECC is used for emulation.
|
||||
*/
|
||||
if (IS_ENABLED(CONFIG_BT_TINYCRYPT_ECC)) {
|
||||
bt_dev.supported_commands[34] |= 0x02;
|
||||
bt_dev.supported_commands[34] |= 0x04;
|
||||
bt_hci_ecc_supported_commands(bt_dev.supported_commands);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -317,6 +317,14 @@ int bt_hci_ecc_send(struct net_buf *buf)
|
|||
return bt_dev.drv->send(buf);
|
||||
}
|
||||
|
||||
void bt_hci_ecc_supported_commands(uint8_t *supported_commands)
|
||||
{
|
||||
/* LE Read Local P-256 Public Key */
|
||||
supported_commands[34] |= BIT(1);
|
||||
/* LE Generate DH Key v1 */
|
||||
supported_commands[34] |= BIT(2);
|
||||
}
|
||||
|
||||
int default_CSPRNG(uint8_t *dst, unsigned int len)
|
||||
{
|
||||
return !bt_rand(dst, len);
|
||||
|
|
|
@ -8,3 +8,4 @@
|
|||
|
||||
void bt_hci_ecc_init(void);
|
||||
int bt_hci_ecc_send(struct net_buf *buf);
|
||||
void bt_hci_ecc_supported_commands(uint8_t *supported_commands);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue