blob: fc843fb8269f2ab378ffef1b8c0579671a78cdd1 [file] [log] [blame]
The Android Open Source Project5738f832012-12-12 16:00:35 -08001/******************************************************************************
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 Pawlowskidc3c1f22016-09-28 09:02:39 -070028#include "smp_api_types.h"
The Android Open Source Project5738f832012-12-12 16:00:35 -080029
Bryce Lee3d6accf2016-05-10 17:10:09 -070030#ifdef __cplusplus
31extern "C" {
32#endif
33
The Android Open Source Project5738f832012-12-12 16:00:35 -080034/*****************************************************************************
35** External Function Declarations
36*****************************************************************************/
The Android Open Source Project5738f832012-12-12 16:00:35 -080037/* 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-Gans24933b52014-09-24 15:25:02 -070048extern void SMP_Init(void);
The Android Open Source Project5738f832012-12-12 16:00:35 -080049
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 Janssend19e0782016-07-15 12:48:27 -070060extern uint8_t SMP_SetTraceLevel (uint8_t new_level);
The Android Open Source Project5738f832012-12-12 16:00:35 -080061
62/*******************************************************************************
63**
64** Function SMP_Register
65**
66** Description This function register for the SMP service callback.
67**
68** Returns void
69**
70*******************************************************************************/
Marie Janssend19e0782016-07-15 12:48:27 -070071extern bool SMP_Register (tSMP_CALLBACK *p_cback);
The Android Open Source Project5738f832012-12-12 16:00:35 -080072
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-Gans24933b52014-09-24 15:25:02 -070082extern tSMP_STATUS SMP_Pair (BD_ADDR bd_addr);
Satya Calloji444a8da2015-03-06 10:38:22 -080083
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*******************************************************************************/
93extern tSMP_STATUS SMP_BR_PairWith (BD_ADDR bd_addr);
94
The Android Open Source Project5738f832012-12-12 16:00:35 -080095/*******************************************************************************
96**
97** Function SMP_PairCancel
98**
99** Description This function is called to cancel a SMP pairing.
100**
Marie Janssend19e0782016-07-15 12:48:27 -0700101** Returns true - pairing cancelled
The Android Open Source Project5738f832012-12-12 16:00:35 -0800102**
103*******************************************************************************/
Marie Janssend19e0782016-07-15 12:48:27 -0700104extern bool SMP_PairCancel (BD_ADDR bd_addr);
The Android Open Source Project5738f832012-12-12 16:00:35 -0800105
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 Janssend19e0782016-07-15 12:48:27 -0700119extern void SMP_SecurityGrant(BD_ADDR bd_addr, uint8_t res);
The Android Open Source Project5738f832012-12-12 16:00:35 -0800120
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 Calloji444a8da2015-03-06 10:38:22 -0800129** res - result of the operation SMP_SUCCESS if success
The Android Open Source Project5738f832012-12-12 16:00:35 -0800130** passkey - numeric value in the range of
131** BTM_MIN_PASSKEY_VAL(0) - BTM_MAX_PASSKEY_VAL(999999(0xF423F)).
132**
133*******************************************************************************/
Marie Janssend19e0782016-07-15 12:48:27 -0700134extern void SMP_PasskeyReply (BD_ADDR bd_addr, uint8_t res, uint32_t passkey);
The Android Open Source Project5738f832012-12-12 16:00:35 -0800135
136/*******************************************************************************
137**
Satya Calloji444a8da2015-03-06 10:38:22 -0800138** 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 Janssend19e0782016-07-15 12:48:27 -0700148extern void SMP_ConfirmReply (BD_ADDR bd_addr, uint8_t res);
Satya Calloji444a8da2015-03-06 10:38:22 -0800149
150/*******************************************************************************
151**
The Android Open Source Project5738f832012-12-12 16:00:35 -0800152** Function SMP_OobDataReply
153**
154** Description This function is called to provide the OOB data for
Satya Calloji444a8da2015-03-06 10:38:22 -0800155** SMP in response to SMP_OOB_REQ_EVT
The Android Open Source Project5738f832012-12-12 16:00:35 -0800156**
157** Parameters: bd_addr - Address of the peer device
158** res - result of the operation SMP_SUCCESS if success
Satya Calloji444a8da2015-03-06 10:38:22 -0800159** p_data - SM Randomizer C.
The Android Open Source Project5738f832012-12-12 16:00:35 -0800160**
161*******************************************************************************/
Marie Janssend19e0782016-07-15 12:48:27 -0700162extern void SMP_OobDataReply(BD_ADDR bd_addr, tSMP_STATUS res, uint8_t len,
163 uint8_t *p_data);
The Android Open Source Project5738f832012-12-12 16:00:35 -0800164
165/*******************************************************************************
166**
Satya Calloji444a8da2015-03-06 10:38:22 -0800167** 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 Janssend19e0782016-07-15 12:48:27 -0700175extern void SMP_SecureConnectionOobDataReply(uint8_t *p_data);
Satya Calloji444a8da2015-03-06 10:38:22 -0800176
177/*******************************************************************************
178**
The Android Open Source Project5738f832012-12-12 16:00:35 -0800179** 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 Janssend19e0782016-07-15 12:48:27 -0700191** Returns Boolean - true: encryption is successful
The Android Open Source Project5738f832012-12-12 16:00:35 -0800192*******************************************************************************/
Marie Janssend19e0782016-07-15 12:48:27 -0700193extern bool SMP_Encrypt (uint8_t *key, uint8_t key_len,
194 uint8_t *plain_text, uint8_t pt_len,
June R. Tate-Gans24933b52014-09-24 15:25:02 -0700195 tSMP_ENC *p_out);
The Android Open Source Project5738f832012-12-12 16:00:35 -0800196
Satya Calloji444a8da2015-03-06 10:38:22 -0800197/*******************************************************************************
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 Janssend19e0782016-07-15 12:48:27 -0700208extern void SMP_KeypressNotification (BD_ADDR bd_addr, uint8_t value);
Satya Calloji444a8da2015-03-06 10:38:22 -0800209
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 Janssend19e0782016-07-15 12:48:27 -0700220** Returns Boolean - true: creation of local SC OOB data set started.
Satya Calloji444a8da2015-03-06 10:38:22 -0800221*******************************************************************************/
Pavlin Radoslavovb2a292b2016-10-14 19:34:48 -0700222extern 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.
226extern 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.
230extern 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//
242bool aes_cipher_msg_auth_code(BT_OCTET16 key, uint8_t *input, uint16_t length,
243 uint16_t tlen, uint8_t *p_signature);
Satya Calloji444a8da2015-03-06 10:38:22 -0800244
The Android Open Source Project5738f832012-12-12 16:00:35 -0800245#ifdef __cplusplus
246}
247#endif
248#endif /* SMP_API_H */