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 the SMP API function external definitions. 22 * 23 ******************************************************************************/ 24 #ifndef SMP_API_H 25 #define SMP_API_H 26 27 #include "bt_target.h" 28 #include "smp_api_types.h" 29 30 /***************************************************************************** 31 * External Function Declarations 32 ****************************************************************************/ 33 /* API of SMP */ 34 35 /******************************************************************************* 36 * 37 * Function SMP_Init 38 * 39 * Description This function initializes the SMP unit. 40 * 41 * Returns void 42 * 43 ******************************************************************************/ 44 extern void SMP_Init(void); 45 46 /******************************************************************************* 47 * 48 * Function SMP_SetTraceLevel 49 * 50 * Description This function sets the trace level for SMP. If called with 51 * a value of 0xFF, it simply returns the current trace level. 52 * 53 * Returns The new or current trace level 54 * 55 ******************************************************************************/ 56 extern uint8_t SMP_SetTraceLevel(uint8_t new_level); 57 58 /******************************************************************************* 59 * 60 * Function SMP_Register 61 * 62 * Description This function register for the SMP service callback. 63 * 64 * Returns void 65 * 66 ******************************************************************************/ 67 extern bool SMP_Register(tSMP_CALLBACK* p_cback); 68 69 /******************************************************************************* 70 * 71 * Function SMP_Pair 72 * 73 * Description This function is called to start a SMP pairing. 74 * 75 * Returns SMP_STARTED if bond started, else otherwise exception. 76 * 77 ******************************************************************************/ 78 extern tSMP_STATUS SMP_Pair(BD_ADDR bd_addr); 79 80 /******************************************************************************* 81 * 82 * Function SMP_BR_PairWith 83 * 84 * Description This function is called to start a SMP pairing over BR/EDR. 85 * 86 * Returns SMP_STARTED if pairing started, otherwise the reason for the 87 * failure. 88 * 89 ******************************************************************************/ 90 extern tSMP_STATUS SMP_BR_PairWith(BD_ADDR bd_addr); 91 92 /******************************************************************************* 93 * 94 * Function SMP_PairCancel 95 * 96 * Description This function is called to cancel a SMP pairing. 97 * 98 * Returns true - pairing cancelled 99 * 100 ******************************************************************************/ 101 extern bool SMP_PairCancel(BD_ADDR bd_addr); 102 103 /******************************************************************************* 104 * 105 * Function SMP_SecurityGrant 106 * 107 * Description This function is called to grant security process. 108 * 109 * Parameters bd_addr - peer device bd address. 110 * res - result of the operation SMP_SUCCESS if success. 111 * Otherwise, SMP_REPEATED_ATTEMPTS is too many 112 * attempts. 113 * 114 * Returns None 115 * 116 ******************************************************************************/ 117 extern void SMP_SecurityGrant(BD_ADDR bd_addr, uint8_t res); 118 119 /******************************************************************************* 120 * 121 * Function SMP_PasskeyReply 122 * 123 * Description This function is called after Security Manager submitted 124 * Passkey request to the application. 125 * 126 * Parameters: bd_addr - Address of the device for which PIN was requested 127 * res - result of the operation SMP_SUCCESS if success 128 * passkey - numeric value in the range of 129 * BTM_MIN_PASSKEY_VAL(0) - 130 * BTM_MAX_PASSKEY_VAL(999999(0xF423F)). 131 * 132 ******************************************************************************/ 133 extern void SMP_PasskeyReply(BD_ADDR bd_addr, uint8_t res, uint32_t passkey); 134 135 /******************************************************************************* 136 * 137 * Function SMP_ConfirmReply 138 * 139 * Description This function is called after Security Manager submitted 140 * numeric comparison request to the application. 141 * 142 * Parameters: bd_addr - Address of the device with which numeric 143 * comparison was requested 144 * res - comparison result SMP_SUCCESS if success 145 * 146 ******************************************************************************/ 147 extern void SMP_ConfirmReply(BD_ADDR bd_addr, uint8_t res); 148 149 /******************************************************************************* 150 * 151 * Function SMP_OobDataReply 152 * 153 * Description This function is called to provide the OOB data for 154 * SMP in response to SMP_OOB_REQ_EVT 155 * 156 * Parameters: bd_addr - Address of the peer device 157 * res - result of the operation SMP_SUCCESS if success 158 * p_data - SM Randomizer C. 159 * 160 ******************************************************************************/ 161 extern void SMP_OobDataReply(BD_ADDR bd_addr, tSMP_STATUS res, uint8_t len, 162 uint8_t* p_data); 163 164 /******************************************************************************* 165 * 166 * Function SMP_SecureConnectionOobDataReply 167 * 168 * Description This function is called to provide the SC OOB data for 169 * SMP in response to SMP_SC_OOB_REQ_EVT 170 * 171 * Parameters: p_data - pointer to the data 172 * 173 ******************************************************************************/ 174 extern void SMP_SecureConnectionOobDataReply(uint8_t* p_data); 175 176 /******************************************************************************* 177 * 178 * Function SMP_Encrypt 179 * 180 * Description Encrypt the data with the specified key. 181 * 182 * Parameters: key - Pointer to key key[0] conatins the MSB 183 * key_len - key length 184 * plain_text - Pointer to data to be encrypted 185 * plain_text[0] conatins the MSB 186 * pt_len - plain text length 187 * p_out - pointer to the encrypted outputs 188 * 189 * Returns Boolean - true: encryption is successful 190 ******************************************************************************/ 191 extern bool SMP_Encrypt(uint8_t* key, uint8_t key_len, uint8_t* plain_text, 192 uint8_t pt_len, tSMP_ENC* p_out); 193 194 /******************************************************************************* 195 * 196 * Function SMP_KeypressNotification 197 * 198 * Description Notify SM about Keypress Notification. 199 * 200 * Parameters: bd_addr - Address of the device to send keypress 201 * notification to 202 * value - keypress notification parameter value 203 * 204 ******************************************************************************/ 205 extern void SMP_KeypressNotification(BD_ADDR bd_addr, uint8_t value); 206 207 /******************************************************************************* 208 * 209 * Function SMP_CreateLocalSecureConnectionsOobData 210 * 211 * Description This function is called to start creation of local SC OOB 212 * data set (tSMP_LOC_OOB_DATA). 213 * 214 * Parameters: bd_addr - Address of the device to send OOB data block 215 * to. 216 * 217 * Returns Boolean - true: creation of local SC OOB data set started. 218 ******************************************************************************/ 219 extern bool SMP_CreateLocalSecureConnectionsOobData( 220 tBLE_BD_ADDR* addr_to_send_to); 221 222 // Called when LTK request is received from controller. 223 extern bool smp_proc_ltk_request(BD_ADDR bda); 224 225 // Called when link is encrypted and notified to slave device. 226 // Proceed to send LTK, DIV and ER to master if bonding the devices. 227 extern void smp_link_encrypted(BD_ADDR bda, uint8_t encr_enable); 228 229 // 230 // The AES-CMAC Generation Function with tlen implemented. 231 // |key| - CMAC key in little endian order, expect SRK when used by SMP. 232 // |input| - text to be signed in little endian byte order. 233 // |length| - length of the input in byte. 234 // |tlen| - lenth of mac desired 235 // |p_signature| - data pointer to where signed data to be stored, tlen long. 236 // Returns false if out of resources, true in other cases. 237 // 238 bool aes_cipher_msg_auth_code(BT_OCTET16 key, uint8_t* input, uint16_t length, 239 uint16_t tlen, uint8_t* p_signature); 240 241 #endif /* SMP_API_H */ 242