aboutsummaryrefslogtreecommitdiff
path: root/KSDK_1.2.0/platform/drivers/src/mmcau/asm-cm0p/cau_api.h
blob: 7d5c72a0fd401793ca3bcade703aaecffae669b2 (plain)
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
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
/*
 *  CAU Header File
 *  Works with library cau_lib.a and lib_mmcau*.a
 *  Define FREESCALE_CAU if CAU coprocessor is used --Register parameter passing is assumed
 *  Define FREESCALE_MMCAU if mmCAU coprocessor is used --EABI for Kinetis ARM Cortex-Mx
 *  12/19/2013
 */

#if FREESCALE_MMCAU
#define cau_aes_set_key               mmcau_aes_set_key
#define cau_aes_encrypt               mmcau_aes_encrypt
#define cau_aes_decrypt               mmcau_aes_decrypt
#define cau_des_chk_parity            mmcau_des_chk_parity
#define cau_des_encrypt               mmcau_des_encrypt
#define cau_des_decrypt               mmcau_des_decrypt
#define cau_md5_initialize_output     mmcau_md5_initialize_output
#define cau_md5_hash_n                mmcau_md5_hash_n
#define cau_md5_update                mmcau_md5_update
#define cau_md5_hash                  mmcau_md5_hash
#define cau_sha1_initialize_output    mmcau_sha1_initialize_output
#define cau_sha1_hash_n               mmcau_sha1_hash_n
#define cau_sha1_update               mmcau_sha1_update
#define cau_sha1_hash                 mmcau_sha1_hash
#define cau_sha256_initialize_output  mmcau_sha256_initialize_output
#define cau_sha256_hash_n             mmcau_sha256_hash_n
#define cau_sha256_update             mmcau_sha256_update
#define cau_sha256_hash               mmcau_sha256_hash
#endif

//******************************************************************************
// 
// AES: Performs an AES key expansion
//   arguments
//          *key        pointer to input key (128, 192, 256 bits in length)
//           key_size   key_size in bits (128, 192, 256)
//          *key_sch    pointer to key schedule output (44, 52, 60 longwords)
//
//   calling convention
//   void   cau_aes_set_key (const unsigned char *key,
//                           const int            key_size,
//                           unsigned char       *key_sch)
#if FREESCALE_CAU
__declspec (standard_abi)
#endif
void 
cau_aes_set_key (const unsigned char *key, const int key_size, 
                 unsigned char *key_sch);

//******************************************************************************
//******************************************************************************
//
// AES: Encrypts a single 16-byte block
//   arguments
//          *in         pointer to 16-byte block of input plaintext
//          *key_sch    pointer to key schedule (44, 52, 60 longwords)
//           nr         number of AES rounds (10, 12, 14 = f(key_schedule))
//          *out        pointer to 16-byte block of output ciphertext
//
//   NOTE   Input and output blocks may overlap
//
//   calling convention
//   void   cau_aes_encrypt (const unsigned char *in,
//                           const unsigned char *key_sch,
//                           const int            nr,
//                           unsigned char       *out)
#if FREESCALE_CAU
__declspec (standard_abi)
#endif
void 
cau_aes_encrypt (const unsigned char *in, const unsigned char *key_sch, 
                 const int nr, unsigned char *out);

//******************************************************************************
//******************************************************************************
//
// AES: Decrypts a single 16-byte block
//   arguments
//          *in         pointer to 16-byte block of input chiphertext
//          *key_sch    pointer to key schedule (44, 52, 60 longwords)
//           nr         number of AES rounds (10, 12, 14 = f(key_schedule))
//          *out        pointer to 16-byte block of output plaintext
//
//   NOTE   Input and output blocks may overlap
//
//   calling convention
//   void   cau_aes_decrypt (const unsigned char *in,
//                           const unsigned char *key_sch,
//                           const int            nr,
//                           unsigned char       *out)
#if FREESCALE_CAU
__declspec (standard_abi)
#endif
void 
cau_aes_decrypt (const unsigned char *in, const unsigned char *key_sch, 
                 const int nr, unsigned char *out);
    
//******************************************************************************
// 
// DES: Checks key parity
//   arguments
//          *key        pointer to 64-bit DES key with parity bits
//
//   return
//          0           no error
//         -1           parity error
//
//   calling convention
//   int    cau_des_chk_parity (const unsigned char *key)
#if FREESCALE_CAU
__declspec (standard_abi)
#endif
int 
cau_des_chk_parity (const unsigned char *key);

//******************************************************************************
//
// DES: Encrypts a single 8-byte block
//   arguments
//          *in         pointer to 8-byte block of input plaintext
//          *key        pointer to 64-bit DES key with parity bits
//          *out        pointer to 8-byte block of output ciphertext
//
//   NOTE   Input and output blocks may overlap
//
//   calling convention
//   void     cau_des_encrypt (const unsigned char *in,
//                             const unsigned char *key,
//                             unsigned char       *out)
#if FREESCALE_CAU
__declspec (standard_abi)
#endif
void 
cau_des_encrypt (const unsigned char *in, const unsigned char *key, 
                 unsigned char *out);

//******************************************************************************
// 
// DES: Decrypts a single 8-byte block
//   arguments
//          *in         pointer to 8-byte block of input ciphertext
//          *key        pointer to 64-bit DES key with parity bits
//          *out        pointer to 8-byte block of output plaintext
//   
//   NOTE   Input and output blocks may overlap
//   
//   calling convention
//   void   cau_des_decrypt (const unsigned char *in,
//                           const unsigned char *key,
//                           unsigned char       *out)
#if FREESCALE_CAU
__declspec (standard_abi)
#endif
void 
cau_des_decrypt (const unsigned char *in, const unsigned char *key, 
                 unsigned char *out);
    
//******************************************************************************
//******************************************************************************
//
// MD5: Initializes the MD5 state variables
//   arguments
//          *md_state   pointer to 120-bit block of md5 state variables:
//                      a,b,c,d
//
//   calling convention
//   void   cau_md5_initialize_output (const unsigned char *md_state)
#if FREESCALE_CAU
__declspec (standard_abi)
#endif
void 
cau_md5_initialize_output (const unsigned char *md5_state);

//******************************************************************************
//******************************************************************************
//
// MD5: Updates MD5 state variables for one or more input message blocks
//
//   arguments
//          *msg_data   pointer to start of input message data
//           num_blks   number of 512-bit blocks to process
//          *md_state   pointer to 128-bit block of MD5 state variables:
//                      a,b,c,d
//
//   calling convention
//   void   cau_md5_hash_n (const unsigned char *msg_data,
//                          const int            num_blks,
//                          unsigned char       *md_state)
#if FREESCALE_CAU
__declspec (standard_abi)
#endif
void 
cau_md5_hash_n (const unsigned char *msg_data, const int num_blks, 
                unsigned char *md5_state);

//******************************************************************************
//******************************************************************************
//
// MD5: Updates MD5 state variables for one or more input message blocks
//   arguments
//          *msg_data   pointer to start of input message data
//           num_blks   number of 512-bit blocks to process
//          *md_state   pointer to 128-bit block of MD5 state variables: 
//                      a,b,c,d
//
//   calling convention
//   void   cau_md5_update (const unsigned char *msg_data,
//                          const int            num_blks,
//                          unsigned char       *md_state)
#if FREESCALE_CAU
__declspec (standard_abi)
#endif
void 
cau_md5_update (const unsigned char *msg_data, const int num_blks, 
                unsigned char *md5_state);

//******************************************************************************
//******************************************************************************
//
// MD5: Performs MD5 hash algorithm for a single input message block
//          *msg_data   pointer to start of input message data
//          *md_state   pointer to 128-bit block of MD5 state variables:
//                      a,b,c,d
//
//   calling convention
//   void   cau_md5_hash (const unsigned char *msg_data,
//                        unsigned char       *md_state)
#if FREESCALE_CAU
__declspec (standard_abi)
#endif
void 
cau_md5_hash (const unsigned char *msg_data, unsigned char *md5_state);

//******************************************************************************
//******************************************************************************
//
// SHA1: Initializes the SHA1 state variables
//   arguments
//          *sha1_state pointer to 160-bit block of SHA1 state variables:
//                      a,b,c,d,e
//
//   calling convention
//   void   cau_sha1_initialize_output (const unsigned int *sha1_state)
#if FREESCALE_CAU
__declspec (standard_abi)
#endif
void 
cau_sha1_initialize_output (const unsigned int *sha1_state);

//******************************************************************************
//******************************************************************************
// 
// SHA1: Perform the hash and generate SHA1 state variables for one or more 
//       input message blocks 
//  arguments
//          *msg_data   pointer to start of input message data
//           num_blks   number of 512-bit blocks to process
//          *sha1_state pointer to 160-bit block of SHA1 state variables:
//                      a,b,c,d,e
//
//   NOTE   Input message and state variable output blocks must not overlap
//
//   calling convention
//   void   cau_sha1_hash (const unsigned char *msg_data,
//                         const int            num_blks,
//                         unsigned int        *sha1_state)
#if FREESCALE_CAU
__declspec (standard_abi)
#endif
void 
cau_sha1_hash_n (const unsigned char *msg_data, const int num_blks, 
                 unsigned int *sha1_state);

//******************************************************************************
//******************************************************************************
// 
// SHA1: Updates SHA1 state variables for one or more input message blocks
//   arguments
//          *msg_data   pointer to start of input message data
//           num_blks   number of 512-bit blocks to process
//          *sha1_state pointer to 160-bit block of SHA1 state variables:
//                      a,b,c,d,e
//
//   calling convention
//   void   cau_sha1_update (const unsigned char *msg_data,
//                           const int            num_blks,
//                           unsigned int        *sha1_state)
#if FREESCALE_CAU
__declspec (standard_abi)
#endif
void 
cau_sha1_update (const unsigned char *msg_data, const int num_blks, 
                 unsigned int *sha1_state);

//******************************************************************************
//******************************************************************************
// 
// SHA1: Performs SHA1 hash algorithm on a single input message block
//   arguments
//          *msg_data   pointer to start of input message data
//          *sha1_state pointer to 160-bit block of SHA1 state variables:
//                      a,b,c,d,e
//
//   calling convention
//   void   cau_sha1_update (const unsigned char *msg_data,
//                           unsigned int        *sha1_state)
#if FREESCALE_CAU
__declspec (standard_abi)
#endif
void 
cau_sha1_hash (const unsigned char *msg_data, 
               unsigned int *sha1_state);
    
//******************************************************************************
//******************************************************************************
// 
// SHA256: Initializes the hash output and checks the CAU hardware revision
//   arguments
//          *output     pointer to 256-bit message digest output
//
//   return
//          0           no error -> CAU2 hardware present
//         -1           error -> incorrect CAU hardware revision
//
//   calling convention
//   int    cau_sha256_initialize_output (const unsigned int *output)
#if FREESCALE_CAU
__declspec (standard_abi)
#endif
int 
cau_sha256_initialize_output (const unsigned int *output);

//******************************************************************************
//******************************************************************************
// 
// SHA256: Updates SHA256 digest output for one or more message block arguments 
//   arguments
//          *input      pointer to start of input message
//           input      number of 512-bit blocks to process
//          *output     pointer to 256-bit message digest output
// 
//   NOTE   Input message and digest output blocks must not overlap
// 
//   calling convention
//   void   cau_sha256_hash_n (const unsigned char *input,
//                             int                  num_blks,
//                             const unsigned int  *output)
#if FREESCALE_CAU
__declspec (standard_abi)
#endif
void 
cau_sha256_hash_n (const unsigned char *input, const int num_blks, 
                   unsigned int *output);

//******************************************************************************
//******************************************************************************
//
// SHA256: Updates SHA256 state variables for one or more input message blocks
//   arguments
//          *input      pointer to start of input message data
//           num_blks   number of 512-bit blocks to process
//          *output     pointer to 256-bit message digest output
//
//   calling convention
//   void   cau_sha256_update (const unsigned char *input,
//                             const int            num_blks,
//                             unsigned int        *output)
#if FREESCALE_CAU
__declspec (standard_abi)
#endif
void 
cau_sha256_update (const unsigned char *input, const int num_blks, 
                   unsigned int *output);

//******************************************************************************
//******************************************************************************
//
// SHA256: Performs SHA256 hash algorithm for a single input message block
//   arguments
//          *input      pointer to start of input message data
//          *output     pointer to 256-bit message digest output
//
//   calling convention
//   void   cau_sha256_hash (const unsigned char *input,
//                           unsigned int        *output)
#if FREESCALE_CAU
__declspec (standard_abi)
#endif
void 
cau_sha256_hash (const unsigned char *input, unsigned int *output);