3e3c0a05b05d3f4002aa23654e1bd9a3e5e6e618
[platform/core/security/key-manager-se-backend.git] / tests / test_cases.cpp
1 /*
2  *  Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  *  Licensed under the Apache License, Version 2.0 (the "License");
5  *  you may not use this file except in compliance with the License.
6  *  You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  *  Unless required by applicable law or agreed to in writing, software
11  *  distributed under the License is distributed on an "AS IS" BASIS,
12  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  *  See the License for the specific language governing permissions and
14  *  limitations under the License
15  *
16  *
17  * @file        test_cases.cpp
18  * @author      Dongsun Lee (ds73.lee@samsung.com)
19  * @version     1.0
20  * @brief       tests for SE Backend
21  */
22 #include <boost/test/unit_test.hpp>
23 #include <stdio.h>
24 #include <string>
25 #include <key-manager-se-backend.h>
26
27 BOOST_AUTO_TEST_SUITE(USER)
28
29 BOOST_AUTO_TEST_SUITE(SE_EMUL);
30
31 void _print_bin(char *bin, uint32_t len) {
32     for(uint32_t i=0; i<len; i++) {
33         printf("%02X, ", 0x00FF & bin[i]);
34     }
35     printf("\n");
36 }
37
38 bool _dbp_key_exist()
39 {
40     bool key_exist = true;
41     kmsb_error_e ret = KMSB_ERROR_NONE;
42
43     unsigned char input[32] = {0x01};
44     unsigned char iv[16] = {0x02};
45     unsigned char *output = NULL;
46     unsigned int output_len = 0;
47
48     ret = kmsb_encrypt_with_dbp_key(SE_BACKEND_DBP_SCHEME_VERSION,
49                                     input, sizeof(input),
50                                     iv, sizeof(iv),
51                                     &output, &output_len);
52     if (ret == KMSB_ERROR_NO_KEY)
53         key_exist = false;
54
55     BOOST_TEST_MESSAGE( "Check Existence of DB Protection Key : Exist=" << std::boolalpha << key_exist );
56     return key_exist;
57 }
58
59 struct dbp_key_checker
60 {
61     dbp_key_checker() {}
62
63     boost::test_tools::assertion_result operator()(boost::unit_test::test_unit_id)
64     {
65         return _dbp_key_exist();
66     }
67 };
68
69 struct no_dbp_key_checker
70 {
71     no_dbp_key_checker() {}
72
73     boost::test_tools::assertion_result operator()(boost::unit_test::test_unit_id)
74     {
75         return !_dbp_key_exist();
76     }
77 };
78
79 BOOST_AUTO_TEST_CASE(kmsb_generate_dbp_key_p,
80   * boost::unit_test::precondition(no_dbp_key_checker()))
81 {
82     kmsb_error_e ret = KMSB_ERROR_NONE;
83
84     unsigned char input[32] = {0x01};
85     unsigned char iv[16] = {0x02};
86     unsigned char *output = NULL;
87     unsigned int output_len = 0;
88
89     ret = kmsb_encrypt_with_dbp_key(SE_BACKEND_DBP_SCHEME_VERSION,
90                                     input, sizeof(input),
91                                     iv, sizeof(iv),
92                                     &output, &output_len);
93     BOOST_REQUIRE(ret == KMSB_ERROR_NO_KEY);
94
95     ret = kmsb_generate_dbp_key(false);
96     BOOST_REQUIRE(ret == KMSB_ERROR_NONE);
97     
98     ret = kmsb_encrypt_with_dbp_key(SE_BACKEND_DBP_SCHEME_VERSION,
99                                     input, sizeof(input),
100                                     iv, sizeof(iv),
101                                     &output, &output_len);
102     BOOST_REQUIRE(ret == KMSB_ERROR_NONE);
103     if (output) free(output);
104 }
105
106 BOOST_AUTO_TEST_CASE(kmsb_generate_dbp_key_regenerate_p,
107   * boost::unit_test::precondition(dbp_key_checker()))
108 {
109     kmsb_error_e ret = kmsb_generate_dbp_key(true);
110     BOOST_REQUIRE(ret == KMSB_ERROR_NONE);
111 }
112
113 BOOST_AUTO_TEST_CASE(kmsb_generate_dbp_key_not_permitted_n,
114   * boost::unit_test::precondition(dbp_key_checker()))
115 {
116     kmsb_error_e ret = kmsb_generate_dbp_key(false);
117     BOOST_REQUIRE(ret == KMSB_ERROR_NOT_PERMITTED);
118 }
119
120 BOOST_AUTO_TEST_CASE(kmsb_encrypt_with_dbp_key_p,
121   * boost::unit_test::precondition(dbp_key_checker()))
122 {
123     kmsb_error_e ret = KMSB_ERROR_NONE;
124
125     unsigned char input[32] = {0x01};
126     unsigned char iv[16] = {0x02};
127     unsigned char *output1 = NULL;
128     unsigned char *output2 = NULL;
129     unsigned int output_len = 0;
130
131     ret = kmsb_encrypt_with_dbp_key(SE_BACKEND_DBP_SCHEME_VERSION,
132                                     input, sizeof(input),
133                                     iv, sizeof(iv),
134                                     &output1, &output_len);
135     BOOST_REQUIRE(ret == KMSB_ERROR_NONE);
136     BOOST_REQUIRE(output_len == sizeof(input));
137
138     ret = kmsb_encrypt_with_dbp_key(SE_BACKEND_DBP_SCHEME_VERSION,
139                                     input, sizeof(input),
140                                     iv, sizeof(iv),
141                                     &output2, &output_len);
142     BOOST_REQUIRE(ret == KMSB_ERROR_NONE);
143     BOOST_REQUIRE(output_len == sizeof(input));
144
145     BOOST_REQUIRE(std::memcmp(output1, output2, output_len) == 0);
146
147     if (output1) free(output1);
148     if (output2) free(output2);
149 }
150
151 BOOST_AUTO_TEST_CASE(kmsb_encrypt_with_dbp_key_invalid_parameter_n)
152 {
153     kmsb_error_e ret = KMSB_ERROR_NONE;
154
155     unsigned char input[32] = {0x01};
156     unsigned char iv[16] = {0x02};
157     unsigned char *output = NULL;
158     unsigned int output_len = 0;
159
160     ret = kmsb_encrypt_with_dbp_key(0,
161                                     input, sizeof(input),
162                                     iv, sizeof(iv),
163                                     &output, &output_len);
164     BOOST_REQUIRE(ret == KMSB_ERROR_INVALID_PARAMETER);
165
166     ret = kmsb_encrypt_with_dbp_key(SE_BACKEND_DBP_SCHEME_VERSION,
167                                     NULL, sizeof(input),
168                                     iv, sizeof(iv),
169                                     &output, &output_len);
170     BOOST_REQUIRE(ret == KMSB_ERROR_INVALID_PARAMETER);
171
172     ret = kmsb_encrypt_with_dbp_key(SE_BACKEND_DBP_SCHEME_VERSION,
173                                     input, 0,
174                                     iv, sizeof(iv),
175                                     &output, &output_len);
176     BOOST_REQUIRE(ret == KMSB_ERROR_INVALID_PARAMETER);
177
178     ret = kmsb_encrypt_with_dbp_key(SE_BACKEND_DBP_SCHEME_VERSION,
179                                     input, sizeof(input),
180                                     NULL, sizeof(iv),
181                                     &output, &output_len);
182     BOOST_REQUIRE(ret == KMSB_ERROR_INVALID_PARAMETER);
183
184     ret = kmsb_encrypt_with_dbp_key(SE_BACKEND_DBP_SCHEME_VERSION,
185                                     input, sizeof(input),
186                                     iv, 0,
187                                     &output, &output_len);
188     BOOST_REQUIRE(ret == KMSB_ERROR_INVALID_PARAMETER);
189
190     ret = kmsb_encrypt_with_dbp_key(SE_BACKEND_DBP_SCHEME_VERSION,
191                                     input, sizeof(input),
192                                     iv, sizeof(iv),
193                                     NULL, &output_len);
194     BOOST_REQUIRE(ret == KMSB_ERROR_INVALID_PARAMETER);
195
196     ret = kmsb_encrypt_with_dbp_key(SE_BACKEND_DBP_SCHEME_VERSION,
197                                     input, sizeof(input),
198                                     iv, sizeof(iv),
199                                     &output, NULL);
200     BOOST_REQUIRE(ret == KMSB_ERROR_INVALID_PARAMETER);
201 }
202
203 ///////////////////////////
204 const int TEST_AES_KEY_IDX = 1;
205 const int TEST_ECDSA_P192_KEY_IDX = 2;
206 const int TEST_ECDSA_P256_KEY_IDX = 3;
207 const int TEST_ECDSA_S384_KEY_IDX = 4;
208
209 BOOST_AUTO_TEST_CASE(kmsb_aes_cbc_encrypt_p)
210 {
211     kmsb_error_e ret = KMSB_ERROR_NONE;
212
213     unsigned char input[32] = {0x01};
214     unsigned char iv[16] = {0x02};
215     unsigned char *output1 = NULL;
216     unsigned char *output2 = NULL;
217     unsigned int output_len = 0;
218
219     kmsb_aes_param_s param;
220     param.mode = KMSB_ALGO_AES_CBC;
221     param.iv = iv;
222     param.iv_len = 16;
223
224     ret = kmsb_aes_encrypt(TEST_AES_KEY_IDX, &param,
225                             input, sizeof(input),
226                             &output1, &output_len);
227     BOOST_REQUIRE(ret == KMSB_ERROR_NONE);
228
229     ret = kmsb_aes_encrypt(TEST_AES_KEY_IDX, &param,
230                             input, sizeof(input),
231                             &output2, &output_len);
232     BOOST_REQUIRE(ret == KMSB_ERROR_NONE);
233     BOOST_REQUIRE(std::memcmp(output1, output2, output_len) == 0);
234
235     if (output1) free(output1);
236     if (output2) free(output2);
237 }
238
239 BOOST_AUTO_TEST_CASE(kmsb_aes_cbc_decrypt_p)
240 {
241     kmsb_error_e ret = KMSB_ERROR_NONE;
242
243     unsigned char input[32] = {0x01};
244     unsigned char iv[16] = {0x02};
245     unsigned char *output1 = NULL;
246     unsigned char *output2 = NULL;
247     unsigned int output_len = 0;
248
249     kmsb_aes_param_s param;
250     param.mode = KMSB_ALGO_AES_CBC;
251     param.iv = iv;
252     param.iv_len = 16;
253
254     ret = kmsb_aes_encrypt(TEST_AES_KEY_IDX, &param,
255                             input, sizeof(input),
256                             &output1, &output_len);
257     BOOST_REQUIRE(ret == KMSB_ERROR_NONE);
258
259     ret = kmsb_aes_decrypt(TEST_AES_KEY_IDX, &param,
260                             output1, output_len,
261                             &output2, &output_len);
262     BOOST_REQUIRE(ret == KMSB_ERROR_NONE);
263     BOOST_REQUIRE(output_len == sizeof(input));
264     BOOST_REQUIRE(std::memcmp(input, output2, output_len) == 0);
265
266     if (output1) free(output1);
267     if (output2) free(output2);
268 }
269
270 BOOST_AUTO_TEST_CASE(kmsb_aes_ctr_encrypt_p)
271 {
272     kmsb_error_e ret = KMSB_ERROR_NONE;
273
274     unsigned char input[32] = {0x01};
275     unsigned char iv[16] = {0x02};
276     unsigned char *output1 = NULL;
277     unsigned char *output2 = NULL;
278     unsigned int output_len = 0;
279
280     kmsb_aes_param_s param;
281     param.mode = KMSB_ALGO_AES_CTR;
282     param.iv = iv;
283     param.iv_len = 16;
284     ret = kmsb_aes_encrypt(TEST_AES_KEY_IDX, &param,
285                             input, sizeof(input),
286                             &output1, &output_len);
287     BOOST_REQUIRE(ret == KMSB_ERROR_NONE);
288     BOOST_REQUIRE(output_len == sizeof(input));
289
290     ret = kmsb_aes_encrypt(TEST_AES_KEY_IDX, &param,
291                             input, sizeof(input),
292                             &output2, &output_len);
293     BOOST_REQUIRE(ret == KMSB_ERROR_NONE);
294     BOOST_REQUIRE(output_len == sizeof(input));
295
296     BOOST_REQUIRE(std::memcmp(output1, output2, output_len) == 0);
297
298     if (output1) free(output1);
299     if (output2) free(output2);
300 }
301
302 BOOST_AUTO_TEST_CASE(kmsb_aes_ctr_decrypt_p)
303 {
304     kmsb_error_e ret = KMSB_ERROR_NONE;
305
306     unsigned char input[32] = {0x01};
307     unsigned char iv[16] = {0x02};
308     unsigned char *output1 = NULL;
309     unsigned char *output2 = NULL;
310     unsigned int output_len = 0;
311
312     kmsb_aes_param_s param;
313     param.mode = KMSB_ALGO_AES_CTR;
314     param.iv = iv;
315     param.iv_len = 16;
316
317     ret = kmsb_aes_encrypt(TEST_AES_KEY_IDX, &param,
318                             input, sizeof(input),
319                             &output1, &output_len);
320     BOOST_REQUIRE(ret == KMSB_ERROR_NONE);
321     BOOST_REQUIRE(output_len == sizeof(input));
322
323     ret = kmsb_aes_decrypt(TEST_AES_KEY_IDX, &param,
324                             output1, output_len,
325                             &output2, &output_len);
326     BOOST_REQUIRE(ret == KMSB_ERROR_NONE);
327     BOOST_REQUIRE(output_len == sizeof(input));
328     BOOST_REQUIRE(std::memcmp(input, output2, output_len) == 0);
329
330     if (output1) free(output1);
331     if (output2) free(output2);
332 }
333
334 BOOST_AUTO_TEST_CASE(kmsb_aes_cfb_encrypt_p)
335 {
336     kmsb_error_e ret = KMSB_ERROR_NONE;
337
338     unsigned char input[32] = {0x01};
339     unsigned char iv[16] = {0x02};
340     unsigned char *output1 = NULL;
341     unsigned char *output2 = NULL;
342     unsigned int output_len = 0;
343
344     kmsb_aes_param_s param;
345     param.mode = KMSB_ALGO_AES_CFB;
346     param.iv = iv;
347     param.iv_len = 16;
348     ret = kmsb_aes_encrypt(TEST_AES_KEY_IDX, &param,
349                             input, sizeof(input),
350                             &output1, &output_len);
351     BOOST_REQUIRE(ret == KMSB_ERROR_NONE);
352     BOOST_REQUIRE(output_len == sizeof(input));
353
354     ret = kmsb_aes_encrypt(TEST_AES_KEY_IDX, &param,
355                             input, sizeof(input),
356                             &output2, &output_len);
357     BOOST_REQUIRE(ret == KMSB_ERROR_NONE);
358     BOOST_REQUIRE(output_len == sizeof(input));
359
360     BOOST_REQUIRE(std::memcmp(output1, output2, output_len) == 0);
361
362     if (output1) free(output1);
363     if (output2) free(output2);
364 }
365
366 BOOST_AUTO_TEST_CASE(kmsb_aes_cfb_decrypt_p)
367 {
368     kmsb_error_e ret = KMSB_ERROR_NONE;
369
370     unsigned char input[32] = {0x01};
371     unsigned char iv[16] = {0x02};
372     unsigned char *output1 = NULL;
373     unsigned char *output2 = NULL;
374     unsigned int output_len = 0;
375
376     kmsb_aes_param_s param;
377     param.mode = KMSB_ALGO_AES_CFB;
378     param.iv = iv;
379     param.iv_len = 16;
380
381     ret = kmsb_aes_encrypt(TEST_AES_KEY_IDX, &param,
382                             input, sizeof(input),
383                             &output1, &output_len);
384     BOOST_REQUIRE(ret == KMSB_ERROR_NONE);
385     BOOST_REQUIRE(output_len == sizeof(input));
386
387     ret = kmsb_aes_decrypt(TEST_AES_KEY_IDX, &param,
388                             output1, output_len,
389                             &output2, &output_len);
390     BOOST_REQUIRE(ret == KMSB_ERROR_NONE);
391     BOOST_REQUIRE(output_len == sizeof(input));
392     BOOST_REQUIRE(std::memcmp(input, output2, output_len) == 0);
393
394     if (output1) free(output1);
395     if (output2) free(output2);
396 }
397
398 BOOST_AUTO_TEST_CASE(kmsb_aes_gcm_encrypt_p)
399 {
400     kmsb_error_e ret = KMSB_ERROR_NONE;
401
402     unsigned char input[32] = {0x01};
403     unsigned char iv[16] = {0x02};
404     unsigned char aad[16] = {0x03};
405     unsigned char tag[16];
406     unsigned char *output1 = NULL;
407     unsigned char *output2 = NULL;
408     unsigned int output_len = 0;
409
410     kmsb_aes_param_s param;
411     param.mode = KMSB_ALGO_AES_GCM;
412     param.iv = iv;
413     param.iv_len = 16;
414     param.aad = aad;
415     param.aad_len = sizeof(aad),
416     param.tag = tag;
417     ret = kmsb_aes_encrypt(TEST_AES_KEY_IDX, &param,
418                             input, sizeof(input),
419                             &output1, &output_len);
420     BOOST_REQUIRE(ret == KMSB_ERROR_NONE);
421     BOOST_REQUIRE(output_len == sizeof(input));
422
423     ret = kmsb_aes_encrypt(TEST_AES_KEY_IDX, &param,
424                             input, sizeof(input),
425                             &output2, &output_len);
426     BOOST_REQUIRE(ret == KMSB_ERROR_NONE);
427     BOOST_REQUIRE(output_len == sizeof(input));
428
429     BOOST_REQUIRE(std::memcmp(output1, output2, output_len) == 0);
430
431     if (output1) free(output1);
432     if (output2) free(output2);
433 }
434
435 BOOST_AUTO_TEST_CASE(kmsb_aes_gcm_decrypt_p)
436 {
437     kmsb_error_e ret = KMSB_ERROR_NONE;
438
439     unsigned char input[32] = {0x01};
440     unsigned char iv[16] = {0x02};
441     unsigned char aad[16] = {0x03};
442     unsigned char tag[16];
443     unsigned char *output1 = NULL;
444     unsigned char *output2 = NULL;
445     unsigned int output_len = 0;
446
447     kmsb_aes_param_s param;
448     param.mode = KMSB_ALGO_AES_GCM;
449     param.iv = iv;
450     param.iv_len = 16;
451     param.aad = aad;
452     param.aad_len = sizeof(aad);
453     param.tag = tag;
454
455     ret = kmsb_aes_encrypt(TEST_AES_KEY_IDX, &param,
456                             input, sizeof(input),
457                             &output1, &output_len);
458     BOOST_REQUIRE(ret == KMSB_ERROR_NONE);
459     BOOST_REQUIRE(output_len == sizeof(input));
460
461     ret = kmsb_aes_decrypt(TEST_AES_KEY_IDX, &param,
462                             output1, output_len,
463                             &output2, &output_len);
464     BOOST_REQUIRE(ret == KMSB_ERROR_NONE);
465     BOOST_REQUIRE(output_len == sizeof(input));
466     BOOST_REQUIRE(std::memcmp(input, output2, output_len) == 0);
467
468     if (output1) free(output1);
469     if (output2) free(output2);
470 }
471
472 void test_kmsb_create_signature(int key_idx, 
473                                 kmsb_hash_algo_e alg, kmsb_ec_type_e ec,
474                                 unsigned char *input, unsigned int input_len,
475                                 unsigned char **output, unsigned int *output_len)
476 {
477     kmsb_error_e ret = KMSB_ERROR_NONE;
478     kmsb_sign_param_s param;
479     param.ec_type = ec;
480     param.hash_algo = alg;
481
482     ret = kmsb_create_signature(key_idx, &param,
483                             input, input_len,
484                             output, output_len);
485     BOOST_REQUIRE(ret == KMSB_ERROR_NONE);
486 }
487
488 void test_kmsb_verify_signature(int key_idx, 
489                                 kmsb_hash_algo_e alg, kmsb_ec_type_e ec,
490                                 unsigned char *input, unsigned int input_len,
491                                 unsigned char **output, unsigned int *output_len)
492 {
493     kmsb_error_e ret = KMSB_ERROR_NONE;
494     kmsb_sign_param_s param;
495     param.ec_type = ec;
496     param.hash_algo = alg;
497
498     ret = kmsb_create_signature(key_idx, &param,
499                             input, input_len,
500                             output, output_len);
501     BOOST_REQUIRE(ret == KMSB_ERROR_NONE);
502
503     ret = kmsb_verify_signature(key_idx, &param,
504                             input, input_len,
505                             *output, *output_len);
506     BOOST_REQUIRE(ret == KMSB_ERROR_NONE);
507 }
508
509 BOOST_AUTO_TEST_CASE(kmsb_create_signature_sha1_p)
510 {
511     unsigned char input[32] = {0x01};
512     unsigned char *signature = NULL;
513     unsigned int signature_len = 0;
514
515     kmsb_hash_algo_e alg = KMSB_HASH_SHA1;
516     kmsb_ec_type_e ec = KMSB_EC_PRIME256V1;
517     test_kmsb_create_signature(TEST_ECDSA_P256_KEY_IDX, alg, ec,
518                             input, sizeof(input),
519                             &signature, &signature_len);
520
521     if (signature) free(signature);
522 }
523
524 BOOST_AUTO_TEST_CASE(kmsb_create_signature_sha256_p)
525 {
526     unsigned char input[32] = {0x01};
527     unsigned char *signature = NULL;
528     unsigned int signature_len = 0;
529
530     kmsb_hash_algo_e alg = KMSB_HASH_SHA256;
531     kmsb_ec_type_e ec = KMSB_EC_PRIME256V1;
532     test_kmsb_create_signature(TEST_ECDSA_P256_KEY_IDX, alg, ec,
533                             input, sizeof(input),
534                             &signature, &signature_len);
535
536     if (signature) free(signature);
537 }
538
539 BOOST_AUTO_TEST_CASE(kmsb_create_signature_sha384_p)
540 {
541     unsigned char input[32] = {0x01};
542     unsigned char *signature = NULL;
543     unsigned int signature_len = 0;
544
545     kmsb_hash_algo_e alg = KMSB_HASH_SHA384;
546     kmsb_ec_type_e ec = KMSB_EC_PRIME256V1;
547     test_kmsb_create_signature(TEST_ECDSA_P256_KEY_IDX, alg, ec,
548                             input, sizeof(input),
549                             &signature, &signature_len);
550
551     if (signature) free(signature);
552 }
553
554 BOOST_AUTO_TEST_CASE(kmsb_create_signature_sha512_p)
555 {
556     unsigned char input[32] = {0x01};
557     unsigned char *signature = NULL;
558     unsigned int signature_len = 0;
559
560     kmsb_hash_algo_e alg = KMSB_HASH_SHA512;
561     kmsb_ec_type_e ec = KMSB_EC_PRIME256V1;
562     test_kmsb_create_signature(TEST_ECDSA_P256_KEY_IDX, alg, ec,
563                             input, sizeof(input),
564                             &signature, &signature_len);
565
566     if (signature) free(signature);
567 }
568
569 BOOST_AUTO_TEST_CASE(kmsb_create_signature_p192v1_p)
570 {
571     unsigned char input[32] = {0x01};
572     unsigned char *signature = NULL;
573     unsigned int signature_len = 0;
574
575     kmsb_hash_algo_e alg = KMSB_HASH_SHA256;
576     kmsb_ec_type_e ec = KMSB_EC_PRIME192V1;
577     test_kmsb_create_signature(TEST_ECDSA_P192_KEY_IDX, alg, ec,
578                             input, sizeof(input),
579                             &signature, &signature_len);
580
581     if (signature) free(signature);
582 }
583
584 BOOST_AUTO_TEST_CASE(kmsb_create_signature_secp384r1_p)
585 {
586     unsigned char input[32] = {0x01};
587     unsigned char *signature = NULL;
588     unsigned int signature_len = 0;
589
590     kmsb_hash_algo_e alg = KMSB_HASH_SHA256;
591     kmsb_ec_type_e ec = KMSB_EC_SECP384R1;
592     test_kmsb_create_signature(TEST_ECDSA_S384_KEY_IDX, alg, ec,
593                             input, sizeof(input),
594                             &signature, &signature_len);
595
596     if (signature) free(signature);
597 }
598
599 BOOST_AUTO_TEST_CASE(kmsb_verify_signature_sha1_p)
600 {
601     unsigned char input[32] = {0x01};
602     unsigned char *signature = NULL;
603     unsigned int signature_len = 0;
604
605     kmsb_hash_algo_e alg = KMSB_HASH_SHA1;
606     kmsb_ec_type_e ec = KMSB_EC_PRIME256V1;
607     test_kmsb_verify_signature(TEST_ECDSA_P256_KEY_IDX, alg, ec,
608                             input, sizeof(input),
609                             &signature, &signature_len);
610
611     if (signature) free(signature);
612 }
613
614 BOOST_AUTO_TEST_CASE(kmsb_verify_signature_sha256_p)
615 {
616     unsigned char input[32] = {0x01};
617     unsigned char *signature = NULL;
618     unsigned int signature_len = 0;
619
620     kmsb_hash_algo_e alg = KMSB_HASH_SHA256;
621     kmsb_ec_type_e ec = KMSB_EC_PRIME256V1;
622     test_kmsb_verify_signature(TEST_ECDSA_P256_KEY_IDX, alg, ec,
623                             input, sizeof(input),
624                             &signature, &signature_len);
625
626     if (signature) free(signature);
627 }
628
629 BOOST_AUTO_TEST_CASE(kmsb_verify_signature_sha384_p)
630 {
631     unsigned char input[32] = {0x01};
632     unsigned char *signature = NULL;
633     unsigned int signature_len = 0;
634
635     kmsb_hash_algo_e alg = KMSB_HASH_SHA384;
636     kmsb_ec_type_e ec = KMSB_EC_PRIME256V1;
637     test_kmsb_verify_signature(TEST_ECDSA_P256_KEY_IDX, alg, ec,
638                             input, sizeof(input),
639                             &signature, &signature_len);
640
641     if (signature) free(signature);
642 }
643
644 BOOST_AUTO_TEST_CASE(kmsb_verify_signature_sha512_p)
645 {
646     unsigned char input[32] = {0x01};
647     unsigned char *signature = NULL;
648     unsigned int signature_len = 0;
649
650     kmsb_hash_algo_e alg = KMSB_HASH_SHA512;
651     kmsb_ec_type_e ec = KMSB_EC_PRIME256V1;
652     test_kmsb_verify_signature(TEST_ECDSA_P256_KEY_IDX, alg, ec,
653                             input, sizeof(input),
654                             &signature, &signature_len);
655
656     if (signature) free(signature);
657 }
658
659 BOOST_AUTO_TEST_CASE(kmsb_verify_signature_p192v1_p)
660 {
661     unsigned char input[32] = {0x01};
662     unsigned char *signature = NULL;
663     unsigned int signature_len = 0;
664
665     kmsb_hash_algo_e alg = KMSB_HASH_SHA256;
666     kmsb_ec_type_e ec = KMSB_EC_PRIME192V1;
667     test_kmsb_verify_signature(TEST_ECDSA_P192_KEY_IDX, alg, ec,
668                             input, sizeof(input),
669                             &signature, &signature_len);
670
671     if (signature) free(signature);
672 }
673
674 BOOST_AUTO_TEST_CASE(kmsb_verify_signature_secp384r1_p)
675 {
676     unsigned char input[32] = {0x01};
677     unsigned char *signature = NULL;
678     unsigned int signature_len = 0;
679
680     kmsb_hash_algo_e alg = KMSB_HASH_SHA256;
681     kmsb_ec_type_e ec = KMSB_EC_SECP384R1;
682     test_kmsb_verify_signature(TEST_ECDSA_S384_KEY_IDX, alg, ec,
683                             input, sizeof(input),
684                             &signature, &signature_len);
685
686     if (signature) free(signature);
687 }
688 BOOST_AUTO_TEST_SUITE_END() // SE_EMUL
689
690 BOOST_AUTO_TEST_SUITE_END() // USER