Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Test driver for cipher functions. |
| 3 | * Currently only supports multi-part operations using AES-CTR. |
| 4 | */ |
Steven Cooreman | 3ec4018 | 2020-09-02 16:27:46 +0200 | [diff] [blame] | 5 | /* Copyright The Mbed TLS Contributors |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 6 | * 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 Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 19 | */ |
| 20 | |
| 21 | #if !defined(MBEDTLS_CONFIG_FILE) |
| 22 | #include "mbedtls/config.h" |
| 23 | #else |
| 24 | #include MBEDTLS_CONFIG_FILE |
| 25 | #endif |
| 26 | |
| 27 | #if defined(MBEDTLS_PSA_CRYPTO_DRIVERS) && defined(PSA_CRYPTO_DRIVER_TEST) |
| 28 | #include "psa/crypto.h" |
Ronald Cron | 8d310ad | 2020-12-15 15:17:20 +0100 | [diff] [blame] | 29 | #include "psa_crypto_cipher.h" |
Steven Cooreman | acb5a10 | 2020-09-08 14:06:57 +0200 | [diff] [blame] | 30 | #include "psa_crypto_core.h" |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 31 | #include "mbedtls/cipher.h" |
| 32 | |
Steven Cooreman | acb5a10 | 2020-09-08 14:06:57 +0200 | [diff] [blame] | 33 | #include "test/drivers/cipher.h" |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 34 | |
| 35 | #include "test/random.h" |
| 36 | |
| 37 | #include <string.h> |
| 38 | |
Steven Cooreman | acb5a10 | 2020-09-08 14:06:57 +0200 | [diff] [blame] | 39 | test_driver_cipher_hooks_t test_driver_cipher_hooks = TEST_DRIVER_CIPHER_INIT; |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 40 | |
Steven Cooreman | fe0ab55 | 2020-09-10 13:07:02 +0200 | [diff] [blame] | 41 | static psa_status_t test_transparent_cipher_oneshot( |
| 42 | mbedtls_operation_t direction, |
| 43 | const psa_key_attributes_t *attributes, |
| 44 | const uint8_t *key, size_t key_length, |
| 45 | psa_algorithm_t alg, |
| 46 | const uint8_t *input, size_t input_length, |
| 47 | uint8_t *output, size_t output_size, size_t *output_length) |
| 48 | { |
| 49 | test_driver_cipher_hooks.hits++; |
| 50 | |
| 51 | /* Test driver supports AES-CTR only, to verify operation calls. */ |
| 52 | if( alg != PSA_ALG_CTR || |
| 53 | psa_get_key_type( attributes ) != PSA_KEY_TYPE_AES ) |
| 54 | return( PSA_ERROR_NOT_SUPPORTED ); |
| 55 | |
| 56 | /* If test driver response code is not SUCCESS, we can return early */ |
| 57 | if( test_driver_cipher_hooks.forced_status != PSA_SUCCESS ) |
| 58 | return( test_driver_cipher_hooks.forced_status ); |
| 59 | |
| 60 | /* If test driver output is overridden, we don't need to do actual crypto */ |
| 61 | if( test_driver_cipher_hooks.forced_output != NULL ) |
| 62 | { |
| 63 | if( output_size < test_driver_cipher_hooks.forced_output_length ) |
| 64 | return( PSA_ERROR_BUFFER_TOO_SMALL ); |
| 65 | |
| 66 | memcpy( output, |
| 67 | test_driver_cipher_hooks.forced_output, |
| 68 | test_driver_cipher_hooks.forced_output_length ); |
| 69 | *output_length = test_driver_cipher_hooks.forced_output_length; |
| 70 | |
| 71 | return( test_driver_cipher_hooks.forced_status ); |
| 72 | } |
| 73 | |
| 74 | /* Run AES-CTR using the cipher module */ |
| 75 | { |
| 76 | mbedtls_test_rnd_pseudo_info rnd_info; |
| 77 | memset( &rnd_info, 0x5A, sizeof( mbedtls_test_rnd_pseudo_info ) ); |
| 78 | |
| 79 | const mbedtls_cipher_info_t *cipher_info = |
| 80 | mbedtls_cipher_info_from_values( MBEDTLS_CIPHER_ID_AES, |
| 81 | key_length * 8, |
| 82 | MBEDTLS_MODE_CTR ); |
| 83 | mbedtls_cipher_context_t cipher; |
| 84 | int ret = 0; |
| 85 | uint8_t temp_output_buffer[16] = {0}; |
| 86 | size_t temp_output_length = 0; |
| 87 | |
| 88 | if( direction == MBEDTLS_ENCRYPT ) |
| 89 | { |
| 90 | /* Oneshot encrypt needs to prepend the IV to the output */ |
| 91 | if( output_size < ( input_length + 16 ) ) |
| 92 | return( PSA_ERROR_BUFFER_TOO_SMALL ); |
| 93 | } |
| 94 | else |
| 95 | { |
| 96 | /* Oneshot decrypt has the IV prepended to the input */ |
| 97 | if( output_size < ( input_length - 16 ) ) |
| 98 | return( PSA_ERROR_BUFFER_TOO_SMALL ); |
| 99 | } |
| 100 | |
| 101 | if( cipher_info == NULL ) |
| 102 | return( PSA_ERROR_NOT_SUPPORTED ); |
| 103 | |
| 104 | mbedtls_cipher_init( &cipher ); |
| 105 | ret = mbedtls_cipher_setup( &cipher, cipher_info ); |
| 106 | if( ret != 0 ) |
| 107 | goto exit; |
| 108 | |
| 109 | ret = mbedtls_cipher_setkey( &cipher, |
| 110 | key, |
| 111 | key_length * 8, direction ); |
| 112 | if( ret != 0 ) |
| 113 | goto exit; |
| 114 | |
| 115 | if( direction == MBEDTLS_ENCRYPT ) |
| 116 | { |
| 117 | mbedtls_test_rnd_pseudo_info rnd_info; |
| 118 | memset( &rnd_info, 0x5A, sizeof( mbedtls_test_rnd_pseudo_info ) ); |
| 119 | |
| 120 | ret = mbedtls_test_rnd_pseudo_rand( &rnd_info, |
| 121 | temp_output_buffer, |
| 122 | 16 ); |
| 123 | if( ret != 0 ) |
| 124 | goto exit; |
| 125 | |
| 126 | ret = mbedtls_cipher_set_iv( &cipher, temp_output_buffer, 16 ); |
| 127 | } |
| 128 | else |
| 129 | ret = mbedtls_cipher_set_iv( &cipher, input, 16 ); |
| 130 | |
| 131 | if( ret != 0 ) |
| 132 | goto exit; |
| 133 | |
| 134 | if( direction == MBEDTLS_ENCRYPT ) |
| 135 | { |
| 136 | ret = mbedtls_cipher_update( &cipher, |
| 137 | input, input_length, |
| 138 | &output[16], output_length ); |
| 139 | if( ret == 0 ) |
| 140 | { |
| 141 | memcpy( output, temp_output_buffer, 16 ); |
| 142 | *output_length += 16; |
| 143 | } |
| 144 | } |
| 145 | else |
| 146 | ret = mbedtls_cipher_update( &cipher, |
| 147 | &input[16], input_length - 16, |
| 148 | output, output_length ); |
| 149 | |
| 150 | if( ret != 0 ) |
| 151 | goto exit; |
| 152 | |
| 153 | ret = mbedtls_cipher_finish( &cipher, |
| 154 | temp_output_buffer, |
| 155 | &temp_output_length ); |
| 156 | |
| 157 | exit: |
| 158 | if( ret != 0 ) |
| 159 | { |
| 160 | *output_length = 0; |
| 161 | memset(output, 0, output_size); |
| 162 | } |
| 163 | |
| 164 | mbedtls_cipher_free( &cipher ); |
| 165 | return( mbedtls_to_psa_error( ret ) ); |
| 166 | } |
| 167 | } |
| 168 | |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 169 | psa_status_t test_transparent_cipher_encrypt( |
| 170 | const psa_key_attributes_t *attributes, |
| 171 | const uint8_t *key, size_t key_length, |
| 172 | psa_algorithm_t alg, |
| 173 | const uint8_t *input, size_t input_length, |
| 174 | uint8_t *output, size_t output_size, size_t *output_length) |
| 175 | { |
Steven Cooreman | fe0ab55 | 2020-09-10 13:07:02 +0200 | [diff] [blame] | 176 | return ( |
| 177 | test_transparent_cipher_oneshot( |
| 178 | MBEDTLS_ENCRYPT, |
| 179 | attributes, |
| 180 | key, key_length, |
| 181 | alg, |
| 182 | input, input_length, |
| 183 | output, output_size, output_length) ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 184 | } |
| 185 | |
| 186 | psa_status_t test_transparent_cipher_decrypt( |
| 187 | const psa_key_attributes_t *attributes, |
| 188 | const uint8_t *key, size_t key_length, |
| 189 | psa_algorithm_t alg, |
| 190 | const uint8_t *input, size_t input_length, |
| 191 | uint8_t *output, size_t output_size, size_t *output_length) |
| 192 | { |
Steven Cooreman | fe0ab55 | 2020-09-10 13:07:02 +0200 | [diff] [blame] | 193 | return ( |
| 194 | test_transparent_cipher_oneshot( |
| 195 | MBEDTLS_DECRYPT, |
| 196 | attributes, |
| 197 | key, key_length, |
| 198 | alg, |
| 199 | input, input_length, |
| 200 | output, output_size, output_length) ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 201 | } |
| 202 | |
Steven Cooreman | 16afd3d | 2020-09-09 15:36:39 +0200 | [diff] [blame] | 203 | psa_status_t test_transparent_cipher_encrypt_setup( |
Ronald Cron | 7cb9c3d | 2021-03-10 12:21:48 +0100 | [diff] [blame] | 204 | mbedtls_transparent_test_driver_cipher_operation_t *operation, |
Steven Cooreman | 16afd3d | 2020-09-09 15:36:39 +0200 | [diff] [blame] | 205 | const psa_key_attributes_t *attributes, |
| 206 | const uint8_t *key, size_t key_length, |
| 207 | psa_algorithm_t alg) |
| 208 | { |
Ronald Cron | 8d310ad | 2020-12-15 15:17:20 +0100 | [diff] [blame] | 209 | test_driver_cipher_hooks.hits++; |
| 210 | |
| 211 | /* Wiping the entire struct here, instead of member-by-member. This is |
| 212 | * useful for the test suite, since it gives a chance of catching memory |
| 213 | * corruption errors should the core not have allocated (enough) memory for |
| 214 | * our context struct. */ |
| 215 | memset( operation, 0, sizeof( *operation ) ); |
| 216 | |
| 217 | if( test_driver_cipher_hooks.forced_status != PSA_SUCCESS ) |
| 218 | return( test_driver_cipher_hooks.forced_status ); |
| 219 | |
Ronald Cron | 3522e32 | 2021-03-12 11:08:49 +0100 | [diff] [blame] | 220 | return ( mbedtls_transparent_test_driver_cipher_encrypt_setup( |
| 221 | operation, attributes, key, key_length, alg ) ); |
Steven Cooreman | 16afd3d | 2020-09-09 15:36:39 +0200 | [diff] [blame] | 222 | } |
| 223 | |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 224 | psa_status_t test_transparent_cipher_decrypt_setup( |
Ronald Cron | 7cb9c3d | 2021-03-10 12:21:48 +0100 | [diff] [blame] | 225 | mbedtls_transparent_test_driver_cipher_operation_t *operation, |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 226 | const psa_key_attributes_t *attributes, |
| 227 | const uint8_t *key, size_t key_length, |
| 228 | psa_algorithm_t alg) |
| 229 | { |
Ronald Cron | 8d310ad | 2020-12-15 15:17:20 +0100 | [diff] [blame] | 230 | test_driver_cipher_hooks.hits++; |
| 231 | |
| 232 | if( test_driver_cipher_hooks.forced_status != PSA_SUCCESS ) |
| 233 | return( test_driver_cipher_hooks.forced_status ); |
| 234 | |
Ronald Cron | 3522e32 | 2021-03-12 11:08:49 +0100 | [diff] [blame] | 235 | return ( mbedtls_transparent_test_driver_cipher_decrypt_setup( |
| 236 | operation, attributes, key, key_length, alg ) ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 237 | } |
| 238 | |
| 239 | psa_status_t test_transparent_cipher_abort( |
Ronald Cron | 7cb9c3d | 2021-03-10 12:21:48 +0100 | [diff] [blame] | 240 | mbedtls_transparent_test_driver_cipher_operation_t *operation) |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 241 | { |
Steven Cooreman | 89e54f2 | 2020-09-10 18:07:57 +0200 | [diff] [blame] | 242 | test_driver_cipher_hooks.hits++; |
| 243 | |
Steven Cooreman | 8b12225 | 2020-09-03 15:30:32 +0200 | [diff] [blame] | 244 | if( operation->alg == 0 ) |
| 245 | return( PSA_SUCCESS ); |
Steven Cooreman | 8b12225 | 2020-09-03 15:30:32 +0200 | [diff] [blame] | 246 | |
Ronald Cron | 3522e32 | 2021-03-12 11:08:49 +0100 | [diff] [blame] | 247 | mbedtls_transparent_test_driver_cipher_abort( operation ); |
Steven Cooreman | 8b12225 | 2020-09-03 15:30:32 +0200 | [diff] [blame] | 248 | |
Ronald Cron | 8d310ad | 2020-12-15 15:17:20 +0100 | [diff] [blame] | 249 | /* Wiping the entire struct here, instead of member-by-member. This is |
| 250 | * useful for the test suite, since it gives a chance of catching memory |
| 251 | * corruption errors should the core not have allocated (enough) memory for |
| 252 | * our context struct. */ |
Steven Cooreman | 5240e8b | 2020-09-09 11:51:45 +0200 | [diff] [blame] | 253 | memset( operation, 0, sizeof( *operation ) ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 254 | |
Ronald Cron | 8d310ad | 2020-12-15 15:17:20 +0100 | [diff] [blame] | 255 | return( test_driver_cipher_hooks.forced_status ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 256 | } |
| 257 | |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 258 | psa_status_t test_transparent_cipher_set_iv( |
Ronald Cron | 7cb9c3d | 2021-03-10 12:21:48 +0100 | [diff] [blame] | 259 | mbedtls_transparent_test_driver_cipher_operation_t *operation, |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 260 | const uint8_t *iv, |
| 261 | size_t iv_length) |
| 262 | { |
Steven Cooreman | acb5a10 | 2020-09-08 14:06:57 +0200 | [diff] [blame] | 263 | test_driver_cipher_hooks.hits++; |
Steven Cooreman | 8b12225 | 2020-09-03 15:30:32 +0200 | [diff] [blame] | 264 | |
Steven Cooreman | 89e54f2 | 2020-09-10 18:07:57 +0200 | [diff] [blame] | 265 | if( test_driver_cipher_hooks.forced_status != PSA_SUCCESS ) |
| 266 | return( test_driver_cipher_hooks.forced_status ); |
| 267 | |
Ronald Cron | 3522e32 | 2021-03-12 11:08:49 +0100 | [diff] [blame] | 268 | return( mbedtls_transparent_test_driver_cipher_set_iv( |
| 269 | operation, iv, iv_length ) ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 270 | } |
| 271 | |
| 272 | psa_status_t test_transparent_cipher_update( |
Ronald Cron | 7cb9c3d | 2021-03-10 12:21:48 +0100 | [diff] [blame] | 273 | mbedtls_transparent_test_driver_cipher_operation_t *operation, |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 274 | const uint8_t *input, |
| 275 | size_t input_length, |
| 276 | uint8_t *output, |
| 277 | size_t output_size, |
| 278 | size_t *output_length) |
| 279 | { |
Steven Cooreman | acb5a10 | 2020-09-08 14:06:57 +0200 | [diff] [blame] | 280 | test_driver_cipher_hooks.hits++; |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 281 | |
Steven Cooreman | acb5a10 | 2020-09-08 14:06:57 +0200 | [diff] [blame] | 282 | if( test_driver_cipher_hooks.forced_output != NULL ) |
Steven Cooreman | 8b12225 | 2020-09-03 15:30:32 +0200 | [diff] [blame] | 283 | { |
Steven Cooreman | acb5a10 | 2020-09-08 14:06:57 +0200 | [diff] [blame] | 284 | if( output_size < test_driver_cipher_hooks.forced_output_length ) |
Steven Cooreman | 8b12225 | 2020-09-03 15:30:32 +0200 | [diff] [blame] | 285 | return PSA_ERROR_BUFFER_TOO_SMALL; |
| 286 | |
Steven Cooreman | acb5a10 | 2020-09-08 14:06:57 +0200 | [diff] [blame] | 287 | memcpy( output, |
| 288 | test_driver_cipher_hooks.forced_output, |
| 289 | test_driver_cipher_hooks.forced_output_length ); |
| 290 | *output_length = test_driver_cipher_hooks.forced_output_length; |
Ronald Cron | 8d310ad | 2020-12-15 15:17:20 +0100 | [diff] [blame] | 291 | |
| 292 | return( test_driver_cipher_hooks.forced_status ); |
Steven Cooreman | 8b12225 | 2020-09-03 15:30:32 +0200 | [diff] [blame] | 293 | } |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 294 | |
Ronald Cron | 8d310ad | 2020-12-15 15:17:20 +0100 | [diff] [blame] | 295 | if( test_driver_cipher_hooks.forced_status != PSA_SUCCESS ) |
| 296 | return( test_driver_cipher_hooks.forced_status ); |
| 297 | |
Ronald Cron | 3522e32 | 2021-03-12 11:08:49 +0100 | [diff] [blame] | 298 | return( mbedtls_transparent_test_driver_cipher_update( |
| 299 | operation, input, input_length, |
| 300 | output, output_size, output_length ) ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 301 | } |
| 302 | |
| 303 | psa_status_t test_transparent_cipher_finish( |
Ronald Cron | 7cb9c3d | 2021-03-10 12:21:48 +0100 | [diff] [blame] | 304 | mbedtls_transparent_test_driver_cipher_operation_t *operation, |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 305 | uint8_t *output, |
| 306 | size_t output_size, |
| 307 | size_t *output_length) |
| 308 | { |
Steven Cooreman | acb5a10 | 2020-09-08 14:06:57 +0200 | [diff] [blame] | 309 | test_driver_cipher_hooks.hits++; |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 310 | |
Steven Cooreman | acb5a10 | 2020-09-08 14:06:57 +0200 | [diff] [blame] | 311 | if( test_driver_cipher_hooks.forced_output != NULL ) |
Steven Cooreman | 8b12225 | 2020-09-03 15:30:32 +0200 | [diff] [blame] | 312 | { |
Steven Cooreman | acb5a10 | 2020-09-08 14:06:57 +0200 | [diff] [blame] | 313 | if( output_size < test_driver_cipher_hooks.forced_output_length ) |
Steven Cooreman | 8b12225 | 2020-09-03 15:30:32 +0200 | [diff] [blame] | 314 | return PSA_ERROR_BUFFER_TOO_SMALL; |
| 315 | |
Steven Cooreman | acb5a10 | 2020-09-08 14:06:57 +0200 | [diff] [blame] | 316 | memcpy( output, |
| 317 | test_driver_cipher_hooks.forced_output, |
| 318 | test_driver_cipher_hooks.forced_output_length ); |
| 319 | *output_length = test_driver_cipher_hooks.forced_output_length; |
Ronald Cron | 8d310ad | 2020-12-15 15:17:20 +0100 | [diff] [blame] | 320 | |
| 321 | return( test_driver_cipher_hooks.forced_status ); |
Steven Cooreman | 8b12225 | 2020-09-03 15:30:32 +0200 | [diff] [blame] | 322 | } |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 323 | |
Ronald Cron | 8d310ad | 2020-12-15 15:17:20 +0100 | [diff] [blame] | 324 | if( test_driver_cipher_hooks.forced_status != PSA_SUCCESS ) |
| 325 | return( test_driver_cipher_hooks.forced_status ); |
| 326 | |
Ronald Cron | 3522e32 | 2021-03-12 11:08:49 +0100 | [diff] [blame] | 327 | return( mbedtls_transparent_test_driver_cipher_finish( |
| 328 | operation, output, output_size, output_length ) ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 329 | } |
| 330 | |
| 331 | /* |
| 332 | * opaque versions, to do |
| 333 | */ |
| 334 | psa_status_t test_opaque_cipher_encrypt( |
| 335 | const psa_key_attributes_t *attributes, |
| 336 | const uint8_t *key, size_t key_length, |
| 337 | psa_algorithm_t alg, |
| 338 | const uint8_t *input, size_t input_length, |
| 339 | uint8_t *output, size_t output_size, size_t *output_length) |
| 340 | { |
| 341 | (void) attributes; |
| 342 | (void) key; |
| 343 | (void) key_length; |
| 344 | (void) alg; |
| 345 | (void) input; |
| 346 | (void) input_length; |
| 347 | (void) output; |
| 348 | (void) output_size; |
| 349 | (void) output_length; |
Steven Cooreman | acb5a10 | 2020-09-08 14:06:57 +0200 | [diff] [blame] | 350 | return( PSA_ERROR_NOT_SUPPORTED ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 351 | } |
| 352 | |
| 353 | psa_status_t test_opaque_cipher_decrypt( |
| 354 | const psa_key_attributes_t *attributes, |
| 355 | const uint8_t *key, size_t key_length, |
| 356 | psa_algorithm_t alg, |
| 357 | const uint8_t *input, size_t input_length, |
| 358 | uint8_t *output, size_t output_size, size_t *output_length) |
| 359 | { |
| 360 | (void) attributes; |
| 361 | (void) key; |
| 362 | (void) key_length; |
| 363 | (void) alg; |
| 364 | (void) input; |
| 365 | (void) input_length; |
| 366 | (void) output; |
| 367 | (void) output_size; |
| 368 | (void) output_length; |
Steven Cooreman | acb5a10 | 2020-09-08 14:06:57 +0200 | [diff] [blame] | 369 | return( PSA_ERROR_NOT_SUPPORTED ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 370 | } |
| 371 | |
| 372 | psa_status_t test_opaque_cipher_encrypt_setup( |
Ronald Cron | 7cb9c3d | 2021-03-10 12:21:48 +0100 | [diff] [blame] | 373 | mbedtls_opaque_test_driver_cipher_operation_t *operation, |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 374 | const psa_key_attributes_t *attributes, |
| 375 | const uint8_t *key, size_t key_length, |
| 376 | psa_algorithm_t alg) |
| 377 | { |
| 378 | (void) operation; |
| 379 | (void) attributes; |
| 380 | (void) key; |
| 381 | (void) key_length; |
| 382 | (void) alg; |
Steven Cooreman | acb5a10 | 2020-09-08 14:06:57 +0200 | [diff] [blame] | 383 | return( PSA_ERROR_NOT_SUPPORTED ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 384 | } |
| 385 | |
| 386 | psa_status_t test_opaque_cipher_decrypt_setup( |
Ronald Cron | 7cb9c3d | 2021-03-10 12:21:48 +0100 | [diff] [blame] | 387 | mbedtls_opaque_test_driver_cipher_operation_t *operation, |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 388 | const psa_key_attributes_t *attributes, |
| 389 | const uint8_t *key, size_t key_length, |
| 390 | psa_algorithm_t alg) |
| 391 | { |
| 392 | (void) operation; |
| 393 | (void) attributes; |
| 394 | (void) key; |
| 395 | (void) key_length; |
| 396 | (void) alg; |
Steven Cooreman | acb5a10 | 2020-09-08 14:06:57 +0200 | [diff] [blame] | 397 | return( PSA_ERROR_NOT_SUPPORTED ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 398 | } |
| 399 | |
| 400 | psa_status_t test_opaque_cipher_abort( |
Ronald Cron | 7cb9c3d | 2021-03-10 12:21:48 +0100 | [diff] [blame] | 401 | mbedtls_opaque_test_driver_cipher_operation_t *operation ) |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 402 | { |
| 403 | (void) operation; |
Steven Cooreman | acb5a10 | 2020-09-08 14:06:57 +0200 | [diff] [blame] | 404 | return( PSA_ERROR_NOT_SUPPORTED ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 405 | } |
| 406 | |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 407 | psa_status_t test_opaque_cipher_set_iv( |
Ronald Cron | 7cb9c3d | 2021-03-10 12:21:48 +0100 | [diff] [blame] | 408 | mbedtls_opaque_test_driver_cipher_operation_t *operation, |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 409 | const uint8_t *iv, |
| 410 | size_t iv_length) |
| 411 | { |
| 412 | (void) operation; |
| 413 | (void) iv; |
| 414 | (void) iv_length; |
Steven Cooreman | acb5a10 | 2020-09-08 14:06:57 +0200 | [diff] [blame] | 415 | return( PSA_ERROR_NOT_SUPPORTED ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 416 | } |
| 417 | |
| 418 | psa_status_t test_opaque_cipher_update( |
Ronald Cron | 7cb9c3d | 2021-03-10 12:21:48 +0100 | [diff] [blame] | 419 | mbedtls_opaque_test_driver_cipher_operation_t *operation, |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 420 | const uint8_t *input, |
| 421 | size_t input_length, |
| 422 | uint8_t *output, |
| 423 | size_t output_size, |
| 424 | size_t *output_length) |
| 425 | { |
| 426 | (void) operation; |
| 427 | (void) input; |
| 428 | (void) input_length; |
| 429 | (void) output; |
| 430 | (void) output_size; |
| 431 | (void) output_length; |
Steven Cooreman | acb5a10 | 2020-09-08 14:06:57 +0200 | [diff] [blame] | 432 | return( PSA_ERROR_NOT_SUPPORTED ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 433 | } |
| 434 | |
| 435 | psa_status_t test_opaque_cipher_finish( |
Ronald Cron | 7cb9c3d | 2021-03-10 12:21:48 +0100 | [diff] [blame] | 436 | mbedtls_opaque_test_driver_cipher_operation_t *operation, |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 437 | uint8_t *output, |
| 438 | size_t output_size, |
| 439 | size_t *output_length) |
| 440 | { |
| 441 | (void) operation; |
| 442 | (void) output; |
| 443 | (void) output_size; |
| 444 | (void) output_length; |
Steven Cooreman | acb5a10 | 2020-09-08 14:06:57 +0200 | [diff] [blame] | 445 | return( PSA_ERROR_NOT_SUPPORTED ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 446 | } |
| 447 | #endif /* MBEDTLS_PSA_CRYPTO_DRIVERS && PSA_CRYPTO_DRIVER_TEST */ |