blob: 678d8d5d6ad3c1159c6a14824bd463f5116ab9aa [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
Dave Rodgman16799db2023-11-02 19:47:20 +00006 * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
Steven Cooreman37941cb2020-07-28 18:49:51 +02007 */
8
Mateusz Starzyk2c09c9b2021-05-14 22:20:10 +02009#include <test/helpers.h>
10
Ronald Crone6e6b752023-01-16 16:56:51 +010011#if defined(PSA_CRYPTO_DRIVER_TEST)
Steven Cooreman37941cb2020-07-28 18:49:51 +020012#include "psa/crypto.h"
Ronald Cron8d310ad2020-12-15 15:17:20 +010013#include "psa_crypto_cipher.h"
Steven Cooremanacb5a102020-09-08 14:06:57 +020014#include "psa_crypto_core.h"
Steven Cooreman37941cb2020-07-28 18:49:51 +020015#include "mbedtls/cipher.h"
16
Steven Cooremanacb5a102020-09-08 14:06:57 +020017#include "test/drivers/cipher.h"
Steven Cooreman37941cb2020-07-28 18:49:51 +020018
19#include "test/random.h"
20
Ronald Cron7975fae2021-09-13 14:50:42 +020021#if defined(MBEDTLS_TEST_LIBTESTDRIVER1)
22#include "libtestdriver1/library/psa_crypto_cipher.h"
23#endif
24
Steven Cooreman37941cb2020-07-28 18:49:51 +020025#include <string.h>
26
Ronald Cron7f13fa22021-04-13 12:41:34 +020027mbedtls_test_driver_cipher_hooks_t mbedtls_test_driver_cipher_hooks =
28 MBEDTLS_TEST_DRIVER_CIPHER_INIT;
Steven Cooreman37941cb2020-07-28 18:49:51 +020029
gabor-mezei-arma9449a02021-03-25 11:17:10 +010030psa_status_t mbedtls_test_transparent_cipher_encrypt(
Steven Cooremanfe0ab552020-09-10 13:07:02 +020031 const psa_key_attributes_t *attributes,
gabor-mezei-arma9449a02021-03-25 11:17:10 +010032 const uint8_t *key_buffer,
33 size_t key_buffer_size,
Steven Cooremanfe0ab552020-09-10 13:07:02 +020034 psa_algorithm_t alg,
Ronald Cron9b674282021-07-09 09:19:35 +020035 const uint8_t *iv,
36 size_t iv_length,
gabor-mezei-arma9449a02021-03-25 11:17:10 +010037 const uint8_t *input,
38 size_t input_length,
39 uint8_t *output,
40 size_t output_size,
Gilles Peskine449bd832023-01-11 14:50:10 +010041 size_t *output_length)
Steven Cooremanfe0ab552020-09-10 13:07:02 +020042{
Ronald Cron7f13fa22021-04-13 12:41:34 +020043 mbedtls_test_driver_cipher_hooks.hits++;
Steven Cooremanfe0ab552020-09-10 13:07:02 +020044
Gilles Peskine449bd832023-01-11 14:50:10 +010045 if (mbedtls_test_driver_cipher_hooks.forced_output != NULL) {
46 if (output_size < mbedtls_test_driver_cipher_hooks.forced_output_length) {
47 return PSA_ERROR_BUFFER_TOO_SMALL;
48 }
Steven Cooremanfe0ab552020-09-10 13:07:02 +020049
Gilles Peskine449bd832023-01-11 14:50:10 +010050 memcpy(output,
51 mbedtls_test_driver_cipher_hooks.forced_output,
52 mbedtls_test_driver_cipher_hooks.forced_output_length);
Ronald Cron7f13fa22021-04-13 12:41:34 +020053 *output_length = mbedtls_test_driver_cipher_hooks.forced_output_length;
Steven Cooremanfe0ab552020-09-10 13:07:02 +020054
Gilles Peskine449bd832023-01-11 14:50:10 +010055 return mbedtls_test_driver_cipher_hooks.forced_status;
Steven Cooremanfe0ab552020-09-10 13:07:02 +020056 }
57
Gilles Peskine449bd832023-01-11 14:50:10 +010058 if (mbedtls_test_driver_cipher_hooks.forced_status != PSA_SUCCESS) {
59 return mbedtls_test_driver_cipher_hooks.forced_status;
60 }
Steven Cooremanfe0ab552020-09-10 13:07:02 +020061
Ronald Cron7975fae2021-09-13 14:50:42 +020062#if defined(MBEDTLS_TEST_LIBTESTDRIVER1) && \
63 defined(LIBTESTDRIVER1_MBEDTLS_PSA_BUILTIN_CIPHER)
Gilles Peskine449bd832023-01-11 14:50:10 +010064 return libtestdriver1_mbedtls_psa_cipher_encrypt(
65 (const libtestdriver1_psa_key_attributes_t *) attributes,
66 key_buffer, key_buffer_size,
67 alg, iv, iv_length, input, input_length,
68 output, output_size, output_length);
Ronald Cron73c9d9e2021-04-09 11:09:54 +020069#elif defined(MBEDTLS_PSA_BUILTIN_CIPHER)
Gilles Peskine449bd832023-01-11 14:50:10 +010070 return mbedtls_psa_cipher_encrypt(
71 attributes, key_buffer, key_buffer_size,
72 alg, iv, iv_length, input, input_length,
73 output, output_size, output_length);
Ronald Cron73c9d9e2021-04-09 11:09:54 +020074#endif
75
Gilles Peskine449bd832023-01-11 14:50:10 +010076 return PSA_ERROR_NOT_SUPPORTED;
Steven Cooreman37941cb2020-07-28 18:49:51 +020077}
78
Ronald Cron7f13fa22021-04-13 12:41:34 +020079psa_status_t mbedtls_test_transparent_cipher_decrypt(
Steven Cooreman37941cb2020-07-28 18:49:51 +020080 const psa_key_attributes_t *attributes,
gabor-mezei-arma9449a02021-03-25 11:17:10 +010081 const uint8_t *key_buffer,
82 size_t key_buffer_size,
Steven Cooreman37941cb2020-07-28 18:49:51 +020083 psa_algorithm_t alg,
gabor-mezei-arma9449a02021-03-25 11:17:10 +010084 const uint8_t *input,
85 size_t input_length,
86 uint8_t *output,
87 size_t output_size,
Gilles Peskine449bd832023-01-11 14:50:10 +010088 size_t *output_length)
Steven Cooreman37941cb2020-07-28 18:49:51 +020089{
Gilles Peskine449bd832023-01-11 14:50:10 +010090 mbedtls_test_driver_cipher_hooks.hits++;
gabor-mezei-arma9449a02021-03-25 11:17:10 +010091
Gilles Peskine449bd832023-01-11 14:50:10 +010092 if (mbedtls_test_driver_cipher_hooks.forced_output != NULL) {
93 if (output_size < mbedtls_test_driver_cipher_hooks.forced_output_length) {
94 return PSA_ERROR_BUFFER_TOO_SMALL;
95 }
gabor-mezei-arma9449a02021-03-25 11:17:10 +010096
Gilles Peskine449bd832023-01-11 14:50:10 +010097 memcpy(output,
98 mbedtls_test_driver_cipher_hooks.forced_output,
99 mbedtls_test_driver_cipher_hooks.forced_output_length);
gabor-mezei-arma9449a02021-03-25 11:17:10 +0100100 *output_length = mbedtls_test_driver_cipher_hooks.forced_output_length;
101
Gilles Peskine449bd832023-01-11 14:50:10 +0100102 return mbedtls_test_driver_cipher_hooks.forced_status;
gabor-mezei-arma9449a02021-03-25 11:17:10 +0100103 }
104
Gilles Peskine449bd832023-01-11 14:50:10 +0100105 if (mbedtls_test_driver_cipher_hooks.forced_status != PSA_SUCCESS) {
106 return mbedtls_test_driver_cipher_hooks.forced_status;
107 }
gabor-mezei-arma9449a02021-03-25 11:17:10 +0100108
Ronald Cron7975fae2021-09-13 14:50:42 +0200109#if defined(MBEDTLS_TEST_LIBTESTDRIVER1) && \
110 defined(LIBTESTDRIVER1_MBEDTLS_PSA_BUILTIN_CIPHER)
Gilles Peskine449bd832023-01-11 14:50:10 +0100111 return libtestdriver1_mbedtls_psa_cipher_decrypt(
112 (const libtestdriver1_psa_key_attributes_t *) attributes,
113 key_buffer, key_buffer_size,
114 alg, input, input_length,
115 output, output_size, output_length);
Ronald Cron73c9d9e2021-04-09 11:09:54 +0200116#elif defined(MBEDTLS_PSA_BUILTIN_CIPHER)
Gilles Peskine449bd832023-01-11 14:50:10 +0100117 return mbedtls_psa_cipher_decrypt(
118 attributes, key_buffer, key_buffer_size,
119 alg, input, input_length,
120 output, output_size, output_length);
Ronald Cron73c9d9e2021-04-09 11:09:54 +0200121#endif
122
Gilles Peskine449bd832023-01-11 14:50:10 +0100123 return PSA_ERROR_NOT_SUPPORTED;
Steven Cooreman37941cb2020-07-28 18:49:51 +0200124}
125
Ronald Cron7f13fa22021-04-13 12:41:34 +0200126psa_status_t mbedtls_test_transparent_cipher_encrypt_setup(
Ronald Cron7cb9c3d2021-03-10 12:21:48 +0100127 mbedtls_transparent_test_driver_cipher_operation_t *operation,
Steven Cooreman16afd3d2020-09-09 15:36:39 +0200128 const psa_key_attributes_t *attributes,
129 const uint8_t *key, size_t key_length,
130 psa_algorithm_t alg)
131{
Ronald Cron7f13fa22021-04-13 12:41:34 +0200132 mbedtls_test_driver_cipher_hooks.hits++;
Ronald Cron8d310ad2020-12-15 15:17:20 +0100133
134 /* Wiping the entire struct here, instead of member-by-member. This is
135 * useful for the test suite, since it gives a chance of catching memory
136 * corruption errors should the core not have allocated (enough) memory for
137 * our context struct. */
Gilles Peskine449bd832023-01-11 14:50:10 +0100138 memset(operation, 0, sizeof(*operation));
Ronald Cron8d310ad2020-12-15 15:17:20 +0100139
Gilles Peskine449bd832023-01-11 14:50:10 +0100140 if (mbedtls_test_driver_cipher_hooks.forced_status != PSA_SUCCESS) {
141 return mbedtls_test_driver_cipher_hooks.forced_status;
142 }
Ronald Cron8d310ad2020-12-15 15:17:20 +0100143
Ronald Cron7975fae2021-09-13 14:50:42 +0200144#if defined(MBEDTLS_TEST_LIBTESTDRIVER1) && \
145 defined(LIBTESTDRIVER1_MBEDTLS_PSA_BUILTIN_CIPHER)
Gilles Peskine449bd832023-01-11 14:50:10 +0100146 return libtestdriver1_mbedtls_psa_cipher_encrypt_setup(
147 operation,
148 (const libtestdriver1_psa_key_attributes_t *) attributes,
149 key, key_length, alg);
Ronald Cron73c9d9e2021-04-09 11:09:54 +0200150#elif defined(MBEDTLS_PSA_BUILTIN_CIPHER)
Gilles Peskine449bd832023-01-11 14:50:10 +0100151 return mbedtls_psa_cipher_encrypt_setup(
152 operation, attributes, key, key_length, alg);
Ronald Cron73c9d9e2021-04-09 11:09:54 +0200153#endif
154
Gilles Peskine449bd832023-01-11 14:50:10 +0100155 return PSA_ERROR_NOT_SUPPORTED;
Steven Cooreman16afd3d2020-09-09 15:36:39 +0200156}
157
Ronald Cron7f13fa22021-04-13 12:41:34 +0200158psa_status_t mbedtls_test_transparent_cipher_decrypt_setup(
Ronald Cron7cb9c3d2021-03-10 12:21:48 +0100159 mbedtls_transparent_test_driver_cipher_operation_t *operation,
Steven Cooreman37941cb2020-07-28 18:49:51 +0200160 const psa_key_attributes_t *attributes,
161 const uint8_t *key, size_t key_length,
162 psa_algorithm_t alg)
163{
Ronald Cron7f13fa22021-04-13 12:41:34 +0200164 mbedtls_test_driver_cipher_hooks.hits++;
Ronald Cron8d310ad2020-12-15 15:17:20 +0100165
Gilles Peskine449bd832023-01-11 14:50:10 +0100166 if (mbedtls_test_driver_cipher_hooks.forced_status != PSA_SUCCESS) {
167 return mbedtls_test_driver_cipher_hooks.forced_status;
168 }
Ronald Cron8d310ad2020-12-15 15:17:20 +0100169
Ronald Cron7975fae2021-09-13 14:50:42 +0200170#if defined(MBEDTLS_TEST_LIBTESTDRIVER1) && \
171 defined(LIBTESTDRIVER1_MBEDTLS_PSA_BUILTIN_CIPHER)
Gilles Peskine449bd832023-01-11 14:50:10 +0100172 return libtestdriver1_mbedtls_psa_cipher_decrypt_setup(
173 operation,
174 (const libtestdriver1_psa_key_attributes_t *) attributes,
175 key, key_length, alg);
Ronald Cron73c9d9e2021-04-09 11:09:54 +0200176#elif defined(MBEDTLS_PSA_BUILTIN_CIPHER)
Gilles Peskine449bd832023-01-11 14:50:10 +0100177 return mbedtls_psa_cipher_decrypt_setup(
178 operation, attributes, key, key_length, alg);
Ronald Cron73c9d9e2021-04-09 11:09:54 +0200179#endif
180
Gilles Peskine449bd832023-01-11 14:50:10 +0100181 return PSA_ERROR_NOT_SUPPORTED;
Steven Cooreman37941cb2020-07-28 18:49:51 +0200182}
183
Ronald Cron7f13fa22021-04-13 12:41:34 +0200184psa_status_t mbedtls_test_transparent_cipher_abort(
Ronald Cron7cb9c3d2021-03-10 12:21:48 +0100185 mbedtls_transparent_test_driver_cipher_operation_t *operation)
Steven Cooreman37941cb2020-07-28 18:49:51 +0200186{
Ronald Cron7f13fa22021-04-13 12:41:34 +0200187 mbedtls_test_driver_cipher_hooks.hits++;
Steven Cooreman89e54f22020-09-10 18:07:57 +0200188
Ronald Cron7975fae2021-09-13 14:50:42 +0200189#if defined(MBEDTLS_TEST_LIBTESTDRIVER1) && \
190 defined(LIBTESTDRIVER1_MBEDTLS_PSA_BUILTIN_CIPHER)
Gilles Peskine449bd832023-01-11 14:50:10 +0100191 libtestdriver1_mbedtls_psa_cipher_abort(operation);
Ronald Cron73c9d9e2021-04-09 11:09:54 +0200192#elif defined(MBEDTLS_PSA_BUILTIN_CIPHER)
Gilles Peskine449bd832023-01-11 14:50:10 +0100193 mbedtls_psa_cipher_abort(operation);
Ronald Cron73c9d9e2021-04-09 11:09:54 +0200194#endif
Steven Cooreman8b122252020-09-03 15:30:32 +0200195
Ronald Cron8d310ad2020-12-15 15:17:20 +0100196 /* Wiping the entire struct here, instead of member-by-member. This is
197 * useful for the test suite, since it gives a chance of catching memory
198 * corruption errors should the core not have allocated (enough) memory for
199 * our context struct. */
Gilles Peskine449bd832023-01-11 14:50:10 +0100200 memset(operation, 0, sizeof(*operation));
Steven Cooreman37941cb2020-07-28 18:49:51 +0200201
Gilles Peskine449bd832023-01-11 14:50:10 +0100202 return mbedtls_test_driver_cipher_hooks.forced_status;
Steven Cooreman37941cb2020-07-28 18:49:51 +0200203}
204
Ronald Cron7f13fa22021-04-13 12:41:34 +0200205psa_status_t mbedtls_test_transparent_cipher_set_iv(
Ronald Cron7cb9c3d2021-03-10 12:21:48 +0100206 mbedtls_transparent_test_driver_cipher_operation_t *operation,
Steven Cooreman37941cb2020-07-28 18:49:51 +0200207 const uint8_t *iv,
208 size_t iv_length)
209{
Ronald Cron7f13fa22021-04-13 12:41:34 +0200210 mbedtls_test_driver_cipher_hooks.hits++;
Steven Cooreman8b122252020-09-03 15:30:32 +0200211
Gilles Peskine449bd832023-01-11 14:50:10 +0100212 if (mbedtls_test_driver_cipher_hooks.forced_status != PSA_SUCCESS) {
213 return mbedtls_test_driver_cipher_hooks.forced_status;
214 }
Steven Cooreman89e54f22020-09-10 18:07:57 +0200215
Ronald Cron7975fae2021-09-13 14:50:42 +0200216#if defined(MBEDTLS_TEST_LIBTESTDRIVER1) && \
217 defined(LIBTESTDRIVER1_MBEDTLS_PSA_BUILTIN_CIPHER)
Gilles Peskine449bd832023-01-11 14:50:10 +0100218 return libtestdriver1_mbedtls_psa_cipher_set_iv(
219 operation, iv, iv_length);
Ronald Cron73c9d9e2021-04-09 11:09:54 +0200220#elif defined(MBEDTLS_PSA_BUILTIN_CIPHER)
Gilles Peskine449bd832023-01-11 14:50:10 +0100221 return mbedtls_psa_cipher_set_iv(operation, iv, iv_length);
Ronald Cron73c9d9e2021-04-09 11:09:54 +0200222#endif
223
Gilles Peskine449bd832023-01-11 14:50:10 +0100224 return PSA_ERROR_NOT_SUPPORTED;
Steven Cooreman37941cb2020-07-28 18:49:51 +0200225}
226
Ronald Cron7f13fa22021-04-13 12:41:34 +0200227psa_status_t mbedtls_test_transparent_cipher_update(
Ronald Cron7cb9c3d2021-03-10 12:21:48 +0100228 mbedtls_transparent_test_driver_cipher_operation_t *operation,
Steven Cooreman37941cb2020-07-28 18:49:51 +0200229 const uint8_t *input,
230 size_t input_length,
231 uint8_t *output,
232 size_t output_size,
233 size_t *output_length)
234{
Ronald Cron7f13fa22021-04-13 12:41:34 +0200235 mbedtls_test_driver_cipher_hooks.hits++;
Steven Cooreman37941cb2020-07-28 18:49:51 +0200236
Gilles Peskine449bd832023-01-11 14:50:10 +0100237 if (mbedtls_test_driver_cipher_hooks.forced_output != NULL) {
238 if (output_size < mbedtls_test_driver_cipher_hooks.forced_output_length) {
Steven Cooreman8b122252020-09-03 15:30:32 +0200239 return PSA_ERROR_BUFFER_TOO_SMALL;
Gilles Peskine449bd832023-01-11 14:50:10 +0100240 }
Steven Cooreman8b122252020-09-03 15:30:32 +0200241
Gilles Peskine449bd832023-01-11 14:50:10 +0100242 memcpy(output,
243 mbedtls_test_driver_cipher_hooks.forced_output,
244 mbedtls_test_driver_cipher_hooks.forced_output_length);
Ronald Cron7f13fa22021-04-13 12:41:34 +0200245 *output_length = mbedtls_test_driver_cipher_hooks.forced_output_length;
Ronald Cron8d310ad2020-12-15 15:17:20 +0100246
Gilles Peskine449bd832023-01-11 14:50:10 +0100247 return mbedtls_test_driver_cipher_hooks.forced_status;
Steven Cooreman8b122252020-09-03 15:30:32 +0200248 }
Steven Cooreman37941cb2020-07-28 18:49:51 +0200249
Gilles Peskine449bd832023-01-11 14:50:10 +0100250 if (mbedtls_test_driver_cipher_hooks.forced_status != PSA_SUCCESS) {
251 return mbedtls_test_driver_cipher_hooks.forced_status;
252 }
Ronald Cron8d310ad2020-12-15 15:17:20 +0100253
Ronald Cron7975fae2021-09-13 14:50:42 +0200254#if defined(MBEDTLS_TEST_LIBTESTDRIVER1) && \
255 defined(LIBTESTDRIVER1_MBEDTLS_PSA_BUILTIN_CIPHER)
Gilles Peskine449bd832023-01-11 14:50:10 +0100256 return libtestdriver1_mbedtls_psa_cipher_update(
257 operation, input, input_length,
258 output, output_size, output_length);
Ronald Cron73c9d9e2021-04-09 11:09:54 +0200259#elif defined(MBEDTLS_PSA_BUILTIN_CIPHER)
Gilles Peskine449bd832023-01-11 14:50:10 +0100260 return mbedtls_psa_cipher_update(
261 operation, input, input_length,
262 output, output_size, output_length);
Ronald Cron73c9d9e2021-04-09 11:09:54 +0200263#endif
264
Gilles Peskine449bd832023-01-11 14:50:10 +0100265 return PSA_ERROR_NOT_SUPPORTED;
Steven Cooreman37941cb2020-07-28 18:49:51 +0200266}
267
Ronald Cron7f13fa22021-04-13 12:41:34 +0200268psa_status_t mbedtls_test_transparent_cipher_finish(
Ronald Cron7cb9c3d2021-03-10 12:21:48 +0100269 mbedtls_transparent_test_driver_cipher_operation_t *operation,
Steven Cooreman37941cb2020-07-28 18:49:51 +0200270 uint8_t *output,
271 size_t output_size,
272 size_t *output_length)
273{
Ronald Cron7f13fa22021-04-13 12:41:34 +0200274 mbedtls_test_driver_cipher_hooks.hits++;
Steven Cooreman37941cb2020-07-28 18:49:51 +0200275
Gilles Peskine449bd832023-01-11 14:50:10 +0100276 if (mbedtls_test_driver_cipher_hooks.forced_output != NULL) {
277 if (output_size < mbedtls_test_driver_cipher_hooks.forced_output_length) {
Steven Cooreman8b122252020-09-03 15:30:32 +0200278 return PSA_ERROR_BUFFER_TOO_SMALL;
Gilles Peskine449bd832023-01-11 14:50:10 +0100279 }
Steven Cooreman8b122252020-09-03 15:30:32 +0200280
Gilles Peskine449bd832023-01-11 14:50:10 +0100281 memcpy(output,
282 mbedtls_test_driver_cipher_hooks.forced_output,
283 mbedtls_test_driver_cipher_hooks.forced_output_length);
Ronald Cron7f13fa22021-04-13 12:41:34 +0200284 *output_length = mbedtls_test_driver_cipher_hooks.forced_output_length;
Ronald Cron8d310ad2020-12-15 15:17:20 +0100285
Gilles Peskine449bd832023-01-11 14:50:10 +0100286 return mbedtls_test_driver_cipher_hooks.forced_status;
Steven Cooreman8b122252020-09-03 15:30:32 +0200287 }
Steven Cooreman37941cb2020-07-28 18:49:51 +0200288
Gilles Peskine449bd832023-01-11 14:50:10 +0100289 if (mbedtls_test_driver_cipher_hooks.forced_status != PSA_SUCCESS) {
290 return mbedtls_test_driver_cipher_hooks.forced_status;
291 }
Ronald Cron8d310ad2020-12-15 15:17:20 +0100292
Ronald Cron7975fae2021-09-13 14:50:42 +0200293#if defined(MBEDTLS_TEST_LIBTESTDRIVER1) && \
294 defined(LIBTESTDRIVER1_MBEDTLS_PSA_BUILTIN_CIPHER)
Gilles Peskine449bd832023-01-11 14:50:10 +0100295 return libtestdriver1_mbedtls_psa_cipher_finish(
296 operation, output, output_size, output_length);
Ronald Cron73c9d9e2021-04-09 11:09:54 +0200297#elif defined(MBEDTLS_PSA_BUILTIN_CIPHER)
Gilles Peskine449bd832023-01-11 14:50:10 +0100298 return mbedtls_psa_cipher_finish(
299 operation, output, output_size, output_length);
Ronald Cron73c9d9e2021-04-09 11:09:54 +0200300#endif
301
Gilles Peskine449bd832023-01-11 14:50:10 +0100302 return PSA_ERROR_NOT_SUPPORTED;
Steven Cooreman37941cb2020-07-28 18:49:51 +0200303}
304
305/*
306 * opaque versions, to do
307 */
Ronald Cron7f13fa22021-04-13 12:41:34 +0200308psa_status_t mbedtls_test_opaque_cipher_encrypt(
Steven Cooreman37941cb2020-07-28 18:49:51 +0200309 const psa_key_attributes_t *attributes,
310 const uint8_t *key, size_t key_length,
311 psa_algorithm_t alg,
Ronald Cron9b674282021-07-09 09:19:35 +0200312 const uint8_t *iv, size_t iv_length,
Steven Cooreman37941cb2020-07-28 18:49:51 +0200313 const uint8_t *input, size_t input_length,
314 uint8_t *output, size_t output_size, size_t *output_length)
315{
316 (void) attributes;
317 (void) key;
318 (void) key_length;
319 (void) alg;
Ronald Cron9b674282021-07-09 09:19:35 +0200320 (void) iv;
321 (void) iv_length;
Steven Cooreman37941cb2020-07-28 18:49:51 +0200322 (void) input;
323 (void) input_length;
324 (void) output;
325 (void) output_size;
326 (void) output_length;
Gilles Peskine449bd832023-01-11 14:50:10 +0100327 return PSA_ERROR_NOT_SUPPORTED;
Steven Cooreman37941cb2020-07-28 18:49:51 +0200328}
329
Ronald Cron7f13fa22021-04-13 12:41:34 +0200330psa_status_t mbedtls_test_opaque_cipher_decrypt(
Steven Cooreman37941cb2020-07-28 18:49:51 +0200331 const psa_key_attributes_t *attributes,
332 const uint8_t *key, size_t key_length,
333 psa_algorithm_t alg,
334 const uint8_t *input, size_t input_length,
335 uint8_t *output, size_t output_size, size_t *output_length)
336{
337 (void) attributes;
338 (void) key;
339 (void) key_length;
340 (void) alg;
341 (void) input;
342 (void) input_length;
343 (void) output;
344 (void) output_size;
345 (void) output_length;
Gilles Peskine449bd832023-01-11 14:50:10 +0100346 return PSA_ERROR_NOT_SUPPORTED;
Steven Cooreman37941cb2020-07-28 18:49:51 +0200347}
348
Ronald Cron7f13fa22021-04-13 12:41:34 +0200349psa_status_t mbedtls_test_opaque_cipher_encrypt_setup(
Ronald Cron7cb9c3d2021-03-10 12:21:48 +0100350 mbedtls_opaque_test_driver_cipher_operation_t *operation,
Steven Cooreman37941cb2020-07-28 18:49:51 +0200351 const psa_key_attributes_t *attributes,
352 const uint8_t *key, size_t key_length,
353 psa_algorithm_t alg)
354{
355 (void) operation;
356 (void) attributes;
357 (void) key;
358 (void) key_length;
359 (void) alg;
Gilles Peskine449bd832023-01-11 14:50:10 +0100360 return PSA_ERROR_NOT_SUPPORTED;
Steven Cooreman37941cb2020-07-28 18:49:51 +0200361}
362
Ronald Cron7f13fa22021-04-13 12:41:34 +0200363psa_status_t mbedtls_test_opaque_cipher_decrypt_setup(
Ronald Cron7cb9c3d2021-03-10 12:21:48 +0100364 mbedtls_opaque_test_driver_cipher_operation_t *operation,
Steven Cooreman37941cb2020-07-28 18:49:51 +0200365 const psa_key_attributes_t *attributes,
366 const uint8_t *key, size_t key_length,
367 psa_algorithm_t alg)
368{
369 (void) operation;
370 (void) attributes;
371 (void) key;
372 (void) key_length;
373 (void) alg;
Gilles Peskine449bd832023-01-11 14:50:10 +0100374 return PSA_ERROR_NOT_SUPPORTED;
Steven Cooreman37941cb2020-07-28 18:49:51 +0200375}
376
Ronald Cron7f13fa22021-04-13 12:41:34 +0200377psa_status_t mbedtls_test_opaque_cipher_abort(
Gilles Peskine449bd832023-01-11 14:50:10 +0100378 mbedtls_opaque_test_driver_cipher_operation_t *operation)
Steven Cooreman37941cb2020-07-28 18:49:51 +0200379{
380 (void) operation;
Gilles Peskine449bd832023-01-11 14:50:10 +0100381 return PSA_ERROR_NOT_SUPPORTED;
Steven Cooreman37941cb2020-07-28 18:49:51 +0200382}
383
Ronald Cron7f13fa22021-04-13 12:41:34 +0200384psa_status_t mbedtls_test_opaque_cipher_set_iv(
Ronald Cron7cb9c3d2021-03-10 12:21:48 +0100385 mbedtls_opaque_test_driver_cipher_operation_t *operation,
Steven Cooreman37941cb2020-07-28 18:49:51 +0200386 const uint8_t *iv,
387 size_t iv_length)
388{
389 (void) operation;
390 (void) iv;
391 (void) iv_length;
Gilles Peskine449bd832023-01-11 14:50:10 +0100392 return PSA_ERROR_NOT_SUPPORTED;
Steven Cooreman37941cb2020-07-28 18:49:51 +0200393}
394
Ronald Cron7f13fa22021-04-13 12:41:34 +0200395psa_status_t mbedtls_test_opaque_cipher_update(
Ronald Cron7cb9c3d2021-03-10 12:21:48 +0100396 mbedtls_opaque_test_driver_cipher_operation_t *operation,
Steven Cooreman37941cb2020-07-28 18:49:51 +0200397 const uint8_t *input,
398 size_t input_length,
399 uint8_t *output,
400 size_t output_size,
401 size_t *output_length)
402{
403 (void) operation;
404 (void) input;
405 (void) input_length;
406 (void) output;
407 (void) output_size;
408 (void) output_length;
Gilles Peskine449bd832023-01-11 14:50:10 +0100409 return PSA_ERROR_NOT_SUPPORTED;
Steven Cooreman37941cb2020-07-28 18:49:51 +0200410}
411
Ronald Cron7f13fa22021-04-13 12:41:34 +0200412psa_status_t mbedtls_test_opaque_cipher_finish(
Ronald Cron7cb9c3d2021-03-10 12:21:48 +0100413 mbedtls_opaque_test_driver_cipher_operation_t *operation,
Steven Cooreman37941cb2020-07-28 18:49:51 +0200414 uint8_t *output,
415 size_t output_size,
416 size_t *output_length)
417{
418 (void) operation;
419 (void) output;
420 (void) output_size;
421 (void) output_length;
Gilles Peskine449bd832023-01-11 14:50:10 +0100422 return PSA_ERROR_NOT_SUPPORTED;
Steven Cooreman37941cb2020-07-28 18:49:51 +0200423}
Ronald Crone6e6b752023-01-16 16:56:51 +0100424#endif /* PSA_CRYPTO_DRIVER_TEST */