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