[package] base-files, ppp: fix interface shutdown
[openwrt.git] / target / linux / generic-2.6 / files / crypto / ocf / kirkwood / cesa / mvCesaTest.c
1 /*******************************************************************************
2 Copyright (C) Marvell International Ltd. and its affiliates
3
4 This software file (the "File") is owned and distributed by Marvell
5 International Ltd. and/or its affiliates ("Marvell") under the following
6 alternative licensing terms. Once you have made an election to distribute the
7 File under one of the following license alternatives, please (i) delete this
8 introductory statement regarding license alternatives, (ii) delete the two
9 license alternatives that you have not elected to use and (iii) preserve the
10 Marvell copyright notice above.
11
12 ********************************************************************************
13 Marvell Commercial License Option
14
15 If you received this File from Marvell and you have entered into a commercial
16 license agreement (a "Commercial License") with Marvell, the File is licensed
17 to you under the terms of the applicable Commercial License.
18
19 ********************************************************************************
20 Marvell GPL License Option
21
22 If you received this File from Marvell, you may opt to use, redistribute and/or
23 modify this File in accordance with the terms and conditions of the General
24 Public License Version 2, June 1991 (the "GPL License"), a copy of which is
25 available along with the File in the license.txt file or by writing to the Free
26 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or
27 on the worldwide web at http://www.gnu.org/licenses/gpl.txt.
28
29 THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED
30 WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY
31 DISCLAIMED. The GPL License provides additional details about this warranty
32 disclaimer.
33 ********************************************************************************
34 Marvell BSD License Option
35
36 If you received this File from Marvell, you may opt to use, redistribute and/or
37 modify this File under the following licensing terms.
38 Redistribution and use in source and binary forms, with or without modification,
39 are permitted provided that the following conditions are met:
40
41 * Redistributions of source code must retain the above copyright notice,
42 this list of conditions and the following disclaimer.
43
44 * Redistributions in binary form must reproduce the above copyright
45 notice, this list of conditions and the following disclaimer in the
46 documentation and/or other materials provided with the distribution.
47
48 * Neither the name of Marvell nor the names of its contributors may be
49 used to endorse or promote products derived from this software without
50 specific prior written permission.
51
52 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
53 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
54 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
55 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
56 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
57 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
58 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
59 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
60 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
61 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
62
63 *******************************************************************************/
64
65 #include "mvOs.h"
66
67 #if defined(MV_VXWORKS)
68
69 #include "sysLib.h"
70 #include "logLib.h"
71 #include "tickLib.h"
72 #include "intLib.h"
73 #include "config.h"
74
75
76 SEM_ID cesaSemId = NULL;
77 SEM_ID cesaWaitSemId = NULL;
78
79 #define CESA_TEST_LOCK(flags) flags = intLock()
80 #define CESA_TEST_UNLOCK(flags) intUnlock(flags)
81
82 #define CESA_TEST_WAIT_INIT() cesaWaitSemId = semBCreate(SEM_Q_PRIORITY, SEM_EMPTY)
83 #define CESA_TEST_WAKE_UP() semGive(cesaWaitSemId)
84 #define CESA_TEST_WAIT(cond, ms) semTake(cesaWaitSemId, (sysClkRateGet()*ms)/1000)
85
86 #define CESA_TEST_TICK_GET() tickGet()
87 #define CESA_TEST_TICK_TO_MS(tick) (((tick)*1000)/sysClkRateGet())
88
89 #elif defined(MV_LINUX)
90
91 #include <linux/wait.h>
92 wait_queue_head_t cesaTest_waitq;
93 spinlock_t cesaLock;
94
95 #define CESA_TEST_LOCK(flags) spin_lock_irqsave( &cesaLock, flags)
96 #define CESA_TEST_UNLOCK(flags) spin_unlock_irqrestore( &cesaLock, flags);
97
98 #define CESA_TEST_WAIT_INIT() init_waitqueue_head(&cesaTest_waitq)
99 #define CESA_TEST_WAKE_UP() wake_up(&cesaTest_waitq)
100 #define CESA_TEST_WAIT(cond, ms) wait_event_timeout(cesaTest_waitq, (cond), msecs_to_jiffies(ms))
101
102 #define CESA_TEST_TICK_GET() jiffies
103 #define CESA_TEST_TICK_TO_MS(tick) jiffies_to_msecs(tick)
104
105 #elif defined(MV_NETBSD)
106
107 #include <sys/param.h>
108 #include <sys/kernel.h>
109 static int cesaLock;
110
111 #define CESA_TEST_LOCK(flags) flags = splnet()
112 #define CESA_TEST_UNLOCK(flags) splx(flags)
113
114 #define CESA_TEST_WAIT_INIT() /* nothing */
115 #define CESA_TEST_WAKE_UP() wakeup(&cesaLock)
116 #define CESA_TEST_WAIT(cond, ms) \
117 do { \
118 while (!(cond)) \
119 tsleep(&cesaLock, PWAIT, "cesatest",mstohz(ms)); \
120 } while (/*CONSTCOND*/0)
121
122 #define CESA_TEST_TICK_GET() hardclock_ticks
123 #define CESA_TEST_TICK_TO_MS(tick) ((1000/hz)*(tick))
124
125 #define request_irq(i,h,t,n,a) \
126 !mv_intr_establish((i),IPL_NET,(int(*)(void *))(h),(a))
127
128 #else
129 #error "Only Linux, VxWorks, or NetBSD OS are supported"
130 #endif
131
132 #include "mvDebug.h"
133
134 #include "mvSysHwConfig.h"
135 #include "boardEnv/mvBoardEnvLib.h"
136 #include "ctrlEnv/sys/mvCpuIf.h"
137 #include "cntmr/mvCntmr.h"
138 #include "cesa/mvCesa.h"
139 #include "cesa/mvCesaRegs.h"
140 #include "cesa/mvMD5.h"
141 #include "cesa/mvSHA1.h"
142
143 #if defined(CONFIG_MV646xx)
144 #include "marvell_pic.h"
145 #endif
146
147 #define MV_CESA_USE_TIMER_ID 0
148 #define CESA_DEF_BUF_SIZE 1500
149 #define CESA_DEF_BUF_NUM 1
150 #define CESA_DEF_SESSION_NUM 32
151
152 #define CESA_DEF_ITER_NUM 100
153
154 #define CESA_DEF_REQ_SIZE 256
155
156
157 /* CESA Tests Debug */
158 #undef CESA_TEST_DEBUG
159
160 #ifdef CESA_TEST_DEBUG
161
162 # define CESA_TEST_DEBUG_PRINT(msg) mvOsPrintf msg
163 # define CESA_TEST_DEBUG_CODE(code) code
164
165 typedef struct
166 {
167 int type; /* 0 - isrEmpty, 1 - cesaReadyGet, 2 - cesaAction */
168 MV_U32 timeStamp;
169 MV_U32 cause;
170 MV_U32 realCause;
171 MV_U32 dmaCause;
172 int resources;
173 MV_CESA_REQ* pReqReady;
174 MV_CESA_REQ* pReqEmpty;
175 MV_CESA_REQ* pReqProcess;
176 } MV_CESA_TEST_TRACE;
177
178 #define MV_CESA_TEST_TRACE_SIZE 25
179
180 static int cesaTestTraceIdx = 0;
181 static MV_CESA_TEST_TRACE cesaTestTrace[MV_CESA_TEST_TRACE_SIZE];
182
183 static void cesaTestTraceAdd(int type, MV_U32 cause)
184 {
185 cesaTestTrace[cesaTestTraceIdx].type = type;
186 cesaTestTrace[cesaTestTraceIdx].cause = cause;
187 cesaTestTrace[cesaTestTraceIdx].realCause = MV_REG_READ(MV_CESA_ISR_CAUSE_REG);
188 cesaTestTrace[cesaTestTraceIdx].dmaCause = MV_REG_READ(IDMA_CAUSE_REG);
189 cesaTestTrace[cesaTestTraceIdx].resources = cesaReqResources;
190 cesaTestTrace[cesaTestTraceIdx].pReqReady = pCesaReqReady;
191 cesaTestTrace[cesaTestTraceIdx].pReqEmpty = pCesaReqEmpty;
192 cesaTestTrace[cesaTestTraceIdx].pReqProcess = pCesaReqProcess;
193 cesaTestTrace[cesaTestTraceIdx].timeStamp = mvCntmrRead(MV_CESA_USE_TIMER_ID);
194 cesaTestTraceIdx++;
195 if(cesaTestTraceIdx == MV_CESA_TEST_TRACE_SIZE)
196 cesaTestTraceIdx = 0;
197 }
198
199 #else
200
201 # define CESA_TEST_DEBUG_PRINT(msg)
202 # define CESA_TEST_DEBUG_CODE(code)
203
204 #endif /* CESA_TEST_DEBUG */
205
206 int cesaExpReqId=0;
207 int cesaCbIter=0;
208
209 int cesaIdx;
210 int cesaIteration;
211 int cesaRateSize;
212 int cesaReqSize;
213 unsigned long cesaTaskId;
214 int cesaBufNum;
215 int cesaBufSize;
216 int cesaCheckOffset;
217 int cesaCheckSize;
218 int cesaCheckMode;
219 int cesaTestIdx;
220 int cesaCaseIdx;
221
222
223 MV_U32 cesaTestIsrCount = 0;
224 MV_U32 cesaTestIsrMissCount = 0;
225
226 MV_U32 cesaCryptoError = 0;
227 MV_U32 cesaReqIdError = 0;
228 MV_U32 cesaError = 0;
229
230 char* cesaHexBuffer = NULL;
231
232 char* cesaBinBuffer = NULL;
233 char* cesaExpBinBuffer = NULL;
234
235 char* cesaInputHexStr = NULL;
236 char* cesaOutputHexStr = NULL;
237
238 MV_BUF_INFO cesaReqBufs[CESA_DEF_REQ_SIZE];
239
240 MV_CESA_COMMAND* cesaCmdRing;
241 MV_CESA_RESULT cesaResult;
242
243 int cesaTestFull = 0;
244
245 MV_BOOL cesaIsReady = MV_FALSE;
246 MV_U32 cesaCycles = 0;
247 MV_U32 cesaBeginTicks = 0;
248 MV_U32 cesaEndTicks = 0;
249 MV_U32 cesaRate = 0;
250 MV_U32 cesaRateAfterDot = 0;
251
252 void *cesaTestOSHandle = NULL;
253
254 enum
255 {
256 CESA_FAST_CHECK_MODE = 0,
257 CESA_FULL_CHECK_MODE,
258 CESA_NULL_CHECK_MODE,
259 CESA_SHOW_CHECK_MODE,
260 CESA_SW_SHOW_CHECK_MODE,
261 CESA_SW_NULL_CHECK_MODE,
262
263 CESA_MAX_CHECK_MODE
264 };
265
266 enum
267 {
268 DES_TEST_TYPE = 0,
269 TRIPLE_DES_TEST_TYPE = 1,
270 AES_TEST_TYPE = 2,
271 MD5_TEST_TYPE = 3,
272 SHA_TEST_TYPE = 4,
273 COMBINED_TEST_TYPE = 5,
274
275 MAX_TEST_TYPE
276 };
277
278 /* Tests data base */
279 typedef struct
280 {
281 short sid;
282 char cryptoAlgorithm; /* DES/3DES/AES */
283 char cryptoMode; /* ECB or CBC */
284 char macAlgorithm; /* MD5 / SHA1 */
285 char operation; /* CRYPTO/HMAC/CRYPTO+HMAC/HMAC+CRYPTO */
286 char direction; /* ENCODE(SIGN)/DECODE(VERIFY) */
287 unsigned char* pCryptoKey;
288 int cryptoKeySize;
289 unsigned char* pMacKey;
290 int macKeySize;
291 const char* name;
292
293 } MV_CESA_TEST_SESSION;
294
295 typedef struct
296 {
297 MV_CESA_TEST_SESSION* pSessions;
298 int numSessions;
299
300 } MV_CESA_TEST_DB_ENTRY;
301
302 typedef struct
303 {
304 char* plainHexStr;
305 char* cipherHexStr;
306 unsigned char* pCryptoIV;
307 int cryptoLength;
308 int macLength;
309 int digestOffset;
310
311 } MV_CESA_TEST_CASE;
312
313 typedef struct
314 {
315 int size;
316 const char* outputHexStr;
317
318 } MV_CESA_SIZE_TEST;
319
320 static unsigned char cryptoKey1[] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
321 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
322 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef};
323
324 static unsigned char cryptoKey7[] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef};
325 static unsigned char iv1[] = {0x12, 0x34, 0x56, 0x78, 0x90, 0xab, 0xcd, 0xef};
326
327
328 static unsigned char cryptoKey2[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
329 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F};
330
331 static unsigned char cryptoKey3[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
332 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
333 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17};
334
335 static unsigned char cryptoKey4[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
336 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
337 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
338 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f};
339
340 static unsigned char cryptoKey5[] = {0x56, 0xe4, 0x7a, 0x38, 0xc5, 0x59, 0x89, 0x74,
341 0xbc, 0x46, 0x90, 0x3d, 0xba, 0x29, 0x03, 0x49};
342
343
344 static unsigned char key3des1[] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF,
345 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF, 0x01,
346 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF, 0x01, 0x23};
347
348 /* Input ASCII string: The quick brown fox jump */
349 static char plain3des1[] = "54686520717566636B2062726F776E20666F78206A756D70";
350 static char cipher3des1[] = "A826FD8CE53B855FCCE21C8112256FE668D5C05DD9B6B900";
351
352 static unsigned char key3des2[] = {0x62, 0x7f, 0x46, 0x0e, 0x08, 0x10, 0x4a, 0x10,
353 0x43, 0xcd, 0x26, 0x5d, 0x58, 0x40, 0xea, 0xf1,
354 0x31, 0x3e, 0xdf, 0x97, 0xdf, 0x2a, 0x8a, 0x8c};
355
356 static unsigned char iv3des2[] = {0x8e, 0x29, 0xf7, 0x5e, 0xa7, 0x7e, 0x54, 0x75};
357
358 static char plain3des2[] = "326a494cd33fe756";
359
360 static char cipher3desCbc2[] = "8e29f75ea77e5475"
361 "b22b8d66de970692";
362
363 static unsigned char key3des3[] = {0x37, 0xae, 0x5e, 0xbf, 0x46, 0xdf, 0xf2, 0xdc,
364 0x07, 0x54, 0xb9, 0x4f, 0x31, 0xcb, 0xb3, 0x85,
365 0x5e, 0x7f, 0xd3, 0x6d, 0xc8, 0x70, 0xbf, 0xae};
366
367 static unsigned char iv3des3[] = {0x3d, 0x1d, 0xe3, 0xcc, 0x13, 0x2e, 0x3b, 0x65};
368
369 static char plain3des3[] = "84401f78fe6c10876d8ea23094ea5309";
370
371 static char cipher3desCbc3[] = "3d1de3cc132e3b65"
372 "7b1f7c7e3b1c948ebd04a75ffba7d2f5";
373
374 static unsigned char iv5[] = {0x8c, 0xe8, 0x2e, 0xef, 0xbe, 0xa0, 0xda, 0x3c,
375 0x44, 0x69, 0x9e, 0xd7, 0xdb, 0x51, 0xb7, 0xd9};
376
377 static unsigned char aesCtrKey[] = {0x76, 0x91, 0xBE, 0x03, 0x5E, 0x50, 0x20, 0xA8,
378 0xAC, 0x6E, 0x61, 0x85, 0x29, 0xF9, 0xA0, 0xDC};
379
380 static unsigned char mdKey1[] = {0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
381 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b};
382
383 static unsigned char mdKey2[] = {0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
384 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa};
385
386 static unsigned char shaKey1[] = {0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
387 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
388 0x0b, 0x0b, 0x0b, 0x0b};
389
390 static unsigned char shaKey2[] = {0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
391 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
392 0xaa, 0xaa, 0xaa, 0xaa};
393
394 static unsigned char mdKey4[] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
395 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10};
396
397 static unsigned char shaKey4[] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
398 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
399 0x11, 0x12, 0x13, 0x14};
400
401
402 static MV_CESA_TEST_SESSION desTestSessions[] =
403 {
404 /*000*/ {-1, MV_CESA_CRYPTO_DES, MV_CESA_CRYPTO_ECB,
405 MV_CESA_MAC_NULL, MV_CESA_CRYPTO_ONLY,
406 MV_CESA_DIR_ENCODE,
407 cryptoKey7, sizeof(cryptoKey7)/sizeof(cryptoKey7[0]),
408 NULL, 0,
409 "DES ECB encode",
410 },
411 /*001*/ {-1, MV_CESA_CRYPTO_DES, MV_CESA_CRYPTO_ECB,
412 MV_CESA_MAC_NULL, MV_CESA_CRYPTO_ONLY,
413 MV_CESA_DIR_DECODE,
414 cryptoKey7, sizeof(cryptoKey7)/sizeof(cryptoKey7[0]),
415 NULL, 0,
416 "DES ECB decode",
417 },
418 /*002*/ {-1, MV_CESA_CRYPTO_DES, MV_CESA_CRYPTO_CBC,
419 MV_CESA_MAC_NULL, MV_CESA_CRYPTO_ONLY,
420 MV_CESA_DIR_ENCODE,
421 cryptoKey7, sizeof(cryptoKey7)/sizeof(cryptoKey7[0]),
422 NULL, 0,
423 "DES CBC encode"
424 },
425 /*003*/ {-1, MV_CESA_CRYPTO_DES, MV_CESA_CRYPTO_CBC,
426 MV_CESA_MAC_NULL, MV_CESA_CRYPTO_ONLY,
427 MV_CESA_DIR_DECODE,
428 cryptoKey7, sizeof(cryptoKey7)/sizeof(cryptoKey7[0]),
429 NULL, 0,
430 "DES CBC decode"
431 },
432 /*004*/ {-1, MV_CESA_CRYPTO_NULL, MV_CESA_CRYPTO_ECB,
433 MV_CESA_MAC_NULL, MV_CESA_CRYPTO_ONLY,
434 MV_CESA_DIR_ENCODE,
435 NULL, 0, NULL, 0,
436 "NULL Crypto Algorithm encode"
437 },
438 };
439
440
441 static MV_CESA_TEST_SESSION tripleDesTestSessions[] =
442 {
443 /*100*/ {-1, MV_CESA_CRYPTO_3DES, MV_CESA_CRYPTO_ECB,
444 MV_CESA_MAC_NULL, MV_CESA_CRYPTO_ONLY,
445 MV_CESA_DIR_ENCODE,
446 cryptoKey1, sizeof(cryptoKey1)/sizeof(cryptoKey1[0]),
447 NULL, 0,
448 "3DES ECB encode",
449 },
450 /*101*/ {-1, MV_CESA_CRYPTO_3DES, MV_CESA_CRYPTO_ECB,
451 MV_CESA_MAC_NULL, MV_CESA_CRYPTO_ONLY,
452 MV_CESA_DIR_DECODE,
453 cryptoKey1, sizeof(cryptoKey1)/sizeof(cryptoKey1[0]),
454 NULL, 0,
455 "3DES ECB decode",
456 },
457 /*102*/ {-1, MV_CESA_CRYPTO_3DES, MV_CESA_CRYPTO_CBC,
458 MV_CESA_MAC_NULL, MV_CESA_CRYPTO_ONLY,
459 MV_CESA_DIR_ENCODE,
460 cryptoKey1, sizeof(cryptoKey1)/sizeof(cryptoKey1[0]),
461 NULL, 0,
462 "3DES CBC encode"
463 },
464 /*103*/ {-1, MV_CESA_CRYPTO_3DES, MV_CESA_CRYPTO_CBC,
465 MV_CESA_MAC_NULL, MV_CESA_CRYPTO_ONLY,
466 MV_CESA_DIR_DECODE,
467 cryptoKey1, sizeof(cryptoKey1)/sizeof(cryptoKey1[0]),
468 NULL, 0,
469 "3DES CBC decode"
470 },
471 /*104*/ {-1, MV_CESA_CRYPTO_3DES, MV_CESA_CRYPTO_ECB,
472 MV_CESA_MAC_NULL, MV_CESA_CRYPTO_ONLY,
473 MV_CESA_DIR_ENCODE,
474 key3des1, sizeof(key3des1),
475 NULL, 0,
476 "3DES ECB encode"
477 },
478 /*105*/ {-1, MV_CESA_CRYPTO_3DES, MV_CESA_CRYPTO_CBC,
479 MV_CESA_MAC_NULL, MV_CESA_CRYPTO_ONLY,
480 MV_CESA_DIR_ENCODE,
481 key3des2, sizeof(key3des2),
482 NULL, 0,
483 "3DES ECB encode"
484 },
485 /*106*/ {-1, MV_CESA_CRYPTO_3DES, MV_CESA_CRYPTO_CBC,
486 MV_CESA_MAC_NULL, MV_CESA_CRYPTO_ONLY,
487 MV_CESA_DIR_ENCODE,
488 key3des3, sizeof(key3des3),
489 NULL, 0,
490 "3DES ECB encode"
491 },
492 };
493
494
495 static MV_CESA_TEST_SESSION aesTestSessions[] =
496 {
497 /*200*/ {-1, MV_CESA_CRYPTO_AES, MV_CESA_CRYPTO_ECB,
498 MV_CESA_MAC_NULL, MV_CESA_CRYPTO_ONLY,
499 MV_CESA_DIR_ENCODE,
500 cryptoKey2, sizeof(cryptoKey2)/sizeof(cryptoKey2[0]),
501 NULL, 0,
502 "AES-128 ECB encode"
503 },
504 /*201*/ {-1, MV_CESA_CRYPTO_AES, MV_CESA_CRYPTO_ECB,
505 MV_CESA_MAC_NULL, MV_CESA_CRYPTO_ONLY,
506 MV_CESA_DIR_DECODE,
507 cryptoKey2, sizeof(cryptoKey2)/sizeof(cryptoKey2[0]),
508 NULL, 0,
509 "AES-128 ECB decode"
510 },
511 /*202*/ {-1, MV_CESA_CRYPTO_AES, MV_CESA_CRYPTO_CBC,
512 MV_CESA_MAC_NULL, MV_CESA_CRYPTO_ONLY,
513 MV_CESA_DIR_ENCODE,
514 cryptoKey5, sizeof(cryptoKey5)/sizeof(cryptoKey5[0]),
515 NULL, 0,
516 "AES-128 CBC encode"
517 },
518 /*203*/ {-1, MV_CESA_CRYPTO_AES, MV_CESA_CRYPTO_CBC,
519 MV_CESA_MAC_NULL, MV_CESA_CRYPTO_ONLY,
520 MV_CESA_DIR_DECODE,
521 cryptoKey5, sizeof(cryptoKey5)/sizeof(cryptoKey5[0]),
522 NULL, 0,
523 "AES-128 CBC decode"
524 },
525 /*204*/ {-1, MV_CESA_CRYPTO_AES, MV_CESA_CRYPTO_ECB,
526 MV_CESA_MAC_NULL, MV_CESA_CRYPTO_ONLY,
527 MV_CESA_DIR_ENCODE,
528 cryptoKey3, sizeof(cryptoKey3)/sizeof(cryptoKey3[0]),
529 NULL, 0,
530 "AES-192 ECB encode"
531 },
532 /*205*/ {-1, MV_CESA_CRYPTO_AES, MV_CESA_CRYPTO_ECB,
533 MV_CESA_MAC_NULL, MV_CESA_CRYPTO_ONLY,
534 MV_CESA_DIR_DECODE,
535 cryptoKey3, sizeof(cryptoKey3)/sizeof(cryptoKey3[0]),
536 NULL, 0,
537 "AES-192 ECB decode"
538 },
539 /*206*/ {-1, MV_CESA_CRYPTO_AES, MV_CESA_CRYPTO_ECB,
540 MV_CESA_MAC_NULL, MV_CESA_CRYPTO_ONLY,
541 MV_CESA_DIR_ENCODE,
542 cryptoKey4, sizeof(cryptoKey4)/sizeof(cryptoKey4[0]),
543 NULL, 0,
544 "AES-256 ECB encode"
545 },
546 /*207*/ {-1, MV_CESA_CRYPTO_AES, MV_CESA_CRYPTO_ECB,
547 MV_CESA_MAC_NULL, MV_CESA_CRYPTO_ONLY,
548 MV_CESA_DIR_DECODE,
549 cryptoKey4, sizeof(cryptoKey4)/sizeof(cryptoKey4[0]),
550 NULL, 0,
551 "AES-256 ECB decode"
552 },
553 /*208*/ {-1, MV_CESA_CRYPTO_AES, MV_CESA_CRYPTO_CTR,
554 MV_CESA_MAC_NULL, MV_CESA_CRYPTO_ONLY,
555 MV_CESA_DIR_ENCODE,
556 aesCtrKey, sizeof(aesCtrKey)/sizeof(aesCtrKey[0]),
557 NULL, 0,
558 "AES-128 CTR encode"
559 },
560 };
561
562
563 static MV_CESA_TEST_SESSION md5TestSessions[] =
564 {
565 /*300*/ {-1, MV_CESA_CRYPTO_NULL, MV_CESA_CRYPTO_ECB,
566 MV_CESA_MAC_HMAC_MD5, MV_CESA_MAC_ONLY,
567 MV_CESA_DIR_ENCODE,
568 NULL, 0,
569 mdKey1, sizeof(mdKey1),
570 "HMAC-MD5 Generate Signature"
571 },
572 /*301*/ {-1, MV_CESA_CRYPTO_NULL, MV_CESA_CRYPTO_ECB,
573 MV_CESA_MAC_HMAC_MD5, MV_CESA_MAC_ONLY,
574 MV_CESA_DIR_DECODE,
575 NULL, 0,
576 mdKey1, sizeof(mdKey1),
577 "HMAC-MD5 Verify Signature"
578 },
579 /*302*/ {-1, MV_CESA_CRYPTO_NULL, MV_CESA_CRYPTO_ECB,
580 MV_CESA_MAC_HMAC_MD5, MV_CESA_MAC_ONLY,
581 MV_CESA_DIR_ENCODE,
582 NULL, 0,
583 mdKey2, sizeof(mdKey2),
584 "HMAC-MD5 Generate Signature"
585 },
586 /*303*/ {-1, MV_CESA_CRYPTO_NULL, MV_CESA_CRYPTO_ECB,
587 MV_CESA_MAC_HMAC_MD5, MV_CESA_MAC_ONLY,
588 MV_CESA_DIR_DECODE,
589 NULL, 0,
590 mdKey2, sizeof(mdKey2),
591 "HMAC-MD5 Verify Signature"
592 },
593 /*304*/ {-1, MV_CESA_CRYPTO_NULL, MV_CESA_CRYPTO_ECB,
594 MV_CESA_MAC_HMAC_MD5, MV_CESA_MAC_ONLY,
595 MV_CESA_DIR_ENCODE,
596 NULL, 0,
597 mdKey4, sizeof(mdKey4),
598 "HMAC-MD5 Generate Signature"
599 },
600 /*305*/ {-1, MV_CESA_CRYPTO_NULL, MV_CESA_CRYPTO_ECB,
601 MV_CESA_MAC_MD5, MV_CESA_MAC_ONLY,
602 MV_CESA_DIR_ENCODE,
603 NULL, 0,
604 NULL, 0,
605 "HASH-MD5 Generate Signature"
606 },
607 };
608
609
610 static MV_CESA_TEST_SESSION shaTestSessions[] =
611 {
612 /*400*/ {-1, MV_CESA_CRYPTO_NULL, MV_CESA_CRYPTO_ECB,
613 MV_CESA_MAC_HMAC_SHA1, MV_CESA_MAC_ONLY,
614 MV_CESA_DIR_ENCODE,
615 NULL, 0,
616 shaKey1, sizeof(shaKey1),
617 "HMAC-SHA1 Generate Signature"
618 },
619 /*401*/ {-1, MV_CESA_CRYPTO_NULL, MV_CESA_CRYPTO_ECB,
620 MV_CESA_MAC_HMAC_SHA1, MV_CESA_MAC_ONLY,
621 MV_CESA_DIR_DECODE,
622 NULL, 0,
623 shaKey1, sizeof(shaKey1),
624 "HMAC-SHA1 Verify Signature"
625 },
626 /*402*/ {-1, MV_CESA_CRYPTO_NULL, MV_CESA_CRYPTO_ECB,
627 MV_CESA_MAC_HMAC_SHA1, MV_CESA_MAC_ONLY,
628 MV_CESA_DIR_ENCODE,
629 NULL, 0,
630 shaKey2, sizeof(shaKey2),
631 "HMAC-SHA1 Generate Signature"
632 },
633 /*403*/ {-1, MV_CESA_CRYPTO_NULL, MV_CESA_CRYPTO_ECB,
634 MV_CESA_MAC_HMAC_SHA1, MV_CESA_MAC_ONLY,
635 MV_CESA_DIR_DECODE,
636 NULL, 0,
637 shaKey2, sizeof(shaKey2),
638 "HMAC-SHA1 Verify Signature"
639 },
640 /*404*/ {-1, MV_CESA_CRYPTO_NULL, MV_CESA_CRYPTO_ECB,
641 MV_CESA_MAC_HMAC_SHA1, MV_CESA_MAC_ONLY,
642 MV_CESA_DIR_ENCODE,
643 NULL, 0,
644 shaKey4, sizeof(shaKey4),
645 "HMAC-SHA1 Generate Signature"
646 },
647 /*405*/ {-1, MV_CESA_CRYPTO_NULL, MV_CESA_CRYPTO_ECB,
648 MV_CESA_MAC_SHA1, MV_CESA_MAC_ONLY,
649 MV_CESA_DIR_ENCODE,
650 NULL, 0,
651 NULL, 0,
652 "HASH-SHA1 Generate Signature"
653 },
654 };
655
656 static MV_CESA_TEST_SESSION combinedTestSessions[] =
657 {
658 /*500*/ {-1, MV_CESA_CRYPTO_DES, MV_CESA_CRYPTO_ECB,
659 MV_CESA_MAC_HMAC_MD5, MV_CESA_CRYPTO_THEN_MAC,
660 MV_CESA_DIR_ENCODE,
661 cryptoKey1, MV_CESA_DES_KEY_LENGTH,
662 mdKey4, sizeof(mdKey4),
663 "DES + MD5 encode"
664 },
665 /*501*/ {-1, MV_CESA_CRYPTO_DES, MV_CESA_CRYPTO_ECB,
666 MV_CESA_MAC_HMAC_SHA1, MV_CESA_CRYPTO_THEN_MAC,
667 MV_CESA_DIR_ENCODE,
668 cryptoKey1, MV_CESA_DES_KEY_LENGTH,
669 shaKey4, sizeof(shaKey4),
670 "DES + SHA1 encode"
671 },
672 /*502*/ {-1, MV_CESA_CRYPTO_3DES, MV_CESA_CRYPTO_ECB,
673 MV_CESA_MAC_HMAC_MD5, MV_CESA_CRYPTO_THEN_MAC,
674 MV_CESA_DIR_ENCODE,
675 cryptoKey1, sizeof(cryptoKey1)/sizeof(cryptoKey1[0]),
676 mdKey4, sizeof(mdKey4),
677 "3DES + MD5 encode"
678 },
679 /*503*/ {-1, MV_CESA_CRYPTO_3DES, MV_CESA_CRYPTO_ECB,
680 MV_CESA_MAC_HMAC_SHA1, MV_CESA_CRYPTO_THEN_MAC,
681 MV_CESA_DIR_ENCODE,
682 cryptoKey1, sizeof(cryptoKey1)/sizeof(cryptoKey1[0]),
683 shaKey4, sizeof(shaKey4),
684 "3DES + SHA1 encode"
685 },
686 /*504*/ {-1, MV_CESA_CRYPTO_3DES, MV_CESA_CRYPTO_CBC,
687 MV_CESA_MAC_HMAC_MD5, MV_CESA_CRYPTO_THEN_MAC,
688 MV_CESA_DIR_ENCODE,
689 cryptoKey1, sizeof(cryptoKey1)/sizeof(cryptoKey1[0]),
690 mdKey4, sizeof(mdKey4),
691 "3DES CBC + MD5 encode"
692 },
693 /*505*/ {-1, MV_CESA_CRYPTO_3DES, MV_CESA_CRYPTO_CBC,
694 MV_CESA_MAC_HMAC_SHA1, MV_CESA_CRYPTO_THEN_MAC,
695 MV_CESA_DIR_ENCODE,
696 cryptoKey1, sizeof(cryptoKey1)/sizeof(cryptoKey1[0]),
697 shaKey4, sizeof(shaKey4),
698 "3DES CBC + SHA1 encode"
699 },
700 /*506*/ {-1, MV_CESA_CRYPTO_AES, MV_CESA_CRYPTO_CBC,
701 MV_CESA_MAC_HMAC_MD5, MV_CESA_CRYPTO_THEN_MAC,
702 MV_CESA_DIR_ENCODE,
703 cryptoKey5, sizeof(cryptoKey5)/sizeof(cryptoKey5[0]),
704 mdKey4, sizeof(mdKey4),
705 "AES-128 CBC + MD5 encode"
706 },
707 /*507*/ {-1, MV_CESA_CRYPTO_AES, MV_CESA_CRYPTO_CBC,
708 MV_CESA_MAC_HMAC_SHA1, MV_CESA_CRYPTO_THEN_MAC,
709 MV_CESA_DIR_ENCODE,
710 cryptoKey5, sizeof(cryptoKey5)/sizeof(cryptoKey5[0]),
711 shaKey4, sizeof(shaKey4),
712 "AES-128 CBC + SHA1 encode"
713 },
714 /*508*/ {-1, MV_CESA_CRYPTO_3DES, MV_CESA_CRYPTO_ECB,
715 MV_CESA_MAC_HMAC_MD5, MV_CESA_MAC_THEN_CRYPTO,
716 MV_CESA_DIR_DECODE,
717 cryptoKey1, sizeof(cryptoKey1)/sizeof(cryptoKey1[0]),
718 mdKey4, sizeof(mdKey4),
719 "HMAC-MD5 + 3DES decode"
720 },
721 };
722
723
724 static MV_CESA_TEST_DB_ENTRY cesaTestsDB[MAX_TEST_TYPE+1] =
725 {
726 { desTestSessions, sizeof(desTestSessions)/sizeof(desTestSessions[0]) },
727 { tripleDesTestSessions, sizeof(tripleDesTestSessions)/sizeof(tripleDesTestSessions[0]) },
728 { aesTestSessions, sizeof(aesTestSessions)/sizeof(aesTestSessions[0]) },
729 { md5TestSessions, sizeof(md5TestSessions)/sizeof(md5TestSessions[0]) },
730 { shaTestSessions, sizeof(shaTestSessions)/sizeof(shaTestSessions[0]) },
731 { combinedTestSessions, sizeof(combinedTestSessions)/sizeof(combinedTestSessions[0]) },
732 { NULL, 0 }
733 };
734
735
736 char cesaNullPlainHexText[] = "000000000000000000000000000000000000000000000000";
737
738 char cesaPlainAsciiText[] = "Now is the time for all ";
739 char cesaPlainHexEbc[] = "4e6f77206973207468652074696d6520666f7220616c6c20";
740 char cesaCipherHexEcb[] = "3fa40e8a984d48156a271787ab8883f9893d51ec4b563b53";
741 char cesaPlainHexCbc[] = "1234567890abcdef4e6f77206973207468652074696d6520666f7220616c6c20";
742 char cesaCipherHexCbc[] = "1234567890abcdefe5c7cdde872bf27c43e934008c389c0f683788499a7c05f6";
743
744 char cesaAesPlainHexEcb[] = "000102030405060708090a0b0c0d0e0f";
745 char cesaAes128cipherHexEcb[] = "0a940bb5416ef045f1c39458c653ea5a";
746 char cesaAes192cipherHexEcb[] = "0060bffe46834bb8da5cf9a61ff220ae";
747 char cesaAes256cipherHexEcb[] = "5a6e045708fb7196f02e553d02c3a692";
748
749 char cesaAsciiStr1[] = "Hi There";
750 char cesaDataHexStr1[] = "4869205468657265";
751 char cesaHmacMd5digestHex1[] = "9294727a3638bb1c13f48ef8158bfc9d";
752 char cesaHmacSha1digestHex1[] = "b617318655057264e28bc0b6fb378c8ef146be00";
753 char cesaDataAndMd5digest1[] = "48692054686572659294727a3638bb1c13f48ef8158bfc9d";
754 char cesaDataAndSha1digest1[] = "4869205468657265b617318655057264e28bc0b6fb378c8ef146be00";
755
756 char cesaAesPlainText[] = "a0a1a2a3a4a5a6a7a8a9aaabacadaeaf"
757 "b0b1b2b3b4b5b6b7b8b9babbbcbdbebf"
758 "c0c1c2c3c4c5c6c7c8c9cacbcccdcecf"
759 "d0d1d2d3d4d5d6d7d8d9dadbdcdddedf";
760
761 char cesaAes128CipherCbc[] = "c30e32ffedc0774e6aff6af0869f71aa"
762 "0f3af07a9a31a9c684db207eb0ef8e4e"
763 "35907aa632c3ffdf868bb7b29d3d46ad"
764 "83ce9f9a102ee99d49a53e87f4c3da55";
765
766 char cesaAesIvPlainText[] = "8ce82eefbea0da3c44699ed7db51b7d9"
767 "a0a1a2a3a4a5a6a7a8a9aaabacadaeaf"
768 "b0b1b2b3b4b5b6b7b8b9babbbcbdbebf"
769 "c0c1c2c3c4c5c6c7c8c9cacbcccdcecf"
770 "d0d1d2d3d4d5d6d7d8d9dadbdcdddedf";
771
772 char cesaAes128IvCipherCbc[] = "8ce82eefbea0da3c44699ed7db51b7d9"
773 "c30e32ffedc0774e6aff6af0869f71aa"
774 "0f3af07a9a31a9c684db207eb0ef8e4e"
775 "35907aa632c3ffdf868bb7b29d3d46ad"
776 "83ce9f9a102ee99d49a53e87f4c3da55";
777
778 char cesaAesCtrPlain[] = "00E0017B27777F3F4A1786F000000001"
779 "000102030405060708090A0B0C0D0E0F"
780 "101112131415161718191A1B1C1D1E1F"
781 "20212223";
782
783 char cesaAesCtrCipher[] = "00E0017B27777F3F4A1786F000000001"
784 "C1CF48A89F2FFDD9CF4652E9EFDB72D7"
785 "4540A42BDE6D7836D59A5CEAAEF31053"
786 "25B2072F";
787
788
789
790 /* Input cesaHmacHex3 is '0xdd' repeated 50 times */
791 char cesaHmacMd5digestHex3[] = "56be34521d144c88dbb8c733f0e8b3f6";
792 char cesaHmacSha1digestHex3[] = "125d7342b9ac11cd91a39af48aa17b4f63f175d3";
793 char cesaDataHexStr3[50*2+1] = "";
794 char cesaDataAndMd5digest3[sizeof(cesaDataHexStr3)+sizeof(cesaHmacMd5digestHex3)+8*2+1] = "";
795 char cesaDataAndSha1digest3[sizeof(cesaDataHexStr3)+sizeof(cesaHmacSha1digestHex3)+8*2+1] = "";
796
797 /* Ascii string is "abc" */
798 char hashHexStr3[] = "616263";
799 char hashMd5digest3[] = "900150983cd24fb0d6963f7d28e17f72";
800 char hashSha1digest3[] = "a9993e364706816aba3e25717850c26c9cd0d89d";
801
802 char hashHexStr80[] = "31323334353637383930"
803 "31323334353637383930"
804 "31323334353637383930"
805 "31323334353637383930"
806 "31323334353637383930"
807 "31323334353637383930"
808 "31323334353637383930"
809 "31323334353637383930";
810
811 char hashMd5digest80[] = "57edf4a22be3c955ac49da2e2107b67a";
812
813 char tripleDesThenMd5digest80[] = "b7726a03aad490bd6c5a452a89a1b271";
814 char tripleDesThenSha1digest80[] = "b2ddeaca91030eab5b95a234ef2c0f6e738ff883";
815
816 char cbc3desThenMd5digest80[] = "6f463057e1a90e0e91ae505b527bcec0";
817 char cbc3desThenSha1digest80[] = "1b002ed050be743aa98860cf35659646bb8efcc0";
818
819 char cbcAes128ThenMd5digest80[] = "6b6e863ac5a71d15e3e9b1c86c9ba05f";
820 char cbcAes128ThenSha1digest80[] = "13558472d1fc1c90dffec6e5136c7203452d509b";
821
822
823 static MV_CESA_TEST_CASE cesaTestCases[] =
824 {
825 /* plainHexStr cipherHexStr IV crypto mac digest */
826 /* Length Length Offset */
827 /*0*/ { NULL, NULL, NULL, 0, 0, -1 },
828 /*1*/ { cesaPlainHexEbc, cesaCipherHexEcb, NULL, 24, 0, -1 },
829 /*2*/ { cesaPlainHexCbc, cesaCipherHexCbc, NULL, 24, 0, -1 },
830 /*3*/ { cesaAesPlainHexEcb, cesaAes128cipherHexEcb, NULL, 16, 0, -1 },
831 /*4*/ { cesaAesPlainHexEcb, cesaAes192cipherHexEcb, NULL, 16, 0, -1 },
832 /*5*/ { cesaAesPlainHexEcb, cesaAes256cipherHexEcb, NULL, 16, 0, -1 },
833 /*6*/ { cesaDataHexStr1, cesaHmacMd5digestHex1, NULL, 0, 8, -1 },
834 /*7*/ { NULL, cesaDataAndMd5digest1, NULL, 0, 8, -1 },
835 /*8*/ { cesaDataHexStr3, cesaHmacMd5digestHex3, NULL, 0, 50, -1 },
836 /*9*/ { NULL, cesaDataAndMd5digest3, NULL, 0, 50, -1 },
837 /*10*/ { cesaAesPlainText, cesaAes128IvCipherCbc, iv5, 64, 0, -1 },
838 /*11*/ { cesaDataHexStr1, cesaHmacSha1digestHex1, NULL, 0, 8, -1 },
839 /*12*/ { NULL, cesaDataAndSha1digest1, NULL, 0, 8, -1 },
840 /*13*/ { cesaDataHexStr3, cesaHmacSha1digestHex3, NULL, 0, 50, -1 },
841 /*14*/ { NULL, cesaDataAndSha1digest3, NULL, 0, 50, -1 },
842 /*15*/ { hashHexStr3, hashMd5digest3, NULL, 0, 3, -1 },
843 /*16*/ { hashHexStr3, hashSha1digest3, NULL, 0, 3, -1 },
844 /*17*/ { hashHexStr80, tripleDesThenMd5digest80, NULL, 80, 80, -1 },
845 /*18*/ { hashHexStr80, tripleDesThenSha1digest80, NULL, 80, 80, -1 },
846 /*19*/ { hashHexStr80, cbc3desThenMd5digest80, iv1, 80, 80, -1 },
847 /*20*/ { hashHexStr80, cbc3desThenSha1digest80, iv1, 80, 80, -1 },
848 /*21*/ { hashHexStr80, cbcAes128ThenMd5digest80, iv5, 80, 80, -1 },
849 /*22*/ { hashHexStr80, cbcAes128ThenSha1digest80, iv5, 80, 80, -1 },
850 /*23*/ { cesaAesCtrPlain, cesaAesCtrCipher, NULL, 36, 0, -1 },
851 /*24*/ { cesaAesIvPlainText, cesaAes128IvCipherCbc, NULL, 64, 0, -1 },
852 /*25*/ { plain3des1, cipher3des1, NULL, 0, 0, -1 },
853 /*26*/ { plain3des2, cipher3desCbc2, iv3des2,0, 0, -1 },
854 /*27*/ { plain3des3, cipher3desCbc3, iv3des3,0, 0, -1 },
855 };
856
857
858 /* Key = 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
859 * 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa
860 * Input 0xdd repeated "size" times
861 */
862 static MV_CESA_SIZE_TEST mdMultiSizeTest302[] =
863 {
864 { 80, "7a031a640c14a4872814930b1ef3a5b2" },
865 { 512, "5488e6c5a14dc72a79f28312ca5b939b" },
866 { 1000, "d00814f586a8b78a05724239d2531821" },
867 { 1001, "bf07df7b7f49d3f5b5ecacd4e9e63281" },
868 { 1002, "1ed4a1a802e87817a819d4e37bb4d0f7" },
869 { 1003, "5972ab64a4f265ee371dac2f2f137f90" },
870 { 1004, "71f95e7ec3aa7df2548e90898abdb28e" },
871 { 1005, "e082790b4857fcfc266e92e59e608814" },
872 { 1006, "9500f02fd8ac7fde8b10e4fece9a920d" },
873 { 1336, "e42edcce57d0b75b01aa09d71427948b" },
874 { 1344, "bb5454ada0deb49ba0a97ffd60f57071" },
875 { 1399, "0f44d793e744b24d53f44f295082ee8c" },
876 { 1400, "359de8a03a9b707928c6c60e0e8d79f1" },
877 { 1401, "e913858b484cbe2b384099ea88d8855b" },
878 { 1402, "d9848a164af53620e0540c1d7d87629e" },
879 { 1403, "0c9ee1c2c9ef45e9b625c26cbaf3e822" },
880 { 1404, "12edd4f609416e3c936170360561b064" },
881 { 1405, "7fc912718a05446395345009132bf562" },
882 { 1406, "882f17425e579ff0d85a91a59f308aa0" },
883 { 1407, "005cae408630a2fb5db82ad9db7e59da" },
884 { 1408, "64655f8b404b3fea7a3e3e609bc5088f" },
885 { 1409, "4a145284a7f74e01b6bb1a0ec6a0dd80" },
886 { 2048, "67caf64475650732def374ebb8bde3fd" },
887 { 2049, "6c84f11f472825f7e6cd125c2981884b" },
888 { 2050, "8999586754a73a99efbe4dbad2816d41" },
889 { 2051, "ba6946b610e098d286bc81091659dfff" },
890 { 2052, "d0afa01c92d4d13def2b024f36faed83" },
891 { 3072, "61d8beac61806afa2585d74a9a0e6974" },
892 { 3074, "f6501a28dcc24d1e4770505c51a87ed3" },
893 { 3075, "ea4a6929be67e33e61ff475369248b73" },
894 { 4048, "aa8c4d68f282a07e7385acdfa69f4bed" },
895 { 4052, "afb5ed2c0e1d430ea59e59ed5ed6b18a" },
896 { 4058, "9e8553f9bdd43aebe0bd729f0e600c99" },
897 { 6144, "f628f3e5d183fe5cdd3a5abee39cf872" },
898 { 6150, "89a3efcea9a2f25f919168ad4a1fd292" },
899 { 6400, "cdd176b7fb747873efa4da5e32bdf88f" },
900 { 6528, "b1d707b027354aca152c45ee559ccd3f" },
901 { 8192, "c600ea4429ac47f9941f09182166e51a" },
902 {16384, "16e8754bfbeb4c649218422792267a37" },
903 {18432, "0fd0607521b0aa8b52219cfbe215f63e" },
904 { 0, NULL },
905 };
906
907 /* Key = 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
908 * 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10
909 * InputHexStr = "31323334353637383930" (ASCII = "1234567890")
910 */
911 static MV_CESA_SIZE_TEST mdMultiSizeTest304[] =
912 {
913 { 80, "a456c4723fee6068530af5a2afa71627" },
914 { 512, "f85c2a2344f5de68b432208ad13e5794" },
915 { 1000, "35464d6821fd4a293a41eb84e274c8c5" },
916 { 1001, "c08eedbdce60cceb54bc2d732bb32c8b" },
917 { 1002, "5664f71800c011cc311cb6943339c1b8" },
918 { 1003, "779c723b044c585dc7802b13e8501bdc" },
919 { 1004, "55e500766a2c307bc5c5fdd15e4cacd4" },
920 { 1005, "d5f978954f5c38529d1679d2b714f068" },
921 { 1006, "cd3efc827ce628b7281b72172693abf9" },
922 { 1336, "6f04479910785878ae6335b8d1e87edf" },
923 { 1344, "b6d27b50c2bce1ba2a8e1b5cc4324368" },
924 { 1399, "65f70a1d4c86e5eaeb0704c8a7816795" },
925 { 1400, "3394b5adc4cb3ff98843ca260a44a88a" },
926 { 1401, "3a06f3582033a66a4e57e0603ce94e74" },
927 { 1402, "e4d97f5ed51edc48abfa46eeb5c31752" },
928 { 1403, "3d05e40b080ee3bedf293cb87b7140e7" },
929 { 1404, "8cf294fc3cd153ab18dccb2a52cbf244" },
930 { 1405, "d1487bd42f6edd9b4dab316631159221" },
931 { 1406, "0527123b6bf6936cf5d369dc18c6c70f" },
932 { 1407, "3224a06639db70212a0cd1ae1fcc570a" },
933 { 1408, "a9e13335612c0356f5e2c27086e86c43" },
934 { 1409, "a86d1f37d1ed8a3552e9a4f04dceea98" },
935 { 2048, "396905c9b961cd0f6152abfb69c4449c" },
936 { 2049, "49f39bff85d9dcf059fadb89efc4a70f" },
937 { 2050, "3a2b4823bc4d0415656550226a63e34a" },
938 { 2051, "dec60580d406c782540f398ad0bcc7e0" },
939 { 2052, "32f76610a14310309eb748fe025081bf" },
940 { 3072, "45edc1a42bf9d708a621076b63b774da" },
941 { 3074, "9be1b333fe7c0c9f835fb369dc45f778" },
942 { 3075, "8c06fcac7bd0e7b7a17fd6508c09a549" },
943 { 4048, "0ddaef848184bf0ad98507a10f1e90e4" },
944 { 4052, "81976bcaeb274223983996c137875cb8" },
945 { 4058, "0b0a7a1c82bc7cbc64d8b7cd2dc2bb22" },
946 { 6144, "1c24056f52725ede2dff0d7f9fc9855f" },
947 { 6150, "b7f4b65681c4e43ee68ca466ca9ca4ec" },
948 { 6400, "443bbaab9f7331ddd4bf11b659cd43c8" },
949 { 6528, "216f44f23047cfee03a7a64f88f9a995" },
950 { 8192, "ac7a993b2cad54879dba1bde63e39097" },
951 { 8320, "55ed7be9682d6c0025b3221a62088d08" },
952 {16384, "c6c722087653b62007aea668277175e5" },
953 {18432, "f1faca8e907872c809e14ffbd85792d6" },
954 { 0, NULL },
955 };
956
957 /* HASH-MD5
958 * InputHexStr = "31323334353637383930" (ASCII = "1234567890")
959 * repeated "size" times
960 */
961 static MV_CESA_SIZE_TEST mdMultiSizeTest305[] =
962 {
963 { 80, "57edf4a22be3c955ac49da2e2107b67a" },
964 { 512, "c729ae8f0736cc377a9767a660eaa04e" },
965 { 1000, "f1257a8659eb92d36fe14c6bf3852a6a" },
966 { 1001, "f8a46fe8ea04fdc8c7de0e84042d3878" },
967 { 1002, "da188dd67bff87d58aa3c02af2d0cc0f" },
968 { 1003, "961753017feee04c9b93a8e51658a829" },
969 { 1004, "dd68c4338608dcc87807a711636bf2af" },
970 { 1005, "e338d567d3ce66bf69ada29658a8759b" },
971 { 1006, "443c9811e8b92599b0b149e8d7ec700a" },
972 { 1336, "89a98511706008ba4cbd0b4a24fa5646" },
973 { 1344, "335a919805f370b9e402a62c6fe01739" },
974 { 1399, "5d18d0eddcd84212fe28d812b5e80e3b" },
975 { 1400, "6b695c240d2dffd0dffc99459ca76db6" },
976 { 1401, "49590f61298a76719bc93a57a30136f5" },
977 { 1402, "94c2999fa3ef1910a683d69b2b8476f2" },
978 { 1403, "37073a02ab00ecba2645c57c228860db" },
979 { 1404, "1bcd06994fce28b624f0c5fdc2dcdd2b" },
980 { 1405, "11b93671a64c95079e8cf9e7cddc8b3d" },
981 { 1406, "4b6695772a4c66313fa4871017d05f36" },
982 { 1407, "d1539b97fbfda1c075624e958de19c5b" },
983 { 1408, "b801b9b69920907cd018e8063092ede9" },
984 { 1409, "b765f1406cfe78e238273ed01bbcaf7e" },
985 { 2048, "1d7e2c64ac29e2b3fb4c272844ed31f5" },
986 { 2049, "71d38fac49c6b1f4478d8d88447bcdd0" },
987 { 2050, "141c34a5592b1bebfa731e0b23d0cdba" },
988 { 2051, "c5e1853f21c59f5d6039bd13d4b380d8" },
989 { 2052, "dd44a0d128b63d4b5cccd967906472d7" },
990 { 3072, "37d158e33b21390822739d13db7b87fe" },
991 { 3074, "aef3b209d01d39d0597fe03634bbf441" },
992 { 3075, "335ffb428eabf210bada96d74d5a4012" },
993 { 4048, "2434c2b43d798d2819487a886261fc64" },
994 { 4052, "ac2fa84a8a33065b2e92e36432e861f8" },
995 { 4058, "856781f85616c341c3533d090c1e1e84" },
996 { 6144, "e5d134c652c18bf19833e115f7a82e9b" },
997 { 6150, "a09a353be7795fac2401dac5601872e6" },
998 { 6400, "08b9033ac6a1821398f50af75a2dbc83" },
999 { 6528, "3d47aa193a8540c091e7e02f779e6751" },
1000 { 8192, "d3164e710c0626f6f395b38f20141cb7" },
1001 { 8320, "b727589d9183ff4e8491dd24466974a3" },
1002 {16384, "3f54d970793d2274d5b20d10a69938ac" },
1003 {18432, "f558511dcf81985b7a1bb57fad970531" },
1004 { 0, NULL },
1005 };
1006
1007
1008 /* Key = 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1009 * 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa
1010 * 0xaa, 0xaa, 0xaa, 0xaa
1011 * InputHexStr = "31323334353637383930" (ASCII = "1234567890")
1012 */
1013 static MV_CESA_SIZE_TEST shaMultiSizeTest402[] =
1014 {
1015 { 80, "e812f370e659705a1649940d1f78cd7af18affd3" },
1016 { 512, "e547f886b2c15d995ed76a8a924cb408c8080f66" },
1017 { 1000, "239443194409f1a5342ecde1a092c8f3a3ed790a" },
1018 { 1001, "f278ab9a102850a9f48dc4e9e6822afe2d0c52b5" },
1019 { 1002, "8bcc667df5ab6ece988b3af361d09747c77f4e72" },
1020 { 1003, "0fae6046c7dc1d3e356b25af836f6077a363f338" },
1021 { 1004, "0ea48401cc92ae6bc92ae76685269cb0167fbe1a" },
1022 { 1005, "ecbcd7c879b295bafcd8766cbeac58cc371e31d1" },
1023 { 1006, "eb4a4a3d07d1e9a15e6f1ab8a9c47f243e27324c" },
1024 { 1336, "f5950ee1d77c10e9011d2149699c9366fe52529c" },
1025 { 1344, "b04263604a63c351b0b3b9cf1785b4bdba6c8838" },
1026 { 1399, "8cb1cff61d5b784045974a2fc69386e3b8d24218" },
1027 { 1400, "9bb2f3fcbeddb2b90f0be797cd647334a2816d51" },
1028 { 1401, "23ae462a7a0cb440f7445791079a5d75a535dd33" },
1029 { 1402, "832974b524a4d3f9cc2f45a3cabf5ccef65cd2aa" },
1030 { 1403, "d1c683742fe404c3c20d5704a5430e7832a7ec95" },
1031 { 1404, "867c79042e64f310628e219d8b85594cd0c7adc3" },
1032 { 1405, "c9d81d49d13d94358f56ccfd61af02b36c69f7c3" },
1033 { 1406, "0df43daab2786172f9b8d07d61f14a070cf1287a" },
1034 { 1407, "0fd8f3ad7f169534b274d4c66bbddd89f759e391" },
1035 { 1408, "3987511182b18473a564436003139b808fa46343" },
1036 { 1409, "ef667e063c9e9f539a8987a8d0bd3066ee85d901" },
1037 { 2048, "921109c99f3fedaca21727156d5f2b4460175327" },
1038 { 2049, "47188600dd165eb45f27c27196d3c46f4f042c1b" },
1039 { 2050, "8831939904009338de10e7fa670847041387807d" },
1040 { 2051, "2f8ebb5db2997d614e767be1050366f3641e7520" },
1041 { 2052, "669e51cd730dae158d3bef8adba075bd95a0d011" },
1042 { 3072, "cfee66cfd83abc8451af3c96c6b35a41cc6c55f5" },
1043 { 3074, "216ea26f02976a261b7d21a4dd3085157bedfabd" },
1044 { 3075, "bd612ebba021fd8e012b14c3bd60c8c5161fabc0" },
1045 { 4048, "c2564c1fdf2d5e9d7dde7aace2643428e90662e8" },
1046 { 4052, "91ce61fe924b445dfe7b5a1dcd10a27caec16df6" },
1047 { 4058, "db2a9be5ee8124f091c7ebd699266c5de223c164" },
1048 { 6144, "855109903feae2ba3a7a05a326b8a171116eb368" },
1049 { 6150, "37520bb3a668294d9c7b073e7e3daf8fee248a78" },
1050 { 6400, "60a353c841b6d2b1a05890349dad2fa33c7536b7" },
1051 { 6528, "9e53a43a69bb42d7c8522ca8bd632e421d5edb36" },
1052 { 8192, "a918cb0da862eaea0a33ee0efea50243e6b4927c" },
1053 { 8320, "29a5dcf55d1db29cd113fcf0572ae414f1c71329" },
1054 {16384, "6fb27966138e0c8d5a0d65ace817ebd53633cee1" },
1055 {18432, "ca09900d891c7c9ae2a559b10f63a217003341c1" },
1056 { 0, NULL },
1057 };
1058
1059 /* Key = 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
1060 * 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10
1061 * 0x11, 0x12, 0x13, 0x14
1062 * InputHexStr = "31323334353637383930" (ASCII = "1234567890")
1063 */
1064 static MV_CESA_SIZE_TEST shaMultiSizeTest404[] =
1065 {
1066 { 80, "beaf20a34b06a87558d156c0949bc3957d40222e" },
1067 { 512, "3353955358d886bc2940a3c7f337ff7dafb59c7b" },
1068 { 1000, "8737a542c5e9b2b6244b757ebb69d5bd602a829f" },
1069 { 1001, "fd9e7582d8a5d3c9fe3b923e4e6a41b07a1eb4d4" },
1070 { 1002, "a146d14a6fc3c274ff600568f4d75b977989e00d" },
1071 { 1003, "be22601bbc027ddef2dec97d30b3dc424fd803c5" },
1072 { 1004, "3e71fe99b2fe2b7bfdf4dbf0c7f3da25d7ea35e7" },
1073 { 1005, "2c422735d7295408fddd76f5e8a83a2a8da13df3" },
1074 { 1006, "6d875319049314b61855101a647b9ba3313428e6" },
1075 { 1336, "c1631ea80bad9dc43a180712461b65a0598c711c" },
1076 { 1344, "816069bf91d34581005746e2e0283d0f9c7b7605" },
1077 { 1399, "4e139866dc61cfcb8b67ca2ebd637b3a538593af" },
1078 { 1400, "ff2a0f8dd2b02c5417910f6f55d33a78e081a723" },
1079 { 1401, "ab00c12be62336964cbce31ae97fe2a0002984d5" },
1080 { 1402, "61349e7f999f3a1acc56c3e9a5060a9c4a7b05b6" },
1081 { 1403, "3edbc0f61e435bc1317fa27d840076093fb79353" },
1082 { 1404, "d052c6dfdbe63d45dab23ef9893e2aa4636aca1e" },
1083 { 1405, "0cc16b7388d67bf0add15a31e6e6c753cfae4987" },
1084 { 1406, "c96ba7eaad74253c38c22101b558d2850b1d1b90" },
1085 { 1407, "3445428a40d2c6556e7c55797ad8d323b61a48d9" },
1086 { 1408, "8d6444f937a09317c89834187b8ea9b8d3a8c56b" },
1087 { 1409, "c700acd3ecd19014ea2bdb4d42510c467e088475" },
1088 { 2048, "ee27d2a0cb77470c2f496212dfd68b5bb7b04e4b" },
1089 { 2049, "683762d7a02983b26a6d046e6451d9cd82c25932" },
1090 { 2050, "0fd20f1d55a9ee18363c2a6fd54aa13aee69992f" },
1091 { 2051, "86c267d8cc4bc8d59090e4f8b303da960fd228b7" },
1092 { 2052, "452395ae05b3ec503eea34f86fc0832485ad97c1" },
1093 { 3072, "75198e3cfd0b9bcff2dabdf8e38e6fdaa33ca49a" },
1094 { 3074, "4e24785ef080141ce4aab4675986d9acea624d7c" },
1095 { 3075, "3a20c5978dd637ec0e809bf84f0d9ccf30bc65bf" },
1096 { 4048, "3c32da256be7a7554922bf5fed51b0d2d09e59ad" },
1097 { 4052, "fff898426ea16e54325ae391a32c6c9bce4c23c0" },
1098 { 4058, "c800b9e562e1c91e1310116341a3c91d37f848ec" },
1099 { 6144, "d91d509d0cc4376c2d05bf9a5097717a373530e6" },
1100 { 6150, "d957030e0f13c5df07d9eec298542d8f94a07f12" },
1101 { 6400, "bb745313c3d7dc17b3f955e5534ad500a1082613" },
1102 { 6528, "77905f80d9ca82080bbb3e5654896dabfcfd1bdb" },
1103 { 8192, "5237fd9a81830c974396f99f32047586612ff3c0" },
1104 { 8320, "57668e28d5f2dba0839518a11db0f6af3d7e08bf" },
1105 {16384, "62e093fde467f0748087beea32e9af97d5c61241" },
1106 {18432, "845fb33130c7d6ea554fd5aacb9c50cf7ccb5929" },
1107 { 0, NULL },
1108 };
1109
1110 /* HASH-SHA1
1111 * InputHexStr = "31323334353637383930" (ASCII = "1234567890")
1112 * repeated "size" times
1113 */
1114 static MV_CESA_SIZE_TEST shaMultiSizeTest405[] =
1115 {
1116 { 80, "50abf5706a150990a08b2c5ea40fa0e585554732" },
1117 { 512, "f14516a08948fa27917a974d219741a697ba0087" },
1118 { 1000, "0bd18c378d5788817eb4f1e5dc07d867efa5cbf4" },
1119 { 1001, "ca29b85c35db1b8aef83c977893a11159d1b7aa2" },
1120 { 1002, "d83bc973eaaedb8a31437994dabbb3304b0be086" },
1121 { 1003, "2cf7bbef0acd6c00536b5c58ca470df9a3a90b6c" },
1122 { 1004, "e4375d09b1223385a8a393066f8209acfd936a80" },
1123 { 1005, "1029b38043e027745d019ce1d2d68e3d8b9d8f99" },
1124 { 1006, "deea16dcebbd8ac137e2b984deb639b9fb5e9680" },
1125 { 1336, "ea031b065fff63dcfb6a41956e4777520cdbc55d" },
1126 { 1344, "b52096c6445e6c0a8355995c70dc36ae186c863c" },
1127 { 1399, "cde2f6f8379870db4b32cf17471dc828a8dbff2b" },
1128 { 1400, "e53ff664064bc09fe5054c650806bd42d8179518" },
1129 { 1401, "d1156db5ddafcace64cdb510ff0d4af9b9a8ad64" },
1130 { 1402, "34ede0e9a909dd84a2ae291539105c0507b958e1" },
1131 { 1403, "a772ca3536da77e6ad3251e4f9e1234a4d7b87c0" },
1132 { 1404, "29740fd2b04e7a8bfd32242db6233156ad699948" },
1133 { 1405, "65b17397495b70ce4865dad93bf991b74c97cce1" },
1134 { 1406, "a7ee89cd0754061fdb91af7ea6abad2c69d542e3" },
1135 { 1407, "3eebf82f7420188e23d328b7ce93580b279a5715" },
1136 { 1408, "e08d3363a8b9a490dfb3a4c453452b8f114deeec" },
1137 { 1409, "95d74df739181a4ff30b8c39e28793a36598e924" },
1138 { 2048, "aa40262509c2abf84aab0197f83187fc90056d91" },
1139 { 2049, "7dec28ef105bc313bade8d9a7cdeac58b99de5ea" },
1140 { 2050, "d2e30f77ec81197de20f56588a156094ecb88450" },
1141 { 2051, "6b22ccc874833e96551a39da0c0edcaa0d969d92" },
1142 { 2052, "f843141e57875cd669af58744bc60aa9ea59549c" },
1143 { 3072, "09c5fedeaa62c132e673cc3c608a00142273d086" },
1144 { 3074, "b09e95eea9c7b1b007a58accec488301901a7f3d" },
1145 { 3075, "e6226b77b4ada287a8c9bbcf4ed71eec5ce632dc" },
1146 { 4048, "e99394894f855821951ddddf5bfc628547435f5c" },
1147 { 4052, "32d2f1af38be9cfba6cd03d55a254d0b3e1eb382" },
1148 { 4058, "d906552a4f2aca3a22e1fecccbcd183d7289d0ef" },
1149 { 6144, "2e7f62d35a860988e1224dc0543204af19316041" },
1150 { 6150, "d6b89698ee133df46fec9d552fadc328aa5a1b51" },
1151 { 6400, "dff50e90c46853988fa3a4b4ce5dda6945aae976" },
1152 { 6528, "9e63ec0430b96db02d38bc78357a2f63de2ab7f8" },
1153 { 8192, "971eb71ed60394d5ab5abb12e88420bdd41b5992" },
1154 { 8320, "91606a31b46afeaac965cecf87297e791b211013" },
1155 {16384, "547f830a5ec1f5f170ce818f156b1002cabc7569" },
1156 {18432, "f16f272787f3b8d539652e4dc315af6ab4fda0ef" },
1157 { 0, NULL },
1158 };
1159
1160 /* CryptoKey = 0x01234567, 0x89abcdef,
1161 * 0x01234567, 0x89abcdef,
1162 * 0x01234567, 0x89abcdef;
1163 * MacKey = 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
1164 * 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10
1165 * InputHexStr = "31323334353637383930" (ASCII = "1234567890")
1166 * Note: only sizes aligned to 3DES block size (8 bytes) allowed
1167 */
1168 static MV_CESA_SIZE_TEST tripleDesMdMultiSizeTest502[] =
1169 {
1170 { 64, "9586962a2aaaef28803dec2e17807a7f" },
1171 { 80, "b7726a03aad490bd6c5a452a89a1b271" },
1172 { 352, "f1ed9563aecc3c0d2766eb2bed3b4e4c" },
1173 { 512, "0f9decb11ab40fe86f4d4d9397bc020e" },
1174 { 1000, "3ba69deac12cab8ff9dff7dbd9669927" },
1175 { 1336, "6cf47bf1e80e03e2c1d0945bc50d37d2" },
1176 { 1344, "4be388dab21ceb3fa1b8d302e9b821f7" },
1177 { 1400, "a58b79fb21dd9bfc6ec93e3b99fb0ef1" },
1178 { 1408, "8bc97379fc2ac3237effcdd4f7a86528" },
1179 { 2048, "1339f03ab3076f25a20bc4cba16eb5bf" },
1180 { 3072, "731204d2d90c4b36ae41f5e1fb874288" },
1181 { 4048, "c028d998cfda5642547b7e1ed5ea16e4" },
1182 { 6144, "b1b19cd910cc51bd22992f1e59f1e068" },
1183 { 6400, "44e4613496ba622deb0e7cb768135a2f" },
1184 { 6528, "3b06b0a86f8db9cd67f9448dfcf10549" },
1185 { 8192, "d581780b7163138a0f412be681457d82" },
1186 {16384, "03b8ac05527faaf1bed03df149c65ccf" },
1187 {18432, "677c8a86a41dab6c5d81b85b8fb10ff6" },
1188 { 0, NULL },
1189 };
1190
1191
1192 /* CryptoKey = 0x01234567, 0x89abcdef,
1193 * 0x01234567, 0x89abcdef,
1194 * 0x01234567, 0x89abcdef;
1195 * MacKey = 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
1196 * 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10
1197 * 0x11, 0x12, 0x13, 0x14
1198 * InputHexStr = "31323334353637383930" (ASCII = "1234567890")
1199 * Note: only sizes aligned to 3DES block size (8 bytes) allowed
1200 */
1201 static MV_CESA_SIZE_TEST tripleDesShaMultiSizeTest503[] =
1202 {
1203 { 64, "44a1e9bcbfc1429630d9ea68b7a48b0427a684f2" },
1204 { 80, "b2ddeaca91030eab5b95a234ef2c0f6e738ff883" },
1205 { 352, "4b91864c7ff629bdff75d9726421f76705452aaf" },
1206 { 512, "6dd37faceeb2aa98ba74f4242ed6734a4d546af5" },
1207 { 1000, "463661c30300be512a9df40904f0757cde5f1141" },
1208 { 1336, "b931f831d9034fe59c65176400b039fe9c1f44a5" },
1209 { 1344, "af8866b1cd4a4887d6185bfe72470ffdfb3648e1" },
1210 { 1400, "49c6caf07296d5e31d2504d088bc5b20c3ee7cdb" },
1211 { 1408, "fcae8deedbc6ebf0763575dc7e9de075b448a0f4" },
1212 { 2048, "edece5012146c1faa0dd10f50b183ba5d2af58ac" },
1213 { 3072, "5b83625adb43a488b8d64fecf39bb766818547b7" },
1214 { 4048, "d2c533678d26c970293af60f14c8279dc708bfc9" },
1215 { 6144, "b8f67af4f991b08b725f969b049ebf813bfacc5c" },
1216 { 6400, "d9a6c7f746ac7a60ef2edbed2841cf851c25cfb0" },
1217 { 6528, "376792b8c8d18161d15579fb7829e6e3a27e9946" },
1218 { 8192, "d890eabdca195b34ef8724b28360cffa92ae5655" },
1219 {16384, "a167ee52639ec7bf19aee9c6e8f76667c14134b9" },
1220 {18432, "e4396ab56f67296b220985a12078f4a0e365d2cc" },
1221 { 0, NULL },
1222 };
1223
1224 /* CryptoKey = 0x01234567, 0x89abcdef,
1225 * 0x01234567, 0x89abcdef,
1226 * 0x01234567, 0x89abcdef
1227 * IV = 0x12345678, 0x90abcdef
1228 * MacKey = 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
1229 * 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10
1230 * InputHexStr = "31323334353637383930" (ASCII = "1234567890")
1231 * Note: only sizes aligned to 3DES block size (8 bytes) allowed
1232 */
1233 static MV_CESA_SIZE_TEST cbc3desMdMultiSizeTest504[] =
1234 {
1235 { 64, "8d10e00802460ede0058c139ba48bd2d" },
1236 { 80, "6f463057e1a90e0e91ae505b527bcec0" },
1237 { 352, "4938d48bdf86aece2c6851e7c6079788" },
1238 { 512, "516705d59f3cf810ebf2a13a23a7d42e" },
1239 { 1000, "a5a000ee5c830e67ddc6a2d2e5644b31" },
1240 { 1336, "44af60087b74ed07950088efbe3b126a" },
1241 { 1344, "1f5b39e0577920af731dabbfcf6dfc2a" },
1242 { 1400, "6804ea640e29b9cd39e08bc37dbce734" },
1243 { 1408, "4fb436624b02516fc9d1535466574bf9" },
1244 { 2048, "c909b0985c423d8d86719f701e9e83db" },
1245 { 3072, "cfe0bc34ef97213ee3d3f8b10122db21" },
1246 { 4048, "03ea10b5ae4ddeb20aed6af373082ed1" },
1247 { 6144, "b9a0ff4f87fc14b3c2dc6f0ed0998fdf" },
1248 { 6400, "6995f85d9d4985dd99e974ec7dda9dd6" },
1249 { 6528, "bbbb548ce2fa3d58467f6a6a5168a0e6" },
1250 { 8192, "afe101fbe745bb449ae4f50d10801456" },
1251 {16384, "9741706d0b1c923340c4660ff97cacdf" },
1252 {18432, "b0217becb73cb8f61fd79c7ce9d023fb" },
1253 { 0, NULL },
1254 };
1255
1256
1257 /* CryptoKey = 0x01234567, 0x89abcdef,
1258 * 0x01234567, 0x89abcdef,
1259 * 0x01234567, 0x89abcdef;
1260 * IV = 0x12345678, 0x90abcdef
1261 * MacKey = 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
1262 * 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10
1263 * 0x11, 0x12, 0x13, 0x14
1264 * InputHexStr = "31323334353637383930" (ASCII = "1234567890")
1265 * Note: only sizes aligned to 3DES block size (8 bytes) allowed
1266 */
1267 static MV_CESA_SIZE_TEST cbc3desShaMultiSizeTest505[] =
1268 {
1269 { 64, "409187e5bdb0be4a7754ca3747f7433dc4f01b98" },
1270 { 80, "1b002ed050be743aa98860cf35659646bb8efcc0" },
1271 { 352, "6cbf7ebe50fa4fa6eecc19eca23f9eae553ccfff" },
1272 { 512, "cfb5253fb4bf72b743320c30c7e48c54965853b0" },
1273 { 1000, "95e04e1ca2937e7c5a9aba9e42d2bcdb8a7af21f" },
1274 { 1336, "3b5c1f5eee5837ebf67b83ae01405542d77a6627" },
1275 { 1344, "2b3d42ab25615437f98a1ee310b81d07a02badc2" },
1276 { 1400, "7f8687df7c1af44e4baf3c934b6cca5ab6bc993e" },
1277 { 1408, "473a581c5f04f7527d50793c845471ac87e86430" },
1278 { 2048, "e41d20cae7ebe34e6e828ed62b1e5734019037bb" },
1279 { 3072, "275664afd7a561d804e6b0d204e53939cde653ae" },
1280 { 4048, "0d220cc5b34aeeb46bbbd637dde6290b5a8285a3" },
1281 { 6144, "cb393ddcc8b1c206060625b7d822ef9839e67bc5" },
1282 { 6400, "dd3317e2a627fc04800f74a4b05bfda00fab0347" },
1283 { 6528, "8a74c3b2441ab3f5a7e08895cc432566219a7c41" },
1284 { 8192, "b8e6ef3a549ed0e005bd5b8b1a5fe6689e9711a7" },
1285 {16384, "55f59404008276cdac0e2ba0d193af2d40eac5ce" },
1286 {18432, "86ae6c4fc72369a54cce39938e2d0296cd9c6ec5" },
1287 { 0, NULL },
1288 };
1289
1290
1291 /* CryptoKey = 0x01234567, 0x89abcdef,
1292 * 0x01234567, 0x89abcdef,
1293 * 0x01234567, 0x89abcdef
1294 * IV = 0x12345678, 0x90abcdef
1295 * MacKey = 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
1296 * 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10
1297 * InputHexStr = "31323334353637383930" (ASCII = "1234567890")
1298 * Note: only sizes aligned to AES block size (16 bytes) allowed
1299 */
1300 static MV_CESA_SIZE_TEST cbcAes128md5multiSizeTest506[] =
1301 {
1302 { 16, "7ca4c2ba866751598720c5c4aa0d6786" },
1303 { 64, "7dba7fb988e80da609b1fea7254bced8" },
1304 { 80, "6b6e863ac5a71d15e3e9b1c86c9ba05f" },
1305 { 352, "a1ceb9c2e3021002400d525187a9f38c" },
1306 { 512, "596c055c1c55db748379223164075641" },
1307 { 1008, "f920989c02f3b3603f53c99d89492377" },
1308 { 1344, "2e496b73759d77ed32ea222dbd2e7b41" },
1309 { 1408, "7178c046b3a8d772efdb6a71c4991ea4" },
1310 { 2048, "a917f0099c69eb94079a8421714b6aad" },
1311 { 3072, "693cd5033d7f5391d3c958519fa9e934" },
1312 { 4048, "139dca91bcff65b3c40771749052906b" },
1313 { 6144, "428d9cef6df4fb70a6e9b6bbe4819e55" },
1314 { 6400, "9c0b909e76daa811e12b1fc17000a0c4" },
1315 { 6528, "ad876f6297186a7be1f1b907ed860eda" },
1316 { 8192, "479cbbaca37dd3191ea1f3e8134a0ef4" },
1317 {16384, "60fda559c74f91df538100c9842f2f15" },
1318 {18432, "4a3eb1cba1fa45f3981270953f720c42" },
1319 { 0, NULL },
1320 };
1321
1322
1323 /* CryptoKey = 0x01234567, 0x89abcdef,
1324 * 0x01234567, 0x89abcdef,
1325 * 0x01234567, 0x89abcdef;
1326 * IV = 0x12345678, 0x90abcdef
1327 * MacKey = 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
1328 * 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10
1329 * 0x11, 0x12, 0x13, 0x14
1330 * InputHexStr = "31323334353637383930" (ASCII = "1234567890")
1331 * Note: only sizes aligned to AES block size (16 bytes) allowed
1332 */
1333 static MV_CESA_SIZE_TEST cbcAes128sha1multiSizeTest507[] =
1334 {
1335 { 16, "9aa8dc1c45f0946daf78057fa978759c625c1fee" },
1336 { 64, "9f588fc1ede851e5f8b20256abc9979465ae2189" },
1337 { 80, "13558472d1fc1c90dffec6e5136c7203452d509b" },
1338 { 352, "6b93518e006cfaa1f7adb24615e7291fb0a27e06" },
1339 { 512, "096874951a77fbbf333e49d80c096ee2016e09bd" },
1340 { 1008, "696fc203c2e4b5ae0ec5d1db3f623c490bc6dbac" },
1341 { 1344, "79bf77509935ccd3528caaac6a5eb6481f74029b" },
1342 { 1408, "627f9462b95fc188e8cfa7eec15119bdc5d4fcf1" },
1343 { 2048, "3d50d0c005feba92fe41502d609fced9c882b4d1" },
1344 { 3072, "758807e5b983e3a91c06fb218fe0f73f77111e94" },
1345 { 4048, "ca90e85242e33f005da3504416a52098d0d31fb2" },
1346 { 6144, "8044c1d4fd06642dfc46990b4f18b61ef1e972cf" },
1347 { 6400, "166f1f4ea57409f04feba9fb1e39af0e00bd6f43" },
1348 { 6528, "0389016a39485d6e330f8b4215ddf718b404f7e9" },
1349 { 8192, "6df7ee2a8b61d6f7f860ce8dbf778f0c2a5b508b" },
1350 {16384, "a70a6d8dfa1f91ded621c3dbaed34162bc48783f" },
1351 {18432, "8dfad627922ce15df1eed10bdbed49244efa57db" },
1352 { 0, NULL },
1353 };
1354
1355
1356 void cesaTestPrintStatus(void);
1357
1358
1359 /*------------------------- LOCAL FUNCTIONs ---------------------------------*/
1360 MV_STATUS testCmd(int sid, int iter, MV_CESA_COMMAND* pCmd,
1361 MV_CESA_TEST_SESSION* pTestSession, MV_U8* pIV, int ivSize);
1362 MV_STATUS testClose(int idx);
1363 MV_STATUS testOpen(int idx);
1364 void close_session(int sid);
1365 void cesaTestCheckReady(const MV_CESA_RESULT *r);
1366 void cesaCheckReady(MV_CESA_RESULT* r);
1367 void printTestResults(int idx, MV_STATUS status, int checkMode);
1368 void cesaLastResult(void);
1369 void cesaTestPrintReq(int req, int offset, int size);
1370
1371 void cesaTestPrintStatus(void);
1372 void cesaTestPrintSession(int idx);
1373 void sizeTest(int testIdx, int iter, int checkMode);
1374 void multiTest(int iter, int reqSize, int checkMode);
1375 void oneTest(int testIdx, int caseIdx,int iter, int reqSize, int checkMode);
1376 void multiSizeTest(int idx, int iter, int checkMode, char* inputData);
1377 void cesaTest(int iter, int reqSize, int checkMode);
1378 void cesaOneTest(int testIdx, int caseIdx,int iter, int reqSize, int checkMode);
1379 void combiTest(int iter, int reqSize, int checkMode);
1380 void shaTest(int iter, int reqSize, int checkMode);
1381 void mdTest(int iter, int reqSize, int checkMode);
1382 void aesTest(int iter, int reqSize, int checkMode);
1383 void tripleDesTest(int iter, int reqSize, int checkMode);
1384 void desTest(int iter, int reqSize, int checkMode);
1385 void cesaTestStop(void);
1386 MV_STATUS testRun(int idx, int caseIdx, int iter,int reqSize, int checkMode);
1387 void cesaTestStart(int bufNum, int bufSize);
1388
1389
1390 static MV_U32 getRate(MV_U32* remainder)
1391 {
1392 MV_U32 kBits, milliSec, rate;
1393
1394 milliSec = 0;
1395 if( (cesaEndTicks - cesaBeginTicks) > 0)
1396 {
1397 milliSec = CESA_TEST_TICK_TO_MS(cesaEndTicks - cesaBeginTicks);
1398 }
1399 if(milliSec == 0)
1400 {
1401 if(remainder != NULL)
1402 *remainder = 0;
1403 return 0;
1404 }
1405
1406 kBits = (cesaIteration*cesaRateSize*8)/1000;
1407 rate = kBits/milliSec;
1408 if(remainder != NULL)
1409 *remainder = ((kBits % milliSec)*10)/milliSec;
1410
1411 return rate;
1412 }
1413
1414 static char* extractMbuf(MV_CESA_MBUF *pMbuf,
1415 int offset, int size, char* hexStr)
1416 {
1417 mvCesaCopyFromMbuf((MV_U8*)cesaBinBuffer, pMbuf, offset, size);
1418 mvBinToHex((const MV_U8*)cesaBinBuffer, hexStr, size);
1419
1420 return hexStr;
1421 }
1422
1423 static MV_BOOL cesaCheckMbuf(MV_CESA_MBUF *pMbuf,
1424 const char* hexString, int offset,
1425 int checkSize)
1426 {
1427 MV_BOOL isFailed = MV_FALSE;
1428 MV_STATUS status;
1429 int size = strlen(hexString)/2;
1430 int checkedSize = 0;
1431 /*
1432 mvOsPrintf("cesaCheckMbuf: pMbuf=%p, offset=%d, checkSize=%d, mBufSize=%d\n",
1433 pMbuf, offset, checkSize, pMbuf->mbufSize);
1434 */
1435 if(pMbuf->mbufSize < (checkSize + offset))
1436 {
1437 mvOsPrintf("checkSize (%d) is too large: offset=%d, mbufSize=%d\n",
1438 checkSize, offset, pMbuf->mbufSize);
1439 return MV_TRUE;
1440 }
1441 status = mvCesaCopyFromMbuf((MV_U8*)cesaBinBuffer, pMbuf, offset, checkSize);
1442 if(status != MV_OK)
1443 {
1444 mvOsPrintf("CesaTest: Can't copy %d bytes from Mbuf=%p to checkBuf=%p\n",
1445 checkSize, pMbuf, cesaBinBuffer);
1446 return MV_TRUE;
1447 }
1448 /*
1449 mvDebugMemDump(cesaBinBuffer, size, 1);
1450 */
1451 mvHexToBin(hexString, (MV_U8*)cesaExpBinBuffer, size);
1452
1453 /* Compare buffers */
1454 while(checkSize > checkedSize)
1455 {
1456 size = MV_MIN(size, (checkSize - checkedSize));
1457 if(memcmp(cesaExpBinBuffer, &cesaBinBuffer[checkedSize], size) != 0)
1458 {
1459 mvOsPrintf("CheckMbuf failed: checkSize=%d, size=%d, checkedSize=%d\n",
1460 checkSize, size, checkedSize);
1461 mvDebugMemDump(&cesaBinBuffer[checkedSize], size, 1);
1462 mvDebugMemDump(cesaExpBinBuffer, size, 1);
1463
1464 isFailed = MV_TRUE;
1465 break;
1466 }
1467 checkedSize += size;
1468 }
1469
1470 return isFailed;
1471 }
1472
1473 static MV_STATUS cesaSetMbuf(MV_CESA_MBUF *pMbuf,
1474 const char* hexString,
1475 int offset, int reqSize)
1476 {
1477 MV_STATUS status = MV_OK;
1478 int copySize, size = strlen(hexString)/2;
1479
1480 mvHexToBin(hexString, (MV_U8*)cesaBinBuffer, size);
1481
1482 copySize = 0;
1483 while(reqSize > copySize)
1484 {
1485 size = MV_MIN(size, (reqSize - copySize));
1486
1487 status = mvCesaCopyToMbuf((MV_U8*)cesaBinBuffer, pMbuf, offset+copySize, size);
1488 if(status != MV_OK)
1489 {
1490 mvOsPrintf("cesaSetMbuf Error: Copy %d of %d bytes to MBuf\n",
1491 copySize, reqSize);
1492 break;
1493 }
1494 copySize += size;
1495 }
1496 pMbuf->mbufSize = offset+copySize;
1497 return status;
1498 }
1499
1500 static MV_CESA_TEST_SESSION* getTestSessionDb(int idx, int* pTestIdx)
1501 {
1502 int testIdx, dbIdx = idx/100;
1503
1504 if(dbIdx > MAX_TEST_TYPE)
1505 {
1506 mvOsPrintf("Wrong index %d - No such test type\n", idx);
1507 return NULL;
1508 }
1509 testIdx = idx % 100;
1510
1511 if(testIdx >= cesaTestsDB[dbIdx].numSessions)
1512 {
1513 mvOsPrintf("Wrong index %d - No such test\n", idx);
1514 return NULL;
1515 }
1516 if(pTestIdx != NULL)
1517 *pTestIdx = testIdx;
1518
1519 return cesaTestsDB[dbIdx].pSessions;
1520 }
1521
1522 /* Debug */
1523 void cesaTestPrintReq(int req, int offset, int size)
1524 {
1525 MV_CESA_MBUF* pMbuf;
1526
1527 mvOsPrintf("cesaTestPrintReq: req=%d, offset=%d, size=%d\n",
1528 req, offset, size);
1529 mvDebugMemDump(cesaCmdRing, 128, 4);
1530
1531 pMbuf = cesaCmdRing[req].pSrc;
1532 mvCesaDebugMbuf("src", pMbuf, offset,size);
1533 pMbuf = cesaCmdRing[req].pDst;
1534 mvCesaDebugMbuf("dst", pMbuf, offset, size);
1535
1536 cesaTestPrintStatus();
1537 }
1538
1539 void cesaLastResult(void)
1540 {
1541 mvOsPrintf("Last Result: ReqId = %d, SessionId = %d, rc = (%d)\n",
1542 (MV_U32)cesaResult.pReqPrv, cesaResult.sessionId,
1543 cesaResult.retCode);
1544 }
1545
1546 void printTestResults(int idx, MV_STATUS status, int checkMode)
1547 {
1548 int testIdx;
1549 MV_CESA_TEST_SESSION* pTestSessions = getTestSessionDb(idx, &testIdx);
1550
1551 if(pTestSessions == NULL)
1552 return;
1553
1554 mvOsPrintf("%-35s %4dx%-4d : ", pTestSessions[testIdx].name,
1555 cesaIteration, cesaReqSize);
1556 if( (status == MV_OK) &&
1557 (cesaCryptoError == 0) &&
1558 (cesaError == 0) &&
1559 (cesaReqIdError == 0) )
1560 {
1561 mvOsPrintf("Passed, Rate=%3u.%u Mbps (%5u cpp)\n",
1562 cesaRate, cesaRateAfterDot, cesaEndTicks - cesaBeginTicks);
1563 }
1564 else
1565 {
1566 mvOsPrintf("Failed, Status = 0x%x\n", status);
1567 if(cesaCryptoError > 0)
1568 mvOsPrintf("cryptoError : %d\n", cesaCryptoError);
1569 if(cesaReqIdError > 0)
1570 mvOsPrintf("reqIdError : %d\n", cesaReqIdError);
1571 if(cesaError > 0)
1572 mvOsPrintf("cesaError : %d\n", cesaError);
1573 }
1574 if(cesaTestIsrMissCount > 0)
1575 mvOsPrintf("cesaIsrMissed : %d\n", cesaTestIsrMissCount);
1576 }
1577
1578 void cesaCheckReady(MV_CESA_RESULT* r)
1579 {
1580 int reqId;
1581 MV_CESA_MBUF *pMbuf;
1582 MV_BOOL isFailed;
1583
1584 cesaResult = *r;
1585 reqId = (int)cesaResult.pReqPrv;
1586 pMbuf = cesaCmdRing[reqId].pDst;
1587
1588 /*
1589 mvOsPrintf("cesaCheckReady: reqId=%d, checkOffset=%d, checkSize=%d\n",
1590 reqId, cesaCheckOffset, cesaCheckSize);
1591 */
1592 /* Check expected reqId */
1593 if(reqId != cesaExpReqId)
1594 {
1595 cesaReqIdError++;
1596 /*
1597 mvOsPrintf("CESA reqId Error: cbIter=%d (%d), reqId=%d, expReqId=%d\n",
1598 cesaCbIter, cesaIteration, reqId, cesaExpReqId);
1599 */
1600 }
1601 else
1602 {
1603 if( (cesaCheckMode == CESA_FULL_CHECK_MODE) ||
1604 (cesaCheckMode == CESA_FAST_CHECK_MODE) )
1605 {
1606 if(cesaResult.retCode != MV_OK)
1607 {
1608 cesaError++;
1609
1610 mvOsPrintf("CESA Error: cbIter=%d (%d), reqId=%d, rc=%d\n",
1611 cesaCbIter, cesaIteration, reqId, cesaResult.retCode);
1612 }
1613 else
1614 {
1615 if( (cesaCheckSize > 0) && (cesaOutputHexStr != NULL) )
1616 {
1617 /* Check expected output */
1618
1619 isFailed = cesaCheckMbuf(pMbuf, cesaOutputHexStr, cesaCheckOffset, cesaCheckSize);
1620 if(isFailed)
1621 {
1622 mvOsPrintf("CESA Crypto Error: cbIter=%d (%d), reqId=%d\n",
1623 cesaCbIter, cesaIteration, reqId);
1624
1625 CESA_TEST_DEBUG_PRINT(("Error: reqId=%d, reqSize=%d, checkOffset=%d, checkSize=%d\n",
1626 reqId, cesaReqSize, cesaCheckOffset, cesaCheckSize));
1627
1628 CESA_TEST_DEBUG_PRINT(("Output str: %s\n", cesaOutputHexStr));
1629
1630 CESA_TEST_DEBUG_CODE( mvCesaDebugMbuf("error", pMbuf, 0, cesaCheckOffset+cesaCheckSize) );
1631
1632 cesaCryptoError++;
1633 }
1634 }
1635 }
1636 }
1637 }
1638 if(cesaCheckMode == CESA_SHOW_CHECK_MODE)
1639 {
1640 extractMbuf(pMbuf, cesaCheckOffset, cesaCheckSize, cesaHexBuffer);
1641 mvOsPrintf("%4d, %s\n", cesaCheckOffset, cesaHexBuffer);
1642 }
1643
1644 cesaCbIter++;
1645 if(cesaCbIter >= cesaIteration)
1646 {
1647 cesaCbIter = 0;
1648 cesaExpReqId = 0;
1649 cesaIsReady = MV_TRUE;
1650
1651 cesaEndTicks = CESA_TEST_TICK_GET();
1652 cesaRate = getRate(&cesaRateAfterDot);
1653 }
1654 else
1655 {
1656 cesaExpReqId = reqId + 1;
1657 if(cesaExpReqId == CESA_DEF_REQ_SIZE)
1658 cesaExpReqId = 0;
1659 }
1660 }
1661
1662
1663 #ifdef MV_NETBSD
1664 static int cesaTestReadyIsr(void *arg)
1665 #else
1666 #ifdef __KERNEL__
1667 static irqreturn_t cesaTestReadyIsr( int irq , void *dev_id)
1668 #endif
1669 #ifdef MV_VXWORKS
1670 void cesaTestReadyIsr(void)
1671 #endif
1672 #endif
1673 {
1674 MV_U32 cause;
1675 MV_STATUS status;
1676 MV_CESA_RESULT result;
1677
1678 cesaTestIsrCount++;
1679 /* Clear cause register */
1680 cause = MV_REG_READ(MV_CESA_ISR_CAUSE_REG);
1681 if( (cause & MV_CESA_CAUSE_ACC_DMA_ALL_MASK) == 0)
1682 {
1683 mvOsPrintf("cesaTestReadyIsr: cause=0x%x\n", cause);
1684 #ifdef MV_NETBSD
1685 return 0;
1686 #else
1687 #ifdef __KERNEL__
1688 return 1;
1689 #else
1690 return;
1691 #endif
1692 #endif
1693 }
1694
1695 MV_REG_WRITE(MV_CESA_ISR_CAUSE_REG, 0);
1696
1697 while(MV_TRUE)
1698 {
1699 /* Get Ready requests */
1700 status = mvCesaReadyGet(&result);
1701 if(status == MV_OK)
1702 cesaCheckReady(&result);
1703
1704 break;
1705 }
1706 if( (cesaTestFull == 1) && (status != MV_BUSY) )
1707 {
1708 cesaTestFull = 0;
1709 CESA_TEST_WAKE_UP();
1710 }
1711
1712 #ifdef __KERNEL__
1713 return 1;
1714 #endif
1715 }
1716
1717 void
1718 cesaTestCheckReady(const MV_CESA_RESULT *r)
1719 {
1720 MV_CESA_RESULT result = *r;
1721
1722 cesaCheckReady(&result);
1723
1724 if (cesaTestFull == 1) {
1725 cesaTestFull = 0;
1726 CESA_TEST_WAKE_UP();
1727 }
1728 }
1729
1730 static INLINE int open_session(MV_CESA_OPEN_SESSION* pOs)
1731 {
1732 MV_U16 sid;
1733 MV_STATUS status;
1734
1735 status = mvCesaSessionOpen(pOs, (short*)&sid);
1736 if(status != MV_OK)
1737 {
1738 mvOsPrintf("CesaTest: Can't open new session - status = 0x%x\n",
1739 status);
1740 return -1;
1741 }
1742
1743 return (int)sid;
1744 }
1745
1746 void close_session(int sid)
1747 {
1748 MV_STATUS status;
1749
1750 status = mvCesaSessionClose(sid);
1751 if(status != MV_OK)
1752 {
1753 mvOsPrintf("CesaTest: Can't close session %d - status = 0x%x\n",
1754 sid, status);
1755 }
1756 }
1757
1758 MV_STATUS testOpen(int idx)
1759 {
1760 MV_CESA_OPEN_SESSION os;
1761 int sid, i, testIdx;
1762 MV_CESA_TEST_SESSION* pTestSession;
1763 MV_U16 digestSize = 0;
1764
1765 pTestSession = getTestSessionDb(idx, &testIdx);
1766 if(pTestSession == NULL)
1767 {
1768 mvOsPrintf("Test %d is not exist\n", idx);
1769 return MV_BAD_PARAM;
1770 }
1771 pTestSession = &pTestSession[testIdx];
1772
1773 if(pTestSession->sid != -1)
1774 {
1775 mvOsPrintf("Session for test %d already created: sid=%d\n",
1776 idx, pTestSession->sid);
1777 return MV_OK;
1778 }
1779
1780 os.cryptoAlgorithm = pTestSession->cryptoAlgorithm;
1781 os.macMode = pTestSession->macAlgorithm;
1782 switch(os.macMode)
1783 {
1784 case MV_CESA_MAC_MD5:
1785 case MV_CESA_MAC_HMAC_MD5:
1786 digestSize = MV_CESA_MD5_DIGEST_SIZE;
1787 break;
1788
1789 case MV_CESA_MAC_SHA1:
1790 case MV_CESA_MAC_HMAC_SHA1:
1791 digestSize = MV_CESA_SHA1_DIGEST_SIZE;
1792 break;
1793
1794 case MV_CESA_MAC_NULL:
1795 digestSize = 0;
1796 }
1797 os.cryptoMode = pTestSession->cryptoMode;
1798 os.direction = pTestSession->direction;
1799 os.operation = pTestSession->operation;
1800
1801 for(i=0; i<pTestSession->cryptoKeySize; i++)
1802 os.cryptoKey[i] = pTestSession->pCryptoKey[i];
1803
1804 os.cryptoKeyLength = pTestSession->cryptoKeySize;
1805
1806 for(i=0; i<pTestSession->macKeySize; i++)
1807 os.macKey[i] = pTestSession->pMacKey[i];
1808
1809 os.macKeyLength = pTestSession->macKeySize;
1810 os.digestSize = digestSize;
1811
1812 sid = open_session(&os);
1813 if(sid == -1)
1814 {
1815 mvOsPrintf("Can't open session for test %d: rc=0x%x\n",
1816 idx, cesaResult.retCode);
1817 return cesaResult.retCode;
1818 }
1819 CESA_TEST_DEBUG_PRINT(("Opened session: sid = %d\n", sid));
1820 pTestSession->sid = sid;
1821 return MV_OK;
1822 }
1823
1824 MV_STATUS testClose(int idx)
1825 {
1826 int testIdx;
1827 MV_CESA_TEST_SESSION* pTestSession;
1828
1829 pTestSession = getTestSessionDb(idx, &testIdx);
1830 if(pTestSession == NULL)
1831 {
1832 mvOsPrintf("Test %d is not exist\n", idx);
1833 return MV_BAD_PARAM;
1834 }
1835 pTestSession = &pTestSession[testIdx];
1836
1837 if(pTestSession->sid == -1)
1838 {
1839 mvOsPrintf("Test session %d is not opened\n", idx);
1840 return MV_NO_SUCH;
1841 }
1842
1843 close_session(pTestSession->sid);
1844 pTestSession->sid = -1;
1845
1846 return MV_OK;
1847 }
1848
1849 MV_STATUS testCmd(int sid, int iter, MV_CESA_COMMAND* pCmd,
1850 MV_CESA_TEST_SESSION* pTestSession, MV_U8* pIV, int ivSize)
1851 {
1852 int cmdReqId = 0;
1853 int i;
1854 MV_STATUS rc = MV_OK;
1855 char ivZeroHex[] = "0000";
1856
1857 if(iter == 0)
1858 iter = CESA_DEF_ITER_NUM;
1859
1860 if(pCmd == NULL)
1861 {
1862 mvOsPrintf("testCmd failed: pCmd=NULL\n");
1863 return MV_BAD_PARAM;
1864 }
1865 pCmd->sessionId = sid;
1866
1867 cesaCryptoError = 0;
1868 cesaReqIdError = 0;
1869 cesaError = 0;
1870 cesaTestIsrMissCount = 0;
1871 cesaIsReady = MV_FALSE;
1872 cesaIteration = iter;
1873
1874 if(cesaInputHexStr == NULL)
1875 cesaInputHexStr = cesaPlainHexEbc;
1876
1877 for(i=0; i<CESA_DEF_REQ_SIZE; i++)
1878 {
1879 pCmd->pSrc = (MV_CESA_MBUF*)(cesaCmdRing[i].pSrc);
1880 if(pIV != NULL)
1881 {
1882 /* If IV from SA - set IV in Source buffer to zeros */
1883 cesaSetMbuf(pCmd->pSrc, ivZeroHex, 0, pCmd->cryptoOffset);
1884 cesaSetMbuf(pCmd->pSrc, cesaInputHexStr, pCmd->cryptoOffset,
1885 (cesaReqSize - pCmd->cryptoOffset));
1886 }
1887 else
1888 {
1889 cesaSetMbuf(pCmd->pSrc, cesaInputHexStr, 0, cesaReqSize);
1890 }
1891 pCmd->pDst = (MV_CESA_MBUF*)(cesaCmdRing[i].pDst);
1892 cesaSetMbuf(pCmd->pDst, cesaNullPlainHexText, 0, cesaReqSize);
1893
1894 memcpy(&cesaCmdRing[i], pCmd, sizeof(*pCmd));
1895 }
1896
1897 if(cesaCheckMode == CESA_SW_SHOW_CHECK_MODE)
1898 {
1899 MV_U8 pDigest[MV_CESA_MAX_DIGEST_SIZE];
1900
1901 if(pTestSession->macAlgorithm == MV_CESA_MAC_MD5)
1902 {
1903 mvMD5(pCmd->pSrc->pFrags[0].bufVirtPtr, pCmd->macLength, pDigest);
1904 mvOsPrintf("SW HASH_MD5: reqSize=%d, macLength=%d\n",
1905 cesaReqSize, pCmd->macLength);
1906 mvDebugMemDump(pDigest, MV_CESA_MD5_DIGEST_SIZE, 1);
1907 return MV_OK;
1908 }
1909 if(pTestSession->macAlgorithm == MV_CESA_MAC_SHA1)
1910 {
1911 mvSHA1(pCmd->pSrc->pFrags[0].bufVirtPtr, pCmd->macLength, pDigest);
1912 mvOsPrintf("SW HASH_SHA1: reqSize=%d, macLength=%d\n",
1913 cesaReqSize, pCmd->macLength);
1914 mvDebugMemDump(pDigest, MV_CESA_SHA1_DIGEST_SIZE, 1);
1915 return MV_OK;
1916 }
1917 }
1918
1919 cesaBeginTicks = CESA_TEST_TICK_GET();
1920 CESA_TEST_DEBUG_CODE( memset(cesaTestTrace, 0, sizeof(cesaTestTrace));
1921 cesaTestTraceIdx = 0;
1922 );
1923
1924 if(cesaCheckMode == CESA_SW_NULL_CHECK_MODE)
1925 {
1926 volatile MV_U8 pDigest[MV_CESA_MAX_DIGEST_SIZE];
1927
1928 for(i=0; i<iter; i++)
1929 {
1930 if(pTestSession->macAlgorithm == MV_CESA_MAC_MD5)
1931 {
1932 mvMD5(pCmd->pSrc->pFrags[0].bufVirtPtr, pCmd->macLength, (unsigned char*)pDigest);
1933 }
1934 if(pTestSession->macAlgorithm == MV_CESA_MAC_SHA1)
1935 {
1936 mvSHA1(pCmd->pSrc->pFrags[0].bufVirtPtr, pCmd->macLength, (MV_U8 *)pDigest);
1937 }
1938 }
1939 cesaEndTicks = CESA_TEST_TICK_GET();
1940 cesaRate = getRate(&cesaRateAfterDot);
1941 cesaIsReady = MV_TRUE;
1942
1943 return MV_OK;
1944 }
1945
1946 /*cesaTestIsrCount = 0;*/
1947 /*mvCesaDebugStatsClear();*/
1948
1949 #ifndef MV_NETBSD
1950 MV_REG_WRITE(MV_CESA_ISR_CAUSE_REG, 0);
1951 #endif
1952
1953 for(i=0; i<iter; i++)
1954 {
1955 unsigned long flags;
1956
1957 pCmd = &cesaCmdRing[cmdReqId];
1958 pCmd->pReqPrv = (void*)cmdReqId;
1959
1960 CESA_TEST_LOCK(flags);
1961
1962 rc = mvCesaAction(pCmd);
1963 if(rc == MV_NO_RESOURCE)
1964 cesaTestFull = 1;
1965
1966 CESA_TEST_UNLOCK(flags);
1967
1968 if(rc == MV_NO_RESOURCE)
1969 {
1970 CESA_TEST_LOCK(flags);
1971 CESA_TEST_WAIT( (cesaTestFull == 0), 100);
1972 CESA_TEST_UNLOCK(flags);
1973 if(cesaTestFull == 1)
1974 {
1975 mvOsPrintf("CESA Test timeout: i=%d, iter=%d, cesaTestFull=%d\n",
1976 i, iter, cesaTestFull);
1977 cesaTestFull = 0;
1978 return MV_TIMEOUT;
1979 }
1980
1981 CESA_TEST_LOCK(flags);
1982
1983 rc = mvCesaAction(pCmd);
1984
1985 CESA_TEST_UNLOCK(flags);
1986 }
1987 if( (rc != MV_OK) && (rc != MV_NO_MORE) )
1988 {
1989 mvOsPrintf("mvCesaAction failed: rc=%d\n", rc);
1990 return rc;
1991 }
1992
1993 cmdReqId++;
1994 if(cmdReqId >= CESA_DEF_REQ_SIZE)
1995 cmdReqId = 0;
1996
1997 #ifdef MV_LINUX
1998 /* Reschedule each 16 requests */
1999 if( (i & 0xF) == 0)
2000 schedule();
2001 #endif
2002 }
2003 return MV_OK;
2004 }
2005
2006 void cesaTestStart(int bufNum, int bufSize)
2007 {
2008 int i, j, idx;
2009 MV_CESA_MBUF *pMbufSrc, *pMbufDst;
2010 MV_BUF_INFO *pFragsSrc, *pFragsDst;
2011 char *pBuf;
2012 #ifndef MV_NETBSD
2013 int numOfSessions, queueDepth;
2014 char *pSram;
2015 MV_STATUS status;
2016 MV_CPU_DEC_WIN addrDecWin;
2017 #endif
2018
2019 cesaCmdRing = mvOsMalloc(sizeof(MV_CESA_COMMAND) * CESA_DEF_REQ_SIZE);
2020 if(cesaCmdRing == NULL)
2021 {
2022 mvOsPrintf("testStart: Can't allocate %ld bytes of memory\n",
2023 sizeof(MV_CESA_COMMAND) * CESA_DEF_REQ_SIZE);
2024 return;
2025 }
2026 memset(cesaCmdRing, 0, sizeof(MV_CESA_COMMAND) * CESA_DEF_REQ_SIZE);
2027
2028 if(bufNum == 0)
2029 bufNum = CESA_DEF_BUF_NUM;
2030
2031 if(bufSize == 0)
2032 bufSize = CESA_DEF_BUF_SIZE;
2033
2034 cesaBufNum = bufNum;
2035 cesaBufSize = bufSize;
2036 mvOsPrintf("CESA test started: bufNum = %d, bufSize = %d\n",
2037 bufNum, bufSize);
2038
2039 cesaHexBuffer = mvOsMalloc(2*bufNum*bufSize);
2040 if(cesaHexBuffer == NULL)
2041 {
2042 mvOsPrintf("testStart: Can't malloc %d bytes for cesaHexBuffer.\n",
2043 2*bufNum*bufSize);
2044 return;
2045 }
2046 memset(cesaHexBuffer, 0, (2*bufNum*bufSize));
2047
2048 cesaBinBuffer = mvOsMalloc(bufNum*bufSize);
2049 if(cesaBinBuffer == NULL)
2050 {
2051 mvOsPrintf("testStart: Can't malloc %d bytes for cesaBinBuffer\n",
2052 bufNum*bufSize);
2053 return;
2054 }
2055 memset(cesaBinBuffer, 0, (bufNum*bufSize));
2056
2057 cesaExpBinBuffer = mvOsMalloc(bufNum*bufSize);
2058 if(cesaExpBinBuffer == NULL)
2059 {
2060 mvOsPrintf("testStart: Can't malloc %d bytes for cesaExpBinBuffer\n",
2061 bufNum*bufSize);
2062 return;
2063 }
2064 memset(cesaExpBinBuffer, 0, (bufNum*bufSize));
2065
2066 CESA_TEST_WAIT_INIT();
2067
2068 pMbufSrc = mvOsMalloc(sizeof(MV_CESA_MBUF) * CESA_DEF_REQ_SIZE);
2069 pFragsSrc = mvOsMalloc(sizeof(MV_BUF_INFO) * bufNum * CESA_DEF_REQ_SIZE);
2070
2071 pMbufDst = mvOsMalloc(sizeof(MV_CESA_MBUF) * CESA_DEF_REQ_SIZE);
2072 pFragsDst = mvOsMalloc(sizeof(MV_BUF_INFO) * bufNum * CESA_DEF_REQ_SIZE);
2073
2074 if( (pMbufSrc == NULL) || (pFragsSrc == NULL) ||
2075 (pMbufDst == NULL) || (pFragsDst == NULL) )
2076 {
2077 mvOsPrintf("testStart: Can't malloc Src and Dst pMbuf and pFrags structures.\n");
2078 /* !!!! Dima cesaTestCleanup();*/
2079 return;
2080 }
2081
2082 memset(pMbufSrc, 0, sizeof(MV_CESA_MBUF) * CESA_DEF_REQ_SIZE);
2083 memset(pFragsSrc, 0, sizeof(MV_BUF_INFO) * bufNum * CESA_DEF_REQ_SIZE);
2084
2085 memset(pMbufDst, 0, sizeof(MV_CESA_MBUF) * CESA_DEF_REQ_SIZE);
2086 memset(pFragsDst, 0, sizeof(MV_BUF_INFO) * bufNum * CESA_DEF_REQ_SIZE);
2087
2088 mvOsPrintf("Cesa Test Start: pMbufSrc=%p, pFragsSrc=%p, pMbufDst=%p, pFragsDst=%p\n",
2089 pMbufSrc, pFragsSrc, pMbufDst, pFragsDst);
2090
2091 idx = 0;
2092 for(i=0; i<CESA_DEF_REQ_SIZE; i++)
2093 {
2094 pBuf = mvOsIoCachedMalloc(cesaTestOSHandle,bufSize * bufNum * 2,
2095 &cesaReqBufs[i].bufPhysAddr,
2096 &cesaReqBufs[i].memHandle);
2097 if(pBuf == NULL)
2098 {
2099 mvOsPrintf("testStart: Can't malloc %d bytes for pBuf\n",
2100 bufSize * bufNum * 2);
2101 return;
2102 }
2103
2104 memset(pBuf, 0, bufSize * bufNum * 2);
2105 mvOsCacheFlush(cesaTestOSHandle,pBuf, bufSize * bufNum * 2);
2106 if(pBuf == NULL)
2107 {
2108 mvOsPrintf("cesaTestStart: Can't allocate %d bytes for req_%d buffers\n",
2109 bufSize * bufNum * 2, i);
2110 return;
2111 }
2112
2113 cesaReqBufs[i].bufVirtPtr = (MV_U8*)pBuf;
2114 cesaReqBufs[i].bufSize = bufSize * bufNum * 2;
2115
2116 cesaCmdRing[i].pSrc = &pMbufSrc[i];
2117 cesaCmdRing[i].pSrc->pFrags = &pFragsSrc[idx];
2118 cesaCmdRing[i].pSrc->numFrags = bufNum;
2119 cesaCmdRing[i].pSrc->mbufSize = 0;
2120
2121 cesaCmdRing[i].pDst = &pMbufDst[i];
2122 cesaCmdRing[i].pDst->pFrags = &pFragsDst[idx];
2123 cesaCmdRing[i].pDst->numFrags = bufNum;
2124 cesaCmdRing[i].pDst->mbufSize = 0;
2125
2126 for(j=0; j<bufNum; j++)
2127 {
2128 cesaCmdRing[i].pSrc->pFrags[j].bufVirtPtr = (MV_U8*)pBuf;
2129 cesaCmdRing[i].pSrc->pFrags[j].bufSize = bufSize;
2130 pBuf += bufSize;
2131 cesaCmdRing[i].pDst->pFrags[j].bufVirtPtr = (MV_U8*)pBuf;
2132 cesaCmdRing[i].pDst->pFrags[j].bufSize = bufSize;
2133 pBuf += bufSize;
2134 }
2135 idx += bufNum;
2136 }
2137
2138 #ifndef MV_NETBSD
2139 if (mvCpuIfTargetWinGet(CRYPT_ENG, &addrDecWin) == MV_OK)
2140 pSram = (char*)addrDecWin.addrWin.baseLow;
2141 else
2142 {
2143 mvOsPrintf("mvCesaInit: ERR. mvCpuIfTargetWinGet failed\n");
2144 return;
2145 }
2146
2147 #ifdef MV_CESA_NO_SRAM
2148 pSram = mvOsMalloc(4*1024+8);
2149 if(pSram == NULL)
2150 {
2151 mvOsPrintf("CesaTest: can't allocate %d bytes for SRAM simulation\n",
2152 4*1024+8);
2153 /* !!!! Dima cesaTestCleanup();*/
2154 return;
2155 }
2156 pSram = (MV_U8*)MV_ALIGN_UP((MV_U32)pSram, 8);
2157 #endif /* MV_CESA_NO_SRAM */
2158
2159 numOfSessions = CESA_DEF_SESSION_NUM;
2160 queueDepth = CESA_DEF_REQ_SIZE - MV_CESA_MAX_CHAN;
2161
2162 status = mvCesaInit(numOfSessions, queueDepth, pSram, NULL);
2163 if(status != MV_OK)
2164 {
2165 mvOsPrintf("mvCesaInit is Failed: status = 0x%x\n", status);
2166 /* !!!! Dima cesaTestCleanup();*/
2167 return;
2168 }
2169 #endif /* !MV_NETBSD */
2170
2171 /* Prepare data for tests */
2172 for(i=0; i<50; i++)
2173 strcat((char*)cesaDataHexStr3, "dd");
2174
2175 strcpy((char*)cesaDataAndMd5digest3, cesaDataHexStr3);
2176 strcpy((char*)cesaDataAndSha1digest3, cesaDataHexStr3);
2177
2178 /* Digest must be 8 byte aligned */
2179 for(; i<56; i++)
2180 {
2181 strcat((char*)cesaDataAndMd5digest3, "00");
2182 strcat((char*)cesaDataAndSha1digest3, "00");
2183 }
2184 strcat((char*)cesaDataAndMd5digest3, cesaHmacMd5digestHex3);
2185 strcat((char*)cesaDataAndSha1digest3, cesaHmacSha1digestHex3);
2186
2187 #ifndef MV_NETBSD
2188 MV_REG_WRITE( MV_CESA_ISR_CAUSE_REG, 0);
2189 MV_REG_WRITE( MV_CESA_ISR_MASK_REG, MV_CESA_CAUSE_ACC_DMA_MASK);
2190 #endif
2191
2192 #ifdef MV_VXWORKS
2193 {
2194 MV_STATUS status;
2195
2196 status = intConnect((VOIDFUNCPTR *)INT_LVL_CESA, cesaTestReadyIsr, (int)NULL);
2197 if (status != OK)
2198 {
2199 mvOsPrintf("CESA: Can't connect CESA (%d) interrupt, status=0x%x \n",
2200 INT_LVL_CESA, status);
2201 /* !!!! Dima cesaTestCleanup();*/
2202 return;
2203 }
2204 cesaSemId = semMCreate(SEM_Q_PRIORITY | SEM_INVERSION_SAFE | SEM_DELETE_SAFE);
2205 if(cesaSemId == NULL)
2206 {
2207 mvOsPrintf("cesaTestStart: Can't create semaphore\n");
2208 return;
2209 }
2210 intEnable(INT_LVL_CESA);
2211 }
2212 #endif /* MV_VXWORKS */
2213
2214 #if !defined(MV_NETBSD) && defined(__KERNEL__)
2215 if( request_irq(CESA_IRQ, cesaTestReadyIsr, (SA_INTERRUPT) , "cesa_test", NULL ) )
2216 {
2217 mvOsPrintf( "cannot assign irq\n" );
2218 /* !!!! Dima cesaTestCleanup();*/
2219 return;
2220 }
2221 spin_lock_init( &cesaLock );
2222 #endif
2223 }
2224
2225 MV_STATUS testRun(int idx, int caseIdx, int iter,
2226 int reqSize, int checkMode)
2227 {
2228 int testIdx, count, sid, digestSize;
2229 int blockSize;
2230 MV_CESA_TEST_SESSION* pTestSession;
2231 MV_CESA_COMMAND cmd;
2232 MV_STATUS status;
2233
2234 memset(&cmd, 0, sizeof(cmd));
2235
2236 pTestSession = getTestSessionDb(idx, &testIdx);
2237 if(pTestSession == NULL)
2238 {
2239 mvOsPrintf("Test %d is not exist\n", idx);
2240 return MV_BAD_PARAM;
2241 }
2242 pTestSession = &pTestSession[testIdx];
2243
2244 sid = pTestSession->sid;
2245 if(sid == -1)
2246 {
2247 mvOsPrintf("Test %d is not opened\n", idx);
2248 return MV_BAD_STATE;
2249 }
2250 switch(pTestSession->cryptoAlgorithm)
2251 {
2252 case MV_CESA_CRYPTO_DES:
2253 case MV_CESA_CRYPTO_3DES:
2254 blockSize = MV_CESA_DES_BLOCK_SIZE;
2255 break;
2256
2257 case MV_CESA_CRYPTO_AES:
2258 blockSize = MV_CESA_AES_BLOCK_SIZE;
2259 break;
2260
2261 case MV_CESA_CRYPTO_NULL:
2262 blockSize = 0;
2263 break;
2264
2265 default:
2266 mvOsPrintf("cesaTestRun: Bad CryptoAlgorithm=%d\n",
2267 pTestSession->cryptoAlgorithm);
2268 return MV_BAD_PARAM;
2269 }
2270 switch(pTestSession->macAlgorithm)
2271 {
2272 case MV_CESA_MAC_MD5:
2273 case MV_CESA_MAC_HMAC_MD5:
2274 digestSize = MV_CESA_MD5_DIGEST_SIZE;
2275 break;
2276
2277 case MV_CESA_MAC_SHA1:
2278 case MV_CESA_MAC_HMAC_SHA1:
2279 digestSize = MV_CESA_SHA1_DIGEST_SIZE;
2280 break;
2281 default:
2282 digestSize = 0;
2283 }
2284
2285 if(iter == 0)
2286 iter = CESA_DEF_ITER_NUM;
2287
2288 if(pTestSession->direction == MV_CESA_DIR_ENCODE)
2289 {
2290 cesaOutputHexStr = cesaTestCases[caseIdx].cipherHexStr;
2291 cesaInputHexStr = cesaTestCases[caseIdx].plainHexStr;
2292 }
2293 else
2294 {
2295 cesaOutputHexStr = cesaTestCases[caseIdx].plainHexStr;
2296 cesaInputHexStr = cesaTestCases[caseIdx].cipherHexStr;
2297 }
2298
2299 cmd.sessionId = sid;
2300 if(checkMode == CESA_FAST_CHECK_MODE)
2301 {
2302 cmd.cryptoLength = cesaTestCases[caseIdx].cryptoLength;
2303 cmd.macLength = cesaTestCases[caseIdx].macLength;
2304 }
2305 else
2306 {
2307 cmd.cryptoLength = reqSize;
2308 cmd.macLength = reqSize;
2309 }
2310 cesaRateSize = cmd.cryptoLength;
2311 cesaReqSize = cmd.cryptoLength;
2312 cmd.cryptoOffset = 0;
2313 if(pTestSession->operation != MV_CESA_MAC_ONLY)
2314 {
2315 if( (pTestSession->cryptoMode == MV_CESA_CRYPTO_CBC) ||
2316 (pTestSession->cryptoMode == MV_CESA_CRYPTO_CTR) )
2317 {
2318 cmd.ivOffset = 0;
2319 cmd.cryptoOffset = blockSize;
2320 if(cesaTestCases[caseIdx].pCryptoIV == NULL)
2321 {
2322 cmd.ivFromUser = 1;
2323 }
2324 else
2325 {
2326 cmd.ivFromUser = 0;
2327 mvCesaCryptoIvSet(cesaTestCases[caseIdx].pCryptoIV, blockSize);
2328 }
2329 cesaReqSize = cmd.cryptoOffset + cmd.cryptoLength;
2330 }
2331 }
2332
2333 /*
2334 mvOsPrintf("ivFromUser=%d, cryptoLength=%d, cesaReqSize=%d, cryptoOffset=%d\n",
2335 cmd.ivFromUser, cmd.cryptoLength, cesaReqSize, cmd.cryptoOffset);
2336 */
2337 if(pTestSession->operation != MV_CESA_CRYPTO_ONLY)
2338 {
2339 cmd.macOffset = cmd.cryptoOffset;
2340
2341 if(cesaTestCases[caseIdx].digestOffset == -1)
2342 {
2343 cmd.digestOffset = cmd.macOffset + cmd.macLength;
2344 cmd.digestOffset = MV_ALIGN_UP(cmd.digestOffset, 8);
2345 }
2346 else
2347 {
2348 cmd.digestOffset = cesaTestCases[caseIdx].digestOffset;
2349 }
2350 if( (cmd.digestOffset + digestSize) > cesaReqSize)
2351 cesaReqSize = cmd.digestOffset + digestSize;
2352 }
2353
2354 cesaCheckMode = checkMode;
2355
2356 if(checkMode == CESA_NULL_CHECK_MODE)
2357 {
2358 cesaCheckSize = 0;
2359 cesaCheckOffset = 0;
2360 }
2361 else
2362 {
2363 if(pTestSession->operation == MV_CESA_CRYPTO_ONLY)
2364 {
2365 cesaCheckOffset = 0;
2366 cesaCheckSize = cmd.cryptoLength;
2367 }
2368 else
2369 {
2370 cesaCheckSize = digestSize;
2371 cesaCheckOffset = cmd.digestOffset;
2372 }
2373 }
2374 /*
2375 mvOsPrintf("reqSize=%d, checkSize=%d, checkOffset=%d, checkMode=%d\n",
2376 cesaReqSize, cesaCheckSize, cesaCheckOffset, cesaCheckMode);
2377
2378 mvOsPrintf("blockSize=%d, ivOffset=%d, ivFromUser=%d, crOffset=%d, crLength=%d\n",
2379 blockSize, cmd.ivOffset, cmd.ivFromUser,
2380 cmd.cryptoOffset, cmd.cryptoLength);
2381
2382 mvOsPrintf("macOffset=%d, digestOffset=%d, macLength=%d\n",
2383 cmd.macOffset, cmd.digestOffset, cmd.macLength);
2384 */
2385 status = testCmd(sid, iter, &cmd, pTestSession,
2386 cesaTestCases[caseIdx].pCryptoIV, blockSize);
2387
2388 if(status != MV_OK)
2389 return status;
2390
2391 /* Wait when all callbacks is received */
2392 count = 0;
2393 while(cesaIsReady == MV_FALSE)
2394 {
2395 mvOsSleep(10);
2396 count++;
2397 if(count > 100)
2398 {
2399 mvOsPrintf("testRun: Timeout occured\n");
2400 return MV_TIMEOUT;
2401 }
2402 }
2403
2404 return MV_OK;
2405 }
2406
2407
2408 void cesaTestStop(void)
2409 {
2410 MV_CESA_MBUF *pMbufSrc, *pMbufDst;
2411 MV_BUF_INFO *pFragsSrc, *pFragsDst;
2412 int i;
2413
2414 /* Release all allocated memories */
2415 pMbufSrc = (MV_CESA_MBUF*)(cesaCmdRing[0].pSrc);
2416 pFragsSrc = cesaCmdRing[0].pSrc->pFrags;
2417
2418 pMbufDst = (MV_CESA_MBUF*)(cesaCmdRing[0].pDst);
2419 pFragsDst = cesaCmdRing[0].pDst->pFrags;
2420
2421 mvOsFree(pMbufSrc);
2422 mvOsFree(pMbufDst);
2423 mvOsFree(pFragsSrc);
2424 mvOsFree(pFragsDst);
2425
2426 for(i=0; i<CESA_DEF_REQ_SIZE; i++)
2427 {
2428 mvOsIoCachedFree(cesaTestOSHandle,cesaReqBufs[i].bufSize,
2429 cesaReqBufs[i].bufPhysAddr,cesaReqBufs[i].bufVirtPtr,
2430 cesaReqBufs[i].memHandle);
2431 }
2432 cesaDataHexStr3[0] = '\0';
2433 }
2434
2435 void desTest(int iter, int reqSize, int checkMode)
2436 {
2437 int mode, i;
2438 MV_STATUS status;
2439
2440 mode = checkMode;
2441 if(checkMode == CESA_FULL_CHECK_MODE)
2442 mode = CESA_FAST_CHECK_MODE;
2443 i = iter;
2444 if(mode != CESA_NULL_CHECK_MODE)
2445 i = 1;
2446
2447 testOpen(0);
2448 testOpen(1);
2449 testOpen(2);
2450 testOpen(3);
2451
2452 /* DES / ECB mode / Encrypt only */
2453 status = testRun(0, 1, iter, reqSize, checkMode);
2454 printTestResults(0, status, checkMode);
2455
2456 /* DES / ECB mode / Decrypt only */
2457 status = testRun(1, 1, iter, reqSize, checkMode);
2458 printTestResults(1, status, checkMode);
2459
2460 /* DES / CBC mode / Encrypt only */
2461 status = testRun(2, 2, i, reqSize, mode);
2462 printTestResults(2, status, mode);
2463
2464 /* DES / CBC mode / Decrypt only */
2465 status = testRun(3, 2, iter, reqSize, mode);
2466 printTestResults(3, status, mode);
2467
2468 testClose(0);
2469 testClose(1);
2470 testClose(2);
2471 testClose(3);
2472 }
2473
2474 void tripleDesTest(int iter, int reqSize, int checkMode)
2475 {
2476 int mode, i;
2477 MV_STATUS status;
2478
2479 mode = checkMode;
2480 if(checkMode == CESA_FULL_CHECK_MODE)
2481 mode = CESA_FAST_CHECK_MODE;
2482 i = iter;
2483 if(mode != CESA_NULL_CHECK_MODE)
2484 i = 1;
2485
2486 testOpen(100);
2487 testOpen(101);
2488 testOpen(102);
2489 testOpen(103);
2490
2491 /* 3DES / ECB mode / Encrypt only */
2492 status = testRun(100, 1, iter, reqSize, checkMode);
2493 printTestResults(100, status, checkMode);
2494
2495 /* 3DES / ECB mode / Decrypt only */
2496 status = testRun(101, 1, iter, reqSize, checkMode);
2497 printTestResults(101, status, checkMode);
2498
2499 /* 3DES / CBC mode / Encrypt only */
2500 status = testRun(102, 2, i, reqSize, mode);
2501 printTestResults(102, status, mode);
2502
2503 /* 3DES / CBC mode / Decrypt only */
2504 status = testRun(103, 2, iter, reqSize, mode);
2505 printTestResults(103, status, mode);
2506
2507 testClose(100);
2508 testClose(101);
2509 testClose(102);
2510 testClose(103);
2511 }
2512
2513 void aesTest(int iter, int reqSize, int checkMode)
2514 {
2515 MV_STATUS status;
2516 int mode, i;
2517
2518 mode = checkMode;
2519 if(checkMode == CESA_FULL_CHECK_MODE)
2520 mode = CESA_FAST_CHECK_MODE;
2521
2522 i = iter;
2523 if(mode != CESA_NULL_CHECK_MODE)
2524 i = 1;
2525
2526 testOpen(200);
2527 testOpen(201);
2528 testOpen(202);
2529 testOpen(203);
2530 testOpen(204);
2531 testOpen(205);
2532 testOpen(206);
2533 testOpen(207);
2534 testOpen(208);
2535
2536 /* AES-128 Encode ECB mode */
2537 status = testRun(200, 3, iter, reqSize, checkMode);
2538 printTestResults(200, status, checkMode);
2539
2540 /* AES-128 Decode ECB mode */
2541 status = testRun(201, 3, iter, reqSize, checkMode);
2542 printTestResults(201, status, checkMode);
2543
2544 /* AES-128 Encode CBC mode (IV from SA) */
2545 status = testRun(202, 10, i, reqSize, mode);
2546 printTestResults(202, status, mode);
2547
2548 /* AES-128 Encode CBC mode (IV from User) */
2549 status = testRun(202, 24, i, reqSize, mode);
2550 printTestResults(202, status, mode);
2551
2552 /* AES-128 Decode CBC mode */
2553 status = testRun(203, 24, iter, reqSize, mode);
2554 printTestResults(203, status, checkMode);
2555
2556 /* AES-192 Encode ECB mode */
2557 status = testRun(204, 4, iter, reqSize, checkMode);
2558 printTestResults(204, status, checkMode);
2559
2560 /* AES-192 Decode ECB mode */
2561 status = testRun(205, 4, iter, reqSize, checkMode);
2562 printTestResults(205, status, checkMode);
2563
2564 /* AES-256 Encode ECB mode */
2565 status = testRun(206, 5, iter, reqSize, checkMode);
2566 printTestResults(206, status, checkMode);
2567
2568 /* AES-256 Decode ECB mode */
2569 status = testRun(207, 5, iter, reqSize, checkMode);
2570 printTestResults(207, status, checkMode);
2571
2572 #if defined(MV_LINUX)
2573 /* AES-128 Encode CTR mode */
2574 status = testRun(208, 23, iter, reqSize, mode);
2575 printTestResults(208, status, checkMode);
2576 #endif
2577 testClose(200);
2578 testClose(201);
2579 testClose(202);
2580 testClose(203);
2581 testClose(204);
2582 testClose(205);
2583 testClose(206);
2584 testClose(207);
2585 testClose(208);
2586 }
2587
2588
2589 void mdTest(int iter, int reqSize, int checkMode)
2590 {
2591 int mode;
2592 MV_STATUS status;
2593
2594 if(iter == 0)
2595 iter = CESA_DEF_ITER_NUM;
2596
2597 mode = checkMode;
2598 if(checkMode == CESA_FULL_CHECK_MODE)
2599 mode = CESA_FAST_CHECK_MODE;
2600
2601 testOpen(300);
2602 testOpen(301);
2603 testOpen(302);
2604 testOpen(303);
2605 testOpen(305);
2606
2607 /* HMAC-MD5 Generate signature test */
2608 status = testRun(300, 6, iter, reqSize, mode);
2609 printTestResults(300, status, checkMode);
2610
2611 /* HMAC-MD5 Verify Signature test */
2612 status = testRun(301, 7, iter, reqSize, mode);
2613 printTestResults(301, status, checkMode);
2614
2615 /* HMAC-MD5 Generate signature test */
2616 status = testRun(302, 8, iter, reqSize, mode);
2617 printTestResults(302, status, checkMode);
2618
2619 /* HMAC-MD5 Verify Signature test */
2620 status = testRun(303, 9, iter, reqSize, mode);
2621 printTestResults(303, status, checkMode);
2622
2623 /* HASH-MD5 Generate signature test */
2624 status = testRun(305, 15, iter, reqSize, mode);
2625 printTestResults(305, status, checkMode);
2626
2627 testClose(300);
2628 testClose(301);
2629 testClose(302);
2630 testClose(303);
2631 testClose(305);
2632 }
2633
2634 void shaTest(int iter, int reqSize, int checkMode)
2635 {
2636 int mode;
2637 MV_STATUS status;
2638
2639 if(iter == 0)
2640 iter = CESA_DEF_ITER_NUM;
2641
2642 mode = checkMode;
2643 if(checkMode == CESA_FULL_CHECK_MODE)
2644 mode = CESA_FAST_CHECK_MODE;
2645
2646 testOpen(400);
2647 testOpen(401);
2648 testOpen(402);
2649 testOpen(403);
2650 testOpen(405);
2651
2652 /* HMAC-SHA1 Generate signature test */
2653 status = testRun(400, 11, iter, reqSize, mode);
2654 printTestResults(400, status, checkMode);
2655
2656 /* HMAC-SHA1 Verify Signature test */
2657 status = testRun(401, 12, iter, reqSize, mode);
2658 printTestResults(401, status, checkMode);
2659
2660 /* HMAC-SHA1 Generate signature test */
2661 status = testRun(402, 13, iter, reqSize, mode);
2662 printTestResults(402, status, checkMode);
2663
2664 /* HMAC-SHA1 Verify Signature test */
2665 status = testRun(403, 14, iter, reqSize, mode);
2666 printTestResults(403, status, checkMode);
2667
2668 /* HMAC-SHA1 Generate signature test */
2669 status = testRun(405, 16, iter, reqSize, mode);
2670 printTestResults(405, status, checkMode);
2671
2672 testClose(400);
2673 testClose(401);
2674 testClose(402);
2675 testClose(403);
2676 testClose(405);
2677 }
2678
2679 void combiTest(int iter, int reqSize, int checkMode)
2680 {
2681 MV_STATUS status;
2682 int mode, i;
2683
2684 mode = checkMode;
2685 if(checkMode == CESA_FULL_CHECK_MODE)
2686 mode = CESA_FAST_CHECK_MODE;
2687
2688 if(iter == 0)
2689 iter = CESA_DEF_ITER_NUM;
2690
2691 i = iter;
2692 if(mode != CESA_NULL_CHECK_MODE)
2693 i = 1;
2694
2695 testOpen(500);
2696 testOpen(501);
2697 testOpen(502);
2698 testOpen(503);
2699 testOpen(504);
2700 testOpen(505);
2701 testOpen(506);
2702 testOpen(507);
2703
2704 /* DES ECB + MD5 encode test */
2705 status = testRun(500, 17, iter, reqSize, mode);
2706 printTestResults(500, status, mode);
2707
2708 /* DES ECB + SHA1 encode test */
2709 status = testRun(501, 18, iter, reqSize, mode);
2710 printTestResults(501, status, mode);
2711
2712 /* 3DES ECB + MD5 encode test */
2713 status = testRun(502, 17, iter, reqSize, mode);
2714 printTestResults(502, status, mode);
2715
2716 /* 3DES ECB + SHA1 encode test */
2717 status = testRun(503, 18, iter, reqSize, mode);
2718 printTestResults(503, status, mode);
2719
2720 /* 3DES CBC + MD5 encode test */
2721 status = testRun(504, 19, i, reqSize, mode);
2722 printTestResults(504, status, mode);
2723
2724 /* 3DES CBC + SHA1 encode test */
2725 status = testRun(505, 20, i, reqSize, mode);
2726 printTestResults(505, status, mode);
2727
2728 /* AES-128 CBC + MD5 encode test */
2729 status = testRun(506, 21, i, reqSize, mode);
2730 printTestResults(506, status, mode);
2731
2732 /* AES-128 CBC + SHA1 encode test */
2733 status = testRun(507, 22, i, reqSize, mode);
2734 printTestResults(507, status, mode);
2735
2736 testClose(500);
2737 testClose(501);
2738 testClose(502);
2739 testClose(503);
2740 testClose(504);
2741 testClose(505);
2742 testClose(506);
2743 testClose(507);
2744 }
2745
2746 void cesaOneTest(int testIdx, int caseIdx,
2747 int iter, int reqSize, int checkMode)
2748 {
2749 MV_STATUS status;
2750
2751 if(iter == 0)
2752 iter = CESA_DEF_ITER_NUM;
2753
2754 mvOsPrintf("test=%d, case=%d, size=%d, iter=%d\n",
2755 testIdx, caseIdx, reqSize, iter);
2756
2757 status = testOpen(testIdx);
2758
2759 status = testRun(testIdx, caseIdx, iter, reqSize, checkMode);
2760 printTestResults(testIdx, status, checkMode);
2761 status = testClose(testIdx);
2762
2763 }
2764
2765 void cesaTest(int iter, int reqSize, int checkMode)
2766 {
2767 if(iter == 0)
2768 iter = CESA_DEF_ITER_NUM;
2769
2770 mvOsPrintf("%d iteration\n", iter);
2771 mvOsPrintf("%d size\n\n", reqSize);
2772
2773 /* DES tests */
2774 desTest(iter, reqSize, checkMode);
2775
2776 /* 3DES tests */
2777 tripleDesTest(iter, reqSize, checkMode);
2778
2779 /* AES tests */
2780 aesTest(iter, reqSize, checkMode);
2781
2782 /* MD5 tests */
2783 mdTest(iter, reqSize, checkMode);
2784
2785 /* SHA-1 tests */
2786 shaTest(iter, reqSize, checkMode);
2787 }
2788
2789 void multiSizeTest(int idx, int iter, int checkMode, char* inputData)
2790 {
2791 MV_STATUS status;
2792 int i;
2793 MV_CESA_SIZE_TEST* pMultiTest;
2794
2795 if( testOpen(idx) != MV_OK)
2796 return;
2797
2798 if(iter == 0)
2799 iter = CESA_DEF_ITER_NUM;
2800
2801 if(checkMode == CESA_SHOW_CHECK_MODE)
2802 {
2803 iter = 1;
2804 }
2805 else
2806 checkMode = CESA_FULL_CHECK_MODE;
2807
2808 cesaTestCases[0].plainHexStr = inputData;
2809 cesaTestCases[0].pCryptoIV = NULL;
2810
2811 switch(idx)
2812 {
2813 case 302:
2814 pMultiTest = mdMultiSizeTest302;
2815 if(inputData == NULL)
2816 cesaTestCases[0].plainHexStr = cesaDataHexStr3;
2817 break;
2818
2819 case 304:
2820 pMultiTest = mdMultiSizeTest304;
2821 if(inputData == NULL)
2822 cesaTestCases[0].plainHexStr = hashHexStr80;
2823 break;
2824
2825 case 305:
2826 pMultiTest = mdMultiSizeTest305;
2827 if(inputData == NULL)
2828 cesaTestCases[0].plainHexStr = hashHexStr80;
2829 break;
2830
2831 case 402:
2832 pMultiTest = shaMultiSizeTest402;
2833 if(inputData == NULL)
2834 cesaTestCases[0].plainHexStr = hashHexStr80;
2835 break;
2836
2837 case 404:
2838 pMultiTest = shaMultiSizeTest404;
2839 if(inputData == NULL)
2840 cesaTestCases[0].plainHexStr = hashHexStr80;
2841 break;
2842
2843 case 405:
2844 pMultiTest = shaMultiSizeTest405;
2845 if(inputData == NULL)
2846 cesaTestCases[0].plainHexStr = hashHexStr80;
2847 break;
2848
2849 case 502:
2850 pMultiTest = tripleDesMdMultiSizeTest502;
2851 if(inputData == NULL)
2852 cesaTestCases[0].plainHexStr = hashHexStr80;
2853 break;
2854
2855 case 503:
2856 pMultiTest = tripleDesShaMultiSizeTest503;
2857 if(inputData == NULL)
2858 cesaTestCases[0].plainHexStr = hashHexStr80;
2859 break;
2860
2861 case 504:
2862 iter = 1;
2863 pMultiTest = cbc3desMdMultiSizeTest504;
2864 cesaTestCases[0].pCryptoIV = iv1;
2865 if(inputData == NULL)
2866 cesaTestCases[0].plainHexStr = hashHexStr80;
2867 break;
2868
2869 case 505:
2870 iter = 1;
2871 pMultiTest = cbc3desShaMultiSizeTest505;
2872 cesaTestCases[0].pCryptoIV = iv1;
2873 if(inputData == NULL)
2874 cesaTestCases[0].plainHexStr = hashHexStr80;
2875 break;
2876
2877 case 506:
2878 iter = 1;
2879 pMultiTest = cbcAes128md5multiSizeTest506;
2880 cesaTestCases[0].pCryptoIV = iv5;
2881 if(inputData == NULL)
2882 cesaTestCases[0].plainHexStr = hashHexStr80;
2883 break;
2884
2885 case 507:
2886 iter = 1;
2887 pMultiTest = cbcAes128sha1multiSizeTest507;
2888 cesaTestCases[0].pCryptoIV = iv5;
2889 if(inputData == NULL)
2890 cesaTestCases[0].plainHexStr = hashHexStr80;
2891 break;
2892
2893 default:
2894 iter = 1;
2895 checkMode = CESA_SHOW_CHECK_MODE;
2896 pMultiTest = mdMultiSizeTest302;
2897 if(inputData == NULL)
2898 cesaTestCases[0].plainHexStr = hashHexStr80;
2899 }
2900 i = 0;
2901 while(pMultiTest[i].outputHexStr != NULL)
2902 {
2903 cesaTestCases[0].cipherHexStr = (char *)pMultiTest[i].outputHexStr;
2904 status = testRun(idx, 0, iter, pMultiTest[i].size,
2905 checkMode);
2906 if(checkMode != CESA_SHOW_CHECK_MODE)
2907 {
2908 cesaReqSize = pMultiTest[i].size;
2909 printTestResults(idx, status, checkMode);
2910 }
2911 if(status != MV_OK)
2912 break;
2913 i++;
2914 }
2915 testClose(idx);
2916 /*
2917 mvCesaDebugStatus();
2918 cesaTestPrintStatus();
2919 */
2920 }
2921
2922 void open_session_test(int idx, int caseIdx, int iter)
2923 {
2924 int reqIdError, cryptoError, openErrors, i;
2925 int openErrDisp[100];
2926 MV_STATUS status;
2927
2928 memset(openErrDisp, 0, sizeof(openErrDisp));
2929 openErrors = 0;
2930 reqIdError = 0;
2931 cryptoError = 0;
2932 for(i=0; i<iter; i++)
2933 {
2934 status = testOpen(idx);
2935 if(status != MV_OK)
2936 {
2937 openErrors++;
2938 openErrDisp[status]++;
2939 }
2940 else
2941 {
2942 testRun(idx, caseIdx, 1, 0, CESA_FAST_CHECK_MODE);
2943 if(cesaCryptoError > 0)
2944 cryptoError++;
2945 if(cesaReqIdError > 0)
2946 reqIdError++;
2947
2948 testClose(idx);
2949 }
2950 }
2951 if(cryptoError > 0)
2952 mvOsPrintf("cryptoError : %d\n", cryptoError);
2953 if(reqIdError > 0)
2954 mvOsPrintf("reqIdError : %d\n", reqIdError);
2955
2956 if(openErrors > 0)
2957 {
2958 mvOsPrintf("Open Errors = %d\n", openErrors);
2959 for(i=0; i<100; i++)
2960 {
2961 if(openErrDisp[i] != 0)
2962 mvOsPrintf("Error %d - occurs %d times\n", i, openErrDisp[i]);
2963 }
2964 }
2965 }
2966
2967
2968 void loopback_test(int idx, int iter, int size, char* pPlainData)
2969 {
2970 }
2971
2972
2973 #if defined(MV_VXWORKS)
2974 int testMode = 0;
2975 unsigned __TASKCONV cesaTask(void* args)
2976 {
2977 int reqSize = cesaReqSize;
2978
2979 if(testMode == 0)
2980 {
2981 cesaOneTest(cesaTestIdx, cesaCaseIdx, cesaIteration,
2982 reqSize, cesaCheckMode);
2983 }
2984 else
2985 {
2986 if(testMode == 1)
2987 {
2988 cesaTest(cesaIteration, reqSize, cesaCheckMode);
2989 combiTest(cesaIteration, reqSize, cesaCheckMode);
2990 }
2991 else
2992 {
2993 multiSizeTest(cesaIdx, cesaIteration, cesaCheckMode, NULL);
2994 }
2995 }
2996 return 0;
2997 }
2998
2999 void oneTest(int testIdx, int caseIdx,
3000 int iter, int reqSize, int checkMode)
3001 {
3002 long rc;
3003
3004 cesaIteration = iter;
3005 cesaReqSize = cesaRateSize = reqSize;
3006 cesaCheckMode = checkMode;
3007 testMode = 0;
3008 cesaTestIdx = testIdx;
3009 cesaCaseIdx = caseIdx;
3010 rc = mvOsTaskCreate("CESA_T", 100, 4*1024, cesaTask, NULL, &cesaTaskId);
3011 if (rc != MV_OK)
3012 {
3013 mvOsPrintf("hMW: Can't create CESA multiCmd test task, rc = %ld\n", rc);
3014 }
3015 }
3016
3017 void multiTest(int iter, int reqSize, int checkMode)
3018 {
3019 long rc;
3020
3021 cesaIteration = iter;
3022 cesaCheckMode = checkMode;
3023 cesaReqSize = reqSize;
3024 testMode = 1;
3025 rc = mvOsTaskCreate("CESA_T", 100, 4*1024, cesaTask, NULL, &cesaTaskId);
3026 if (rc != MV_OK)
3027 {
3028 mvOsPrintf("hMW: Can't create CESA multiCmd test task, rc = %ld\n", rc);
3029 }
3030 }
3031
3032 void sizeTest(int testIdx, int iter, int checkMode)
3033 {
3034 long rc;
3035
3036 cesaIteration = iter;
3037 cesaCheckMode = checkMode;
3038 testMode = 2;
3039 cesaIdx = testIdx;
3040 rc = mvOsTaskCreate("CESA_T", 100, 4*1024, cesaTask, NULL, &cesaTaskId);
3041 if (rc != MV_OK)
3042 {
3043 mvOsPrintf("hMW: Can't create CESA test task, rc = %ld\n", rc);
3044 }
3045 }
3046
3047 #endif /* MV_VXWORKS */
3048
3049 extern void mvCesaDebugSA(short sid, int mode);
3050 void cesaTestPrintSession(int idx)
3051 {
3052 int testIdx;
3053 MV_CESA_TEST_SESSION* pTestSession;
3054
3055 pTestSession = getTestSessionDb(idx, &testIdx);
3056 if(pTestSession == NULL)
3057 {
3058 mvOsPrintf("Test %d is not exist\n", idx);
3059 return;
3060 }
3061 pTestSession = &pTestSession[testIdx];
3062
3063 if(pTestSession->sid == -1)
3064 {
3065 mvOsPrintf("Test session %d is not opened\n", idx);
3066 return;
3067 }
3068
3069 mvCesaDebugSA(pTestSession->sid, 1);
3070 }
3071
3072 void cesaTestPrintStatus(void)
3073 {
3074 mvOsPrintf("\n\t Cesa Test Status\n\n");
3075
3076 mvOsPrintf("isrCount=%d\n",
3077 cesaTestIsrCount);
3078
3079 #ifdef CESA_TEST_DEBUG
3080 {
3081 int i, j;
3082 j = cesaTestTraceIdx;
3083 mvOsPrintf("No Type Cause rCause iCause Res Time pReady pProc pEmpty\n");
3084 for(i=0; i<MV_CESA_TEST_TRACE_SIZE; i++)
3085 {
3086 mvOsPrintf("%02d. %d 0x%04x 0x%04x 0x%04x 0x%02x 0x%02x %02d 0x%06x %p %p %p\n",
3087 j, cesaTestTrace[j].type, cesaTestTrace[j].cause, cesaTestTrace[j].realCause,
3088 cesaTestTrace[j].dmaCause, cesaTestTrace[j].resources, cesaTestTrace[j].timeStamp,
3089 cesaTestTrace[j].pReqReady, cesaTestTrace[j].pReqProcess, cesaTestTrace[j].pReqEmpty);
3090 j++;
3091 if(j == MV_CESA_TEST_TRACE_SIZE)
3092 j = 0;
3093 }
3094 }
3095 #endif /* CESA_TEST_DEBUG */
3096 }
This page took 0.211209 seconds and 5 git commands to generate.