1 /*
2 * Copyright (C) 2022 Huawei Technologies Co., Ltd.
3 * Licensed under the Mulan PSL v2.
4 * You can use this software according to the terms and conditions of the Mulan PSL v2.
5 * You may obtain a copy of Mulan PSL v2 at:
6 * http://license.coscl.org.cn/MulanPSL2
7 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
8 * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
9 * PURPOSE.
10 * See the Mulan PSL v2 for more details.
11 */
12
13 #include "monad.h"
14 #include "tee_log.h"
15
16 // Crypto_AsymSign_Fun_001
CaseAsymSignRsaV15Sha384KeySize2048Once(void)17 int CaseAsymSignRsaV15Sha384KeySize2048Once(void)
18 {
19 TestVector tv = {
20 .algName = {"AS_sv_rsa_v15_sha384"},
21 .operaMaxKeySize = 2048,
22 .keySize = 2048,
23 .rsaGenPubExpId = TST_RSA_KEYGEN_PUB_EXP_ID_3,
24 .fwdKeyTypeName = "kt_rsa_pair",
25 .bckKeyTypeName = "kt_rsa_pub",
26 .fwdEngine = FWDENGINE,
27 .bckEngine = BCKENGINE,
28 .dataSize = 48,
29 .actions = {
30 IRSetUp,
31 GlbAlloc, GlbS1S2,
32 ASSignFwd,
33 ASVerifyBck,
34 GlbFree,
35 IRTearDown, },
36 .actionsSize = 7,
37 .expRet = ER_OK,
38 };
39 int ret = MonadRun2(&tv);
40 if (ret != 0) {
41 tloge("[%s]:MonadRun2 failed\n", __func__);
42 return -1;
43 }
44 tlogi("[%s]:MonadRun2 success\n", __func__);
45 tlogi("[%s]:--------------CaseAsymSignRsaV15Sha384KeySize2048Once success\n", __func__);
46 return 0;
47 }
48
49 // Crypto_AsymSign_Fun_002
CaseAsymSignRsaV15Sha384KeySize2048Multi(void)50 int CaseAsymSignRsaV15Sha384KeySize2048Multi(void)
51 {
52 TestVector tv = {
53 .algName = {"AS_sv_rsa_v15_sha384"},
54 .operaMaxKeySize = 2048,
55 .keySize = 2048,
56 .rsaGenPubExpId = TST_RSA_KEYGEN_PUB_EXP_ID_3,
57 .fwdKeyTypeName = "kt_rsa_pair",
58 .bckKeyTypeName = "kt_rsa_pub",
59 .fwdEngine = FWDENGINE,
60 .bckEngine = BCKENGINE,
61 .dataSize = 48,
62 .actions = {
63 IRSetUp,
64 GlbAlloc, GlbS1S2,
65 ASSignFwd, ASVerifyBck,
66 ASSignFwd, ASVerifyBck,
67 GlbFree,
68 IRTearDown, },
69 .actionsSize = 9,
70 .expRet = ER_OK,
71 };
72 int ret = MonadRun2(&tv);
73 if (ret != 0) {
74 tloge("[%s]:MonadRun2 failed\n", __func__);
75 return -1;
76 }
77 tlogi("[%s]:MonadRun2 success\n", __func__);
78 tlogi("[%s]:--------------CaseAsymSignRsaV15Sha384KeySize2048Multi success\n", __func__);
79 return 0;
80 }
81
82 // Crypto_AsymSign_Fun_001
CaseAsymSignRsaV15Sha512KeySize4096Once(void)83 int CaseAsymSignRsaV15Sha512KeySize4096Once(void)
84 {
85 TestVector tv = {
86 .algName = {"AS_sv_rsa_v15_sha512"},
87 .operaMaxKeySize = 4096,
88 .keySize = 4096,
89 .rsaGenPubExpId = TST_RSA_KEYGEN_PUB_EXP_ID_4,
90 .fwdKeyTypeName = "kt_rsa_pair",
91 .bckKeyTypeName = "kt_rsa_pub",
92 .fwdEngine = FWDENGINE,
93 .bckEngine = BCKENGINE,
94 .dataSize = 64,
95 .actions = {
96 IRSetUp,
97 GlbAlloc, GlbS1S2,
98 ASSignFwd,
99 ASVerifyBck,
100 GlbFree,
101 IRTearDown, },
102 .actionsSize = 7,
103 .expRet = ER_OK,
104 };
105 int ret = MonadRun2(&tv);
106 if (ret != 0) {
107 tloge("[%s]:MonadRun2 failed\n", __func__);
108 return -1;
109 }
110 tlogi("[%s]:MonadRun2 success\n", __func__);
111 tlogi("[%s]:--------------CaseAsymSignRsaV15Sha512KeySize4096Once success\n", __func__);
112 return 0;
113 }
114
115 // Crypto_AsymSign_Fun_002
CaseAsymSignRsaV15Sha512KeySize4096Multi(void)116 int CaseAsymSignRsaV15Sha512KeySize4096Multi(void)
117 {
118 TestVector tv = {
119 .algName = {"AS_sv_rsa_v15_sha512"},
120 .operaMaxKeySize = 4096,
121 .keySize = 4096,
122 .rsaGenPubExpId = TST_RSA_KEYGEN_PUB_EXP_ID_4,
123 .fwdKeyTypeName = "kt_rsa_pair",
124 .bckKeyTypeName = "kt_rsa_pub",
125 .fwdEngine = FWDENGINE,
126 .bckEngine = BCKENGINE,
127 .dataSize = 64,
128 .actions = {
129 IRSetUp,
130 GlbAlloc, GlbS1S2,
131 ASSignFwd, ASVerifyBck,
132 ASSignFwd, ASVerifyBck,
133 GlbFree,
134 IRTearDown, },
135 .actionsSize = 9,
136 .expRet = ER_OK,
137 };
138 int ret = MonadRun2(&tv);
139 if (ret != 0) {
140 tloge("[%s]:MonadRun2 failed\n", __func__);
141 return -1;
142 }
143 tlogi("[%s]:MonadRun2 success\n", __func__);
144 tlogi("[%s]:--------------CaseAsymSignRsaV15Sha512KeySize4096Multi success\n", __func__);
145 return 0;
146 }
147
148 // Crypto_AsymSign_Fun_003
CaseAsymSignRsaPssSha384KeySize2048Once(void)149 int CaseAsymSignRsaPssSha384KeySize2048Once(void)
150 {
151 TestVector tv = {
152 .algName = {"AS_sv_rsa_pss_SHA384"},
153 .operaMaxKeySize = 2048,
154 .keySize = 2048,
155 .rsaGenPubExpId = TST_RSA_KEYGEN_PUB_EXP_ID_3,
156 .fwdKeyTypeName = "kt_rsa_pair",
157 .bckKeyTypeName = "kt_rsa_pair",
158 .fwdEngine = FWDENGINE,
159 .bckEngine = BCKENGINE,
160 .dataSize = 48,
161 .actions = {
162 IRSetUp,
163 GlbAlloc, GlbS1S2,
164 ASSignFwd,
165 ASVerifyBck,
166 GlbFree,
167 IRTearDown, },
168 .actionsSize = 7,
169 .expRet = ER_OK,
170 };
171 int ret = MonadRun2(&tv);
172 if (ret != 0) {
173 tloge("[%s]:MonadRun2 failed\n", __func__);
174 return -1;
175 }
176 tlogi("[%s]:MonadRun2 success\n", __func__);
177 tlogi("[%s]:--------------CaseAsymSignRsaPssSha384KeySize2048Once success\n", __func__);
178 return 0;
179 }
180
181 // Crypto_AsymSign_Fun_004
CaseAsymSignRsaPssSha384KeySize2048Multi(void)182 int CaseAsymSignRsaPssSha384KeySize2048Multi(void)
183 {
184 TestVector tv = {
185 .algName = {"AS_sv_rsa_pss_SHA384"},
186 .operaMaxKeySize = 2048,
187 .keySize = 2048,
188 .rsaGenPubExpId = TST_RSA_KEYGEN_PUB_EXP_ID_3,
189 .fwdKeyTypeName = "kt_rsa_pair",
190 .bckKeyTypeName = "kt_rsa_pair",
191 .fwdEngine = FWDENGINE,
192 .bckEngine = BCKENGINE,
193 .dataSize = 48,
194 .actions = {
195 IRSetUp,
196 GlbAlloc, GlbS1S2,
197 ASSignFwd, ASVerifyBck,
198 ASSignFwd, ASVerifyBck,
199 GlbFree,
200 IRTearDown, },
201 .actionsSize = 9,
202 .expRet = ER_OK,
203 };
204 int ret = MonadRun2(&tv);
205 if (ret != 0) {
206 tloge("[%s]:MonadRun2 failed\n", __func__);
207 return -1;
208 }
209 tlogi("[%s]:MonadRun2 success\n", __func__);
210 tlogi("[%s]:--------------CaseAsymSignRsaPssSha384KeySize2048Multi success\n", __func__);
211 return 0;
212 }
213
214 // Crypto_AsymSign_Fun_003
CaseAsymSignRsaPssSha512KeySize4096Once(void)215 int CaseAsymSignRsaPssSha512KeySize4096Once(void)
216 {
217 TestVector tv = {
218 .algName = {"AS_sv_rsa_pss_SHA512"},
219 .operaMaxKeySize = 4096,
220 .keySize = 4096,
221 .rsaGenPubExpId = TST_RSA_KEYGEN_PUB_EXP_ID_4,
222 .fwdKeyTypeName = "kt_rsa_pair",
223 .bckKeyTypeName = "kt_rsa_pair",
224 .fwdEngine = FWDENGINE,
225 .bckEngine = BCKENGINE,
226 .dataSize = 64,
227 .actions = {
228 IRSetUp,
229 GlbAlloc, GlbS1S2,
230 ASSignFwd,
231 ASVerifyBck,
232 GlbFree,
233 IRTearDown, },
234 .actionsSize = 7,
235 .expRet = ER_OK,
236 };
237 int ret = MonadRun2(&tv);
238 if (ret != 0) {
239 tloge("[%s]:MonadRun2 failed\n", __func__);
240 return -1;
241 }
242 tlogi("[%s]:MonadRun2 success\n", __func__);
243 tlogi("[%s]:--------------CaseAsymSignRsaPssSha512KeySize4096Once success\n", __func__);
244 return 0;
245 }
246
247 // Crypto_AsymSign_Fun_004
CaseAsymSignRsaPssSha512KeySize4096Multi(void)248 int CaseAsymSignRsaPssSha512KeySize4096Multi(void)
249 {
250 TestVector tv = {
251 .algName = {"AS_sv_rsa_pss_SHA512"},
252 .operaMaxKeySize = 4096,
253 .keySize = 4096,
254 .rsaGenPubExpId = TST_RSA_KEYGEN_PUB_EXP_ID_4,
255 .fwdKeyTypeName = "kt_rsa_pair",
256 .bckKeyTypeName = "kt_rsa_pair",
257 .fwdEngine = FWDENGINE,
258 .bckEngine = BCKENGINE,
259 .dataSize = 64,
260 .actions = {
261 IRSetUp,
262 GlbAlloc, GlbS1S2,
263 ASSignFwd, ASVerifyBck,
264 ASSignFwd, ASVerifyBck,
265 GlbFree,
266 IRTearDown, },
267 .actionsSize = 9,
268 .expRet = ER_OK,
269 };
270 int ret = MonadRun2(&tv);
271 if (ret != 0) {
272 tloge("[%s]:MonadRun2 failed\n", __func__);
273 return -1;
274 }
275 tlogi("[%s]:MonadRun2 success\n", __func__);
276 tlogi("[%s]:--------------CaseAsymSignRsaPssSha512KeySize4096Multi success\n", __func__);
277 return 0;
278 }
279
280 // Crypto_AsymSign_Fun_005
CaseAsymSignEcdsaSha256KeySize256Once(void)281 int CaseAsymSignEcdsaSha256KeySize256Once(void)
282 {
283 TestVector tv = {
284 .algName = {"AS_sv_ecdsa_sha256"},
285 .operaMaxKeySize = 521,
286 .keySize = 256,
287 .ecKeyCurve = TEE_ECC_CURVE_NIST_P256,
288 .fwdKeyTypeName = "kt_ecdsa_pair",
289 .bckKeyTypeName = "kt_ecdsa_pub",
290 .fwdEngine = FWDENGINE,
291 .bckEngine = BCKENGINE,
292 .dataSize = 32,
293 .actions = {
294 IRSetUp,
295 GlbAlloc, GlbS1S2,
296 ASSignFwd,
297 ASVerifyBck,
298 GlbFree,
299 IRTearDown, },
300 .actionsSize = 7,
301 .expRet = ER_OK,
302 };
303 int ret = MonadRun2(&tv);
304 if (ret != 0) {
305 tloge("[%s]:MonadRun2 failed\n", __func__);
306 return -1;
307 }
308 tlogi("[%s]:MonadRun2 success\n", __func__);
309 tlogi("[%s]:--------------CaseAsymSignEcdsaSha256KeySize256Once success\n", __func__);
310 return 0;
311 }
312
313 // Crypto_AsymSign_Fun_006
CaseAsymSignEcdsaSha256KeySize256Multi(void)314 int CaseAsymSignEcdsaSha256KeySize256Multi(void)
315 {
316 TestVector tv = {
317 .algName = {"AS_sv_ecdsa_sha256"},
318 .operaMaxKeySize = 521,
319 .keySize = 256,
320 .ecKeyCurve = TEE_ECC_CURVE_NIST_P256,
321 .fwdKeyTypeName = "kt_ecdsa_pair",
322 .bckKeyTypeName = "kt_ecdsa_pub",
323 .fwdEngine = FWDENGINE,
324 .bckEngine = BCKENGINE,
325 .dataSize = 32,
326 .actions = {
327 IRSetUp,
328 GlbAlloc, GlbS1S2,
329 ASSignFwd, ASVerifyBck,
330 ASSignFwd, ASVerifyBck,
331 GlbFree,
332 IRTearDown, },
333 .actionsSize = 9,
334 .expRet = ER_OK,
335 };
336 int ret = MonadRun2(&tv);
337 if (ret != 0) {
338 tloge("[%s]:MonadRun2 failed\n", __func__);
339 return -1;
340 }
341 tlogi("[%s]:MonadRun2 success\n", __func__);
342 tlogi("[%s]:--------------CaseAsymSignEcdsaSha256KeySize256Multi success\n", __func__);
343 return 0;
344 }
345
346 // Crypto_AsymSign_Fun_005
CaseAsymSignEcdsaSha384KeySize384Once(void)347 int CaseAsymSignEcdsaSha384KeySize384Once(void)
348 {
349 TestVector tv = {
350 .algName = {"AS_sv_ecdsa_sha384"},
351 .operaMaxKeySize = 521,
352 .keySize = 384,
353 .ecKeyCurve = TEE_ECC_CURVE_NIST_P384,
354 .fwdKeyTypeName = "kt_ecdsa_pair",
355 .bckKeyTypeName = "kt_ecdsa_pair",
356 .fwdEngine = FWDENGINE,
357 .bckEngine = BCKENGINE,
358 .dataSize = 48,
359 .actions = {
360 IRSetUp,
361 GlbAlloc, GlbS1S2,
362 ASSignFwd,
363 ASVerifyBck,
364 GlbFree,
365 IRTearDown, },
366 .actionsSize = 7,
367 .expRet = ER_OK,
368 };
369 int ret = MonadRun2(&tv);
370 if (ret != 0) {
371 tloge("[%s]:MonadRun2 failed\n", __func__);
372 return -1;
373 }
374 tlogi("[%s]:MonadRun2 success\n", __func__);
375 tlogi("[%s]:--------------CaseAsymSignEcdsaSha384KeySize384Once success\n", __func__);
376 return 0;
377 }
378
379 // Crypto_AsymSign_Fun_006
CaseAsymSignEcdsaSha384KeySize384Multi(void)380 int CaseAsymSignEcdsaSha384KeySize384Multi(void)
381 {
382 TestVector tv = {
383 .algName = {"AS_sv_ecdsa_sha384"},
384 .operaMaxKeySize = 521,
385 .keySize = 384,
386 .ecKeyCurve = TEE_ECC_CURVE_NIST_P384,
387 .fwdKeyTypeName = "kt_ecdsa_pair",
388 .bckKeyTypeName = "kt_ecdsa_pair",
389 .fwdEngine = FWDENGINE,
390 .bckEngine = BCKENGINE,
391 .dataSize = 48,
392 .actions = {
393 IRSetUp,
394 GlbAlloc, GlbS1S2,
395 ASSignFwd, ASVerifyBck,
396 ASSignFwd, ASVerifyBck,
397 GlbFree,
398 IRTearDown, },
399 .actionsSize = 9,
400 .expRet = ER_OK,
401 };
402 int ret = MonadRun2(&tv);
403 if (ret != 0) {
404 tloge("[%s]:MonadRun2 failed\n", __func__);
405 return -1;
406 }
407 tlogi("[%s]:MonadRun2 success\n", __func__);
408 tlogi("[%s]:--------------CaseAsymSignEcdsaSha384KeySize384Multi success\n", __func__);
409 return 0;
410 }
411
412 // Crypto_AsymSign_Fun_005
CaseAsymSignEcdsaSha512KeySize521Once(void)413 int CaseAsymSignEcdsaSha512KeySize521Once(void)
414 {
415 TestVector tv = {
416 .algName = {"AS_sv_ecdsa_sha512"},
417 .operaMaxKeySize = 521,
418 .keySize = 521,
419 .ecKeyCurve = TEE_ECC_CURVE_NIST_P521,
420 .fwdKeyTypeName = "kt_ecdsa_pair",
421 .bckKeyTypeName = "kt_ecdsa_pair",
422 .fwdEngine = FWDENGINE,
423 .bckEngine = BCKENGINE,
424 .dataSize = 64,
425 .actions = {
426 IRSetUp,
427 GlbAlloc, GlbS1S2,
428 ASSignFwd,
429 ASVerifyBck,
430 GlbFree,
431 IRTearDown, },
432 .actionsSize = 7,
433 .expRet = ER_OK,
434 };
435 int ret = MonadRun2(&tv);
436 if (ret != 0) {
437 tloge("[%s]:MonadRun2 failed\n", __func__);
438 return -1;
439 }
440 tlogi("[%s]:MonadRun2 success\n", __func__);
441 tlogi("[%s]:--------------CaseAsymSignEcdsaSha512KeySize521Once success\n", __func__);
442 return 0;
443 }
444
445 // Crypto_AsymSign_Fun_006
CaseAsymSignEcdsaSha512KeySize521Multi(void)446 int CaseAsymSignEcdsaSha512KeySize521Multi(void)
447 {
448 TestVector tv = {
449 .algName = {"AS_sv_ecdsa_sha512"},
450 .operaMaxKeySize = 521,
451 .keySize = 521,
452 .ecKeyCurve = TEE_ECC_CURVE_NIST_P521,
453 .fwdKeyTypeName = "kt_ecdsa_pair",
454 .bckKeyTypeName = "kt_ecdsa_pair",
455 .fwdEngine = FWDENGINE,
456 .bckEngine = BCKENGINE,
457 .dataSize = 64,
458 .actions = {
459 IRSetUp,
460 GlbAlloc, GlbS1S2,
461 ASSignFwd, ASVerifyBck,
462 ASSignFwd, ASVerifyBck,
463 GlbFree,
464 IRTearDown, },
465 .actionsSize = 9,
466 .expRet = ER_OK,
467 };
468 int ret = MonadRun2(&tv);
469 if (ret != 0) {
470 tloge("[%s]:MonadRun2 failed\n", __func__);
471 return -1;
472 }
473 tlogi("[%s]:MonadRun2 success\n", __func__);
474 tlogi("[%s]:--------------CaseAsymSignEcdsaSha512KeySize521Multi success\n", __func__);
475 return 0;
476 }
477
478 // Crypto_AsymSign_Fun_007
CaseAsymSignEd25519DataSize64Once(void)479 int CaseAsymSignEd25519DataSize64Once(void)
480 {
481 TestVector tv = {
482 .algName = {"AS_sv_ed25519"},
483 .operaMaxKeySize = 256,
484 .keySize = 256,
485 .ecKeyCurve = TEE_ECC_CURVE_25519,
486 .fwdKeyTypeName = "kt_ed25519_pair",
487 .bckKeyTypeName = "kt_ed25519_pub",
488 .fwdEngine = FWDENGINE,
489 .bckEngine = BCKENGINE,
490 .dataSize = 64,
491 .actions = {
492 IRSetUp,
493 GlbAlloc, GlbS1S2,
494 ASSignFwd,
495 ASVerifyBck,
496 GlbFree,
497 IRTearDown, },
498 .actionsSize = 7,
499 .expRet = ER_OK,
500 };
501 int ret = MonadRun2(&tv);
502 if (ret != 0) {
503 tloge("[%s]:MonadRun2 failed\n", __func__);
504 return -1;
505 }
506 tlogi("[%s]:MonadRun2 success\n", __func__);
507 tlogi("[%s]:--------------CaseAsymSignEd25519DataSize64Once success\n", __func__);
508 return 0;
509 }
510
511 // Crypto_AsymSign_Fun_008
CaseAsymSignEd25519DataSize64Multi(void)512 int CaseAsymSignEd25519DataSize64Multi(void)
513 {
514 TestVector tv = {
515 .algName = {"AS_sv_ed25519"},
516 .operaMaxKeySize = 256,
517 .keySize = 256,
518 .ecKeyCurve = TEE_ECC_CURVE_25519,
519 .fwdKeyTypeName = "kt_ed25519_pair",
520 .bckKeyTypeName = "kt_ed25519_pub",
521 .fwdEngine = FWDENGINE,
522 .bckEngine = BCKENGINE,
523 .dataSize = 64,
524 .actions = {
525 IRSetUp,
526 GlbAlloc, GlbS1S2,
527 ASSignFwd, ASVerifyBck,
528 ASSignFwd, ASVerifyBck,
529 GlbFree,
530 IRTearDown, },
531 .actionsSize = 9,
532 .expRet = ER_OK,
533 };
534 int ret = MonadRun2(&tv);
535 if (ret != 0) {
536 tloge("[%s]:MonadRun2 failed\n", __func__);
537 return -1;
538 }
539 tlogi("[%s]:MonadRun2 success\n", __func__);
540 tlogi("[%s]:--------------CaseAsymSignEd25519DataSize64Multi success\n", __func__);
541 return 0;
542 }
543
544 // Crypto_AsymSign_Fun_007
CaseAsymSignEd25519DataSize470Once(void)545 int CaseAsymSignEd25519DataSize470Once(void)
546 {
547 TestVector tv = {
548 .algName = {"AS_sv_ed25519"},
549 .operaMaxKeySize = 256,
550 .keySize = 256,
551 .ecKeyCurve = TEE_ECC_CURVE_25519,
552 .fwdKeyTypeName = "kt_ed25519_pair",
553 .bckKeyTypeName = "kt_ed25519_pair",
554 .fwdEngine = FWDENGINE,
555 .bckEngine = BCKENGINE,
556 .dataSize = 470,
557 .actions = {
558 IRSetUp,
559 GlbAlloc, GlbS1S2,
560 ASSignFwd,
561 ASVerifyBck,
562 GlbFree,
563 IRTearDown, },
564 .actionsSize = 7,
565 .expRet = ER_OK,
566 };
567 int ret = MonadRun2(&tv);
568 if (ret != 0) {
569 tloge("[%s]:MonadRun2 failed\n", __func__);
570 return -1;
571 }
572 tlogi("[%s]:MonadRun2 success\n", __func__);
573 tlogi("[%s]:--------------CaseAsymSignEd25519DataSize470Once success\n", __func__);
574 return 0;
575 }
576
577 // Crypto_AsymSign_Fun_008
CaseAsymSignEd25519DataSize470Multi(void)578 int CaseAsymSignEd25519DataSize470Multi(void)
579 {
580 TestVector tv = {
581 .algName = {"AS_sv_ed25519"},
582 .operaMaxKeySize = 256,
583 .keySize = 256,
584 .ecKeyCurve = TEE_ECC_CURVE_25519,
585 .fwdKeyTypeName = "kt_ed25519_pair",
586 .bckKeyTypeName = "kt_ed25519_pair",
587 .fwdEngine = FWDENGINE,
588 .bckEngine = BCKENGINE,
589 .dataSize = 470,
590 .actions = {
591 IRSetUp,
592 GlbAlloc, GlbS1S2,
593 ASSignFwd, ASVerifyBck,
594 ASSignFwd, ASVerifyBck,
595 GlbFree,
596 IRTearDown, },
597 .actionsSize = 9,
598 .expRet = ER_OK,
599 };
600 int ret = MonadRun2(&tv);
601 if (ret != 0) {
602 tloge("[%s]:MonadRun2 failed\n", __func__);
603 return -1;
604 }
605 tlogi("[%s]:MonadRun2 success\n", __func__);
606 tlogi("[%s]:--------------CaseAsymSignEd25519DataSize470Multi success\n", __func__);
607 return 0;
608 }
609
610 // Crypto_AsymSign_Fun_007
CaseAsymSignEd25519DataSize1270Once(void)611 int CaseAsymSignEd25519DataSize1270Once(void)
612 {
613 TestVector tv = {
614 .algName = {"AS_sv_ed25519"},
615 .operaMaxKeySize = 256,
616 .keySize = 256,
617 .ecKeyCurve = TEE_ECC_CURVE_25519,
618 .fwdKeyTypeName = "kt_ed25519_pair",
619 .bckKeyTypeName = "kt_ed25519_pub",
620 .fwdEngine = FWDENGINE,
621 .bckEngine = BCKENGINE,
622 .dataSize = 1270,
623 .actions = {
624 IRSetUp,
625 GlbAlloc, GlbS1S2,
626 ASSignFwd,
627 ASVerifyBck,
628 GlbFree,
629 IRTearDown, },
630 .actionsSize = 7,
631 .expRet = ER_OK,
632 };
633 int ret = MonadRun2(&tv);
634 if (ret != 0) {
635 tloge("[%s]:MonadRun2 failed\n", __func__);
636 return -1;
637 }
638 tlogi("[%s]:MonadRun2 success\n", __func__);
639 tlogi("[%s]:--------------CaseAsymSignEd25519DataSize1270Once success\n", __func__);
640 return 0;
641 }
642
643 // Crypto_AsymSign_Fun_008
CaseAsymSignEd25519DataSize1270Multi(void)644 int CaseAsymSignEd25519DataSize1270Multi(void)
645 {
646 TestVector tv = {
647 .algName = {"AS_sv_ed25519"},
648 .operaMaxKeySize = 256,
649 .keySize = 256,
650 .ecKeyCurve = TEE_ECC_CURVE_25519,
651 .fwdKeyTypeName = "kt_ed25519_pair",
652 .bckKeyTypeName = "kt_ed25519_pub",
653 .fwdEngine = FWDENGINE,
654 .bckEngine = BCKENGINE,
655 .dataSize = 1270,
656 .actions = {
657 IRSetUp,
658 GlbAlloc, GlbS1S2,
659 ASSignFwd, ASVerifyBck,
660 ASSignFwd, ASVerifyBck,
661 GlbFree,
662 IRTearDown, },
663 .actionsSize = 9,
664 .expRet = ER_OK,
665 };
666 int ret = MonadRun2(&tv);
667 if (ret != 0) {
668 tloge("[%s]:MonadRun2 failed\n", __func__);
669 return -1;
670 }
671 tlogi("[%s]:MonadRun2 success\n", __func__);
672 tlogi("[%s]:--------------CaseAsymSignEd25519DataSize1270Multi success\n", __func__);
673 return 0;
674 }
675
676 // Crypto_AsymSign_Fun_007
CaseAsymSignEd25519DataSize4096Once(void)677 int CaseAsymSignEd25519DataSize4096Once(void)
678 {
679 TestVector tv = {
680 .algName = {"AS_sv_ed25519"},
681 .operaMaxKeySize = 256,
682 .keySize = 256,
683 .ecKeyCurve = TEE_ECC_CURVE_25519,
684 .fwdKeyTypeName = "kt_ed25519_pair",
685 .bckKeyTypeName = "kt_ed25519_pair",
686 .fwdEngine = FWDENGINE,
687 .bckEngine = BCKENGINE,
688 .dataSize = 4096,
689 .actions = {
690 IRSetUp,
691 GlbAlloc, GlbS1S2,
692 ASSignFwd,
693 ASVerifyBck,
694 GlbFree,
695 IRTearDown, },
696 .actionsSize = 7,
697 .expRet = ER_OK,
698 };
699 int ret = MonadRun2(&tv);
700 if (ret != 0) {
701 tloge("[%s]:MonadRun2 failed\n", __func__);
702 return -1;
703 }
704 tlogi("[%s]:MonadRun2 success\n", __func__);
705 tlogi("[%s]:--------------CaseAsymSignEd25519DataSize4096Once success\n", __func__);
706 return 0;
707 }
708
709 // Crypto_AsymSign_Fun_008
CaseAsymSignEd25519DataSize4096Multi(void)710 int CaseAsymSignEd25519DataSize4096Multi(void)
711 {
712 TestVector tv = {
713 .algName = {"AS_sv_ed25519"},
714 .operaMaxKeySize = 256,
715 .keySize = 256,
716 .ecKeyCurve = TEE_ECC_CURVE_25519,
717 .fwdKeyTypeName = "kt_ed25519_pair",
718 .bckKeyTypeName = "kt_ed25519_pair",
719 .fwdEngine = FWDENGINE,
720 .bckEngine = BCKENGINE,
721 .dataSize = 4096,
722 .actions = {
723 IRSetUp,
724 GlbAlloc, GlbS1S2,
725 ASSignFwd, ASVerifyBck,
726 ASSignFwd, ASVerifyBck,
727 GlbFree,
728 IRTearDown, },
729 .actionsSize = 9,
730 .expRet = ER_OK,
731 };
732 int ret = MonadRun2(&tv);
733 if (ret != 0) {
734 tloge("[%s]:MonadRun2 failed\n", __func__);
735 return -1;
736 }
737 tlogi("[%s]:MonadRun2 success\n", __func__);
738 tlogi("[%s]:--------------CaseAsymSignEd25519DataSize4096Multi success\n", __func__);
739 return 0;
740 }
741
742 // Crypto_AsymSign_Fun_009
CaseAsymSignSm2DsaSm3DataSize32Once(void)743 int CaseAsymSignSm2DsaSm3DataSize32Once(void)
744 {
745 TestVector tv = {
746 .algName = {"AS_sv_sm2_dsa_sm3"},
747 .operaMaxKeySize = 256,
748 .keySize = 256,
749 .ecKeyCurve = TEE_ECC_CURVE_SM2,
750 .fwdKeyTypeName = "kt_sm2_dsa_pair",
751 .bckKeyTypeName = "kt_sm2_dsa_pair",
752 .fwdEngine = FWDENGINE,
753 .bckEngine = BCKENGINE,
754 .dataSize = 32,
755 .actions = {
756 IRSetUp,
757 GlbAlloc, GlbS1S2,
758 ASSignFwd,
759 ASVerifyBck,
760 GlbFree,
761 IRTearDown, },
762 .actionsSize = 7,
763 .expRet = ER_OK,
764 };
765 int ret = MonadRun2(&tv);
766 if (ret != 0) {
767 tloge("[%s]:MonadRun2 failed\n", __func__);
768 return -1;
769 }
770 tlogi("[%s]:MonadRun2 success\n", __func__);
771 tlogi("[%s]:--------------CaseAsymSignSm2DsaSm3DataSize32Once success\n", __func__);
772 return 0;
773 }
774
775 // Crypto_AsymSign_Fun_010
CaseAsymSignSm2DsaSm3DataSize32Multi(void)776 int CaseAsymSignSm2DsaSm3DataSize32Multi(void)
777 {
778 TestVector tv = {
779 .algName = {"AS_sv_sm2_dsa_sm3"},
780 .operaMaxKeySize = 256,
781 .keySize = 256,
782 .ecKeyCurve = TEE_ECC_CURVE_SM2,
783 .fwdKeyTypeName = "kt_sm2_dsa_pair",
784 .bckKeyTypeName = "kt_sm2_dsa_pub",
785 .fwdEngine = FWDENGINE,
786 .bckEngine = BCKENGINE,
787 .dataSize = 32,
788 .actions = {
789 IRSetUp,
790 GlbAlloc, GlbS1S2,
791 ASSignFwd, ASVerifyBck,
792 ASSignFwd, ASVerifyBck,
793 GlbFree,
794 IRTearDown, },
795 .actionsSize = 9,
796 .expRet = ER_OK,
797 };
798 int ret = MonadRun2(&tv);
799 if (ret != 0) {
800 tloge("[%s]:MonadRun2 failed\n", __func__);
801 return -1;
802 }
803 tlogi("[%s]:MonadRun2 success\n", __func__);
804 tlogi("[%s]:--------------CaseAsymSignSm2DsaSm3DataSize32Multi success\n", __func__);
805 return 0;
806 }
807
808 // Crypto_AsymSign_Fun_009
CaseAsymSignSm2DsaSm3DataSize128Once(void)809 int CaseAsymSignSm2DsaSm3DataSize128Once(void)
810 {
811 TestVector tv = {
812 .algName = {"AS_sv_sm2_dsa_sm3"},
813 .operaMaxKeySize = 256,
814 .keySize = 256,
815 .ecKeyCurve = TEE_ECC_CURVE_SM2,
816 .fwdKeyTypeName = "kt_sm2_dsa_pair",
817 .bckKeyTypeName = "kt_sm2_dsa_pair",
818 .fwdEngine = FWDENGINE,
819 .bckEngine = BCKENGINE,
820 .dataSize = 128,
821 .actions = {
822 IRSetUp,
823 GlbAlloc, GlbS1S2,
824 ASSignFwd,
825 ASVerifyBck,
826 GlbFree,
827 IRTearDown, },
828 .actionsSize = 7,
829 .expRet = ER_OK,
830 };
831 int ret = MonadRun2(&tv);
832 if (ret != 0) {
833 tloge("[%s]:MonadRun2 failed\n", __func__);
834 return -1;
835 }
836 tlogi("[%s]:MonadRun2 success\n", __func__);
837 tlogi("[%s]:--------------CaseAsymSignSm2DsaSm3DataSize128Once success\n", __func__);
838 return 0;
839 }