Skip to content

Commit 2b64d15

Browse files
Brian GixGustavo F. Padovan
authored andcommitted
Bluetooth: Add MITM mechanism to LE-SMP
To achive Man-In-The-Middle (MITM) level security with Low Energy, we have to enable User Passkey Comparison. This commit modifies the hard-coded JUST-WORKS pairing mechanism to support query via the MGMT interface of Passkey comparison and User Confirmation. Signed-off-by: Brian Gix <bgix@codeaurora.org> Acked-by: Marcel Holtmann<marcel@holtmann.org> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
1 parent 371fd83 commit 2b64d15

3 files changed

Lines changed: 211 additions & 22 deletions

File tree

‎include/net/bluetooth/hci_core.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,7 @@ struct hci_conn {
310310
struct hci_dev *hdev;
311311
void *l2cap_data;
312312
void *sco_data;
313+
void *smp_conn;
313314

314315
struct hci_conn *link;
315316

‎include/net/bluetooth/smp.h‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,10 @@ struct smp_cmd_security_req {
115115
#define SMP_MIN_ENC_KEY_SIZE 7
116116
#define SMP_MAX_ENC_KEY_SIZE 16
117117

118+
#define SMP_FLAG_TK_VALID 1
119+
#define SMP_FLAG_CFM_PENDING 2
120+
#define SMP_FLAG_MITM_AUTH 3
121+
118122
struct smp_chan {
119123
struct l2cap_conn *conn;
120124
u8 preq[7]; /* SMP Pairing Request */
@@ -124,6 +128,7 @@ struct smp_chan {
124128
u8 pcnf[16]; /* SMP Pairing Confirm */
125129
u8 tk[16]; /* SMP Temporary Key */
126130
u8 smp_key_size;
131+
unsigned long smp_flags;
127132
struct crypto_blkcipher *tfm;
128133
struct work_struct confirm;
129134
struct work_struct random;
@@ -134,6 +139,7 @@ struct smp_chan {
134139
int smp_conn_security(struct l2cap_conn *conn, __u8 sec_level);
135140
int smp_sig_channel(struct l2cap_conn *conn, struct sk_buff *skb);
136141
int smp_distribute_keys(struct l2cap_conn *conn, __u8 force);
142+
int smp_user_confirm_reply(struct hci_conn *conn, u16 mgmt_op, __le32 passkey);
137143

138144
void smp_chan_destroy(struct l2cap_conn *conn);
139145

0 commit comments

Comments
 (0)