blob: 0a4a347dd307498b6c05c4d42fe1e19b3bc20fdd [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 Cooreman8b122252020-09-03 15:30:32 +020038/* Test driver implements AES-CTR by default when it's status is not overridden.
Steven Cooremanacb5a102020-09-08 14:06:57 +020039 * Set test_driver_cipher_hooks.forced_status to PSA_ERROR_NOT_SUPPORTED to use
40 * fallback even for AES-CTR.
41 * Keep in mind this code is only exercised with the crypto drivers test target,
42 * meaning the other test runs will only test the non-driver implementation. */
43test_driver_cipher_hooks_t test_driver_cipher_hooks = TEST_DRIVER_CIPHER_INIT;
Steven Cooreman37941cb2020-07-28 18:49:51 +020044
45psa_status_t test_transparent_cipher_encrypt(
46 const psa_key_attributes_t *attributes,
47 const uint8_t *key, size_t key_length,
48 psa_algorithm_t alg,
49 const uint8_t *input, size_t input_length,
50 uint8_t *output, size_t output_size, size_t *output_length)
51{
52 (void) attributes;
53 (void) key;
54 (void) key_length;
55 (void) alg;
56 (void) input;
57 (void) input_length;
Steven Cooremanacb5a102020-09-08 14:06:57 +020058 test_driver_cipher_hooks.hits++;
Steven Cooreman37941cb2020-07-28 18:49:51 +020059
Steven Cooremanacb5a102020-09-08 14:06:57 +020060 if( test_driver_cipher_hooks.forced_status != PSA_SUCCESS )
61 return( test_driver_cipher_hooks.forced_status );
62 if( output_size < test_driver_cipher_hooks.forced_output_length )
63 return( PSA_ERROR_BUFFER_TOO_SMALL );
Steven Cooreman37941cb2020-07-28 18:49:51 +020064
Steven Cooremanacb5a102020-09-08 14:06:57 +020065 memcpy( output,
66 test_driver_cipher_hooks.forced_output,
67 test_driver_cipher_hooks.forced_output_length );
68 *output_length = test_driver_cipher_hooks.forced_output_length;
Steven Cooreman37941cb2020-07-28 18:49:51 +020069
Steven Cooremanacb5a102020-09-08 14:06:57 +020070 return( test_driver_cipher_hooks.forced_status );
Steven Cooreman37941cb2020-07-28 18:49:51 +020071}
72
73psa_status_t test_transparent_cipher_decrypt(
74 const psa_key_attributes_t *attributes,
75 const uint8_t *key, size_t key_length,
76 psa_algorithm_t alg,
77 const uint8_t *input, size_t input_length,
78 uint8_t *output, size_t output_size, size_t *output_length)
79{
80 (void) attributes;
81 (void) key;
82 (void) key_length;
83 (void) alg;
84 (void) input;
85 (void) input_length;
Steven Cooremanacb5a102020-09-08 14:06:57 +020086 test_driver_cipher_hooks.hits++;
Steven Cooreman37941cb2020-07-28 18:49:51 +020087
Steven Cooremanacb5a102020-09-08 14:06:57 +020088 if( test_driver_cipher_hooks.forced_status != PSA_SUCCESS )
89 return( test_driver_cipher_hooks.forced_status );
90 if( output_size < test_driver_cipher_hooks.forced_output_length )
91 return( PSA_ERROR_BUFFER_TOO_SMALL );
Steven Cooreman37941cb2020-07-28 18:49:51 +020092
Steven Cooremanacb5a102020-09-08 14:06:57 +020093 memcpy( output,
94 test_driver_cipher_hooks.forced_output,
95 test_driver_cipher_hooks.forced_output_length );
96 *output_length = test_driver_cipher_hooks.forced_output_length;
Steven Cooreman37941cb2020-07-28 18:49:51 +020097
Steven Cooremanacb5a102020-09-08 14:06:57 +020098 return( test_driver_cipher_hooks.forced_status );
Steven Cooreman37941cb2020-07-28 18:49:51 +020099}
100
101psa_status_t test_transparent_cipher_encrypt_setup(
102 test_transparent_cipher_operation_t *operation,
103 const psa_key_attributes_t *attributes,
104 const uint8_t *key, size_t key_length,
105 psa_algorithm_t alg)
106{
Steven Cooreman8b122252020-09-03 15:30:32 +0200107 const mbedtls_cipher_info_t *cipher_info = NULL;
108 int ret = 0;
Steven Cooreman37941cb2020-07-28 18:49:51 +0200109
Steven Cooremanacb5a102020-09-08 14:06:57 +0200110 test_driver_cipher_hooks.hits++;
Steven Cooreman8b122252020-09-03 15:30:32 +0200111
112 if( operation->alg != 0 )
Steven Cooremanacb5a102020-09-08 14:06:57 +0200113 return( PSA_ERROR_BAD_STATE );
Steven Cooreman8b122252020-09-03 15:30:32 +0200114
115 /* write our struct, this will trigger memory corruption failures
116 * in test when we go outside of bounds, or when the function is called
117 * without first destroying the context object. */
Steven Cooremanacb5a102020-09-08 14:06:57 +0200118 memset( operation, 0, sizeof( test_transparent_cipher_operation_t ) );
Steven Cooreman8b122252020-09-03 15:30:32 +0200119
120 /* Test driver supports AES-CTR only, to verify operation calls. */
Steven Cooremanacb5a102020-09-08 14:06:57 +0200121 if( alg != PSA_ALG_CTR ||
122 psa_get_key_type( attributes ) != PSA_KEY_TYPE_AES )
123 return( PSA_ERROR_NOT_SUPPORTED );
Steven Cooreman8b122252020-09-03 15:30:32 +0200124
125 operation->alg = alg;
126 operation->iv_size = 16;
127 operation->block_size = 16;
128
129 cipher_info = mbedtls_cipher_info_from_values( MBEDTLS_CIPHER_ID_AES,
130 key_length * 8,
131 MBEDTLS_MODE_CTR );
132 if( cipher_info == NULL )
Steven Cooremanacb5a102020-09-08 14:06:57 +0200133 return( PSA_ERROR_NOT_SUPPORTED );
Steven Cooreman8b122252020-09-03 15:30:32 +0200134
135 mbedtls_cipher_init( &operation->cipher );
136
137 ret = mbedtls_cipher_setup( &operation->cipher, cipher_info );
138 if( ret != 0 ) {
139 mbedtls_cipher_free( &operation->cipher );
Steven Cooremanacb5a102020-09-08 14:06:57 +0200140 return( mbedtls_to_psa_error( ret ) );
Steven Cooreman8b122252020-09-03 15:30:32 +0200141 }
142
143 ret = mbedtls_cipher_setkey( &operation->cipher,
144 key,
145 key_length * 8, MBEDTLS_ENCRYPT );
146 if( ret != 0 ) {
147 mbedtls_cipher_free( &operation->cipher );
Steven Cooremanacb5a102020-09-08 14:06:57 +0200148 return( mbedtls_to_psa_error( ret ) );
Steven Cooreman8b122252020-09-03 15:30:32 +0200149 }
150
151 operation->iv_set = 0;
152 operation->iv_required = 1;
153 operation->key_set = 1;
154
155 /* Allow overriding return value for testing purposes */
Steven Cooremanacb5a102020-09-08 14:06:57 +0200156 if( test_driver_cipher_hooks.forced_status != PSA_SUCCESS )
Steven Cooreman8b122252020-09-03 15:30:32 +0200157 mbedtls_cipher_free( &operation->cipher );
158
Steven Cooremanacb5a102020-09-08 14:06:57 +0200159 return( test_driver_cipher_hooks.forced_status );
Steven Cooreman37941cb2020-07-28 18:49:51 +0200160}
161
162psa_status_t test_transparent_cipher_decrypt_setup(
163 test_transparent_cipher_operation_t *operation,
164 const psa_key_attributes_t *attributes,
165 const uint8_t *key, size_t key_length,
166 psa_algorithm_t alg)
167{
Steven Cooremanacb5a102020-09-08 14:06:57 +0200168 const mbedtls_cipher_info_t *cipher_info = NULL;
Steven Cooreman8b122252020-09-03 15:30:32 +0200169 int ret = 0;
Steven Cooreman37941cb2020-07-28 18:49:51 +0200170
Steven Cooremanacb5a102020-09-08 14:06:57 +0200171 test_driver_cipher_hooks.hits++;
Steven Cooreman8b122252020-09-03 15:30:32 +0200172
173 if( operation->alg != 0 )
Steven Cooremanacb5a102020-09-08 14:06:57 +0200174 return( PSA_ERROR_BAD_STATE );
Steven Cooreman8b122252020-09-03 15:30:32 +0200175
176 /* write our struct, this will trigger memory corruption failures
177 * in test when we go outside of bounds, or when the function is called
178 * without first destroying the context object. */
Steven Cooremanacb5a102020-09-08 14:06:57 +0200179 memset( operation, 0, sizeof( test_transparent_cipher_operation_t ) );
Steven Cooreman8b122252020-09-03 15:30:32 +0200180
181 /* Test driver supports AES-CTR only, to verify operation calls. */
182 if( alg != PSA_ALG_CTR || psa_get_key_type( attributes ) != PSA_KEY_TYPE_AES )
183 return PSA_ERROR_NOT_SUPPORTED;
184
185 operation->alg = alg;
186 operation->iv_size = 16;
187 operation->block_size = 16;
188
189 mbedtls_cipher_init( &operation->cipher );
190
191 cipher_info = mbedtls_cipher_info_from_values( MBEDTLS_CIPHER_ID_AES,
192 key_length * 8,
193 MBEDTLS_MODE_CTR );
194 if( cipher_info == NULL )
195 return PSA_ERROR_NOT_SUPPORTED;
196
197 ret = mbedtls_cipher_setup( &operation->cipher, cipher_info );
198 if( ret != 0 )
Steven Cooremanacb5a102020-09-08 14:06:57 +0200199 return( mbedtls_to_psa_error( ret ) );
Steven Cooreman8b122252020-09-03 15:30:32 +0200200
201 ret = mbedtls_cipher_setkey( &operation->cipher,
202 key,
203 key_length * 8, MBEDTLS_DECRYPT );
204 if( ret != 0 )
Steven Cooremanacb5a102020-09-08 14:06:57 +0200205 return( mbedtls_to_psa_error( ret ) );
Steven Cooreman8b122252020-09-03 15:30:32 +0200206
207 operation->iv_set = 0;
208 operation->iv_required = 1;
209 operation->key_set = 1;
210
211 /* Allow overriding return value for testing purposes */
Steven Cooremanacb5a102020-09-08 14:06:57 +0200212 if( test_driver_cipher_hooks.forced_status != PSA_SUCCESS )
Steven Cooreman8b122252020-09-03 15:30:32 +0200213 mbedtls_cipher_free( &operation->cipher );
214
Steven Cooremanacb5a102020-09-08 14:06:57 +0200215 return( test_driver_cipher_hooks.forced_status );
Steven Cooreman37941cb2020-07-28 18:49:51 +0200216}
217
218psa_status_t test_transparent_cipher_abort(
219 test_transparent_cipher_operation_t *operation)
220{
Steven Cooreman8b122252020-09-03 15:30:32 +0200221 if( operation->alg == 0 )
222 return( PSA_SUCCESS );
223 if( operation->alg != PSA_ALG_CTR )
224 return( PSA_ERROR_BAD_STATE );
225
226 mbedtls_cipher_free( &operation->cipher );
227
Steven Cooreman37941cb2020-07-28 18:49:51 +0200228 /* write our struct, this will trigger memory corruption failures
229 * in test when we go outside of bounds. */
Steven Cooremanacb5a102020-09-08 14:06:57 +0200230 memset( operation, 0, sizeof( test_transparent_cipher_operation_t ) );
Steven Cooreman37941cb2020-07-28 18:49:51 +0200231
Steven Cooremanacb5a102020-09-08 14:06:57 +0200232 test_driver_cipher_hooks.hits++;
233 return( PSA_SUCCESS );
Steven Cooreman37941cb2020-07-28 18:49:51 +0200234}
235
236psa_status_t test_transparent_cipher_generate_iv(
237 test_transparent_cipher_operation_t *operation,
238 uint8_t *iv,
239 size_t iv_size,
240 size_t *iv_length)
241{
Steven Cooreman8b122252020-09-03 15:30:32 +0200242 psa_status_t status;
243 mbedtls_test_rnd_pseudo_info rnd_info;
244 memset( &rnd_info, 0x5A, sizeof( mbedtls_test_rnd_pseudo_info ) );
Steven Cooreman37941cb2020-07-28 18:49:51 +0200245
Steven Cooremanacb5a102020-09-08 14:06:57 +0200246 test_driver_cipher_hooks.hits++;
Steven Cooreman8b122252020-09-03 15:30:32 +0200247
248 if( operation->alg != PSA_ALG_CTR )
249 return( PSA_ERROR_BAD_STATE );
250
251 if( operation->iv_set || ! operation->iv_required )
252 return( PSA_ERROR_BAD_STATE );
253
254 if( iv_size < operation->iv_size )
255 return( PSA_ERROR_BUFFER_TOO_SMALL );
256
257 status = mbedtls_to_psa_error(
258 mbedtls_test_rnd_pseudo_rand( &rnd_info,
259 iv,
260 operation->iv_size ) );
261 if( status != PSA_SUCCESS )
Steven Cooremanacb5a102020-09-08 14:06:57 +0200262 return( status );
Steven Cooreman8b122252020-09-03 15:30:32 +0200263
264 *iv_length = operation->iv_size;
265 status = test_transparent_cipher_set_iv( operation, iv, *iv_length );
266
Steven Cooremanacb5a102020-09-08 14:06:57 +0200267 return( status );
Steven Cooreman37941cb2020-07-28 18:49:51 +0200268}
269
270psa_status_t test_transparent_cipher_set_iv(
271 test_transparent_cipher_operation_t *operation,
272 const uint8_t *iv,
273 size_t iv_length)
274{
Steven Cooreman8b122252020-09-03 15:30:32 +0200275 psa_status_t status;
Steven Cooreman37941cb2020-07-28 18:49:51 +0200276
Steven Cooremanacb5a102020-09-08 14:06:57 +0200277 test_driver_cipher_hooks.hits++;
Steven Cooreman8b122252020-09-03 15:30:32 +0200278
279 if( operation->alg != PSA_ALG_CTR )
Steven Cooremanacb5a102020-09-08 14:06:57 +0200280 return( PSA_ERROR_BAD_STATE );
Steven Cooreman8b122252020-09-03 15:30:32 +0200281
282 if( operation->iv_set || ! operation->iv_required )
283 return( PSA_ERROR_BAD_STATE );
284
285 if( iv_length != operation->iv_size )
286 return( PSA_ERROR_INVALID_ARGUMENT );
287
288 status = mbedtls_to_psa_error(
289 mbedtls_cipher_set_iv( &operation->cipher, iv, iv_length ) );
290
291 if( status == PSA_SUCCESS )
292 operation->iv_set = 1;
293
Steven Cooremanacb5a102020-09-08 14:06:57 +0200294 return( status );
Steven Cooreman37941cb2020-07-28 18:49:51 +0200295}
296
297psa_status_t test_transparent_cipher_update(
298 test_transparent_cipher_operation_t *operation,
299 const uint8_t *input,
300 size_t input_length,
301 uint8_t *output,
302 size_t output_size,
303 size_t *output_length)
304{
Steven Cooreman8b122252020-09-03 15:30:32 +0200305 size_t expected_output_size;
306 psa_status_t status;
307
Steven Cooremanacb5a102020-09-08 14:06:57 +0200308 test_driver_cipher_hooks.hits++;
Steven Cooreman37941cb2020-07-28 18:49:51 +0200309
Steven Cooreman8b122252020-09-03 15:30:32 +0200310 if( operation->alg != PSA_ALG_CTR )
311 return( PSA_ERROR_BAD_STATE );
Steven Cooreman37941cb2020-07-28 18:49:51 +0200312
Steven Cooreman8b122252020-09-03 15:30:32 +0200313 expected_output_size = ( operation->cipher.unprocessed_len + input_length )
314 / operation->block_size * operation->block_size;
315
316 if( output_size < expected_output_size )
317 return( PSA_ERROR_BUFFER_TOO_SMALL );
318
319 status = mbedtls_to_psa_error(
320 mbedtls_cipher_update( &operation->cipher, input,
321 input_length, output, output_length ) );
322
323 if( status != PSA_SUCCESS )
324 return status;
325
Steven Cooremanacb5a102020-09-08 14:06:57 +0200326 if( test_driver_cipher_hooks.forced_output != NULL )
Steven Cooreman8b122252020-09-03 15:30:32 +0200327 {
Steven Cooremanacb5a102020-09-08 14:06:57 +0200328 if( output_size < test_driver_cipher_hooks.forced_output_length )
Steven Cooreman8b122252020-09-03 15:30:32 +0200329 return PSA_ERROR_BUFFER_TOO_SMALL;
330
Steven Cooremanacb5a102020-09-08 14:06:57 +0200331 memcpy( output,
332 test_driver_cipher_hooks.forced_output,
333 test_driver_cipher_hooks.forced_output_length );
334 *output_length = test_driver_cipher_hooks.forced_output_length;
Steven Cooreman8b122252020-09-03 15:30:32 +0200335 }
Steven Cooreman37941cb2020-07-28 18:49:51 +0200336
Steven Cooremanacb5a102020-09-08 14:06:57 +0200337 return( test_driver_cipher_hooks.forced_status );
Steven Cooreman37941cb2020-07-28 18:49:51 +0200338}
339
340psa_status_t test_transparent_cipher_finish(
341 test_transparent_cipher_operation_t *operation,
342 uint8_t *output,
343 size_t output_size,
344 size_t *output_length)
345{
Steven Cooreman8b122252020-09-03 15:30:32 +0200346 psa_status_t status = PSA_ERROR_GENERIC_ERROR;
347 uint8_t temp_output_buffer[MBEDTLS_MAX_BLOCK_LENGTH];
348
Steven Cooremanacb5a102020-09-08 14:06:57 +0200349 test_driver_cipher_hooks.hits++;
Steven Cooreman37941cb2020-07-28 18:49:51 +0200350
Steven Cooreman8b122252020-09-03 15:30:32 +0200351 if( operation->alg != PSA_ALG_CTR )
352 return( PSA_ERROR_BAD_STATE );
Steven Cooreman37941cb2020-07-28 18:49:51 +0200353
Steven Cooreman8b122252020-09-03 15:30:32 +0200354 if( ! operation->key_set )
355 return( PSA_ERROR_BAD_STATE );
356
357 if( operation->iv_required && ! operation->iv_set )
358 return( PSA_ERROR_BAD_STATE );
359
360 status = mbedtls_to_psa_error(
361 mbedtls_cipher_finish( &operation->cipher,
362 temp_output_buffer,
363 output_length ) );
364
365 mbedtls_cipher_free( &operation->cipher );
366
367 if( status != PSA_SUCCESS )
368 return( status );
369
370 if( *output_length == 0 )
371 ; /* Nothing to copy. Note that output may be NULL in this case. */
372 else if( output_size >= *output_length )
373 memcpy( output, temp_output_buffer, *output_length );
374 else
375 return( PSA_ERROR_BUFFER_TOO_SMALL );
376
377
Steven Cooremanacb5a102020-09-08 14:06:57 +0200378 if( test_driver_cipher_hooks.forced_output != NULL )
Steven Cooreman8b122252020-09-03 15:30:32 +0200379 {
Steven Cooremanacb5a102020-09-08 14:06:57 +0200380 if( output_size < test_driver_cipher_hooks.forced_output_length )
Steven Cooreman8b122252020-09-03 15:30:32 +0200381 return PSA_ERROR_BUFFER_TOO_SMALL;
382
Steven Cooremanacb5a102020-09-08 14:06:57 +0200383 memcpy( output,
384 test_driver_cipher_hooks.forced_output,
385 test_driver_cipher_hooks.forced_output_length );
386 *output_length = test_driver_cipher_hooks.forced_output_length;
Steven Cooreman8b122252020-09-03 15:30:32 +0200387 }
Steven Cooreman37941cb2020-07-28 18:49:51 +0200388
Steven Cooremanacb5a102020-09-08 14:06:57 +0200389 return( test_driver_cipher_hooks.forced_status );
Steven Cooreman37941cb2020-07-28 18:49:51 +0200390}
391
392/*
393 * opaque versions, to do
394 */
395psa_status_t test_opaque_cipher_encrypt(
396 const psa_key_attributes_t *attributes,
397 const uint8_t *key, size_t key_length,
398 psa_algorithm_t alg,
399 const uint8_t *input, size_t input_length,
400 uint8_t *output, size_t output_size, size_t *output_length)
401{
402 (void) attributes;
403 (void) key;
404 (void) key_length;
405 (void) alg;
406 (void) input;
407 (void) input_length;
408 (void) output;
409 (void) output_size;
410 (void) output_length;
Steven Cooremanacb5a102020-09-08 14:06:57 +0200411 return( PSA_ERROR_NOT_SUPPORTED );
Steven Cooreman37941cb2020-07-28 18:49:51 +0200412}
413
414psa_status_t test_opaque_cipher_decrypt(
415 const psa_key_attributes_t *attributes,
416 const uint8_t *key, size_t key_length,
417 psa_algorithm_t alg,
418 const uint8_t *input, size_t input_length,
419 uint8_t *output, size_t output_size, size_t *output_length)
420{
421 (void) attributes;
422 (void) key;
423 (void) key_length;
424 (void) alg;
425 (void) input;
426 (void) input_length;
427 (void) output;
428 (void) output_size;
429 (void) output_length;
Steven Cooremanacb5a102020-09-08 14:06:57 +0200430 return( PSA_ERROR_NOT_SUPPORTED );
Steven Cooreman37941cb2020-07-28 18:49:51 +0200431}
432
433psa_status_t test_opaque_cipher_encrypt_setup(
434 test_opaque_cipher_operation_t *operation,
435 const psa_key_attributes_t *attributes,
436 const uint8_t *key, size_t key_length,
437 psa_algorithm_t alg)
438{
439 (void) operation;
440 (void) attributes;
441 (void) key;
442 (void) key_length;
443 (void) alg;
Steven Cooremanacb5a102020-09-08 14:06:57 +0200444 return( PSA_ERROR_NOT_SUPPORTED );
Steven Cooreman37941cb2020-07-28 18:49:51 +0200445}
446
447psa_status_t test_opaque_cipher_decrypt_setup(
448 test_opaque_cipher_operation_t *operation,
449 const psa_key_attributes_t *attributes,
450 const uint8_t *key, size_t key_length,
451 psa_algorithm_t alg)
452{
453 (void) operation;
454 (void) attributes;
455 (void) key;
456 (void) key_length;
457 (void) alg;
Steven Cooremanacb5a102020-09-08 14:06:57 +0200458 return( PSA_ERROR_NOT_SUPPORTED );
Steven Cooreman37941cb2020-07-28 18:49:51 +0200459}
460
461psa_status_t test_opaque_cipher_abort(
462 test_opaque_cipher_operation_t *operation)
463{
464 (void) operation;
Steven Cooremanacb5a102020-09-08 14:06:57 +0200465 return( PSA_ERROR_NOT_SUPPORTED );
Steven Cooreman37941cb2020-07-28 18:49:51 +0200466}
467
468psa_status_t test_opaque_cipher_generate_iv(
469 test_opaque_cipher_operation_t *operation,
470 uint8_t *iv,
471 size_t iv_size,
472 size_t *iv_length)
473{
474 (void) operation;
475 (void) iv;
476 (void) iv_size;
477 (void) iv_length;
Steven Cooremanacb5a102020-09-08 14:06:57 +0200478 return( PSA_ERROR_NOT_SUPPORTED );
Steven Cooreman37941cb2020-07-28 18:49:51 +0200479}
480
481psa_status_t test_opaque_cipher_set_iv(
482 test_opaque_cipher_operation_t *operation,
483 const uint8_t *iv,
484 size_t iv_length)
485{
486 (void) operation;
487 (void) iv;
488 (void) iv_length;
Steven Cooremanacb5a102020-09-08 14:06:57 +0200489 return( PSA_ERROR_NOT_SUPPORTED );
Steven Cooreman37941cb2020-07-28 18:49:51 +0200490}
491
492psa_status_t test_opaque_cipher_update(
493 test_opaque_cipher_operation_t *operation,
494 const uint8_t *input,
495 size_t input_length,
496 uint8_t *output,
497 size_t output_size,
498 size_t *output_length)
499{
500 (void) operation;
501 (void) input;
502 (void) input_length;
503 (void) output;
504 (void) output_size;
505 (void) output_length;
Steven Cooremanacb5a102020-09-08 14:06:57 +0200506 return( PSA_ERROR_NOT_SUPPORTED );
Steven Cooreman37941cb2020-07-28 18:49:51 +0200507}
508
509psa_status_t test_opaque_cipher_finish(
510 test_opaque_cipher_operation_t *operation,
511 uint8_t *output,
512 size_t output_size,
513 size_t *output_length)
514{
515 (void) operation;
516 (void) output;
517 (void) output_size;
518 (void) output_length;
Steven Cooremanacb5a102020-09-08 14:06:57 +0200519 return( PSA_ERROR_NOT_SUPPORTED );
Steven Cooreman37941cb2020-07-28 18:49:51 +0200520}
521#endif /* MBEDTLS_PSA_CRYPTO_DRIVERS && PSA_CRYPTO_DRIVER_TEST */