mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-24 13:43:38 +00:00
allow to fix local csrk for testing
This commit is contained in:
parent
80c6fa00ac
commit
09222c1170
13
ble/sm.c
13
ble/sm.c
@ -117,6 +117,8 @@ typedef enum {
|
||||
// GLOBAL DATA
|
||||
//
|
||||
|
||||
static uint8_t test_use_fixed_local_csrk;
|
||||
|
||||
// configuration
|
||||
static uint8_t sm_accepted_stk_generation_methods;
|
||||
static uint8_t sm_max_encryption_key_size;
|
||||
@ -1505,6 +1507,11 @@ static void sm_run(void){
|
||||
if (setup->sm_key_distribution_send_set & SM_KEYDIST_FLAG_SIGNING_IDENTIFICATION){
|
||||
setup->sm_key_distribution_send_set &= ~SM_KEYDIST_FLAG_SIGNING_IDENTIFICATION;
|
||||
|
||||
// hack to reproduce test runs
|
||||
if (test_use_fixed_local_csrk){
|
||||
memset(setup->sm_local_csrk, 0xcc, 16);
|
||||
}
|
||||
|
||||
uint8_t buffer[17];
|
||||
buffer[0] = SM_CODE_SIGNING_INFORMATION;
|
||||
log_info("sm: store local CSRK");
|
||||
@ -2280,6 +2287,10 @@ void sm_test_set_irk(sm_key_t irk){
|
||||
sm_persistent_irk_ready = 1;
|
||||
}
|
||||
|
||||
void sm_test_use_fixed_local_csrk(void){
|
||||
test_use_fixed_local_csrk = 1;
|
||||
}
|
||||
|
||||
void sm_init(void){
|
||||
// set some (BTstack default) ER and IR
|
||||
int i;
|
||||
@ -2311,6 +2322,8 @@ void sm_init(void){
|
||||
|
||||
sm_active_connection = 0;
|
||||
|
||||
test_use_fixed_local_csrk = 0;
|
||||
|
||||
// attach to lower layers
|
||||
l2cap_register_fixed_channel(sm_packet_handler, L2CAP_CID_SECURITY_MANAGER_PROTOCOL);
|
||||
}
|
||||
|
3
ble/sm.h
3
ble/sm.h
@ -279,6 +279,9 @@ int sm_address_resolution_lookup(uint8_t addr_type, bd_addr_t addr);
|
||||
int sm_le_device_index(uint16_t handle );
|
||||
/* API_END */
|
||||
|
||||
// testing only
|
||||
void sm_test_use_fixed_local_csrk(void);
|
||||
|
||||
#if defined __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -1494,6 +1494,7 @@ int btstack_main(int argc, const char * argv[]){
|
||||
|
||||
sm_set_encryption_key_size_range(sm_min_key_size, 16);
|
||||
sm_test_set_irk(test_irk);
|
||||
sm_test_use_fixed_local_csrk();
|
||||
|
||||
// setup GATT Client
|
||||
gatt_client_init();
|
||||
|
Loading…
x
Reference in New Issue
Block a user