Bluetooth: SMP_BR: Use macros instead of hard code
Define macros for encryption value, #define BT_HCI_ENCRYPTION_OFF 0x00 #define BT_HCI_ENCRYPTION_ON_LE_AES_CCM 0x01 #define BT_HCI_ENCRYPTION_ON_BR_E0 0x01 #define BT_HCI_ENCRYPTION_ON_BR_AES_CCM 0x02 Use the macros to replace the hard code. Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
This commit is contained in:
parent
af86a35b61
commit
d42294d809
3 changed files with 11 additions and 4 deletions
|
@ -2804,6 +2804,12 @@ struct bt_hci_evt_remote_name_req_complete {
|
|||
uint8_t name[248];
|
||||
} __packed;
|
||||
|
||||
/* Encryption Value */
|
||||
#define BT_HCI_ENCRYPTION_OFF 0x00
|
||||
#define BT_HCI_ENCRYPTION_ON_LE_AES_CCM 0x01
|
||||
#define BT_HCI_ENCRYPTION_ON_BR_E0 0x01
|
||||
#define BT_HCI_ENCRYPTION_ON_BR_AES_CCM 0x02
|
||||
|
||||
#define BT_HCI_EVT_ENCRYPT_CHANGE 0x08
|
||||
struct bt_hci_evt_encrypt_change {
|
||||
uint8_t status;
|
||||
|
|
|
@ -155,7 +155,7 @@ bool bt_br_update_sec_level(struct bt_conn *conn)
|
|||
|
||||
if (conn->br.link_key) {
|
||||
if (conn->br.link_key->flags & BT_LINK_KEY_AUTHENTICATED) {
|
||||
if (conn->encrypt == 0x02) {
|
||||
if (conn->encrypt == BT_HCI_ENCRYPTION_ON_BR_AES_CCM) {
|
||||
conn->sec_level = BT_SECURITY_L4;
|
||||
} else {
|
||||
conn->sec_level = BT_SECURITY_L3;
|
||||
|
|
|
@ -958,7 +958,8 @@ static void smp_br_derive_ltk(struct bt_smp_br *smp)
|
|||
return;
|
||||
}
|
||||
|
||||
if (IS_ENABLED(CONFIG_BT_SMP_FORCE_BREDR) && conn->encrypt != 0x02) {
|
||||
if (IS_ENABLED(CONFIG_BT_SMP_FORCE_BREDR) &&
|
||||
conn->encrypt != BT_HCI_ENCRYPTION_ON_BR_AES_CCM) {
|
||||
LOG_WRN("Using P192 Link Key for P256 LTK derivation");
|
||||
}
|
||||
|
||||
|
@ -1164,11 +1165,11 @@ static bool smp_br_pairing_allowed(struct bt_smp_br *smp)
|
|||
return false;
|
||||
}
|
||||
|
||||
if (conn->encrypt == 0x02) {
|
||||
if (conn->encrypt == BT_HCI_ENCRYPTION_ON_BR_AES_CCM) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (IS_ENABLED(CONFIG_BT_SMP_FORCE_BREDR) && conn->encrypt == 0x01) {
|
||||
if (IS_ENABLED(CONFIG_BT_SMP_FORCE_BREDR) && conn->encrypt == BT_HCI_ENCRYPTION_ON_BR_E0) {
|
||||
LOG_WRN("Allowing BR/EDR SMP with P-192 key");
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue