SimpleLink CC31xx/CC32xx Host Driver  Version 3.0.1.55
Simplifies the implementation of Internet connectivity
netutil.h
1 /*
2  * netutil.h - CC31xx/CC32xx Host Driver Implementation
3  *
4  * Copyright (C) 2017 Texas Instruments Incorporated - https://www.ti.com/
5  *
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  *
14  * Redistributions in binary form must reproduce the above copyright
15  * notice, this list of conditions and the following disclaimer in the
16  * documentation and/or other materials provided with the
17  * distribution.
18  *
19  * Neither the name of Texas Instruments Incorporated nor the names of
20  * its contributors may be used to endorse or promote products derived
21  * from this software without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34  *
35 */
36 
37 #ifndef __NETUTIL_H__
38 #define __NETUTIL_H__
39 
40 /*****************************************************************************/
41 /* Include files */
42 /*****************************************************************************/
43 #include <ti/drivers/net/wifi/simplelink.h>
44 
45 #ifdef __cplusplus
46 extern "C" {
47 #endif
48 
62 /*****************************************************************************/
63 /* Macro declarations */
64 /*****************************************************************************/
65 
66 /* Set/get options */
67 #define SL_NETUTIL_CRYPTO_PUBLIC_KEY (1)
68 #define SL_NETUTIL_CRYPTO_PUBLIC_KEY_INFO (2)
69 #define SL_NETUTIL_TRUE_RANDOM (3)
70 
71 /* Commands */
72 #define SL_NETUTIL_CRYPTO_CMD_CREATE_CERT (1)
73 #define SL_NETUTIL_CRYPTO_CMD_SIGN_MSG (2)
74 #define SL_NETUTIL_CRYPTO_CMD_VERIFY_MSG (3)
75 #define SL_NETUTIL_CRYPTO_CMD_TEMP_KEYS (4)
76 #define SL_NETUTIL_CRYPTO_CMD_INSTALL_OP (5)
77 #define SL_NETUTIL_CMD_ARP_LOOKUP (6)
78 
79 /*****************************************************************************/
80 /* Errors returned from the general error async event */
81 /*****************************************************************************/
82 
83 
84 /*****************************************************************************/
85 /* Structure/Enum declarations */
86 /*****************************************************************************/
87 
88 typedef struct
89 {
90  _u8 *pOutputValues;
91  _u16 *pOutputLen;
92  _i16 Status;
94 
95 /* Defines the size of the buffer that will be allocated */
96 /* (on the stack) by the sl_UtilsCmd API. */
97 #define SL_NETUTIL_CMD_BUFFER_SIZE (256)
98 
99 /* Enumeration of Signature types */
100 #define SL_NETUTIL_CRYPTO_SIG_SHAwDSA (0)
101 #define SL_NETUTIL_CRYPTO_SIG_MD2wRSA (1)
102 #define SL_NETUTIL_CRYPTO_SIG_MD5wRSA (2)
103 #define SL_NETUTIL_CRYPTO_SIG_SHAwRSA (3)
104 #define SL_NETUTIL_CRYPTO_SIG_SHAwECDSA (4)
105 #define SL_NETUTIL_CRYPTO_SIG_SHA256wRSA (5)
106 #define SL_NETUTIL_CRYPTO_SIG_SHA256wECDSA (6)
107 #define SL_NETUTIL_CRYPTO_SIG_SHA384wRSA (7)
108 #define SL_NETUTIL_CRYPTO_SIG_SHA384wECDSA (8)
109 #define SL_NETUTIL_CRYPTO_SIG_SHA512wRSA (9)
110 #define SL_NETUTIL_CRYPTO_SIG_SHA512wECDSA (10)
111 #define SL_NETUTIL_CRYPTO_SIG_DIGESTwECDSA (11)
112 /* Add more signature-Types here */
113 
114 /* Digest length definitions */
115 #define SL_NETUTIL_CRYPTO_DGST_MD2_LEN_BYTES (16)
116 #define SL_NETUTIL_CRYPTO_DGST_MD5_LEN_BYTES (16)
117 #define SL_NETUTIL_CRYPTO_DGST_SHA_LEN_BYTES (20)
118 #define SL_NETUTIL_CRYPTO_DGST_SHA256_LEN_BYTES (32)
119 #define SL_NETUTIL_CRYPTO_DGST_SHA384_LEN_BYTES (48)
120 #define SL_NETUTIL_CRYPTO_DGST_SHA512_LEN_BYTES (64)
121 
122 
123 /* Enumeration of Create-Certificate sub-commands */
124 #define SL_NETUTIL_CRYPTO_CERT_INIT (1)
125 #define SL_NETUTIL_CRYPTO_CERT_SIGN_AND_SAVE (2)
126 #define SL_NETUTIL_CRYPTO_CERT_VER (3)
127 #define SL_NETUTIL_CRYPTO_CERT_SERIAL (4)
128 #define SL_NETUTIL_CRYPTO_CERT_SIG_TYPE (5)
129 #define SL_NETUTIL_CRYPTO_CSR_SIGN_AND_SAVE (6)
130 #if 0 /* reserved for Issuer information - currently not supported */
131 #define SL_NETUTIL_CRYPTO_CERT_ISSUER_COUNTRY (6)
132 #define SL_NETUTIL_CRYPTO_CERT_ISSUER_STATE (7)
133 #define SL_NETUTIL_CRYPTO_CERT_ISSUER_LOCALITY (8)
134 #define SL_NETUTIL_CRYPTO_CERT_ISSUER_SUR (9)
135 #define SL_NETUTIL_CRYPTO_CERT_ISSUER_ORG (10)
136 #define SL_NETUTIL_CRYPTO_CERT_ISSUER_ORG_UNIT (11)
137 #define SL_NETUTIL_CRYPTO_CERT_ISSUER_COMMON_NAME (12)
138 #define SL_NETUTIL_CRYPTO_CERT_ISSUER_EMAIL (13)
139 #endif /* End - issuer information */
140 #define SL_NETUTIL_CRYPTO_CERT_DAYS_VALID (14)
141 #define SL_NETUTIL_CRYPTO_CERT_SUBJECT_COUNTRY (15)
142 #define SL_NETUTIL_CRYPTO_CERT_SUBJECT_STATE (16)
143 #define SL_NETUTIL_CRYPTO_CERT_SUBJECT_LOCALITY (17)
144 #define SL_NETUTIL_CRYPTO_CERT_SUBJECT_SUR (18)
145 #define SL_NETUTIL_CRYPTO_CERT_SUBJECT_ORG (19)
146 #define SL_NETUTIL_CRYPTO_CERT_SUBJECT_ORG_UNIT (20)
147 #define SL_NETUTIL_CRYPTO_CERT_SUBJECT_COMMON_NAME (21)
148 #define SL_NETUTIL_CRYPTO_CERT_SUBJECT_EMAIL (22)
149 #define SL_NETUTIL_CRYPTO_CERT_IS_CA (23)
150 
151 
152 /* Enumeration of "Temp-Keys" commands */
153 #define SL_NETUTIL_CRYPTO_TEMP_KEYS_CREATE (1)
154 #define SL_NETUTIL_CRYPTO_TEMP_KEYS_REMOVE (2)
155 
156 /* Enumeration of "Install/Uninstall" sub-commands */
157 #define SL_NETUTIL_CRYPTO_INSTALL_SUB_CMD (1)
158 #define SL_NETUTIL_CRYPTO_UNINSTALL_SUB_CMD (2)
159 
160 
161 /* The reserved key for IOT Usage */
162 #define SL_NETUTIL_CRYPTO_SERVICES_IOT_RESERVED_INDEX (0)
163 
164 /* The Temporary key for FS Usage */
165 #define SL_NETUTIL_CRYPTO_FS_TEMP_KEYS_OBJ_ID (1)
166 
167 
168 /**********************************************/
169 /* Public Key Info Structures and Definitions */
170 /**********************************************/
171 
172 /* Enumeration of Elliptic Curve "named" curves */
173 #define SL_NETUTIL_CRYPTO_EC_NAMED_CURVE_NONE (0)
174 #define SL_NETUTIL_CRYPTO_EC_NAMED_CURVE_SECP256R1 (1)
175 
176 /* PLACE HOLDER for future definitions of custom-curve parameters */
177 typedef struct
178 {
179  _u8 Padding[4];
181 
182 
183 /* Union holding the Elliptic Curve parameters. */
184 typedef union
185 {
186  _u8 NamedCurveParams; /* parameters for named-curve (the curve identifier) */
187  SlNetUtilCryptoEcCustomCurveParam_t CustomCurveParams; /* parameters for custom curves */
189 
190 
191 /* ?curve-type? definitions */
192 #define SL_NETUTIL_CRYPTO_EC_CURVE_TYPE_NAMED (1) /* ECC Named Curve type */
193 #define SL_NETUTIL_CRYPTO_EC_CURVE_TYPE_CUSTOM (2) /* ECC Custom curve type */
194 
195 
196 /* Enumeration of the supported public-key algorithms */
197 #define SL_NETUTIL_CRYPTO_PUB_KEY_ALGO_NONE (0)
198 #define SL_NETUTIL_CRYPTO_PUB_KEY_ALGO_EC (1)
199 
200 
201 /* Structure for holding the Elliptic Curve Key parameters */
202 typedef struct
203 {
204  _u8 CurveType; /* defines curve type - custom or named */
205  SlNetUtilCryptoEcCurveParams_u CurveParams; /* specific parameters of the curve (depends on curve_type) */
207 
208 /* Union for holding the Public Key parameters, depends on key algorithm */
209 typedef union
210 {
211 
212  SlNetUtilCryptoEcKeyParams_t EcParams; /* parameters for Elliptic Curve key */
213 
214  /* add containers for other key types and algos here*/
216 
217 /* structure for holding all the meta-data about a key-pair */
218 typedef struct
219 {
220  _u8 KeyAlgo;
222  _u8 KeyFileNameLen;
223  _u8 CertFileNameLen;
225 
226 /********************************************/
227 /* NetUtil-Crypto Cmd "Attributes" structures */
228 /********************************************/
229 /* structure for holding all the attributes for a "Sign" Command */
230 typedef struct
231 {
232  _u32 ObjId;
233  _u32 SigType;
234  _u32 Flags;
236 
237 
238 /* structure for holding all the attributes for a "Verify" Command */
239 typedef struct
240 {
241  _u32 ObjId;
242  _u32 SigType;
243  _u32 Flags;
244  _u16 MsgLen;
245  _u16 SigLen;
247 
248 /* structure for holding all the attributes for a "Create Certificate" Command */
249 typedef struct
250 {
251  _u32 ObjId;
252  _u32 Flags;
253  _u16 SubCmd;
255 
256 /* structure for holding all the attributes for "Key management" Commands: */
257 /* Temp-Key (create and delete), Install and un-Install. */
258 typedef struct
259 {
260  _u32 ObjId;
261  _u32 Flags;
262  _u16 SubCmd;
264 
265 /* structure for holding all the attributes for a "SL_NETUTIL_CMD_ARP_LOOKUP" Command */
266 typedef struct
267 {
268  _u16 NumOfRetries; /* number of retires for ARP request, range 1-20 */
269  _u16 Timeout; /* timeout between ARP requests, range 10-500 mSec , 10 mSec resolution*/
271 
272 
273 /******************************************************************************/
274 /* Type declarations */
275 /******************************************************************************/
276 
277 /*****************************************************************************/
278 /* Function prototypes */
279 /*****************************************************************************/
280 
294 #if _SL_INCLUDE_FUNC(sl_NetUtilSet)
295 _i32 sl_NetUtilSet(const _u16 Option, const _u32 ObjID, const _u8 *pValues, const _u16 ValueLen);
296 #endif
297 
343 #if _SL_INCLUDE_FUNC(sl_NetUtilGet)
344 _i16 sl_NetUtilGet(const _u16 Option, const _u32 ObjID, _u8 *pValues, _u16 *pValueLen);
345 #endif
346 
527 #if _SL_INCLUDE_FUNC(sl_NetUtilCmd)
528 _i16 sl_NetUtilCmd(const _u16 Cmd, const _u8 *pAttrib, const _u16 AttribLen,
529  const _u8 *pInputValues, const _u16 InputLen,
530  _u8 *pOutputValues,_u16 *pOutputLen );
531 #endif
532 
541 #ifdef __cplusplus
542 }
543 #endif /* __cplusplus */
544 
545 #endif /* __NETUTIL_H__ */
546 
547 
_i16 sl_NetUtilGet(const _u16 Option, const _u32 ObjID, _u8 *pValues, _u16 *pValueLen)
Function for getting configurations of utilities.
Definition: netutil.c:74
_i16 sl_NetUtilCmd(const _u16 Cmd, const _u8 *pAttrib, const _u16 AttribLen, const _u8 *pInputValues, const _u16 InputLen, _u8 *pOutputValues, _u16 *pOutputLen)
Function for performing utilities-related commands.
Definition: netutil.c:162
_i32 sl_NetUtilSet(const _u16 Option, const _u32 ObjID, const _u8 *pValues, const _u16 ValueLen)
Function for setting configurations of utilities.