Skip to content

Commit 64201a3

Browse files
alxelaxrlubos
authored andcommitted
[nrf fromtree] bluetooth: mesh: update max oob size till 32 bytes
Commit updates maximum OOB authentication size from 8 bytes till 32 bytes according to specification errata ES-27446. Since previous OOB API does not allow to expose OOB values with such width the new API has been introduced. The previous API was deprecated and hidden under BT_MESH_PROV_OOB_API_LEGACY option and left for backward compatibility with existing code base. Signed-off-by: Aleksandr Khromykh <[email protected]> (cherry picked from commit 613d228) Signed-off-by: Aleksandr Khromykh <[email protected]>
1 parent c13c3fc commit 64201a3

File tree

13 files changed

+428
-108
lines changed

13 files changed

+428
-108
lines changed

doc/connectivity/bluetooth/api/mesh/provisioning.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ sequence should be repeated after a delay of three seconds or more.
144144
When an Input OOB action is selected, the user should be prompted when the
145145
application receives the :c:member:`bt_mesh_prov.input` callback. The user
146146
response should be fed back to the Provisioning API through
147-
:c:func:`bt_mesh_input_string` or :c:func:`bt_mesh_input_number`. If
147+
:c:func:`bt_mesh_input_string` or :c:func:`bt_mesh_input_numeric`. If
148148
no user response is recorded within 60 seconds, the Provisioning process is
149149
aborted.
150150

doc/releases/release-notes-4.4.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,15 @@ Removed APIs and options
5353
Deprecated APIs and options
5454
===========================
5555

56+
* Bluetooth
57+
58+
* Mesh
59+
60+
* The function :c:func:`bt_mesh_input_number` was deprecated. Applications should use
61+
:c:func:`bt_mesh_input_numeric` instead.
62+
* The callback :c:member:`output_number` in :c:struct:`bt_mesh_prov` structure was deprecated.
63+
Applications should use :c:member:`output_numeric` callback instead.
64+
5665
New APIs and options
5766
====================
5867

@@ -66,6 +75,12 @@ New APIs and options
6675
6776
* Bluetooth
6877

78+
* Mesh
79+
80+
* :c:func:`bt_mesh_input_numeric` to provide provisioning numeric input OOB value.
81+
* :c:member:`output_numeric` callback in :c:struct:`bt_mesh_prov` structure to
82+
output numeric values during provisioning.
83+
6984
* Services
7085

7186
* Introduced Alert Notification Service (ANS) :kconfig:option:`CONFIG_BT_ANS`

