Select one of the symbols to view example projects that use it.
 
Outline
...
...
...
...
...
...
#define NX_CRYPTO_AES_H
#include "nx_crypto.h"
#include "nx_crypto_cbc.h"
#include "nx_crypto_ctr.h"
#include "nx_crypto_ccm.h"
#include "nx_crypto_gcm.h"
#define NX_CRYPTO_BITS_IN_UCHAR
#define NX_CRYPTO_BIT_POSITION_BYTE_INDEX
#define NX_CRYPTO_BIT_POSITION_BIT_VALUE
#define NX_CRYPTO_BIT_POSITION_WORD_INDEX
#define NX_CRYPTO_BIT_POSITION_WORD_BIT_VALUE
#define NX_CRYPTO_AES_STATE_ROWS
#define NX_CRYPTO_AES_STATE_NB_BYTES
#define NX_CRYPTO_AES_KEY_SIZE_128_BITS
#define NX_CRYPTO_AES_KEY_SIZE_192_BITS
#define NX_CRYPTO_AES_KEY_SIZE_256_BITS
#define NX_CRYPTO_AES_256_KEY_LEN_IN_BITS
#define NX_CRYPTO_AES_192_KEY_LEN_IN_BITS
#define NX_CRYPTO_AES_128_KEY_LEN_IN_BITS
#define NX_CRYPTO_AES_XCBC_MAC_KEY_LEN_IN_BITS
#define NX_CRYPTO_AES_MAX_KEY_SIZE
#define NX_CRYPTO_AES_BLOCK_SIZE
#define NX_CRYPTO_AES_BLOCK_SIZE_IN_BITS
#define NX_CRYPTO_AES_IV_LEN_IN_BITS
#define NX_CRYPTO_AES_CTR_IV_LEN_IN_BITS
#define NX_CRYPTO_AES_KEY_SCHEDULE_UNKNOWN
#define NX_CRYPTO_AES_KEY_SCHEDULE_ENCRYPT
#define NX_CRYPTO_AES_KEY_SCHEDULE_DECRYPT
#define NX_CRYPTO_AES_TABLE
#define NX_CRYPTO_AES_TABLE
#define NX_AES
NX_CRYPTO_AES_STRUCT
_nx_crypto_aes_encrypt(NX_CRYPTO_AES *, UCHAR *, UCHAR *, UINT);
_nx_crypto_aes_decrypt(NX_CRYPTO_AES *, UCHAR *, UCHAR *, UINT);
_nx_crypto_aes_key_set(NX_CRYPTO_AES *, UCHAR *, UINT);
_nx_crypto_method_aes_init(struct NX_CRYPTO_METHOD_STRUCT *, UCHAR *, NX_CRYPTO_KEY_SIZE, void **, void *, ULONG);
_nx_crypto_method_aes_cleanup(void *);
_nx_crypto_method_aes_operation(UINT, void *, struct NX_CRYPTO_METHOD_STRUCT *, UCHAR *, NX_CRYPTO_KEY_SIZE, UCHAR *, ULONG, UCHAR *, UCHAR *, ULONG, void *, ULONG, void *, void (*)(void *, UINT));
_nx_crypto_method_aes_cbc_operation(UINT, void *, struct NX_CRYPTO_METHOD_STRUCT *, UCHAR *, NX_CRYPTO_KEY_SIZE, UCHAR *, ULONG, UCHAR *, UCHAR *, ULONG, void *, ULONG, void *, void (*)(void *, UINT));
_nx_crypto_method_aes_ccm_operation(UINT, void *, struct NX_CRYPTO_METHOD_STRUCT *, UCHAR *, NX_CRYPTO_KEY_SIZE, UCHAR *, ULONG, UCHAR *, UCHAR *, ULONG, void *, ULONG, void *, void (*)(void *, UINT));
_nx_crypto_method_aes_gcm_operation(UINT, void *, struct NX_CRYPTO_METHOD_STRUCT *, UCHAR *, NX_CRYPTO_KEY_SIZE, UCHAR *, ULONG, UCHAR *, UCHAR *, ULONG, void *, ULONG, void *, void (*)(void *, UINT));
_nx_crypto_method_aes_ctr_operation(UINT, void *, struct NX_CRYPTO_METHOD_STRUCT *, UCHAR *, NX_CRYPTO_KEY_SIZE, UCHAR *, ULONG, UCHAR *, UCHAR *, ULONG, void *, ULONG, void *, void (*)(void *, UINT));
_nx_crypto_method_aes_xcbc_operation(UINT, void *, struct NX_CRYPTO_METHOD_STRUCT *, UCHAR *, NX_CRYPTO_KEY_SIZE, UCHAR *, ULONG, UCHAR *, UCHAR *, ULONG, void *, ULONG, void *, void (*)(void *, UINT));
Files
loading...
SourceVuSTM32 Libraries and Samplesnetxduocrypto_libraries/inc/nx_crypto_aes.h
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
/**************************************************************************/ /* */ /* Copyright (c) Microsoft Corporation. All rights reserved. */ /* */ /* This software is licensed under the Microsoft Software License */ /* Terms for Microsoft Azure RTOS. Full text of the license can be */ /* found in the LICENSE file at https://aka.ms/AzureRTOS_EULA */ /* and in the root directory of this software. */ /* */... /**************************************************************************/ ... /**************************************************************************/ /**************************************************************************/ /** */ /** NetX Crypto Component */ /** */ /** AES Encryption */ /** */... /**************************************************************************/ /**************************************************************************/ ... /**************************************************************************/ /* */ /* APPLICATION INTERFACE DEFINITION RELEASE */ /* */ /* nx_crypto_aes.h PORTABLE C */ /* 6.1.10 */ /* AUTHOR */ /* */ /* Timothy Stapko, Microsoft Corporation */ /* */ /* DESCRIPTION */ /* */ /* This file defines the basic Application Interface (API) to the */ /* NetX Crypto AES module. */ /* */ /* RELEASE HISTORY */ /* */ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Timothy Stapko Initial Version 6.0 */ /* 09-30-2020 Timothy Stapko Modified comment(s), */ /* resulting in version 6.1 */ /* 01-31-2022 Timothy Stapko Modified comment(s), */ /* moved inverse key expansion,*/ /* added using RAM tables, */ /* resulting in version 6.1.10 */ /* */... /**************************************************************************/ #ifndef NX_CRYPTO_AES_H #define NX_CRYPTO_AES_H /* Determine if a C++ compiler is being used. If so, ensure that standard C is used to process the API information. *//* ... */ #ifdef __cplusplus /* Yes, C++ compiler is present. Use standard C. */ extern "C" { #endif /* Include the ThreadX and port-specific data type file. */ #include "nx_crypto.h" #include "nx_crypto_cbc.h" #include "nx_crypto_ctr.h" #include "nx_crypto_ccm.h" #include "nx_crypto_gcm.h" 5 includes /* Constants. */ #define NX_CRYPTO_BITS_IN_UCHAR ((UINT)0x8) /* Helper macros for bit indexing (used by the division operation). */ #define NX_CRYPTO_BIT_POSITION_BYTE_INDEX(x) (x >> 3) /* Divide the bit position by 8 to get the byte array index. */ #define NX_CRYPTO_BIT_POSITION_BIT_VALUE(x) ((UINT)0x1 << (x & 0x7)) /* The bit to set (OR with the byte) is at (bit position % 8). */ /* Word-aligned versions. */ #define NX_CRYPTO_BIT_POSITION_WORD_INDEX(x) (x >> 4) /* Divide the bit position by 16 to get the word array index. */ #define NX_CRYPTO_BIT_POSITION_WORD_BIT_VALUE(x) ((UINT)0x1 << (x & 0xF)) /* The bit to set (OR with the byte) is at (bit position % 16). */ /* AES Support */ #define NX_CRYPTO_AES_STATE_ROWS (4) #define NX_CRYPTO_AES_STATE_NB_BYTES (4) /* AES expects key sizes in the number of 32-bit words each key takes. */ #define NX_CRYPTO_AES_KEY_SIZE_128_BITS (4) #define NX_CRYPTO_AES_KEY_SIZE_192_BITS (6) #define NX_CRYPTO_AES_KEY_SIZE_256_BITS (8) #define NX_CRYPTO_AES_256_KEY_LEN_IN_BITS (256) #define NX_CRYPTO_AES_192_KEY_LEN_IN_BITS (192) #define NX_CRYPTO_AES_128_KEY_LEN_IN_BITS (128) #define NX_CRYPTO_AES_XCBC_MAC_KEY_LEN_IN_BITS (128) #define NX_CRYPTO_AES_MAX_KEY_SIZE (NX_CRYPTO_AES_KEY_SIZE_256_BITS) /* Maximum key size in bytes. */ #define NX_CRYPTO_AES_BLOCK_SIZE (16) /* The AES block size for all NetX Crypto operations, in bytes. */ #define NX_CRYPTO_AES_BLOCK_SIZE_IN_BITS (128) #define NX_CRYPTO_AES_IV_LEN_IN_BITS (128) #define NX_CRYPTO_AES_CTR_IV_LEN_IN_BITS (64) #define NX_CRYPTO_AES_KEY_SCHEDULE_UNKNOWN 0 #define NX_CRYPTO_AES_KEY_SCHEDULE_ENCRYPT 1 #define NX_CRYPTO_AES_KEY_SCHEDULE_DECRYPT 2 22 defines /* Define NX_CRYPTO_AES_USE_RAM_TABLES to move tables to RAM. */ #ifdef NX_CRYPTO_AES_USE_RAM_TABLES #define NX_CRYPTO_AES_TABLE static #else #define NX_CRYPTO_AES_TABLE static const #endif /* Define the control block structure for backward compatibility. */ #define NX_AES NX_CRYPTO_AES typedef struct NX_CRYPTO_AES_STRUCT { /* UINT nb; Number of bytes per column, equal to block length / 32 - ALWAYS == 4 */ /* AES internal state, 4 rows (32 bits each) of nb bytes */ UINT nx_crypto_aes_state[NX_CRYPTO_AES_STATE_NB_BYTES]; /* Number of *words* in the cipher key - can be 4 (128 bits), 6 (192 bits), or 8 (256 bits). */ USHORT nx_crypto_aes_key_size; /* Number of AES rounds for the current key. */ UCHAR nx_crypto_aes_rounds; /* Use the flag field to indicate the inverse key expansion is done. */ UCHAR nx_crypto_aes_inverse_key_expanded; /* The key schedule is as large as the key size (max = 256 bits) with expansion, total 64 UINT words. */ UINT nx_crypto_aes_key_schedule[NX_CRYPTO_AES_MAX_KEY_SIZE * 8]; UINT nx_crypto_aes_decrypt_key_schedule[NX_CRYPTO_AES_MAX_KEY_SIZE * 8]; /* Metadata for each mode. */ union { NX_CRYPTO_CBC cbc; NX_CRYPTO_CTR ctr; NX_CRYPTO_GCM gcm; NX_CRYPTO_CCM ccm; ...} nx_crypto_aes_mode_context; ...} NX_CRYPTO_AES; UINT _nx_crypto_aes_encrypt(NX_CRYPTO_AES *aes_ptr, UCHAR *input, UCHAR *output, UINT length); UINT _nx_crypto_aes_decrypt(NX_CRYPTO_AES *aes_ptr, UCHAR *input, UCHAR *output, UINT length); UINT _nx_crypto_aes_key_set(NX_CRYPTO_AES *aes_ptr, UCHAR *key, UINT key_size); UINT _nx_crypto_method_aes_init(struct NX_CRYPTO_METHOD_STRUCT *method, UCHAR *key, NX_CRYPTO_KEY_SIZE key_size_in_bits, VOID **handle, VOID *crypto_metadata, ULONG crypto_metadata_size); UINT _nx_crypto_method_aes_cleanup(VOID *crypto_metadata); UINT _nx_crypto_method_aes_operation(UINT op, /* Encrypt, Decrypt, Authenticate */ VOID *handle, /* Crypto handler */ struct NX_CRYPTO_METHOD_STRUCT *method, UCHAR *key, NX_CRYPTO_KEY_SIZE key_size_in_bits, UCHAR *input, ULONG input_length_in_byte, UCHAR *iv_ptr, UCHAR *output, ULONG output_length_in_byte, VOID *crypto_metadata, ULONG crypto_metadata_size, VOID *packet_ptr, VOID (*nx_crypto_hw_process_callback)(VOID *packet_ptr, UINT status)); UINT _nx_crypto_method_aes_cbc_operation(UINT op, /* Encrypt, Decrypt, Authenticate */ VOID *handle, /* Crypto handler */ struct NX_CRYPTO_METHOD_STRUCT *method, UCHAR *key, NX_CRYPTO_KEY_SIZE key_size_in_bits, UCHAR *input, ULONG input_length_in_byte, UCHAR *iv_ptr, UCHAR *output, ULONG output_length_in_byte, VOID *crypto_metadata, ULONG crypto_metadata_size, VOID *packet_ptr, VOID (*nx_crypto_hw_process_callback)(VOID *packet_ptr, UINT status)); UINT _nx_crypto_method_aes_ccm_operation(UINT op, /* Encrypt, Decrypt, Authenticate */ VOID *handle, /* Crypto handler */ struct NX_CRYPTO_METHOD_STRUCT *method, UCHAR *key, NX_CRYPTO_KEY_SIZE key_size_in_bits, UCHAR *input, ULONG input_length_in_byte, UCHAR *iv_ptr, UCHAR *output, ULONG output_length_in_byte, VOID *crypto_metadata, ULONG crypto_metadata_size, VOID *packet_ptr, VOID (*nx_crypto_hw_process_callback)(VOID *packet_ptr, UINT status)); UINT _nx_crypto_method_aes_gcm_operation(UINT op, /* Encrypt, Decrypt, Authenticate */ VOID *handle, /* Crypto handler */ struct NX_CRYPTO_METHOD_STRUCT *method, UCHAR *key, NX_CRYPTO_KEY_SIZE key_size_in_bits, UCHAR *input, ULONG input_length_in_byte, UCHAR *iv_ptr, UCHAR *output, ULONG output_length_in_byte, VOID *crypto_metadata, ULONG crypto_metadata_size, VOID *packet_ptr, VOID (*nx_crypto_hw_process_callback)(VOID *packet_ptr, UINT status)); UINT _nx_crypto_method_aes_ctr_operation(UINT op, /* Encrypt, Decrypt, Authenticate */ VOID *handle, /* Crypto handler */ struct NX_CRYPTO_METHOD_STRUCT *method, UCHAR *key, NX_CRYPTO_KEY_SIZE key_size_in_bits, UCHAR *input, ULONG input_length_in_byte, UCHAR *iv_ptr, UCHAR *output, ULONG output_length_in_byte, VOID *crypto_metadata, ULONG crypto_metadata_size, VOID *packet_ptr, VOID (*nx_crypto_hw_process_callback)(VOID *packet_ptr, UINT status)); UINT _nx_crypto_method_aes_xcbc_operation(UINT op, /* Encrypt, Decrypt, Authenticate */ VOID *handle, /* Crypto handler */ struct NX_CRYPTO_METHOD_STRUCT *method, UCHAR *key, NX_CRYPTO_KEY_SIZE key_size_in_bits, UCHAR *input, ULONG input_length_in_byte, UCHAR *iv_ptr, UCHAR *output, ULONG output_length_in_byte, VOID *crypto_metadata, ULONG crypto_metadata_size, VOID *packet_ptr, VOID (*nx_crypto_hw_process_callback)(VOID *packet_ptr, UINT status)); #ifdef __cplusplus }extern "C" { ... } #endif /* ... */ #endif /* NX_CRYPTO_AES_H_ */...
Details
Show:
from
Types: Columns:
This file uses the notable symbols shown below. Click anywhere in the file to view more details.