22 psa_key_handle_t key_handle;
23 psa_key_type_t key_type;
26 psa_key_usage_t usage;
27 psa_algorithm_t key_alg;
32 size_t output_size[2];
33 uint8_t expected_output[32];
34 size_t expected_output_length;
35 psa_status_t expected_status;
39 #ifdef ARCH_TEST_AES_128 40 #ifdef ARCH_TEST_CBC_NO_PADDING 41 {
"Test psa_cipher_finish - 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, {SIZE_32B, SIZE_32B},
49 {0xA0, 0x76, 0xEC, 0x9D, 0xFB, 0xE4, 0x7D, 0x52, 0xAF, 0xC3, 0x57, 0x33, 0x6F,
50 0x20, 0x74, 0x3B}, 0, PSA_SUCCESS
53 {
"Test psa_cipher_finish - 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, 16},
60 {0x6b, 0xc1, 0xbe, 0xe2, 0x23}, 0, PSA_ERROR_INVALID_ARGUMENT
64 #ifdef ARCH_TEST_CBC_PKCS7 65 {
"Test psa_cipher_finish - 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, {SIZE_32B, SIZE_32B},
73 {0xa0, 0x76, 0xec, 0x9d, 0xfb, 0xe4, 0x7d, 0x52, 0xaf, 0xc3, 0x57, 0x33, 0x6f,
74 0x20, 0x74, 0x3b, 0xca, 0x7e, 0x8a, 0x15, 0xdc, 0x3c, 0x77, 0x64, 0x36, 0x31,
75 0x42, 0x93, 0x03, 0x1c, 0xd4, 0xf3}, 16, PSA_SUCCESS
78 {
"Test psa_cipher_finish - Encrypt - AES CBC_PKCS7 (Short input)\n", 4, PSA_KEY_TYPE_AES,
79 {0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09,
80 0xcf, 0x4f, 0x3c}, AES_16B_KEY_SIZE,
81 PSA_KEY_USAGE_ENCRYPT, PSA_ALG_CBC_PKCS7,
82 {0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a,
83 0x2a, 0x2a, 0x2a}, 16,
84 {0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73,
85 0x93, 0x17}, 15, {SIZE_32B, SIZE_32B},
86 {0x62, 0x79, 0xb4, 0x9d, 0x7f, 0x7a, 0x8d, 0xd8, 0x7b, 0x68, 0x51, 0x75, 0xd4,
87 0x27, 0x6e, 0x24}, 16, PSA_SUCCESS
91 #ifdef ARCH_TEST_CIPER_MODE_CTR 92 {
"Test psa_cipher_finish - Encrypt - AES CTR\n", 5, PSA_KEY_TYPE_AES,
93 {0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09,
94 0xcf, 0x4f, 0x3c}, AES_16B_KEY_SIZE,
95 PSA_KEY_USAGE_ENCRYPT, PSA_ALG_CTR,
96 {0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a,
97 0x2a, 0x2a, 0x2a}, 16,
98 {0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73,
99 0x93, 0x17, 0x2a}, 16, {SIZE_32B, SIZE_32B},
100 {0x8f, 0x94, 0x08, 0xfe, 0x80, 0xa8, 0x1d, 0x3e, 0x81, 0x3d, 0xa3, 0xc7, 0xb0,
101 0xb2, 0xbd, 0x32}, 0, PSA_SUCCESS
104 {
"Test psa_cipher_finish - Encrypt - AES CTR (short input)\n", 6, PSA_KEY_TYPE_AES,
105 {0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09,
106 0xcf, 0x4f, 0x3c}, AES_16B_KEY_SIZE,
107 PSA_KEY_USAGE_ENCRYPT, PSA_ALG_CTR,
108 {0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a,
109 0x2a, 0x2a, 0x2a}, 16,
110 {0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73,
111 0x93, 0x17}, 15, {SIZE_32B, SIZE_32B},
112 {0x8f, 0x94, 0x08, 0xfe, 0x80, 0xa8, 0x1d, 0x3e, 0x81, 0x3d, 0xa3, 0xc7, 0xb0,
113 0xb2, 0xbd}, 0, PSA_SUCCESS
118 #ifdef ARCH_TEST_CBC_NO_PADDING 119 #ifdef ARCH_TEST_DES_1KEY 120 {
"Test psa_cipher_finish - Encrypt - DES CBC (nopad)\n", 7, PSA_KEY_TYPE_DES,
121 {0x01, 0x02, 0x04, 0x07, 0x08, 0x0b, 0x0d, 0x0e}, DES_8B_KEY_SIZE,
122 PSA_KEY_USAGE_ENCRYPT, PSA_ALG_CBC_NO_PADDING,
123 {0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a}, 8,
124 {0xed, 0xa4, 0x01, 0x12, 0x39, 0xbc, 0x3a, 0xc9}, 8, {SIZE_32B, SIZE_32B},
125 {0x64, 0xf9, 0x17, 0xb0, 0x15, 0x2f, 0x8f, 0x05}, 0, PSA_SUCCESS
129 #ifdef ARCH_TEST_DES_2KEY 130 {
"Test psa_cipher_finish - Encrypt - 2-key 3DE -CBC (nopad)\n", 8, PSA_KEY_TYPE_DES,
131 {0x01, 0x02, 0x04, 0x07, 0x08, 0x0b, 0x0d, 0x0e, 0xc1, 0xc2, 0xc4, 0xc7, 0xc8,
132 0xcb, 0xcd, 0xce}, DES3_2KEY_SIZE,
133 PSA_KEY_USAGE_ENCRYPT, PSA_ALG_CBC_NO_PADDING,
134 {0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a}, 8,
135 {0xed, 0xa4, 0x01, 0x12, 0x39, 0xbc, 0x3a, 0xc9}, 8, {SIZE_32B, SIZE_32B},
136 {0x5d, 0x06, 0x52, 0x42, 0x9c, 0x5b, 0x0a, 0xc7}, 0, PSA_SUCCESS
140 #ifdef ARCH_TEST_DES_3KEY 141 {
"Test psa_cipher_finish - Encrypt - 3-key 3DE -CBC (nopad)\n", 9, PSA_KEY_TYPE_DES,
142 {0x01, 0x02, 0x04, 0x07, 0x08, 0x0b, 0x0d, 0x0e, 0xc1, 0xc2, 0xc4, 0xc7, 0xc8,
143 0xcb, 0xcd, 0xce, 0x31, 0x32, 0x34, 0x37, 0x38, 0x3b, 0x3d, 0x3e}, DES3_3KEY_SIZE,
144 PSA_KEY_USAGE_ENCRYPT, PSA_ALG_CBC_NO_PADDING,
145 {0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a}, 8,
146 {0xed, 0xa4, 0x01, 0x12, 0x39, 0xbc, 0x3a, 0xc9}, 8, {SIZE_32B, SIZE_32B},
147 {0x81, 0x7c, 0xa7, 0xd6, 0x9b, 0x80, 0xd8, 0x6a}, 0, PSA_SUCCESS
152 #ifdef ARCH_TEST_AES_128 153 #ifdef ARCH_TEST_CBC_PKCS7 154 {
"Test psa_cipher_finish - small output buffer size\n", 10, PSA_KEY_TYPE_AES,
155 {0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09,
156 0xcf, 0x4f, 0x3c}, AES_16B_KEY_SIZE,
157 PSA_KEY_USAGE_ENCRYPT, PSA_ALG_CBC_PKCS7,
158 {0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a,
159 0x2a, 0x2a, 0x2a}, 16,
160 {0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73,
161 0x93, 0x17, 0x2a}, 16, {SIZE_32B, 15},
162 {0xa0, 0x76, 0xec, 0x9d, 0xfb, 0xe4, 0x7d, 0x52, 0xaf, 0xc3, 0x57, 0x33, 0x6f,
163 0x20, 0x74, 0x3b, 0xca, 0x7e, 0x8a, 0x15, 0xdc, 0x3c, 0x77, 0x64, 0x36, 0x31,
164 0x42, 0x93, 0x03, 0x1c, 0xd4, 0xf3}, 16, PSA_ERROR_BUFFER_TOO_SMALL
168 #ifdef ARCH_TEST_CBC_NO_PADDING 169 {
"Test psa_cipher_finish - Decrypt - AES CBC_NO_PADDING\n", 11, PSA_KEY_TYPE_AES,
170 {0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09,
171 0xcf, 0x4f, 0x3c}, AES_16B_KEY_SIZE,
172 PSA_KEY_USAGE_DECRYPT, PSA_ALG_CBC_NO_PADDING,
173 {0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a,
174 0x2a, 0x2a, 0x2a}, 16,
175 {0xA0, 0x76, 0xEC, 0x9D, 0xFB, 0xE4, 0x7D, 0x52, 0xAF, 0xC3, 0x57, 0x33, 0x6F,
177 16, {SIZE_32B, SIZE_32B},
178 {0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73,
179 0x93, 0x17, 0x2a}, 0, PSA_SUCCESS
182 {
"Test psa_cipher_finish - Decrypt - AES CBC_NO_PADDING (Short input)\n", 12, PSA_KEY_TYPE_AES,
183 {0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09,
184 0xcf, 0x4f, 0x3c}, AES_16B_KEY_SIZE,
185 PSA_KEY_USAGE_ENCRYPT, PSA_ALG_CBC_NO_PADDING,
186 {0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a,
187 0x2a, 0x2a, 0x2a}, 16,
188 {0x6b, 0xc1, 0xbe, 0xe2, 0x23}, 5, {16, 16},
189 {0x6b, 0xc1, 0xbe, 0xe2, 0x23}, 0, PSA_ERROR_INVALID_ARGUMENT
193 #ifdef ARCH_TEST_CBC_PKCS7 194 {
"Test psa_cipher_finish - Decrypt - AES CBC_PKCS7\n", 13, PSA_KEY_TYPE_AES,
195 {0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09,
196 0xcf, 0x4f, 0x3c}, AES_16B_KEY_SIZE,
197 PSA_KEY_USAGE_DECRYPT, PSA_ALG_CBC_PKCS7,
198 {0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a,
199 0x2a, 0x2a, 0x2a}, 16,
200 {0xa0, 0x76, 0xec, 0x9d, 0xfb, 0xe4, 0x7d, 0x52, 0xaf, 0xc3, 0x57, 0x33, 0x6f,
201 0x20, 0x74, 0x3b, 0xca, 0x7e, 0x8a, 0x15, 0xdc, 0x3c, 0x77, 0x64, 0x36, 0x31,
202 0x42, 0x93, 0x03, 0x1c, 0xd4, 0xf3}, 32, {SIZE_32B, SIZE_32B},
203 {0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73,
204 0x93, 0x17, 0x2a}, 0, PSA_SUCCESS
207 {
"Test psa_cipher_finish - Decrypt - AES CBC_PKCS7 (Short input)\n", 14, PSA_KEY_TYPE_AES,
208 {0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09,
209 0xcf, 0x4f, 0x3c}, AES_16B_KEY_SIZE,
210 PSA_KEY_USAGE_DECRYPT, PSA_ALG_CBC_PKCS7,
211 {0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a,
212 0x2a, 0x2a, 0x2a}, 16,
213 {0x62, 0x79, 0xb4, 0x9d, 0x7f, 0x7a, 0x8d, 0xd8, 0x7b, 0x68, 0x51, 0x75, 0xd4,
214 0x27, 0x6e, 0x24}, 16, {SIZE_32B, SIZE_32B},
215 {0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73,
216 0x93, 0x17}, 15, PSA_SUCCESS
220 #ifdef ARCH_TEST_CIPER_MODE_CTR 221 {
"Test psa_cipher_finish - Decrypt - AES CTR\n", 15, PSA_KEY_TYPE_AES,
222 {0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09,
223 0xcf, 0x4f, 0x3c}, AES_16B_KEY_SIZE,
224 PSA_KEY_USAGE_DECRYPT, PSA_ALG_CTR,
225 {0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a,
226 0x2a, 0x2a, 0x2a}, 16,
227 {0x8f, 0x94, 0x08, 0xfe, 0x80, 0xa8, 0x1d, 0x3e, 0x81, 0x3d, 0xa3, 0xc7, 0xb0,
228 0xb2, 0xbd, 0x32}, 16, {SIZE_32B, SIZE_32B},
229 {0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73,
234 {
"Test psa_cipher_finish - Decrypt - AES CTR (short input)\n", 16, PSA_KEY_TYPE_AES,
235 {0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09,
236 0xcf, 0x4f, 0x3c}, AES_16B_KEY_SIZE,
237 PSA_KEY_USAGE_DECRYPT, PSA_ALG_CTR,
238 {0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a,
239 0x2a, 0x2a, 0x2a}, 16,
240 {0x8f, 0x94, 0x08, 0xfe, 0x80, 0xa8, 0x1d, 0x3e, 0x81, 0x3d, 0xa3, 0xc7, 0xb0,
241 0xb2, 0xbd}, 15, {SIZE_32B, SIZE_32B},
242 {0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73,
243 0x93, 0x17}, 0, PSA_SUCCESS
248 #ifdef ARCH_TEST_CBC_NO_PADDING 249 #ifdef ARCH_TEST_DES_1KEY 250 {
"Test psa_cipher_finish - Decrypt - DES CBC (nopad)\n", 17, PSA_KEY_TYPE_DES,
251 {0x01, 0x02, 0x04, 0x07, 0x08, 0x0b, 0x0d, 0x0e}, DES_8B_KEY_SIZE,
252 PSA_KEY_USAGE_DECRYPT, PSA_ALG_CBC_NO_PADDING,
253 {0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a}, 8,
254 {0x64, 0xf9, 0x17, 0xb0, 0x15, 0x2f, 0x8f, 0x05}, 8, {SIZE_32B, SIZE_32B},
255 {0xed, 0xa4, 0x01, 0x12, 0x39, 0xbc, 0x3a, 0xc9}, 0, PSA_SUCCESS
259 #ifdef ARCH_TEST_DES_2KEY 260 {
"Test psa_cipher_finish - Decrypt - 2-key 3DE -CBC (nopad)\n", 18, PSA_KEY_TYPE_DES,
261 {0x01, 0x02, 0x04, 0x07, 0x08, 0x0b, 0x0d, 0x0e, 0xc1, 0xc2, 0xc4, 0xc7, 0xc8,
262 0xcb, 0xcd, 0xce}, DES3_2KEY_SIZE,
263 PSA_KEY_USAGE_DECRYPT, PSA_ALG_CBC_NO_PADDING,
264 {0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a}, 8,
265 {0x5d, 0x06, 0x52, 0x42, 0x9c, 0x5b, 0x0a, 0xc7}, 8, {SIZE_32B, SIZE_32B},
266 {0xed, 0xa4, 0x01, 0x12, 0x39, 0xbc, 0x3a, 0xc9}, 0, PSA_SUCCESS
270 #ifdef ARCH_TEST_DES_3KEY 271 {
"Test psa_cipher_finish - 3-key 3DE -CBC (nopad)\n", 19, PSA_KEY_TYPE_DES,
272 {0x01, 0x02, 0x04, 0x07, 0x08, 0x0b, 0x0d, 0x0e, 0xc1, 0xc2, 0xc4, 0xc7, 0xc8,
273 0xcb, 0xcd, 0xce, 0x31, 0x32, 0x34, 0x37, 0x38, 0x3b, 0x3d, 0x3e}, DES3_3KEY_SIZE,
274 PSA_KEY_USAGE_DECRYPT, PSA_ALG_CBC_NO_PADDING,
275 {0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a}, 8,
276 {0x81, 0x7c, 0xa7, 0xd6, 0x9b, 0x80, 0xd8, 0x6a}, 8, {SIZE_32B, SIZE_32B},
277 {0xed, 0xa4, 0x01, 0x12, 0x39, 0xbc, 0x3a, 0xc9}, 0, PSA_SUCCESS
Copyright (c) 2018-2019, Arm Limited or its affiliates.