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;
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_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
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
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
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,
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
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
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
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
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
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
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
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
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
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
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
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
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
Copyright (c) 2018-2019, Arm Limited or its affiliates.