Mistake on this page?
Report an issue in GitHub or email us
compliance_crypto/test_c020/test_data.h
Go to the documentation of this file.
1 /** @file
2  * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved.
3  * SPDX-License-Identifier : Apache-2.0
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16 **/
17 
18 #include "val_crypto.h"
19 
20 typedef struct {
21  char test_desc[75];
22  psa_key_handle_t key_handle[4];
23  psa_key_type_t key_type[2];
24  uint8_t key_data[32];
25  uint32_t key_length;
26  psa_key_usage_t usage[2];
27  psa_algorithm_t key_alg[2];
28  size_t capacity;
29  size_t size;
30  psa_status_t expected_status;
31 } test_data;
32 
33 static test_data check1[] = {
34 #ifdef ARCH_TEST_HKDF
35 #ifdef ARCH_TEST_CIPER_MODE_CTR
36 #ifdef ARCH_TEST_AES_128
37 #ifdef ARCH_TEST_SHA256
38 {"Test psa_generator_import_key for 16 Byte AES Key\n", {1, 2, 3, 4},
39 {PSA_KEY_TYPE_DERIVE, PSA_KEY_TYPE_AES},
40 {0x49, 0x8E, 0xC7, 0x7D, 0x01, 0x95, 0x0D, 0x94, 0x2C, 0x16, 0xA5, 0x3E, 0x99,
41  0x5F, 0xC9},
42  AES_16B_KEY_SIZE, {PSA_KEY_USAGE_DERIVE, PSA_KEY_USAGE_EXPORT},
43  {PSA_ALG_HKDF(PSA_ALG_SHA_256), PSA_ALG_CTR},
44  32, 16, PSA_SUCCESS
45 },
46 #endif
47 #endif
48 
49 #ifdef ARCH_TEST_SHA512
50 #ifdef ARCH_TEST_DES_3KEY
51 {"Test psa_generator_import_key for Triple DES 3-Key\n", {5, 6, 7, 8},
52 {PSA_KEY_TYPE_DERIVE, PSA_KEY_TYPE_DES},
53 {0xEA, 0xD5, 0xE6, 0xC8, 0x51, 0xF9, 0xEC, 0xBB, 0x9B, 0x57, 0x7C, 0xED, 0xD2,
54  0x4B, 0x82, 0x84, 0x9F, 0x9F, 0xE6, 0x73, 0x21, 0x3D, 0x1A, 0x05, 0xC9, 0xED,
55  0xDF, 0x25, 0x17, 0x68, 0x86, 0xAE},
56  AES_32B_KEY_SIZE, {PSA_KEY_USAGE_DERIVE, PSA_KEY_USAGE_EXPORT},
57 {PSA_ALG_HKDF(PSA_ALG_SHA_512), PSA_ALG_CTR},
58  DES3_3KEY_SIZE, DES3_3KEY_SIZE, PSA_SUCCESS
59 },
60 #endif
61 #endif
62 
63 #ifdef ARCH_TEST_SHA1
64 #ifdef ARCH_TEST_AES
65 {"Test psa_generator_import_key output greater than capacity\n", {9, 10, 11, 12},
66 {PSA_KEY_TYPE_DERIVE, PSA_KEY_TYPE_AES},
67 {0x70, 0x24, 0x55, 0x0C, 0x14, 0x9D, 0xED, 0x29},
68  DES_8B_KEY_SIZE, {PSA_KEY_USAGE_DERIVE, PSA_KEY_USAGE_EXPORT},
69 {PSA_ALG_HKDF(PSA_ALG_SHA_1), PSA_ALG_CTR},
70  64, 80, PSA_ERROR_INSUFFICIENT_CAPACITY
71 },
72 #endif
73 #endif
74 
75 #ifdef ARCH_TEST_SHA256
76 #ifdef ARCH_TEST_RSA
77 {"Test psa_generator_import_key for RSA Public Key - Invalid type\n", {13, 14, 15, 16},
78 {PSA_KEY_TYPE_DERIVE, PSA_KEY_TYPE_RSA_PUBLIC_KEY},
79 {0x49, 0x8E, 0xC7, 0x7D, 0x01, 0x95, 0x0D, 0x94, 0x2C, 0x16, 0xA5, 0x3E, 0x99,
80  0x5F, 0xC9},
81  AES_16B_KEY_SIZE, {PSA_KEY_USAGE_DERIVE, PSA_KEY_USAGE_EXPORT},
82 {PSA_ALG_HKDF(PSA_ALG_SHA_256), PSA_ALG_CTR},
83  32, 16, PSA_ERROR_INVALID_ARGUMENT
84 },
85 #endif
86 #endif
87 
88 #ifdef ARCH_TEST_SHA256
89 #ifdef ARCH_TEST_AES_128
90 {"Test psa_generator_import_key for invalid byte for generation\n", {20, 21, 22, 23},
91 {PSA_KEY_TYPE_DERIVE, PSA_KEY_TYPE_AES},
92 {0x49, 0x8E, 0xC7, 0x7D, 0x01, 0x95, 0x0D, 0x94, 0x2C, 0x16, 0xA5, 0x3E, 0x99,
93  0x5F, 0xC9},
94  AES_16B_KEY_SIZE, {PSA_KEY_USAGE_DERIVE, PSA_KEY_USAGE_EXPORT},
95 {PSA_ALG_HKDF(PSA_ALG_SHA_256), PSA_ALG_CTR},
96  32, 10, PSA_ERROR_INVALID_ARGUMENT
97 },
98 #endif
99 #endif
100 #endif
101 #endif
102 };
103 
104 static test_data check2[] = {
105 #ifdef ARCH_TEST_HKDF
106 #ifdef ARCH_TEST_CIPER_MODE_CTR
107 #ifdef ARCH_TEST_AES_128
108 #ifdef ARCH_TEST_SHA256
109 {"Test psa_generator_import_key negative cases\n",
110 {17, 18, 18, 18},
111 {PSA_KEY_TYPE_DERIVE, PSA_KEY_TYPE_AES},
112 {0x49, 0x8E, 0xC7, 0x7D, 0x01, 0x95, 0x0D, 0x94, 0x2C, 0x16, 0xA5, 0x3E, 0x99,
113  0x5F, 0xC9},
114  AES_16B_KEY_SIZE, {PSA_KEY_USAGE_DERIVE, PSA_KEY_USAGE_EXPORT},
115 {PSA_ALG_HKDF(PSA_ALG_SHA_256), PSA_ALG_CTR},
116  32, BYTES_TO_BITS(8), PSA_ERROR_INVALID_HANDLE
117 },
118 #endif
119 #endif
120 #endif
121 #endif
122 };
Copyright (c) 2018-2019, Arm Limited or its affiliates.
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.