From 81a2cd20fcd03ac4f7fd9de13dac41f44a1201ef Mon Sep 17 00:00:00 2001
From: Hauke Mehrtens <hauke@hauke-m.de>
Date: Sat, 24 Aug 2019 11:13:32 +0200
Subject: [PATCH] BLE: UART: Enforce encryption and authentication

It is now only possible to use this with encryption and authentication.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
---
 epicardium/ble/uart.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/epicardium/ble/uart.c b/epicardium/ble/uart.c
index ac3a32ac..c9d2f589 100644
--- a/epicardium/ble/uart.c
+++ b/epicardium/ble/uart.c
@@ -72,7 +72,8 @@ static const attsAttr_t uartAttrCfgList[] = {
 		.pLen        = NULL,
 		.maxLen      = 128,
 		.settings    = ATTS_SET_WRITE_CBACK | ATTS_SET_VARIABLE_LEN,
-		.permissions = ATTS_PERMIT_WRITE,
+		.permissions = ATTS_PERMIT_WRITE | ATTS_PERMIT_WRITE_ENC |
+			       ATTS_PERMIT_WRITE_AUTH,
 	},
 	/* UART tx characteristic */
 	{
@@ -91,7 +92,8 @@ static const attsAttr_t uartAttrCfgList[] = {
 		.pLen        = &uartTxCh_buf_len,
 		.maxLen      = sizeof(uartTxCh_buf),
 		.settings    = ATTS_SET_READ_CBACK,
-		.permissions = ATTS_PERMIT_READ,
+		.permissions = ATTS_PERMIT_READ | ATTS_PERMIT_READ_ENC |
+			       ATTS_PERMIT_READ_AUTH,
 	},
 	/* UART tx CCC descriptor */
 	{
@@ -100,7 +102,9 @@ static const attsAttr_t uartAttrCfgList[] = {
 		.pLen        = NULL,
 		.maxLen      = 0,
 		.settings    = ATTS_SET_CCC,
-		.permissions = ATTS_PERMIT_READ | ATTS_PERMIT_WRITE,
+		.permissions = ATTS_PERMIT_WRITE | ATTS_PERMIT_WRITE_ENC |
+			       ATTS_PERMIT_WRITE_AUTH | ATTS_PERMIT_READ |
+			       ATTS_PERMIT_READ_ENC | ATTS_PERMIT_READ_AUTH,
 	},
 };
 
-- 
GitLab