blob: b9da5d244209030d54cd568d230ebc214d5adcae [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) {
Valerio Setti7ef35a92023-11-24 12:51:42 +0100252 ++mbedtls_test_driver_cipher_hooks.cipher_update_forced_status_hits;
Gilles Peskine449bd832023-01-11 14:50:10 +0100253 return mbedtls_test_driver_cipher_hooks.forced_status;
254 }
Ronald Cron8d310ad2020-12-15 15:17:20 +0100255
Ronald Cron7975fae2021-09-13 14:50:42 +0200256#if defined(MBEDTLS_TEST_LIBTESTDRIVER1) && \
257 defined(LIBTESTDRIVER1_MBEDTLS_PSA_BUILTIN_CIPHER)
Gilles Peskine449bd832023-01-11 14:50:10 +0100258 return libtestdriver1_mbedtls_psa_cipher_update(
259 operation, input, input_length,
260 output, output_size, output_length);
Ronald Cron73c9d9e2021-04-09 11:09:54 +0200261#elif defined(MBEDTLS_PSA_BUILTIN_CIPHER)
Gilles Peskine449bd832023-01-11 14:50:10 +0100262 return mbedtls_psa_cipher_update(
263 operation, input, input_length,
264 output, output_size, output_length);
Ronald Cron73c9d9e2021-04-09 11:09:54 +0200265#endif
266
Gilles Peskine449bd832023-01-11 14:50:10 +0100267 return PSA_ERROR_NOT_SUPPORTED;
Steven Cooreman37941cb2020-07-28 18:49:51 +0200268}
269
Ronald Cron7f13fa22021-04-13 12:41:34 +0200270psa_status_t mbedtls_test_transparent_cipher_finish(
Ronald Cron7cb9c3d2021-03-10 12:21:48 +0100271 mbedtls_transparent_test_driver_cipher_operation_t *operation,
Steven Cooreman37941cb2020-07-28 18:49:51 +0200272 uint8_t *output,
273 size_t output_size,
274 size_t *output_length)
275{
Ronald Cron7f13fa22021-04-13 12:41:34 +0200276 mbedtls_test_driver_cipher_hooks.hits++;
Steven Cooreman37941cb2020-07-28 18:49:51 +0200277
Gilles Peskine449bd832023-01-11 14:50:10 +0100278 if (mbedtls_test_driver_cipher_hooks.forced_output != NULL) {
279 if (output_size < mbedtls_test_driver_cipher_hooks.forced_output_length) {
Steven Cooreman8b122252020-09-03 15:30:32 +0200280 return PSA_ERROR_BUFFER_TOO_SMALL;
Gilles Peskine449bd832023-01-11 14:50:10 +0100281 }
Steven Cooreman8b122252020-09-03 15:30:32 +0200282
Gilles Peskine449bd832023-01-11 14:50:10 +0100283 memcpy(output,
284 mbedtls_test_driver_cipher_hooks.forced_output,
285 mbedtls_test_driver_cipher_hooks.forced_output_length);
Ronald Cron7f13fa22021-04-13 12:41:34 +0200286 *output_length = mbedtls_test_driver_cipher_hooks.forced_output_length;
Ronald Cron8d310ad2020-12-15 15:17:20 +0100287
Gilles Peskine449bd832023-01-11 14:50:10 +0100288 return mbedtls_test_driver_cipher_hooks.forced_status;
Steven Cooreman8b122252020-09-03 15:30:32 +0200289 }
Steven Cooreman37941cb2020-07-28 18:49:51 +0200290
Gilles Peskine449bd832023-01-11 14:50:10 +0100291 if (mbedtls_test_driver_cipher_hooks.forced_status != PSA_SUCCESS) {
292 return mbedtls_test_driver_cipher_hooks.forced_status;
293 }
Ronald Cron8d310ad2020-12-15 15:17:20 +0100294
Ronald Cron7975fae2021-09-13 14:50:42 +0200295#if defined(MBEDTLS_TEST_LIBTESTDRIVER1) && \
296 defined(LIBTESTDRIVER1_MBEDTLS_PSA_BUILTIN_CIPHER)
Gilles Peskine449bd832023-01-11 14:50:10 +0100297 return libtestdriver1_mbedtls_psa_cipher_finish(
298 operation, output, output_size, output_length);
Ronald Cron73c9d9e2021-04-09 11:09:54 +0200299#elif defined(MBEDTLS_PSA_BUILTIN_CIPHER)
Gilles Peskine449bd832023-01-11 14:50:10 +0100300 return mbedtls_psa_cipher_finish(
301 operation, output, output_size, output_length);
Ronald Cron73c9d9e2021-04-09 11:09:54 +0200302#endif
303
Gilles Peskine449bd832023-01-11 14:50:10 +0100304 return PSA_ERROR_NOT_SUPPORTED;
Steven Cooreman37941cb2020-07-28 18:49:51 +0200305}
306
307/*
308 * opaque versions, to do
309 */
Ronald Cron7f13fa22021-04-13 12:41:34 +0200310psa_status_t mbedtls_test_opaque_cipher_encrypt(
Steven Cooreman37941cb2020-07-28 18:49:51 +0200311 const psa_key_attributes_t *attributes,
312 const uint8_t *key, size_t key_length,
313 psa_algorithm_t alg,
Ronald Cron9b674282021-07-09 09:19:35 +0200314 const uint8_t *iv, size_t iv_length,
Steven Cooreman37941cb2020-07-28 18:49:51 +0200315 const uint8_t *input, size_t input_length,
316 uint8_t *output, size_t output_size, size_t *output_length)
317{
318 (void) attributes;
319 (void) key;
320 (void) key_length;
321 (void) alg;
Ronald Cron9b674282021-07-09 09:19:35 +0200322 (void) iv;
323 (void) iv_length;
Steven Cooreman37941cb2020-07-28 18:49:51 +0200324 (void) input;
325 (void) input_length;
326 (void) output;
327 (void) output_size;
328 (void) output_length;
Gilles Peskine449bd832023-01-11 14:50:10 +0100329 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;
Gilles Peskine449bd832023-01-11 14:50:10 +0100348 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;
Gilles Peskine449bd832023-01-11 14:50:10 +0100362 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;
Gilles Peskine449bd832023-01-11 14:50:10 +0100376 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(
Gilles Peskine449bd832023-01-11 14:50:10 +0100380 mbedtls_opaque_test_driver_cipher_operation_t *operation)
Steven Cooreman37941cb2020-07-28 18:49:51 +0200381{
382 (void) operation;
Gilles Peskine449bd832023-01-11 14:50:10 +0100383 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;
Gilles Peskine449bd832023-01-11 14:50:10 +0100394 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;
Gilles Peskine449bd832023-01-11 14:50:10 +0100411 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;
Gilles Peskine449bd832023-01-11 14:50:10 +0100424 return PSA_ERROR_NOT_SUPPORTED;
Steven Cooreman37941cb2020-07-28 18:49:51 +0200425}
Ronald Crone6e6b752023-01-16 16:56:51 +0100426#endif /* PSA_CRYPTO_DRIVER_TEST */