Merge branch 'bugfix/generate_value_0_when_prov_auth_v3.3' into 'release/v3.3'

ble_mesh: stack: Fix provisioning input or output count number should be at least 1 (v3.3)

See merge request espressif/esp-idf!13483
This commit is contained in:
Jiang Jiang Jian 2021-05-08 12:53:48 +00:00
commit 61a1e0d5c9
2 changed files with 23 additions and 2 deletions

View File

@ -753,7 +753,18 @@ static int prov_auth(u8_t method, u8_t action, u8_t size)
u32_t num = 0U;
bt_mesh_rand(&num, sizeof(num));
num %= div[size - 1];
if (output == BLE_MESH_BLINK ||
output == BLE_MESH_BEEP ||
output == BLE_MESH_VIBRATE) {
/** NOTE: According to the Bluetooth Mesh Profile Specification
* Section 5.4.2.4, blink, beep and vibrate should be a random
* integer between 0 and 10^size.
*/
num = (num % (div[size - 1] - 1)) + 1;
} else {
num %= div[size - 1];
}
sys_put_be32(num, &link.auth[12]);
(void)memset(link.auth, 0, 12);

View File

@ -1957,7 +1957,17 @@ static int prov_auth(const u8_t idx, u8_t method, u8_t action, u8_t size)
u32_t num = 0U;
bt_mesh_rand(&num, sizeof(num));
num %= div[size - 1];
if (input == BLE_MESH_PUSH ||
input == BLE_MESH_TWIST) {
/** NOTE: According to the Bluetooth Mesh Profile Specification
* Section 5.4.2.4, push and twist should be a random integer
* between 0 and 10^size.
*/
num = (num % (div[size - 1] - 1)) + 1;
} else {
num %= div[size - 1];
}
sys_put_be32(num, &link[idx].auth[12]);
memset(link[idx].auth, 0, 12);