drivers/nble: Fix not setting user input expected flag

Fixes SEC/AUT/BV-11 PTS test case at least in GUI mode.

Change-Id: I60e7013f1c66027dabc1b94df87f2da991a5718c
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
This commit is contained in:
Andrei Emeltchenko 2016-07-15 16:33:03 +03:00 committed by Johan Hedberg
parent cc1d2f6ff7
commit 10411ed2f9
1 changed files with 17 additions and 1 deletions

View File

@ -458,6 +458,7 @@ void on_nble_sm_passkey_disp_evt(const struct nble_sm_passkey_disp_evt *ev)
void on_nble_sm_passkey_req_evt(const struct nble_sm_passkey_req_evt *ev)
{
struct bt_conn *conn;
struct bt_smp *smp;
conn = bt_conn_lookup_handle(ev->conn_handle);
if (!conn) {
@ -465,6 +466,17 @@ void on_nble_sm_passkey_req_evt(const struct nble_sm_passkey_req_evt *ev)
return;
}
smp = smp_chan_get(conn);
if (!smp) {
bt_conn_unref(conn);
return;
}
BT_DBG("conn %p key_type %u", conn, ev->key_type);
/* Set user input expected flag */
atomic_set_bit(&smp->flags, SMP_FLAG_USER);
if (ev->key_type == NBLE_GAP_SM_PK_PASSKEY) {
if (nble.auth && nble.auth->passkey_entry) {
nble.auth->passkey_entry(conn);
@ -506,6 +518,8 @@ static void legacy_passkey_entry(struct bt_smp *smp, unsigned int passkey)
.passkey = passkey,
};
BT_DBG("passkey %u", passkey);
nble_security_reply(smp->conn, &pkey);
}
@ -520,7 +534,7 @@ int bt_smp_auth_passkey_entry(struct bt_conn *conn, unsigned int passkey)
{
struct bt_smp *smp;
BT_DBG("");
BT_DBG("passkey %u", passkey);
smp = smp_chan_get(conn);
if (!smp) {
@ -528,6 +542,7 @@ int bt_smp_auth_passkey_entry(struct bt_conn *conn, unsigned int passkey)
}
if (!atomic_test_and_clear_bit(&smp->flags, SMP_FLAG_USER)) {
BT_ERR("Not expected user input");
return -EINVAL;
}
@ -552,6 +567,7 @@ int bt_smp_auth_pairing_confirm(struct bt_conn *conn)
}
if (!atomic_test_and_clear_bit(&smp->flags, SMP_FLAG_USER)) {
BT_ERR("Not expected user input");
return -EINVAL;
}