include/zephyr/bluetooth/mesh/main.h

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ struct bt_mesh_prov {
173173
*/
174174
void (*capabilities)(const struct bt_mesh_dev_capabilities *cap);
175175

176+
#if defined CONFIG_BT_MESH_PROV_OOB_API_LEGACY
176177
/** @brief Output of a number is requested.
177178
*
178179
* This callback notifies the application that it should
@@ -183,7 +184,21 @@ struct bt_mesh_prov {
183184
*
184185
* @return Zero on success or negative error code otherwise
185186
*/
186-
int (*output_number)(bt_mesh_output_action_t act, uint32_t num);
187+
int (*output_number)(bt_mesh_output_action_t act, uint32_t num) __deprecated;
188+
#else
189+
/** @brief Output of a numeric value is requested.
190+
*
191+
* This callback notifies the application that it should
192+
* output the given numeric value using the given action.
193+
*
194+
* @param act Action for outputting the numeric value.
195+
* @param numeric memory with numeric value in the little endian format to be outputted.
196+
* @param size size of the numeric value in bytes.
197+
*
198+
* @return Zero on success or negative error code otherwise
199+
*/
200+
int (*output_numeric)(bt_mesh_output_action_t act, uint8_t *numeric, size_t size);
201+
#endif
187202

188203
/** @brief Output of a string is requested.
189204
*
@@ -202,7 +217,7 @@ struct bt_mesh_prov {
202217
* request input from the user using the given action. The
203218
* requested input will either be a string or a number, and
204219
* the application needs to consequently call the
205-
* bt_mesh_input_string() or bt_mesh_input_number() functions
220+
* bt_mesh_input_string() or bt_mesh_input_numeric() functions
206221
* once the data has been acquired from the user.
207222
*
208223
* @param act Action for inputting data.
@@ -313,7 +328,7 @@ struct bt_mesh_rpr_node;
313328

314329
/** @brief Provide provisioning input OOB string.
315330
*
316-
* This is intended to be called after the bt_mesh_prov input callback
331+
* This is intended to be called after the @ref bt_mesh_prov::input callback
317332
* has been called with BT_MESH_ENTER_STRING as the action.
318333
*
319334
* @param str String.
@@ -322,16 +337,30 @@ struct bt_mesh_rpr_node;
322337
*/
323338
int bt_mesh_input_string(const char *str);
324339

340+
#if defined CONFIG_BT_MESH_PROV_OOB_API_LEGACY
325341
/** @brief Provide provisioning input OOB number.
326342
*
327-
* This is intended to be called after the bt_mesh_prov input callback
328-
* has been called with BT_MESH_ENTER_NUMBER as the action.
343+
* This is intended to be called after the @ref bt_mesh_prov::input callback
344+
* has been called with @ref BT_MESH_ENTER_NUMBER as the action.
329345
*
330346
* @param num Number.
331347
*
332348
* @return Zero on success or (negative) error code otherwise.
333349
*/
334-
int bt_mesh_input_number(uint32_t num);
350+
__deprecated int bt_mesh_input_number(uint32_t num);
351+
#endif
352+
353+
/** @brief Provide provisioning input OOB numeric value.
354+
*
355+
* This is intended to be called after the @ref bt_mesh_prov::input callback
356+
* has been called with @ref BT_MESH_ENTER_NUMBER as the action.
357+
*
358+
* @param numeric Pointer to the numeric value in little endian.
359+
* @param size Size of the numeric value in bytes (this is not OOB size).
360+
*
361+
* @return Zero on success or (negative) error code otherwise.
362+
*/
363+
int bt_mesh_input_numeric(uint8_t *numeric, size_t size);
335364

336365
/** @brief Provide Device public key.
337366
*
@@ -347,7 +376,7 @@ int bt_mesh_prov_remote_pub_key_set(const uint8_t public_key[64]);
347376
*
348377
* Instruct the unprovisioned device to use the specified Input OOB
349378
* authentication action. When using @ref BT_MESH_PUSH, @ref BT_MESH_TWIST or
350-
* @ref BT_MESH_ENTER_NUMBER, the @ref bt_mesh_prov::output_number callback is
379+
* @ref BT_MESH_ENTER_NUMBER, the @ref bt_mesh_prov::output_numeric callback is
351380
* called with a random number that has to be entered on the unprovisioned
352381
* device.
353382
*
@@ -372,7 +401,7 @@ int bt_mesh_auth_method_set_input(bt_mesh_input_action_t action, uint8_t size);
372401
*
373402
* When using @ref BT_MESH_BLINK, @ref BT_MESH_BEEP, @ref BT_MESH_VIBRATE
374403
* or @ref BT_MESH_DISPLAY_NUMBER, and the application has to call
375-
* @ref bt_mesh_input_number with the random number indicated by
404+
* @ref bt_mesh_input_numeric with the random number indicated by
376405
* the unprovisioned device.
377406
*
378407
* When using @ref BT_MESH_DISPLAY_STRING, the application has to call

samples/bluetooth/mesh/src/main.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -267,9 +267,16 @@ static const struct bt_mesh_comp comp = {
267267
};
268268

269269
/* Provisioning */
270-
271-
static int output_number(bt_mesh_output_action_t action, uint32_t number)
270+
static int output_numeric(bt_mesh_output_action_t action, uint8_t *numeric, size_t size)
272271
{
272+
uint32_t number;
273+
274+
if (size != sizeof(number)) {
275+
printk("Wrong OOB size: %u\n", size);
276+
return -EINVAL;
277+
}
278+
279+
number = sys_get_le32(numeric);
273280
printk("OOB Number: %u\n", number);
274281

275282
board_output_number(action, number);
@@ -293,7 +300,7 @@ static const struct bt_mesh_prov prov = {
293300
.uuid = dev_uuid,
294301
.output_size = 4,
295302
.output_actions = BT_MESH_DISPLAY_NUMBER,
296-
.output_number = output_number,
303+
.output_numeric = output_numeric,
297304
.complete = prov_complete,
298305
.reset = prov_reset,
299306
};

samples/boards/nordic/mesh/onoff-app/src/main.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
#include <zephyr/bluetooth/hci.h>
4848
#include <zephyr/bluetooth/mesh.h>
4949
#include <stdio.h>
50+
#include <inttypes.h>
5051

5152
/* Model Operation Codes */
5253
#define BT_MESH_MODEL_OP_GEN_ONOFF_GET BT_MESH_MODEL_OP_2(0x82, 0x01)
@@ -366,9 +367,13 @@ static int gen_onoff_status(const struct bt_mesh_model *model,
366367
return 0;
367368
}
368369

369-
static int output_number(bt_mesh_output_action_t action, uint32_t number)
370+
static int output_numeric(bt_mesh_output_action_t action, uint8_t *numeric, size_t size)
370371
{
371-
printk("OOB Number %06u\n", number);
372+
uint64_t number = 0ull;
373+
374+
sys_get_le(&number, numeric, size);
375+
376+
printk("OOB Number %06" PRIu64 "\n", number);
372377
return 0;
373378
}
374379

@@ -525,7 +530,7 @@ static const struct bt_mesh_prov prov = {
525530
#if 1
526531
.output_size = 6,
527532
.output_actions = (BT_MESH_DISPLAY_NUMBER | BT_MESH_DISPLAY_STRING),
528-
.output_number = output_number,
533+
.output_numeric = output_numeric,
529534
.output_string = output_string,
530535
#else
531536
.output_size = 0,

samples/boards/nordic/mesh/onoff_level_lighting_vnd_app/src/mesh/ble_mesh.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,13 @@
1010

1111
#ifdef OOB_AUTH_ENABLE
1212

13-
static int output_number(bt_mesh_output_action_t action, uint32_t number)
13+
static int output_numeric(bt_mesh_output_action_t action, uint8_t *numeric, size_t size)
1414
{
15-
printk("OOB Number: %u\n", number);
15+
uint64_t number = 0ull;
16+
17+
sys_get_le(&number, numeric, size);
18+
19+
printk("OOB Number %06" PRIu64 "\n", number);
1620
return 0;
1721
}
1822

@@ -42,7 +46,7 @@ static const struct bt_mesh_prov prov = {
4246

4347
.output_size = 6,
4448
.output_actions = BT_MESH_DISPLAY_NUMBER | BT_MESH_DISPLAY_STRING,
45-
.output_number = output_number,
49+
.output_numeric = output_numeric,
4650
.output_string = output_string,
4751

4852
#endif

subsys/bluetooth/mesh/Kconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,18 @@ config BT_MESH_OOB_AUTH_REQUIRED
376376
bool "OOB authentication mandates to use HMAC SHA256"
377377
depends on BT_MESH_ECDH_P256_HMAC_SHA256_AES_CCM
378378

379+
config BT_MESH_PROV_OOB_API_LEGACY
380+
bool "Reduced maximum OOB authentication size support [DEPRECATED]"
381+
select DEPRECATED
382+
depends on BT_MESH_PROV
383+
help
384+
By default, the maximum OOB authentication size is 32 bytes.
385+
Enable this option to use the legacy API which is only compatible with
386+
specification v1.1 and earlier. This limits OOB authentication to 8
387+
bytes maximum.
388+
This option is intended for backward compatibility.
389+
Not recommended for new designs due to reduced security.
390+
379391
config BT_MESH_PROVISIONER
380392
bool "Provisioner support"
381393
depends on BT_MESH_CDB

0 commit comments

Comments
 (0)