blob: 42e79c49033ea4553188b83585267da80c182bf7 [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
Ronald Crone6e6b752023-01-16 16:56:51 +010023#if defined(PSA_CRYPTO_DRIVER_TEST)
Steven Cooreman37941cb2020-07-28 18:49:51 +020024#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,
Ronald Cron9b674282021-07-09 09:19:35 +020047 const uint8_t *iv,
48 size_t iv_length,
gabor-mezei-arma9449a02021-03-25 11:17:10 +010049 const uint8_t *input,
50 size_t input_length,
51 uint8_t *output,
52 size_t output_size,
Gilles Peskine449bd832023-01-11 14:50:10 +010053 size_t *output_length)
Steven Cooremanfe0ab552020-09-10 13:07:02 +020054{
Ronald Cron7f13fa22021-04-13 12:41:34 +020055 mbedtls_test_driver_cipher_hooks.hits++;
Steven Cooremanfe0ab552020-09-10 13:07:02 +020056
Gilles Peskine449bd832023-01-11 14:50:10 +010057 if (mbedtls_test_driver_cipher_hooks.forced_output != NULL) {
58 if (output_size < mbedtls_test_driver_cipher_hooks.forced_output_length) {
59 return PSA_ERROR_BUFFER_TOO_SMALL;
60 }
Steven Cooremanfe0ab552020-09-10 13:07:02 +020061
Gilles Peskine449bd832023-01-11 14:50:10 +010062 memcpy(output,
63 mbedtls_test_driver_cipher_hooks.forced_output,
64 mbedtls_test_driver_cipher_hooks.forced_output_length);
Ronald Cron7f13fa22021-04-13 12:41:34 +020065 *output_length = mbedtls_test_driver_cipher_hooks.forced_output_length;
Steven Cooremanfe0ab552020-09-10 13:07:02 +020066
Gilles Peskine449bd832023-01-11 14:50:10 +010067 return mbedtls_test_driver_cipher_hooks.forced_status;
Steven Cooremanfe0ab552020-09-10 13:07:02 +020068 }
69
Gilles Peskine449bd832023-01-11 14:50:10 +010070 if (mbedtls_test_driver_cipher_hooks.forced_status != PSA_SUCCESS) {
71 return mbedtls_test_driver_cipher_hooks.forced_status;
72 }
Steven Cooremanfe0ab552020-09-10 13:07:02 +020073
Ronald Cron7975fae2021-09-13 14:50:42 +020074#if defined(MBEDTLS_TEST_LIBTESTDRIVER1) && \
75 defined(LIBTESTDRIVER1_MBEDTLS_PSA_BUILTIN_CIPHER)
Gilles Peskine449bd832023-01-11 14:50:10 +010076 return libtestdriver1_mbedtls_psa_cipher_encrypt(
77 (const libtestdriver1_psa_key_attributes_t *) attributes,
78 key_buffer, key_buffer_size,
79 alg, iv, iv_length, input, input_length,
80 output, output_size, output_length);
Ronald Cron73c9d9e2021-04-09 11:09:54 +020081#elif defined(MBEDTLS_PSA_BUILTIN_CIPHER)
Gilles Peskine449bd832023-01-11 14:50:10 +010082 return mbedtls_psa_cipher_encrypt(
83 attributes, key_buffer, key_buffer_size,
84 alg, iv, iv_length, input, input_length,
85 output, output_size, output_length);
Ronald Cron73c9d9e2021-04-09 11:09:54 +020086#endif
87
Gilles Peskine449bd832023-01-11 14:50:10 +010088 return PSA_ERROR_NOT_SUPPORTED;
Steven Cooreman37941cb2020-07-28 18:49:51 +020089}
90
Ronald Cron7f13fa22021-04-13 12:41:34 +020091psa_status_t mbedtls_test_transparent_cipher_decrypt(
Steven Cooreman37941cb2020-07-28 18:49:51 +020092 const psa_key_attributes_t *attributes,
gabor-mezei-arma9449a02021-03-25 11:17:10 +010093 const uint8_t *key_buffer,
94 size_t key_buffer_size,
Steven Cooreman37941cb2020-07-28 18:49:51 +020095 psa_algorithm_t alg,
gabor-mezei-arma9449a02021-03-25 11:17:10 +010096 const uint8_t *input,
97 size_t input_length,
98 uint8_t *output,
99 size_t output_size,
Gilles Peskine449bd832023-01-11 14:50:10 +0100100 size_t *output_length)
Steven Cooreman37941cb2020-07-28 18:49:51 +0200101{
Gilles Peskine449bd832023-01-11 14:50:10 +0100102 mbedtls_test_driver_cipher_hooks.hits++;
gabor-mezei-arma9449a02021-03-25 11:17:10 +0100103
Gilles Peskine449bd832023-01-11 14:50:10 +0100104 if (mbedtls_test_driver_cipher_hooks.forced_output != NULL) {
105 if (output_size < mbedtls_test_driver_cipher_hooks.forced_output_length) {
106 return PSA_ERROR_BUFFER_TOO_SMALL;
107 }
gabor-mezei-arma9449a02021-03-25 11:17:10 +0100108
Gilles Peskine449bd832023-01-11 14:50:10 +0100109 memcpy(output,
110 mbedtls_test_driver_cipher_hooks.forced_output,
111 mbedtls_test_driver_cipher_hooks.forced_output_length);
gabor-mezei-arma9449a02021-03-25 11:17:10 +0100112 *output_length = mbedtls_test_driver_cipher_hooks.forced_output_length;
113
Gilles Peskine449bd832023-01-11 14:50:10 +0100114 return mbedtls_test_driver_cipher_hooks.forced_status;
gabor-mezei-arma9449a02021-03-25 11:17:10 +0100115 }
116
Gilles Peskine449bd832023-01-11 14:50:10 +0100117 if (mbedtls_test_driver_cipher_hooks.forced_status != PSA_SUCCESS) {
118 return mbedtls_test_driver_cipher_hooks.forced_status;
119 }
gabor-mezei-arma9449a02021-03-25 11:17:10 +0100120
Ronald Cron7975fae2021-09-13 14:50:42 +0200121#if defined(MBEDTLS_TEST_LIBTESTDRIVER1) && \
122 defined(LIBTESTDRIVER1_MBEDTLS_PSA_BUILTIN_CIPHER)
Gilles Peskine449bd832023-01-11 14:50:10 +0100123 return libtestdriver1_mbedtls_psa_cipher_decrypt(
124 (const libtestdriver1_psa_key_attributes_t *) attributes,
125 key_buffer, key_buffer_size,
126 alg, input, input_length,
127 output, output_size, output_length);
Ronald Cron73c9d9e2021-04-09 11:09:54 +0200128#elif defined(MBEDTLS_PSA_BUILTIN_CIPHER)
Gilles Peskine449bd832023-01-11 14:50:10 +0100129 return mbedtls_psa_cipher_decrypt(
130 attributes, key_buffer, key_buffer_size,
131 alg, input, input_length,
132 output, output_size, output_length);
Ronald Cron73c9d9e2021-04-09 11:09:54 +0200133#endif
134
Gilles Peskine449bd832023-01-11 14:50:10 +0100135 return PSA_ERROR_NOT_SUPPORTED;
Steven Cooreman37941cb2020-07-28 18:49:51 +0200136}
137
Ronald Cron7f13fa22021-04-13 12:41:34 +0200138psa_status_t mbedtls_test_transparent_cipher_encrypt_setup(
Ronald Cron7cb9c3d2021-03-10 12:21:48 +0100139 mbedtls_transparent_test_driver_cipher_operation_t *operation,
Steven Cooreman16afd3d2020-09-09 15:36:39 +0200140 const psa_key_attributes_t *attributes,
141 const uint8_t *key, size_t key_length,
142 psa_algorithm_t alg)
143{
Ronald Cron7f13fa22021-04-13 12:41:34 +0200144 mbedtls_test_driver_cipher_hooks.hits++;
Ronald Cron8d310ad2020-12-15 15:17:20 +0100145
146 /* Wiping the entire struct here, instead of member-by-member. This is
147 * useful for the test suite, since it gives a chance of catching memory
148 * corruption errors should the core not have allocated (enough) memory for
149 * our context struct. */
Gilles Peskine449bd832023-01-11 14:50:10 +0100150 memset(operation, 0, sizeof(*operation));
Ronald Cron8d310ad2020-12-15 15:17:20 +0100151
Gilles Peskine449bd832023-01-11 14:50:10 +0100152 if (mbedtls_test_driver_cipher_hooks.forced_status != PSA_SUCCESS) {
153 return mbedtls_test_driver_cipher_hooks.forced_status;
154 }
Ronald Cron8d310ad2020-12-15 15:17:20 +0100155
Ronald Cron7975fae2021-09-13 14:50:42 +0200156#if defined(MBEDTLS_TEST_LIBTESTDRIVER1) && \
157 defined(LIBTESTDRIVER1_MBEDTLS_PSA_BUILTIN_CIPHER)
Gilles Peskine449bd832023-01-11 14:50:10 +0100158 return libtestdriver1_mbedtls_psa_cipher_encrypt_setup(
159 operation,
160 (const libtestdriver1_psa_key_attributes_t *) attributes,
161 key, key_length, alg);
Ronald Cron73c9d9e2021-04-09 11:09:54 +0200162#elif defined(MBEDTLS_PSA_BUILTIN_CIPHER)
Gilles Peskine449bd832023-01-11 14:50:10 +0100163 return mbedtls_psa_cipher_encrypt_setup(
164 operation, attributes, key, key_length, alg);
Ronald Cron73c9d9e2021-04-09 11:09:54 +0200165#endif
166
Gilles Peskine449bd832023-01-11 14:50:10 +0100167 return PSA_ERROR_NOT_SUPPORTED;
Steven Cooreman16afd3d2020-09-09 15:36:39 +0200168}
169
Ronald Cron7f13fa22021-04-13 12:41:34 +0200170psa_status_t mbedtls_test_transparent_cipher_decrypt_setup(
Ronald Cron7cb9c3d2021-03-10 12:21:48 +0100171 mbedtls_transparent_test_driver_cipher_operation_t *operation,
Steven Cooreman37941cb2020-07-28 18:49:51 +0200172 const psa_key_attributes_t *attributes,
173 const uint8_t *key, size_t key_length,
174 psa_algorithm_t alg)
175{
Ronald Cron7f13fa22021-04-13 12:41:34 +0200176 mbedtls_test_driver_cipher_hooks.hits++;
Ronald Cron8d310ad2020-12-15 15:17:20 +0100177
Gilles Peskine449bd832023-01-11 14:50:10 +0100178 if (mbedtls_test_driver_cipher_hooks.forced_status != PSA_SUCCESS) {
179 return mbedtls_test_driver_cipher_hooks.forced_status;
180 }
Ronald Cron8d310ad2020-12-15 15:17:20 +0100181
Ronald Cron7975fae2021-09-13 14:50:42 +0200182#if defined(MBEDTLS_TEST_LIBTESTDRIVER1) && \
183 defined(LIBTESTDRIVER1_MBEDTLS_PSA_BUILTIN_CIPHER)
Gilles Peskine449bd832023-01-11 14:50:10 +0100184 return libtestdriver1_mbedtls_psa_cipher_decrypt_setup(
185 operation,
186 (const libtestdriver1_psa_key_attributes_t *) attributes,
187 key, key_length, alg);
Ronald Cron73c9d9e2021-04-09 11:09:54 +0200188#elif defined(MBEDTLS_PSA_BUILTIN_CIPHER)
Gilles Peskine449bd832023-01-11 14:50:10 +0100189 return mbedtls_psa_cipher_decrypt_setup(
190 operation, attributes, key, key_length, alg);
Ronald Cron73c9d9e2021-04-09 11:09:54 +0200191#endif
192
Gilles Peskine449bd832023-01-11 14:50:10 +0100193 return PSA_ERROR_NOT_SUPPORTED;
Steven Cooreman37941cb2020-07-28 18:49:51 +0200194}
195
Ronald Cron7f13fa22021-04-13 12:41:34 +0200196psa_status_t mbedtls_test_transparent_cipher_abort(
Ronald Cron7cb9c3d2021-03-10 12:21:48 +0100197 mbedtls_transparent_test_driver_cipher_operation_t *operation)
Steven Cooreman37941cb2020-07-28 18:49:51 +0200198{
Ronald Cron7f13fa22021-04-13 12:41:34 +0200199 mbedtls_test_driver_cipher_hooks.hits++;
Steven Cooreman89e54f22020-09-10 18:07:57 +0200200
Ronald Cron7975fae2021-09-13 14:50:42 +0200201#if defined(MBEDTLS_TEST_LIBTESTDRIVER1) && \
202 defined(LIBTESTDRIVER1_MBEDTLS_PSA_BUILTIN_CIPHER)
Gilles Peskine449bd832023-01-11 14:50:10 +0100203 libtestdriver1_mbedtls_psa_cipher_abort(operation);
Ronald Cron73c9d9e2021-04-09 11:09:54 +0200204#elif defined(MBEDTLS_PSA_BUILTIN_CIPHER)
Gilles Peskine449bd832023-01-11 14:50:10 +0100205 mbedtls_psa_cipher_abort(operation);
Ronald Cron73c9d9e2021-04-09 11:09:54 +0200206#endif
Steven Cooreman8b122252020-09-03 15:30:32 +0200207
Ronald Cron8d310ad2020-12-15 15:17:20 +0100208 /* Wiping the entire struct here, instead of member-by-member. This is
209 * useful for the test suite, since it gives a chance of catching memory
210 * corruption errors should the core not have allocated (enough) memory for
211 * our context struct. */
Gilles Peskine449bd832023-01-11 14:50:10 +0100212 memset(operation, 0, sizeof(*operation));
Steven Cooreman37941cb2020-07-28 18:49:51 +0200213
Gilles Peskine449bd832023-01-11 14:50:10 +0100214 return mbedtls_test_driver_cipher_hooks.forced_status;
Steven Cooreman37941cb2020-07-28 18:49:51 +0200215}
216
Ronald Cron7f13fa22021-04-13 12:41:34 +0200217psa_status_t mbedtls_test_transparent_cipher_set_iv(
Ronald Cron7cb9c3d2021-03-10 12:21:48 +0100218 mbedtls_transparent_test_driver_cipher_operation_t *operation,
Steven Cooreman37941cb2020-07-28 18:49:51 +0200219 const uint8_t *iv,
220 size_t iv_length)
221{
Ronald Cron7f13fa22021-04-13 12:41:34 +0200222 mbedtls_test_driver_cipher_hooks.hits++;
Steven Cooreman8b122252020-09-03 15:30:32 +0200223
Gilles Peskine449bd832023-01-11 14:50:10 +0100224 if (mbedtls_test_driver_cipher_hooks.forced_status != PSA_SUCCESS) {
225 return mbedtls_test_driver_cipher_hooks.forced_status;
226 }
Steven Cooreman89e54f22020-09-10 18:07:57 +0200227
Ronald Cron7975fae2021-09-13 14:50:42 +0200228#if defined(MBEDTLS_TEST_LIBTESTDRIVER1) && \
229 defined(LIBTESTDRIVER1_MBEDTLS_PSA_BUILTIN_CIPHER)
Gilles Peskine449bd832023-01-11 14:50:10 +0100230 return libtestdriver1_mbedtls_psa_cipher_set_iv(
231 operation, iv, iv_length);
Ronald Cron73c9d9e2021-04-09 11:09:54 +0200232#elif defined(MBEDTLS_PSA_BUILTIN_CIPHER)
Gilles Peskine449bd832023-01-11 14:50:10 +0100233 return mbedtls_psa_cipher_set_iv(operation, iv, iv_length);
Ronald Cron73c9d9e2021-04-09 11:09:54 +0200234#endif
235
Gilles Peskine449bd832023-01-11 14:50:10 +0100236 return PSA_ERROR_NOT_SUPPORTED;
Steven Cooreman37941cb2020-07-28 18:49:51 +0200237}
238
Ronald Cron7f13fa22021-04-13 12:41:34 +0200239psa_status_t mbedtls_test_transparent_cipher_update(
Ronald Cron7cb9c3d2021-03-10 12:21:48 +0100240 mbedtls_transparent_test_driver_cipher_operation_t *operation,
Steven Cooreman37941cb2020-07-28 18:49:51 +0200241 const uint8_t *input,
242 size_t input_length,
243 uint8_t *output,
244 size_t output_size,
245 size_t *output_length)
246{
Ronald Cron7f13fa22021-04-13 12:41:34 +0200247 mbedtls_test_driver_cipher_hooks.hits++;
Steven Cooreman37941cb2020-07-28 18:49:51 +0200248
Gilles Peskine449bd832023-01-11 14:50:10 +0100249 if (mbedtls_test_driver_cipher_hooks.forced_output != NULL) {
250 if (output_size < mbedtls_test_driver_cipher_hooks.forced_output_length) {
Steven Cooreman8b122252020-09-03 15:30:32 +0200251 return PSA_ERROR_BUFFER_TOO_SMALL;
Gilles Peskine449bd832023-01-11 14:50:10 +0100252 }
Steven Cooreman8b122252020-09-03 15:30:32 +0200253
Gilles Peskine449bd832023-01-11 14:50:10 +0100254 memcpy(output,
255 mbedtls_test_driver_cipher_hooks.forced_output,
256 mbedtls_test_driver_cipher_hooks.forced_output_length);
Ronald Cron7f13fa22021-04-13 12:41:34 +0200257 *output_length = mbedtls_test_driver_cipher_hooks.forced_output_length;
Ronald Cron8d310ad2020-12-15 15:17:20 +0100258
Gilles Peskine449bd832023-01-11 14:50:10 +0100259 return mbedtls_test_driver_cipher_hooks.forced_status;
Steven Cooreman8b122252020-09-03 15:30:32 +0200260 }
Steven Cooreman37941cb2020-07-28 18:49:51 +0200261
Gilles Peskine449bd832023-01-11 14:50:10 +0100262 if (mbedtls_test_driver_cipher_hooks.forced_status != PSA_SUCCESS) {
263 return mbedtls_test_driver_cipher_hooks.forced_status;
264 }
Ronald Cron8d310ad2020-12-15 15:17:20 +0100265
Ronald Cron7975fae2021-09-13 14:50:42 +0200266#if defined(MBEDTLS_TEST_LIBTESTDRIVER1) && \
267 defined(LIBTESTDRIVER1_MBEDTLS_PSA_BUILTIN_CIPHER)
Gilles Peskine449bd832023-01-11 14:50:10 +0100268 return libtestdriver1_mbedtls_psa_cipher_update(
269 operation, input, input_length,
270 output, output_size, output_length);
Ronald Cron73c9d9e2021-04-09 11:09:54 +0200271#elif defined(MBEDTLS_PSA_BUILTIN_CIPHER)
Gilles Peskine449bd832023-01-11 14:50:10 +0100272 return mbedtls_psa_cipher_update(
273 operation, input, input_length,
274 output, output_size, output_length);
Ronald Cron73c9d9e2021-04-09 11:09:54 +0200275#endif
276
Gilles Peskine449bd832023-01-11 14:50:10 +0100277 return PSA_ERROR_NOT_SUPPORTED;
Steven Cooreman37941cb2020-07-28 18:49:51 +0200278}
279
Ronald Cron7f13fa22021-04-13 12:41:34 +0200280psa_status_t mbedtls_test_transparent_cipher_finish(
Ronald Cron7cb9c3d2021-03-10 12:21:48 +0100281 mbedtls_transparent_test_driver_cipher_operation_t *operation,
Steven Cooreman37941cb2020-07-28 18:49:51 +0200282 uint8_t *output,
283 size_t output_size,
284 size_t *output_length)
285{
Ronald Cron7f13fa22021-04-13 12:41:34 +0200286 mbedtls_test_driver_cipher_hooks.hits++;
Steven Cooreman37941cb2020-07-28 18:49:51 +0200287
Gilles Peskine449bd832023-01-11 14:50:10 +0100288 if (mbedtls_test_driver_cipher_hooks.forced_output != NULL) {
289 if (output_size < mbedtls_test_driver_cipher_hooks.forced_output_length) {
Steven Cooreman8b122252020-09-03 15:30:32 +0200290 return PSA_ERROR_BUFFER_TOO_SMALL;
Gilles Peskine449bd832023-01-11 14:50:10 +0100291 }
Steven Cooreman8b122252020-09-03 15:30:32 +0200292
Gilles Peskine449bd832023-01-11 14:50:10 +0100293 memcpy(output,
294 mbedtls_test_driver_cipher_hooks.forced_output,
295 mbedtls_test_driver_cipher_hooks.forced_output_length);
Ronald Cron7f13fa22021-04-13 12:41:34 +0200296 *output_length = mbedtls_test_driver_cipher_hooks.forced_output_length;
Ronald Cron8d310ad2020-12-15 15:17:20 +0100297
Gilles Peskine449bd832023-01-11 14:50:10 +0100298 return mbedtls_test_driver_cipher_hooks.forced_status;
Steven Cooreman8b122252020-09-03 15:30:32 +0200299 }
Steven Cooreman37941cb2020-07-28 18:49:51 +0200300
Gilles Peskine449bd832023-01-11 14:50:10 +0100301 if (mbedtls_test_driver_cipher_hooks.forced_status != PSA_SUCCESS) {
302 return mbedtls_test_driver_cipher_hooks.forced_status;
303 }
Ronald Cron8d310ad2020-12-15 15:17:20 +0100304
Ronald Cron7975fae2021-09-13 14:50:42 +0200305#if defined(MBEDTLS_TEST_LIBTESTDRIVER1) && \
306 defined(LIBTESTDRIVER1_MBEDTLS_PSA_BUILTIN_CIPHER)
Gilles Peskine449bd832023-01-11 14:50:10 +0100307 return libtestdriver1_mbedtls_psa_cipher_finish(
308 operation, output, output_size, output_length);
Ronald Cron73c9d9e2021-04-09 11:09:54 +0200309#elif defined(MBEDTLS_PSA_BUILTIN_CIPHER)
Gilles Peskine449bd832023-01-11 14:50:10 +0100310 return mbedtls_psa_cipher_finish(
311 operation, output, output_size, output_length);
Ronald Cron73c9d9e2021-04-09 11:09:54 +0200312#endif
313
Gilles Peskine449bd832023-01-11 14:50:10 +0100314 return PSA_ERROR_NOT_SUPPORTED;
Steven Cooreman37941cb2020-07-28 18:49:51 +0200315}
316
317/*
318 * opaque versions, to do
319 */
Ronald Cron7f13fa22021-04-13 12:41:34 +0200320psa_status_t mbedtls_test_opaque_cipher_encrypt(
Steven Cooreman37941cb2020-07-28 18:49:51 +0200321 const psa_key_attributes_t *attributes,
322 const uint8_t *key, size_t key_length,
323 psa_algorithm_t alg,
Ronald Cron9b674282021-07-09 09:19:35 +0200324 const uint8_t *iv, size_t iv_length,
Steven Cooreman37941cb2020-07-28 18:49:51 +0200325 const uint8_t *input, size_t input_length,
326 uint8_t *output, size_t output_size, size_t *output_length)
327{
328 (void) attributes;
329 (void) key;
330 (void) key_length;
331 (void) alg;
Ronald Cron9b674282021-07-09 09:19:35 +0200332 (void) iv;
333 (void) iv_length;
Steven Cooreman37941cb2020-07-28 18:49:51 +0200334 (void) input;
335 (void) input_length;
336 (void) output;
337 (void) output_size;
338 (void) output_length;
Gilles Peskine449bd832023-01-11 14:50:10 +0100339 return PSA_ERROR_NOT_SUPPORTED;
Steven Cooreman37941cb2020-07-28 18:49:51 +0200340}
341
Ronald Cron7f13fa22021-04-13 12:41:34 +0200342psa_status_t mbedtls_test_opaque_cipher_decrypt(
Steven Cooreman37941cb2020-07-28 18:49:51 +0200343 const psa_key_attributes_t *attributes,
344 const uint8_t *key, size_t key_length,
345 psa_algorithm_t alg,
346 const uint8_t *input, size_t input_length,
347 uint8_t *output, size_t output_size, size_t *output_length)
348{
349 (void) attributes;
350 (void) key;
351 (void) key_length;
352 (void) alg;
353 (void) input;
354 (void) input_length;
355 (void) output;
356 (void) output_size;
357 (void) output_length;
Gilles Peskine449bd832023-01-11 14:50:10 +0100358 return PSA_ERROR_NOT_SUPPORTED;
Steven Cooreman37941cb2020-07-28 18:49:51 +0200359}
360
Ronald Cron7f13fa22021-04-13 12:41:34 +0200361psa_status_t mbedtls_test_opaque_cipher_encrypt_setup(
Ronald Cron7cb9c3d2021-03-10 12:21:48 +0100362 mbedtls_opaque_test_driver_cipher_operation_t *operation,
Steven Cooreman37941cb2020-07-28 18:49:51 +0200363 const psa_key_attributes_t *attributes,
364 const uint8_t *key, size_t key_length,
365 psa_algorithm_t alg)
366{
367 (void) operation;
368 (void) attributes;
369 (void) key;
370 (void) key_length;
371 (void) alg;
Gilles Peskine449bd832023-01-11 14:50:10 +0100372 return PSA_ERROR_NOT_SUPPORTED;
Steven Cooreman37941cb2020-07-28 18:49:51 +0200373}
374
Ronald Cron7f13fa22021-04-13 12:41:34 +0200375psa_status_t mbedtls_test_opaque_cipher_decrypt_setup(
Ronald Cron7cb9c3d2021-03-10 12:21:48 +0100376 mbedtls_opaque_test_driver_cipher_operation_t *operation,
Steven Cooreman37941cb2020-07-28 18:49:51 +0200377 const psa_key_attributes_t *attributes,
378 const uint8_t *key, size_t key_length,
379 psa_algorithm_t alg)
380{
381 (void) operation;
382 (void) attributes;
383 (void) key;
384 (void) key_length;
385 (void) alg;
Gilles Peskine449bd832023-01-11 14:50:10 +0100386 return PSA_ERROR_NOT_SUPPORTED;
Steven Cooreman37941cb2020-07-28 18:49:51 +0200387}
388
Ronald Cron7f13fa22021-04-13 12:41:34 +0200389psa_status_t mbedtls_test_opaque_cipher_abort(
Gilles Peskine449bd832023-01-11 14:50:10 +0100390 mbedtls_opaque_test_driver_cipher_operation_t *operation)
Steven Cooreman37941cb2020-07-28 18:49:51 +0200391{
392 (void) operation;
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_set_iv(
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 *iv,
399 size_t iv_length)
400{
401 (void) operation;
402 (void) iv;
403 (void) iv_length;
Gilles Peskine449bd832023-01-11 14:50:10 +0100404 return PSA_ERROR_NOT_SUPPORTED;
Steven Cooreman37941cb2020-07-28 18:49:51 +0200405}
406
Ronald Cron7f13fa22021-04-13 12:41:34 +0200407psa_status_t mbedtls_test_opaque_cipher_update(
Ronald Cron7cb9c3d2021-03-10 12:21:48 +0100408 mbedtls_opaque_test_driver_cipher_operation_t *operation,
Steven Cooreman37941cb2020-07-28 18:49:51 +0200409 const uint8_t *input,
410 size_t input_length,
411 uint8_t *output,
412 size_t output_size,
413 size_t *output_length)
414{
415 (void) operation;
416 (void) input;
417 (void) input_length;
418 (void) output;
419 (void) output_size;
420 (void) output_length;
Gilles Peskine449bd832023-01-11 14:50:10 +0100421 return PSA_ERROR_NOT_SUPPORTED;
Steven Cooreman37941cb2020-07-28 18:49:51 +0200422}
423
Ronald Cron7f13fa22021-04-13 12:41:34 +0200424psa_status_t mbedtls_test_opaque_cipher_finish(
Ronald Cron7cb9c3d2021-03-10 12:21:48 +0100425 mbedtls_opaque_test_driver_cipher_operation_t *operation,
Steven Cooreman37941cb2020-07-28 18:49:51 +0200426 uint8_t *output,
427 size_t output_size,
428 size_t *output_length)
429{
430 (void) operation;
431 (void) output;
432 (void) output_size;
433 (void) output_length;
Gilles Peskine449bd832023-01-11 14:50:10 +0100434 return PSA_ERROR_NOT_SUPPORTED;
Steven Cooreman37941cb2020-07-28 18:49:51 +0200435}
Ronald Crone6e6b752023-01-16 16:56:51 +0100436#endif /* PSA_CRYPTO_DRIVER_TEST */