Skip to content

Commit d278ba5

Browse files
committed
extmod/nimble: Remove asserts of ediv_rand_present and adjust comments.
Recent versions of NimBLE (since release 1.6.0) removed this variable; see apache/mynewt-nimble@7cc8c08. We never used it except in an assert, so remove those asserts to make the code compatible with newer NimBLE versions (eg for the esp32 port). Signed-off-by: Damien George <[email protected]>
1 parent 919756c commit d278ba5

File tree

1 file changed

+3
-13
lines changed

1 file changed

+3
-13
lines changed

extmod/nimble/modbluetooth_nimble.c

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1911,24 +1911,21 @@ static int ble_secret_store_read(int obj_type, const union ble_store_key *key, u
19111911
// <type=peer,addr,*> (single)
19121912
// Find the entry for this specific peer.
19131913
assert(key->sec.idx == 0);
1914-
assert(!key->sec.ediv_rand_present);
19151914
key_data = (const uint8_t *)&key->sec.peer_addr;
19161915
key_data_len = sizeof(ble_addr_t);
19171916
} else {
19181917
// <type=peer,*> (with index)
19191918
// Iterate all known peers.
1920-
assert(!key->sec.ediv_rand_present);
19211919
key_data = NULL;
19221920
key_data_len = 0;
19231921
}
19241922
break;
19251923
}
19261924
case BLE_STORE_OBJ_TYPE_OUR_SEC: {
1927-
// <type=our,addr,ediv_rand>
1928-
// Find our secret for this remote device, matching this ediv/rand key.
1925+
// <type=our,addr,*>
1926+
// Find our secret for this remote device.
19291927
assert(ble_addr_cmp(&key->sec.peer_addr, BLE_ADDR_ANY)); // Must have address.
19301928
assert(key->sec.idx == 0);
1931-
assert(key->sec.ediv_rand_present);
19321929
key_data = (const uint8_t *)&key->sec.peer_addr;
19331930
key_data_len = sizeof(ble_addr_t);
19341931
break;
@@ -1958,10 +1955,6 @@ static int ble_secret_store_read(int obj_type, const union ble_store_key *key, u
19581955

19591956
DEBUG_printf("ble_secret_store_read: found secret\n");
19601957

1961-
if (obj_type == BLE_STORE_OBJ_TYPE_OUR_SEC) {
1962-
// TODO: Verify ediv_rand matches.
1963-
}
1964-
19651958
return 0;
19661959
}
19671960

@@ -1970,14 +1963,13 @@ static int ble_secret_store_write(int obj_type, const union ble_store_value *val
19701963
switch (obj_type) {
19711964
case BLE_STORE_OBJ_TYPE_PEER_SEC:
19721965
case BLE_STORE_OBJ_TYPE_OUR_SEC: {
1973-
// <type=peer,addr,edivrand>
1966+
// <type=peer,addr,*>
19741967

19751968
struct ble_store_key_sec key_sec;
19761969
const struct ble_store_value_sec *value_sec = &val->sec;
19771970
ble_store_key_from_value_sec(&key_sec, value_sec);
19781971

19791972
assert(ble_addr_cmp(&key_sec.peer_addr, BLE_ADDR_ANY)); // Must have address.
1980-
assert(key_sec.ediv_rand_present);
19811973

19821974
if (!mp_bluetooth_gap_on_set_secret(obj_type, (const uint8_t *)&key_sec.peer_addr, sizeof(ble_addr_t), (const uint8_t *)value_sec, sizeof(struct ble_store_value_sec))) {
19831975
DEBUG_printf("Failed to write key: type=%d\n", obj_type);
@@ -2005,9 +1997,7 @@ static int ble_secret_store_delete(int obj_type, const union ble_store_key *key)
20051997
case BLE_STORE_OBJ_TYPE_PEER_SEC:
20061998
case BLE_STORE_OBJ_TYPE_OUR_SEC: {
20071999
// <type=peer,addr,*>
2008-
20092000
assert(ble_addr_cmp(&key->sec.peer_addr, BLE_ADDR_ANY)); // Must have address.
2010-
// ediv_rand is optional (will not be present for delete).
20112001

20122002
if (!mp_bluetooth_gap_on_set_secret(obj_type, (const uint8_t *)&key->sec.peer_addr, sizeof(ble_addr_t), NULL, 0)) {
20132003
DEBUG_printf("Failed to delete key: type=%d\n", obj_type);

0 commit comments

Comments
 (0)