blob: c8eb1d3505fcada893705a3723f69fd0f123df4b [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
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
Steven Cooreman5240e8b2020-09-09 11:51:45 +0200115 /* Wiping the entire struct here, instead of member-by-member. This is useful
116 * for the test suite, since it gives a chance of catching memory corruption
117 * errors should the core not have allocated (enough) memory for our context
118 * struct. */
119 memset( operation, 0, sizeof( *operation ) );
Steven Cooreman8b122252020-09-03 15:30:32 +0200120
121 /* Test driver supports AES-CTR only, to verify operation calls. */
Steven Cooremanacb5a102020-09-08 14:06:57 +0200122 if( alg != PSA_ALG_CTR ||
123 psa_get_key_type( attributes ) != PSA_KEY_TYPE_AES )
124 return( PSA_ERROR_NOT_SUPPORTED );
Steven Cooreman8b122252020-09-03 15:30:32 +0200125
126 operation->alg = alg;
127 operation->iv_size = 16;
128 operation->block_size = 16;
129
130 cipher_info = mbedtls_cipher_info_from_values( MBEDTLS_CIPHER_ID_AES,
131 key_length * 8,
132 MBEDTLS_MODE_CTR );
133 if( cipher_info == NULL )
Steven Cooremanacb5a102020-09-08 14:06:57 +0200134 return( PSA_ERROR_NOT_SUPPORTED );
Steven Cooreman8b122252020-09-03 15:30:32 +0200135
136 mbedtls_cipher_init( &operation->cipher );
137
138 ret = mbedtls_cipher_setup( &operation->cipher, cipher_info );
139 if( ret != 0 ) {
140 mbedtls_cipher_free( &operation->cipher );
Steven Cooremanacb5a102020-09-08 14:06:57 +0200141 return( mbedtls_to_psa_error( ret ) );
Steven Cooreman8b122252020-09-03 15:30:32 +0200142 }
143
144 ret = mbedtls_cipher_setkey( &operation->cipher,
145 key,
146 key_length * 8, MBEDTLS_ENCRYPT );
147 if( ret != 0 ) {
148 mbedtls_cipher_free( &operation->cipher );
Steven Cooremanacb5a102020-09-08 14:06:57 +0200149 return( mbedtls_to_psa_error( ret ) );
Steven Cooreman8b122252020-09-03 15:30:32 +0200150 }
151
152 operation->iv_set = 0;
153 operation->iv_required = 1;
154 operation->key_set = 1;
155
156 /* Allow overriding return value for testing purposes */
Steven Cooremanacb5a102020-09-08 14:06:57 +0200157 if( test_driver_cipher_hooks.forced_status != PSA_SUCCESS )
Steven Cooreman8b122252020-09-03 15:30:32 +0200158 mbedtls_cipher_free( &operation->cipher );
159
Steven Cooremanacb5a102020-09-08 14:06:57 +0200160 return( test_driver_cipher_hooks.forced_status );
Steven Cooreman37941cb2020-07-28 18:49:51 +0200161}
162
163psa_status_t test_transparent_cipher_decrypt_setup(
164 test_transparent_cipher_operation_t *operation,
165 const psa_key_attributes_t *attributes,
166 const uint8_t *key, size_t key_length,
167 psa_algorithm_t alg)
168{
Steven Cooremanacb5a102020-09-08 14:06:57 +0200169 const mbedtls_cipher_info_t *cipher_info = NULL;
Steven Cooreman8b122252020-09-03 15:30:32 +0200170 int ret = 0;
Steven Cooreman37941cb2020-07-28 18:49:51 +0200171
Steven Cooremanacb5a102020-09-08 14:06:57 +0200172 test_driver_cipher_hooks.hits++;
Steven Cooreman8b122252020-09-03 15:30:32 +0200173
174 if( operation->alg != 0 )
Steven Cooremanacb5a102020-09-08 14:06:57 +0200175 return( PSA_ERROR_BAD_STATE );
Steven Cooreman8b122252020-09-03 15:30:32 +0200176
Steven Cooreman5240e8b2020-09-09 11:51:45 +0200177 /* Wiping the entire struct here, instead of member-by-member. This is useful
178 * for the test suite, since it gives a chance of catching memory corruption
179 * errors should the core not have allocated (enough) memory for our context
180 * struct. */
181 memset( operation, 0, sizeof( *operation ) );
Steven Cooreman8b122252020-09-03 15:30:32 +0200182
183 /* Test driver supports AES-CTR only, to verify operation calls. */
184 if( alg != PSA_ALG_CTR || psa_get_key_type( attributes ) != PSA_KEY_TYPE_AES )
185 return PSA_ERROR_NOT_SUPPORTED;
186
187 operation->alg = alg;
188 operation->iv_size = 16;
189 operation->block_size = 16;
190
191 mbedtls_cipher_init( &operation->cipher );
192
193 cipher_info = mbedtls_cipher_info_from_values( MBEDTLS_CIPHER_ID_AES,
194 key_length * 8,
195 MBEDTLS_MODE_CTR );
196 if( cipher_info == NULL )
197 return PSA_ERROR_NOT_SUPPORTED;
198
199 ret = mbedtls_cipher_setup( &operation->cipher, cipher_info );
200 if( ret != 0 )
Steven Cooremanacb5a102020-09-08 14:06:57 +0200201 return( mbedtls_to_psa_error( ret ) );
Steven Cooreman8b122252020-09-03 15:30:32 +0200202
203 ret = mbedtls_cipher_setkey( &operation->cipher,
204 key,
205 key_length * 8, MBEDTLS_DECRYPT );
206 if( ret != 0 )
Steven Cooremanacb5a102020-09-08 14:06:57 +0200207 return( mbedtls_to_psa_error( ret ) );
Steven Cooreman8b122252020-09-03 15:30:32 +0200208
209 operation->iv_set = 0;
210 operation->iv_required = 1;
211 operation->key_set = 1;
212
213 /* Allow overriding return value for testing purposes */
Steven Cooremanacb5a102020-09-08 14:06:57 +0200214 if( test_driver_cipher_hooks.forced_status != PSA_SUCCESS )
Steven Cooreman8b122252020-09-03 15:30:32 +0200215 mbedtls_cipher_free( &operation->cipher );
216
Steven Cooremanacb5a102020-09-08 14:06:57 +0200217 return( test_driver_cipher_hooks.forced_status );
Steven Cooreman37941cb2020-07-28 18:49:51 +0200218}
219
220psa_status_t test_transparent_cipher_abort(
221 test_transparent_cipher_operation_t *operation)
222{
Steven Cooreman8b122252020-09-03 15:30:32 +0200223 if( operation->alg == 0 )
224 return( PSA_SUCCESS );
225 if( operation->alg != PSA_ALG_CTR )
226 return( PSA_ERROR_BAD_STATE );
227
228 mbedtls_cipher_free( &operation->cipher );
229
Steven Cooreman5240e8b2020-09-09 11:51:45 +0200230 /* Wiping the entire struct here, instead of member-by-member. This is useful
231 * for the test suite, since it gives a chance of catching memory corruption
232 * errors should the core not have allocated (enough) memory for our context
233 * struct. */
234 memset( operation, 0, sizeof( *operation ) );
Steven Cooreman37941cb2020-07-28 18:49:51 +0200235
Steven Cooremanacb5a102020-09-08 14:06:57 +0200236 test_driver_cipher_hooks.hits++;
237 return( PSA_SUCCESS );
Steven Cooreman37941cb2020-07-28 18:49:51 +0200238}
239
240psa_status_t test_transparent_cipher_generate_iv(
241 test_transparent_cipher_operation_t *operation,
242 uint8_t *iv,
243 size_t iv_size,
244 size_t *iv_length)
245{
Steven Cooreman8b122252020-09-03 15:30:32 +0200246 psa_status_t status;
247 mbedtls_test_rnd_pseudo_info rnd_info;
248 memset( &rnd_info, 0x5A, sizeof( mbedtls_test_rnd_pseudo_info ) );
Steven Cooreman37941cb2020-07-28 18:49:51 +0200249
Steven Cooremanacb5a102020-09-08 14:06:57 +0200250 test_driver_cipher_hooks.hits++;
Steven Cooreman8b122252020-09-03 15:30:32 +0200251
252 if( operation->alg != PSA_ALG_CTR )
253 return( PSA_ERROR_BAD_STATE );
254
255 if( operation->iv_set || ! operation->iv_required )
256 return( PSA_ERROR_BAD_STATE );
257
258 if( iv_size < operation->iv_size )
259 return( PSA_ERROR_BUFFER_TOO_SMALL );
260
261 status = mbedtls_to_psa_error(
262 mbedtls_test_rnd_pseudo_rand( &rnd_info,
263 iv,
264 operation->iv_size ) );
265 if( status != PSA_SUCCESS )
Steven Cooremanacb5a102020-09-08 14:06:57 +0200266 return( status );
Steven Cooreman8b122252020-09-03 15:30:32 +0200267
268 *iv_length = operation->iv_size;
269 status = test_transparent_cipher_set_iv( operation, iv, *iv_length );
270
Steven Cooremanacb5a102020-09-08 14:06:57 +0200271 return( status );
Steven Cooreman37941cb2020-07-28 18:49:51 +0200272}
273
274psa_status_t test_transparent_cipher_set_iv(
275 test_transparent_cipher_operation_t *operation,
276 const uint8_t *iv,
277 size_t iv_length)
278{
Steven Cooreman8b122252020-09-03 15:30:32 +0200279 psa_status_t status;
Steven Cooreman37941cb2020-07-28 18:49:51 +0200280
Steven Cooremanacb5a102020-09-08 14:06:57 +0200281 test_driver_cipher_hooks.hits++;
Steven Cooreman8b122252020-09-03 15:30:32 +0200282
283 if( operation->alg != PSA_ALG_CTR )
Steven Cooremanacb5a102020-09-08 14:06:57 +0200284 return( PSA_ERROR_BAD_STATE );
Steven Cooreman8b122252020-09-03 15:30:32 +0200285
286 if( operation->iv_set || ! operation->iv_required )
287 return( PSA_ERROR_BAD_STATE );
288
289 if( iv_length != operation->iv_size )
290 return( PSA_ERROR_INVALID_ARGUMENT );
291
292 status = mbedtls_to_psa_error(
293 mbedtls_cipher_set_iv( &operation->cipher, iv, iv_length ) );
294
295 if( status == PSA_SUCCESS )
296 operation->iv_set = 1;
297
Steven Cooremanacb5a102020-09-08 14:06:57 +0200298 return( status );
Steven Cooreman37941cb2020-07-28 18:49:51 +0200299}
300
301psa_status_t test_transparent_cipher_update(
302 test_transparent_cipher_operation_t *operation,
303 const uint8_t *input,
304 size_t input_length,
305 uint8_t *output,
306 size_t output_size,
307 size_t *output_length)
308{
Steven Cooreman8b122252020-09-03 15:30:32 +0200309 size_t expected_output_size;
310 psa_status_t status;
311
Steven Cooremanacb5a102020-09-08 14:06:57 +0200312 test_driver_cipher_hooks.hits++;
Steven Cooreman37941cb2020-07-28 18:49:51 +0200313
Steven Cooreman8b122252020-09-03 15:30:32 +0200314 if( operation->alg != PSA_ALG_CTR )
315 return( PSA_ERROR_BAD_STATE );
Steven Cooreman37941cb2020-07-28 18:49:51 +0200316
Steven Cooreman8b122252020-09-03 15:30:32 +0200317 expected_output_size = ( operation->cipher.unprocessed_len + input_length )
318 / operation->block_size * operation->block_size;
319
320 if( output_size < expected_output_size )
321 return( PSA_ERROR_BUFFER_TOO_SMALL );
322
323 status = mbedtls_to_psa_error(
324 mbedtls_cipher_update( &operation->cipher, input,
325 input_length, output, output_length ) );
326
327 if( status != PSA_SUCCESS )
328 return status;
329
Steven Cooremanacb5a102020-09-08 14:06:57 +0200330 if( test_driver_cipher_hooks.forced_output != NULL )
Steven Cooreman8b122252020-09-03 15:30:32 +0200331 {
Steven Cooremanacb5a102020-09-08 14:06:57 +0200332 if( output_size < test_driver_cipher_hooks.forced_output_length )
Steven Cooreman8b122252020-09-03 15:30:32 +0200333 return PSA_ERROR_BUFFER_TOO_SMALL;
334
Steven Cooremanacb5a102020-09-08 14:06:57 +0200335 memcpy( output,
336 test_driver_cipher_hooks.forced_output,
337 test_driver_cipher_hooks.forced_output_length );
338 *output_length = test_driver_cipher_hooks.forced_output_length;
Steven Cooreman8b122252020-09-03 15:30:32 +0200339 }
Steven Cooreman37941cb2020-07-28 18:49:51 +0200340
Steven Cooremanacb5a102020-09-08 14:06:57 +0200341 return( test_driver_cipher_hooks.forced_status );
Steven Cooreman37941cb2020-07-28 18:49:51 +0200342}
343
344psa_status_t test_transparent_cipher_finish(
345 test_transparent_cipher_operation_t *operation,
346 uint8_t *output,
347 size_t output_size,
348 size_t *output_length)
349{
Steven Cooreman8b122252020-09-03 15:30:32 +0200350 psa_status_t status = PSA_ERROR_GENERIC_ERROR;
351 uint8_t temp_output_buffer[MBEDTLS_MAX_BLOCK_LENGTH];
352
Steven Cooremanacb5a102020-09-08 14:06:57 +0200353 test_driver_cipher_hooks.hits++;
Steven Cooreman37941cb2020-07-28 18:49:51 +0200354
Steven Cooreman8b122252020-09-03 15:30:32 +0200355 if( operation->alg != PSA_ALG_CTR )
356 return( PSA_ERROR_BAD_STATE );
Steven Cooreman37941cb2020-07-28 18:49:51 +0200357
Steven Cooreman8b122252020-09-03 15:30:32 +0200358 if( ! operation->key_set )
359 return( PSA_ERROR_BAD_STATE );
360
361 if( operation->iv_required && ! operation->iv_set )
362 return( PSA_ERROR_BAD_STATE );
363
364 status = mbedtls_to_psa_error(
365 mbedtls_cipher_finish( &operation->cipher,
366 temp_output_buffer,
367 output_length ) );
368
369 mbedtls_cipher_free( &operation->cipher );
370
371 if( status != PSA_SUCCESS )
372 return( status );
373
374 if( *output_length == 0 )
375 ; /* Nothing to copy. Note that output may be NULL in this case. */
376 else if( output_size >= *output_length )
377 memcpy( output, temp_output_buffer, *output_length );
378 else
379 return( PSA_ERROR_BUFFER_TOO_SMALL );
380
381
Steven Cooremanacb5a102020-09-08 14:06:57 +0200382 if( test_driver_cipher_hooks.forced_output != NULL )
Steven Cooreman8b122252020-09-03 15:30:32 +0200383 {
Steven Cooremanacb5a102020-09-08 14:06:57 +0200384 if( output_size < test_driver_cipher_hooks.forced_output_length )
Steven Cooreman8b122252020-09-03 15:30:32 +0200385 return PSA_ERROR_BUFFER_TOO_SMALL;
386
Steven Cooremanacb5a102020-09-08 14:06:57 +0200387 memcpy( output,
388 test_driver_cipher_hooks.forced_output,
389 test_driver_cipher_hooks.forced_output_length );
390 *output_length = test_driver_cipher_hooks.forced_output_length;
Steven Cooreman8b122252020-09-03 15:30:32 +0200391 }
Steven Cooreman37941cb2020-07-28 18:49:51 +0200392
Steven Cooremanacb5a102020-09-08 14:06:57 +0200393 return( test_driver_cipher_hooks.forced_status );
Steven Cooreman37941cb2020-07-28 18:49:51 +0200394}
395
396/*
397 * opaque versions, to do
398 */
399psa_status_t test_opaque_cipher_encrypt(
400 const psa_key_attributes_t *attributes,
401 const uint8_t *key, size_t key_length,
402 psa_algorithm_t alg,
403 const uint8_t *input, size_t input_length,
404 uint8_t *output, size_t output_size, size_t *output_length)
405{
406 (void) attributes;
407 (void) key;
408 (void) key_length;
409 (void) alg;
410 (void) input;
411 (void) input_length;
412 (void) output;
413 (void) output_size;
414 (void) output_length;
Steven Cooremanacb5a102020-09-08 14:06:57 +0200415 return( PSA_ERROR_NOT_SUPPORTED );
Steven Cooreman37941cb2020-07-28 18:49:51 +0200416}
417
418psa_status_t test_opaque_cipher_decrypt(
419 const psa_key_attributes_t *attributes,
420 const uint8_t *key, size_t key_length,
421 psa_algorithm_t alg,
422 const uint8_t *input, size_t input_length,
423 uint8_t *output, size_t output_size, size_t *output_length)
424{
425 (void) attributes;
426 (void) key;
427 (void) key_length;
428 (void) alg;
429 (void) input;
430 (void) input_length;
431 (void) output;
432 (void) output_size;
433 (void) output_length;
Steven Cooremanacb5a102020-09-08 14:06:57 +0200434 return( PSA_ERROR_NOT_SUPPORTED );
Steven Cooreman37941cb2020-07-28 18:49:51 +0200435}
436
437psa_status_t test_opaque_cipher_encrypt_setup(
438 test_opaque_cipher_operation_t *operation,
439 const psa_key_attributes_t *attributes,
440 const uint8_t *key, size_t key_length,
441 psa_algorithm_t alg)
442{
443 (void) operation;
444 (void) attributes;
445 (void) key;
446 (void) key_length;
447 (void) alg;
Steven Cooremanacb5a102020-09-08 14:06:57 +0200448 return( PSA_ERROR_NOT_SUPPORTED );
Steven Cooreman37941cb2020-07-28 18:49:51 +0200449}
450
451psa_status_t test_opaque_cipher_decrypt_setup(
452 test_opaque_cipher_operation_t *operation,
453 const psa_key_attributes_t *attributes,
454 const uint8_t *key, size_t key_length,
455 psa_algorithm_t alg)
456{
457 (void) operation;
458 (void) attributes;
459 (void) key;
460 (void) key_length;
461 (void) alg;
Steven Cooremanacb5a102020-09-08 14:06:57 +0200462 return( PSA_ERROR_NOT_SUPPORTED );
Steven Cooreman37941cb2020-07-28 18:49:51 +0200463}
464
465psa_status_t test_opaque_cipher_abort(
466 test_opaque_cipher_operation_t *operation)
467{
468 (void) operation;
Steven Cooremanacb5a102020-09-08 14:06:57 +0200469 return( PSA_ERROR_NOT_SUPPORTED );
Steven Cooreman37941cb2020-07-28 18:49:51 +0200470}
471
472psa_status_t test_opaque_cipher_generate_iv(
473 test_opaque_cipher_operation_t *operation,
474 uint8_t *iv,
475 size_t iv_size,
476 size_t *iv_length)
477{
478 (void) operation;
479 (void) iv;
480 (void) iv_size;
481 (void) iv_length;
Steven Cooremanacb5a102020-09-08 14:06:57 +0200482 return( PSA_ERROR_NOT_SUPPORTED );
Steven Cooreman37941cb2020-07-28 18:49:51 +0200483}
484
485psa_status_t test_opaque_cipher_set_iv(
486 test_opaque_cipher_operation_t *operation,
487 const uint8_t *iv,
488 size_t iv_length)
489{
490 (void) operation;
491 (void) iv;
492 (void) iv_length;
Steven Cooremanacb5a102020-09-08 14:06:57 +0200493 return( PSA_ERROR_NOT_SUPPORTED );
Steven Cooreman37941cb2020-07-28 18:49:51 +0200494}
495
496psa_status_t test_opaque_cipher_update(
497 test_opaque_cipher_operation_t *operation,
498 const uint8_t *input,
499 size_t input_length,
500 uint8_t *output,
501 size_t output_size,
502 size_t *output_length)
503{
504 (void) operation;
505 (void) input;
506 (void) input_length;
507 (void) output;
508 (void) output_size;
509 (void) output_length;
Steven Cooremanacb5a102020-09-08 14:06:57 +0200510 return( PSA_ERROR_NOT_SUPPORTED );
Steven Cooreman37941cb2020-07-28 18:49:51 +0200511}
512
513psa_status_t test_opaque_cipher_finish(
514 test_opaque_cipher_operation_t *operation,
515 uint8_t *output,
516 size_t output_size,
517 size_t *output_length)
518{
519 (void) operation;
520 (void) output;
521 (void) output_size;
522 (void) output_length;
Steven Cooremanacb5a102020-09-08 14:06:57 +0200523 return( PSA_ERROR_NOT_SUPPORTED );
Steven Cooreman37941cb2020-07-28 18:49:51 +0200524}
525#endif /* MBEDTLS_PSA_CRYPTO_DRIVERS && PSA_CRYPTO_DRIVER_TEST */