blob: 3d1efb85e76d039b696046c87158908b64ff7f5f [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
Mateusz Starzyk2c09c9b2021-05-14 22:20:10 +020021#include <test/helpers.h>
22
Steven Cooreman37941cb2020-07-28 18:49:51 +020023#if defined(MBEDTLS_PSA_CRYPTO_DRIVERS) && defined(PSA_CRYPTO_DRIVER_TEST)
24#include "psa/crypto.h"
Ronald Cron8d310ad2020-12-15 15:17:20 +010025#include "psa_crypto_cipher.h"
Steven Cooremanacb5a102020-09-08 14:06:57 +020026#include "psa_crypto_core.h"
Steven Cooreman37941cb2020-07-28 18:49:51 +020027#include "mbedtls/cipher.h"
28
Steven Cooremanacb5a102020-09-08 14:06:57 +020029#include "test/drivers/cipher.h"
Steven Cooreman37941cb2020-07-28 18:49:51 +020030
31#include "test/random.h"
32
Ronald Cron7975fae2021-09-13 14:50:42 +020033#if defined(MBEDTLS_TEST_LIBTESTDRIVER1)
34#include "libtestdriver1/library/psa_crypto_cipher.h"
35#endif
36
Steven Cooreman37941cb2020-07-28 18:49:51 +020037#include <string.h>
38
Ronald Cron7f13fa22021-04-13 12:41:34 +020039mbedtls_test_driver_cipher_hooks_t mbedtls_test_driver_cipher_hooks =
40 MBEDTLS_TEST_DRIVER_CIPHER_INIT;
Steven Cooreman37941cb2020-07-28 18:49:51 +020041
gabor-mezei-arma9449a02021-03-25 11:17:10 +010042psa_status_t mbedtls_test_transparent_cipher_encrypt(
Steven Cooremanfe0ab552020-09-10 13:07:02 +020043 const psa_key_attributes_t *attributes,
gabor-mezei-arma9449a02021-03-25 11:17:10 +010044 const uint8_t *key_buffer,
45 size_t key_buffer_size,
Steven Cooremanfe0ab552020-09-10 13:07:02 +020046 psa_algorithm_t alg,
gabor-mezei-arma9449a02021-03-25 11:17:10 +010047 const uint8_t *input,
48 size_t input_length,
49 uint8_t *output,
50 size_t output_size,
51 size_t *output_length )
Steven Cooremanfe0ab552020-09-10 13:07:02 +020052{
Ronald Cron7f13fa22021-04-13 12:41:34 +020053 mbedtls_test_driver_cipher_hooks.hits++;
Steven Cooremanfe0ab552020-09-10 13:07:02 +020054
Ronald Cron7f13fa22021-04-13 12:41:34 +020055 if( mbedtls_test_driver_cipher_hooks.forced_output != NULL )
Steven Cooremanfe0ab552020-09-10 13:07:02 +020056 {
Ronald Cron7f13fa22021-04-13 12:41:34 +020057 if( output_size < mbedtls_test_driver_cipher_hooks.forced_output_length )
Steven Cooremanfe0ab552020-09-10 13:07:02 +020058 return( PSA_ERROR_BUFFER_TOO_SMALL );
59
60 memcpy( output,
Ronald Cron7f13fa22021-04-13 12:41:34 +020061 mbedtls_test_driver_cipher_hooks.forced_output,
62 mbedtls_test_driver_cipher_hooks.forced_output_length );
63 *output_length = mbedtls_test_driver_cipher_hooks.forced_output_length;
Steven Cooremanfe0ab552020-09-10 13:07:02 +020064
Ronald Cron7f13fa22021-04-13 12:41:34 +020065 return( mbedtls_test_driver_cipher_hooks.forced_status );
Steven Cooremanfe0ab552020-09-10 13:07:02 +020066 }
67
gabor-mezei-arma9449a02021-03-25 11:17:10 +010068 if( mbedtls_test_driver_cipher_hooks.forced_status != PSA_SUCCESS )
69 return( mbedtls_test_driver_cipher_hooks.forced_status );
Steven Cooremanfe0ab552020-09-10 13:07:02 +020070
gabor-mezei-arma9449a02021-03-25 11:17:10 +010071 psa_generate_random( output, PSA_CIPHER_IV_LENGTH( attributes->core.type, alg ) );
Steven Cooremanfe0ab552020-09-10 13:07:02 +020072
Ronald Cron7975fae2021-09-13 14:50:42 +020073#if defined(MBEDTLS_TEST_LIBTESTDRIVER1) && \
74 defined(LIBTESTDRIVER1_MBEDTLS_PSA_BUILTIN_CIPHER)
Ronald Cron40170d92021-03-13 18:19:08 +010075 return( libtestdriver1_mbedtls_psa_cipher_encrypt(
Ronald Cron7975fae2021-09-13 14:50:42 +020076 (const libtestdriver1_psa_key_attributes_t *)attributes,
77 key_buffer, key_buffer_size,
gabor-mezei-arma9449a02021-03-25 11:17:10 +010078 alg, input, input_length,
79 output, output_size, output_length ) );
Ronald Cron73c9d9e2021-04-09 11:09:54 +020080#elif defined(MBEDTLS_PSA_BUILTIN_CIPHER)
81 return( mbedtls_psa_cipher_encrypt(
82 attributes, key_buffer, key_buffer_size,
83 alg, input, input_length,
84 output, output_size, output_length ) );
85#endif
86
87 return( PSA_ERROR_NOT_SUPPORTED );
Steven Cooreman37941cb2020-07-28 18:49:51 +020088}
89
Ronald Cron7f13fa22021-04-13 12:41:34 +020090psa_status_t mbedtls_test_transparent_cipher_decrypt(
Steven Cooreman37941cb2020-07-28 18:49:51 +020091 const psa_key_attributes_t *attributes,
gabor-mezei-arma9449a02021-03-25 11:17:10 +010092 const uint8_t *key_buffer,
93 size_t key_buffer_size,
Steven Cooreman37941cb2020-07-28 18:49:51 +020094 psa_algorithm_t alg,
gabor-mezei-arma9449a02021-03-25 11:17:10 +010095 const uint8_t *input,
96 size_t input_length,
97 uint8_t *output,
98 size_t output_size,
99 size_t *output_length )
Steven Cooreman37941cb2020-07-28 18:49:51 +0200100{
gabor-mezei-arma9449a02021-03-25 11:17:10 +0100101 mbedtls_test_driver_cipher_hooks.hits++;
102
103 if( mbedtls_test_driver_cipher_hooks.forced_output != NULL )
104 {
105 if( output_size < mbedtls_test_driver_cipher_hooks.forced_output_length )
106 return( PSA_ERROR_BUFFER_TOO_SMALL );
107
108 memcpy( output,
109 mbedtls_test_driver_cipher_hooks.forced_output,
110 mbedtls_test_driver_cipher_hooks.forced_output_length );
111 *output_length = mbedtls_test_driver_cipher_hooks.forced_output_length;
112
113 return( mbedtls_test_driver_cipher_hooks.forced_status );
114 }
115
116 if( mbedtls_test_driver_cipher_hooks.forced_status != PSA_SUCCESS )
117 return( mbedtls_test_driver_cipher_hooks.forced_status );
118
Ronald Cron7975fae2021-09-13 14:50:42 +0200119#if defined(MBEDTLS_TEST_LIBTESTDRIVER1) && \
120 defined(LIBTESTDRIVER1_MBEDTLS_PSA_BUILTIN_CIPHER)
Ronald Cron40170d92021-03-13 18:19:08 +0100121 return( libtestdriver1_mbedtls_psa_cipher_decrypt(
Ronald Cron7975fae2021-09-13 14:50:42 +0200122 (const libtestdriver1_psa_key_attributes_t *)attributes,
123 key_buffer, key_buffer_size,
gabor-mezei-arma9449a02021-03-25 11:17:10 +0100124 alg, input, input_length,
125 output, output_size, output_length ) );
Ronald Cron73c9d9e2021-04-09 11:09:54 +0200126#elif defined(MBEDTLS_PSA_BUILTIN_CIPHER)
127 return( mbedtls_psa_cipher_decrypt(
128 attributes, key_buffer, key_buffer_size,
129 alg, input, input_length,
130 output, output_size, output_length ) );
131#endif
132
133 return( PSA_ERROR_NOT_SUPPORTED );
Steven Cooreman37941cb2020-07-28 18:49:51 +0200134}
135
Ronald Cron7f13fa22021-04-13 12:41:34 +0200136psa_status_t mbedtls_test_transparent_cipher_encrypt_setup(
Ronald Cron7cb9c3d2021-03-10 12:21:48 +0100137 mbedtls_transparent_test_driver_cipher_operation_t *operation,
Steven Cooreman16afd3d2020-09-09 15:36:39 +0200138 const psa_key_attributes_t *attributes,
139 const uint8_t *key, size_t key_length,
140 psa_algorithm_t alg)
141{
Ronald Cron7f13fa22021-04-13 12:41:34 +0200142 mbedtls_test_driver_cipher_hooks.hits++;
Ronald Cron8d310ad2020-12-15 15:17:20 +0100143
144 /* Wiping the entire struct here, instead of member-by-member. This is
145 * useful for the test suite, since it gives a chance of catching memory
146 * corruption errors should the core not have allocated (enough) memory for
147 * our context struct. */
148 memset( operation, 0, sizeof( *operation ) );
149
Ronald Cron7f13fa22021-04-13 12:41:34 +0200150 if( mbedtls_test_driver_cipher_hooks.forced_status != PSA_SUCCESS )
151 return( mbedtls_test_driver_cipher_hooks.forced_status );
Ronald Cron8d310ad2020-12-15 15:17:20 +0100152
Ronald Cron7975fae2021-09-13 14:50:42 +0200153#if defined(MBEDTLS_TEST_LIBTESTDRIVER1) && \
154 defined(LIBTESTDRIVER1_MBEDTLS_PSA_BUILTIN_CIPHER)
Ronald Cron40170d92021-03-13 18:19:08 +0100155 return( libtestdriver1_mbedtls_psa_cipher_encrypt_setup(
Ronald Cron7975fae2021-09-13 14:50:42 +0200156 operation,
157 (const libtestdriver1_psa_key_attributes_t *)attributes,
158 key, key_length, alg ) );
Ronald Cron73c9d9e2021-04-09 11:09:54 +0200159#elif defined(MBEDTLS_PSA_BUILTIN_CIPHER)
160 return( mbedtls_psa_cipher_encrypt_setup(
161 operation, attributes, key, key_length, alg ) );
162#endif
163
164 return( PSA_ERROR_NOT_SUPPORTED );
Steven Cooreman16afd3d2020-09-09 15:36:39 +0200165}
166
Ronald Cron7f13fa22021-04-13 12:41:34 +0200167psa_status_t mbedtls_test_transparent_cipher_decrypt_setup(
Ronald Cron7cb9c3d2021-03-10 12:21:48 +0100168 mbedtls_transparent_test_driver_cipher_operation_t *operation,
Steven Cooreman37941cb2020-07-28 18:49:51 +0200169 const psa_key_attributes_t *attributes,
170 const uint8_t *key, size_t key_length,
171 psa_algorithm_t alg)
172{
Ronald Cron7f13fa22021-04-13 12:41:34 +0200173 mbedtls_test_driver_cipher_hooks.hits++;
Ronald Cron8d310ad2020-12-15 15:17:20 +0100174
Ronald Cron7f13fa22021-04-13 12:41:34 +0200175 if( mbedtls_test_driver_cipher_hooks.forced_status != PSA_SUCCESS )
176 return( mbedtls_test_driver_cipher_hooks.forced_status );
Ronald Cron8d310ad2020-12-15 15:17:20 +0100177
Ronald Cron7975fae2021-09-13 14:50:42 +0200178#if defined(MBEDTLS_TEST_LIBTESTDRIVER1) && \
179 defined(LIBTESTDRIVER1_MBEDTLS_PSA_BUILTIN_CIPHER)
Ronald Cron40170d92021-03-13 18:19:08 +0100180 return( libtestdriver1_mbedtls_psa_cipher_decrypt_setup(
Ronald Cron7975fae2021-09-13 14:50:42 +0200181 operation,
182 (const libtestdriver1_psa_key_attributes_t *)attributes,
183 key, key_length, alg ) );
Ronald Cron73c9d9e2021-04-09 11:09:54 +0200184#elif defined(MBEDTLS_PSA_BUILTIN_CIPHER)
185 return( mbedtls_psa_cipher_decrypt_setup(
186 operation, attributes, key, key_length, alg ) );
187#endif
188
189 return( PSA_ERROR_NOT_SUPPORTED );
Steven Cooreman37941cb2020-07-28 18:49:51 +0200190}
191
Ronald Cron7f13fa22021-04-13 12:41:34 +0200192psa_status_t mbedtls_test_transparent_cipher_abort(
Ronald Cron7cb9c3d2021-03-10 12:21:48 +0100193 mbedtls_transparent_test_driver_cipher_operation_t *operation)
Steven Cooreman37941cb2020-07-28 18:49:51 +0200194{
Ronald Cron7f13fa22021-04-13 12:41:34 +0200195 mbedtls_test_driver_cipher_hooks.hits++;
Steven Cooreman89e54f22020-09-10 18:07:57 +0200196
Ronald Cron7975fae2021-09-13 14:50:42 +0200197#if defined(MBEDTLS_TEST_LIBTESTDRIVER1) && \
198 defined(LIBTESTDRIVER1_MBEDTLS_PSA_BUILTIN_CIPHER)
Ronald Cron40170d92021-03-13 18:19:08 +0100199 libtestdriver1_mbedtls_psa_cipher_abort( operation );
Ronald Cron73c9d9e2021-04-09 11:09:54 +0200200#elif defined(MBEDTLS_PSA_BUILTIN_CIPHER)
201 mbedtls_psa_cipher_abort( operation );
202#endif
Steven Cooreman8b122252020-09-03 15:30:32 +0200203
Ronald Cron8d310ad2020-12-15 15:17:20 +0100204 /* Wiping the entire struct here, instead of member-by-member. This is
205 * useful for the test suite, since it gives a chance of catching memory
206 * corruption errors should the core not have allocated (enough) memory for
207 * our context struct. */
Steven Cooreman5240e8b2020-09-09 11:51:45 +0200208 memset( operation, 0, sizeof( *operation ) );
Steven Cooreman37941cb2020-07-28 18:49:51 +0200209
Ronald Cron7f13fa22021-04-13 12:41:34 +0200210 return( mbedtls_test_driver_cipher_hooks.forced_status );
Steven Cooreman37941cb2020-07-28 18:49:51 +0200211}
212
Ronald Cron7f13fa22021-04-13 12:41:34 +0200213psa_status_t mbedtls_test_transparent_cipher_set_iv(
Ronald Cron7cb9c3d2021-03-10 12:21:48 +0100214 mbedtls_transparent_test_driver_cipher_operation_t *operation,
Steven Cooreman37941cb2020-07-28 18:49:51 +0200215 const uint8_t *iv,
216 size_t iv_length)
217{
Ronald Cron7f13fa22021-04-13 12:41:34 +0200218 mbedtls_test_driver_cipher_hooks.hits++;
Steven Cooreman8b122252020-09-03 15:30:32 +0200219
Ronald Cron7f13fa22021-04-13 12:41:34 +0200220 if( mbedtls_test_driver_cipher_hooks.forced_status != PSA_SUCCESS )
221 return( mbedtls_test_driver_cipher_hooks.forced_status );
Steven Cooreman89e54f22020-09-10 18:07:57 +0200222
Ronald Cron7975fae2021-09-13 14:50:42 +0200223#if defined(MBEDTLS_TEST_LIBTESTDRIVER1) && \
224 defined(LIBTESTDRIVER1_MBEDTLS_PSA_BUILTIN_CIPHER)
Ronald Cron40170d92021-03-13 18:19:08 +0100225 return( libtestdriver1_mbedtls_psa_cipher_set_iv(
Ronald Cron3522e322021-03-12 11:08:49 +0100226 operation, iv, iv_length ) );
Ronald Cron73c9d9e2021-04-09 11:09:54 +0200227#elif defined(MBEDTLS_PSA_BUILTIN_CIPHER)
228 return( mbedtls_psa_cipher_set_iv( operation, iv, iv_length ) );
229#endif
230
231 return( PSA_ERROR_NOT_SUPPORTED );
Steven Cooreman37941cb2020-07-28 18:49:51 +0200232}
233
Ronald Cron7f13fa22021-04-13 12:41:34 +0200234psa_status_t mbedtls_test_transparent_cipher_update(
Ronald Cron7cb9c3d2021-03-10 12:21:48 +0100235 mbedtls_transparent_test_driver_cipher_operation_t *operation,
Steven Cooreman37941cb2020-07-28 18:49:51 +0200236 const uint8_t *input,
237 size_t input_length,
238 uint8_t *output,
239 size_t output_size,
240 size_t *output_length)
241{
Ronald Cron7f13fa22021-04-13 12:41:34 +0200242 mbedtls_test_driver_cipher_hooks.hits++;
Steven Cooreman37941cb2020-07-28 18:49:51 +0200243
Ronald Cron7f13fa22021-04-13 12:41:34 +0200244 if( mbedtls_test_driver_cipher_hooks.forced_output != NULL )
Steven Cooreman8b122252020-09-03 15:30:32 +0200245 {
Ronald Cron7f13fa22021-04-13 12:41:34 +0200246 if( output_size < mbedtls_test_driver_cipher_hooks.forced_output_length )
Steven Cooreman8b122252020-09-03 15:30:32 +0200247 return PSA_ERROR_BUFFER_TOO_SMALL;
248
Steven Cooremanacb5a102020-09-08 14:06:57 +0200249 memcpy( output,
Ronald Cron7f13fa22021-04-13 12:41:34 +0200250 mbedtls_test_driver_cipher_hooks.forced_output,
251 mbedtls_test_driver_cipher_hooks.forced_output_length );
252 *output_length = mbedtls_test_driver_cipher_hooks.forced_output_length;
Ronald Cron8d310ad2020-12-15 15:17:20 +0100253
Ronald Cron7f13fa22021-04-13 12:41:34 +0200254 return( mbedtls_test_driver_cipher_hooks.forced_status );
Steven Cooreman8b122252020-09-03 15:30:32 +0200255 }
Steven Cooreman37941cb2020-07-28 18:49:51 +0200256
Ronald Cron7f13fa22021-04-13 12:41:34 +0200257 if( mbedtls_test_driver_cipher_hooks.forced_status != PSA_SUCCESS )
258 return( mbedtls_test_driver_cipher_hooks.forced_status );
Ronald Cron8d310ad2020-12-15 15:17:20 +0100259
Ronald Cron7975fae2021-09-13 14:50:42 +0200260#if defined(MBEDTLS_TEST_LIBTESTDRIVER1) && \
261 defined(LIBTESTDRIVER1_MBEDTLS_PSA_BUILTIN_CIPHER)
Ronald Cron40170d92021-03-13 18:19:08 +0100262 return( libtestdriver1_mbedtls_psa_cipher_update(
Ronald Cron3522e322021-03-12 11:08:49 +0100263 operation, input, input_length,
264 output, output_size, output_length ) );
Ronald Cron73c9d9e2021-04-09 11:09:54 +0200265#elif defined(MBEDTLS_PSA_BUILTIN_CIPHER)
266 return( mbedtls_psa_cipher_update(
267 operation, input, input_length,
268 output, output_size, output_length ) );
269#endif
270
271 return( PSA_ERROR_NOT_SUPPORTED );
Steven Cooreman37941cb2020-07-28 18:49:51 +0200272}
273
Ronald Cron7f13fa22021-04-13 12:41:34 +0200274psa_status_t mbedtls_test_transparent_cipher_finish(
Ronald Cron7cb9c3d2021-03-10 12:21:48 +0100275 mbedtls_transparent_test_driver_cipher_operation_t *operation,
Steven Cooreman37941cb2020-07-28 18:49:51 +0200276 uint8_t *output,
277 size_t output_size,
278 size_t *output_length)
279{
Ronald Cron7f13fa22021-04-13 12:41:34 +0200280 mbedtls_test_driver_cipher_hooks.hits++;
Steven Cooreman37941cb2020-07-28 18:49:51 +0200281
Ronald Cron7f13fa22021-04-13 12:41:34 +0200282 if( mbedtls_test_driver_cipher_hooks.forced_output != NULL )
Steven Cooreman8b122252020-09-03 15:30:32 +0200283 {
Ronald Cron7f13fa22021-04-13 12:41:34 +0200284 if( output_size < mbedtls_test_driver_cipher_hooks.forced_output_length )
Steven Cooreman8b122252020-09-03 15:30:32 +0200285 return PSA_ERROR_BUFFER_TOO_SMALL;
286
Steven Cooremanacb5a102020-09-08 14:06:57 +0200287 memcpy( output,
Ronald Cron7f13fa22021-04-13 12:41:34 +0200288 mbedtls_test_driver_cipher_hooks.forced_output,
289 mbedtls_test_driver_cipher_hooks.forced_output_length );
290 *output_length = mbedtls_test_driver_cipher_hooks.forced_output_length;
Ronald Cron8d310ad2020-12-15 15:17:20 +0100291
Ronald Cron7f13fa22021-04-13 12:41:34 +0200292 return( mbedtls_test_driver_cipher_hooks.forced_status );
Steven Cooreman8b122252020-09-03 15:30:32 +0200293 }
Steven Cooreman37941cb2020-07-28 18:49:51 +0200294
Ronald Cron7f13fa22021-04-13 12:41:34 +0200295 if( mbedtls_test_driver_cipher_hooks.forced_status != PSA_SUCCESS )
296 return( mbedtls_test_driver_cipher_hooks.forced_status );
Ronald Cron8d310ad2020-12-15 15:17:20 +0100297
Ronald Cron7975fae2021-09-13 14:50:42 +0200298#if defined(MBEDTLS_TEST_LIBTESTDRIVER1) && \
299 defined(LIBTESTDRIVER1_MBEDTLS_PSA_BUILTIN_CIPHER)
Ronald Cron40170d92021-03-13 18:19:08 +0100300 return( libtestdriver1_mbedtls_psa_cipher_finish(
Ronald Cron3522e322021-03-12 11:08:49 +0100301 operation, output, output_size, output_length ) );
Ronald Cron73c9d9e2021-04-09 11:09:54 +0200302#elif defined(MBEDTLS_PSA_BUILTIN_CIPHER)
303 return( mbedtls_psa_cipher_finish(
304 operation, output, output_size, output_length ) );
305#endif
306
307 return( PSA_ERROR_NOT_SUPPORTED );
Steven Cooreman37941cb2020-07-28 18:49:51 +0200308}
309
310/*
311 * opaque versions, to do
312 */
Ronald Cron7f13fa22021-04-13 12:41:34 +0200313psa_status_t mbedtls_test_opaque_cipher_encrypt(
Steven Cooreman37941cb2020-07-28 18:49:51 +0200314 const psa_key_attributes_t *attributes,
315 const uint8_t *key, size_t key_length,
316 psa_algorithm_t alg,
317 const uint8_t *input, size_t input_length,
318 uint8_t *output, size_t output_size, size_t *output_length)
319{
320 (void) attributes;
321 (void) key;
322 (void) key_length;
323 (void) alg;
324 (void) input;
325 (void) input_length;
326 (void) output;
327 (void) output_size;
328 (void) output_length;
Steven Cooremanacb5a102020-09-08 14:06:57 +0200329 return( PSA_ERROR_NOT_SUPPORTED );
Steven Cooreman37941cb2020-07-28 18:49:51 +0200330}
331
Ronald Cron7f13fa22021-04-13 12:41:34 +0200332psa_status_t mbedtls_test_opaque_cipher_decrypt(
Steven Cooreman37941cb2020-07-28 18:49:51 +0200333 const psa_key_attributes_t *attributes,
334 const uint8_t *key, size_t key_length,
335 psa_algorithm_t alg,
336 const uint8_t *input, size_t input_length,
337 uint8_t *output, size_t output_size, size_t *output_length)
338{
339 (void) attributes;
340 (void) key;
341 (void) key_length;
342 (void) alg;
343 (void) input;
344 (void) input_length;
345 (void) output;
346 (void) output_size;
347 (void) output_length;
Steven Cooremanacb5a102020-09-08 14:06:57 +0200348 return( PSA_ERROR_NOT_SUPPORTED );
Steven Cooreman37941cb2020-07-28 18:49:51 +0200349}
350
Ronald Cron7f13fa22021-04-13 12:41:34 +0200351psa_status_t mbedtls_test_opaque_cipher_encrypt_setup(
Ronald Cron7cb9c3d2021-03-10 12:21:48 +0100352 mbedtls_opaque_test_driver_cipher_operation_t *operation,
Steven Cooreman37941cb2020-07-28 18:49:51 +0200353 const psa_key_attributes_t *attributes,
354 const uint8_t *key, size_t key_length,
355 psa_algorithm_t alg)
356{
357 (void) operation;
358 (void) attributes;
359 (void) key;
360 (void) key_length;
361 (void) alg;
Steven Cooremanacb5a102020-09-08 14:06:57 +0200362 return( PSA_ERROR_NOT_SUPPORTED );
Steven Cooreman37941cb2020-07-28 18:49:51 +0200363}
364
Ronald Cron7f13fa22021-04-13 12:41:34 +0200365psa_status_t mbedtls_test_opaque_cipher_decrypt_setup(
Ronald Cron7cb9c3d2021-03-10 12:21:48 +0100366 mbedtls_opaque_test_driver_cipher_operation_t *operation,
Steven Cooreman37941cb2020-07-28 18:49:51 +0200367 const psa_key_attributes_t *attributes,
368 const uint8_t *key, size_t key_length,
369 psa_algorithm_t alg)
370{
371 (void) operation;
372 (void) attributes;
373 (void) key;
374 (void) key_length;
375 (void) alg;
Steven Cooremanacb5a102020-09-08 14:06:57 +0200376 return( PSA_ERROR_NOT_SUPPORTED );
Steven Cooreman37941cb2020-07-28 18:49:51 +0200377}
378
Ronald Cron7f13fa22021-04-13 12:41:34 +0200379psa_status_t mbedtls_test_opaque_cipher_abort(
Ronald Cron7cb9c3d2021-03-10 12:21:48 +0100380 mbedtls_opaque_test_driver_cipher_operation_t *operation )
Steven Cooreman37941cb2020-07-28 18:49:51 +0200381{
382 (void) operation;
Steven Cooremanacb5a102020-09-08 14:06:57 +0200383 return( PSA_ERROR_NOT_SUPPORTED );
Steven Cooreman37941cb2020-07-28 18:49:51 +0200384}
385
Ronald Cron7f13fa22021-04-13 12:41:34 +0200386psa_status_t mbedtls_test_opaque_cipher_set_iv(
Ronald Cron7cb9c3d2021-03-10 12:21:48 +0100387 mbedtls_opaque_test_driver_cipher_operation_t *operation,
Steven Cooreman37941cb2020-07-28 18:49:51 +0200388 const uint8_t *iv,
389 size_t iv_length)
390{
391 (void) operation;
392 (void) iv;
393 (void) iv_length;
Steven Cooremanacb5a102020-09-08 14:06:57 +0200394 return( PSA_ERROR_NOT_SUPPORTED );
Steven Cooreman37941cb2020-07-28 18:49:51 +0200395}
396
Ronald Cron7f13fa22021-04-13 12:41:34 +0200397psa_status_t mbedtls_test_opaque_cipher_update(
Ronald Cron7cb9c3d2021-03-10 12:21:48 +0100398 mbedtls_opaque_test_driver_cipher_operation_t *operation,
Steven Cooreman37941cb2020-07-28 18:49:51 +0200399 const uint8_t *input,
400 size_t input_length,
401 uint8_t *output,
402 size_t output_size,
403 size_t *output_length)
404{
405 (void) operation;
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
Ronald Cron7f13fa22021-04-13 12:41:34 +0200414psa_status_t mbedtls_test_opaque_cipher_finish(
Ronald Cron7cb9c3d2021-03-10 12:21:48 +0100415 mbedtls_opaque_test_driver_cipher_operation_t *operation,
Steven Cooreman37941cb2020-07-28 18:49:51 +0200416 uint8_t *output,
417 size_t output_size,
418 size_t *output_length)
419{
420 (void) operation;
421 (void) output;
422 (void) output_size;
423 (void) output_length;
Steven Cooremanacb5a102020-09-08 14:06:57 +0200424 return( PSA_ERROR_NOT_SUPPORTED );
Steven Cooreman37941cb2020-07-28 18:49:51 +0200425}
426#endif /* MBEDTLS_PSA_CRYPTO_DRIVERS && PSA_CRYPTO_DRIVER_TEST */