1 /*******************************************************************************
2 Copyright (C) Marvell International Ltd. and its affiliates
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.
12 ********************************************************************************
13 Marvell Commercial License Option
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.
19 ********************************************************************************
20 Marvell GPL License Option
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.
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
33 ********************************************************************************
34 Marvell BSD License Option
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:
41 * Redistributions of source code must retain the above copyright notice,
42 this list of conditions and the following disclaimer.
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.
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.
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.
63 *******************************************************************************/
67 #if defined(MV_VXWORKS)
76 SEM_ID cesaSemId
= NULL
;
77 SEM_ID cesaWaitSemId
= NULL
;
79 #define CESA_TEST_LOCK(flags) flags = intLock()
80 #define CESA_TEST_UNLOCK(flags) intUnlock(flags)
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)
86 #define CESA_TEST_TICK_GET() tickGet()
87 #define CESA_TEST_TICK_TO_MS(tick) (((tick)*1000)/sysClkRateGet())
89 #elif defined(MV_LINUX)
91 #include <linux/wait.h>
92 wait_queue_head_t cesaTest_waitq
;
95 #define CESA_TEST_LOCK(flags) spin_lock_irqsave( &cesaLock, flags)
96 #define CESA_TEST_UNLOCK(flags) spin_unlock_irqrestore( &cesaLock, flags);
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))
102 #define CESA_TEST_TICK_GET() jiffies
103 #define CESA_TEST_TICK_TO_MS(tick) jiffies_to_msecs(tick)
105 #elif defined(MV_NETBSD)
107 #include <sys/param.h>
108 #include <sys/kernel.h>
111 #define CESA_TEST_LOCK(flags) flags = splnet()
112 #define CESA_TEST_UNLOCK(flags) splx(flags)
114 #define CESA_TEST_WAIT_INIT() /* nothing */
115 #define CESA_TEST_WAKE_UP() wakeup(&cesaLock)
116 #define CESA_TEST_WAIT(cond, ms) \
119 tsleep(&cesaLock, PWAIT, "cesatest",mstohz(ms)); \
120 } while (/*CONSTCOND*/0)
122 #define CESA_TEST_TICK_GET() hardclock_ticks
123 #define CESA_TEST_TICK_TO_MS(tick) ((1000/hz)*(tick))
125 #define request_irq(i,h,t,n,a) \
126 !mv_intr_establish((i),IPL_NET,(int(*)(void *))(h),(a))
129 #error "Only Linux, VxWorks, or NetBSD OS are supported"
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"
143 #if defined(CONFIG_MV646xx)
144 #include "marvell_pic.h"
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
152 #define CESA_DEF_ITER_NUM 100
154 #define CESA_DEF_REQ_SIZE 256
157 /* CESA Tests Debug */
158 #undef CESA_TEST_DEBUG
160 #ifdef CESA_TEST_DEBUG
162 # define CESA_TEST_DEBUG_PRINT(msg) mvOsPrintf msg
163 # define CESA_TEST_DEBUG_CODE(code) code
167 int type
; /* 0 - isrEmpty, 1 - cesaReadyGet, 2 - cesaAction */
173 MV_CESA_REQ
* pReqReady
;
174 MV_CESA_REQ
* pReqEmpty
;
175 MV_CESA_REQ
* pReqProcess
;
176 } MV_CESA_TEST_TRACE
;
178 #define MV_CESA_TEST_TRACE_SIZE 25
180 static int cesaTestTraceIdx
= 0;
181 static MV_CESA_TEST_TRACE cesaTestTrace
[MV_CESA_TEST_TRACE_SIZE
];
183 static void cesaTestTraceAdd(int type
, MV_U32 cause
)
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
);
195 if(cesaTestTraceIdx
== MV_CESA_TEST_TRACE_SIZE
)
196 cesaTestTraceIdx
= 0;
201 # define CESA_TEST_DEBUG_PRINT(msg)
202 # define CESA_TEST_DEBUG_CODE(code)
204 #endif /* CESA_TEST_DEBUG */
213 unsigned long cesaTaskId
;
223 MV_U32 cesaTestIsrCount
= 0;
224 MV_U32 cesaTestIsrMissCount
= 0;
226 MV_U32 cesaCryptoError
= 0;
227 MV_U32 cesaReqIdError
= 0;
228 MV_U32 cesaError
= 0;
230 char* cesaHexBuffer
= NULL
;
232 char* cesaBinBuffer
= NULL
;
233 char* cesaExpBinBuffer
= NULL
;
235 char* cesaInputHexStr
= NULL
;
236 char* cesaOutputHexStr
= NULL
;
238 MV_BUF_INFO cesaReqBufs
[CESA_DEF_REQ_SIZE
];
240 MV_CESA_COMMAND
* cesaCmdRing
;
241 MV_CESA_RESULT cesaResult
;
243 int cesaTestFull
= 0;
245 MV_BOOL cesaIsReady
= MV_FALSE
;
246 MV_U32 cesaCycles
= 0;
247 MV_U32 cesaBeginTicks
= 0;
248 MV_U32 cesaEndTicks
= 0;
250 MV_U32 cesaRateAfterDot
= 0;
252 void *cesaTestOSHandle
= NULL
;
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
,
269 TRIPLE_DES_TEST_TYPE
= 1,
273 COMBINED_TEST_TYPE
= 5,
278 /* Tests data base */
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
;
289 unsigned char* pMacKey
;
293 } MV_CESA_TEST_SESSION
;
297 MV_CESA_TEST_SESSION
* pSessions
;
300 } MV_CESA_TEST_DB_ENTRY
;
306 unsigned char* pCryptoIV
;
316 const char* outputHexStr
;
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};
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};
328 static unsigned char cryptoKey2
[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
329 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F};
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};
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};
340 static unsigned char cryptoKey5
[] = {0x56, 0xe4, 0x7a, 0x38, 0xc5, 0x59, 0x89, 0x74,
341 0xbc, 0x46, 0x90, 0x3d, 0xba, 0x29, 0x03, 0x49};
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};
348 /* Input ASCII string: The quick brown fox jump */
349 static char plain3des1
[] = "54686520717566636B2062726F776E20666F78206A756D70";
350 static char cipher3des1
[] = "A826FD8CE53B855FCCE21C8112256FE668D5C05DD9B6B900";
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};
356 static unsigned char iv3des2
[] = {0x8e, 0x29, 0xf7, 0x5e, 0xa7, 0x7e, 0x54, 0x75};
358 static char plain3des2
[] = "326a494cd33fe756";
360 static char cipher3desCbc2
[] = "8e29f75ea77e5475"
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};
367 static unsigned char iv3des3
[] = {0x3d, 0x1d, 0xe3, 0xcc, 0x13, 0x2e, 0x3b, 0x65};
369 static char plain3des3
[] = "84401f78fe6c10876d8ea23094ea5309";
371 static char cipher3desCbc3
[] = "3d1de3cc132e3b65"
372 "7b1f7c7e3b1c948ebd04a75ffba7d2f5";
374 static unsigned char iv5
[] = {0x8c, 0xe8, 0x2e, 0xef, 0xbe, 0xa0, 0xda, 0x3c,
375 0x44, 0x69, 0x9e, 0xd7, 0xdb, 0x51, 0xb7, 0xd9};
377 static unsigned char aesCtrKey
[] = {0x76, 0x91, 0xBE, 0x03, 0x5E, 0x50, 0x20, 0xA8,
378 0xAC, 0x6E, 0x61, 0x85, 0x29, 0xF9, 0xA0, 0xDC};
380 static unsigned char mdKey1
[] = {0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
381 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b};
383 static unsigned char mdKey2
[] = {0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
384 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa};
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};
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};
394 static unsigned char mdKey4
[] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
395 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10};
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};
402 static MV_CESA_TEST_SESSION desTestSessions
[] =
404 /*000*/ {-1, MV_CESA_CRYPTO_DES
, MV_CESA_CRYPTO_ECB
,
405 MV_CESA_MAC_NULL
, MV_CESA_CRYPTO_ONLY
,
407 cryptoKey7
, sizeof(cryptoKey7
)/sizeof(cryptoKey7
[0]),
411 /*001*/ {-1, MV_CESA_CRYPTO_DES
, MV_CESA_CRYPTO_ECB
,
412 MV_CESA_MAC_NULL
, MV_CESA_CRYPTO_ONLY
,
414 cryptoKey7
, sizeof(cryptoKey7
)/sizeof(cryptoKey7
[0]),
418 /*002*/ {-1, MV_CESA_CRYPTO_DES
, MV_CESA_CRYPTO_CBC
,
419 MV_CESA_MAC_NULL
, MV_CESA_CRYPTO_ONLY
,
421 cryptoKey7
, sizeof(cryptoKey7
)/sizeof(cryptoKey7
[0]),
425 /*003*/ {-1, MV_CESA_CRYPTO_DES
, MV_CESA_CRYPTO_CBC
,
426 MV_CESA_MAC_NULL
, MV_CESA_CRYPTO_ONLY
,
428 cryptoKey7
, sizeof(cryptoKey7
)/sizeof(cryptoKey7
[0]),
432 /*004*/ {-1, MV_CESA_CRYPTO_NULL
, MV_CESA_CRYPTO_ECB
,
433 MV_CESA_MAC_NULL
, MV_CESA_CRYPTO_ONLY
,
436 "NULL Crypto Algorithm encode"
441 static MV_CESA_TEST_SESSION tripleDesTestSessions
[] =
443 /*100*/ {-1, MV_CESA_CRYPTO_3DES
, MV_CESA_CRYPTO_ECB
,
444 MV_CESA_MAC_NULL
, MV_CESA_CRYPTO_ONLY
,
446 cryptoKey1
, sizeof(cryptoKey1
)/sizeof(cryptoKey1
[0]),
450 /*101*/ {-1, MV_CESA_CRYPTO_3DES
, MV_CESA_CRYPTO_ECB
,
451 MV_CESA_MAC_NULL
, MV_CESA_CRYPTO_ONLY
,
453 cryptoKey1
, sizeof(cryptoKey1
)/sizeof(cryptoKey1
[0]),
457 /*102*/ {-1, MV_CESA_CRYPTO_3DES
, MV_CESA_CRYPTO_CBC
,
458 MV_CESA_MAC_NULL
, MV_CESA_CRYPTO_ONLY
,
460 cryptoKey1
, sizeof(cryptoKey1
)/sizeof(cryptoKey1
[0]),
464 /*103*/ {-1, MV_CESA_CRYPTO_3DES
, MV_CESA_CRYPTO_CBC
,
465 MV_CESA_MAC_NULL
, MV_CESA_CRYPTO_ONLY
,
467 cryptoKey1
, sizeof(cryptoKey1
)/sizeof(cryptoKey1
[0]),
471 /*104*/ {-1, MV_CESA_CRYPTO_3DES
, MV_CESA_CRYPTO_ECB
,
472 MV_CESA_MAC_NULL
, MV_CESA_CRYPTO_ONLY
,
474 key3des1
, sizeof(key3des1
),
478 /*105*/ {-1, MV_CESA_CRYPTO_3DES
, MV_CESA_CRYPTO_CBC
,
479 MV_CESA_MAC_NULL
, MV_CESA_CRYPTO_ONLY
,
481 key3des2
, sizeof(key3des2
),
485 /*106*/ {-1, MV_CESA_CRYPTO_3DES
, MV_CESA_CRYPTO_CBC
,
486 MV_CESA_MAC_NULL
, MV_CESA_CRYPTO_ONLY
,
488 key3des3
, sizeof(key3des3
),
495 static MV_CESA_TEST_SESSION aesTestSessions
[] =
497 /*200*/ {-1, MV_CESA_CRYPTO_AES
, MV_CESA_CRYPTO_ECB
,
498 MV_CESA_MAC_NULL
, MV_CESA_CRYPTO_ONLY
,
500 cryptoKey2
, sizeof(cryptoKey2
)/sizeof(cryptoKey2
[0]),
504 /*201*/ {-1, MV_CESA_CRYPTO_AES
, MV_CESA_CRYPTO_ECB
,
505 MV_CESA_MAC_NULL
, MV_CESA_CRYPTO_ONLY
,
507 cryptoKey2
, sizeof(cryptoKey2
)/sizeof(cryptoKey2
[0]),
511 /*202*/ {-1, MV_CESA_CRYPTO_AES
, MV_CESA_CRYPTO_CBC
,
512 MV_CESA_MAC_NULL
, MV_CESA_CRYPTO_ONLY
,
514 cryptoKey5
, sizeof(cryptoKey5
)/sizeof(cryptoKey5
[0]),
518 /*203*/ {-1, MV_CESA_CRYPTO_AES
, MV_CESA_CRYPTO_CBC
,
519 MV_CESA_MAC_NULL
, MV_CESA_CRYPTO_ONLY
,
521 cryptoKey5
, sizeof(cryptoKey5
)/sizeof(cryptoKey5
[0]),
525 /*204*/ {-1, MV_CESA_CRYPTO_AES
, MV_CESA_CRYPTO_ECB
,
526 MV_CESA_MAC_NULL
, MV_CESA_CRYPTO_ONLY
,
528 cryptoKey3
, sizeof(cryptoKey3
)/sizeof(cryptoKey3
[0]),
532 /*205*/ {-1, MV_CESA_CRYPTO_AES
, MV_CESA_CRYPTO_ECB
,
533 MV_CESA_MAC_NULL
, MV_CESA_CRYPTO_ONLY
,
535 cryptoKey3
, sizeof(cryptoKey3
)/sizeof(cryptoKey3
[0]),
539 /*206*/ {-1, MV_CESA_CRYPTO_AES
, MV_CESA_CRYPTO_ECB
,
540 MV_CESA_MAC_NULL
, MV_CESA_CRYPTO_ONLY
,
542 cryptoKey4
, sizeof(cryptoKey4
)/sizeof(cryptoKey4
[0]),
546 /*207*/ {-1, MV_CESA_CRYPTO_AES
, MV_CESA_CRYPTO_ECB
,
547 MV_CESA_MAC_NULL
, MV_CESA_CRYPTO_ONLY
,
549 cryptoKey4
, sizeof(cryptoKey4
)/sizeof(cryptoKey4
[0]),
553 /*208*/ {-1, MV_CESA_CRYPTO_AES
, MV_CESA_CRYPTO_CTR
,
554 MV_CESA_MAC_NULL
, MV_CESA_CRYPTO_ONLY
,
556 aesCtrKey
, sizeof(aesCtrKey
)/sizeof(aesCtrKey
[0]),
563 static MV_CESA_TEST_SESSION md5TestSessions
[] =
565 /*300*/ {-1, MV_CESA_CRYPTO_NULL
, MV_CESA_CRYPTO_ECB
,
566 MV_CESA_MAC_HMAC_MD5
, MV_CESA_MAC_ONLY
,
569 mdKey1
, sizeof(mdKey1
),
570 "HMAC-MD5 Generate Signature"
572 /*301*/ {-1, MV_CESA_CRYPTO_NULL
, MV_CESA_CRYPTO_ECB
,
573 MV_CESA_MAC_HMAC_MD5
, MV_CESA_MAC_ONLY
,
576 mdKey1
, sizeof(mdKey1
),
577 "HMAC-MD5 Verify Signature"
579 /*302*/ {-1, MV_CESA_CRYPTO_NULL
, MV_CESA_CRYPTO_ECB
,
580 MV_CESA_MAC_HMAC_MD5
, MV_CESA_MAC_ONLY
,
583 mdKey2
, sizeof(mdKey2
),
584 "HMAC-MD5 Generate Signature"
586 /*303*/ {-1, MV_CESA_CRYPTO_NULL
, MV_CESA_CRYPTO_ECB
,
587 MV_CESA_MAC_HMAC_MD5
, MV_CESA_MAC_ONLY
,
590 mdKey2
, sizeof(mdKey2
),
591 "HMAC-MD5 Verify Signature"
593 /*304*/ {-1, MV_CESA_CRYPTO_NULL
, MV_CESA_CRYPTO_ECB
,
594 MV_CESA_MAC_HMAC_MD5
, MV_CESA_MAC_ONLY
,
597 mdKey4
, sizeof(mdKey4
),
598 "HMAC-MD5 Generate Signature"
600 /*305*/ {-1, MV_CESA_CRYPTO_NULL
, MV_CESA_CRYPTO_ECB
,
601 MV_CESA_MAC_MD5
, MV_CESA_MAC_ONLY
,
605 "HASH-MD5 Generate Signature"
610 static MV_CESA_TEST_SESSION shaTestSessions
[] =
612 /*400*/ {-1, MV_CESA_CRYPTO_NULL
, MV_CESA_CRYPTO_ECB
,
613 MV_CESA_MAC_HMAC_SHA1
, MV_CESA_MAC_ONLY
,
616 shaKey1
, sizeof(shaKey1
),
617 "HMAC-SHA1 Generate Signature"
619 /*401*/ {-1, MV_CESA_CRYPTO_NULL
, MV_CESA_CRYPTO_ECB
,
620 MV_CESA_MAC_HMAC_SHA1
, MV_CESA_MAC_ONLY
,
623 shaKey1
, sizeof(shaKey1
),
624 "HMAC-SHA1 Verify Signature"
626 /*402*/ {-1, MV_CESA_CRYPTO_NULL
, MV_CESA_CRYPTO_ECB
,
627 MV_CESA_MAC_HMAC_SHA1
, MV_CESA_MAC_ONLY
,
630 shaKey2
, sizeof(shaKey2
),
631 "HMAC-SHA1 Generate Signature"
633 /*403*/ {-1, MV_CESA_CRYPTO_NULL
, MV_CESA_CRYPTO_ECB
,
634 MV_CESA_MAC_HMAC_SHA1
, MV_CESA_MAC_ONLY
,
637 shaKey2
, sizeof(shaKey2
),
638 "HMAC-SHA1 Verify Signature"
640 /*404*/ {-1, MV_CESA_CRYPTO_NULL
, MV_CESA_CRYPTO_ECB
,
641 MV_CESA_MAC_HMAC_SHA1
, MV_CESA_MAC_ONLY
,
644 shaKey4
, sizeof(shaKey4
),
645 "HMAC-SHA1 Generate Signature"
647 /*405*/ {-1, MV_CESA_CRYPTO_NULL
, MV_CESA_CRYPTO_ECB
,
648 MV_CESA_MAC_SHA1
, MV_CESA_MAC_ONLY
,
652 "HASH-SHA1 Generate Signature"
656 static MV_CESA_TEST_SESSION combinedTestSessions
[] =
658 /*500*/ {-1, MV_CESA_CRYPTO_DES
, MV_CESA_CRYPTO_ECB
,
659 MV_CESA_MAC_HMAC_MD5
, MV_CESA_CRYPTO_THEN_MAC
,
661 cryptoKey1
, MV_CESA_DES_KEY_LENGTH
,
662 mdKey4
, sizeof(mdKey4
),
665 /*501*/ {-1, MV_CESA_CRYPTO_DES
, MV_CESA_CRYPTO_ECB
,
666 MV_CESA_MAC_HMAC_SHA1
, MV_CESA_CRYPTO_THEN_MAC
,
668 cryptoKey1
, MV_CESA_DES_KEY_LENGTH
,
669 shaKey4
, sizeof(shaKey4
),
672 /*502*/ {-1, MV_CESA_CRYPTO_3DES
, MV_CESA_CRYPTO_ECB
,
673 MV_CESA_MAC_HMAC_MD5
, MV_CESA_CRYPTO_THEN_MAC
,
675 cryptoKey1
, sizeof(cryptoKey1
)/sizeof(cryptoKey1
[0]),
676 mdKey4
, sizeof(mdKey4
),
679 /*503*/ {-1, MV_CESA_CRYPTO_3DES
, MV_CESA_CRYPTO_ECB
,
680 MV_CESA_MAC_HMAC_SHA1
, MV_CESA_CRYPTO_THEN_MAC
,
682 cryptoKey1
, sizeof(cryptoKey1
)/sizeof(cryptoKey1
[0]),
683 shaKey4
, sizeof(shaKey4
),
686 /*504*/ {-1, MV_CESA_CRYPTO_3DES
, MV_CESA_CRYPTO_CBC
,
687 MV_CESA_MAC_HMAC_MD5
, MV_CESA_CRYPTO_THEN_MAC
,
689 cryptoKey1
, sizeof(cryptoKey1
)/sizeof(cryptoKey1
[0]),
690 mdKey4
, sizeof(mdKey4
),
691 "3DES CBC + MD5 encode"
693 /*505*/ {-1, MV_CESA_CRYPTO_3DES
, MV_CESA_CRYPTO_CBC
,
694 MV_CESA_MAC_HMAC_SHA1
, MV_CESA_CRYPTO_THEN_MAC
,
696 cryptoKey1
, sizeof(cryptoKey1
)/sizeof(cryptoKey1
[0]),
697 shaKey4
, sizeof(shaKey4
),
698 "3DES CBC + SHA1 encode"
700 /*506*/ {-1, MV_CESA_CRYPTO_AES
, MV_CESA_CRYPTO_CBC
,
701 MV_CESA_MAC_HMAC_MD5
, MV_CESA_CRYPTO_THEN_MAC
,
703 cryptoKey5
, sizeof(cryptoKey5
)/sizeof(cryptoKey5
[0]),
704 mdKey4
, sizeof(mdKey4
),
705 "AES-128 CBC + MD5 encode"
707 /*507*/ {-1, MV_CESA_CRYPTO_AES
, MV_CESA_CRYPTO_CBC
,
708 MV_CESA_MAC_HMAC_SHA1
, MV_CESA_CRYPTO_THEN_MAC
,
710 cryptoKey5
, sizeof(cryptoKey5
)/sizeof(cryptoKey5
[0]),
711 shaKey4
, sizeof(shaKey4
),
712 "AES-128 CBC + SHA1 encode"
714 /*508*/ {-1, MV_CESA_CRYPTO_3DES
, MV_CESA_CRYPTO_ECB
,
715 MV_CESA_MAC_HMAC_MD5
, MV_CESA_MAC_THEN_CRYPTO
,
717 cryptoKey1
, sizeof(cryptoKey1
)/sizeof(cryptoKey1
[0]),
718 mdKey4
, sizeof(mdKey4
),
719 "HMAC-MD5 + 3DES decode"
724 static MV_CESA_TEST_DB_ENTRY cesaTestsDB
[MAX_TEST_TYPE
+1] =
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]) },
736 char cesaNullPlainHexText
[] = "000000000000000000000000000000000000000000000000";
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";
744 char cesaAesPlainHexEcb
[] = "000102030405060708090a0b0c0d0e0f";
745 char cesaAes128cipherHexEcb
[] = "0a940bb5416ef045f1c39458c653ea5a";
746 char cesaAes192cipherHexEcb
[] = "0060bffe46834bb8da5cf9a61ff220ae";
747 char cesaAes256cipherHexEcb
[] = "5a6e045708fb7196f02e553d02c3a692";
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";
756 char cesaAesPlainText
[] = "a0a1a2a3a4a5a6a7a8a9aaabacadaeaf"
757 "b0b1b2b3b4b5b6b7b8b9babbbcbdbebf"
758 "c0c1c2c3c4c5c6c7c8c9cacbcccdcecf"
759 "d0d1d2d3d4d5d6d7d8d9dadbdcdddedf";
761 char cesaAes128CipherCbc
[] = "c30e32ffedc0774e6aff6af0869f71aa"
762 "0f3af07a9a31a9c684db207eb0ef8e4e"
763 "35907aa632c3ffdf868bb7b29d3d46ad"
764 "83ce9f9a102ee99d49a53e87f4c3da55";
766 char cesaAesIvPlainText
[] = "8ce82eefbea0da3c44699ed7db51b7d9"
767 "a0a1a2a3a4a5a6a7a8a9aaabacadaeaf"
768 "b0b1b2b3b4b5b6b7b8b9babbbcbdbebf"
769 "c0c1c2c3c4c5c6c7c8c9cacbcccdcecf"
770 "d0d1d2d3d4d5d6d7d8d9dadbdcdddedf";
772 char cesaAes128IvCipherCbc
[] = "8ce82eefbea0da3c44699ed7db51b7d9"
773 "c30e32ffedc0774e6aff6af0869f71aa"
774 "0f3af07a9a31a9c684db207eb0ef8e4e"
775 "35907aa632c3ffdf868bb7b29d3d46ad"
776 "83ce9f9a102ee99d49a53e87f4c3da55";
778 char cesaAesCtrPlain
[] = "00E0017B27777F3F4A1786F000000001"
779 "000102030405060708090A0B0C0D0E0F"
780 "101112131415161718191A1B1C1D1E1F"
783 char cesaAesCtrCipher
[] = "00E0017B27777F3F4A1786F000000001"
784 "C1CF48A89F2FFDD9CF4652E9EFDB72D7"
785 "4540A42BDE6D7836D59A5CEAAEF31053"
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] = "";
797 /* Ascii string is "abc" */
798 char hashHexStr3
[] = "616263";
799 char hashMd5digest3
[] = "900150983cd24fb0d6963f7d28e17f72";
800 char hashSha1digest3
[] = "a9993e364706816aba3e25717850c26c9cd0d89d";
802 char hashHexStr80
[] = "31323334353637383930"
803 "31323334353637383930"
804 "31323334353637383930"
805 "31323334353637383930"
806 "31323334353637383930"
807 "31323334353637383930"
808 "31323334353637383930"
809 "31323334353637383930";
811 char hashMd5digest80
[] = "57edf4a22be3c955ac49da2e2107b67a";
813 char tripleDesThenMd5digest80
[] = "b7726a03aad490bd6c5a452a89a1b271";
814 char tripleDesThenSha1digest80
[] = "b2ddeaca91030eab5b95a234ef2c0f6e738ff883";
816 char cbc3desThenMd5digest80
[] = "6f463057e1a90e0e91ae505b527bcec0";
817 char cbc3desThenSha1digest80
[] = "1b002ed050be743aa98860cf35659646bb8efcc0";
819 char cbcAes128ThenMd5digest80
[] = "6b6e863ac5a71d15e3e9b1c86c9ba05f";
820 char cbcAes128ThenSha1digest80
[] = "13558472d1fc1c90dffec6e5136c7203452d509b";
823 static MV_CESA_TEST_CASE cesaTestCases
[] =
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 },
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
862 static MV_CESA_SIZE_TEST mdMultiSizeTest302
[] =
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" },
907 /* Key = 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
908 * 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10
909 * InputHexStr = "31323334353637383930" (ASCII = "1234567890")
911 static MV_CESA_SIZE_TEST mdMultiSizeTest304
[] =
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" },
958 * InputHexStr = "31323334353637383930" (ASCII = "1234567890")
959 * repeated "size" times
961 static MV_CESA_SIZE_TEST mdMultiSizeTest305
[] =
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" },
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")
1013 static MV_CESA_SIZE_TEST shaMultiSizeTest402
[] =
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" },
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")
1064 static MV_CESA_SIZE_TEST shaMultiSizeTest404
[] =
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" },
1111 * InputHexStr = "31323334353637383930" (ASCII = "1234567890")
1112 * repeated "size" times
1114 static MV_CESA_SIZE_TEST shaMultiSizeTest405
[] =
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" },
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
1168 static MV_CESA_SIZE_TEST tripleDesMdMultiSizeTest502
[] =
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" },
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
1201 static MV_CESA_SIZE_TEST tripleDesShaMultiSizeTest503
[] =
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" },
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
1233 static MV_CESA_SIZE_TEST cbc3desMdMultiSizeTest504
[] =
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" },
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
1267 static MV_CESA_SIZE_TEST cbc3desShaMultiSizeTest505
[] =
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" },
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
1300 static MV_CESA_SIZE_TEST cbcAes128md5multiSizeTest506
[] =
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" },
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
1333 static MV_CESA_SIZE_TEST cbcAes128sha1multiSizeTest507
[] =
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" },
1356 void cesaTestPrintStatus(void);
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
);
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
);
1390 static MV_U32
getRate(MV_U32
* remainder
)
1392 MV_U32 kBits
, milliSec
, rate
;
1395 if( (cesaEndTicks
- cesaBeginTicks
) > 0)
1397 milliSec
= CESA_TEST_TICK_TO_MS(cesaEndTicks
- cesaBeginTicks
);
1401 if(remainder
!= NULL
)
1406 kBits
= (cesaIteration
*cesaRateSize
*8)/1000;
1407 rate
= kBits
/milliSec
;
1408 if(remainder
!= NULL
)
1409 *remainder
= ((kBits
% milliSec
)*10)/milliSec
;
1414 static char* extractMbuf(MV_CESA_MBUF
*pMbuf
,
1415 int offset
, int size
, char* hexStr
)
1417 mvCesaCopyFromMbuf((MV_U8
*)cesaBinBuffer
, pMbuf
, offset
, size
);
1418 mvBinToHex((const MV_U8
*)cesaBinBuffer
, hexStr
, size
);
1423 static MV_BOOL
cesaCheckMbuf(MV_CESA_MBUF
*pMbuf
,
1424 const char* hexString
, int offset
,
1427 MV_BOOL isFailed
= MV_FALSE
;
1429 int size
= strlen(hexString
)/2;
1430 int checkedSize
= 0;
1432 mvOsPrintf("cesaCheckMbuf: pMbuf=%p, offset=%d, checkSize=%d, mBufSize=%d\n",
1433 pMbuf, offset, checkSize, pMbuf->mbufSize);
1435 if(pMbuf
->mbufSize
< (checkSize
+ offset
))
1437 mvOsPrintf("checkSize (%d) is too large: offset=%d, mbufSize=%d\n",
1438 checkSize
, offset
, pMbuf
->mbufSize
);
1441 status
= mvCesaCopyFromMbuf((MV_U8
*)cesaBinBuffer
, pMbuf
, offset
, checkSize
);
1444 mvOsPrintf("CesaTest: Can't copy %d bytes from Mbuf=%p to checkBuf=%p\n",
1445 checkSize
, pMbuf
, cesaBinBuffer
);
1449 mvDebugMemDump(cesaBinBuffer, size, 1);
1451 mvHexToBin(hexString
, (MV_U8
*)cesaExpBinBuffer
, size
);
1453 /* Compare buffers */
1454 while(checkSize
> checkedSize
)
1456 size
= MV_MIN(size
, (checkSize
- checkedSize
));
1457 if(memcmp(cesaExpBinBuffer
, &cesaBinBuffer
[checkedSize
], size
) != 0)
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);
1467 checkedSize
+= size
;
1473 static MV_STATUS
cesaSetMbuf(MV_CESA_MBUF
*pMbuf
,
1474 const char* hexString
,
1475 int offset
, int reqSize
)
1477 MV_STATUS status
= MV_OK
;
1478 int copySize
, size
= strlen(hexString
)/2;
1480 mvHexToBin(hexString
, (MV_U8
*)cesaBinBuffer
, size
);
1483 while(reqSize
> copySize
)
1485 size
= MV_MIN(size
, (reqSize
- copySize
));
1487 status
= mvCesaCopyToMbuf((MV_U8
*)cesaBinBuffer
, pMbuf
, offset
+copySize
, size
);
1490 mvOsPrintf("cesaSetMbuf Error: Copy %d of %d bytes to MBuf\n",
1496 pMbuf
->mbufSize
= offset
+copySize
;
1500 static MV_CESA_TEST_SESSION
* getTestSessionDb(int idx
, int* pTestIdx
)
1502 int testIdx
, dbIdx
= idx
/100;
1504 if(dbIdx
> MAX_TEST_TYPE
)
1506 mvOsPrintf("Wrong index %d - No such test type\n", idx
);
1509 testIdx
= idx
% 100;
1511 if(testIdx
>= cesaTestsDB
[dbIdx
].numSessions
)
1513 mvOsPrintf("Wrong index %d - No such test\n", idx
);
1516 if(pTestIdx
!= NULL
)
1517 *pTestIdx
= testIdx
;
1519 return cesaTestsDB
[dbIdx
].pSessions
;
1523 void cesaTestPrintReq(int req
, int offset
, int size
)
1525 MV_CESA_MBUF
* pMbuf
;
1527 mvOsPrintf("cesaTestPrintReq: req=%d, offset=%d, size=%d\n",
1529 mvDebugMemDump(cesaCmdRing
, 128, 4);
1531 pMbuf
= cesaCmdRing
[req
].pSrc
;
1532 mvCesaDebugMbuf("src", pMbuf
, offset
,size
);
1533 pMbuf
= cesaCmdRing
[req
].pDst
;
1534 mvCesaDebugMbuf("dst", pMbuf
, offset
, size
);
1536 cesaTestPrintStatus();
1539 void cesaLastResult(void)
1541 mvOsPrintf("Last Result: ReqId = %d, SessionId = %d, rc = (%d)\n",
1542 (MV_U32
)cesaResult
.pReqPrv
, cesaResult
.sessionId
,
1543 cesaResult
.retCode
);
1546 void printTestResults(int idx
, MV_STATUS status
, int checkMode
)
1549 MV_CESA_TEST_SESSION
* pTestSessions
= getTestSessionDb(idx
, &testIdx
);
1551 if(pTestSessions
== NULL
)
1554 mvOsPrintf("%-35s %4dx%-4d : ", pTestSessions
[testIdx
].name
,
1555 cesaIteration
, cesaReqSize
);
1556 if( (status
== MV_OK
) &&
1557 (cesaCryptoError
== 0) &&
1559 (cesaReqIdError
== 0) )
1561 mvOsPrintf("Passed, Rate=%3u.%u Mbps (%5u cpp)\n",
1562 cesaRate
, cesaRateAfterDot
, cesaEndTicks
- cesaBeginTicks
);
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
);
1572 mvOsPrintf("cesaError : %d\n", cesaError
);
1574 if(cesaTestIsrMissCount
> 0)
1575 mvOsPrintf("cesaIsrMissed : %d\n", cesaTestIsrMissCount
);
1578 void cesaCheckReady(MV_CESA_RESULT
* r
)
1581 MV_CESA_MBUF
*pMbuf
;
1585 reqId
= (int)cesaResult
.pReqPrv
;
1586 pMbuf
= cesaCmdRing
[reqId
].pDst
;
1589 mvOsPrintf("cesaCheckReady: reqId=%d, checkOffset=%d, checkSize=%d\n",
1590 reqId, cesaCheckOffset, cesaCheckSize);
1592 /* Check expected reqId */
1593 if(reqId
!= cesaExpReqId
)
1597 mvOsPrintf("CESA reqId Error: cbIter=%d (%d), reqId=%d, expReqId=%d\n",
1598 cesaCbIter, cesaIteration, reqId, cesaExpReqId);
1603 if( (cesaCheckMode
== CESA_FULL_CHECK_MODE
) ||
1604 (cesaCheckMode
== CESA_FAST_CHECK_MODE
) )
1606 if(cesaResult
.retCode
!= MV_OK
)
1610 mvOsPrintf("CESA Error: cbIter=%d (%d), reqId=%d, rc=%d\n",
1611 cesaCbIter
, cesaIteration
, reqId
, cesaResult
.retCode
);
1615 if( (cesaCheckSize
> 0) && (cesaOutputHexStr
!= NULL
) )
1617 /* Check expected output */
1619 isFailed
= cesaCheckMbuf(pMbuf
, cesaOutputHexStr
, cesaCheckOffset
, cesaCheckSize
);
1622 mvOsPrintf("CESA Crypto Error: cbIter=%d (%d), reqId=%d\n",
1623 cesaCbIter
, cesaIteration
, reqId
);
1625 CESA_TEST_DEBUG_PRINT(("Error: reqId=%d, reqSize=%d, checkOffset=%d, checkSize=%d\n",
1626 reqId
, cesaReqSize
, cesaCheckOffset
, cesaCheckSize
));
1628 CESA_TEST_DEBUG_PRINT(("Output str: %s\n", cesaOutputHexStr
));
1630 CESA_TEST_DEBUG_CODE( mvCesaDebugMbuf("error", pMbuf
, 0, cesaCheckOffset
+cesaCheckSize
) );
1638 if(cesaCheckMode
== CESA_SHOW_CHECK_MODE
)
1640 extractMbuf(pMbuf
, cesaCheckOffset
, cesaCheckSize
, cesaHexBuffer
);
1641 mvOsPrintf("%4d, %s\n", cesaCheckOffset
, cesaHexBuffer
);
1645 if(cesaCbIter
>= cesaIteration
)
1649 cesaIsReady
= MV_TRUE
;
1651 cesaEndTicks
= CESA_TEST_TICK_GET();
1652 cesaRate
= getRate(&cesaRateAfterDot
);
1656 cesaExpReqId
= reqId
+ 1;
1657 if(cesaExpReqId
== CESA_DEF_REQ_SIZE
)
1664 static int cesaTestReadyIsr(void *arg
)
1667 static irqreturn_t
cesaTestReadyIsr( int irq
, void *dev_id
)
1670 void cesaTestReadyIsr(void)
1676 MV_CESA_RESULT result
;
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)
1683 mvOsPrintf("cesaTestReadyIsr: cause=0x%x\n", cause
);
1695 MV_REG_WRITE(MV_CESA_ISR_CAUSE_REG
, 0);
1699 /* Get Ready requests */
1700 status
= mvCesaReadyGet(&result
);
1702 cesaCheckReady(&result
);
1706 if( (cesaTestFull
== 1) && (status
!= MV_BUSY
) )
1709 CESA_TEST_WAKE_UP();
1718 cesaTestCheckReady(const MV_CESA_RESULT
*r
)
1720 MV_CESA_RESULT result
= *r
;
1722 cesaCheckReady(&result
);
1724 if (cesaTestFull
== 1) {
1726 CESA_TEST_WAKE_UP();
1730 static INLINE
int open_session(MV_CESA_OPEN_SESSION
* pOs
)
1735 status
= mvCesaSessionOpen(pOs
, (short*)&sid
);
1738 mvOsPrintf("CesaTest: Can't open new session - status = 0x%x\n",
1746 void close_session(int sid
)
1750 status
= mvCesaSessionClose(sid
);
1753 mvOsPrintf("CesaTest: Can't close session %d - status = 0x%x\n",
1758 MV_STATUS
testOpen(int idx
)
1760 MV_CESA_OPEN_SESSION os
;
1761 int sid
, i
, testIdx
;
1762 MV_CESA_TEST_SESSION
* pTestSession
;
1763 MV_U16 digestSize
= 0;
1765 pTestSession
= getTestSessionDb(idx
, &testIdx
);
1766 if(pTestSession
== NULL
)
1768 mvOsPrintf("Test %d is not exist\n", idx
);
1769 return MV_BAD_PARAM
;
1771 pTestSession
= &pTestSession
[testIdx
];
1773 if(pTestSession
->sid
!= -1)
1775 mvOsPrintf("Session for test %d already created: sid=%d\n",
1776 idx
, pTestSession
->sid
);
1780 os
.cryptoAlgorithm
= pTestSession
->cryptoAlgorithm
;
1781 os
.macMode
= pTestSession
->macAlgorithm
;
1784 case MV_CESA_MAC_MD5
:
1785 case MV_CESA_MAC_HMAC_MD5
:
1786 digestSize
= MV_CESA_MD5_DIGEST_SIZE
;
1789 case MV_CESA_MAC_SHA1
:
1790 case MV_CESA_MAC_HMAC_SHA1
:
1791 digestSize
= MV_CESA_SHA1_DIGEST_SIZE
;
1794 case MV_CESA_MAC_NULL
:
1797 os
.cryptoMode
= pTestSession
->cryptoMode
;
1798 os
.direction
= pTestSession
->direction
;
1799 os
.operation
= pTestSession
->operation
;
1801 for(i
=0; i
<pTestSession
->cryptoKeySize
; i
++)
1802 os
.cryptoKey
[i
] = pTestSession
->pCryptoKey
[i
];
1804 os
.cryptoKeyLength
= pTestSession
->cryptoKeySize
;
1806 for(i
=0; i
<pTestSession
->macKeySize
; i
++)
1807 os
.macKey
[i
] = pTestSession
->pMacKey
[i
];
1809 os
.macKeyLength
= pTestSession
->macKeySize
;
1810 os
.digestSize
= digestSize
;
1812 sid
= open_session(&os
);
1815 mvOsPrintf("Can't open session for test %d: rc=0x%x\n",
1816 idx
, cesaResult
.retCode
);
1817 return cesaResult
.retCode
;
1819 CESA_TEST_DEBUG_PRINT(("Opened session: sid = %d\n", sid
));
1820 pTestSession
->sid
= sid
;
1824 MV_STATUS
testClose(int idx
)
1827 MV_CESA_TEST_SESSION
* pTestSession
;
1829 pTestSession
= getTestSessionDb(idx
, &testIdx
);
1830 if(pTestSession
== NULL
)
1832 mvOsPrintf("Test %d is not exist\n", idx
);
1833 return MV_BAD_PARAM
;
1835 pTestSession
= &pTestSession
[testIdx
];
1837 if(pTestSession
->sid
== -1)
1839 mvOsPrintf("Test session %d is not opened\n", idx
);
1843 close_session(pTestSession
->sid
);
1844 pTestSession
->sid
= -1;
1849 MV_STATUS
testCmd(int sid
, int iter
, MV_CESA_COMMAND
* pCmd
,
1850 MV_CESA_TEST_SESSION
* pTestSession
, MV_U8
* pIV
, int ivSize
)
1854 MV_STATUS rc
= MV_OK
;
1855 char ivZeroHex
[] = "0000";
1858 iter
= CESA_DEF_ITER_NUM
;
1862 mvOsPrintf("testCmd failed: pCmd=NULL\n");
1863 return MV_BAD_PARAM
;
1865 pCmd
->sessionId
= sid
;
1867 cesaCryptoError
= 0;
1870 cesaTestIsrMissCount
= 0;
1871 cesaIsReady
= MV_FALSE
;
1872 cesaIteration
= iter
;
1874 if(cesaInputHexStr
== NULL
)
1875 cesaInputHexStr
= cesaPlainHexEbc
;
1877 for(i
=0; i
<CESA_DEF_REQ_SIZE
; i
++)
1879 pCmd
->pSrc
= (MV_CESA_MBUF
*)(cesaCmdRing
[i
].pSrc
);
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
));
1889 cesaSetMbuf(pCmd
->pSrc
, cesaInputHexStr
, 0, cesaReqSize
);
1891 pCmd
->pDst
= (MV_CESA_MBUF
*)(cesaCmdRing
[i
].pDst
);
1892 cesaSetMbuf(pCmd
->pDst
, cesaNullPlainHexText
, 0, cesaReqSize
);
1894 memcpy(&cesaCmdRing
[i
], pCmd
, sizeof(*pCmd
));
1897 if(cesaCheckMode
== CESA_SW_SHOW_CHECK_MODE
)
1899 MV_U8 pDigest
[MV_CESA_MAX_DIGEST_SIZE
];
1901 if(pTestSession
->macAlgorithm
== MV_CESA_MAC_MD5
)
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);
1909 if(pTestSession
->macAlgorithm
== MV_CESA_MAC_SHA1
)
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);
1919 cesaBeginTicks
= CESA_TEST_TICK_GET();
1920 CESA_TEST_DEBUG_CODE( memset(cesaTestTrace
, 0, sizeof(cesaTestTrace
));
1921 cesaTestTraceIdx
= 0;
1924 if(cesaCheckMode
== CESA_SW_NULL_CHECK_MODE
)
1926 volatile MV_U8 pDigest
[MV_CESA_MAX_DIGEST_SIZE
];
1928 for(i
=0; i
<iter
; i
++)
1930 if(pTestSession
->macAlgorithm
== MV_CESA_MAC_MD5
)
1932 mvMD5(pCmd
->pSrc
->pFrags
[0].bufVirtPtr
, pCmd
->macLength
, (unsigned char*)pDigest
);
1934 if(pTestSession
->macAlgorithm
== MV_CESA_MAC_SHA1
)
1936 mvSHA1(pCmd
->pSrc
->pFrags
[0].bufVirtPtr
, pCmd
->macLength
, (MV_U8
*)pDigest
);
1939 cesaEndTicks
= CESA_TEST_TICK_GET();
1940 cesaRate
= getRate(&cesaRateAfterDot
);
1941 cesaIsReady
= MV_TRUE
;
1946 /*cesaTestIsrCount = 0;*/
1947 /*mvCesaDebugStatsClear();*/
1950 MV_REG_WRITE(MV_CESA_ISR_CAUSE_REG
, 0);
1953 for(i
=0; i
<iter
; i
++)
1955 unsigned long flags
;
1957 pCmd
= &cesaCmdRing
[cmdReqId
];
1958 pCmd
->pReqPrv
= (void*)cmdReqId
;
1960 CESA_TEST_LOCK(flags
);
1962 rc
= mvCesaAction(pCmd
);
1963 if(rc
== MV_NO_RESOURCE
)
1966 CESA_TEST_UNLOCK(flags
);
1968 if(rc
== MV_NO_RESOURCE
)
1970 CESA_TEST_LOCK(flags
);
1971 CESA_TEST_WAIT( (cesaTestFull
== 0), 100);
1972 CESA_TEST_UNLOCK(flags
);
1973 if(cesaTestFull
== 1)
1975 mvOsPrintf("CESA Test timeout: i=%d, iter=%d, cesaTestFull=%d\n",
1976 i
, iter
, cesaTestFull
);
1981 CESA_TEST_LOCK(flags
);
1983 rc
= mvCesaAction(pCmd
);
1985 CESA_TEST_UNLOCK(flags
);
1987 if( (rc
!= MV_OK
) && (rc
!= MV_NO_MORE
) )
1989 mvOsPrintf("mvCesaAction failed: rc=%d\n", rc
);
1994 if(cmdReqId
>= CESA_DEF_REQ_SIZE
)
1998 /* Reschedule each 16 requests */
2006 void cesaTestStart(int bufNum
, int bufSize
)
2009 MV_CESA_MBUF
*pMbufSrc
, *pMbufDst
;
2010 MV_BUF_INFO
*pFragsSrc
, *pFragsDst
;
2013 int numOfSessions
, queueDepth
;
2016 MV_CPU_DEC_WIN addrDecWin
;
2019 cesaCmdRing
= mvOsMalloc(sizeof(MV_CESA_COMMAND
) * CESA_DEF_REQ_SIZE
);
2020 if(cesaCmdRing
== NULL
)
2022 mvOsPrintf("testStart: Can't allocate %ld bytes of memory\n",
2023 sizeof(MV_CESA_COMMAND
) * CESA_DEF_REQ_SIZE
);
2026 memset(cesaCmdRing
, 0, sizeof(MV_CESA_COMMAND
) * CESA_DEF_REQ_SIZE
);
2029 bufNum
= CESA_DEF_BUF_NUM
;
2032 bufSize
= CESA_DEF_BUF_SIZE
;
2034 cesaBufNum
= bufNum
;
2035 cesaBufSize
= bufSize
;
2036 mvOsPrintf("CESA test started: bufNum = %d, bufSize = %d\n",
2039 cesaHexBuffer
= mvOsMalloc(2*bufNum
*bufSize
);
2040 if(cesaHexBuffer
== NULL
)
2042 mvOsPrintf("testStart: Can't malloc %d bytes for cesaHexBuffer.\n",
2046 memset(cesaHexBuffer
, 0, (2*bufNum
*bufSize
));
2048 cesaBinBuffer
= mvOsMalloc(bufNum
*bufSize
);
2049 if(cesaBinBuffer
== NULL
)
2051 mvOsPrintf("testStart: Can't malloc %d bytes for cesaBinBuffer\n",
2055 memset(cesaBinBuffer
, 0, (bufNum
*bufSize
));
2057 cesaExpBinBuffer
= mvOsMalloc(bufNum
*bufSize
);
2058 if(cesaExpBinBuffer
== NULL
)
2060 mvOsPrintf("testStart: Can't malloc %d bytes for cesaExpBinBuffer\n",
2064 memset(cesaExpBinBuffer
, 0, (bufNum
*bufSize
));
2066 CESA_TEST_WAIT_INIT();
2068 pMbufSrc
= mvOsMalloc(sizeof(MV_CESA_MBUF
) * CESA_DEF_REQ_SIZE
);
2069 pFragsSrc
= mvOsMalloc(sizeof(MV_BUF_INFO
) * bufNum
* CESA_DEF_REQ_SIZE
);
2071 pMbufDst
= mvOsMalloc(sizeof(MV_CESA_MBUF
) * CESA_DEF_REQ_SIZE
);
2072 pFragsDst
= mvOsMalloc(sizeof(MV_BUF_INFO
) * bufNum
* CESA_DEF_REQ_SIZE
);
2074 if( (pMbufSrc
== NULL
) || (pFragsSrc
== NULL
) ||
2075 (pMbufDst
== NULL
) || (pFragsDst
== NULL
) )
2077 mvOsPrintf("testStart: Can't malloc Src and Dst pMbuf and pFrags structures.\n");
2078 /* !!!! Dima cesaTestCleanup();*/
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
);
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
);
2088 mvOsPrintf("Cesa Test Start: pMbufSrc=%p, pFragsSrc=%p, pMbufDst=%p, pFragsDst=%p\n",
2089 pMbufSrc
, pFragsSrc
, pMbufDst
, pFragsDst
);
2092 for(i
=0; i
<CESA_DEF_REQ_SIZE
; i
++)
2094 pBuf
= mvOsIoCachedMalloc(cesaTestOSHandle
,bufSize
* bufNum
* 2,
2095 &cesaReqBufs
[i
].bufPhysAddr
,
2096 &cesaReqBufs
[i
].memHandle
);
2099 mvOsPrintf("testStart: Can't malloc %d bytes for pBuf\n",
2100 bufSize
* bufNum
* 2);
2104 memset(pBuf
, 0, bufSize
* bufNum
* 2);
2105 mvOsCacheFlush(cesaTestOSHandle
,pBuf
, bufSize
* bufNum
* 2);
2108 mvOsPrintf("cesaTestStart: Can't allocate %d bytes for req_%d buffers\n",
2109 bufSize
* bufNum
* 2, i
);
2113 cesaReqBufs
[i
].bufVirtPtr
= (MV_U8
*)pBuf
;
2114 cesaReqBufs
[i
].bufSize
= bufSize
* bufNum
* 2;
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;
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;
2126 for(j
=0; j
<bufNum
; j
++)
2128 cesaCmdRing
[i
].pSrc
->pFrags
[j
].bufVirtPtr
= (MV_U8
*)pBuf
;
2129 cesaCmdRing
[i
].pSrc
->pFrags
[j
].bufSize
= bufSize
;
2131 cesaCmdRing
[i
].pDst
->pFrags
[j
].bufVirtPtr
= (MV_U8
*)pBuf
;
2132 cesaCmdRing
[i
].pDst
->pFrags
[j
].bufSize
= bufSize
;
2139 if (mvCpuIfTargetWinGet(CRYPT_ENG
, &addrDecWin
) == MV_OK
)
2140 pSram
= (char*)addrDecWin
.addrWin
.baseLow
;
2143 mvOsPrintf("mvCesaInit: ERR. mvCpuIfTargetWinGet failed\n");
2147 #ifdef MV_CESA_NO_SRAM
2148 pSram
= mvOsMalloc(4*1024+8);
2151 mvOsPrintf("CesaTest: can't allocate %d bytes for SRAM simulation\n",
2153 /* !!!! Dima cesaTestCleanup();*/
2156 pSram
= (MV_U8
*)MV_ALIGN_UP((MV_U32
)pSram
, 8);
2157 #endif /* MV_CESA_NO_SRAM */
2159 numOfSessions
= CESA_DEF_SESSION_NUM
;
2160 queueDepth
= CESA_DEF_REQ_SIZE
- MV_CESA_MAX_CHAN
;
2162 status
= mvCesaInit(numOfSessions
, queueDepth
, pSram
, NULL
);
2165 mvOsPrintf("mvCesaInit is Failed: status = 0x%x\n", status
);
2166 /* !!!! Dima cesaTestCleanup();*/
2169 #endif /* !MV_NETBSD */
2171 /* Prepare data for tests */
2173 strcat((char*)cesaDataHexStr3
, "dd");
2175 strcpy((char*)cesaDataAndMd5digest3
, cesaDataHexStr3
);
2176 strcpy((char*)cesaDataAndSha1digest3
, cesaDataHexStr3
);
2178 /* Digest must be 8 byte aligned */
2181 strcat((char*)cesaDataAndMd5digest3
, "00");
2182 strcat((char*)cesaDataAndSha1digest3
, "00");
2184 strcat((char*)cesaDataAndMd5digest3
, cesaHmacMd5digestHex3
);
2185 strcat((char*)cesaDataAndSha1digest3
, cesaHmacSha1digestHex3
);
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
);
2196 status
= intConnect((VOIDFUNCPTR
*)INT_LVL_CESA
, cesaTestReadyIsr
, (int)NULL
);
2199 mvOsPrintf("CESA: Can't connect CESA (%d) interrupt, status=0x%x \n",
2200 INT_LVL_CESA
, status
);
2201 /* !!!! Dima cesaTestCleanup();*/
2204 cesaSemId
= semMCreate(SEM_Q_PRIORITY
| SEM_INVERSION_SAFE
| SEM_DELETE_SAFE
);
2205 if(cesaSemId
== NULL
)
2207 mvOsPrintf("cesaTestStart: Can't create semaphore\n");
2210 intEnable(INT_LVL_CESA
);
2212 #endif /* MV_VXWORKS */
2214 #if !defined(MV_NETBSD) && defined(__KERNEL__)
2215 if( request_irq(CESA_IRQ
, cesaTestReadyIsr
, (SA_INTERRUPT
) , "cesa_test", NULL
) )
2217 mvOsPrintf( "cannot assign irq\n" );
2218 /* !!!! Dima cesaTestCleanup();*/
2221 spin_lock_init( &cesaLock
);
2225 MV_STATUS
testRun(int idx
, int caseIdx
, int iter
,
2226 int reqSize
, int checkMode
)
2228 int testIdx
, count
, sid
, digestSize
;
2230 MV_CESA_TEST_SESSION
* pTestSession
;
2231 MV_CESA_COMMAND cmd
;
2234 memset(&cmd
, 0, sizeof(cmd
));
2236 pTestSession
= getTestSessionDb(idx
, &testIdx
);
2237 if(pTestSession
== NULL
)
2239 mvOsPrintf("Test %d is not exist\n", idx
);
2240 return MV_BAD_PARAM
;
2242 pTestSession
= &pTestSession
[testIdx
];
2244 sid
= pTestSession
->sid
;
2247 mvOsPrintf("Test %d is not opened\n", idx
);
2248 return MV_BAD_STATE
;
2250 switch(pTestSession
->cryptoAlgorithm
)
2252 case MV_CESA_CRYPTO_DES
:
2253 case MV_CESA_CRYPTO_3DES
:
2254 blockSize
= MV_CESA_DES_BLOCK_SIZE
;
2257 case MV_CESA_CRYPTO_AES
:
2258 blockSize
= MV_CESA_AES_BLOCK_SIZE
;
2261 case MV_CESA_CRYPTO_NULL
:
2266 mvOsPrintf("cesaTestRun: Bad CryptoAlgorithm=%d\n",
2267 pTestSession
->cryptoAlgorithm
);
2268 return MV_BAD_PARAM
;
2270 switch(pTestSession
->macAlgorithm
)
2272 case MV_CESA_MAC_MD5
:
2273 case MV_CESA_MAC_HMAC_MD5
:
2274 digestSize
= MV_CESA_MD5_DIGEST_SIZE
;
2277 case MV_CESA_MAC_SHA1
:
2278 case MV_CESA_MAC_HMAC_SHA1
:
2279 digestSize
= MV_CESA_SHA1_DIGEST_SIZE
;
2286 iter
= CESA_DEF_ITER_NUM
;
2288 if(pTestSession
->direction
== MV_CESA_DIR_ENCODE
)
2290 cesaOutputHexStr
= cesaTestCases
[caseIdx
].cipherHexStr
;
2291 cesaInputHexStr
= cesaTestCases
[caseIdx
].plainHexStr
;
2295 cesaOutputHexStr
= cesaTestCases
[caseIdx
].plainHexStr
;
2296 cesaInputHexStr
= cesaTestCases
[caseIdx
].cipherHexStr
;
2299 cmd
.sessionId
= sid
;
2300 if(checkMode
== CESA_FAST_CHECK_MODE
)
2302 cmd
.cryptoLength
= cesaTestCases
[caseIdx
].cryptoLength
;
2303 cmd
.macLength
= cesaTestCases
[caseIdx
].macLength
;
2307 cmd
.cryptoLength
= reqSize
;
2308 cmd
.macLength
= reqSize
;
2310 cesaRateSize
= cmd
.cryptoLength
;
2311 cesaReqSize
= cmd
.cryptoLength
;
2312 cmd
.cryptoOffset
= 0;
2313 if(pTestSession
->operation
!= MV_CESA_MAC_ONLY
)
2315 if( (pTestSession
->cryptoMode
== MV_CESA_CRYPTO_CBC
) ||
2316 (pTestSession
->cryptoMode
== MV_CESA_CRYPTO_CTR
) )
2319 cmd
.cryptoOffset
= blockSize
;
2320 if(cesaTestCases
[caseIdx
].pCryptoIV
== NULL
)
2327 mvCesaCryptoIvSet(cesaTestCases
[caseIdx
].pCryptoIV
, blockSize
);
2329 cesaReqSize
= cmd
.cryptoOffset
+ cmd
.cryptoLength
;
2334 mvOsPrintf("ivFromUser=%d, cryptoLength=%d, cesaReqSize=%d, cryptoOffset=%d\n",
2335 cmd.ivFromUser, cmd.cryptoLength, cesaReqSize, cmd.cryptoOffset);
2337 if(pTestSession
->operation
!= MV_CESA_CRYPTO_ONLY
)
2339 cmd
.macOffset
= cmd
.cryptoOffset
;
2341 if(cesaTestCases
[caseIdx
].digestOffset
== -1)
2343 cmd
.digestOffset
= cmd
.macOffset
+ cmd
.macLength
;
2344 cmd
.digestOffset
= MV_ALIGN_UP(cmd
.digestOffset
, 8);
2348 cmd
.digestOffset
= cesaTestCases
[caseIdx
].digestOffset
;
2350 if( (cmd
.digestOffset
+ digestSize
) > cesaReqSize
)
2351 cesaReqSize
= cmd
.digestOffset
+ digestSize
;
2354 cesaCheckMode
= checkMode
;
2356 if(checkMode
== CESA_NULL_CHECK_MODE
)
2359 cesaCheckOffset
= 0;
2363 if(pTestSession
->operation
== MV_CESA_CRYPTO_ONLY
)
2365 cesaCheckOffset
= 0;
2366 cesaCheckSize
= cmd
.cryptoLength
;
2370 cesaCheckSize
= digestSize
;
2371 cesaCheckOffset
= cmd
.digestOffset
;
2375 mvOsPrintf("reqSize=%d, checkSize=%d, checkOffset=%d, checkMode=%d\n",
2376 cesaReqSize, cesaCheckSize, cesaCheckOffset, cesaCheckMode);
2378 mvOsPrintf("blockSize=%d, ivOffset=%d, ivFromUser=%d, crOffset=%d, crLength=%d\n",
2379 blockSize, cmd.ivOffset, cmd.ivFromUser,
2380 cmd.cryptoOffset, cmd.cryptoLength);
2382 mvOsPrintf("macOffset=%d, digestOffset=%d, macLength=%d\n",
2383 cmd.macOffset, cmd.digestOffset, cmd.macLength);
2385 status
= testCmd(sid
, iter
, &cmd
, pTestSession
,
2386 cesaTestCases
[caseIdx
].pCryptoIV
, blockSize
);
2391 /* Wait when all callbacks is received */
2393 while(cesaIsReady
== MV_FALSE
)
2399 mvOsPrintf("testRun: Timeout occured\n");
2408 void cesaTestStop(void)
2410 MV_CESA_MBUF
*pMbufSrc
, *pMbufDst
;
2411 MV_BUF_INFO
*pFragsSrc
, *pFragsDst
;
2414 /* Release all allocated memories */
2415 pMbufSrc
= (MV_CESA_MBUF
*)(cesaCmdRing
[0].pSrc
);
2416 pFragsSrc
= cesaCmdRing
[0].pSrc
->pFrags
;
2418 pMbufDst
= (MV_CESA_MBUF
*)(cesaCmdRing
[0].pDst
);
2419 pFragsDst
= cesaCmdRing
[0].pDst
->pFrags
;
2423 mvOsFree(pFragsSrc
);
2424 mvOsFree(pFragsDst
);
2426 for(i
=0; i
<CESA_DEF_REQ_SIZE
; i
++)
2428 mvOsIoCachedFree(cesaTestOSHandle
,cesaReqBufs
[i
].bufSize
,
2429 cesaReqBufs
[i
].bufPhysAddr
,cesaReqBufs
[i
].bufVirtPtr
,
2430 cesaReqBufs
[i
].memHandle
);
2432 cesaDataHexStr3
[0] = '\0';
2435 void desTest(int iter
, int reqSize
, int checkMode
)
2441 if(checkMode
== CESA_FULL_CHECK_MODE
)
2442 mode
= CESA_FAST_CHECK_MODE
;
2444 if(mode
!= CESA_NULL_CHECK_MODE
)
2452 /* DES / ECB mode / Encrypt only */
2453 status
= testRun(0, 1, iter
, reqSize
, checkMode
);
2454 printTestResults(0, status
, checkMode
);
2456 /* DES / ECB mode / Decrypt only */
2457 status
= testRun(1, 1, iter
, reqSize
, checkMode
);
2458 printTestResults(1, status
, checkMode
);
2460 /* DES / CBC mode / Encrypt only */
2461 status
= testRun(2, 2, i
, reqSize
, mode
);
2462 printTestResults(2, status
, mode
);
2464 /* DES / CBC mode / Decrypt only */
2465 status
= testRun(3, 2, iter
, reqSize
, mode
);
2466 printTestResults(3, status
, mode
);
2474 void tripleDesTest(int iter
, int reqSize
, int checkMode
)
2480 if(checkMode
== CESA_FULL_CHECK_MODE
)
2481 mode
= CESA_FAST_CHECK_MODE
;
2483 if(mode
!= CESA_NULL_CHECK_MODE
)
2491 /* 3DES / ECB mode / Encrypt only */
2492 status
= testRun(100, 1, iter
, reqSize
, checkMode
);
2493 printTestResults(100, status
, checkMode
);
2495 /* 3DES / ECB mode / Decrypt only */
2496 status
= testRun(101, 1, iter
, reqSize
, checkMode
);
2497 printTestResults(101, status
, checkMode
);
2499 /* 3DES / CBC mode / Encrypt only */
2500 status
= testRun(102, 2, i
, reqSize
, mode
);
2501 printTestResults(102, status
, mode
);
2503 /* 3DES / CBC mode / Decrypt only */
2504 status
= testRun(103, 2, iter
, reqSize
, mode
);
2505 printTestResults(103, status
, mode
);
2513 void aesTest(int iter
, int reqSize
, int checkMode
)
2519 if(checkMode
== CESA_FULL_CHECK_MODE
)
2520 mode
= CESA_FAST_CHECK_MODE
;
2523 if(mode
!= CESA_NULL_CHECK_MODE
)
2536 /* AES-128 Encode ECB mode */
2537 status
= testRun(200, 3, iter
, reqSize
, checkMode
);
2538 printTestResults(200, status
, checkMode
);
2540 /* AES-128 Decode ECB mode */
2541 status
= testRun(201, 3, iter
, reqSize
, checkMode
);
2542 printTestResults(201, status
, checkMode
);
2544 /* AES-128 Encode CBC mode (IV from SA) */
2545 status
= testRun(202, 10, i
, reqSize
, mode
);
2546 printTestResults(202, status
, mode
);
2548 /* AES-128 Encode CBC mode (IV from User) */
2549 status
= testRun(202, 24, i
, reqSize
, mode
);
2550 printTestResults(202, status
, mode
);
2552 /* AES-128 Decode CBC mode */
2553 status
= testRun(203, 24, iter
, reqSize
, mode
);
2554 printTestResults(203, status
, checkMode
);
2556 /* AES-192 Encode ECB mode */
2557 status
= testRun(204, 4, iter
, reqSize
, checkMode
);
2558 printTestResults(204, status
, checkMode
);
2560 /* AES-192 Decode ECB mode */
2561 status
= testRun(205, 4, iter
, reqSize
, checkMode
);
2562 printTestResults(205, status
, checkMode
);
2564 /* AES-256 Encode ECB mode */
2565 status
= testRun(206, 5, iter
, reqSize
, checkMode
);
2566 printTestResults(206, status
, checkMode
);
2568 /* AES-256 Decode ECB mode */
2569 status
= testRun(207, 5, iter
, reqSize
, checkMode
);
2570 printTestResults(207, status
, checkMode
);
2572 #if defined(MV_LINUX)
2573 /* AES-128 Encode CTR mode */
2574 status
= testRun(208, 23, iter
, reqSize
, mode
);
2575 printTestResults(208, status
, checkMode
);
2589 void mdTest(int iter
, int reqSize
, int checkMode
)
2595 iter
= CESA_DEF_ITER_NUM
;
2598 if(checkMode
== CESA_FULL_CHECK_MODE
)
2599 mode
= CESA_FAST_CHECK_MODE
;
2607 /* HMAC-MD5 Generate signature test */
2608 status
= testRun(300, 6, iter
, reqSize
, mode
);
2609 printTestResults(300, status
, checkMode
);
2611 /* HMAC-MD5 Verify Signature test */
2612 status
= testRun(301, 7, iter
, reqSize
, mode
);
2613 printTestResults(301, status
, checkMode
);
2615 /* HMAC-MD5 Generate signature test */
2616 status
= testRun(302, 8, iter
, reqSize
, mode
);
2617 printTestResults(302, status
, checkMode
);
2619 /* HMAC-MD5 Verify Signature test */
2620 status
= testRun(303, 9, iter
, reqSize
, mode
);
2621 printTestResults(303, status
, checkMode
);
2623 /* HASH-MD5 Generate signature test */
2624 status
= testRun(305, 15, iter
, reqSize
, mode
);
2625 printTestResults(305, status
, checkMode
);
2634 void shaTest(int iter
, int reqSize
, int checkMode
)
2640 iter
= CESA_DEF_ITER_NUM
;
2643 if(checkMode
== CESA_FULL_CHECK_MODE
)
2644 mode
= CESA_FAST_CHECK_MODE
;
2652 /* HMAC-SHA1 Generate signature test */
2653 status
= testRun(400, 11, iter
, reqSize
, mode
);
2654 printTestResults(400, status
, checkMode
);
2656 /* HMAC-SHA1 Verify Signature test */
2657 status
= testRun(401, 12, iter
, reqSize
, mode
);
2658 printTestResults(401, status
, checkMode
);
2660 /* HMAC-SHA1 Generate signature test */
2661 status
= testRun(402, 13, iter
, reqSize
, mode
);
2662 printTestResults(402, status
, checkMode
);
2664 /* HMAC-SHA1 Verify Signature test */
2665 status
= testRun(403, 14, iter
, reqSize
, mode
);
2666 printTestResults(403, status
, checkMode
);
2668 /* HMAC-SHA1 Generate signature test */
2669 status
= testRun(405, 16, iter
, reqSize
, mode
);
2670 printTestResults(405, status
, checkMode
);
2679 void combiTest(int iter
, int reqSize
, int checkMode
)
2685 if(checkMode
== CESA_FULL_CHECK_MODE
)
2686 mode
= CESA_FAST_CHECK_MODE
;
2689 iter
= CESA_DEF_ITER_NUM
;
2692 if(mode
!= CESA_NULL_CHECK_MODE
)
2704 /* DES ECB + MD5 encode test */
2705 status
= testRun(500, 17, iter
, reqSize
, mode
);
2706 printTestResults(500, status
, mode
);
2708 /* DES ECB + SHA1 encode test */
2709 status
= testRun(501, 18, iter
, reqSize
, mode
);
2710 printTestResults(501, status
, mode
);
2712 /* 3DES ECB + MD5 encode test */
2713 status
= testRun(502, 17, iter
, reqSize
, mode
);
2714 printTestResults(502, status
, mode
);
2716 /* 3DES ECB + SHA1 encode test */
2717 status
= testRun(503, 18, iter
, reqSize
, mode
);
2718 printTestResults(503, status
, mode
);
2720 /* 3DES CBC + MD5 encode test */
2721 status
= testRun(504, 19, i
, reqSize
, mode
);
2722 printTestResults(504, status
, mode
);
2724 /* 3DES CBC + SHA1 encode test */
2725 status
= testRun(505, 20, i
, reqSize
, mode
);
2726 printTestResults(505, status
, mode
);
2728 /* AES-128 CBC + MD5 encode test */
2729 status
= testRun(506, 21, i
, reqSize
, mode
);
2730 printTestResults(506, status
, mode
);
2732 /* AES-128 CBC + SHA1 encode test */
2733 status
= testRun(507, 22, i
, reqSize
, mode
);
2734 printTestResults(507, status
, mode
);
2746 void cesaOneTest(int testIdx
, int caseIdx
,
2747 int iter
, int reqSize
, int checkMode
)
2752 iter
= CESA_DEF_ITER_NUM
;
2754 mvOsPrintf("test=%d, case=%d, size=%d, iter=%d\n",
2755 testIdx
, caseIdx
, reqSize
, iter
);
2757 status
= testOpen(testIdx
);
2759 status
= testRun(testIdx
, caseIdx
, iter
, reqSize
, checkMode
);
2760 printTestResults(testIdx
, status
, checkMode
);
2761 status
= testClose(testIdx
);
2765 void cesaTest(int iter
, int reqSize
, int checkMode
)
2768 iter
= CESA_DEF_ITER_NUM
;
2770 mvOsPrintf("%d iteration\n", iter
);
2771 mvOsPrintf("%d size\n\n", reqSize
);
2774 desTest(iter
, reqSize
, checkMode
);
2777 tripleDesTest(iter
, reqSize
, checkMode
);
2780 aesTest(iter
, reqSize
, checkMode
);
2783 mdTest(iter
, reqSize
, checkMode
);
2786 shaTest(iter
, reqSize
, checkMode
);
2789 void multiSizeTest(int idx
, int iter
, int checkMode
, char* inputData
)
2793 MV_CESA_SIZE_TEST
* pMultiTest
;
2795 if( testOpen(idx
) != MV_OK
)
2799 iter
= CESA_DEF_ITER_NUM
;
2801 if(checkMode
== CESA_SHOW_CHECK_MODE
)
2806 checkMode
= CESA_FULL_CHECK_MODE
;
2808 cesaTestCases
[0].plainHexStr
= inputData
;
2809 cesaTestCases
[0].pCryptoIV
= NULL
;
2814 pMultiTest
= mdMultiSizeTest302
;
2815 if(inputData
== NULL
)
2816 cesaTestCases
[0].plainHexStr
= cesaDataHexStr3
;
2820 pMultiTest
= mdMultiSizeTest304
;
2821 if(inputData
== NULL
)
2822 cesaTestCases
[0].plainHexStr
= hashHexStr80
;
2826 pMultiTest
= mdMultiSizeTest305
;
2827 if(inputData
== NULL
)
2828 cesaTestCases
[0].plainHexStr
= hashHexStr80
;
2832 pMultiTest
= shaMultiSizeTest402
;
2833 if(inputData
== NULL
)
2834 cesaTestCases
[0].plainHexStr
= hashHexStr80
;
2838 pMultiTest
= shaMultiSizeTest404
;
2839 if(inputData
== NULL
)
2840 cesaTestCases
[0].plainHexStr
= hashHexStr80
;
2844 pMultiTest
= shaMultiSizeTest405
;
2845 if(inputData
== NULL
)
2846 cesaTestCases
[0].plainHexStr
= hashHexStr80
;
2850 pMultiTest
= tripleDesMdMultiSizeTest502
;
2851 if(inputData
== NULL
)
2852 cesaTestCases
[0].plainHexStr
= hashHexStr80
;
2856 pMultiTest
= tripleDesShaMultiSizeTest503
;
2857 if(inputData
== NULL
)
2858 cesaTestCases
[0].plainHexStr
= hashHexStr80
;
2863 pMultiTest
= cbc3desMdMultiSizeTest504
;
2864 cesaTestCases
[0].pCryptoIV
= iv1
;
2865 if(inputData
== NULL
)
2866 cesaTestCases
[0].plainHexStr
= hashHexStr80
;
2871 pMultiTest
= cbc3desShaMultiSizeTest505
;
2872 cesaTestCases
[0].pCryptoIV
= iv1
;
2873 if(inputData
== NULL
)
2874 cesaTestCases
[0].plainHexStr
= hashHexStr80
;
2879 pMultiTest
= cbcAes128md5multiSizeTest506
;
2880 cesaTestCases
[0].pCryptoIV
= iv5
;
2881 if(inputData
== NULL
)
2882 cesaTestCases
[0].plainHexStr
= hashHexStr80
;
2887 pMultiTest
= cbcAes128sha1multiSizeTest507
;
2888 cesaTestCases
[0].pCryptoIV
= iv5
;
2889 if(inputData
== NULL
)
2890 cesaTestCases
[0].plainHexStr
= hashHexStr80
;
2895 checkMode
= CESA_SHOW_CHECK_MODE
;
2896 pMultiTest
= mdMultiSizeTest302
;
2897 if(inputData
== NULL
)
2898 cesaTestCases
[0].plainHexStr
= hashHexStr80
;
2901 while(pMultiTest
[i
].outputHexStr
!= NULL
)
2903 cesaTestCases
[0].cipherHexStr
= (char *)pMultiTest
[i
].outputHexStr
;
2904 status
= testRun(idx
, 0, iter
, pMultiTest
[i
].size
,
2906 if(checkMode
!= CESA_SHOW_CHECK_MODE
)
2908 cesaReqSize
= pMultiTest
[i
].size
;
2909 printTestResults(idx
, status
, checkMode
);
2917 mvCesaDebugStatus();
2918 cesaTestPrintStatus();
2922 void open_session_test(int idx
, int caseIdx
, int iter
)
2924 int reqIdError
, cryptoError
, openErrors
, i
;
2925 int openErrDisp
[100];
2928 memset(openErrDisp
, 0, sizeof(openErrDisp
));
2932 for(i
=0; i
<iter
; i
++)
2934 status
= testOpen(idx
);
2938 openErrDisp
[status
]++;
2942 testRun(idx
, caseIdx
, 1, 0, CESA_FAST_CHECK_MODE
);
2943 if(cesaCryptoError
> 0)
2945 if(cesaReqIdError
> 0)
2952 mvOsPrintf("cryptoError : %d\n", cryptoError
);
2954 mvOsPrintf("reqIdError : %d\n", reqIdError
);
2958 mvOsPrintf("Open Errors = %d\n", openErrors
);
2959 for(i
=0; i
<100; i
++)
2961 if(openErrDisp
[i
] != 0)
2962 mvOsPrintf("Error %d - occurs %d times\n", i
, openErrDisp
[i
]);
2968 void loopback_test(int idx
, int iter
, int size
, char* pPlainData
)
2973 #if defined(MV_VXWORKS)
2975 unsigned __TASKCONV
cesaTask(void* args
)
2977 int reqSize
= cesaReqSize
;
2981 cesaOneTest(cesaTestIdx
, cesaCaseIdx
, cesaIteration
,
2982 reqSize
, cesaCheckMode
);
2988 cesaTest(cesaIteration
, reqSize
, cesaCheckMode
);
2989 combiTest(cesaIteration
, reqSize
, cesaCheckMode
);
2993 multiSizeTest(cesaIdx
, cesaIteration
, cesaCheckMode
, NULL
);
2999 void oneTest(int testIdx
, int caseIdx
,
3000 int iter
, int reqSize
, int checkMode
)
3004 cesaIteration
= iter
;
3005 cesaReqSize
= cesaRateSize
= reqSize
;
3006 cesaCheckMode
= checkMode
;
3008 cesaTestIdx
= testIdx
;
3009 cesaCaseIdx
= caseIdx
;
3010 rc
= mvOsTaskCreate("CESA_T", 100, 4*1024, cesaTask
, NULL
, &cesaTaskId
);
3013 mvOsPrintf("hMW: Can't create CESA multiCmd test task, rc = %ld\n", rc
);
3017 void multiTest(int iter
, int reqSize
, int checkMode
)
3021 cesaIteration
= iter
;
3022 cesaCheckMode
= checkMode
;
3023 cesaReqSize
= reqSize
;
3025 rc
= mvOsTaskCreate("CESA_T", 100, 4*1024, cesaTask
, NULL
, &cesaTaskId
);
3028 mvOsPrintf("hMW: Can't create CESA multiCmd test task, rc = %ld\n", rc
);
3032 void sizeTest(int testIdx
, int iter
, int checkMode
)
3036 cesaIteration
= iter
;
3037 cesaCheckMode
= checkMode
;
3040 rc
= mvOsTaskCreate("CESA_T", 100, 4*1024, cesaTask
, NULL
, &cesaTaskId
);
3043 mvOsPrintf("hMW: Can't create CESA test task, rc = %ld\n", rc
);
3047 #endif /* MV_VXWORKS */
3049 extern void mvCesaDebugSA(short sid
, int mode
);
3050 void cesaTestPrintSession(int idx
)
3053 MV_CESA_TEST_SESSION
* pTestSession
;
3055 pTestSession
= getTestSessionDb(idx
, &testIdx
);
3056 if(pTestSession
== NULL
)
3058 mvOsPrintf("Test %d is not exist\n", idx
);
3061 pTestSession
= &pTestSession
[testIdx
];
3063 if(pTestSession
->sid
== -1)
3065 mvOsPrintf("Test session %d is not opened\n", idx
);
3069 mvCesaDebugSA(pTestSession
->sid
, 1);
3072 void cesaTestPrintStatus(void)
3074 mvOsPrintf("\n\t Cesa Test Status\n\n");
3076 mvOsPrintf("isrCount=%d\n",
3079 #ifdef CESA_TEST_DEBUG
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
++)
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
);
3091 if(j
== MV_CESA_TEST_TRACE_SIZE
)
3095 #endif /* CESA_TEST_DEBUG */