Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Bluetooth: Remove HCI prefix from SMP LTK defines

The LTK type has really nothing to do with HCI so it makes more sense to
have these in smp.h than hci.h. This patch moves the defines to smp.h
and removes the HCI_ prefix in the same go.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>

authored by

Johan Hedberg and committed by
Marcel Holtmann
2ceba539 7d5843b7

+16 -13
-4
include/net/bluetooth/hci.h
··· 347 347 #define HCI_LK_CHANGED_COMBINATION 0x06 348 348 #define HCI_LK_UNAUTH_COMBINATION_P256 0x07 349 349 #define HCI_LK_AUTH_COMBINATION_P256 0x08 350 - /* The spec doesn't define types for SMP keys, the _MASTER suffix is implied */ 351 - #define HCI_SMP_STK 0x80 352 - #define HCI_SMP_LTK 0x82 353 - #define HCI_SMP_LTK_SLAVE 0x83 354 350 355 351 /* Long Term Key types */ 356 352 #define HCI_LTK_UNAUTH 0x00
+1 -1
net/bluetooth/hci_core.c
··· 2974 2974 2975 2975 static bool ltk_type_master(u8 type) 2976 2976 { 2977 - if (type == HCI_SMP_STK || type == HCI_SMP_LTK) 2977 + if (type == SMP_STK || type == SMP_LTK) 2978 2978 return true; 2979 2979 2980 2980 return false;
+2 -1
net/bluetooth/hci_event.c
··· 32 32 33 33 #include "a2mp.h" 34 34 #include "amp.h" 35 + #include "smp.h" 35 36 36 37 /* Handle HCI Event packets */ 37 38 ··· 4242 4241 * distribute the keys. Later, security can be re-established 4243 4242 * using a distributed LTK. 4244 4243 */ 4245 - if (ltk->type == HCI_SMP_STK) { 4244 + if (ltk->type == SMP_STK) { 4246 4245 list_del(&ltk->list); 4247 4246 kfree(ltk); 4248 4247 }
+3 -3
net/bluetooth/mgmt.c
··· 4550 4550 addr_type = ADDR_LE_DEV_RANDOM; 4551 4551 4552 4552 if (key->master) 4553 - type = HCI_SMP_LTK; 4553 + type = SMP_LTK; 4554 4554 else 4555 - type = HCI_SMP_LTK_SLAVE; 4555 + type = SMP_LTK_SLAVE; 4556 4556 4557 4557 switch (key->type) { 4558 4558 case MGMT_LTK_UNAUTHENTICATED: ··· 5279 5279 ev.key.ediv = key->ediv; 5280 5280 ev.key.rand = key->rand; 5281 5281 5282 - if (key->type == HCI_SMP_LTK) 5282 + if (key->type == SMP_LTK) 5283 5283 ev.key.master = 1; 5284 5284 5285 5285 memcpy(ev.key.val, key->val, sizeof(key->val));
+3 -4
net/bluetooth/smp.c
··· 573 573 * STK never needs to be stored). 574 574 */ 575 575 hci_add_ltk(hcon->hdev, &hcon->dst, hcon->dst_type, 576 - HCI_SMP_STK, auth, stk, smp->enc_key_size, 577 - ediv, rand); 576 + SMP_STK, auth, stk, smp->enc_key_size, ediv, rand); 578 577 } 579 578 580 579 return 0; ··· 1026 1027 1027 1028 hci_dev_lock(hdev); 1028 1029 authenticated = (hcon->sec_level == BT_SECURITY_HIGH); 1029 - ltk = hci_add_ltk(hdev, &hcon->dst, hcon->dst_type, HCI_SMP_LTK, 1030 + ltk = hci_add_ltk(hdev, &hcon->dst, hcon->dst_type, SMP_LTK, 1030 1031 authenticated, smp->tk, smp->enc_key_size, 1031 1032 rp->ediv, rp->rand); 1032 1033 smp->ltk = ltk; ··· 1342 1343 1343 1344 authenticated = hcon->sec_level == BT_SECURITY_HIGH; 1344 1345 ltk = hci_add_ltk(hdev, &hcon->dst, hcon->dst_type, 1345 - HCI_SMP_LTK_SLAVE, authenticated, enc.ltk, 1346 + SMP_LTK_SLAVE, authenticated, enc.ltk, 1346 1347 smp->enc_key_size, ediv, rand); 1347 1348 smp->slave_ltk = ltk; 1348 1349
+7
net/bluetooth/smp.h
··· 116 116 #define SMP_MIN_ENC_KEY_SIZE 7 117 117 #define SMP_MAX_ENC_KEY_SIZE 16 118 118 119 + /* LTK types used in internal storage (struct smp_ltk) */ 120 + enum { 121 + SMP_STK, 122 + SMP_LTK, 123 + SMP_LTK_SLAVE, 124 + }; 125 + 119 126 /* SMP Commands */ 120 127 bool smp_sufficient_security(struct hci_conn *hcon, u8 sec_level); 121 128 int smp_conn_security(struct hci_conn *hcon, __u8 sec_level);