This patch accepts 16 octet hex key for static OOB authentication [mesh-cfgclient]# provision F24B3F329DF200000000000000000000 Provisioning started Request hexadecimal key (hex 16 octets) [[mesh-agent]# ] Enter key (hex number): 0a0b0a0b0a0b0a0b0a0b0a0b0a0b0a0b Assign addresses for 4 elements Provisioning done: Mesh node: UUID = F24B3F329DF200000000000000000000 primary = 00aa elements = 4 --- tools/mesh-cfgclient.c | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/tools/mesh-cfgclient.c b/tools/mesh-cfgclient.c index b4d76de..a1fd72a 100644 --- a/tools/mesh-cfgclient.c +++ b/tools/mesh-cfgclient.c @@ -373,14 +373,26 @@ static void agent_input_done(oob_type_t type, void *buf, uint16_t len, struct l_dbus_message_builder *builder; uint32_t val_u32; uint8_t ascii[16]; + uint8_t hex_key[MAX_HEXADECIMAL_OOB_LEN]; switch (type) { case NONE: case OUTPUT: case HEXADECIMAL: - default: - break; + bt_shell_printf("Hex key length [%d]\n", len); + if (len > MAX_HEXADECIMAL_OOB_LEN) { + bt_shell_printf("Bad input length\n"); + break; + } + memset(hex_key, 0, MAX_HEXADECIMAL_OOB_LEN); + memcpy(hex_key, buf, len); + reply = l_dbus_message_new_method_return(msg); + builder = l_dbus_message_builder_new(reply); + append_byte_array(builder, hex_key, len); + l_dbus_message_builder_finalize(builder); + l_dbus_message_builder_destroy(builder); + break; case ASCII: if (len > 8) { bt_shell_printf("Bad input length\n"); @@ -406,6 +418,8 @@ static void agent_input_done(oob_type_t type, void *buf, uint16_t len, reply = l_dbus_message_new_method_return(msg); l_dbus_message_set_arguments(reply, "u", val_u32); break; + default: + break; } if (!reply) @@ -539,13 +553,22 @@ static struct l_dbus_message *prompt_static_call(struct l_dbus *dbus, return l_dbus_message_new_error(msg, dbus_err_fail, NULL); } - if (!strcmp(str, "in-alpha") && !strcmp(str, "out-alpha")) - return l_dbus_message_new_error(msg, dbus_err_support, NULL); + if ((strcmp(str, "in-alpha") != 0) && (strcmp(str, "out-alpha") != 0) + && (strcmp(str, "static-oob") != 0)) + return l_dbus_message_new_error(msg, dbus_err_args, NULL); l_dbus_message_ref(msg); - agent_input_request(ASCII, 8, "Enter displayed Ascii code", - agent_input_done, msg); + if (strcmp(str, "static-oob") != 0) { + if (!agent_input_request(ASCII, 8, "Enter displayed Ascii code", + agent_input_done, msg)) + return l_dbus_message_new_error(msg, dbus_err_fail, NULL); + } else { + /* Static OOB key len is fixed to 16 Octets */ + if (!agent_input_request(HEXADECIMAL, 16, NULL, + agent_input_done, msg)) + return l_dbus_message_new_error(msg, dbus_err_fail, NULL); + } return NULL; } -- 2.7.4