PTS: Add a Secure Only mode.
Use Case:
Certification test cases require BLE to be in secure only
mode and reject legacy pairing requests.
Test Case: TP/SEC/SEM/BV-28-C
Failure:
Currently the host doesn't have a method of putting host into
a mode where it can only perform secure pairing.
This prevents execution of certification test cases
requiring Secure Only mode.
Fix:
Made changes to read the value of a tag "PTS_SecurePairOnly"
at runtime from the file "bt_stack.conf".
Bug: 27852645
Change-Id: I32cd6412621efeed2cb31c760a031762d9f369f9
diff --git a/conf/bt_stack.conf b/conf/bt_stack.conf
index 1278921..a965ba9 100644
--- a/conf/bt_stack.conf
+++ b/conf/bt_stack.conf
@@ -39,3 +39,8 @@
TRC_GAP=2
TRC_BNEP=2
TRC_PAN=2
+
+# PTS testing helps
+
+# Secure connections only mode.
+# PTS_SecurePairOnly=true
diff --git a/include/stack_config.h b/include/stack_config.h
index ff7f955..c249ad8 100644
--- a/include/stack_config.h
+++ b/include/stack_config.h
@@ -34,6 +34,7 @@
bool (*get_btsnoop_turned_on)(void);
bool (*get_btsnoop_should_save_last)(void);
bool (*get_trace_config_enabled)(void);
+ bool (*get_pts_secure_only_mode)(void);
config_t *(*get_all)(void);
} stack_config_t;
diff --git a/main/stack_config.c b/main/stack_config.c
index e5808da..9df9bb8 100644
--- a/main/stack_config.c
+++ b/main/stack_config.c
@@ -29,6 +29,7 @@
const char *BTSNOOP_TURNED_ON_KEY = "BtSnoopLogOutput";
const char *BTSNOOP_SHOULD_SAVE_LAST_KEY = "BtSnoopSaveLog";
const char *TRACE_CONFIG_ENABLED_KEY = "TraceConf";
+const char *PTS_SECURE_ONLY_MODE = "PTS_SecurePairOnly";
static config_t *config;
@@ -88,6 +89,10 @@
return config_get_bool(config, CONFIG_DEFAULT_SECTION, TRACE_CONFIG_ENABLED_KEY, false);
}
+static bool get_pts_secure_only_mode(void) {
+ return config_get_bool(config, CONFIG_DEFAULT_SECTION, PTS_SECURE_ONLY_MODE, false);
+}
+
static config_t *get_all(void) {
return config;
}
@@ -97,6 +102,7 @@
get_btsnoop_turned_on,
get_btsnoop_should_save_last,
get_trace_config_enabled,
+ get_pts_secure_only_mode,
get_all
};
diff --git a/stack/btm/btm_main.c b/stack/btm/btm_main.c
index dd49f97..93b0ecc 100644
--- a/stack/btm/btm_main.c
+++ b/stack/btm/btm_main.c
@@ -27,6 +27,7 @@
#include "bt_target.h"
#include <string.h>
#include "btm_int.h"
+#include "stack_config.h"
/* Global BTM control block structure
*/
@@ -63,7 +64,11 @@
/* Initialize BTM component structures */
btm_inq_db_init(); /* Inquiry Database and Structures */
btm_acl_init(); /* ACL Database and Structures */
- btm_sec_init(BTM_SEC_MODE_SP); /* Security Manager Database and Structures */
+ /* Security Manager Database and Structures */
+ if (stack_config_get_interface()->get_pts_secure_only_mode())
+ btm_sec_init(BTM_SEC_MODE_SC);
+ else
+ btm_sec_init(BTM_SEC_MODE_SP);
#if BTM_SCO_INCLUDED == TRUE
btm_sco_init(); /* SCO Database and Structures (If included) */
#endif