blob: f9106d171c8c6dd71cfc0202679213c618e07ac5 [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 Cooreman89e54f22020-09-10 18:07:57 +0200299 test_driver_cipher_hooks.hits++;
300
Steven Cooreman8b122252020-09-03 15:30:32 +0200301 if( operation->alg == 0 )
302 return( PSA_SUCCESS );
303 if( operation->alg != PSA_ALG_CTR )
304 return( PSA_ERROR_BAD_STATE );
305
306 mbedtls_cipher_free( &operation->cipher );
307
Steven Cooreman5240e8b2020-09-09 11:51:45 +0200308 /* Wiping the entire struct here, instead of member-by-member. This is useful
309 * for the test suite, since it gives a chance of catching memory corruption
310 * errors should the core not have allocated (enough) memory for our context
311 * struct. */
312 memset( operation, 0, sizeof( *operation ) );
Steven Cooreman37941cb2020-07-28 18:49:51 +0200313
Steven Cooremanacb5a102020-09-08 14:06:57 +0200314 return( PSA_SUCCESS );
Steven Cooreman37941cb2020-07-28 18:49:51 +0200315}
316
317psa_status_t test_transparent_cipher_generate_iv(
318 test_transparent_cipher_operation_t *operation,
319 uint8_t *iv,
320 size_t iv_size,
321 size_t *iv_length)
322{
Steven Cooreman8b122252020-09-03 15:30:32 +0200323 psa_status_t status;
324 mbedtls_test_rnd_pseudo_info rnd_info;
325 memset( &rnd_info, 0x5A, sizeof( mbedtls_test_rnd_pseudo_info ) );
Steven Cooreman37941cb2020-07-28 18:49:51 +0200326
Steven Cooremanacb5a102020-09-08 14:06:57 +0200327 test_driver_cipher_hooks.hits++;
Steven Cooreman8b122252020-09-03 15:30:32 +0200328
Steven Cooreman89e54f22020-09-10 18:07:57 +0200329 if( test_driver_cipher_hooks.forced_status != PSA_SUCCESS )
330 return( test_driver_cipher_hooks.forced_status );
331
Steven Cooreman8b122252020-09-03 15:30:32 +0200332 if( operation->alg != PSA_ALG_CTR )
333 return( PSA_ERROR_BAD_STATE );
334
335 if( operation->iv_set || ! operation->iv_required )
336 return( PSA_ERROR_BAD_STATE );
337
338 if( iv_size < operation->iv_size )
339 return( PSA_ERROR_BUFFER_TOO_SMALL );
340
341 status = mbedtls_to_psa_error(
342 mbedtls_test_rnd_pseudo_rand( &rnd_info,
343 iv,
344 operation->iv_size ) );
345 if( status != PSA_SUCCESS )
Steven Cooremanacb5a102020-09-08 14:06:57 +0200346 return( status );
Steven Cooreman8b122252020-09-03 15:30:32 +0200347
348 *iv_length = operation->iv_size;
349 status = test_transparent_cipher_set_iv( operation, iv, *iv_length );
350
Steven Cooremanacb5a102020-09-08 14:06:57 +0200351 return( status );
Steven Cooreman37941cb2020-07-28 18:49:51 +0200352}
353
354psa_status_t test_transparent_cipher_set_iv(
355 test_transparent_cipher_operation_t *operation,
356 const uint8_t *iv,
357 size_t iv_length)
358{
Steven Cooreman8b122252020-09-03 15:30:32 +0200359 psa_status_t status;
Steven Cooreman37941cb2020-07-28 18:49:51 +0200360
Steven Cooremanacb5a102020-09-08 14:06:57 +0200361 test_driver_cipher_hooks.hits++;
Steven Cooreman8b122252020-09-03 15:30:32 +0200362
Steven Cooreman89e54f22020-09-10 18:07:57 +0200363 if( test_driver_cipher_hooks.forced_status != PSA_SUCCESS )
364 return( test_driver_cipher_hooks.forced_status );
365
Steven Cooreman8b122252020-09-03 15:30:32 +0200366 if( operation->alg != PSA_ALG_CTR )
Steven Cooremanacb5a102020-09-08 14:06:57 +0200367 return( PSA_ERROR_BAD_STATE );
Steven Cooreman8b122252020-09-03 15:30:32 +0200368
369 if( operation->iv_set || ! operation->iv_required )
370 return( PSA_ERROR_BAD_STATE );
371
372 if( iv_length != operation->iv_size )
373 return( PSA_ERROR_INVALID_ARGUMENT );
374
375 status = mbedtls_to_psa_error(
376 mbedtls_cipher_set_iv( &operation->cipher, iv, iv_length ) );
377
378 if( status == PSA_SUCCESS )
379 operation->iv_set = 1;
380
Steven Cooremanacb5a102020-09-08 14:06:57 +0200381 return( status );
Steven Cooreman37941cb2020-07-28 18:49:51 +0200382}
383
384psa_status_t test_transparent_cipher_update(
385 test_transparent_cipher_operation_t *operation,
386 const uint8_t *input,
387 size_t input_length,
388 uint8_t *output,
389 size_t output_size,
390 size_t *output_length)
391{
Steven Cooreman8b122252020-09-03 15:30:32 +0200392 psa_status_t status;
393
Steven Cooremanacb5a102020-09-08 14:06:57 +0200394 test_driver_cipher_hooks.hits++;
Steven Cooreman37941cb2020-07-28 18:49:51 +0200395
Steven Cooreman89e54f22020-09-10 18:07:57 +0200396 if( test_driver_cipher_hooks.forced_status != PSA_SUCCESS )
397 return( test_driver_cipher_hooks.forced_status );
398
Steven Cooreman8b122252020-09-03 15:30:32 +0200399 if( operation->alg != PSA_ALG_CTR )
400 return( PSA_ERROR_BAD_STATE );
Steven Cooreman37941cb2020-07-28 18:49:51 +0200401
Steven Cooreman16afd3d2020-09-09 15:36:39 +0200402 /* CTR is a stream cipher, so data in and out are always the same size */
403 if( output_size < input_length )
Steven Cooreman8b122252020-09-03 15:30:32 +0200404 return( PSA_ERROR_BUFFER_TOO_SMALL );
405
406 status = mbedtls_to_psa_error(
407 mbedtls_cipher_update( &operation->cipher, input,
408 input_length, output, output_length ) );
409
410 if( status != PSA_SUCCESS )
411 return status;
412
Steven Cooremanacb5a102020-09-08 14:06:57 +0200413 if( test_driver_cipher_hooks.forced_output != NULL )
Steven Cooreman8b122252020-09-03 15:30:32 +0200414 {
Steven Cooremanacb5a102020-09-08 14:06:57 +0200415 if( output_size < test_driver_cipher_hooks.forced_output_length )
Steven Cooreman8b122252020-09-03 15:30:32 +0200416 return PSA_ERROR_BUFFER_TOO_SMALL;
417
Steven Cooremanacb5a102020-09-08 14:06:57 +0200418 memcpy( output,
419 test_driver_cipher_hooks.forced_output,
420 test_driver_cipher_hooks.forced_output_length );
421 *output_length = test_driver_cipher_hooks.forced_output_length;
Steven Cooreman8b122252020-09-03 15:30:32 +0200422 }
Steven Cooreman37941cb2020-07-28 18:49:51 +0200423
Steven Cooremanacb5a102020-09-08 14:06:57 +0200424 return( test_driver_cipher_hooks.forced_status );
Steven Cooreman37941cb2020-07-28 18:49:51 +0200425}
426
427psa_status_t test_transparent_cipher_finish(
428 test_transparent_cipher_operation_t *operation,
429 uint8_t *output,
430 size_t output_size,
431 size_t *output_length)
432{
Steven Cooreman8b122252020-09-03 15:30:32 +0200433 psa_status_t status = PSA_ERROR_GENERIC_ERROR;
434 uint8_t temp_output_buffer[MBEDTLS_MAX_BLOCK_LENGTH];
435
Steven Cooremanacb5a102020-09-08 14:06:57 +0200436 test_driver_cipher_hooks.hits++;
Steven Cooreman37941cb2020-07-28 18:49:51 +0200437
Steven Cooreman89e54f22020-09-10 18:07:57 +0200438 if( test_driver_cipher_hooks.forced_status != PSA_SUCCESS )
439 return( test_driver_cipher_hooks.forced_status );
440
Steven Cooreman8b122252020-09-03 15:30:32 +0200441 if( operation->alg != PSA_ALG_CTR )
442 return( PSA_ERROR_BAD_STATE );
Steven Cooreman37941cb2020-07-28 18:49:51 +0200443
Steven Cooreman8b122252020-09-03 15:30:32 +0200444 if( ! operation->key_set )
445 return( PSA_ERROR_BAD_STATE );
446
447 if( operation->iv_required && ! operation->iv_set )
448 return( PSA_ERROR_BAD_STATE );
449
450 status = mbedtls_to_psa_error(
451 mbedtls_cipher_finish( &operation->cipher,
452 temp_output_buffer,
453 output_length ) );
454
455 mbedtls_cipher_free( &operation->cipher );
456
457 if( status != PSA_SUCCESS )
458 return( status );
459
460 if( *output_length == 0 )
461 ; /* Nothing to copy. Note that output may be NULL in this case. */
462 else if( output_size >= *output_length )
463 memcpy( output, temp_output_buffer, *output_length );
464 else
465 return( PSA_ERROR_BUFFER_TOO_SMALL );
466
467
Steven Cooremanacb5a102020-09-08 14:06:57 +0200468 if( test_driver_cipher_hooks.forced_output != NULL )
Steven Cooreman8b122252020-09-03 15:30:32 +0200469 {
Steven Cooremanacb5a102020-09-08 14:06:57 +0200470 if( output_size < test_driver_cipher_hooks.forced_output_length )
Steven Cooreman8b122252020-09-03 15:30:32 +0200471 return PSA_ERROR_BUFFER_TOO_SMALL;
472
Steven Cooremanacb5a102020-09-08 14:06:57 +0200473 memcpy( output,
474 test_driver_cipher_hooks.forced_output,
475 test_driver_cipher_hooks.forced_output_length );
476 *output_length = test_driver_cipher_hooks.forced_output_length;
Steven Cooreman8b122252020-09-03 15:30:32 +0200477 }
Steven Cooreman37941cb2020-07-28 18:49:51 +0200478
Steven Cooremanacb5a102020-09-08 14:06:57 +0200479 return( test_driver_cipher_hooks.forced_status );
Steven Cooreman37941cb2020-07-28 18:49:51 +0200480}
481
482/*
483 * opaque versions, to do
484 */
485psa_status_t test_opaque_cipher_encrypt(
486 const psa_key_attributes_t *attributes,
487 const uint8_t *key, size_t key_length,
488 psa_algorithm_t alg,
489 const uint8_t *input, size_t input_length,
490 uint8_t *output, size_t output_size, size_t *output_length)
491{
492 (void) attributes;
493 (void) key;
494 (void) key_length;
495 (void) alg;
496 (void) input;
497 (void) input_length;
498 (void) output;
499 (void) output_size;
500 (void) output_length;
Steven Cooremanacb5a102020-09-08 14:06:57 +0200501 return( PSA_ERROR_NOT_SUPPORTED );
Steven Cooreman37941cb2020-07-28 18:49:51 +0200502}
503
504psa_status_t test_opaque_cipher_decrypt(
505 const psa_key_attributes_t *attributes,
506 const uint8_t *key, size_t key_length,
507 psa_algorithm_t alg,
508 const uint8_t *input, size_t input_length,
509 uint8_t *output, size_t output_size, size_t *output_length)
510{
511 (void) attributes;
512 (void) key;
513 (void) key_length;
514 (void) alg;
515 (void) input;
516 (void) input_length;
517 (void) output;
518 (void) output_size;
519 (void) output_length;
Steven Cooremanacb5a102020-09-08 14:06:57 +0200520 return( PSA_ERROR_NOT_SUPPORTED );
Steven Cooreman37941cb2020-07-28 18:49:51 +0200521}
522
523psa_status_t test_opaque_cipher_encrypt_setup(
524 test_opaque_cipher_operation_t *operation,
525 const psa_key_attributes_t *attributes,
526 const uint8_t *key, size_t key_length,
527 psa_algorithm_t alg)
528{
529 (void) operation;
530 (void) attributes;
531 (void) key;
532 (void) key_length;
533 (void) alg;
Steven Cooremanacb5a102020-09-08 14:06:57 +0200534 return( PSA_ERROR_NOT_SUPPORTED );
Steven Cooreman37941cb2020-07-28 18:49:51 +0200535}
536
537psa_status_t test_opaque_cipher_decrypt_setup(
538 test_opaque_cipher_operation_t *operation,
539 const psa_key_attributes_t *attributes,
540 const uint8_t *key, size_t key_length,
541 psa_algorithm_t alg)
542{
543 (void) operation;
544 (void) attributes;
545 (void) key;
546 (void) key_length;
547 (void) alg;
Steven Cooremanacb5a102020-09-08 14:06:57 +0200548 return( PSA_ERROR_NOT_SUPPORTED );
Steven Cooreman37941cb2020-07-28 18:49:51 +0200549}
550
551psa_status_t test_opaque_cipher_abort(
552 test_opaque_cipher_operation_t *operation)
553{
554 (void) operation;
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_generate_iv(
559 test_opaque_cipher_operation_t *operation,
560 uint8_t *iv,
561 size_t iv_size,
562 size_t *iv_length)
563{
564 (void) operation;
565 (void) iv;
566 (void) iv_size;
567 (void) iv_length;
Steven Cooremanacb5a102020-09-08 14:06:57 +0200568 return( PSA_ERROR_NOT_SUPPORTED );
Steven Cooreman37941cb2020-07-28 18:49:51 +0200569}
570
571psa_status_t test_opaque_cipher_set_iv(
572 test_opaque_cipher_operation_t *operation,
573 const uint8_t *iv,
574 size_t iv_length)
575{
576 (void) operation;
577 (void) iv;
578 (void) iv_length;
Steven Cooremanacb5a102020-09-08 14:06:57 +0200579 return( PSA_ERROR_NOT_SUPPORTED );
Steven Cooreman37941cb2020-07-28 18:49:51 +0200580}
581
582psa_status_t test_opaque_cipher_update(
583 test_opaque_cipher_operation_t *operation,
584 const uint8_t *input,
585 size_t input_length,
586 uint8_t *output,
587 size_t output_size,
588 size_t *output_length)
589{
590 (void) operation;
591 (void) input;
592 (void) input_length;
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
599psa_status_t test_opaque_cipher_finish(
600 test_opaque_cipher_operation_t *operation,
601 uint8_t *output,
602 size_t output_size,
603 size_t *output_length)
604{
605 (void) operation;
606 (void) output;
607 (void) output_size;
608 (void) output_length;
Steven Cooremanacb5a102020-09-08 14:06:57 +0200609 return( PSA_ERROR_NOT_SUPPORTED );
Steven Cooreman37941cb2020-07-28 18:49:51 +0200610}
611#endif /* MBEDTLS_PSA_CRYPTO_DRIVERS && PSA_CRYPTO_DRIVER_TEST */