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

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.