blob: 324590c0af21f57b3b0e8422c79b886e38a049fe [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++;
Valerio Setti6ef82ae2023-11-13 10:32:34 +010044 mbedtls_test_driver_cipher_hooks.cipher_encrypt_hits++;
Steven Cooremanfe0ab552020-09-10 13:07:02 +020045
Gilles Peskine449bd832023-01-11 14:50:10 +010046 if (mbedtls_test_driver_cipher_hooks.forced_output != NULL) {
47 if (output_size < mbedtls_test_driver_cipher_hooks.forced_output_length) {
48 return PSA_ERROR_BUFFER_TOO_SMALL;
49 }
Steven Cooremanfe0ab552020-09-10 13:07:02 +020050
Gilles Peskine449bd832023-01-11 14:50:10 +010051 memcpy(output,
52 mbedtls_test_driver_cipher_hooks.forced_output,
53 mbedtls_test_driver_cipher_hooks.forced_output_length);
Ronald Cron7f13fa22021-04-13 12:41:34 +020054 *output_length = mbedtls_test_driver_cipher_hooks.forced_output_length;
Steven Cooremanfe0ab552020-09-10 13:07:02 +020055
Gilles Peskine449bd832023-01-11 14:50:10 +010056 return mbedtls_test_driver_cipher_hooks.forced_status;
Steven Cooremanfe0ab552020-09-10 13:07:02 +020057 }
58
Gilles Peskine449bd832023-01-11 14:50:10 +010059 if (mbedtls_test_driver_cipher_hooks.forced_status != PSA_SUCCESS) {
60 return mbedtls_test_driver_cipher_hooks.forced_status;
61 }
Steven Cooremanfe0ab552020-09-10 13:07:02 +020062
Ronald Cron7975fae2021-09-13 14:50:42 +020063#if defined(MBEDTLS_TEST_LIBTESTDRIVER1) && \
64 defined(LIBTESTDRIVER1_MBEDTLS_PSA_BUILTIN_CIPHER)
Gilles Peskine449bd832023-01-11 14:50:10 +010065 return libtestdriver1_mbedtls_psa_cipher_encrypt(
66 (const libtestdriver1_psa_key_attributes_t *) attributes,
67 key_buffer, key_buffer_size,
68 alg, iv, iv_length, input, input_length,
69 output, output_size, output_length);
Ronald Cron73c9d9e2021-04-09 11:09:54 +020070#elif defined(MBEDTLS_PSA_BUILTIN_CIPHER)
Gilles Peskine449bd832023-01-11 14:50:10 +010071 return mbedtls_psa_cipher_encrypt(
72 attributes, key_buffer, key_buffer_size,
73 alg, iv, iv_length, input, input_length,
74 output, output_size, output_length);
Ronald Cron73c9d9e2021-04-09 11:09:54 +020075#endif
76
Gilles Peskine449bd832023-01-11 14:50:10 +010077 return PSA_ERROR_NOT_SUPPORTED;
Steven Cooreman37941cb2020-07-28 18:49:51 +020078}
79
Ronald Cron7f13fa22021-04-13 12:41:34 +020080psa_status_t mbedtls_test_transparent_cipher_decrypt(
Steven Cooreman37941cb2020-07-28 18:49:51 +020081 const psa_key_attributes_t *attributes,
gabor-mezei-arma9449a02021-03-25 11:17:10 +010082 const uint8_t *key_buffer,
83 size_t key_buffer_size,
Steven Cooreman37941cb2020-07-28 18:49:51 +020084 psa_algorithm_t alg,
gabor-mezei-arma9449a02021-03-25 11:17:10 +010085 const uint8_t *input,
86 size_t input_length,
87 uint8_t *output,
88 size_t output_size,
Gilles Peskine449bd832023-01-11 14:50:10 +010089 size_t *output_length)
Steven Cooreman37941cb2020-07-28 18:49:51 +020090{
Gilles Peskine449bd832023-01-11 14:50:10 +010091 mbedtls_test_driver_cipher_hooks.hits++;
gabor-mezei-arma9449a02021-03-25 11:17:10 +010092
Gilles Peskine449bd832023-01-11 14:50:10 +010093 if (mbedtls_test_driver_cipher_hooks.forced_output != NULL) {
94 if (output_size < mbedtls_test_driver_cipher_hooks.forced_output_length) {
95 return PSA_ERROR_BUFFER_TOO_SMALL;
96 }
gabor-mezei-arma9449a02021-03-25 11:17:10 +010097
Gilles Peskine449bd832023-01-11 14:50:10 +010098 memcpy(output,
99 mbedtls_test_driver_cipher_hooks.forced_output,
100 mbedtls_test_driver_cipher_hooks.forced_output_length);
gabor-mezei-arma9449a02021-03-25 11:17:10 +0100101 *output_length = mbedtls_test_driver_cipher_hooks.forced_output_length;
102
Gilles Peskine449bd832023-01-11 14:50:10 +0100103 return mbedtls_test_driver_cipher_hooks.forced_status;
gabor-mezei-arma9449a02021-03-25 11:17:10 +0100104 }
105
Gilles Peskine449bd832023-01-11 14:50:10 +0100106 if (mbedtls_test_driver_cipher_hooks.forced_status != PSA_SUCCESS) {
107 return mbedtls_test_driver_cipher_hooks.forced_status;
108 }
gabor-mezei-arma9449a02021-03-25 11:17:10 +0100109
Ronald Cron7975fae2021-09-13 14:50:42 +0200110#if defined(MBEDTLS_TEST_LIBTESTDRIVER1) && \
111 defined(LIBTESTDRIVER1_MBEDTLS_PSA_BUILTIN_CIPHER)
Gilles Peskine449bd832023-01-11 14:50:10 +0100112 return libtestdriver1_mbedtls_psa_cipher_decrypt(
113 (const libtestdriver1_psa_key_attributes_t *) attributes,
114 key_buffer, key_buffer_size,
115 alg, input, input_length,
116 output, output_size, output_length);
Ronald Cron73c9d9e2021-04-09 11:09:54 +0200117#elif defined(MBEDTLS_PSA_BUILTIN_CIPHER)
Gilles Peskine449bd832023-01-11 14:50:10 +0100118 return mbedtls_psa_cipher_decrypt(
119 attributes, key_buffer, key_buffer_size,
120 alg, input, input_length,
121 output, output_size, output_length);
Ronald Cron73c9d9e2021-04-09 11:09:54 +0200122#endif
123
Gilles Peskine449bd832023-01-11 14:50:10 +0100124 return PSA_ERROR_NOT_SUPPORTED;
Steven Cooreman37941cb2020-07-28 18:49:51 +0200125}
126
Ronald Cron7f13fa22021-04-13 12:41:34 +0200127psa_status_t mbedtls_test_transparent_cipher_encrypt_setup(
Ronald Cron7cb9c3d2021-03-10 12:21:48 +0100128 mbedtls_transparent_test_driver_cipher_operation_t *operation,
Steven Cooreman16afd3d2020-09-09 15:36:39 +0200129 const psa_key_attributes_t *attributes,
130 const uint8_t *key, size_t key_length,
131 psa_algorithm_t alg)
132{
Ronald Cron7f13fa22021-04-13 12:41:34 +0200133 mbedtls_test_driver_cipher_hooks.hits++;
Ronald Cron8d310ad2020-12-15 15:17:20 +0100134
135 /* Wiping the entire struct here, instead of member-by-member. This is
136 * useful for the test suite, since it gives a chance of catching memory
137 * corruption errors should the core not have allocated (enough) memory for
138 * our context struct. */
Gilles Peskine449bd832023-01-11 14:50:10 +0100139 memset(operation, 0, sizeof(*operation));
Ronald Cron8d310ad2020-12-15 15:17:20 +0100140
Gilles Peskine449bd832023-01-11 14:50:10 +0100141 if (mbedtls_test_driver_cipher_hooks.forced_status != PSA_SUCCESS) {
142 return mbedtls_test_driver_cipher_hooks.forced_status;
143 }
Ronald Cron8d310ad2020-12-15 15:17:20 +0100144
Ronald Cron7975fae2021-09-13 14:50:42 +0200145#if defined(MBEDTLS_TEST_LIBTESTDRIVER1) && \
146 defined(LIBTESTDRIVER1_MBEDTLS_PSA_BUILTIN_CIPHER)
Gilles Peskine449bd832023-01-11 14:50:10 +0100147 return libtestdriver1_mbedtls_psa_cipher_encrypt_setup(
148 operation,
149 (const libtestdriver1_psa_key_attributes_t *) attributes,
150 key, key_length, alg);
Ronald Cron73c9d9e2021-04-09 11:09:54 +0200151#elif defined(MBEDTLS_PSA_BUILTIN_CIPHER)
Gilles Peskine449bd832023-01-11 14:50:10 +0100152 return mbedtls_psa_cipher_encrypt_setup(
153 operation, attributes, key, key_length, alg);
Ronald Cron73c9d9e2021-04-09 11:09:54 +0200154#endif
155
Gilles Peskine449bd832023-01-11 14:50:10 +0100156 return PSA_ERROR_NOT_SUPPORTED;
Steven Cooreman16afd3d2020-09-09 15:36:39 +0200157}
158
Ronald Cron7f13fa22021-04-13 12:41:34 +0200159psa_status_t mbedtls_test_transparent_cipher_decrypt_setup(
Ronald Cron7cb9c3d2021-03-10 12:21:48 +0100160 mbedtls_transparent_test_driver_cipher_operation_t *operation,
Steven Cooreman37941cb2020-07-28 18:49:51 +0200161 const psa_key_attributes_t *attributes,
162 const uint8_t *key, size_t key_length,
163 psa_algorithm_t alg)
164{
Ronald Cron7f13fa22021-04-13 12:41:34 +0200165 mbedtls_test_driver_cipher_hooks.hits++;
Ronald Cron8d310ad2020-12-15 15:17:20 +0100166
Gilles Peskine449bd832023-01-11 14:50:10 +0100167 if (mbedtls_test_driver_cipher_hooks.forced_status != PSA_SUCCESS) {
168 return mbedtls_test_driver_cipher_hooks.forced_status;
169 }
Ronald Cron8d310ad2020-12-15 15:17:20 +0100170
Ronald Cron7975fae2021-09-13 14:50:42 +0200171#if defined(MBEDTLS_TEST_LIBTESTDRIVER1) && \
172 defined(LIBTESTDRIVER1_MBEDTLS_PSA_BUILTIN_CIPHER)
Gilles Peskine449bd832023-01-11 14:50:10 +0100173 return libtestdriver1_mbedtls_psa_cipher_decrypt_setup(
174 operation,
175 (const libtestdriver1_psa_key_attributes_t *) attributes,
176 key, key_length, alg);
Ronald Cron73c9d9e2021-04-09 11:09:54 +0200177#elif defined(MBEDTLS_PSA_BUILTIN_CIPHER)
Gilles Peskine449bd832023-01-11 14:50:10 +0100178 return mbedtls_psa_cipher_decrypt_setup(
179 operation, attributes, key, key_length, alg);
Ronald Cron73c9d9e2021-04-09 11:09:54 +0200180#endif
181
Gilles Peskine449bd832023-01-11 14:50:10 +0100182 return PSA_ERROR_NOT_SUPPORTED;
Steven Cooreman37941cb2020-07-28 18:49:51 +0200183}
184
Ronald Cron7f13fa22021-04-13 12:41:34 +0200185psa_status_t mbedtls_test_transparent_cipher_abort(
Ronald Cron7cb9c3d2021-03-10 12:21:48 +0100186 mbedtls_transparent_test_driver_cipher_operation_t *operation)
Steven Cooreman37941cb2020-07-28 18:49:51 +0200187{
Ronald Cron7f13fa22021-04-13 12:41:34 +0200188 mbedtls_test_driver_cipher_hooks.hits++;
Steven Cooreman89e54f22020-09-10 18:07:57 +0200189
Ronald Cron7975fae2021-09-13 14:50:42 +0200190#if defined(MBEDTLS_TEST_LIBTESTDRIVER1) && \
191 defined(LIBTESTDRIVER1_MBEDTLS_PSA_BUILTIN_CIPHER)
Gilles Peskine449bd832023-01-11 14:50:10 +0100192 libtestdriver1_mbedtls_psa_cipher_abort(operation);
Ronald Cron73c9d9e2021-04-09 11:09:54 +0200193#elif defined(MBEDTLS_PSA_BUILTIN_CIPHER)
Gilles Peskine449bd832023-01-11 14:50:10 +0100194 mbedtls_psa_cipher_abort(operation);
Ronald Cron73c9d9e2021-04-09 11:09:54 +0200195#endif
Steven Cooreman8b122252020-09-03 15:30:32 +0200196
Ronald Cron8d310ad2020-12-15 15:17:20 +0100197 /* Wiping the entire struct here, instead of member-by-member. This is
198 * useful for the test suite, since it gives a chance of catching memory
199 * corruption errors should the core not have allocated (enough) memory for
200 * our context struct. */
Gilles Peskine449bd832023-01-11 14:50:10 +0100201 memset(operation, 0, sizeof(*operation));
Steven Cooreman37941cb2020-07-28 18:49:51 +0200202
Gilles Peskine449bd832023-01-11 14:50:10 +0100203 return mbedtls_test_driver_cipher_hooks.forced_status;
Steven Cooreman37941cb2020-07-28 18:49:51 +0200204}
205
Ronald Cron7f13fa22021-04-13 12:41:34 +0200206psa_status_t mbedtls_test_transparent_cipher_set_iv(
Ronald Cron7cb9c3d2021-03-10 12:21:48 +0100207 mbedtls_transparent_test_driver_cipher_operation_t *operation,
Steven Cooreman37941cb2020-07-28 18:49:51 +0200208 const uint8_t *iv,
209 size_t iv_length)
210{
Ronald Cron7f13fa22021-04-13 12:41:34 +0200211 mbedtls_test_driver_cipher_hooks.hits++;
Steven Cooreman8b122252020-09-03 15:30:32 +0200212
Gilles Peskine449bd832023-01-11 14:50:10 +0100213 if (mbedtls_test_driver_cipher_hooks.forced_status != PSA_SUCCESS) {
214 return mbedtls_test_driver_cipher_hooks.forced_status;
215 }
Steven Cooreman89e54f22020-09-10 18:07:57 +0200216
Ronald Cron7975fae2021-09-13 14:50:42 +0200217#if defined(MBEDTLS_TEST_LIBTESTDRIVER1) && \
218 defined(LIBTESTDRIVER1_MBEDTLS_PSA_BUILTIN_CIPHER)
Gilles Peskine449bd832023-01-11 14:50:10 +0100219 return libtestdriver1_mbedtls_psa_cipher_set_iv(
220 operation, iv, iv_length);
Ronald Cron73c9d9e2021-04-09 11:09:54 +0200221#elif defined(MBEDTLS_PSA_BUILTIN_CIPHER)
Gilles Peskine449bd832023-01-11 14:50:10 +0100222 return mbedtls_psa_cipher_set_iv(operation, iv, iv_length);
Ronald Cron73c9d9e2021-04-09 11:09:54 +0200223#endif
224
Gilles Peskine449bd832023-01-11 14:50:10 +0100225 return PSA_ERROR_NOT_SUPPORTED;
Steven Cooreman37941cb2020-07-28 18:49:51 +0200226}
227
Ronald Cron7f13fa22021-04-13 12:41:34 +0200228psa_status_t mbedtls_test_transparent_cipher_update(
Ronald Cron7cb9c3d2021-03-10 12:21:48 +0100229 mbedtls_transparent_test_driver_cipher_operation_t *operation,
Steven Cooreman37941cb2020-07-28 18:49:51 +0200230 const uint8_t *input,
231 size_t input_length,
232 uint8_t *output,
233 size_t output_size,
234 size_t *output_length)
235{
Ronald Cron7f13fa22021-04-13 12:41:34 +0200236 mbedtls_test_driver_cipher_hooks.hits++;
Steven Cooreman37941cb2020-07-28 18:49:51 +0200237
Gilles Peskine449bd832023-01-11 14:50:10 +0100238 if (mbedtls_test_driver_cipher_hooks.forced_output != NULL) {
239 if (output_size < mbedtls_test_driver_cipher_hooks.forced_output_length) {
Steven Cooreman8b122252020-09-03 15:30:32 +0200240 return PSA_ERROR_BUFFER_TOO_SMALL;
Gilles Peskine449bd832023-01-11 14:50:10 +0100241 }
Steven Cooreman8b122252020-09-03 15:30:32 +0200242
Gilles Peskine449bd832023-01-11 14:50:10 +0100243 memcpy(output,
244 mbedtls_test_driver_cipher_hooks.forced_output,
245 mbedtls_test_driver_cipher_hooks.forced_output_length);
Ronald Cron7f13fa22021-04-13 12:41:34 +0200246 *output_length = mbedtls_test_driver_cipher_hooks.forced_output_length;
Ronald Cron8d310ad2020-12-15 15:17:20 +0100247
Gilles Peskine449bd832023-01-11 14:50:10 +0100248 return mbedtls_test_driver_cipher_hooks.forced_status;
Steven Cooreman8b122252020-09-03 15:30:32 +0200249 }
Steven Cooreman37941cb2020-07-28 18:49:51 +0200250
Gilles Peskine449bd832023-01-11 14:50:10 +0100251 if (mbedtls_test_driver_cipher_hooks.forced_status != PSA_SUCCESS) {
252 return mbedtls_test_driver_cipher_hooks.forced_status;
253 }
Ronald Cron8d310ad2020-12-15 15:17:20 +0100254
Ronald Cron7975fae2021-09-13 14:50:42 +0200255#if defined(MBEDTLS_TEST_LIBTESTDRIVER1) && \
256 defined(LIBTESTDRIVER1_MBEDTLS_PSA_BUILTIN_CIPHER)
Gilles Peskine449bd832023-01-11 14:50:10 +0100257 return libtestdriver1_mbedtls_psa_cipher_update(
258 operation, input, input_length,
259 output, output_size, output_length);
Ronald Cron73c9d9e2021-04-09 11:09:54 +0200260#elif defined(MBEDTLS_PSA_BUILTIN_CIPHER)
Gilles Peskine449bd832023-01-11 14:50:10 +0100261 return mbedtls_psa_cipher_update(
262 operation, input, input_length,
263 output, output_size, output_length);
Ronald Cron73c9d9e2021-04-09 11:09:54 +0200264#endif
265
Gilles Peskine449bd832023-01-11 14:50:10 +0100266 return PSA_ERROR_NOT_SUPPORTED;
Steven Cooreman37941cb2020-07-28 18:49:51 +0200267}
268
Ronald Cron7f13fa22021-04-13 12:41:34 +0200269psa_status_t mbedtls_test_transparent_cipher_finish(
Ronald Cron7cb9c3d2021-03-10 12:21:48 +0100270 mbedtls_transparent_test_driver_cipher_operation_t *operation,
Steven Cooreman37941cb2020-07-28 18:49:51 +0200271 uint8_t *output,
272 size_t output_size,
273 size_t *output_length)
274{
Ronald Cron7f13fa22021-04-13 12:41:34 +0200275 mbedtls_test_driver_cipher_hooks.hits++;
Steven Cooreman37941cb2020-07-28 18:49:51 +0200276
Gilles Peskine449bd832023-01-11 14:50:10 +0100277 if (mbedtls_test_driver_cipher_hooks.forced_output != NULL) {
278 if (output_size < mbedtls_test_driver_cipher_hooks.forced_output_length) {
Steven Cooreman8b122252020-09-03 15:30:32 +0200279 return PSA_ERROR_BUFFER_TOO_SMALL;
Gilles Peskine449bd832023-01-11 14:50:10 +0100280 }
Steven Cooreman8b122252020-09-03 15:30:32 +0200281
Gilles Peskine449bd832023-01-11 14:50:10 +0100282 memcpy(output,
283 mbedtls_test_driver_cipher_hooks.forced_output,
284 mbedtls_test_driver_cipher_hooks.forced_output_length);
Ronald Cron7f13fa22021-04-13 12:41:34 +0200285 *output_length = mbedtls_test_driver_cipher_hooks.forced_output_length;
Ronald Cron8d310ad2020-12-15 15:17:20 +0100286
Gilles Peskine449bd832023-01-11 14:50:10 +0100287 return mbedtls_test_driver_cipher_hooks.forced_status;
Steven Cooreman8b122252020-09-03 15:30:32 +0200288 }
Steven Cooreman37941cb2020-07-28 18:49:51 +0200289
Gilles Peskine449bd832023-01-11 14:50:10 +0100290 if (mbedtls_test_driver_cipher_hooks.forced_status != PSA_SUCCESS) {
291 return mbedtls_test_driver_cipher_hooks.forced_status;
292 }
Ronald Cron8d310ad2020-12-15 15:17:20 +0100293
Ronald Cron7975fae2021-09-13 14:50:42 +0200294#if defined(MBEDTLS_TEST_LIBTESTDRIVER1) && \
295 defined(LIBTESTDRIVER1_MBEDTLS_PSA_BUILTIN_CIPHER)
Gilles Peskine449bd832023-01-11 14:50:10 +0100296 return libtestdriver1_mbedtls_psa_cipher_finish(
297 operation, output, output_size, output_length);
Ronald Cron73c9d9e2021-04-09 11:09:54 +0200298#elif defined(MBEDTLS_PSA_BUILTIN_CIPHER)
Gilles Peskine449bd832023-01-11 14:50:10 +0100299 return mbedtls_psa_cipher_finish(
300 operation, output, output_size, output_length);
Ronald Cron73c9d9e2021-04-09 11:09:54 +0200301#endif
302
Gilles Peskine449bd832023-01-11 14:50:10 +0100303 return PSA_ERROR_NOT_SUPPORTED;
Steven Cooreman37941cb2020-07-28 18:49:51 +0200304}
305
306/*
307 * opaque versions, to do
308 */
Ronald Cron7f13fa22021-04-13 12:41:34 +0200309psa_status_t mbedtls_test_opaque_cipher_encrypt(
Steven Cooreman37941cb2020-07-28 18:49:51 +0200310 const psa_key_attributes_t *attributes,
311 const uint8_t *key, size_t key_length,
312 psa_algorithm_t alg,
Ronald Cron9b674282021-07-09 09:19:35 +0200313 const uint8_t *iv, size_t iv_length,
Steven Cooreman37941cb2020-07-28 18:49:51 +0200314 const uint8_t *input, size_t input_length,
315 uint8_t *output, size_t output_size, size_t *output_length)
316{
317 (void) attributes;
318 (void) key;
319 (void) key_length;
320 (void) alg;
Ronald Cron9b674282021-07-09 09:19:35 +0200321 (void) iv;
322 (void) iv_length;
Steven Cooreman37941cb2020-07-28 18:49:51 +0200323 (void) input;
324 (void) input_length;
325 (void) output;
326 (void) output_size;
327 (void) output_length;
Gilles Peskine449bd832023-01-11 14:50:10 +0100328 return PSA_ERROR_NOT_SUPPORTED;
Steven Cooreman37941cb2020-07-28 18:49:51 +0200329}
330
Ronald Cron7f13fa22021-04-13 12:41:34 +0200331psa_status_t mbedtls_test_opaque_cipher_decrypt(
Steven Cooreman37941cb2020-07-28 18:49:51 +0200332 const psa_key_attributes_t *attributes,
333 const uint8_t *key, size_t key_length,
334 psa_algorithm_t alg,
335 const uint8_t *input, size_t input_length,
336 uint8_t *output, size_t output_size, size_t *output_length)
337{
338 (void) attributes;
339 (void) key;
340 (void) key_length;
341 (void) alg;
342 (void) input;
343 (void) input_length;
344 (void) output;
345 (void) output_size;
346 (void) output_length;
Gilles Peskine449bd832023-01-11 14:50:10 +0100347 return PSA_ERROR_NOT_SUPPORTED;
Steven Cooreman37941cb2020-07-28 18:49:51 +0200348}
349
Ronald Cron7f13fa22021-04-13 12:41:34 +0200350psa_status_t mbedtls_test_opaque_cipher_encrypt_setup(
Ronald Cron7cb9c3d2021-03-10 12:21:48 +0100351 mbedtls_opaque_test_driver_cipher_operation_t *operation,
Steven Cooreman37941cb2020-07-28 18:49:51 +0200352 const psa_key_attributes_t *attributes,
353 const uint8_t *key, size_t key_length,
354 psa_algorithm_t alg)
355{
356 (void) operation;
357 (void) attributes;
358 (void) key;
359 (void) key_length;
360 (void) alg;
Gilles Peskine449bd832023-01-11 14:50:10 +0100361 return PSA_ERROR_NOT_SUPPORTED;
Steven Cooreman37941cb2020-07-28 18:49:51 +0200362}
363
Ronald Cron7f13fa22021-04-13 12:41:34 +0200364psa_status_t mbedtls_test_opaque_cipher_decrypt_setup(
Ronald Cron7cb9c3d2021-03-10 12:21:48 +0100365 mbedtls_opaque_test_driver_cipher_operation_t *operation,
Steven Cooreman37941cb2020-07-28 18:49:51 +0200366 const psa_key_attributes_t *attributes,
367 const uint8_t *key, size_t key_length,
368 psa_algorithm_t alg)
369{
370 (void) operation;
371 (void) attributes;
372 (void) key;
373 (void) key_length;
374 (void) alg;
Gilles Peskine449bd832023-01-11 14:50:10 +0100375 return PSA_ERROR_NOT_SUPPORTED;
Steven Cooreman37941cb2020-07-28 18:49:51 +0200376}
377
Ronald Cron7f13fa22021-04-13 12:41:34 +0200378psa_status_t mbedtls_test_opaque_cipher_abort(
Gilles Peskine449bd832023-01-11 14:50:10 +0100379 mbedtls_opaque_test_driver_cipher_operation_t *operation)
Steven Cooreman37941cb2020-07-28 18:49:51 +0200380{
381 (void) operation;
Gilles Peskine449bd832023-01-11 14:50:10 +0100382 return PSA_ERROR_NOT_SUPPORTED;
Steven Cooreman37941cb2020-07-28 18:49:51 +0200383}
384
Ronald Cron7f13fa22021-04-13 12:41:34 +0200385psa_status_t mbedtls_test_opaque_cipher_set_iv(
Ronald Cron7cb9c3d2021-03-10 12:21:48 +0100386 mbedtls_opaque_test_driver_cipher_operation_t *operation,
Steven Cooreman37941cb2020-07-28 18:49:51 +0200387 const uint8_t *iv,
388 size_t iv_length)
389{
390 (void) operation;
391 (void) iv;
392 (void) iv_length;
Gilles Peskine449bd832023-01-11 14:50:10 +0100393 return PSA_ERROR_NOT_SUPPORTED;
Steven Cooreman37941cb2020-07-28 18:49:51 +0200394}
395
Ronald Cron7f13fa22021-04-13 12:41:34 +0200396psa_status_t mbedtls_test_opaque_cipher_update(
Ronald Cron7cb9c3d2021-03-10 12:21:48 +0100397 mbedtls_opaque_test_driver_cipher_operation_t *operation,
Steven Cooreman37941cb2020-07-28 18:49:51 +0200398 const uint8_t *input,
399 size_t input_length,
400 uint8_t *output,
401 size_t output_size,
402 size_t *output_length)
403{
404 (void) operation;
405 (void) input;
406 (void) input_length;
407 (void) output;
408 (void) output_size;
409 (void) output_length;
Gilles Peskine449bd832023-01-11 14:50:10 +0100410 return PSA_ERROR_NOT_SUPPORTED;
Steven Cooreman37941cb2020-07-28 18:49:51 +0200411}
412
Ronald Cron7f13fa22021-04-13 12:41:34 +0200413psa_status_t mbedtls_test_opaque_cipher_finish(
Ronald Cron7cb9c3d2021-03-10 12:21:48 +0100414 mbedtls_opaque_test_driver_cipher_operation_t *operation,
Steven Cooreman37941cb2020-07-28 18:49:51 +0200415 uint8_t *output,
416 size_t output_size,
417 size_t *output_length)
418{
419 (void) operation;
420 (void) output;
421 (void) output_size;
422 (void) output_length;
Gilles Peskine449bd832023-01-11 14:50:10 +0100423 return PSA_ERROR_NOT_SUPPORTED;
Steven Cooreman37941cb2020-07-28 18:49:51 +0200424}
Ronald Crone6e6b752023-01-16 16:56:51 +0100425#endif /* PSA_CRYPTO_DRIVER_TEST */