1 /****************************************************************************** 2 * 3 * Copyright (C) 1999-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 internally used SMP definitions 22 * 23 ******************************************************************************/ 24 #ifndef SMP_INT_H 25 #define SMP_INT_H 26 27 // #if (SMP_INCLUDED == TRUE) 28 29 #include "stack/btu.h" 30 #include "stack/btm_ble_api.h" 31 #include "stack/btm_api.h" 32 #include "stack/smp_api.h" 33 34 #define SMP_MODEL_ENCRYPTION_ONLY 0 /* Legacy mode, Just Works model */ 35 #define SMP_MODEL_PASSKEY 1 /* Legacy mode, Passkey Entry model, this side inputs the key */ 36 #define SMP_MODEL_OOB 2 /* Legacy mode, OOB model */ 37 #define SMP_MODEL_KEY_NOTIF 3 /* Legacy mode, Passkey Entry model, this side displays the key */ 38 #define SMP_MODEL_SEC_CONN_JUSTWORKS 4 /* Secure Connections mode, Just Works model */ 39 #define SMP_MODEL_SEC_CONN_NUM_COMP 5 /* Secure Connections mode, Numeric Comparison model */ 40 #define SMP_MODEL_SEC_CONN_PASSKEY_ENT 6 /* Secure Connections mode, Passkey Entry model, */ 41 /* this side inputs the key */ 42 #define SMP_MODEL_SEC_CONN_PASSKEY_DISP 7 /* Secure Connections mode, Passkey Entry model, */ 43 /* this side displays the key */ 44 #define SMP_MODEL_SEC_CONN_OOB 8 /* Secure Connections mode, OOB model */ 45 #define SMP_MODEL_OUT_OF_RANGE 9 46 typedef UINT8 tSMP_ASSO_MODEL; 47 48 49 #ifndef SMP_MAX_CONN 50 #define SMP_MAX_CONN 2 51 #endif 52 53 #define SMP_WAIT_FOR_RSP_TOUT 30 54 55 #define SMP_OPCODE_INIT 0x04 56 57 /* SMP events */ 58 #define SMP_PAIRING_REQ_EVT SMP_OPCODE_PAIRING_REQ 59 #define SMP_PAIRING_RSP_EVT SMP_OPCODE_PAIRING_RSP 60 #define SMP_CONFIRM_EVT SMP_OPCODE_CONFIRM 61 #define SMP_RAND_EVT SMP_OPCODE_RAND 62 #define SMP_PAIRING_FAILED_EVT SMP_OPCODE_PAIRING_FAILED 63 #define SMP_ENCRPTION_INFO_EVT SMP_OPCODE_ENCRYPT_INFO 64 #define SMP_MASTER_ID_EVT SMP_OPCODE_MASTER_ID 65 #define SMP_ID_INFO_EVT SMP_OPCODE_IDENTITY_INFO 66 #define SMP_ID_ADDR_EVT SMP_OPCODE_ID_ADDR 67 #define SMP_SIGN_INFO_EVT SMP_OPCODE_SIGN_INFO 68 #define SMP_SECURITY_REQ_EVT SMP_OPCODE_SEC_REQ 69 70 #define SMP_PAIR_PUBLIC_KEY_EVT SMP_OPCODE_PAIR_PUBLIC_KEY 71 #define SMP_PAIR_KEYPRESS_NOTIFICATION_EVT SMP_OPCODE_PAIR_KEYPR_NOTIF 72 73 #define SMP_PAIR_COMMITM_EVT SMP_OPCODE_PAIR_COMMITM 74 75 #define SMP_SELF_DEF_EVT (SMP_PAIR_COMMITM_EVT + 1) 76 #define SMP_KEY_READY_EVT (SMP_SELF_DEF_EVT) 77 #define SMP_ENCRYPTED_EVT (SMP_SELF_DEF_EVT + 1) 78 #define SMP_L2CAP_CONN_EVT (SMP_SELF_DEF_EVT + 2) 79 #define SMP_L2CAP_DISCONN_EVT (SMP_SELF_DEF_EVT + 3) 80 #define SMP_IO_RSP_EVT (SMP_SELF_DEF_EVT + 4) 81 #define SMP_API_SEC_GRANT_EVT (SMP_SELF_DEF_EVT + 5) 82 #define SMP_TK_REQ_EVT (SMP_SELF_DEF_EVT + 6) 83 #define SMP_AUTH_CMPL_EVT (SMP_SELF_DEF_EVT + 7) 84 #define SMP_ENC_REQ_EVT (SMP_SELF_DEF_EVT + 8) 85 #define SMP_BOND_REQ_EVT (SMP_SELF_DEF_EVT + 9) 86 #define SMP_DISCARD_SEC_REQ_EVT (SMP_SELF_DEF_EVT + 10) 87 88 #define SMP_PAIR_DHKEY_CHCK_EVT SMP_OPCODE_PAIR_DHKEY_CHECK 89 90 #define SMP_PUBL_KEY_EXCH_REQ_EVT (SMP_SELF_DEF_EVT + 11) /* request to start public */ 91 /* key exchange */ 92 93 #define SMP_LOC_PUBL_KEY_CRTD_EVT (SMP_SELF_DEF_EVT + 12) /* local public key created */ 94 95 #define SMP_BOTH_PUBL_KEYS_RCVD_EVT (SMP_SELF_DEF_EVT + 13) /* both local and peer public */ 96 /* keys are saved in cb */ 97 98 #define SMP_SC_DHKEY_CMPLT_EVT (SMP_SELF_DEF_EVT + 14) /* DHKey computation is completed,*/ 99 /* time to start SC phase1 */ 100 101 #define SMP_HAVE_LOC_NONCE_EVT (SMP_SELF_DEF_EVT + 15) /* new local nonce is generated */ 102 /*and saved in p_cb->rand */ 103 104 #define SMP_SC_PHASE1_CMPLT_EVT (SMP_SELF_DEF_EVT + 16) /* time to start SC phase2 */ 105 106 #define SMP_SC_CALC_NC_EVT (SMP_SELF_DEF_EVT + 17) /* request to calculate number */ 107 /* for user check. Used only in the */ 108 /* numeric compare protocol */ 109 110 /* Request to display the number for user check to the user.*/ 111 /* Used only in the numeric compare protocol */ 112 #define SMP_SC_DSPL_NC_EVT (SMP_SELF_DEF_EVT + 18) 113 114 #define SMP_SC_NC_OK_EVT (SMP_SELF_DEF_EVT + 19) /* user confirms 'OK' numeric */ 115 /*comparison request */ 116 117 /* both local and peer DHKey Checks are already present - it is used on slave to prevent race condition */ 118 #define SMP_SC_2_DHCK_CHKS_PRES_EVT (SMP_SELF_DEF_EVT + 20) 119 120 /* same meaning as SMP_KEY_READY_EVT to separate between SC and legacy actions */ 121 #define SMP_SC_KEY_READY_EVT (SMP_SELF_DEF_EVT + 21) 122 #define SMP_KEYPRESS_NOTIFICATION_EVENT (SMP_SELF_DEF_EVT + 22) 123 124 #define SMP_SC_OOB_DATA_EVT (SMP_SELF_DEF_EVT + 23) /* SC OOB data from some */ 125 /* repository is provided */ 126 127 #define SMP_CR_LOC_SC_OOB_DATA_EVT (SMP_SELF_DEF_EVT + 24) 128 #define SMP_MAX_EVT SMP_CR_LOC_SC_OOB_DATA_EVT 129 130 typedef UINT8 tSMP_EVENT; 131 132 /* Assumption it's only using the low 8 bits, if bigger than that, need to expand it to 16 bits */ 133 #define SMP_SEC_KEY_MASK 0x00ff 134 135 #define SMP_PASSKEY_MASK 0xfff00000 136 137 /* SMP pairing state */ 138 enum { 139 SMP_STATE_IDLE, 140 SMP_STATE_WAIT_APP_RSP, 141 SMP_STATE_SEC_REQ_PENDING, 142 SMP_STATE_PAIR_REQ_RSP, 143 SMP_STATE_WAIT_CONFIRM, 144 SMP_STATE_CONFIRM, 145 SMP_STATE_RAND, 146 SMP_STATE_PUBLIC_KEY_EXCH, 147 SMP_STATE_SEC_CONN_PHS1_START, 148 SMP_STATE_WAIT_COMMITMENT, 149 SMP_STATE_WAIT_NONCE, 150 SMP_STATE_SEC_CONN_PHS2_START, 151 SMP_STATE_WAIT_DHK_CHECK, 152 SMP_STATE_DHK_CHECK, 153 SMP_STATE_ENCRYPTION_PENDING, 154 SMP_STATE_BOND_PENDING, 155 SMP_STATE_CREATE_LOCAL_SEC_CONN_OOB_DATA, 156 SMP_STATE_MAX 157 }; 158 typedef UINT8 tSMP_STATE; 159 160 /* SMP over BR/EDR events */ 161 #define SMP_BR_PAIRING_REQ_EVT SMP_OPCODE_PAIRING_REQ 162 #define SMP_BR_PAIRING_RSP_EVT SMP_OPCODE_PAIRING_RSP 163 #define SMP_BR_CONFIRM_EVT SMP_OPCODE_CONFIRM /* not expected over BR/EDR */ 164 #define SMP_BR_RAND_EVT SMP_OPCODE_RAND /* not expected over BR/EDR */ 165 #define SMP_BR_PAIRING_FAILED_EVT SMP_OPCODE_PAIRING_FAILED 166 #define SMP_BR_ENCRPTION_INFO_EVT SMP_OPCODE_ENCRYPT_INFO /* not expected over BR/EDR */ 167 #define SMP_BR_MASTER_ID_EVT SMP_OPCODE_MASTER_ID /* not expected over BR/EDR */ 168 #define SMP_BR_ID_INFO_EVT SMP_OPCODE_IDENTITY_INFO 169 #define SMP_BR_ID_ADDR_EVT SMP_OPCODE_ID_ADDR 170 #define SMP_BR_SIGN_INFO_EVT SMP_OPCODE_SIGN_INFO 171 #define SMP_BR_SECURITY_REQ_EVT SMP_OPCODE_SEC_REQ /* not expected over BR/EDR */ 172 #define SMP_BR_PAIR_PUBLIC_KEY_EVT SMP_OPCODE_PAIR_PUBLIC_KEY /* not expected over BR/EDR */ 173 #define SMP_BR_PAIR_DHKEY_CHCK_EVT SMP_OPCODE_PAIR_DHKEY_CHECK /* not expected over BR/EDR */ 174 #define SMP_BR_PAIR_KEYPR_NOTIF_EVT SMP_OPCODE_PAIR_KEYPR_NOTIF /* not expected over BR/EDR */ 175 #define SMP_BR_SELF_DEF_EVT SMP_BR_PAIR_KEYPR_NOTIF_EVT 176 #define SMP_BR_KEY_READY_EVT (SMP_BR_SELF_DEF_EVT + 1) 177 #define SMP_BR_ENCRYPTED_EVT (SMP_BR_SELF_DEF_EVT + 2) 178 #define SMP_BR_L2CAP_CONN_EVT (SMP_BR_SELF_DEF_EVT + 3) 179 #define SMP_BR_L2CAP_DISCONN_EVT (SMP_BR_SELF_DEF_EVT + 4) 180 #define SMP_BR_KEYS_RSP_EVT (SMP_BR_SELF_DEF_EVT + 5) 181 #define SMP_BR_API_SEC_GRANT_EVT (SMP_BR_SELF_DEF_EVT + 6) 182 #define SMP_BR_TK_REQ_EVT (SMP_BR_SELF_DEF_EVT + 7) 183 #define SMP_BR_AUTH_CMPL_EVT (SMP_BR_SELF_DEF_EVT + 8) 184 #define SMP_BR_ENC_REQ_EVT (SMP_BR_SELF_DEF_EVT + 9) 185 #define SMP_BR_BOND_REQ_EVT (SMP_BR_SELF_DEF_EVT + 10) 186 #define SMP_BR_DISCARD_SEC_REQ_EVT (SMP_BR_SELF_DEF_EVT + 11) 187 #define SMP_BR_MAX_EVT (SMP_BR_SELF_DEF_EVT + 12) 188 typedef UINT8 tSMP_BR_EVENT; 189 190 /* SMP over BR/EDR pairing states */ 191 enum { 192 SMP_BR_STATE_IDLE = SMP_STATE_IDLE, 193 SMP_BR_STATE_WAIT_APP_RSP, 194 SMP_BR_STATE_PAIR_REQ_RSP, 195 SMP_BR_STATE_BOND_PENDING, 196 SMP_BR_STATE_MAX 197 }; 198 typedef UINT8 tSMP_BR_STATE; 199 200 /* random and encrption activity state */ 201 enum { 202 SMP_GEN_COMPARE = 1, 203 SMP_GEN_CONFIRM, 204 205 SMP_GEN_DIV_LTK, 206 SMP_GEN_DIV_CSRK, 207 SMP_GEN_RAND_V, 208 SMP_GEN_TK, 209 SMP_GEN_SRAND_MRAND, 210 SMP_GEN_SRAND_MRAND_CONT, 211 SMP_GENERATE_PRIVATE_KEY_0_7, 212 SMP_GENERATE_PRIVATE_KEY_8_15, 213 SMP_GENERATE_PRIVATE_KEY_16_23, 214 SMP_GENERATE_PRIVATE_KEY_24_31, 215 SMP_GEN_NONCE_0_7, 216 SMP_GEN_NONCE_8_15 217 }; 218 219 enum { 220 SMP_KEY_TYPE_TK, 221 SMP_KEY_TYPE_CFM, 222 SMP_KEY_TYPE_CMP, 223 SMP_KEY_TYPE_PEER_DHK_CHCK, 224 SMP_KEY_TYPE_STK, 225 SMP_KEY_TYPE_LTK 226 }; 227 typedef struct { 228 UINT8 key_type; 229 UINT8 *p_data; 230 } tSMP_KEY; 231 232 typedef union { 233 UINT8 *p_data; /* UINT8 type data pointer */ 234 tSMP_KEY key; 235 UINT16 reason; 236 UINT32 passkey; 237 tSMP_OOB_DATA_TYPE req_oob_type; 238 } tSMP_INT_DATA; 239 240 /* internal status mask */ 241 #define SMP_PAIR_FLAGS_WE_STARTED_DD (1) 242 #define SMP_PAIR_FLAGS_PEER_STARTED_DD (1 << 1) 243 #define SMP_PAIR_FLAGS_CMD_CONFIRM (1 << SMP_OPCODE_CONFIRM) /* 1 << 3 */ 244 #define SMP_PAIR_FLAG_ENC_AFTER_PAIR (1 << 4) 245 #define SMP_PAIR_FLAG_HAVE_PEER_DHK_CHK (1 << 5) /* used on slave to resolve race condition */ 246 #define SMP_PAIR_FLAG_HAVE_PEER_PUBL_KEY (1 << 6) /* used on slave to resolve race condition */ 247 #define SMP_PAIR_FLAG_HAVE_PEER_COMM (1 << 7) /* used to resolve race condition */ 248 #define SMP_PAIR_FLAG_HAVE_LOCAL_PUBL_KEY (1 << 8) /* used on slave to resolve race condition */ 249 250 /* check if authentication requirement need MITM protection */ 251 #define SMP_NO_MITM_REQUIRED(x) (((x) & SMP_AUTH_YN_BIT) == 0) 252 253 #define SMP_ENCRYT_KEY_SIZE 16 254 #define SMP_ENCRYT_DATA_SIZE 16 255 #define SMP_ECNCRPYT_STATUS HCI_SUCCESS 256 257 typedef struct { 258 BD_ADDR bd_addr; 259 BT_HDR *p_copy; 260 } tSMP_REQ_Q_ENTRY; 261 262 /* SMP control block */ 263 typedef struct { 264 tSMP_CALLBACK *p_callback; 265 TIMER_LIST_ENT rsp_timer_ent; 266 UINT8 trace_level; 267 BD_ADDR pairing_bda; 268 tSMP_STATE state; 269 BOOLEAN derive_lk; 270 BOOLEAN id_addr_rcvd; 271 tBLE_ADDR_TYPE id_addr_type; 272 BD_ADDR id_addr; 273 BOOLEAN smp_over_br; 274 tSMP_BR_STATE br_state; /* if SMP over BR/ERD has priority over SMP */ 275 UINT8 failure; 276 UINT8 status; 277 UINT8 role; 278 UINT16 flags; 279 UINT8 cb_evt; 280 tSMP_SEC_LEVEL sec_level; 281 BOOLEAN connect_initialized; 282 BT_OCTET16 confirm; 283 BT_OCTET16 rconfirm; 284 BT_OCTET16 rrand; /* for SC this is peer nonce */ 285 BT_OCTET16 rand; /* for SC this is local nonce */ 286 BT_OCTET32 private_key; 287 BT_OCTET32 dhkey; 288 BT_OCTET16 commitment; 289 BT_OCTET16 remote_commitment; 290 BT_OCTET16 local_random; /* local randomizer - passkey or OOB randomizer */ 291 BT_OCTET16 peer_random; /* peer randomizer - passkey or OOB randomizer */ 292 BT_OCTET16 dhkey_check; 293 BT_OCTET16 remote_dhkey_check; 294 tSMP_PUBLIC_KEY loc_publ_key; 295 tSMP_PUBLIC_KEY peer_publ_key; 296 tSMP_OOB_DATA_TYPE req_oob_type; 297 tSMP_SC_OOB_DATA sc_oob_data; 298 tSMP_IO_CAP peer_io_caps; 299 tSMP_IO_CAP local_io_capability; 300 tSMP_OOB_FLAG peer_oob_flag; 301 tSMP_OOB_FLAG loc_oob_flag; 302 tSMP_AUTH_REQ peer_auth_req; 303 tSMP_AUTH_REQ loc_auth_req; 304 tSMP_AUTH_REQ auth_mode; 305 BOOLEAN secure_connections_only_mode_required;/* TRUE if locally SM is required to operate */ 306 /* either in Secure Connections mode or not at all */ 307 tSMP_ASSO_MODEL selected_association_model; 308 BOOLEAN le_secure_connections_mode_is_used; 309 BOOLEAN le_sc_kp_notif_is_used; 310 tSMP_SC_KEY_TYPE local_keypress_notification; 311 tSMP_SC_KEY_TYPE peer_keypress_notification; 312 UINT8 round; /* authentication stage 1 round for passkey association model */ 313 UINT32 number_to_display; 314 BT_OCTET16 mac_key; 315 UINT8 peer_enc_size; 316 UINT8 loc_enc_size; 317 UINT8 peer_i_key; 318 UINT8 peer_r_key; 319 UINT8 local_i_key; 320 UINT8 local_r_key; 321 322 BT_OCTET16 tk; 323 BT_OCTET16 ltk; 324 UINT16 div; 325 BT_OCTET16 csrk; /* storage for local CSRK */ 326 UINT16 ediv; 327 BT_OCTET8 enc_rand; 328 UINT8 rand_enc_proc_state; 329 UINT8 addr_type; 330 BD_ADDR local_bda; 331 BOOLEAN is_pair_cancel; 332 BOOLEAN discard_sec_req; 333 UINT8 rcvd_cmd_code; 334 UINT8 rcvd_cmd_len; 335 UINT16 total_tx_unacked; 336 BOOLEAN wait_for_authorization_complete; 337 BOOLEAN use_static_passkey; 338 UINT32 static_passkey; 339 BOOLEAN accept_specified_sec_auth; 340 tSMP_AUTH_REQ origin_loc_auth_req; 341 } tSMP_CB; 342 343 /* Server Action functions are of this type */ 344 typedef void (*tSMP_ACT)(tSMP_CB *p_cb, tSMP_INT_DATA *p_data); 345 346 347 #ifdef __cplusplus 348 extern "C" 349 { 350 #endif 351 352 #if SMP_DYNAMIC_MEMORY == FALSE 353 extern tSMP_CB smp_cb; 354 #else 355 extern tSMP_CB *smp_cb_ptr; 356 #define smp_cb (*smp_cb_ptr) 357 #endif 358 359 #ifdef __cplusplus 360 } 361 #endif 362 363 /* Functions provided by att_main.c */ 364 extern void smp_init (void); 365 366 /* smp main */ 367 extern void smp_sm_event(tSMP_CB *p_cb, tSMP_EVENT event, void *p_data); 368 369 extern void smp_proc_sec_request(tSMP_CB *p_cb, tSMP_INT_DATA *p_data); 370 extern void smp_set_fail_nc (BOOLEAN enable); 371 extern void smp_set_fail_conf (BOOLEAN enable); 372 extern void smp_set_passk_entry_fail(BOOLEAN enable); 373 extern void smp_set_oob_fail(BOOLEAN enable); 374 extern void smp_set_peer_sc_notif(BOOLEAN enable); 375 extern void smp_aes_cmac_rfc4493_chk (UINT8 *key, UINT8 *msg, UINT8 msg_len, 376 UINT8 mac_len, UINT8 *mac); 377 extern void smp_f4_calc_chk (UINT8 *U, UINT8 *V, UINT8 *X, UINT8 *Z, UINT8 *mac); 378 extern void smp_g2_calc_chk (UINT8 *U, UINT8 *V, UINT8 *X, UINT8 *Y); 379 extern void smp_h6_calc_chk (UINT8 *key, UINT8 *key_id, UINT8 *mac); 380 extern void smp_f5_key_calc_chk (UINT8 *w, UINT8 *mac); 381 extern void smp_f5_mackey_or_ltk_calc_chk(UINT8 *t, UINT8 *counter, 382 UINT8 *key_id, UINT8 *n1, 383 UINT8 *n2, UINT8 *a1, UINT8 *a2, 384 UINT8 *length, UINT8 *mac); 385 extern void smp_f5_calc_chk (UINT8 *w, UINT8 *n1, UINT8 *n2, UINT8 *a1, UINT8 *a2, 386 UINT8 *mac_key, UINT8 *ltk); 387 extern void smp_f6_calc_chk (UINT8 *w, UINT8 *n1, UINT8 *n2, UINT8 *r, 388 UINT8 *iocap, UINT8 *a1, UINT8 *a2, UINT8 *mac); 389 /* smp_main */ 390 extern void smp_sm_event(tSMP_CB *p_cb, tSMP_EVENT event, void *p_data); 391 extern tSMP_STATE smp_get_state(void); 392 extern void smp_set_state(tSMP_STATE state); 393 394 /* smp_br_main */ 395 extern void smp_br_state_machine_event(tSMP_CB *p_cb, tSMP_BR_EVENT event, void *p_data); 396 extern tSMP_BR_STATE smp_get_br_state(void); 397 extern void smp_set_br_state(tSMP_BR_STATE state); 398 399 400 /* smp_act.c */ 401 extern void smp_send_pair_req(tSMP_CB *p_cb, tSMP_INT_DATA *p_data); 402 extern void smp_send_confirm(tSMP_CB *p_cb, tSMP_INT_DATA *p_data); 403 extern void smp_send_pair_fail(tSMP_CB *p_cb, tSMP_INT_DATA *p_data); 404 extern void smp_send_rand(tSMP_CB *p_cb, tSMP_INT_DATA *p_data); 405 extern void smp_send_pair_public_key(tSMP_CB *p_cb, tSMP_INT_DATA *p_data); 406 extern void smp_send_commitment(tSMP_CB *p_cb, tSMP_INT_DATA *p_data); 407 extern void smp_send_dhkey_check(tSMP_CB *p_cb, tSMP_INT_DATA *p_data); 408 extern void smp_send_keypress_notification(tSMP_CB *p_cb, tSMP_INT_DATA *p_data); 409 extern void smp_proc_pair_fail(tSMP_CB *p_cb, tSMP_INT_DATA *p_data); 410 extern void smp_proc_confirm(tSMP_CB *p_cb, tSMP_INT_DATA *p_data); 411 extern void smp_proc_rand(tSMP_CB *p_cb, tSMP_INT_DATA *p_data); 412 extern void smp_process_pairing_public_key(tSMP_CB *p_cb, tSMP_INT_DATA *p_data); 413 extern void smp_proc_enc_info(tSMP_CB *p_cb, tSMP_INT_DATA *p_data); 414 extern void smp_proc_master_id(tSMP_CB *p_cb, tSMP_INT_DATA *p_data); 415 extern void smp_proc_id_info(tSMP_CB *p_cb, tSMP_INT_DATA *p_data); 416 extern void smp_proc_id_addr(tSMP_CB *p_cb, tSMP_INT_DATA *p_data); 417 extern void smp_proc_sec_grant(tSMP_CB *p_cb, tSMP_INT_DATA *p_data); 418 extern void smp_proc_sec_req(tSMP_CB *p_cb, tSMP_INT_DATA *p_data); 419 extern void smp_proc_sl_key(tSMP_CB *p_cb, tSMP_INT_DATA *p_data); 420 extern void smp_start_enc(tSMP_CB *p_cb, tSMP_INT_DATA *p_data); 421 extern void smp_enc_cmpl(tSMP_CB *p_cb, tSMP_INT_DATA *p_data); 422 extern void smp_proc_discard(tSMP_CB *p_cb, tSMP_INT_DATA *p_data); 423 extern void smp_pairing_cmpl(tSMP_CB *p_cb, tSMP_INT_DATA *p_data); 424 extern void smp_decide_association_model(tSMP_CB *p_cb, tSMP_INT_DATA *p_data); 425 extern void smp_send_app_cback(tSMP_CB *p_cb, tSMP_INT_DATA *p_data); 426 extern void smp_proc_compare(tSMP_CB *p_cb, tSMP_INT_DATA *p_data); 427 extern void smp_check_auth_req(tSMP_CB *p_cb, tSMP_INT_DATA *p_data); 428 extern void smp_process_io_response(tSMP_CB *p_cb, tSMP_INT_DATA *p_data); 429 extern void smp_send_id_info(tSMP_CB *p_cb, tSMP_INT_DATA *p_data); 430 extern void smp_send_enc_info(tSMP_CB *p_cb, tSMP_INT_DATA *p_data); 431 extern void smp_send_csrk_info(tSMP_CB *p_cb, tSMP_INT_DATA *p_data); 432 extern void smp_send_ltk_reply(tSMP_CB *p_cb, tSMP_INT_DATA *p_data); 433 extern void smp_proc_pair_cmd(tSMP_CB *p_cb, tSMP_INT_DATA *p_data); 434 extern void smp_pair_terminate(tSMP_CB *p_cb, tSMP_INT_DATA *p_data); 435 extern void smp_idle_terminate(tSMP_CB *p_cb, tSMP_INT_DATA *p_data); 436 extern void smp_send_pair_rsp(tSMP_CB *p_cb, tSMP_INT_DATA *p_data); 437 extern void smp_key_distribution(tSMP_CB *p_cb, tSMP_INT_DATA *p_data); 438 extern void smp_proc_srk_info(tSMP_CB *p_cb, tSMP_INT_DATA *p_data); 439 extern void smp_generate_csrk(tSMP_CB *p_cb, tSMP_INT_DATA *p_data); 440 extern void smp_fast_conn_param(tSMP_CB *p_cb, tSMP_INT_DATA *p_data); 441 extern void smp_key_pick_key(tSMP_CB *p_cb, tSMP_INT_DATA *p_data); 442 extern void smp_both_have_public_keys(tSMP_CB *p_cb, tSMP_INT_DATA *p_data); 443 extern void smp_start_secure_connection_phase1(tSMP_CB *p_cb, tSMP_INT_DATA *p_data); 444 extern void smp_process_local_nonce(tSMP_CB *p_cb, tSMP_INT_DATA *p_data); 445 extern void smp_process_pairing_commitment(tSMP_CB *p_cb, tSMP_INT_DATA *p_data); 446 extern void smp_process_peer_nonce(tSMP_CB *p_cb, tSMP_INT_DATA *p_data); 447 extern void smp_process_dhkey_check(tSMP_CB *p_cb, tSMP_INT_DATA *p_data); 448 extern void smp_match_dhkey_checks(tSMP_CB *p_cb, tSMP_INT_DATA *p_data); 449 extern void smp_process_keypress_notification(tSMP_CB *p_cb, tSMP_INT_DATA *p_data); 450 extern void smp_move_to_secure_connections_phase2(tSMP_CB *p_cb, tSMP_INT_DATA *p_data); 451 extern void smp_phase_2_dhkey_checks_are_present(tSMP_CB *p_cb, tSMP_INT_DATA *p_data); 452 extern void smp_wait_for_both_public_keys(tSMP_CB *p_cb, tSMP_INT_DATA *p_data); 453 extern void smp_start_passkey_verification(tSMP_CB *p_cb, tSMP_INT_DATA *p_data); 454 extern void smp_process_secure_connection_oob_data(tSMP_CB *p_cb, tSMP_INT_DATA *p_data); 455 extern void smp_process_secure_connection_long_term_key(void); 456 extern void smp_set_local_oob_keys(tSMP_CB *p_cb, tSMP_INT_DATA *p_data); 457 extern void smp_set_local_oob_random_commitment(tSMP_CB *p_cb, tSMP_INT_DATA *p_data); 458 extern void smp_set_derive_link_key(tSMP_CB *p_cb, tSMP_INT_DATA *p_data); 459 extern void smp_derive_link_key_from_long_term_key(tSMP_CB *p_cb, tSMP_INT_DATA *p_data); 460 extern void smp_br_process_pairing_command(tSMP_CB *p_cb, tSMP_INT_DATA *p_data); 461 extern void smp_br_process_security_grant(tSMP_CB *p_cb, tSMP_INT_DATA *p_data); 462 extern void smp_br_process_slave_keys_response(tSMP_CB *p_cb, tSMP_INT_DATA *p_data); 463 extern void smp_br_send_pair_response(tSMP_CB *p_cb, tSMP_INT_DATA *p_data); 464 extern void smp_br_check_authorization_request(tSMP_CB *p_cb, tSMP_INT_DATA *p_data); 465 extern void smp_br_select_next_key(tSMP_CB *p_cb, tSMP_INT_DATA *p_data); 466 extern void smp_br_process_link_key(tSMP_CB *p_cb, tSMP_INT_DATA *p_data); 467 extern void smp_key_distribution_by_transport(tSMP_CB *p_cb, tSMP_INT_DATA *p_data); 468 extern void smp_br_pairing_complete(tSMP_CB *p_cb, tSMP_INT_DATA *p_data); 469 470 /* smp_l2c */ 471 extern void smp_l2cap_if_init (void); 472 extern void smp_data_ind (BD_ADDR bd_addr, BT_HDR *p_buf); 473 474 /* smp_util.c */ 475 extern BOOLEAN smp_send_cmd(UINT8 cmd_code, tSMP_CB *p_cb); 476 extern void smp_cb_cleanup(tSMP_CB *p_cb); 477 extern void smp_reset_control_value(tSMP_CB *p_cb); 478 extern void smp_proc_pairing_cmpl(tSMP_CB *p_cb); 479 extern void smp_convert_string_to_tk(BT_OCTET16 tk, UINT32 passkey); 480 extern void smp_mask_enc_key(UINT8 loc_enc_size, UINT8 *p_data); 481 extern void smp_rsp_timeout(TIMER_LIST_ENT *p_tle); 482 extern void smp_xor_128(BT_OCTET16 a, const BT_OCTET16 b); 483 extern BOOLEAN smp_encrypt_data (UINT8 *key, UINT8 key_len, 484 UINT8 *plain_text, UINT8 pt_len, 485 tSMP_ENC *p_out); 486 extern BOOLEAN smp_command_has_invalid_parameters(tSMP_CB *p_cb); 487 extern void smp_reject_unexpected_pairing_command(BD_ADDR bd_addr); 488 extern tSMP_ASSO_MODEL smp_select_association_model(tSMP_CB *p_cb); 489 extern void smp_reverse_array(UINT8 *arr, UINT8 len); 490 extern UINT8 smp_calculate_random_input(UINT8 *random, UINT8 round); 491 extern void smp_collect_local_io_capabilities(UINT8 *iocap, tSMP_CB *p_cb); 492 extern void smp_collect_peer_io_capabilities(UINT8 *iocap, tSMP_CB *p_cb); 493 extern void smp_collect_local_ble_address(UINT8 *le_addr, tSMP_CB *p_cb); 494 extern void smp_collect_peer_ble_address(UINT8 *le_addr, tSMP_CB *p_cb); 495 extern BOOLEAN smp_check_commitment(tSMP_CB *p_cb); 496 extern void smp_save_secure_connections_long_term_key(tSMP_CB *p_cb); 497 extern BOOLEAN smp_calculate_f5_mackey_and_long_term_key(tSMP_CB *p_cb); 498 extern void smp_remove_fixed_channel(tSMP_CB *p_cb); 499 extern BOOLEAN smp_request_oob_data(tSMP_CB *p_cb); 500 501 /* smp_keys.c */ 502 extern void smp_generate_srand_mrand_confirm (tSMP_CB *p_cb, tSMP_INT_DATA *p_data); 503 extern void smp_generate_compare (tSMP_CB *p_cb, tSMP_INT_DATA *p_data); 504 extern void smp_generate_stk (tSMP_CB *p_cb, tSMP_INT_DATA *p_data); 505 extern void smp_generate_ltk(tSMP_CB *p_cb, tSMP_INT_DATA *p_data); 506 extern void smp_generate_passkey (tSMP_CB *p_cb, tSMP_INT_DATA *p_data); 507 extern void smp_generate_rand_cont(tSMP_CB *p_cb, tSMP_INT_DATA *p_data); 508 extern void smp_create_private_key(tSMP_CB *p_cb, tSMP_INT_DATA *p_data); 509 extern void smp_use_oob_private_key(tSMP_CB *p_cb, tSMP_INT_DATA *p_data); 510 extern void smp_compute_dhkey(tSMP_CB *p_cb); 511 extern void smp_calculate_local_commitment(tSMP_CB *p_cb); 512 extern void smp_calculate_peer_commitment(tSMP_CB *p_cb, BT_OCTET16 output_buf); 513 extern void smp_calculate_numeric_comparison_display_number(tSMP_CB *p_cb, tSMP_INT_DATA *p_data); 514 extern void smp_calculate_local_dhkey_check(tSMP_CB *p_cb, tSMP_INT_DATA *p_data); 515 extern void smp_calculate_peer_dhkey_check(tSMP_CB *p_cb, tSMP_INT_DATA *p_data); 516 extern void smp_start_nonce_generation(tSMP_CB *p_cb); 517 extern BOOLEAN smp_calculate_link_key_from_long_term_key(tSMP_CB *p_cb); 518 extern BOOLEAN smp_calculate_long_term_key_from_link_key(tSMP_CB *p_cb); 519 extern void smp_calculate_f4(UINT8 *u, UINT8 *v, UINT8 *x, UINT8 z, UINT8 *c); 520 extern UINT32 smp_calculate_g2(UINT8 *u, UINT8 *v, UINT8 *x, UINT8 *y); 521 extern BOOLEAN smp_calculate_f5(UINT8 *w, UINT8 *n1, UINT8 *n2, UINT8 *a1, UINT8 *a2, 522 UINT8 *mac_key, UINT8 *ltk); 523 extern BOOLEAN smp_calculate_f5_mackey_or_long_term_key(UINT8 *t, UINT8 *counter, 524 UINT8 *key_id, UINT8 *n1, UINT8 *n2, UINT8 *a1, 525 UINT8 *a2, UINT8 *length, UINT8 *mac); 526 extern BOOLEAN smp_calculate_f5_key(UINT8 *w, UINT8 *t); 527 extern BOOLEAN smp_calculate_f6(UINT8 *w, UINT8 *n1, UINT8 *n2, UINT8 *r, UINT8 *iocap, 528 UINT8 *a1, UINT8 *a2, UINT8 *f3); 529 extern BOOLEAN smp_calculate_h6(UINT8 *w, UINT8 *keyid, UINT8 *h2); 530 #if SMP_DEBUG == TRUE 531 extern void smp_debug_print_nbyte_little_endian (UINT8 *p, const UINT8 *key_name, 532 UINT8 len); 533 #endif 534 535 /* smp_cmac.c */ 536 extern BOOLEAN aes_cipher_msg_auth_code(BT_OCTET16 key, UINT8 *input, UINT16 length, 537 UINT16 tlen, UINT8 *p_signature); 538 extern void print128(BT_OCTET16 x, const UINT8 *key_name); 539 540 // #endif ///BLE_INCLUDED == TRUE && SMP_INCLUDED == TRUE 541 542 #endif /* SMP_INT_H */ 543