diff --git a/tools/oobtest.c b/tools/oobtest.c
index 7200062..2a4ae2b 100644
--- a/tools/oobtest.c
+++ b/tools/oobtest.c
#include "src/shared/mainloop.h"
#include "src/shared/util.h"
#include "src/shared/mgmt.h"
+#include "src/shared/crypto.h"
static bool use_bredr = false;
static bool use_le = false;
static uint16_t index2 = MGMT_INDEX_NONE;
static bdaddr_t bdaddr1;
static bdaddr_t bdaddr2;
+static uint8_t oob_tk[16];
static void pin_code_request_event(uint16_t index, uint16_t len,
const void *param, void *user_data)
eir_len = le16_to_cpu(rp->eir_len);
printf(" OOB data len: %u\n", eir_len);
- tk = NULL;
+ if (provide_tk)
+ tk = oob_tk;
+ else
+ tk = NULL;
+
hash256 = NULL;
rand256 = NULL;
if (parsed > eir_len)
break;
- /* Security Manager TK Value */
- if (eir[1] == 0x10) {
- tk = eir + 2;
-
- printf(" TK Value: ");
- for (i = 0; i < 16; i++)
- printf("%02x", tk[i]);
- printf("\n");
- }
-
/* LE Secure Connections Confirmation Value */
if (eir[1] == 0x22) {
hash256 = eir + 2;
eir += field_len + 1;
}
- if (!provide_tk)
- tk = NULL;
-
- if (!provide_p256) {
- hash256 = NULL;
- rand256 = NULL;
- }
-
done:
if (index == index1)
add_remote_oob_data(index2, &bdaddr1,
mgmt_send(mgmt, MGMT_OP_READ_LOCAL_OOB_DATA, index, 0, NULL,
read_oob_data_complete,
UINT_TO_PTR(index), NULL);
- } else if (use_le && (provide_tk || provide_p256)) {
+ } else if (use_le && provide_p256) {
uint8_t type = (1 << BDADDR_LE_PUBLIC) |
(1 << BDADDR_LE_RANDOM);
sizeof(type), &type,
read_oob_ext_data_complete,
UINT_TO_PTR(index), NULL);
+ } else if (use_le && provide_tk) {
+ const uint8_t *tk = oob_tk;
+
+ if (index == index1)
+ add_remote_oob_data(index2, &bdaddr1,
+ tk, NULL, NULL, NULL);
+ else if (index == index2)
+ add_remote_oob_data(index1, &bdaddr2,
+ tk, NULL, NULL, NULL);
} else {
if (index == index1)
add_remote_oob_data(index2, &bdaddr1,
return;
}
+ if (provide_tk) {
+ const uint8_t *tk = oob_tk;
+ int i;
+
+ printf(" TK Value: ");
+ for (i = 0; i < 16; i++)
+ printf("%02x", tk[i]);
+ printf("\n");
+ }
+
mgmt_register(mgmt, MGMT_EV_PIN_CODE_REQUEST, index,
pin_code_request_event,
UINT_TO_PTR(index), NULL);
printf("Selecting index %u for initiator\n", index1);
printf("Selecting index %u for acceptor\n", index2);
+ if (provide_tk) {
+ struct bt_crypto *crypto;
+
+ printf("Generating Security Manager TK Value\n");
+
+ crypto = bt_crypto_new();
+ bt_crypto_random_bytes(crypto, oob_tk, 16);
+ bt_crypto_unref(crypto);
+ }
+
mgmt_send(mgmt, MGMT_OP_READ_INFO, index1, 0, NULL,
read_info, UINT_TO_PTR(index1), NULL);
mgmt_send(mgmt, MGMT_OP_READ_INFO, index2, 0, NULL,