blob: 2915fba68ddea39fb5b8f0b7adfc1d98c295b1bf [file] [log] [blame]
Steven Cooreman37941cb2020-07-28 18:49:51 +02001/*
2 * Test driver for cipher functions.
3 * Currently only supports multi-part operations using AES-CTR.
4 */
Steven Cooreman3ec40182020-09-02 16:27:46 +02005/* Copyright The Mbed TLS Contributors
Steven Cooreman37941cb2020-07-28 18:49:51 +02006 * SPDX-License-Identifier: Apache-2.0
7 *
8 * Licensed under the Apache License, Version 2.0 (the "License"); you may
9 * not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
16 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
Steven Cooreman37941cb2020-07-28 18:49:51 +020019 */
20
21#if !defined(MBEDTLS_CONFIG_FILE)
22#include "mbedtls/config.h"
23#else
24#include MBEDTLS_CONFIG_FILE
25#endif
26
27#if defined(MBEDTLS_PSA_CRYPTO_DRIVERS) && defined(PSA_CRYPTO_DRIVER_TEST)
28#include "psa/crypto.h"
Steven Cooremanacb5a102020-09-08 14:06:57 +020029#include "psa_crypto_core.h"
Steven Cooreman37941cb2020-07-28 18:49:51 +020030#include "mbedtls/cipher.h"
31
Steven Cooremanacb5a102020-09-08 14:06:57 +020032#include "test/drivers/cipher.h"
Steven Cooreman37941cb2020-07-28 18:49:51 +020033
34#include "test/random.h"
35
36#include <string.h>
37
Steven Cooreman5240e8b2020-09-09 11:51:45 +020038/* Test driver implements AES-CTR only. Its default behaviour (when its return
39 * status is not overridden through the hooks) is to take care of all AES-CTR
40 * operations, and return PSA_ERROR_NOT_SUPPORTED for all others.
Steven Cooremanacb5a102020-09-08 14:06:57 +020041 * Set test_driver_cipher_hooks.forced_status to PSA_ERROR_NOT_SUPPORTED to use
Steven Cooreman5240e8b2020-09-09 11:51:45 +020042 * fallback even for AES-CTR. */
Steven Cooremanacb5a102020-09-08 14:06:57 +020043test_driver_cipher_hooks_t test_driver_cipher_hooks = TEST_DRIVER_CIPHER_INIT;
Steven Cooreman37941cb2020-07-28 18:49:51 +020044
Steven Cooremanfe0ab552020-09-10 13:07:02 +020045static psa_status_t test_transparent_cipher_oneshot(
46 mbedtls_operation_t direction,
47 const psa_key_attributes_t *attributes,
48 const uint8_t *key, size_t key_length,
49 psa_algorithm_t alg,
50 const uint8_t *input, size_t input_length,
51 uint8_t *output, size_t output_size, size_t *output_length)
52{
53 test_driver_cipher_hooks.hits++;
54
55 /* Test driver supports AES-CTR only, to verify operation calls. */
56 if( alg != PSA_ALG_CTR ||
57 psa_get_key_type( attributes ) != PSA_KEY_TYPE_AES )
58 return( PSA_ERROR_NOT_SUPPORTED );
59
60 /* If test driver response code is not SUCCESS, we can return early */
61 if( test_driver_cipher_hooks.forced_status != PSA_SUCCESS )
62 return( test_driver_cipher_hooks.forced_status );
63
64 /* If test driver output is overridden, we don't need to do actual crypto */
65 if( test_driver_cipher_hooks.forced_output != NULL )
66 {
67 if( output_size < test_driver_cipher_hooks.forced_output_length )
68 return( PSA_ERROR_BUFFER_TOO_SMALL );
69
70 memcpy( output,
71 test_driver_cipher_hooks.forced_output,
72 test_driver_cipher_hooks.forced_output_length );
73 *output_length = test_driver_cipher_hooks.forced_output_length;
74
75 return( test_driver_cipher_hooks.forced_status );
76 }
77
78 /* Run AES-CTR using the cipher module */
79 {
80 mbedtls_test_rnd_pseudo_info rnd_info;
81 memset( &rnd_info, 0x5A, sizeof( mbedtls_test_rnd_pseudo_info ) );
82
83 const mbedtls_cipher_info_t *cipher_info =
84 mbedtls_cipher_info_from_values( MBEDTLS_CIPHER_ID_AES,
85 key_length * 8,
86 MBEDTLS_MODE_CTR );
87 mbedtls_cipher_context_t cipher;
88 int ret = 0;
89 uint8_t temp_output_buffer[16] = {0};
90 size_t temp_output_length = 0;
91
92 if( direction == MBEDTLS_ENCRYPT )
93 {
94 /* Oneshot encrypt needs to prepend the IV to the output */
95 if( output_size < ( input_length + 16 ) )
96 return( PSA_ERROR_BUFFER_TOO_SMALL );
97 }
98 else
99 {
100 /* Oneshot decrypt has the IV prepended to the input */
101 if( output_size < ( input_length - 16 ) )
102 return( PSA_ERROR_BUFFER_TOO_SMALL );
103 }
104
105 if( cipher_info == NULL )
106 return( PSA_ERROR_NOT_SUPPORTED );
107
108 mbedtls_cipher_init( &cipher );
109 ret = mbedtls_cipher_setup( &cipher, cipher_info );
110 if( ret != 0 )
111 goto exit;
112
113 ret = mbedtls_cipher_setkey( &cipher,
114 key,
115 key_length * 8, direction );
116 if( ret != 0 )
117 goto exit;
118
119 if( direction == MBEDTLS_ENCRYPT )
120 {
121 mbedtls_test_rnd_pseudo_info rnd_info;
122 memset( &rnd_info, 0x5A, sizeof( mbedtls_test_rnd_pseudo_info ) );
123
124 ret = mbedtls_test_rnd_pseudo_rand( &rnd_info,
125 temp_output_buffer,
126 16 );
127 if( ret != 0 )
128 goto exit;
129
130 ret = mbedtls_cipher_set_iv( &cipher, temp_output_buffer, 16 );
131 }
132 else
133 ret = mbedtls_cipher_set_iv( &cipher, input, 16 );
134
135 if( ret != 0 )
136 goto exit;
137
138 if( direction == MBEDTLS_ENCRYPT )
139 {
140 ret = mbedtls_cipher_update( &cipher,
141 input, input_length,
142 &output[16], output_length );
143 if( ret == 0 )
144 {
145 memcpy( output, temp_output_buffer, 16 );
146 *output_length += 16;
147 }
148 }
149 else
150 ret = mbedtls_cipher_update( &cipher,
151 &input[16], input_length - 16,
152 output, output_length );
153
154 if( ret != 0 )
155 goto exit;
156
157 ret = mbedtls_cipher_finish( &cipher,
158 temp_output_buffer,
159 &temp_output_length );
160
161exit:
162 if( ret != 0 )
163 {
164 *output_length = 0;
165 memset(output, 0, output_size);
166 }
167
168 mbedtls_cipher_free( &cipher );
169 return( mbedtls_to_psa_error( ret ) );
170 }
171}
172
Steven Cooreman37941cb2020-07-28 18:49:51 +0200173psa_status_t test_transparent_cipher_encrypt(
174 const psa_key_attributes_t *attributes,
175 const uint8_t *key, size_t key_length,
176 psa_algorithm_t alg,
177 const uint8_t *input, size_t input_length,
178 uint8_t *output, size_t output_size, size_t *output_length)
179{
Steven Cooremanfe0ab552020-09-10 13:07:02 +0200180 return (
181 test_transparent_cipher_oneshot(
182 MBEDTLS_ENCRYPT,
183 attributes,
184 key, key_length,
185 alg,
186 input, input_length,
187 output, output_size, output_length) );
Steven Cooreman37941cb2020-07-28 18:49:51 +0200188}
189
190psa_status_t test_transparent_cipher_decrypt(
191 const psa_key_attributes_t *attributes,
192 const uint8_t *key, size_t key_length,
193 psa_algorithm_t alg,
194 const uint8_t *input, size_t input_length,
195 uint8_t *output, size_t output_size, size_t *output_length)
196{
Steven Cooremanfe0ab552020-09-10 13:07:02 +0200197 return (
198 test_transparent_cipher_oneshot(
199 MBEDTLS_DECRYPT,
200 attributes,
201 key, key_length,
202 alg,
203 input, input_length,
204 output, output_size, output_length) );
Steven Cooreman37941cb2020-07-28 18:49:51 +0200205}
206
Steven Cooreman16afd3d2020-09-09 15:36:39 +0200207static psa_status_t test_transparent_cipher_setup(
208 mbedtls_operation_t direction,
Steven Cooreman37941cb2020-07-28 18:49:51 +0200209 test_transparent_cipher_operation_t *operation,
210 const psa_key_attributes_t *attributes,
211 const uint8_t *key, size_t key_length,
212 psa_algorithm_t alg)
213{
Steven Cooreman8b122252020-09-03 15:30:32 +0200214 const mbedtls_cipher_info_t *cipher_info = NULL;
215 int ret = 0;
Steven Cooreman37941cb2020-07-28 18:49:51 +0200216
Steven Cooremanacb5a102020-09-08 14:06:57 +0200217 test_driver_cipher_hooks.hits++;
Steven Cooreman8b122252020-09-03 15:30:32 +0200218
219 if( operation->alg != 0 )
Steven Cooremanacb5a102020-09-08 14:06:57 +0200220 return( PSA_ERROR_BAD_STATE );
Steven Cooreman8b122252020-09-03 15:30:32 +0200221
Steven Cooreman5240e8b2020-09-09 11:51:45 +0200222 /* Wiping the entire struct here, instead of member-by-member. This is useful
223 * for the test suite, since it gives a chance of catching memory corruption
224 * errors should the core not have allocated (enough) memory for our context
225 * struct. */
226 memset( operation, 0, sizeof( *operation ) );
Steven Cooreman8b122252020-09-03 15:30:32 +0200227
228 /* Test driver supports AES-CTR only, to verify operation calls. */
Steven Cooremanacb5a102020-09-08 14:06:57 +0200229 if( alg != PSA_ALG_CTR ||
230 psa_get_key_type( attributes ) != PSA_KEY_TYPE_AES )
231 return( PSA_ERROR_NOT_SUPPORTED );
Steven Cooreman8b122252020-09-03 15:30:32 +0200232
233 operation->alg = alg;
234 operation->iv_size = 16;
Steven Cooreman8b122252020-09-03 15:30:32 +0200235
236 cipher_info = mbedtls_cipher_info_from_values( MBEDTLS_CIPHER_ID_AES,
237 key_length * 8,
238 MBEDTLS_MODE_CTR );
239 if( cipher_info == NULL )
Steven Cooremanacb5a102020-09-08 14:06:57 +0200240 return( PSA_ERROR_NOT_SUPPORTED );
Steven Cooreman8b122252020-09-03 15:30:32 +0200241
242 mbedtls_cipher_init( &operation->cipher );
Steven Cooreman8b122252020-09-03 15:30:32 +0200243 ret = mbedtls_cipher_setup( &operation->cipher, cipher_info );
244 if( ret != 0 ) {
245 mbedtls_cipher_free( &operation->cipher );
Steven Cooremanacb5a102020-09-08 14:06:57 +0200246 return( mbedtls_to_psa_error( ret ) );
Steven Cooreman8b122252020-09-03 15:30:32 +0200247 }
248
249 ret = mbedtls_cipher_setkey( &operation->cipher,
250 key,
Steven Cooreman16afd3d2020-09-09 15:36:39 +0200251 key_length * 8, direction );
Steven Cooreman8b122252020-09-03 15:30:32 +0200252 if( ret != 0 ) {
253 mbedtls_cipher_free( &operation->cipher );
Steven Cooremanacb5a102020-09-08 14:06:57 +0200254 return( mbedtls_to_psa_error( ret ) );
Steven Cooreman8b122252020-09-03 15:30:32 +0200255 }
256
257 operation->iv_set = 0;
258 operation->iv_required = 1;
259 operation->key_set = 1;
260
261 /* Allow overriding return value for testing purposes */
Steven Cooremanacb5a102020-09-08 14:06:57 +0200262 if( test_driver_cipher_hooks.forced_status != PSA_SUCCESS )
Steven Cooreman8b122252020-09-03 15:30:32 +0200263 mbedtls_cipher_free( &operation->cipher );
264
Steven Cooremanacb5a102020-09-08 14:06:57 +0200265 return( test_driver_cipher_hooks.forced_status );
Steven Cooreman37941cb2020-07-28 18:49:51 +0200266}
267
Steven Cooreman16afd3d2020-09-09 15:36:39 +0200268psa_status_t test_transparent_cipher_encrypt_setup(
269 test_transparent_cipher_operation_t *operation,
270 const psa_key_attributes_t *attributes,
271 const uint8_t *key, size_t key_length,
272 psa_algorithm_t alg)
273{
274 return ( test_transparent_cipher_setup( MBEDTLS_ENCRYPT,
275 operation,
276 attributes,
277 key,
278 key_length,
279 alg ) );
280}
281
Steven Cooreman37941cb2020-07-28 18:49:51 +0200282psa_status_t test_transparent_cipher_decrypt_setup(
283 test_transparent_cipher_operation_t *operation,
284 const psa_key_attributes_t *attributes,
285 const uint8_t *key, size_t key_length,
286 psa_algorithm_t alg)
287{
Steven Cooreman16afd3d2020-09-09 15:36:39 +0200288 return ( test_transparent_cipher_setup( MBEDTLS_DECRYPT,
289 operation,
290 attributes,
291 key,
292 key_length,
293 alg ) );
Steven Cooreman37941cb2020-07-28 18:49:51 +0200294}
295
296psa_status_t test_transparent_cipher_abort(
297 test_transparent_cipher_operation_t *operation)
298{
Steven Cooreman8b122252020-09-03 15:30:32 +0200299 if( operation->alg == 0 )
300 return( PSA_SUCCESS );
301 if( operation->alg != PSA_ALG_CTR )
302 return( PSA_ERROR_BAD_STATE );
303
304 mbedtls_cipher_free( &operation->cipher );
305
Steven Cooreman5240e8b2020-09-09 11:51:45 +0200306 /* Wiping the entire struct here, instead of member-by-member. This is useful
307 * for the test suite, since it gives a chance of catching memory corruption
308 * errors should the core not have allocated (enough) memory for our context
309 * struct. */
310 memset( operation, 0, sizeof( *operation ) );
Steven Cooreman37941cb2020-07-28 18:49:51 +0200311
Steven Cooremanacb5a102020-09-08 14:06:57 +0200312 test_driver_cipher_hooks.hits++;
313 return( PSA_SUCCESS );
Steven Cooreman37941cb2020-07-28 18:49:51 +0200314}
315
316psa_status_t test_transparent_cipher_generate_iv(
317 test_transparent_cipher_operation_t *operation,
318 uint8_t *iv,
319 size_t iv_size,
320 size_t *iv_length)
321{
Steven Cooreman8b122252020-09-03 15:30:32 +0200322 psa_status_t status;
323 mbedtls_test_rnd_pseudo_info rnd_info;
324 memset( &rnd_info, 0x5A, sizeof( mbedtls_test_rnd_pseudo_info ) );
Steven Cooreman37941cb2020-07-28 18:49:51 +0200325
Steven Cooremanacb5a102020-09-08 14:06:57 +0200326 test_driver_cipher_hooks.hits++;
Steven Cooreman8b122252020-09-03 15:30:32 +0200327
328 if( operation->alg != PSA_ALG_CTR )
329 return( PSA_ERROR_BAD_STATE );
330
331 if( operation->iv_set || ! operation->iv_required )
332 return( PSA_ERROR_BAD_STATE );
333
334 if( iv_size < operation->iv_size )
335 return( PSA_ERROR_BUFFER_TOO_SMALL );
336
337 status = mbedtls_to_psa_error(
338 mbedtls_test_rnd_pseudo_rand( &rnd_info,
339 iv,
340 operation->iv_size ) );
341 if( status != PSA_SUCCESS )
Steven Cooremanacb5a102020-09-08 14:06:57 +0200342 return( status );
Steven Cooreman8b122252020-09-03 15:30:32 +0200343
344 *iv_length = operation->iv_size;
345 status = test_transparent_cipher_set_iv( operation, iv, *iv_length );
346
Steven Cooremanacb5a102020-09-08 14:06:57 +0200347 return( status );
Steven Cooreman37941cb2020-07-28 18:49:51 +0200348}
349
350psa_status_t test_transparent_cipher_set_iv(
351 test_transparent_cipher_operation_t *operation,
352 const uint8_t *iv,
353 size_t iv_length)
354{
Steven Cooreman8b122252020-09-03 15:30:32 +0200355 psa_status_t status;
Steven Cooreman37941cb2020-07-28 18:49:51 +0200356
Steven Cooremanacb5a102020-09-08 14:06:57 +0200357 test_driver_cipher_hooks.hits++;
Steven Cooreman8b122252020-09-03 15:30:32 +0200358
359 if( operation->alg != PSA_ALG_CTR )
Steven Cooremanacb5a102020-09-08 14:06:57 +0200360 return( PSA_ERROR_BAD_STATE );
Steven Cooreman8b122252020-09-03 15:30:32 +0200361
362 if( operation->iv_set || ! operation->iv_required )
363 return( PSA_ERROR_BAD_STATE );
364
365 if( iv_length != operation->iv_size )
366 return( PSA_ERROR_INVALID_ARGUMENT );
367
368 status = mbedtls_to_psa_error(
369 mbedtls_cipher_set_iv( &operation->cipher, iv, iv_length ) );
370
371 if( status == PSA_SUCCESS )
372 operation->iv_set = 1;
373
Steven Cooremanacb5a102020-09-08 14:06:57 +0200374 return( status );
Steven Cooreman37941cb2020-07-28 18:49:51 +0200375}
376
377psa_status_t test_transparent_cipher_update(
378 test_transparent_cipher_operation_t *operation,
379 const uint8_t *input,
380 size_t input_length,
381 uint8_t *output,
382 size_t output_size,
383 size_t *output_length)
384{
Steven Cooreman8b122252020-09-03 15:30:32 +0200385 psa_status_t status;
386
Steven Cooremanacb5a102020-09-08 14:06:57 +0200387 test_driver_cipher_hooks.hits++;
Steven Cooreman37941cb2020-07-28 18:49:51 +0200388
Steven Cooreman8b122252020-09-03 15:30:32 +0200389 if( operation->alg != PSA_ALG_CTR )
390 return( PSA_ERROR_BAD_STATE );
Steven Cooreman37941cb2020-07-28 18:49:51 +0200391
Steven Cooreman16afd3d2020-09-09 15:36:39 +0200392 /* CTR is a stream cipher, so data in and out are always the same size */
393 if( output_size < input_length )
Steven Cooreman8b122252020-09-03 15:30:32 +0200394 return( PSA_ERROR_BUFFER_TOO_SMALL );
395
396 status = mbedtls_to_psa_error(
397 mbedtls_cipher_update( &operation->cipher, input,
398 input_length, output, output_length ) );
399
400 if( status != PSA_SUCCESS )
401 return status;
402
Steven Cooremanacb5a102020-09-08 14:06:57 +0200403 if( test_driver_cipher_hooks.forced_output != NULL )
Steven Cooreman8b122252020-09-03 15:30:32 +0200404 {
Steven Cooremanacb5a102020-09-08 14:06:57 +0200405 if( output_size < test_driver_cipher_hooks.forced_output_length )
Steven Cooreman8b122252020-09-03 15:30:32 +0200406 return PSA_ERROR_BUFFER_TOO_SMALL;
407
Steven Cooremanacb5a102020-09-08 14:06:57 +0200408 memcpy( output,
409 test_driver_cipher_hooks.forced_output,
410 test_driver_cipher_hooks.forced_output_length );
411 *output_length = test_driver_cipher_hooks.forced_output_length;
Steven Cooreman8b122252020-09-03 15:30:32 +0200412 }
Steven Cooreman37941cb2020-07-28 18:49:51 +0200413
Steven Cooremanacb5a102020-09-08 14:06:57 +0200414 return( test_driver_cipher_hooks.forced_status );
Steven Cooreman37941cb2020-07-28 18:49:51 +0200415}
416
417psa_status_t test_transparent_cipher_finish(
418 test_transparent_cipher_operation_t *operation,
419 uint8_t *output,
420 size_t output_size,
421 size_t *output_length)
422{
Steven Cooreman8b122252020-09-03 15:30:32 +0200423 psa_status_t status = PSA_ERROR_GENERIC_ERROR;
424 uint8_t temp_output_buffer[MBEDTLS_MAX_BLOCK_LENGTH];
425
Steven Cooremanacb5a102020-09-08 14:06:57 +0200426 test_driver_cipher_hooks.hits++;
Steven Cooreman37941cb2020-07-28 18:49:51 +0200427
Steven Cooreman8b122252020-09-03 15:30:32 +0200428 if( operation->alg != PSA_ALG_CTR )
429 return( PSA_ERROR_BAD_STATE );
Steven Cooreman37941cb2020-07-28 18:49:51 +0200430
Steven Cooreman8b122252020-09-03 15:30:32 +0200431 if( ! operation->key_set )
432 return( PSA_ERROR_BAD_STATE );
433
434 if( operation->iv_required && ! operation->iv_set )
435 return( PSA_ERROR_BAD_STATE );
436
437 status = mbedtls_to_psa_error(
438 mbedtls_cipher_finish( &operation->cipher,
439 temp_output_buffer,
440 output_length ) );
441
442 mbedtls_cipher_free( &operation->cipher );
443
444 if( status != PSA_SUCCESS )
445 return( status );
446
447 if( *output_length == 0 )
448 ; /* Nothing to copy. Note that output may be NULL in this case. */
449 else if( output_size >= *output_length )
450 memcpy( output, temp_output_buffer, *output_length );
451 else
452 return( PSA_ERROR_BUFFER_TOO_SMALL );
453
454
Steven Cooremanacb5a102020-09-08 14:06:57 +0200455 if( test_driver_cipher_hooks.forced_output != NULL )
Steven Cooreman8b122252020-09-03 15:30:32 +0200456 {
Steven Cooremanacb5a102020-09-08 14:06:57 +0200457 if( output_size < test_driver_cipher_hooks.forced_output_length )
Steven Cooreman8b122252020-09-03 15:30:32 +0200458 return PSA_ERROR_BUFFER_TOO_SMALL;
459
Steven Cooremanacb5a102020-09-08 14:06:57 +0200460 memcpy( output,
461 test_driver_cipher_hooks.forced_output,
462 test_driver_cipher_hooks.forced_output_length );
463 *output_length = test_driver_cipher_hooks.forced_output_length;
Steven Cooreman8b122252020-09-03 15:30:32 +0200464 }
Steven Cooreman37941cb2020-07-28 18:49:51 +0200465
Steven Cooremanacb5a102020-09-08 14:06:57 +0200466 return( test_driver_cipher_hooks.forced_status );
Steven Cooreman37941cb2020-07-28 18:49:51 +0200467}
468
469/*
470 * opaque versions, to do
471 */
472psa_status_t test_opaque_cipher_encrypt(
473 const psa_key_attributes_t *attributes,
474 const uint8_t *key, size_t key_length,
475 psa_algorithm_t alg,
476 const uint8_t *input, size_t input_length,
477 uint8_t *output, size_t output_size, size_t *output_length)
478{
479 (void) attributes;
480 (void) key;
481 (void) key_length;
482 (void) alg;
483 (void) input;
484 (void) input_length;
485 (void) output;
486 (void) output_size;
487 (void) output_length;
Steven Cooremanacb5a102020-09-08 14:06:57 +0200488 return( PSA_ERROR_NOT_SUPPORTED );
Steven Cooreman37941cb2020-07-28 18:49:51 +0200489}
490
491psa_status_t test_opaque_cipher_decrypt(
492 const psa_key_attributes_t *attributes,
493 const uint8_t *key, size_t key_length,
494 psa_algorithm_t alg,
495 const uint8_t *input, size_t input_length,
496 uint8_t *output, size_t output_size, size_t *output_length)
497{
498 (void) attributes;
499 (void) key;
500 (void) key_length;
501 (void) alg;
502 (void) input;
503 (void) input_length;
504 (void) output;
505 (void) output_size;
506 (void) output_length;
Steven Cooremanacb5a102020-09-08 14:06:57 +0200507 return( PSA_ERROR_NOT_SUPPORTED );
Steven Cooreman37941cb2020-07-28 18:49:51 +0200508}
509
510psa_status_t test_opaque_cipher_encrypt_setup(
511 test_opaque_cipher_operation_t *operation,
512 const psa_key_attributes_t *attributes,
513 const uint8_t *key, size_t key_length,
514 psa_algorithm_t alg)
515{
516 (void) operation;
517 (void) attributes;
518 (void) key;
519 (void) key_length;
520 (void) alg;
Steven Cooremanacb5a102020-09-08 14:06:57 +0200521 return( PSA_ERROR_NOT_SUPPORTED );
Steven Cooreman37941cb2020-07-28 18:49:51 +0200522}
523
524psa_status_t test_opaque_cipher_decrypt_setup(
525 test_opaque_cipher_operation_t *operation,
526 const psa_key_attributes_t *attributes,
527 const uint8_t *key, size_t key_length,
528 psa_algorithm_t alg)
529{
530 (void) operation;
531 (void) attributes;
532 (void) key;
533 (void) key_length;
534 (void) alg;
Steven Cooremanacb5a102020-09-08 14:06:57 +0200535 return( PSA_ERROR_NOT_SUPPORTED );
Steven Cooreman37941cb2020-07-28 18:49:51 +0200536}
537
538psa_status_t test_opaque_cipher_abort(
539 test_opaque_cipher_operation_t *operation)
540{
541 (void) operation;
Steven Cooremanacb5a102020-09-08 14:06:57 +0200542 return( PSA_ERROR_NOT_SUPPORTED );
Steven Cooreman37941cb2020-07-28 18:49:51 +0200543}
544
545psa_status_t test_opaque_cipher_generate_iv(
546 test_opaque_cipher_operation_t *operation,
547 uint8_t *iv,
548 size_t iv_size,
549 size_t *iv_length)
550{
551 (void) operation;
552 (void) iv;
553 (void) iv_size;
554 (void) iv_length;
Steven Cooremanacb5a102020-09-08 14:06:57 +0200555 return( PSA_ERROR_NOT_SUPPORTED );
Steven Cooreman37941cb2020-07-28 18:49:51 +0200556}
557
558psa_status_t test_opaque_cipher_set_iv(
559 test_opaque_cipher_operation_t *operation,
560 const uint8_t *iv,
561 size_t iv_length)
562{
563 (void) operation;
564 (void) iv;
565 (void) iv_length;
Steven Cooremanacb5a102020-09-08 14:06:57 +0200566 return( PSA_ERROR_NOT_SUPPORTED );
Steven Cooreman37941cb2020-07-28 18:49:51 +0200567}
568
569psa_status_t test_opaque_cipher_update(
570 test_opaque_cipher_operation_t *operation,
571 const uint8_t *input,
572 size_t input_length,
573 uint8_t *output,
574 size_t output_size,
575 size_t *output_length)
576{
577 (void) operation;
578 (void) input;
579 (void) input_length;
580 (void) output;
581 (void) output_size;
582 (void) output_length;
Steven Cooremanacb5a102020-09-08 14:06:57 +0200583 return( PSA_ERROR_NOT_SUPPORTED );
Steven Cooreman37941cb2020-07-28 18:49:51 +0200584}
585
586psa_status_t test_opaque_cipher_finish(
587 test_opaque_cipher_operation_t *operation,
588 uint8_t *output,
589 size_t output_size,
590 size_t *output_length)
591{
592 (void) operation;
593 (void) output;
594 (void) output_size;
595 (void) output_length;
Steven Cooremanacb5a102020-09-08 14:06:57 +0200596 return( PSA_ERROR_NOT_SUPPORTED );
Steven Cooreman37941cb2020-07-28 18:49:51 +0200597}
598#endif /* MBEDTLS_PSA_CRYPTO_DRIVERS && PSA_CRYPTO_DRIVER_TEST */