Skip to contentSkip to conversation

shared/att: Make crypto really optional

PATCH Applied Luiz Augusto von Dentz 1 participant 2 messages Aug 31, 2015 – Sep 2, 2015 Bluetooth drivers

lore
Share & tools
lore

Luiz Augusto von Dentz

author maintainer
#0 lore raw

PATCH 1/1 shared/att: Make crypto really optional

From: Luiz Augusto von Dentz <[email protected]>

If bt_crypt_new fails or ext_signed should disable any signing operation but currently only incoming operations were being ignored and only if ext_signed is set which ignores the fact that bt_crypt_new can still fail if the necessary kernel modules are not available.

---
 src/shared/att.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
src/shared/att.c +2 -4
index 70f5d72..d88169e 100644
@@ -82,7 +82,6 @@ struct bt_att {
 	void *debug_data;
 
 	struct bt_crypto *crypto;
-	bool ext_signed;
 
 	struct sign_info *local_sign;
 	struct sign_info *remote_sign;
@@ -294,7 +293,7 @@ static bool encode_pdu(struct bt_att *att, struct att_send_op *op,
 	if (pdu_len > 1)
 		memcpy(op->pdu + 1, pdu, length);
 
-	if (!sign || !(op->opcode & ATT_OP_SIGNED_MASK))
+	if (!sign || !(op->opcode & ATT_OP_SIGNED_MASK) || !att->crypto)
 		return true;
 
 	if (!sign->counter(&sign_cnt, sign->user_data))
@@ -782,7 +781,7 @@ static void handle_notify(struct bt_att *att, uint8_t opcode, uint8_t *pdu,
 	const struct queue_entry *entry;
 	bool found;
 
-	if ((opcode & ATT_OP_SIGNED_MASK) && !att->ext_signed) {
+	if ((opcode & ATT_OP_SIGNED_MASK) && !att->crypto) {
 		if (!handle_signed(att, opcode, pdu, pdu_len))
 			return;
 		pdu_len -= BT_ATT_SIGNATURE_LEN;
@@ -962,7 +961,6 @@ struct bt_att *bt_att_new(int fd, bool ext_signed)
 		return NULL;
 
 	att->fd = fd;
-	att->ext_signed = ext_signed;
 	att->mtu = BT_ATT_DEFAULT_LE_MTU;
 	att->buf = malloc(att->mtu);
 	if (!att->buf)
Signature · 1 line
2.4.3
author maintainer Applied
#1 lore raw

Hi,

Quoted 49 lines · Luiz Augusto von Dentz

From: Luiz Augusto von Dentz <[email protected]>

If bt_crypt_new fails or ext_signed should disable any signing operation but currently only incoming operations were being ignored and only if ext_signed is set which ignores the fact that bt_crypt_new can still fail if the necessary kernel modules are not available.

---
 src/shared/att.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
src/shared/att.c +2 -5
index 70f5d72..d88169e 100644
@@ -82,7 +82,6 @@ struct bt_att {
        void *debug_data;
 
        struct bt_crypto *crypto;
-       bool ext_signed;
 
        struct sign_info *local_sign;
        struct sign_info *remote_sign;
@@ -294,7 +293,7 @@ static bool encode_pdu(struct bt_att *att, struct att_send_op *op,
        if (pdu_len > 1)
                memcpy(op->pdu + 1, pdu, length);
 
-       if (!sign || !(op->opcode & ATT_OP_SIGNED_MASK))
+       if (!sign || !(op->opcode & ATT_OP_SIGNED_MASK) || !att->crypto)
                return true;
 
        if (!sign->counter(&sign_cnt, sign->user_data))
@@ -782,7 +781,7 @@ static void handle_notify(struct bt_att *att, uint8_t opcode, uint8_t *pdu,
        const struct queue_entry *entry;
        bool found;
 
-       if ((opcode & ATT_OP_SIGNED_MASK) && !att->ext_signed) {
+       if ((opcode & ATT_OP_SIGNED_MASK) && !att->crypto) {
                if (!handle_signed(att, opcode, pdu, pdu_len))
                        return;
                pdu_len -= BT_ATT_SIGNATURE_LEN;
@@ -962,7 +961,6 @@ struct bt_att *bt_att_new(int fd, bool ext_signed)
                return NULL;
 
        att->fd = fd;
-       att->ext_signed = ext_signed;
        att->mtu = BT_ATT_DEFAULT_LE_MTU;
        att->buf = malloc(att->mtu);
        if (!att->buf)
--
Quoted 1 line

2.4.3

Applied.

Signature · 1 line
Luiz Augusto von Dentz