Mistake on this page?
Report an issue in GitHub or email us
compliance_crypto/test_c036/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;
23  psa_key_type_t key_type;
24  uint8_t key_data[32];
25  uint32_t key_length;
26  psa_key_usage_t usage;
27  psa_algorithm_t key_alg;
28  uint8_t iv[16];
29  size_t iv_size;
30  uint8_t input[32];
31  size_t input_length;
32  size_t output_size;
33  uint8_t expected_output[32];
34  size_t expected_output_length;
35  psa_status_t expected_status;
36 } test_data;
37 
38 static test_data check1[] = {
39 #ifdef ARCH_TEST_AES_128
40 #ifdef ARCH_TEST_CBC_NO_PADDING
41 {"Test psa_cipher_update - Encrypt - AES CBC_NO_PADDING\n", 1, PSA_KEY_TYPE_AES,
42 {0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09,
43  0xcf, 0x4f, 0x3c}, AES_16B_KEY_SIZE,
44  PSA_KEY_USAGE_ENCRYPT, PSA_ALG_CBC_NO_PADDING,
45 {0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a,
46  0x2a, 0x2a, 0x2a}, 16,
47 {0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73,
48  0x93, 0x17, 0x2a}, 16, 16,
49 {0xA0, 0x76, 0xEC, 0x9D, 0xFB, 0xE4, 0x7D, 0x52, 0xAF, 0xC3, 0x57, 0x33, 0x6F,
50  0x20, 0x74, 0x3B}, 16, PSA_SUCCESS
51 },
52 
53 {"Test psa_cipher_update - Encrypt - AES CBC_NO_PADDING (Short input)\n", 2, PSA_KEY_TYPE_AES,
54 {0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09,
55  0xcf, 0x4f, 0x3c}, AES_16B_KEY_SIZE,
56  PSA_KEY_USAGE_ENCRYPT, PSA_ALG_CBC_NO_PADDING,
57 {0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a,
58  0x2a, 0x2a, 0x2a}, 16,
59 {0x6b, 0xc1, 0xbe, 0xe2, 0x23}, 5, 16,
60 {0x6b, 0xc1, 0xbe, 0xe2, 0x23}, 0, PSA_SUCCESS
61 },
62 #endif
63 
64 #ifdef ARCH_TEST_CBC_PKCS7
65 {"Test psa_cipher_update - Encrypt - AES CBC_PKCS7\n", 3, PSA_KEY_TYPE_AES,
66 {0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09,
67  0xcf, 0x4f, 0x3c}, AES_16B_KEY_SIZE,
68  PSA_KEY_USAGE_ENCRYPT, PSA_ALG_CBC_PKCS7,
69 {0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a,
70  0x2a, 0x2a, 0x2a}, 16,
71 {0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73,
72  0x93, 0x17, 0x2a}, 16, 16,
73 {0xa0, 0x76, 0xec, 0x9d, 0xfb, 0xe4, 0x7d, 0x52, 0xaf, 0xc3, 0x57, 0x33, 0x6f,
74  0x20, 0x74, 0x3b}, 16, PSA_SUCCESS
75 },
76 
77 {"Test psa_cipher_update - Encrypt - AES CBC_PKCS7 (Short input)\n", 4, PSA_KEY_TYPE_AES,
78 {0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09,
79  0xcf, 0x4f, 0x3c}, AES_16B_KEY_SIZE,
80  PSA_KEY_USAGE_ENCRYPT, PSA_ALG_CBC_PKCS7,
81 {0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a,
82  0x2a, 0x2a, 0x2a}, 16,
83 {0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73,
84  0x93, 0x17}, 15, 16,
85 {0}, 0, PSA_SUCCESS
86 },
87 #endif
88 
89 #ifdef ARCH_TEST_CIPER_MODE_CTR
90 {"Test psa_cipher_update - Encrypt - AES CTR\n", 5, PSA_KEY_TYPE_AES,
91 {0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09,
92  0xcf, 0x4f, 0x3c}, AES_16B_KEY_SIZE,
93  PSA_KEY_USAGE_ENCRYPT, PSA_ALG_CTR,
94 {0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a,
95  0x2a, 0x2a, 0x2a}, 16,
96 {0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73,
97  0x93, 0x17, 0x2a}, 16, 16,
98 {0x8f, 0x94, 0x08, 0xfe, 0x80, 0xa8, 0x1d, 0x3e, 0x81, 0x3d, 0xa3, 0xc7, 0xb0,
99  0xb2, 0xbd, 0x32}, 16, PSA_SUCCESS
100 },
101 #endif
102 
103 #ifdef ARCH_TEST_CBC_NO_PADDING
104 #ifdef ARCH_TEST_DES_1KEY
105 {"Test psa_cipher_update - Encrypt - DES CBC (nopad)\n", 6, PSA_KEY_TYPE_DES,
106 {0x01, 0x02, 0x04, 0x07, 0x08, 0x0b, 0x0d, 0x0e}, DES_8B_KEY_SIZE,
107  PSA_KEY_USAGE_ENCRYPT, PSA_ALG_CBC_NO_PADDING,
108 {0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a}, 8,
109 {0xed, 0xa4, 0x01, 0x12, 0x39, 0xbc, 0x3a, 0xc9}, 8, 8,
110 {0x64, 0xf9, 0x17, 0xb0, 0x15, 0x2f, 0x8f, 0x05}, 8, PSA_SUCCESS
111 },
112 #endif
113 #endif
114 #endif
115 
116 #ifdef ARCH_TEST_CBC_NO_PADDING
117 #ifdef ARCH_TEST_DES_2KEY
118 {"Test psa_cipher_update - Encrypt - 2-key 3DE -CBC (nopad)\n", 7, PSA_KEY_TYPE_DES,
119 {0x01, 0x02, 0x04, 0x07, 0x08, 0x0b, 0x0d, 0x0e, 0xc1, 0xc2, 0xc4, 0xc7, 0xc8,
120  0xcb, 0xcd, 0xce}, DES3_2KEY_SIZE,
121  PSA_KEY_USAGE_ENCRYPT, PSA_ALG_CBC_NO_PADDING,
122 {0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a}, 8,
123 {0xed, 0xa4, 0x01, 0x12, 0x39, 0xbc, 0x3a, 0xc9}, 8, 8,
124 {0x5d, 0x06, 0x52, 0x42, 0x9c, 0x5b, 0x0a, 0xc7}, 8, PSA_SUCCESS
125 },
126 #endif
127 
128 #ifdef ARCH_TEST_DES_3KEY
129 {"Test psa_cipher_update - Encrypt - 3-key 3DE -CBC (nopad)\n", 8, PSA_KEY_TYPE_DES,
130 {0x01, 0x02, 0x04, 0x07, 0x08, 0x0b, 0x0d, 0x0e, 0xc1, 0xc2, 0xc4, 0xc7, 0xc8,
131  0xcb, 0xcd, 0xce, 0x31, 0x32, 0x34, 0x37, 0x38, 0x3b, 0x3d, 0x3e}, DES3_3KEY_SIZE,
132  PSA_KEY_USAGE_ENCRYPT, PSA_ALG_CBC_NO_PADDING,
133 {0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a}, 8,
134 {0xed, 0xa4, 0x01, 0x12, 0x39, 0xbc, 0x3a, 0xc9}, 8, 8,
135 {0x81, 0x7c, 0xa7, 0xd6, 0x9b, 0x80, 0xd8, 0x6a}, 8, PSA_SUCCESS
136 },
137 #endif
138 
139 #ifdef ARCH_TEST_AES_128
140 {"Test psa_cipher_update - small output buffer size\n", 9, PSA_KEY_TYPE_AES,
141 {0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09,
142  0xcf, 0x4f, 0x3c}, AES_16B_KEY_SIZE,
143  PSA_KEY_USAGE_ENCRYPT, PSA_ALG_CBC_NO_PADDING,
144 {0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a,
145  0x2a, 0x2a, 0x2a}, 16,
146 {0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73,
147  0x93, 0x17, 0x2a}, 16, 15,
148 {0xA0, 0x76, 0xEC, 0x9D, 0xFB, 0xE4, 0x7D, 0x52, 0xAF, 0xC3, 0x57, 0x33, 0x6F,
149  0x20, 0x74, 0x3B}, 16, PSA_ERROR_BUFFER_TOO_SMALL
150 },
151 
152 {"Test psa_cipher_update - Decrypt - AES CBC_NO_PADDING\n", 10, PSA_KEY_TYPE_AES,
153 {0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09,
154  0xcf, 0x4f, 0x3c}, AES_16B_KEY_SIZE,
155  PSA_KEY_USAGE_DECRYPT, PSA_ALG_CBC_NO_PADDING,
156 {0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a,
157  0x2a, 0x2a, 0x2a}, 16,
158 {0xA0, 0x76, 0xEC, 0x9D, 0xFB, 0xE4, 0x7D, 0x52, 0xAF, 0xC3, 0x57, 0x33, 0x6F,
159  0x20, 0x74, 0x3B}, 16, 16,
160 {0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73,
161  0x93, 0x17, 0x2a}, 16, PSA_SUCCESS
162 },
163 
164 {"Test psa_cipher_update - Decrypt - AES CBC_NO_PADDING (Short input)\n", 11, PSA_KEY_TYPE_AES,
165 {0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09,
166  0xcf, 0x4f, 0x3c}, AES_16B_KEY_SIZE,
167  PSA_KEY_USAGE_DECRYPT, PSA_ALG_CBC_NO_PADDING,
168 {0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a,
169  0x2a, 0x2a, 0x2a}, 16,
170 {0x6b, 0xc1, 0xbe, 0xe2, 0x23}, 5, 16,
171 {0x6b, 0xc1, 0xbe, 0xe2, 0x23}, 0, PSA_SUCCESS
172 },
173 #endif
174 #endif
175 
176 #ifdef ARCH_TEST_AES_128
177 #ifdef ARCH_TEST_CBC_PKCS7
178 {"Test psa_cipher_update - Decrypt - AES CBC_PKCS7\n", 12, PSA_KEY_TYPE_AES,
179 {0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09,
180  0xcf, 0x4f, 0x3c}, AES_16B_KEY_SIZE,
181  PSA_KEY_USAGE_DECRYPT, PSA_ALG_CBC_PKCS7,
182 {0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a,
183  0x2a, 0x2a, 0x2a}, 16,
184 {0xa0, 0x76, 0xec, 0x9d, 0xfb, 0xe4, 0x7d, 0x52, 0xaf, 0xc3, 0x57, 0x33, 0x6f,
185  0x20, 0x74, 0x3b}, 16, 16,
186 {0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73,
187  0x93, 0x17, 0x2a}, 0, PSA_SUCCESS
188 },
189 
190 {"Test psa_cipher_update - Decrypt - AES CBC_PKCS7 (Short input)\n", 13, PSA_KEY_TYPE_AES,
191 {0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09,
192  0xcf, 0x4f, 0x3c}, AES_16B_KEY_SIZE,
193  PSA_KEY_USAGE_DECRYPT, PSA_ALG_CBC_PKCS7,
194 {0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a,
195  0x2a, 0x2a, 0x2a}, 16,
196 {0xa0, 0x76, 0xec, 0x9d, 0xfb, 0xe4, 0x7d, 0x52, 0xaf, 0xc3, 0x57, 0x33, 0x6f,
197  0x20, 0x74, 0x3b, 0xca, 0x7e, 0x8a, 0x15, 0xdc, 0x3c, 0x77, 0x64, 0x36, 0x31,
198  0x42, 0x93, 0x03, 0x1c, 0xd4, 0xf3}, 32, 32,
199 {0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73,
200  0x93, 0x17, 0x2a}, 16, PSA_SUCCESS
201 },
202 #endif
203 
204 #ifdef ARCH_TEST_CIPER_MODE_CTR
205 {"Test psa_cipher_update - Decrypt - AES CTR\n", 14, PSA_KEY_TYPE_AES,
206 {0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09,
207  0xcf, 0x4f, 0x3c}, AES_16B_KEY_SIZE,
208  PSA_KEY_USAGE_DECRYPT, PSA_ALG_CTR,
209 {0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a,
210  0x2a, 0x2a, 0x2a}, 16,
211 {0x8f, 0x94, 0x08, 0xfe, 0x80, 0xa8, 0x1d, 0x3e, 0x81, 0x3d, 0xa3, 0xc7, 0xb0,
212  0xb2, 0xbd, 0x32}, 16, 16,
213 {0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73,
214  0x93, 0x17, 0x2a}, 16, PSA_SUCCESS
215 },
216 #endif
217 #endif
218 
219 #ifdef ARCH_TEST_CBC_NO_PADDING
220 #ifdef ARCH_TEST_DES_1KEY
221 {"Test psa_cipher_update - Decrypt - DES CBC (nopad)\n", 15, PSA_KEY_TYPE_DES,
222 {0x01, 0x02, 0x04, 0x07, 0x08, 0x0b, 0x0d, 0x0e}, DES_8B_KEY_SIZE,
223  PSA_KEY_USAGE_DECRYPT, PSA_ALG_CBC_NO_PADDING,
224 {0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a}, 8,
225 {0x64, 0xf9, 0x17, 0xb0, 0x15, 0x2f, 0x8f, 0x05}, 8, 8,
226 {0xed, 0xa4, 0x01, 0x12, 0x39, 0xbc, 0x3a, 0xc9}, 8, PSA_SUCCESS
227 },
228 #endif
229 
230 #ifdef ARCH_TEST_DES_2KEY
231 {"Test psa_cipher_update - Decrypt - 2-key 3DE -CBC (nopad)\n", 16, PSA_KEY_TYPE_DES,
232 {0x01, 0x02, 0x04, 0x07, 0x08, 0x0b, 0x0d, 0x0e, 0xc1, 0xc2, 0xc4, 0xc7, 0xc8,
233  0xcb, 0xcd, 0xce}, DES3_2KEY_SIZE,
234  PSA_KEY_USAGE_DECRYPT, PSA_ALG_CBC_NO_PADDING,
235 {0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a}, 8,
236 {0x5d, 0x06, 0x52, 0x42, 0x9c, 0x5b, 0x0a, 0xc7}, 8, 8,
237 {0xed, 0xa4, 0x01, 0x12, 0x39, 0xbc, 0x3a, 0xc9}, 8, PSA_SUCCESS
238 },
239 #endif
240 
241 #ifdef ARCH_TEST_DES_3KEY
242 {"Test psa_cipher_update - Decrypt - 3-key 3DE -CBC (nopad)\n", 17, PSA_KEY_TYPE_DES,
243 {0x01, 0x02, 0x04, 0x07, 0x08, 0x0b, 0x0d, 0x0e, 0xc1, 0xc2, 0xc4, 0xc7, 0xc8,
244  0xcb, 0xcd, 0xce, 0x31, 0x32, 0x34, 0x37, 0x38, 0x3b, 0x3d, 0x3e}, DES3_3KEY_SIZE,
245  PSA_KEY_USAGE_DECRYPT, PSA_ALG_CBC_NO_PADDING,
246 {0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a}, 8,
247 {0x81, 0x7c, 0xa7, 0xd6, 0x9b, 0x80, 0xd8, 0x6a}, 8, 8,
248 {0xed, 0xa4, 0x01, 0x12, 0x39, 0xbc, 0x3a, 0xc9}, 8, PSA_SUCCESS
249 },
250 #endif
251 #endif
252 };
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.