Cordio Stack and Cordio Profiles  r2p3-02rel0
smp_defs.h
Go to the documentation of this file.
1 /*************************************************************************************************/
2 /*!
3  * \file
4  *
5  * \brief Security manager constants and definitions from the Bluetooth specification.
6  *
7  * Copyright (c) 2010-2018 Arm Ltd. All Rights Reserved.
8  * Arm Ltd. confidential and proprietary.
9  *
10  * IMPORTANT. Your use of this file is governed by a Software License Agreement
11  * ("Agreement") that must be accepted in order to download or otherwise receive a
12  * copy of this file. You may not use or copy this file for any purpose other than
13  * as described in the Agreement. If you do not agree to all of the terms of the
14  * Agreement do not use this file and delete all copies in your possession or control;
15  * if you do not have a copy of the Agreement, you must contact Arm Ltd. prior
16  * to any use, copying or further distribution of this software.
17  */
18 /*************************************************************************************************/
19 #ifndef SMP_DEFS_H
20 #define SMP_DEFS_H
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
26 /*! \addtogroup STACK_SMP_API
27  * \{ */
28 
29 /**************************************************************************************************
30  Macros
31 **************************************************************************************************/
32 
33 /*! \brief PDU format */
34 #define SMP_HDR_LEN 1 /*!< \brief Attribute PDU header length. */
35 
36 /*! \brief Protocol timeout */
37 #define SMP_TIMEOUT 30 /*!< \brief Protocol timeout in seconds. */
38 
39 /** \name SMP Encryption Key Size
40  *
41  */
42 /**@{*/
43 #define SMP_KEY_SIZE_MAX 16 /*!< \brief Maximum encryption key size. */
44 #define SMP_KEY_SIZE_MIN 7 /*!< \brief Minimum encryption key size. */
45 /**@}*/
46 
47 #define SMP_OOB_LEN 16 /*!< \brief OOB Data length in bytes. */
48 #define SMP_PIN_LEN 3 /*!< \brief Passkey Pin lenght in bytes. */
49 
50 /** \name SMP Error Codes
51  * SMP PDU status codes
52  */
53 /**@{*/
54 #define SMP_ERR_PASSKEY_ENTRY 0x01 /*!< \brief User input of passkey failed. */
55 #define SMP_ERR_OOB 0x02 /*!< \brief OOB data is not available. */
56 #define SMP_ERR_AUTH_REQ 0x03 /*!< \brief Authentication requirements cannot be met. */
57 #define SMP_ERR_CONFIRM_VALUE 0x04 /*!< \brief Confirm value does not match. */
58 #define SMP_ERR_PAIRING_NOT_SUP 0x05 /*!< \brief Pairing is not supported by the device. */
59 #define SMP_ERR_ENC_KEY_SIZE 0x06 /*!< \brief Insufficient encryption key size. */
60 #define SMP_ERR_COMMAND_NOT_SUP 0x07 /*!< \brief Command not supported. */
61 #define SMP_ERR_UNSPECIFIED 0x08 /*!< \brief Unspecified reason. */
62 #define SMP_ERR_ATTEMPTS 0x09 /*!< \brief Repeated attempts. */
63 #define SMP_ERR_INVALID_PARAM 0x0A /*!< \brief Invalid parameter or command length. */
64 #define SMP_ERR_DH_KEY_CHECK 0x0B /*!< \brief DH Key check did not match. */
65 #define SMP_ERR_NUMERIC_COMPARISON 0x0C /*!< \brief Numeric comparison did not match. */
66 #define SMP_ERR_BR_EDR_IN_PROGRESS 0x0D /*!< \brief BR/EDR in progress. */
67 #define SMP_ERR_CROSS_TRANSPORT 0x0E /*!< \brief BR/EDR cross transport key generation not allowed. */
68 /**@}*/
69 
70 /** \name Proprietary Error Codes
71  * Internal error codes not sent in any SMP PDU.
72  */
73 /**@{*/
74 #define SMP_ERR_MEMORY 0xE0 /*!< \brief Out of memory. */
75 #define SMP_ERR_TIMEOUT 0xE1 /*!< \brief Transaction timeout. */
76 /**@}*/
77 
78 /** \name SMP PDU Codes
79  * SMP PDU Code describing command received or sent.
80  */
81 /**@{*/
82 #define SMP_CMD_PAIR_REQ 0x01 /*!< \brief Pairing request. */
83 #define SMP_CMD_PAIR_RSP 0x02 /*!< \brief Pairing response. */
84 #define SMP_CMD_PAIR_CNF 0x03 /*!< \brief Pairing confirm. */
85 #define SMP_CMD_PAIR_RAND 0x04 /*!< \brief Pairing random. */
86 #define SMP_CMD_PAIR_FAIL 0x05 /*!< \brief Pairing failed. */
87 #define SMP_CMD_ENC_INFO 0x06 /*!< \brief Encryption information. */
88 #define SMP_CMD_MASTER_ID 0x07 /*!< \brief Master identification. */
89 #define SMP_CMD_ID_INFO 0x08 /*!< \brief Identity information. */
90 #define SMP_CMD_ID_ADDR_INFO 0x09 /*!< \brief Identity address information. */
91 #define SMP_CMD_SIGN_INFO 0x0A /*!< \brief Signing information. */
92 #define SMP_CMD_SECURITY_REQ 0x0B /*!< \brief Security fequest. */
93 #define SMP_CMD_PUBLIC_KEY 0x0C /*!< \brief Public Kkey. */
94 #define SMP_CMD_DHKEY_CHECK 0x0D /*!< \brief DH Key check. */
95 #define SMP_CMD_KEYPRESS 0x0E /*!< \brief User key press. */
96 #define SMP_CMD_MAX 0x0F /*!< \brief Command code maximum. */
97 /**@}*/
98 
99 /** \name SMP PDU Packet Lengths
100  * Fixed length of the PDU to be sent.
101  */
102 /**@{*/
103 #define SMP_PAIR_REQ_LEN 7 /*!< \brief Pairing request message length. */
104 #define SMP_PAIR_RSP_LEN 7 /*!< \brief Pairing response message length. */
105 #define SMP_PAIR_CNF_LEN 17 /*!< \brief Pairing confirmation message length. */
106 #define SMP_PAIR_RAND_LEN 17 /*!< \brief Pairing random message length. */
107 #define SMP_PAIR_FAIL_LEN 2 /*!< \brief Pairing fail message length. */
108 #define SMP_ENC_INFO_LEN 17 /*!< \brief Encryption information message length. */
109 #define SMP_MASTER_ID_LEN 11 /*!< \brief Master identification messagelength. */
110 #define SMP_ID_INFO_LEN 17 /*!< \brief Identity information message length. */
111 #define SMP_ID_ADDR_INFO_LEN 8 /*!< \brief Identity address information message length. */
112 #define SMP_SIGN_INFO_LEN 17 /*!< \brief Signing information message length. */
113 #define SMP_SECURITY_REQ_LEN 2 /*!< \brief Security request message length. */
114 #define SMP_PUB_KEY_MSG_LEN (1 + 2*SMP_PUB_KEY_LEN) /*!< \brief Public key message length. */
115 #define SMP_DHKEY_CHECK_MSG_LEN (1 + SMP_DHKEY_CHECK_LEN) /*!< \brief Diffie-Hellman key check message length. */
116 #define SMP_KEYPRESS_MSG_LEN 2 /*!< \brief Keypress message length. */
117 /**@}*/
118 
119 /** \name SMP I/O Capabilities
120  * I/O capabilities codes to be set for \ref SMP_CMD_PAIR_REQ and \ref SMP_CMD_PAIR_RSP
121  */
122 /**@{*/
123 #define SMP_IO_DISP_ONLY 0x00 /*!< \brief Display only. */
124 #define SMP_IO_DISP_YES_NO 0x01 /*!< \brief Display yes/no. */
125 #define SMP_IO_KEY_ONLY 0x02 /*!< \brief Keyboard only. */
126 #define SMP_IO_NO_IN_NO_OUT 0x03 /*!< \brief No input, no output. */
127 #define SMP_IO_KEY_DISP 0x04 /*!< \brief Keyboard display. */
128 /**@}*/
129 
130 /** \name SMP OOB Data Flag
131  * Out-of-Band codes to be set for \ref SMP_CMD_PAIR_REQ and \ref SMP_CMD_PAIR_RSP
132  */
133 /**@{*/
134 #define SMP_OOB_DATA_NONE 0x00 /*!< \brief No OOB data from the remote device is present. */
135 #define SMP_OOB_DATA_PRESENT 0x01 /*!< \brief OOB data from the remote device is present. */
136 /**@}*/
137 
138 /** \name SMP Authentication Requirements Flags
139  * Authentication Requirements Flags to be set for \ref SMP_CMD_PAIR_REQ and \ref SMP_CMD_PAIR_RSP.
140  */
141 /**@{*/
142 #define SMP_AUTH_BOND_MASK 0x03 /*!< \brief Mask for bonding bits. */
143 #define SMP_AUTH_BOND_FLAG 0x01 /*!< \brief Bonding requested. */
144 #define SMP_AUTH_MITM_FLAG 0x04 /*!< \brief MITM (authenticated pairing) requested. */
145 #define SMP_AUTH_SC_FLAG 0x08 /*!< \brief LE Secure Connections requested. */
146 #define SMP_AUTH_KP_FLAG 0x10 /*!< \brief Keypress notifications requested. */
147 /**@}*/
148 
149 /** \name SMP Key Distribution Flags
150  * Flags of security keys this device is requesting to be distribution once pairing completes.
151  */
152 /**@{*/
153 #define SMP_KEY_DIST_ENC 0x01 /*!< \brief Distribute LTK. */
154 #define SMP_KEY_DIST_ID 0x02 /*!< \brief Distribute IRK. */
155 #define SMP_KEY_DIST_SIGN 0x04 /*!< \brief Distribute CSRK. */
156 /*! \brief Key distribution mask. */
157 #define SMP_KEY_DIST_MASK (SMP_KEY_DIST_ENC | SMP_KEY_DIST_ID | SMP_KEY_DIST_SIGN)
158 /**@}*/
159 
160 /** \name SMP LE Secure Connection Keypress Codes
161  * Keypress codes found in \ref SMP_CMD_KEYPRESS PDU to be sent on the respective action when
162  * the \ref SMP_AUTH_KP_FLAG is set in both the \ref SMP_CMD_PAIR_REQ and \ref SMP_CMD_PAIR_RSP.
163  */
164 /**@{*/
165 #define SMP_PASSKEY_ENTRY_STARTED 0x00 /*!< \brief Passkey entry started keypress type. */
166 #define SMP_PASSKEY_DIGIT_ENTERED 0x01 /*!< \brief Passkey digit entered keypress type. */
167 #define SMP_PASSKEY_DIGIT_ERASED 0x02 /*!< \brief Passkey digit erased keypress type. */
168 #define SMP_PASSKEY_CLEARED 0x03 /*!< \brief Passkey cleared keypress type. */
169 #define SMP_PASSKEY_ENTRY_COMPLETED 0x04 /*!< \brief Passkey entry complete keypress type. */
170 /**@}*/
171 
172 /** \name SMP Value Length Constants
173  * Lengths of various keys and values.
174  */
175 /**@{*/
176 #define SMP_RAND_LEN 16 /*!< \brief Random number length. */
177 #define SMP_CONFIRM_LEN 16 /*!< \brief Confirm number length. */
178 #define SMP_KEY_LEN 16 /*!< \brief Key length. */
179 #define SMP_RAND8_LEN 8 /*!< \brief Random 8-byte number length. */
180 #define SMP_PRIVATE_KEY_LEN 32 /*!< \brief Secure connections private key length. */
181 #define SMP_PUB_KEY_LEN 32 /*!< \brief Secure connecdtions public key length. */
182 #define SMP_DHKEY_LEN 32 /*!< \brief Secure connection Diffie-Hellman key length. */
183 #define SMP_DHKEY_CHECK_LEN 16 /*!< \brief Secure connection Diffie-Hellman key check length. */
184 /**@}*/
185 
186 /** \name CMAC Input Lengths Constants
187  * Input lengths of SMP cryptopgraphic toolbox functions.
188  */
189 /**@{*/
190 #define SMP_F4_TEXT_LEN (SMP_PUB_KEY_LEN * 2 + 1) /*!< \brief F4 input length. */
191 #define SMP_G2_TEXT_LEN (SMP_PUB_KEY_LEN * 2 + SMP_RAND_LEN) /*!< \brief G2 input length. */
192 #define SMP_F5_TKEY_TEXT_LEN (SMP_DHKEY_LEN) /*!< \brief F5 Temporary key input length. */
193 #define SMP_F5_TEXT_LEN (9 + 2*BDA_ADDR_LEN + 2*SMP_RAND_LEN) /*!< \brief F5 input length. */
194 #define SMP_F6_TEXT_LEN (2*BDA_ADDR_LEN + 3*SMP_RAND_LEN + 5) /*!< \brief F6 input length. */
195 /**@}*/
196 
197 /*! \} */ /* STACK_SMP_API */
198 
199 #ifdef __cplusplus
200 };
201 #endif
202 
203 #endif /* SMP_DEFS_H */