Skip to content

Commit 268d006

Browse files
thoh-otcarlescufi
authored andcommitted
Bluetooth: controller: Fix periph enc reject
Chose correct rejection PDU based on features supported on remote peer when rejecting due to missing LTK. Update unit test setup with faking that a feature exchange procedure has run. Signed-off-by: Thomas Ebert Hansen <[email protected]>
1 parent 06feb02 commit 268d006

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

subsys/bluetooth/controller/ll_sw/ull_llcp_enc.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
#include "pdu.h"
2323
#include "ll.h"
24+
#include "ll_feat.h"
2425
#include "ll_settings.h"
2526

2627
#include "lll.h"
@@ -33,6 +34,7 @@
3334
#include "ull_internal.h"
3435
#include "ull_llcp.h"
3536
#include "ull_llcp_internal.h"
37+
#include "ull_llcp_features.h"
3638
#include "ull_conn_internal.h"
3739

3840
#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_DRIVER)
@@ -652,9 +654,12 @@ static struct node_tx *llcp_rp_enc_tx(struct ll_conn *conn, struct proc_ctx *ctx
652654
llcp_pdu_encode_pause_enc_rsp(pdu);
653655
break;
654656
case PDU_DATA_LLCTRL_TYPE_REJECT_IND:
655-
/* TODO(thoh): Select between LL_REJECT_IND and LL_REJECT_EXT_IND */
656-
llcp_pdu_encode_reject_ext_ind(pdu, PDU_DATA_LLCTRL_TYPE_ENC_REQ,
657-
BT_HCI_ERR_PIN_OR_KEY_MISSING);
657+
if (conn->llcp.fex.valid && feature_ext_rej_ind(conn)) {
658+
llcp_pdu_encode_reject_ext_ind(pdu, PDU_DATA_LLCTRL_TYPE_ENC_REQ,
659+
BT_HCI_ERR_PIN_OR_KEY_MISSING);
660+
} else {
661+
llcp_pdu_encode_reject_ind(pdu, BT_HCI_ERR_PIN_OR_KEY_MISSING);
662+
}
658663
break;
659664
default:
660665
LL_ASSERT(0);

tests/bluetooth/controller/ctrl_encrypt/src/main.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
#include "pdu.h"
2525
#include "ll.h"
26+
#include "ll_feat.h"
2627
#include "ll_settings.h"
2728

2829
#include "lll.h"
@@ -93,6 +94,10 @@ struct ll_conn conn;
9394
static void setup(void)
9495
{
9596
test_setup(&conn);
97+
98+
/* Fake that a Feature exchange proceudre has been executed */
99+
conn.llcp.fex.valid = 1U;
100+
conn.llcp.fex.features_used |= LL_FEAT_BIT_EXT_REJ_IND;
96101
}
97102

98103
void ecb_encrypt(uint8_t const *const key_le, uint8_t const *const clear_text_le,

0 commit comments

Comments
 (0)