SimpleLink CC3120/CC3220 Host Driver  Version 2.0.1.18
Simplifies the implementation of Internet connectivity
netutil.h
1 /*
2  * Copyright (C) 2016 Texas Instruments Incorporated
3  *
4  * All rights reserved. Property of Texas Instruments Incorporated.
5  * Restricted rights to use, duplicate or disclose this code are
6  * granted through contract.
7  *
8  * The program may not be used without the written permission of
9  * Texas Instruments Incorporated or against the terms and conditions
10  * stipulated in the agreement under which this program has been supplied,
11  * and under no circumstances can it be used with non-TI connectivity device.
12  *
13  */
14 
15 #ifndef __NETUTIL_H__
16 #define __NETUTIL_H__
17 
18 /*****************************************************************************/
19 /* Include files */
20 /*****************************************************************************/
21 #include <ti/drivers/net/wifi/simplelink.h>
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
40 /*****************************************************************************/
41 /* Macro declarations */
42 /*****************************************************************************/
43 
44 /* Set/get options */
45 #define SL_NETUTIL_CRYPTO_PUBLIC_KEY (1)
46 #define SL_NETUTIL_CRYPTO_PUBLIC_KEY_INFO (2)
47 #define SL_NETUTIL_TRUE_RANDOM (3)
48 
49 
50 /* Commands */
51 #define SL_NETUTIL_CRYPTO_CMD_CREATE_CERT (1)
52 #define SL_NETUTIL_CRYPTO_CMD_SIGN_MSG (2)
53 #define SL_NETUTIL_CRYPTO_CMD_VERIFY_MSG (3)
54 #define SL_NETUTIL_CRYPTO_CMD_TEMP_KEYS (4)
55 #define SL_NETUTIL_CRYPTO_CMD_INSTALL_OP (5)
56 
57 
58 /*****************************************************************************/
59 /* Errors returned from the general error async event */
60 /*****************************************************************************/
61 
62 
63 /*****************************************************************************/
64 /* Structure/Enum declarations */
65 /*****************************************************************************/
66 
67 /* Defines the size of the buffer that will be alocated */
68 /* (on the stack) by the sl_UtilsCmd API. */
69 #define SL_NETUTIL_CMD_BUFFER_SIZE (256)
70 
71 /* Enumaration of Signature types */
72 #define SL_NETUTIL_CRYPTO_SIG_SHAwDSA (0)
73 #define SL_NETUTIL_CRYPTO_SIG_MD2wRSA (1)
74 #define SL_NETUTIL_CRYPTO_SIG_MD5wRSA (2)
75 #define SL_NETUTIL_CRYPTO_SIG_SHAwRSA (3)
76 #define SL_NETUTIL_CRYPTO_SIG_SHAwECDSA (4)
77 #define SL_NETUTIL_CRYPTO_SIG_SHA256wRSA (5)
78 #define SL_NETUTIL_CRYPTO_SIG_SHA256wECDSA (6)
79 #define SL_NETUTIL_CRYPTO_SIG_SHA384wRSA (7)
80 #define SL_NETUTIL_CRYPTO_SIG_SHA384wECDSA (8)
81 #define SL_NETUTIL_CRYPTO_SIG_SHA512wRSA (9)
82 #define SL_NETUTIL_CRYPTO_SIG_SHA512wECDSA (10)
83 /* Add more signature-Types here */
84 
85 /* Digest length definitions */
86 #define SL_NETUTIL_CRYPTO_DGST_MD2_LEN_BYTES (16)
87 #define SL_NETUTIL_CRYPTO_DGST_MD5_LEN_BYTES (16)
88 #define SL_NETUTIL_CRYPTO_DGST_SHA_LEN_BYTES (20)
89 #define SL_NETUTIL_CRYPTO_DGST_SHA256_LEN_BYTES (32)
90 #define SL_NETUTIL_CRYPTO_DGST_SHA384_LEN_BYTES (48)
91 #define SL_NETUTIL_CRYPTO_DGST_SHA512_LEN_BYTES (64)
92 
93 
94 /* Enumeration of Create-Certificate sub-commands */
95 #define SL_NETUTIL_CRYPTO_CERT_INIT (1)
96 #define SL_NETUTIL_CRYPTO_CERT_SIGN_AND_SAVE (2)
97 #define SL_NETUTIL_CRYPTO_CERT_VER (3)
98 #define SL_NETUTIL_CRYPTO_CERT_SERIAL (4)
99 #define SL_NETUTIL_CRYPTO_CERT_SIG_TYPE (5)
100 #if 0 /* reserved for Issuer information - currently not supported */
101 #define SL_NETUTIL_CRYPTO_CERT_ISSUER_COUNTRY (6)
102 #define SL_NETUTIL_CRYPTO_CERT_ISSUER_STATE (7)
103 #define SL_NETUTIL_CRYPTO_CERT_ISSUER_LOCALITY (8)
104 #define SL_NETUTIL_CRYPTO_CERT_ISSUER_SUR (9)
105 #define SL_NETUTIL_CRYPTO_CERT_ISSUER_ORG (10)
106 #define SL_NETUTIL_CRYPTO_CERT_ISSUER_ORG_UNIT (11)
107 #define SL_NETUTIL_CRYPTO_CERT_ISSUER_COMMON_NAME (12)
108 #define SL_NETUTIL_CRYPTO_CERT_ISSUER_EMAIL (13)
109 #endif /* End - issuer information */
110 #define SL_NETUTIL_CRYPTO_CERT_DAYS_VALID (14)
111 #define SL_NETUTIL_CRYPTO_CERT_SUBJECT_COUNTRY (15)
112 #define SL_NETUTIL_CRYPTO_CERT_SUBJECT_STATE (16)
113 #define SL_NETUTIL_CRYPTO_CERT_SUBJECT_LOCALITY (17)
114 #define SL_NETUTIL_CRYPTO_CERT_SUBJECT_SUR (18)
115 #define SL_NETUTIL_CRYPTO_CERT_SUBJECT_ORG (19)
116 #define SL_NETUTIL_CRYPTO_CERT_SUBJECT_ORG_UNIT (20)
117 #define SL_NETUTIL_CRYPTO_CERT_SUBJECT_COMMON_NAME (21)
118 #define SL_NETUTIL_CRYPTO_CERT_SUBJECT_EMAIL (22)
119 #define SL_NETUTIL_CRYPTO_CERT_IS_CA (23)
120 
121 
122 /* Enumeration of "Temp-Keys" commands */
123 #define SL_NETUTIL_CRYPTO_TEMP_KEYS_CREATE (1)
124 #define SL_NETUTIL_CRYPTO_TEMP_KEYS_REMOVE (2)
125 
126 /* Enumeration of "Install/Uninstall" sub-commands */
127 #define SL_NETUTIL_CRYPTO_INSTALL_SUB_CMD (1)
128 #define SL_NETUTIL_CRYPTO_UNINSTALL_SUB_CMD (2)
129 
130 
131 /* The reserved key for IOT Usage */
132 #define SL_NETUTIL_CRYPTO_SERVICES_IOT_RESERVED_INDEX (0)
133 
134 /* The Temporary key for FS Usage */
135 #define SL_NETUTIL_CRYPTO_FS_TEMP_KEYS_OBJ_ID (1)
136 
137 
138 /**********************************************/
139 /* Public Key Info Structures and Definitions */
140 /**********************************************/
141 
142 /* Enumeration of Elliptic Curve "named" curves */
143 #define SL_NETUTIL_CRYPTO_EC_NAMED_CURVE_NONE (0)
144 #define SL_NETUTIL_CRYPTO_EC_NAMED_CURVE_SECP256R1 (1)
145 
146 /* PLACE HOLDER for future definitions of custom-curve parameters */
147 typedef struct
148 {
149  _u8 Padding[4];
151 
152 
153 /* Union holding the Elliptic Curve parameters. */
154 typedef union
155 {
156  _u8 NamedCurveParams; /* parameters for named-curve (the curve identifier) */
157  SlNetUtilCryptoEcCustomCurveParam_t CustomCurveParams; /* parameters for custom curves */
159 
160 
161 /* “curve-type” definitions */
162 #define SL_NETUTIL_CRYPTO_EC_CURVE_TYPE_NAMED (1) /* ECC Named Curve type */
163 #define SL_NETUTIL_CRYPTO_EC_CURVE_TYPE_CUSTOM (2) /* ECC Custom curve type */
164 
165 
166 /* Enumeration of the supported public-key algorithms */
167 #define SL_NETUTIL_CRYPTO_PUB_KEY_ALGO_NONE (0)
168 #define SL_NETUTIL_CRYPTO_PUB_KEY_ALGO_EC (1)
169 
170 
171 /* Structure for holding the Elliptic Curve Key parameters */
172 typedef struct
173 {
174  _u8 CurveType; /* defines curve type - custom or named */
175  SlNetUtilCryptoEcCurveParams_u CurveParams; /* specific parameters of the curve (depends on curve_type) */
177 
178 /* Union for holding the Public Key parameters, depends on key algorithm */
179 typedef union
180 {
181 
182  SlNetUtilCryptoEcKeyParams_t EcParams; /* parameters for Elliptic Curve key */
183 
184  /* add containers for other key types and algos here*/
185 
187 
188 
189 
190 /* structure for holding all the meta-data about a key-pair */
191 typedef struct
192 {
193  _u8 KeyAlgo;
195  _u8 KeyFileNameLen;
196  _u8 CertFileNameLen;
198 
199 /********************************************/
200 /* NetUtil-Crypto Cmd "Attributes" structures */
201 /********************************************/
202 /* structure for holding all the attributes for a "Sign" Command */
203 typedef struct
204 {
205  _u32 ObjId;
206  _u32 SigType;
207  _u32 Flags;
209 
210 
211 /* structure for holding all the attributes for a "Verify" Command */
212 typedef struct
213 {
214  _u32 ObjId;
215  _u32 SigType;
216  _u32 Flags;
217  _u16 MsgLen;
218  _u16 SigLen;
220 
221 /* structure for holding all the attributes for a "Create Certificate" Command */
222 typedef struct
223 {
224  _u32 ObjId;
225  _u32 Flags;
226  _u16 SubCmd;
228 
229 /* structure for holding all the attributes for "Key management" Commands: */
230 /* Temp-Key (create and delete), Install and un-Install. */
231 typedef struct
232 {
233  _u32 ObjId;
234  _u32 Flags;
235  _u16 SubCmd;
237 
238 
239 
240 /******************************************************************************/
241 /* Type declarations */
242 /******************************************************************************/
243 
244 /*****************************************************************************/
245 /* Function prototypes */
246 /*****************************************************************************/
247 
260 #if _SL_INCLUDE_FUNC(sl_NetUtilSet)
261 _i32 sl_NetUtilSet(const _u16 Option, const _u32 ObjID, const _u8 *pValues, const _u16 ValueLen);
262 #endif
263 
314 #if _SL_INCLUDE_FUNC(sl_NetUtilGet)
315 _i16 sl_NetUtilGet(const _u16 Option, const _u32 ObjID, _u8 *pValues, _u16 *pValueLen);
316 #endif
317 
465 #if _SL_INCLUDE_FUNC(sl_NetUtilCmd)
466 _i16 sl_NetUtilCmd(const _u16 Cmd, const _u8 *pAttrib, const _u16 AttribLen,
467  const _u8 *pInputValues, const _u16 InputLen,
468  _u8 *pOutputValues,_u16 *pOutputLen );
469 #endif
470 
479 #ifdef __cplusplus
480 }
481 #endif /* __cplusplus */
482 
483 #endif /* __NETUTIL_H__ */
484 
485 
_i16 sl_NetUtilGet(const _u16 Option, const _u32 ObjID, _u8 *pValues, _u16 *pValueLen)
Function for getting configurations of utilities.
Definition: netutil.c:61
_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:151
_i32 sl_NetUtilSet(const _u16 Option, const _u32 ObjID, const _u8 *pValues, const _u16 ValueLen)
Function for setting configurations of utilities.