From 5726c06f8cd54008e2fe6d83137330bb9ed64e12 Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Sat, 14 Mar 2015 21:27:48 -0700 Subject: [PATCH] lib: Use single mgmt structure for legacy local OOB data --- lib/mgmt.h | 8 ++------ src/adapter.c | 4 ++-- tools/btmgmt.c | 11 +++++------ tools/oobtest.c | 10 +++++----- 4 files changed, 14 insertions(+), 19 deletions(-) diff --git a/lib/mgmt.h b/lib/mgmt.h index fac6f9b2c..9726c2265 100644 --- a/lib/mgmt.h +++ b/lib/mgmt.h @@ -274,14 +274,10 @@ struct mgmt_cp_user_passkey_neg_reply { #define MGMT_OP_READ_LOCAL_OOB_DATA 0x0020 struct mgmt_rp_read_local_oob_data { - uint8_t hash[16]; - uint8_t randomizer[16]; -} __packed; -struct mgmt_rp_read_local_oob_ext_data { uint8_t hash192[16]; - uint8_t randomizer192[16]; + uint8_t rand192[16]; uint8_t hash256[16]; - uint8_t randomizer256[16]; + uint8_t rand256[16]; } __packed; #define MGMT_OP_ADD_REMOTE_OOB_DATA 0x0021 diff --git a/src/adapter.c b/src/adapter.c index 329e9b415..3744c2be4 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -6530,8 +6530,8 @@ static void read_local_oob_data_complete(uint8_t status, uint16_t length, error("Too small read local OOB data response"); return; } else { - hash = rp->hash; - randomizer = rp->randomizer; + hash = rp->hash192; + randomizer = rp->rand192; } if (!adapter->oob_handler || !adapter->oob_handler->read_local_cb) diff --git a/tools/btmgmt.c b/tools/btmgmt.c index a69a5d295..e53413fbb 100644 --- a/tools/btmgmt.c +++ b/tools/btmgmt.c @@ -2773,7 +2773,6 @@ static void local_oob_rsp(uint8_t status, uint16_t len, const void *param, void *user_data) { const struct mgmt_rp_read_local_oob_data *rp = param; - const struct mgmt_rp_read_local_oob_ext_data *rp_ext = param; char str[33]; if (status != 0) { @@ -2787,19 +2786,19 @@ static void local_oob_rsp(uint8_t status, uint16_t len, const void *param, return noninteractive_quit(EXIT_FAILURE); } - bin2hex(rp->hash, 16, str, sizeof(str)); + bin2hex(rp->hash192, 16, str, sizeof(str)); print("Hash C from P-192: %s", str); - bin2hex(rp->randomizer, 16, str, sizeof(str)); + bin2hex(rp->rand192, 16, str, sizeof(str)); print("Randomizer R with P-192: %s", str); - if (len < sizeof(*rp_ext)) + if (len < sizeof(*rp)) return noninteractive_quit(EXIT_SUCCESS); - bin2hex(rp_ext->hash256, 16, str, sizeof(str)); + bin2hex(rp->hash256, 16, str, sizeof(str)); print("Hash C from P-256: %s", str); - bin2hex(rp_ext->randomizer256, 16, str, sizeof(str)); + bin2hex(rp->rand256, 16, str, sizeof(str)); print("Randomizer R with P-256: %s", str); noninteractive_quit(EXIT_SUCCESS); diff --git a/tools/oobtest.c b/tools/oobtest.c index 9cc6c162e..b25ba2a9e 100644 --- a/tools/oobtest.c +++ b/tools/oobtest.c @@ -277,7 +277,7 @@ static void add_remote_oob_data(uint16_t index, const bdaddr_t *bdaddr, static void read_oob_data_complete(uint8_t status, uint16_t len, const void *param, void *user_data) { - const struct mgmt_rp_read_local_oob_ext_data *rp = param; + const struct mgmt_rp_read_local_oob_data *rp = param; uint16_t index = PTR_TO_UINT(user_data); const uint8_t *hash192, *rand192, *hash256, *rand256; int i; @@ -293,7 +293,7 @@ static void read_oob_data_complete(uint8_t status, uint16_t len, if (provide_p192) { hash192 = rp->hash192; - rand192 = rp->randomizer192; + rand192 = rp->rand192; } else { hash192 = NULL; rand192 = NULL; @@ -306,7 +306,7 @@ static void read_oob_data_complete(uint8_t status, uint16_t len, printf(" Randomizer R with P-192: "); for (i = 0; i < 16; i++) - printf("%02x", rp->randomizer192[i]); + printf("%02x", rp->rand192[i]); printf("\n"); if (len < sizeof(*rp)) { @@ -317,7 +317,7 @@ static void read_oob_data_complete(uint8_t status, uint16_t len, if (provide_p256) { hash256 = rp->hash256; - rand256 = rp->randomizer256; + rand256 = rp->rand256; } else { hash256 = NULL; rand256 = NULL; @@ -330,7 +330,7 @@ static void read_oob_data_complete(uint8_t status, uint16_t len, printf(" Randomizer R with P-256: "); for (i = 0; i < 16; i++) - printf("%02x", rp->randomizer256[i]); + printf("%02x", rp->rand256[i]); printf("\n"); done: -- 2.47.3