Diff between 60ba9a54934ed2bd1cf60c858fc0defd2e4f725e and 6271215e3d077ceb0dad63ac60d09ccd51cadc07

Changed Files

File Additions Deletions Status
android/bluetooth.c +4 -2 modified
lib/mgmt.h +1 -1 modified
monitor/control.c +21 -2 modified
src/adapter.c +7 -7 modified

Full Patch

diff --git a/android/bluetooth.c b/android/bluetooth.c
index 45cac5f..dbb68d4 100644
--- a/android/bluetooth.c
+++ b/android/bluetooth.c
@@ -2354,19 +2354,21 @@ static void new_csrk_callback(uint16_t index, uint16_t length,
 	if (!dev)
 		return;
 
-	switch (ev->key.master) {
+	switch (ev->key.type) {
 	case 0x00:
+	case 0x02:
 		memcpy(dev->local_csrk, ev->key.val, 16);
 		dev->local_sign_cnt = 0;
 		dev->valid_local_csrk = true;
 		break;
 	case 0x01:
+	case 0x03:
 		memcpy(dev->remote_csrk, ev->key.val, 16);
 		dev->remote_sign_cnt = 0;
 		dev->valid_remote_csrk = true;
 		break;
 	default:
-		error("Unknown CSRK key type 02%02x", ev->key.master);
+		error("Unknown CSRK key type 02%02x", ev->key.type);
 		return;
 	}
 
diff --git a/lib/mgmt.h b/lib/mgmt.h
index 59f1f72..7e1ef7b 100644
--- a/lib/mgmt.h
+++ b/lib/mgmt.h
@@ -602,7 +602,7 @@ struct mgmt_ev_new_irk {
 
 struct mgmt_csrk_info {
 	struct mgmt_addr_info addr;
-	uint8_t master;
+	uint8_t type;
 	uint8_t val[16];
 } __packed;
 
diff --git a/monitor/control.c b/monitor/control.c
index c6ed03c..f40debb 100644
--- a/monitor/control.c
+++ b/monitor/control.c
@@ -599,6 +599,7 @@ static void mgmt_new_irk(uint16_t len, const void *buf)
 static void mgmt_new_csrk(uint16_t len, const void *buf)
 {
 	const struct mgmt_ev_new_csrk *ev = buf;
+	const char *type;
 	char addr[18];
 
 	if (len < sizeof(*ev)) {
@@ -608,8 +609,26 @@ static void mgmt_new_csrk(uint16_t len, const void *buf)
 
 	ba2str(&ev->key.addr.bdaddr, addr);
 
-	printf("@ New CSRK: %s (%d) %s\n", addr, ev->key.addr.type,
-					ev->key.master ? "Master" : "Slave");
+	switch (ev->key.type) {
+	case 0x00:
+		type = "Local Unauthenticated";
+		break;
+	case 0x01:
+		type = "Remote Unauthenticated";
+		break;
+	case 0x02:
+		type = "Local Authenticated";
+		break;
+	case 0x03:
+		type = "Remote Authenticated";
+		break;
+	default:
+		type = "<unknown>";
+		break;
+	}
+
+	printf("@ New CSRK: %s (%d) %s (%u)\n", addr, ev->key.addr.type,
+							type, ev->key.type);
 
 	buf += sizeof(*ev);
 	len -= sizeof(*ev);
diff --git a/src/adapter.c b/src/adapter.c
index 32faa26..43501cb 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -6156,7 +6156,7 @@ static void new_long_term_key_callback(uint16_t index, uint16_t length,
 
 static void store_csrk(const bdaddr_t *local, const bdaddr_t *peer,
 				uint8_t bdaddr_type, const unsigned char *key,
-				uint32_t counter, uint8_t master)
+				uint32_t counter, uint8_t type)
 {
 	const char *group;
 	char adapter_addr[18];
@@ -6168,12 +6168,12 @@ static void store_csrk(const bdaddr_t *local, const bdaddr_t *peer,
 	char *str;
 	int i;
 
-	if (master == 0x00)
+	if (type == 0x00 || type == 0x02)
 		group = "LocalSignatureKey";
-	else if (master == 0x01)
+	else if (type == 0x01 || type == 0x03)
 		group = "RemoteSignatureKey";
 	else {
-		warn("Unsupported CSRK type %u", master);
+		warn("Unsupported CSRK type %u", type);
 		return;
 	}
 
@@ -6219,8 +6219,8 @@ static void new_csrk_callback(uint16_t index, uint16_t length,
 
 	ba2str(&addr->bdaddr, dst);
 
-	DBG("hci%u new CSRK for %s master %u", adapter->dev_id, dst,
-								ev->key.master);
+	DBG("hci%u new CSRK for %s type %u", adapter->dev_id, dst,
+								ev->key.type);
 
 	device = btd_adapter_get_device(adapter, &addr->bdaddr, addr->type);
 	if (!device) {
@@ -6232,7 +6232,7 @@ static void new_csrk_callback(uint16_t index, uint16_t length,
 		return;
 
 	store_csrk(bdaddr, &key->addr.bdaddr, key->addr.type, key->val, 0,
-								key->master);
+								key->type);
 
 	if (device_is_temporary(device))
 		btd_device_set_temporary(device, FALSE);