-
Notifications
You must be signed in to change notification settings - Fork 8k
test: Bluetooth: tester: Add support for EAD peripheral #97098
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
test: Bluetooth: tester: Add support for EAD peripheral #97098
Conversation
Reference to the autopts PR: auto-pts/auto-pts#1539 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds support for Encrypted Advertising Data (EAD) peripheral functionality to the Bluetooth tester, enabling encrypted advertisement qualification tests for auto-PTS.
- Added three new BTP GAP commands for EAD key material management, data encryption, and data decryption
- Implemented functions to handle EAD operations including key storage, encryption, and decryption of advertisement data
- Added corresponding BTP protocol definitions and command structures for EAD operations
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
tests/bluetooth/tester/src/btp_gap.c | Implements EAD functionality with key material storage and encrypt/decrypt functions |
tests/bluetooth/tester/src/btp/btp_gap.h | Defines BTP protocol structures and opcodes for EAD commands |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
c82c748
to
6919db6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks OK to me with some formatting and code style comments
@@ -389,6 +389,7 @@ struct btp_gap_bis_broadcast_cmd { | |||
} __packed; | |||
|
|||
#define BTP_GAP_SET_RPA_TIMEOUT 0x30 | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why this extra line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed idI don't I have done anything there. That empty line been there quite a while. Abd seen to separate two commands
a7eeea1 (Lyle Zhu 2025-07-22 18:17:00 +0800 389) } __packed;
a7eeea1 (Lyle Zhu 2025-07-22 18:17:00 +0800 390)
c8e28d1 (Evgenii Kosenko 2025-02-19 13:55:36 +0200 391) #define BTP_GAP_SET_RPA_TIMEOUT 0x30
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
new commands should be added here
#define BTP_GAP_EAD_DECRYPT_ADV_DATA 0x33 | ||
|
||
#define BTP_GAP_EAD_KEY_SIZE 16 | ||
#define BTP_GAP_EAD_IV_SIZE 8 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typically we name flags with command prefix, ie here it would be
BTP_GAP_EAD_SET_KEY_MATERIAL_KEY_SIZE
BTP_GAP_EAD_SET_KEY_MATERIAL_IV_SIZE
same for structure names (cmd and rp)
struct btp_gap_ead_encrypt_adv_data_cmd
struct btp_gap_ead_decrypt_adv_data_cmd
tests/bluetooth/tester/src/btp_gap.c
Outdated
#if defined(CONFIG_BT_EAD) | ||
{ | ||
.opcode = BTP_GAP_EAD_SET_KEY_MATERIAL, | ||
.expect_len = BTP_HANDLER_LENGTH_VARIABLE, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this command has fixed size
We do actually also have self-tests of BTP and the BT Tester in BSIM now - Might be a good idea to add testing of these commands in a BSIM test |
3507839
to
27202db
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove the guard in the header file :)
} __packed; | ||
|
||
struct btp_gap_ead_encrypt_adv_data_rp { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} __packed; | |
struct btp_gap_ead_encrypt_adv_data_rp { | |
} __packed; | |
struct btp_gap_ead_encrypt_adv_data_rp { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
27202db
to
c316c95
Compare
I will do the bsim test in separate pull request. Saves trouble of retesting all the time but takes so study to do them properly. |
@@ -599,3 +599,34 @@ int tester_gap_padv_stop(struct bt_le_ext_adv *ext_adv); | |||
int tester_gap_padv_create_sync(struct bt_le_per_adv_sync_param *create_params); | |||
int tester_gap_padv_stop_sync(void); | |||
#endif /* defined(CONFIG_BT_EXT_ADV) */ | |||
|
|||
#define BTP_GAP_EAD_SET_KEY_MATERIAL_KEY_SIZE 16 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
al this should be next to other commands definition
return BTP_STATUS_FAILED; | ||
} | ||
|
||
err = bt_ead_encrypt(ead_key_materials.session_key, ead_key_materials.initialization_vector, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @param[out] encrypted_payload Encrypted Ad Data including the Randomizer and
* the MIC. Size must be at least @ref BT_EAD_RANDOMIZER_SIZE + @p
* payload_size + @ref BT_EAD_MIC_SIZE. Use @ref
* BT_EAD_ENCRYPTED_PAYLOAD_SIZE to get the right size.
Should this also be validated ? if if BT_EAD_ENCRYPTED_PAYLOAD_SIZE(cp->adv_data_len) would fit in response? to avoid invalid memory writes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking the same, but figured that with ADV sizes of max 254 and the current MTU of 1024, this wouldn't be an issue, but Ideally we'd ensure that the response size is something like BT_EAD_ENCRYPTED_PAYLOAD_SIZE(UINT8_MAX)
if EAD is enabled (can be done via a a BUILD_ASSERT)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a check on getting in the plain text after verifying that size of message is correct. Maximum seems to be 246
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maximum seems to be 246
Oh yeah, that makes sense, since the encrypted advertising data + MAC needs to be in the LTV
Added three functions to support the EAD peripheral: - Setting and storing key materials for EAD - Encrypting data for EAD advertisements - Decrypting data from EAD advertisements Signed-off-by: Petri Pitkanen <petri.pitkanen@silabs.com>
c316c95
to
1794b7e
Compare
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please move commands definition to proper place in btp.h
This is new auto-pts command needed to encrypted adv qualification