• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /******************************************************************************
2  *
3  *  Copyright 2008-2012 Broadcom Corporation
4  *
5  *  Licensed under the Apache License, Version 2.0 (the "License");
6  *  you may not use this file except in compliance with the License.
7  *  You may obtain a copy of the License at:
8  *
9  *  http://www.apache.org/licenses/LICENSE-2.0
10  *
11  *  Unless required by applicable law or agreed to in writing, software
12  *  distributed under the License is distributed on an "AS IS" BASIS,
13  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  *  See the License for the specific language governing permissions and
15  *  limitations under the License.
16  *
17  ******************************************************************************/
18 
19 /******************************************************************************
20  *
21  *  This file contains the implementation of the SMP interface used by
22  *  applications that can run over an SMP.
23  *
24  ******************************************************************************/
25 #include <base/logging.h>
26 #include <string.h>
27 
28 #include "bt_target.h"
29 #include "bt_utils.h"
30 #include "stack_config.h"
31 
32 #include "btm_int.h"
33 #include "hcimsgs.h"
34 #include "l2c_int.h"
35 #include "l2cdefs.h"
36 #include "smp_api.h"
37 #include "smp_int.h"
38 
39 #include "btu.h"
40 #include "p_256_ecc_pp.h"
41 
42 /*******************************************************************************
43  *
44  * Function         SMP_Init
45  *
46  * Description      This function initializes the SMP unit.
47  *
48  * Returns          void
49  *
50  ******************************************************************************/
SMP_Init(void)51 void SMP_Init(void) {
52   memset(&smp_cb, 0, sizeof(tSMP_CB));
53   smp_cb.smp_rsp_timer_ent = alarm_new("smp.smp_rsp_timer_ent");
54   smp_cb.delayed_auth_timer_ent = alarm_new("smp.delayed_auth_timer_ent");
55 
56 #if defined(SMP_INITIAL_TRACE_LEVEL)
57   smp_cb.trace_level = SMP_INITIAL_TRACE_LEVEL;
58 #else
59   smp_cb.trace_level = BT_TRACE_LEVEL_NONE; /* No traces */
60 #endif
61   SMP_TRACE_EVENT("%s", __func__);
62 
63   smp_l2cap_if_init();
64   /* initialization of P-256 parameters */
65   p_256_init_curve();
66 
67   /* Initialize failure case for certification */
68   smp_cb.cert_failure =
69       stack_config_get_interface()->get_pts_smp_failure_case();
70   if (smp_cb.cert_failure)
71     SMP_TRACE_ERROR("%s PTS FAILURE MODE IN EFFECT (CASE %d)", __func__,
72                     smp_cb.cert_failure);
73 }
74 
75 /*******************************************************************************
76  *
77  * Function         SMP_SetTraceLevel
78  *
79  * Description      This function sets the trace level for SMP.  If called with
80  *                  a value of 0xFF, it simply returns the current trace level.
81  *
82  *                  Input Parameters:
83  *                      level:  The level to set the GATT tracing to:
84  *                      0xff-returns the current setting.
85  *                      0-turns off tracing.
86  *                      >= 1-Errors.
87  *                      >= 2-Warnings.
88  *                      >= 3-APIs.
89  *                      >= 4-Events.
90  *                      >= 5-Debug.
91  *
92  * Returns          The new or current trace level
93  *
94  ******************************************************************************/
SMP_SetTraceLevel(uint8_t new_level)95 extern uint8_t SMP_SetTraceLevel(uint8_t new_level) {
96   if (new_level != 0xFF) smp_cb.trace_level = new_level;
97 
98   return (smp_cb.trace_level);
99 }
100 
101 /*******************************************************************************
102  *
103  * Function         SMP_Register
104  *
105  * Description      This function register for the SMP services callback.
106  *
107  * Returns          void
108  *
109  ******************************************************************************/
SMP_Register(tSMP_CALLBACK * p_cback)110 bool SMP_Register(tSMP_CALLBACK* p_cback) {
111   SMP_TRACE_EVENT("SMP_Register state=%d", smp_cb.state);
112 
113   if (smp_cb.p_callback != NULL) {
114     SMP_TRACE_ERROR("SMP_Register: duplicate registration, overwrite it");
115   }
116   smp_cb.p_callback = p_cback;
117 
118   return (true);
119 }
120 
121 /*******************************************************************************
122  *
123  * Function         SMP_Pair
124  *
125  * Description      This function call to perform a SMP pairing with peer
126  *                  device. Device support one SMP pairing at one time.
127  *
128  * Parameters       bd_addr - peer device bd address.
129  *
130  * Returns          None
131  *
132  ******************************************************************************/
SMP_Pair(const RawAddress & bd_addr)133 tSMP_STATUS SMP_Pair(const RawAddress& bd_addr) {
134   tSMP_CB* p_cb = &smp_cb;
135 
136   SMP_TRACE_EVENT("%s: state=%d br_state=%d flag=0x%x, bd_addr=%s", __func__,
137                   p_cb->state, p_cb->br_state, p_cb->flags,
138                   bd_addr.ToString().c_str());
139 
140   if (p_cb->state != SMP_STATE_IDLE ||
141       p_cb->flags & SMP_PAIR_FLAGS_WE_STARTED_DD || p_cb->smp_over_br) {
142     /* pending security on going, reject this one */
143     return SMP_BUSY;
144   } else {
145     p_cb->flags = SMP_PAIR_FLAGS_WE_STARTED_DD;
146     p_cb->pairing_bda = bd_addr;
147 
148     if (!L2CA_ConnectFixedChnl(L2CAP_SMP_CID, bd_addr)) {
149       tSMP_INT_DATA smp_int_data;
150       smp_int_data.status = SMP_PAIR_INTERNAL_ERR;
151       SMP_TRACE_ERROR("%s: L2C connect fixed channel failed.", __func__);
152       smp_sm_event(p_cb, SMP_AUTH_CMPL_EVT, &smp_int_data);
153       return SMP_PAIR_INTERNAL_ERR;
154     }
155 
156     return SMP_STARTED;
157   }
158 }
159 
160 /*******************************************************************************
161  *
162  * Function         SMP_BR_PairWith
163  *
164  * Description      This function is called to start a SMP pairing over BR/EDR.
165  *                  Device support one SMP pairing at one time.
166  *
167  * Parameters       bd_addr - peer device bd address.
168  *
169  * Returns          SMP_STARTED if pairing started, otherwise the reason for
170  *                  failure.
171  *
172  ******************************************************************************/
SMP_BR_PairWith(const RawAddress & bd_addr)173 tSMP_STATUS SMP_BR_PairWith(const RawAddress& bd_addr) {
174   tSMP_CB* p_cb = &smp_cb;
175 
176   SMP_TRACE_EVENT("%s: state=%d br_state=%d flag=0x%x, bd_addr=%s", __func__,
177                   p_cb->state, p_cb->br_state, p_cb->flags,
178                   bd_addr.ToString().c_str());
179 
180   if (p_cb->state != SMP_STATE_IDLE || p_cb->smp_over_br ||
181       p_cb->flags & SMP_PAIR_FLAGS_WE_STARTED_DD) {
182     /* pending security on going, reject this one */
183     return SMP_BUSY;
184   }
185 
186   p_cb->role = HCI_ROLE_MASTER;
187   p_cb->flags = SMP_PAIR_FLAGS_WE_STARTED_DD;
188   p_cb->smp_over_br = true;
189   p_cb->pairing_bda = bd_addr;
190 
191   if (!L2CA_ConnectFixedChnl(L2CAP_SMP_BR_CID, bd_addr)) {
192     SMP_TRACE_ERROR("%s: L2C connect fixed channel failed.", __func__);
193     tSMP_INT_DATA smp_int_data;
194     smp_int_data.status = SMP_PAIR_INTERNAL_ERR;
195     smp_br_state_machine_event(p_cb, SMP_BR_AUTH_CMPL_EVT, &smp_int_data);
196     return SMP_PAIR_INTERNAL_ERR;
197   }
198 
199   return SMP_STARTED;
200 }
201 
202 /*******************************************************************************
203  *
204  * Function         SMP_PairCancel
205  *
206  * Description      This function call to cancel a SMP pairing with peer device.
207  *
208  * Parameters       bd_addr - peer device bd address.
209  *
210  * Returns          true - Pairining is cancelled
211  *
212  ******************************************************************************/
SMP_PairCancel(const RawAddress & bd_addr)213 bool SMP_PairCancel(const RawAddress& bd_addr) {
214   tSMP_CB* p_cb = &smp_cb;
215   uint8_t err_code = SMP_PAIR_FAIL_UNKNOWN;
216 
217   // PTS SMP failure test cases
218   if (p_cb->cert_failure == SMP_PASSKEY_ENTRY_FAIL ||
219       p_cb->cert_failure == SMP_NUMERIC_COMPAR_FAIL)
220     err_code = p_cb->cert_failure;
221 
222   BTM_TRACE_EVENT("SMP_CancelPair state=%d flag=0x%x ", p_cb->state,
223                   p_cb->flags);
224   if (p_cb->state != SMP_STATE_IDLE && p_cb->pairing_bda == bd_addr) {
225     p_cb->is_pair_cancel = true;
226     SMP_TRACE_DEBUG("Cancel Pairing: set fail reason Unknown");
227     tSMP_INT_DATA smp_int_data;
228     smp_int_data.status = SMP_PAIR_FAIL_UNKNOWN;
229     smp_sm_event(p_cb, SMP_AUTH_CMPL_EVT, &smp_int_data);
230     return true;
231   }
232 
233   return false;
234 }
235 /*******************************************************************************
236  *
237  * Function         SMP_SecurityGrant
238  *
239  * Description      This function is called to grant security process.
240  *
241  * Parameters       bd_addr - peer device bd address.
242  *                  res     - result of the operation SMP_SUCCESS if success.
243  *                            Otherwise, SMP_REPEATED_ATTEMPTS if too many
244  *                            attempts.
245  *
246  * Returns          None
247  *
248  ******************************************************************************/
SMP_SecurityGrant(const RawAddress & bd_addr,uint8_t res)249 void SMP_SecurityGrant(const RawAddress& bd_addr, uint8_t res) {
250   SMP_TRACE_EVENT("SMP_SecurityGrant ");
251 
252   // If just showing consent dialog, send response
253   if (smp_cb.cb_evt == SMP_CONSENT_REQ_EVT) {
254     // If JUSTWORKS, this is used to display the consent dialog
255     if (smp_cb.selected_association_model == SMP_MODEL_SEC_CONN_JUSTWORKS) {
256       if (res == SMP_SUCCESS) {
257         smp_sm_event(&smp_cb, SMP_SC_NC_OK_EVT, NULL);
258       } else {
259         SMP_TRACE_WARNING("%s() - Consent dialog fails for JUSTWORKS",
260                           __func__);
261         /* send pairing failure */
262         tSMP_INT_DATA smp_int_data;
263         smp_int_data.status = SMP_NUMERIC_COMPAR_FAIL;
264         smp_sm_event(&smp_cb, SMP_AUTH_CMPL_EVT, &smp_int_data);
265       }
266     } else if (smp_cb.selected_association_model == SMP_MODEL_ENCRYPTION_ONLY) {
267       if (res == SMP_SUCCESS) {
268         smp_cb.sec_level = SMP_SEC_UNAUTHENTICATE;
269 
270         tSMP_KEY key;
271         tSMP_INT_DATA smp_int_data;
272         key.key_type = SMP_KEY_TYPE_TK;
273         key.p_data = smp_cb.tk.data();
274         smp_int_data.key = key;
275 
276         smp_cb.tk = {0};
277         smp_sm_event(&smp_cb, SMP_KEY_READY_EVT, &smp_int_data);
278       } else {
279         SMP_TRACE_WARNING("%s() - Consent dialog fails for ENCRYPTION_ONLY",
280                           __func__);
281         /* send pairing failure */
282         tSMP_INT_DATA smp_int_data;
283         smp_int_data.status = SMP_NUMERIC_COMPAR_FAIL;
284         smp_sm_event(&smp_cb, SMP_AUTH_CMPL_EVT, &smp_int_data);
285       }
286     }
287     return;
288   }
289 
290   if (smp_cb.smp_over_br) {
291     if (smp_cb.br_state != SMP_BR_STATE_WAIT_APP_RSP ||
292         smp_cb.cb_evt != SMP_SEC_REQUEST_EVT || smp_cb.pairing_bda != bd_addr) {
293       return;
294     }
295 
296     /* clear the SMP_SEC_REQUEST_EVT event after get grant */
297     /* avoid generating duplicate pair request */
298     smp_cb.cb_evt = 0;
299     tSMP_INT_DATA smp_int_data;
300     smp_int_data.status = res;
301     smp_br_state_machine_event(&smp_cb, SMP_BR_API_SEC_GRANT_EVT,
302                                &smp_int_data);
303     return;
304   }
305 
306   if (smp_cb.state != SMP_STATE_WAIT_APP_RSP ||
307       smp_cb.cb_evt != SMP_SEC_REQUEST_EVT || smp_cb.pairing_bda != bd_addr)
308     return;
309   /* clear the SMP_SEC_REQUEST_EVT event after get grant */
310   /* avoid generate duplicate pair request */
311   smp_cb.cb_evt = 0;
312   tSMP_INT_DATA smp_int_data;
313   smp_int_data.status = res;
314   smp_sm_event(&smp_cb, SMP_API_SEC_GRANT_EVT, &smp_int_data);
315 }
316 
317 /*******************************************************************************
318  *
319  * Function         SMP_PasskeyReply
320  *
321  * Description      This function is called after Security Manager submitted
322  *                  passkey request to the application.
323  *
324  * Parameters:      bd_addr - Address of the device for which passkey was
325  *                            requested
326  *                  res     - result of the operation SMP_SUCCESS if success
327  *                  passkey - numeric value in the range of
328  *                            BTM_MIN_PASSKEY_VAL(0) -
329  *                            BTM_MAX_PASSKEY_VAL(999999(0xF423F)).
330  *
331  ******************************************************************************/
SMP_PasskeyReply(const RawAddress & bd_addr,uint8_t res,uint32_t passkey)332 void SMP_PasskeyReply(const RawAddress& bd_addr, uint8_t res,
333                       uint32_t passkey) {
334   tSMP_CB* p_cb = &smp_cb;
335 
336   SMP_TRACE_EVENT("SMP_PasskeyReply: Key: %d  Result:%d", passkey, res);
337 
338   /* If timeout already expired or has been canceled, ignore the reply */
339   if (p_cb->cb_evt != SMP_PASSKEY_REQ_EVT) {
340     SMP_TRACE_WARNING("SMP_PasskeyReply() - Wrong State: %d", p_cb->state);
341     return;
342   }
343 
344   if (bd_addr != p_cb->pairing_bda) {
345     SMP_TRACE_ERROR("SMP_PasskeyReply() - Wrong BD Addr");
346     return;
347   }
348 
349   if (btm_find_dev(bd_addr) == NULL) {
350     SMP_TRACE_ERROR("SMP_PasskeyReply() - no dev CB");
351     return;
352   }
353 
354   if (passkey > BTM_MAX_PASSKEY_VAL || res != SMP_SUCCESS) {
355     SMP_TRACE_WARNING(
356         "SMP_PasskeyReply() - Wrong key len: %d or passkey entry fail",
357         passkey);
358     /* send pairing failure */
359     tSMP_INT_DATA smp_int_data;
360     smp_int_data.status = SMP_PASSKEY_ENTRY_FAIL;
361     smp_sm_event(p_cb, SMP_AUTH_CMPL_EVT, &smp_int_data);
362 
363   } else if (p_cb->selected_association_model ==
364              SMP_MODEL_SEC_CONN_PASSKEY_ENT) {
365     tSMP_INT_DATA smp_int_data;
366     smp_int_data.passkey = passkey;
367     smp_sm_event(&smp_cb, SMP_SC_KEY_READY_EVT, &smp_int_data);
368   } else {
369     smp_convert_string_to_tk(&p_cb->tk, passkey);
370   }
371 
372   return;
373 }
374 
375 /*******************************************************************************
376  *
377  * Function         SMP_ConfirmReply
378  *
379  * Description      This function is called after Security Manager submitted
380  *                  numeric comparison request to the application.
381  *
382  * Parameters:      bd_addr      - Address of the device with which numeric
383  *                                 comparison was requested
384  *                  res          - comparison result SMP_SUCCESS if success
385  *
386  ******************************************************************************/
SMP_ConfirmReply(const RawAddress & bd_addr,uint8_t res)387 void SMP_ConfirmReply(const RawAddress& bd_addr, uint8_t res) {
388   tSMP_CB* p_cb = &smp_cb;
389 
390   SMP_TRACE_EVENT("%s: Result:%d", __func__, res);
391 
392   /* If timeout already expired or has been canceled, ignore the reply */
393   if (p_cb->cb_evt != SMP_NC_REQ_EVT) {
394     SMP_TRACE_WARNING("%s() - Wrong State: %d", __func__, p_cb->state);
395     return;
396   }
397 
398   if (bd_addr != p_cb->pairing_bda) {
399     SMP_TRACE_ERROR("%s() - Wrong BD Addr", __func__);
400     return;
401   }
402 
403   if (btm_find_dev(bd_addr) == NULL) {
404     SMP_TRACE_ERROR("%s() - no dev CB", __func__);
405     return;
406   }
407 
408   if (res != SMP_SUCCESS) {
409     SMP_TRACE_WARNING("%s() - Numeric Comparison fails", __func__);
410     /* send pairing failure */
411     tSMP_INT_DATA smp_int_data;
412     smp_int_data.status = SMP_NUMERIC_COMPAR_FAIL;
413     smp_sm_event(p_cb, SMP_AUTH_CMPL_EVT, &smp_int_data);
414   } else {
415     smp_sm_event(p_cb, SMP_SC_NC_OK_EVT, NULL);
416   }
417 }
418 
419 /*******************************************************************************
420  *
421  * Function         SMP_OobDataReply
422  *
423  * Description      This function is called to provide the OOB data for
424  *                  SMP in response to SMP_OOB_REQ_EVT
425  *
426  * Parameters:      bd_addr     - Address of the peer device
427  *                  res         - result of the operation SMP_SUCCESS if success
428  *                  p_data      - simple pairing Randomizer  C.
429  *
430  ******************************************************************************/
SMP_OobDataReply(const RawAddress & bd_addr,tSMP_STATUS res,uint8_t len,uint8_t * p_data)431 void SMP_OobDataReply(const RawAddress& bd_addr, tSMP_STATUS res, uint8_t len,
432                       uint8_t* p_data) {
433   tSMP_CB* p_cb = &smp_cb;
434   tSMP_KEY key;
435 
436   SMP_TRACE_EVENT("%s State: %d  res:%d", __func__, smp_cb.state, res);
437 
438   /* If timeout already expired or has been canceled, ignore the reply */
439   if (p_cb->state != SMP_STATE_WAIT_APP_RSP || p_cb->cb_evt != SMP_OOB_REQ_EVT)
440     return;
441 
442   if (res != SMP_SUCCESS || len == 0 || !p_data) {
443     tSMP_INT_DATA smp_int_data;
444     smp_int_data.status = SMP_OOB_FAIL;
445     smp_sm_event(p_cb, SMP_AUTH_CMPL_EVT, &smp_int_data);
446   } else {
447     if (len > OCTET16_LEN) len = OCTET16_LEN;
448 
449     memcpy(p_cb->tk.data(), p_data, len);
450 
451     key.key_type = SMP_KEY_TYPE_TK;
452     key.p_data = p_cb->tk.data();
453 
454     tSMP_INT_DATA smp_int_data;
455     smp_int_data.key = key;
456     smp_sm_event(&smp_cb, SMP_KEY_READY_EVT, &smp_int_data);
457   }
458 }
459 
460 /*******************************************************************************
461  *
462  * Function         SMP_SecureConnectionOobDataReply
463  *
464  * Description      This function is called to provide the SC OOB data for
465  *                  SMP in response to SMP_SC_OOB_REQ_EVT
466  *
467  * Parameters:      p_data      - pointer to the data
468  *
469  ******************************************************************************/
SMP_SecureConnectionOobDataReply(uint8_t * p_data)470 void SMP_SecureConnectionOobDataReply(uint8_t* p_data) {
471   tSMP_CB* p_cb = &smp_cb;
472 
473   tSMP_SC_OOB_DATA* p_oob = (tSMP_SC_OOB_DATA*)p_data;
474   if (!p_oob) {
475     SMP_TRACE_ERROR("%s received no data", __func__);
476     tSMP_INT_DATA smp_int_data;
477     smp_int_data.status = SMP_OOB_FAIL;
478     smp_sm_event(p_cb, SMP_AUTH_CMPL_EVT, &smp_int_data);
479     return;
480   }
481 
482   SMP_TRACE_EVENT(
483       "%s req_oob_type: %d, loc_oob_data.present: %d, "
484       "peer_oob_data.present: %d",
485       __func__, p_cb->req_oob_type, p_oob->loc_oob_data.present,
486       p_oob->peer_oob_data.present);
487 
488   if (p_cb->state != SMP_STATE_WAIT_APP_RSP ||
489       p_cb->cb_evt != SMP_SC_OOB_REQ_EVT)
490     return;
491 
492   bool data_missing = false;
493   switch (p_cb->req_oob_type) {
494     case SMP_OOB_PEER:
495       if (!p_oob->peer_oob_data.present) data_missing = true;
496       break;
497     case SMP_OOB_LOCAL:
498       if (!p_oob->loc_oob_data.present) data_missing = true;
499       break;
500     case SMP_OOB_BOTH:
501       if (!p_oob->loc_oob_data.present || !p_oob->peer_oob_data.present)
502         data_missing = true;
503       break;
504     default:
505       SMP_TRACE_EVENT("Unexpected OOB data type requested. Fail OOB");
506       data_missing = true;
507       break;
508   }
509 
510   tSMP_INT_DATA smp_int_data;
511   if (data_missing) {
512     smp_int_data.status = SMP_OOB_FAIL;
513     smp_sm_event(p_cb, SMP_AUTH_CMPL_EVT, &smp_int_data);
514     return;
515   }
516 
517   p_cb->sc_oob_data = *p_oob;
518 
519   smp_int_data.p_data = p_data;
520   smp_sm_event(&smp_cb, SMP_SC_OOB_DATA_EVT, &smp_int_data);
521 }
522 
523 /*******************************************************************************
524  *
525  * Function         SMP_KeypressNotification
526  *
527  * Description      This function is called to notify Security Manager about
528  *                  Keypress Notification.
529  *
530  * Parameters:     bd_addr      Address of the device to send keypress
531  *                              notification to
532  *                 value        Keypress notification parameter value
533  *
534  ******************************************************************************/
SMP_KeypressNotification(const RawAddress & bd_addr,uint8_t value)535 void SMP_KeypressNotification(const RawAddress& bd_addr, uint8_t value) {
536   tSMP_CB* p_cb = &smp_cb;
537 
538   SMP_TRACE_EVENT("%s: Value: %d", __func__, value);
539 
540   if (bd_addr != p_cb->pairing_bda) {
541     SMP_TRACE_ERROR("%s() - Wrong BD Addr", __func__);
542     return;
543   }
544 
545   if (btm_find_dev(bd_addr) == NULL) {
546     SMP_TRACE_ERROR("%s() - no dev CB", __func__);
547     return;
548   }
549 
550   /* Keypress Notification is used by a device with KeyboardOnly IO capabilities
551    * during the passkey entry protocol */
552   if (p_cb->local_io_capability != SMP_IO_CAP_IN) {
553     SMP_TRACE_ERROR("%s() - wrong local IO capabilities %d", __func__,
554                     p_cb->local_io_capability);
555     return;
556   }
557 
558   if (p_cb->selected_association_model != SMP_MODEL_SEC_CONN_PASSKEY_ENT) {
559     SMP_TRACE_ERROR("%s() - wrong protocol %d", __func__,
560                     p_cb->selected_association_model);
561     return;
562   }
563 
564   tSMP_INT_DATA smp_int_data;
565   smp_int_data.status = value;
566   smp_sm_event(p_cb, SMP_KEYPRESS_NOTIFICATION_EVENT, &smp_int_data);
567 }
568 
569 /*******************************************************************************
570  *
571  * Function         SMP_CreateLocalSecureConnectionsOobData
572  *
573  * Description      This function is called to start creation of local SC OOB
574  *                  data set (tSMP_LOC_OOB_DATA).
575  *
576  * Parameters:      bd_addr - Address of the device to send OOB data block to
577  *
578  *  Returns         Boolean - true: creation of local SC OOB data set started.
579  ******************************************************************************/
SMP_CreateLocalSecureConnectionsOobData(tBLE_BD_ADDR * addr_to_send_to)580 bool SMP_CreateLocalSecureConnectionsOobData(tBLE_BD_ADDR* addr_to_send_to) {
581   tSMP_CB* p_cb = &smp_cb;
582 
583   if (addr_to_send_to == NULL) {
584     SMP_TRACE_ERROR("%s addr_to_send_to is not provided", __func__);
585     return false;
586   }
587 
588   VLOG(2) << __func__ << " addr type:" << +addr_to_send_to->type
589           << ", BDA:" << addr_to_send_to->bda << ", state:" << p_cb->state
590           << ", br_state: " << p_cb->br_state;
591 
592   if ((p_cb->state != SMP_STATE_IDLE) || (p_cb->smp_over_br)) {
593     SMP_TRACE_WARNING(
594         "%s creation of local OOB data set "
595         "starts only in IDLE state",
596         __func__);
597     return false;
598   }
599 
600   p_cb->sc_oob_data.loc_oob_data.addr_sent_to = *addr_to_send_to;
601   smp_sm_event(p_cb, SMP_CR_LOC_SC_OOB_DATA_EVT, NULL);
602 
603   return true;
604 }
605