Bluetooth: GATT: Add connection authentication check

If attribute requires authentication to be read or written,
we check if current security level (should be BT_SECURITY_HIGH
or higher) allows to perform such operations on this attribute.

Change-Id: Ibba542ac96af00722370eba77d6c929cda520fd8
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
This commit is contained in:
Mariusz Skamra 2015-10-20 11:03:31 +02:00 committed by Anas Nashif
commit 967776deed

View file

@ -654,8 +654,13 @@ static uint8_t check_perm(struct bt_conn *conn, const struct bt_gatt_attr *attr,
mask &= attr->perm;
if (mask & BT_GATT_PERM_AUTHEN_MASK) {
/* TODO: Check conn authentication */
#if defined(CONFIG_BLUETOOTH_SMP)
if (conn->sec_level < BT_SECURITY_HIGH) {
return BT_ATT_ERR_AUTHENTICATION;
}
#else
return BT_ATT_ERR_AUTHENTICATION;
#endif /* CONFIG_BLUETOOTH_SMP */
}
if ((mask & BT_GATT_PERM_ENCRYPT_MASK)) {