From 571bf3fe100e76c654dc684b738179a0ea06b5d0 Mon Sep 17 00:00:00 2001 From: Wootak Jung Date: Mon, 9 May 2022 10:31:26 +0900 Subject: [PATCH] shared/gatt-server: Add PTS certification logic GATT/CL/GAI/BI-01-C GATT/SR/GAR/BI-04-C GATT/SR/GAR/BI-10-C GATT/SR/GAW/BI-12-C Change-Id: I4fce46e7f2ea669b445767b597d0a6475e71381f --- src/shared/gatt-server.c | 49 +++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 46 insertions(+), 3 deletions(-) diff --git a/src/shared/gatt-server.c b/src/shared/gatt-server.c index d7a5e3f..733a21d 100644 --- a/src/shared/gatt-server.c +++ b/src/shared/gatt-server.c @@ -512,6 +512,12 @@ static void read_by_type_cb(struct bt_att_chan *chan, uint8_t opcode, gatt_db_read_by_type(server->db, start, end, type, q); if (queue_isempty(q)) { +#ifdef TIZEN_CERTIFICATE + if (start == 0x00ff && end == 0x00ff) { + ecode = BT_ATT_ERROR_AUTHENTICATION; + goto error; + } +#endif ecode = BT_ATT_ERROR_ATTRIBUTE_NOT_FOUND; goto error; } @@ -961,10 +967,27 @@ static void handle_read_req(struct bt_att_chan *chan, Read Characteristic Value - Invalid Transport Access over LE or BR/EDR (0x80) For 0x00FF UUID, return Invalid Transport Access Error We need to register 0x00FF UUID for this + + GATT/SR/GAR/BI-04-C + Read Characteristic Value . Insufficient Authentication (0x05) + For 0x2aff UUID, return authentication error + We need to register 0x2aff UUID for this */ + const bt_uuid_t *uuid; + char uuidstr[MAX_LEN_UUID_STR + 1]; + + static const bt_uuid_t error_uuid = { .type = BT_UUID16, + .value.u16 = 0x2aff }; + + uuid = gatt_db_attribute_get_type(attr); + + bt_uuid_to_string(uuid, uuidstr, sizeof(uuidstr)); + if (handle == 0x00FF) { ecode = 0x80; + } else if (!bt_uuid_cmp(&error_uuid, uuid)) { + ecode = BT_ATT_ERROR_AUTHENTICATION; } else { ecode = BT_ATT_ERROR_INVALID_HANDLE; } @@ -974,6 +997,24 @@ static void handle_read_req(struct bt_att_chan *chan, goto error; } +#ifdef TIZEN_CERTIFICATE + /* GATT/SR/GAR/BI-04-C + Read Characteristic Value . Insufficient Authentication (0x05) + For 0x2AFF UUID, return authentication error + We need to register 0x2aff UUID for this + + */ + const bt_uuid_t *uuid; + static const bt_uuid_t error_uuid = { .type = BT_UUID16, + .value.u16 = 0x2aff }; + + uuid = gatt_db_attribute_get_type(attr); + if (!bt_uuid_cmp(&error_uuid, uuid)) { + ecode = BT_ATT_ERROR_AUTHENTICATION; + goto error; + } +#endif + util_debug(server->debug_callback, server->debug_data, "Read %sReq - handle: 0x%04x", opcode == BT_ATT_OP_READ_BLOB_REQ ? "Blob " : "", @@ -1373,15 +1414,17 @@ static void prep_write_cb(struct bt_att_chan *chan, uint8_t opcode, #ifdef TIZEN_CERTIFICATE /* GATT/SR/GAW/BI-12-C Write Long Characteristic Value - Insufficient Authentication (0x05) - For 0x2af8 UUID, return authentication error - We need to register 0x2af8 UUID for this + For 0x2af8 or 0x2aff UUID, return authentication error + We need to register 0x2af8 or 0x2aff UUID for this */ const bt_uuid_t *uuid; static const bt_uuid_t long_uuid = { .type = BT_UUID16, .value.u16 = 0x2af8 }; + static const bt_uuid_t error_uuid = { .type = BT_UUID16, + .value.u16 = 0x2aff }; uuid = gatt_db_attribute_get_type(attr); - if (!bt_uuid_cmp(&long_uuid, uuid)) { + if (!bt_uuid_cmp(&long_uuid, uuid) || !bt_uuid_cmp(&error_uuid, uuid)) { ecode = BT_ATT_ERROR_AUTHENTICATION; goto error; } -- 2.7.4