aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2020-08-28 21:34:51 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2020-08-28 21:34:51 +0000
commit9b8d6f75f1f2643144ab8ee226468ab8b2ab1c9f (patch)
treeaf72da966f8f736de91a97283081d448b11fd125
parent7c86810c44ef2efd97c3e78bd77e36257a05f75b (diff)
parentc3894d636014ce4fcd728d380b0c2d05e4686f53 (diff)
downloadbt-9b8d6f75f1f2643144ab8ee226468ab8b2ab1c9f.tar.gz
Merge "Send a response to an smp security request depending on the callback event" into pi-dev
-rw-r--r--stack/smp/smp_api.cc65
1 files changed, 35 insertions, 30 deletions
diff --git a/stack/smp/smp_api.cc b/stack/smp/smp_api.cc
index 579d023a7..e39ee793a 100644
--- a/stack/smp/smp_api.cc
+++ b/stack/smp/smp_api.cc
@@ -249,37 +249,42 @@ bool SMP_PairCancel(const RawAddress& bd_addr) {
void SMP_SecurityGrant(const RawAddress& bd_addr, uint8_t res) {
SMP_TRACE_EVENT("SMP_SecurityGrant ");
- // If JUSTWORKS, this is used to display the consent dialog
- if (smp_cb.selected_association_model == SMP_MODEL_SEC_CONN_JUSTWORKS) {
- if (res == SMP_SUCCESS) {
- smp_sm_event(&smp_cb, SMP_SC_NC_OK_EVT, NULL);
- } else {
- SMP_TRACE_WARNING("%s() - Consent dialog fails for JUSTWORKS", __func__);
- /* send pairing failure */
- tSMP_INT_DATA smp_int_data;
- smp_int_data.status = SMP_NUMERIC_COMPAR_FAIL;
- smp_sm_event(&smp_cb, SMP_AUTH_CMPL_EVT, &smp_int_data);
- }
- } else if (smp_cb.selected_association_model == SMP_MODEL_ENCRYPTION_ONLY) {
- if (res == SMP_SUCCESS) {
- smp_cb.sec_level = SMP_SEC_UNAUTHENTICATE;
-
- tSMP_KEY key;
- tSMP_INT_DATA smp_int_data;
- key.key_type = SMP_KEY_TYPE_TK;
- key.p_data = smp_cb.tk;
- smp_int_data.key = key;
-
- memset(smp_cb.tk, 0, BT_OCTET16_LEN);
- smp_sm_event(&smp_cb, SMP_KEY_READY_EVT, &smp_int_data);
- } else {
- SMP_TRACE_WARNING("%s() - Consent dialog fails for ENCRYPTION_ONLY",
- __func__);
- /* send pairing failure */
- tSMP_INT_DATA smp_int_data;
- smp_int_data.status = SMP_NUMERIC_COMPAR_FAIL;
- smp_sm_event(&smp_cb, SMP_AUTH_CMPL_EVT, &smp_int_data);
+ // If just showing consent dialog, send response
+ if (smp_cb.cb_evt == SMP_CONSENT_REQ_EVT) {
+ // If JUSTWORKS, this is used to display the consent dialog
+ if (smp_cb.selected_association_model == SMP_MODEL_SEC_CONN_JUSTWORKS) {
+ if (res == SMP_SUCCESS) {
+ smp_sm_event(&smp_cb, SMP_SC_NC_OK_EVT, NULL);
+ } else {
+ SMP_TRACE_WARNING("%s() - Consent dialog fails for JUSTWORKS",
+ __func__);
+ /* send pairing failure */
+ tSMP_INT_DATA smp_int_data;
+ smp_int_data.status = SMP_NUMERIC_COMPAR_FAIL;
+ smp_sm_event(&smp_cb, SMP_AUTH_CMPL_EVT, &smp_int_data);
+ }
+ } else if (smp_cb.selected_association_model == SMP_MODEL_ENCRYPTION_ONLY) {
+ if (res == SMP_SUCCESS) {
+ smp_cb.sec_level = SMP_SEC_UNAUTHENTICATE;
+
+ tSMP_KEY key;
+ tSMP_INT_DATA smp_int_data;
+ key.key_type = SMP_KEY_TYPE_TK;
+ key.p_data = smp_cb.tk;
+ smp_int_data.key = key;
+
+ memset(smp_cb.tk, 0, BT_OCTET16_LEN);
+ smp_sm_event(&smp_cb, SMP_KEY_READY_EVT, &smp_int_data);
+ } else {
+ SMP_TRACE_WARNING("%s() - Consent dialog fails for ENCRYPTION_ONLY",
+ __func__);
+ /* send pairing failure */
+ tSMP_INT_DATA smp_int_data;
+ smp_int_data.status = SMP_NUMERIC_COMPAR_FAIL;
+ smp_sm_event(&smp_cb, SMP_AUTH_CMPL_EVT, &smp_int_data);
+ }
}
+ return;
}
if (smp_cb.smp_over_br) {