Bluetooth: Add mgmt support for LE Secure Connections LTK types
We need a dedicated LTK type for LTK resulting from a Secure Connections based SMP pairing. This patch adds a new define for it and ensures that both the New LTK event as well as the Load LTKs command supports it. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
This commit is contained in:
parent
d2eb9e10f7
commit
23fb8de376
|
@ -184,6 +184,9 @@ struct mgmt_cp_load_link_keys {
|
||||||
|
|
||||||
#define MGMT_LTK_UNAUTHENTICATED 0x00
|
#define MGMT_LTK_UNAUTHENTICATED 0x00
|
||||||
#define MGMT_LTK_AUTHENTICATED 0x01
|
#define MGMT_LTK_AUTHENTICATED 0x01
|
||||||
|
#define MGMT_LTK_P256_UNAUTH 0x02
|
||||||
|
#define MGMT_LTK_P256_AUTH 0x03
|
||||||
|
#define MGMT_LTK_P256_DEBUG 0x04
|
||||||
|
|
||||||
struct mgmt_ltk_info {
|
struct mgmt_ltk_info {
|
||||||
struct mgmt_addr_info addr;
|
struct mgmt_addr_info addr;
|
||||||
|
|
|
@ -4910,18 +4910,26 @@ static int load_long_term_keys(struct sock *sk, struct hci_dev *hdev,
|
||||||
else
|
else
|
||||||
addr_type = ADDR_LE_DEV_RANDOM;
|
addr_type = ADDR_LE_DEV_RANDOM;
|
||||||
|
|
||||||
if (key->master)
|
|
||||||
type = SMP_LTK;
|
|
||||||
else
|
|
||||||
type = SMP_LTK_SLAVE;
|
|
||||||
|
|
||||||
switch (key->type) {
|
switch (key->type) {
|
||||||
case MGMT_LTK_UNAUTHENTICATED:
|
case MGMT_LTK_UNAUTHENTICATED:
|
||||||
authenticated = 0x00;
|
authenticated = 0x00;
|
||||||
|
type = key->master ? SMP_LTK : SMP_LTK_SLAVE;
|
||||||
break;
|
break;
|
||||||
case MGMT_LTK_AUTHENTICATED:
|
case MGMT_LTK_AUTHENTICATED:
|
||||||
authenticated = 0x01;
|
authenticated = 0x01;
|
||||||
|
type = key->master ? SMP_LTK : SMP_LTK_SLAVE;
|
||||||
break;
|
break;
|
||||||
|
case MGMT_LTK_P256_UNAUTH:
|
||||||
|
authenticated = 0x00;
|
||||||
|
type = SMP_LTK_P256;
|
||||||
|
break;
|
||||||
|
case MGMT_LTK_P256_AUTH:
|
||||||
|
authenticated = 0x01;
|
||||||
|
type = SMP_LTK_P256;
|
||||||
|
break;
|
||||||
|
case MGMT_LTK_P256_DEBUG:
|
||||||
|
authenticated = 0x00;
|
||||||
|
type = SMP_LTK_P256_DEBUG;
|
||||||
default:
|
default:
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -6101,8 +6109,19 @@ void mgmt_new_link_key(struct hci_dev *hdev, struct link_key *key,
|
||||||
|
|
||||||
static u8 mgmt_ltk_type(struct smp_ltk *ltk)
|
static u8 mgmt_ltk_type(struct smp_ltk *ltk)
|
||||||
{
|
{
|
||||||
if (ltk->authenticated)
|
switch (ltk->type) {
|
||||||
return MGMT_LTK_AUTHENTICATED;
|
case SMP_LTK:
|
||||||
|
case SMP_LTK_SLAVE:
|
||||||
|
if (ltk->authenticated)
|
||||||
|
return MGMT_LTK_AUTHENTICATED;
|
||||||
|
return MGMT_LTK_UNAUTHENTICATED;
|
||||||
|
case SMP_LTK_P256:
|
||||||
|
if (ltk->authenticated)
|
||||||
|
return MGMT_LTK_P256_AUTH;
|
||||||
|
return MGMT_LTK_P256_UNAUTH;
|
||||||
|
case SMP_LTK_P256_DEBUG:
|
||||||
|
return MGMT_LTK_P256_DEBUG;
|
||||||
|
}
|
||||||
|
|
||||||
return MGMT_LTK_UNAUTHENTICATED;
|
return MGMT_LTK_UNAUTHENTICATED;
|
||||||
}
|
}
|
||||||
|
|
|
@ -146,8 +146,21 @@ enum {
|
||||||
SMP_STK,
|
SMP_STK,
|
||||||
SMP_LTK,
|
SMP_LTK,
|
||||||
SMP_LTK_SLAVE,
|
SMP_LTK_SLAVE,
|
||||||
|
SMP_LTK_P256,
|
||||||
|
SMP_LTK_P256_DEBUG,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static inline bool smp_ltk_is_sc(struct smp_ltk *key)
|
||||||
|
{
|
||||||
|
switch (key->type) {
|
||||||
|
case SMP_LTK_P256:
|
||||||
|
case SMP_LTK_P256_DEBUG:
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
static inline u8 smp_ltk_sec_level(struct smp_ltk *key)
|
static inline u8 smp_ltk_sec_level(struct smp_ltk *key)
|
||||||
{
|
{
|
||||||
if (key->authenticated)
|
if (key->authenticated)
|
||||||
|
|
Loading…
Reference in New Issue