mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
bluedroid: fix encrypt keysize of GATT characteristic permission
This commit is contained in:
parent
4b7702c0a4
commit
c97df72bb2
@ -561,6 +561,10 @@ esp_err_t esp_ble_gap_set_security_param(esp_ble_sm_param_t param_type,
|
|||||||
return ESP_ERR_INVALID_ARG;
|
return ESP_ERR_INVALID_ARG;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (param_type == ESP_BLE_APP_ENC_KEY_SIZE) {
|
||||||
|
LOG_ERROR("ESP_BLE_APP_ENC_KEY_SIZE is deprecated, use ESP_GATT_PERM_ENCRYPT_KEY_SIZE in characteristic definition");
|
||||||
|
return ESP_ERR_NOT_SUPPORTED;
|
||||||
|
}
|
||||||
|
|
||||||
btc_msg_t msg = {0};
|
btc_msg_t msg = {0};
|
||||||
btc_ble_gap_args_t arg;
|
btc_ble_gap_args_t arg;
|
||||||
|
@ -277,6 +277,7 @@ typedef enum {
|
|||||||
#define ESP_GATT_PERM_WRITE_SIGNED_MITM (1 << 8) /* bit 8 - 0x0100 */ /* relate to BTA_GATT_PERM_WRITE_SIGNED_MITM in bta/bta_gatt_api.h */
|
#define ESP_GATT_PERM_WRITE_SIGNED_MITM (1 << 8) /* bit 8 - 0x0100 */ /* relate to BTA_GATT_PERM_WRITE_SIGNED_MITM in bta/bta_gatt_api.h */
|
||||||
#define ESP_GATT_PERM_READ_AUTHORIZATION (1 << 9) /* bit 9 - 0x0200 */
|
#define ESP_GATT_PERM_READ_AUTHORIZATION (1 << 9) /* bit 9 - 0x0200 */
|
||||||
#define ESP_GATT_PERM_WRITE_AUTHORIZATION (1 << 10) /* bit 10 - 0x0400 */
|
#define ESP_GATT_PERM_WRITE_AUTHORIZATION (1 << 10) /* bit 10 - 0x0400 */
|
||||||
|
#define ESP_GATT_PERM_ENCRYPT_KEY_SIZE(keysize) (((keysize - 6) & 0xF) << 12) /* bit 12:15 - 0xF000 */
|
||||||
typedef uint16_t esp_gatt_perm_t;
|
typedef uint16_t esp_gatt_perm_t;
|
||||||
|
|
||||||
/* relate to BTA_GATT_CHAR_PROP_BIT_xxx in bta/bta_gatt_api.h */
|
/* relate to BTA_GATT_CHAR_PROP_BIT_xxx in bta/bta_gatt_api.h */
|
||||||
|
@ -51,7 +51,6 @@ tBTE_APPL_CFG bte_appl_cfg = {
|
|||||||
BTM_BLE_MIN_KEY_SIZE,
|
BTM_BLE_MIN_KEY_SIZE,
|
||||||
BTM_BLE_ONLY_ACCEPT_SPECIFIED_SEC_AUTH_DISABLE,
|
BTM_BLE_ONLY_ACCEPT_SPECIFIED_SEC_AUTH_DISABLE,
|
||||||
BTM_BLE_OOB_DISABLE,
|
BTM_BLE_OOB_DISABLE,
|
||||||
BTM_BLE_APPL_ENC_KEY_SIZE,
|
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -428,17 +427,6 @@ void bta_dm_co_ble_set_min_key_size(UINT8 ble_key_size)
|
|||||||
#endif ///SMP_INCLUDED == TRUE
|
#endif ///SMP_INCLUDED == TRUE
|
||||||
}
|
}
|
||||||
|
|
||||||
void bta_dm_co_ble_set_appl_enc_key_size(UINT8 ble_key_size)
|
|
||||||
{
|
|
||||||
#if (SMP_INCLUDED == TRUE)
|
|
||||||
if(ble_key_size >= bte_appl_cfg.ble_min_key_size && ble_key_size <= bte_appl_cfg.ble_max_key_size) {
|
|
||||||
bte_appl_cfg.ble_appl_enc_key_size = ble_key_size;
|
|
||||||
} else {
|
|
||||||
APPL_TRACE_ERROR("%s error:Invalid key size value, key_size =%d",__func__, ble_key_size);
|
|
||||||
}
|
|
||||||
#endif ///SMP_INCLUDED == TRUE
|
|
||||||
}
|
|
||||||
|
|
||||||
void bta_dm_co_ble_set_accept_auth_enable(UINT8 enable)
|
void bta_dm_co_ble_set_accept_auth_enable(UINT8 enable)
|
||||||
{
|
{
|
||||||
#if (SMP_INCLUDED == TRUE)
|
#if (SMP_INCLUDED == TRUE)
|
||||||
|
@ -215,6 +215,4 @@ extern UINT8 bta_dm_co_ble_get_accept_auth_enable(void);
|
|||||||
extern UINT8 bta_dm_co_ble_get_auth_req(void);
|
extern UINT8 bta_dm_co_ble_get_auth_req(void);
|
||||||
|
|
||||||
extern void bta_dm_co_ble_oob_support(UINT8 enable);
|
extern void bta_dm_co_ble_oob_support(UINT8 enable);
|
||||||
|
|
||||||
extern void bta_dm_co_ble_set_appl_enc_key_size(UINT8 ble_key_size);
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1651,12 +1651,6 @@ void btc_gap_ble_call_handler(btc_msg_t *msg)
|
|||||||
bta_dm_co_ble_oob_support(enable);
|
bta_dm_co_ble_oob_support(enable);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ESP_BLE_APP_ENC_KEY_SIZE: {
|
|
||||||
uint8_t key_size = 0;
|
|
||||||
STREAM_TO_UINT8(key_size, value);
|
|
||||||
bta_dm_co_ble_set_appl_enc_key_size(key_size);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,6 @@ typedef struct {
|
|||||||
UINT8 ble_min_key_size;
|
UINT8 ble_min_key_size;
|
||||||
UINT8 ble_accept_auth_enable;
|
UINT8 ble_accept_auth_enable;
|
||||||
UINT8 oob_support;
|
UINT8 oob_support;
|
||||||
UINT8 ble_appl_enc_key_size;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
} tBTE_APPL_CFG;
|
} tBTE_APPL_CFG;
|
||||||
|
@ -34,7 +34,6 @@
|
|||||||
#include "gatt_int.h"
|
#include "gatt_int.h"
|
||||||
#include "stack/l2c_api.h"
|
#include "stack/l2c_api.h"
|
||||||
#include "btm_int.h"
|
#include "btm_int.h"
|
||||||
#include "common/bte_appl.h"
|
|
||||||
|
|
||||||
/********************************************************************************
|
/********************************************************************************
|
||||||
** L O C A L F U N C T I O N P R O T O T Y P E S *
|
** L O C A L F U N C T I O N P R O T O T Y P E S *
|
||||||
@ -125,14 +124,10 @@ static tGATT_STATUS gatts_check_attr_readability(tGATT_ATTR16 *p_attr,
|
|||||||
tGATT_PERM perm = p_attr->permission;
|
tGATT_PERM perm = p_attr->permission;
|
||||||
|
|
||||||
UNUSED(offset);
|
UNUSED(offset);
|
||||||
#if SMP_INCLUDED == TRUE
|
|
||||||
min_key_size = bte_appl_cfg.ble_appl_enc_key_size;
|
|
||||||
#else
|
|
||||||
min_key_size = (((perm & GATT_ENCRYPT_KEY_SIZE_MASK) >> 12));
|
min_key_size = (((perm & GATT_ENCRYPT_KEY_SIZE_MASK) >> 12));
|
||||||
if (min_key_size != 0 ) {
|
if (min_key_size != 0 ) {
|
||||||
min_key_size += 6;
|
min_key_size += 6;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!(perm & GATT_READ_ALLOWED)) {
|
if (!(perm & GATT_READ_ALLOWED)) {
|
||||||
GATT_TRACE_ERROR( "GATT_READ_NOT_PERMIT\n");
|
GATT_TRACE_ERROR( "GATT_READ_NOT_PERMIT\n");
|
||||||
@ -1077,14 +1072,10 @@ tGATT_STATUS gatts_write_attr_perm_check (tGATT_SVC_DB *p_db, UINT8 op_code,
|
|||||||
while (p_attr != NULL) {
|
while (p_attr != NULL) {
|
||||||
if (p_attr->handle == handle) {
|
if (p_attr->handle == handle) {
|
||||||
perm = p_attr->permission;
|
perm = p_attr->permission;
|
||||||
#if SMP_INCLUDED == TRUE
|
|
||||||
min_key_size = bte_appl_cfg.ble_appl_enc_key_size;
|
|
||||||
#else
|
|
||||||
min_key_size = (((perm & GATT_ENCRYPT_KEY_SIZE_MASK) >> 12));
|
min_key_size = (((perm & GATT_ENCRYPT_KEY_SIZE_MASK) >> 12));
|
||||||
if (min_key_size != 0 ) {
|
if (min_key_size != 0 ) {
|
||||||
min_key_size += 6;
|
min_key_size += 6;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
GATT_TRACE_DEBUG( "gatts_write_attr_perm_check p_attr->permission =0x%04x min_key_size==0x%04x",
|
GATT_TRACE_DEBUG( "gatts_write_attr_perm_check p_attr->permission =0x%04x min_key_size==0x%04x",
|
||||||
p_attr->permission,
|
p_attr->permission,
|
||||||
min_key_size);
|
min_key_size);
|
||||||
|
@ -1486,7 +1486,6 @@ typedef UINT8 tBTM_IO_CAP;
|
|||||||
#define BTM_BLE_RESPONDER_KEY_SIZE 15
|
#define BTM_BLE_RESPONDER_KEY_SIZE 15
|
||||||
#define BTM_BLE_MAX_KEY_SIZE 16
|
#define BTM_BLE_MAX_KEY_SIZE 16
|
||||||
#define BTM_BLE_MIN_KEY_SIZE 7
|
#define BTM_BLE_MIN_KEY_SIZE 7
|
||||||
#define BTM_BLE_APPL_ENC_KEY_SIZE 7
|
|
||||||
|
|
||||||
typedef UINT8 tBTM_AUTH_REQ;
|
typedef UINT8 tBTM_AUTH_REQ;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user