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 | 5240e8b | 2020-09-09 11:51:45 +0200 | [diff] [blame] | 39 | /* Test driver implements AES-CTR only. Its default behaviour (when its return |
| 40 | * status is not overridden through the hooks) is to take care of all AES-CTR |
| 41 | * operations, and return PSA_ERROR_NOT_SUPPORTED for all others. |
Steven Cooreman | acb5a10 | 2020-09-08 14:06:57 +0200 | [diff] [blame] | 42 | * Set test_driver_cipher_hooks.forced_status to PSA_ERROR_NOT_SUPPORTED to use |
Steven Cooreman | 5240e8b | 2020-09-09 11:51:45 +0200 | [diff] [blame] | 43 | * fallback even for AES-CTR. */ |
Steven Cooreman | acb5a10 | 2020-09-08 14:06:57 +0200 | [diff] [blame] | 44 | 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] | 45 | |
Steven Cooreman | fe0ab55 | 2020-09-10 13:07:02 +0200 | [diff] [blame] | 46 | static psa_status_t test_transparent_cipher_oneshot( |
| 47 | mbedtls_operation_t direction, |
| 48 | const psa_key_attributes_t *attributes, |
| 49 | const uint8_t *key, size_t key_length, |
| 50 | psa_algorithm_t alg, |
| 51 | const uint8_t *input, size_t input_length, |
| 52 | uint8_t *output, size_t output_size, size_t *output_length) |
| 53 | { |
| 54 | test_driver_cipher_hooks.hits++; |
| 55 | |
| 56 | /* Test driver supports AES-CTR only, to verify operation calls. */ |
| 57 | if( alg != PSA_ALG_CTR || |
| 58 | psa_get_key_type( attributes ) != PSA_KEY_TYPE_AES ) |
| 59 | return( PSA_ERROR_NOT_SUPPORTED ); |
| 60 | |
| 61 | /* If test driver response code is not SUCCESS, we can return early */ |
| 62 | if( test_driver_cipher_hooks.forced_status != PSA_SUCCESS ) |
| 63 | return( test_driver_cipher_hooks.forced_status ); |
| 64 | |
| 65 | /* If test driver output is overridden, we don't need to do actual crypto */ |
| 66 | if( test_driver_cipher_hooks.forced_output != NULL ) |
| 67 | { |
| 68 | if( output_size < test_driver_cipher_hooks.forced_output_length ) |
| 69 | return( PSA_ERROR_BUFFER_TOO_SMALL ); |
| 70 | |
| 71 | memcpy( output, |
| 72 | test_driver_cipher_hooks.forced_output, |
| 73 | test_driver_cipher_hooks.forced_output_length ); |
| 74 | *output_length = test_driver_cipher_hooks.forced_output_length; |
| 75 | |
| 76 | return( test_driver_cipher_hooks.forced_status ); |
| 77 | } |
| 78 | |
| 79 | /* Run AES-CTR using the cipher module */ |
| 80 | { |
| 81 | mbedtls_test_rnd_pseudo_info rnd_info; |
| 82 | memset( &rnd_info, 0x5A, sizeof( mbedtls_test_rnd_pseudo_info ) ); |
| 83 | |
| 84 | const mbedtls_cipher_info_t *cipher_info = |
| 85 | mbedtls_cipher_info_from_values( MBEDTLS_CIPHER_ID_AES, |
| 86 | key_length * 8, |
| 87 | MBEDTLS_MODE_CTR ); |
| 88 | mbedtls_cipher_context_t cipher; |
| 89 | int ret = 0; |
| 90 | uint8_t temp_output_buffer[16] = {0}; |
| 91 | size_t temp_output_length = 0; |
| 92 | |
| 93 | if( direction == MBEDTLS_ENCRYPT ) |
| 94 | { |
| 95 | /* Oneshot encrypt needs to prepend the IV to the output */ |
| 96 | if( output_size < ( input_length + 16 ) ) |
| 97 | return( PSA_ERROR_BUFFER_TOO_SMALL ); |
| 98 | } |
| 99 | else |
| 100 | { |
| 101 | /* Oneshot decrypt has the IV prepended to the input */ |
| 102 | if( output_size < ( input_length - 16 ) ) |
| 103 | return( PSA_ERROR_BUFFER_TOO_SMALL ); |
| 104 | } |
| 105 | |
| 106 | if( cipher_info == NULL ) |
| 107 | return( PSA_ERROR_NOT_SUPPORTED ); |
| 108 | |
| 109 | mbedtls_cipher_init( &cipher ); |
| 110 | ret = mbedtls_cipher_setup( &cipher, cipher_info ); |
| 111 | if( ret != 0 ) |
| 112 | goto exit; |
| 113 | |
| 114 | ret = mbedtls_cipher_setkey( &cipher, |
| 115 | key, |
| 116 | key_length * 8, direction ); |
| 117 | if( ret != 0 ) |
| 118 | goto exit; |
| 119 | |
| 120 | if( direction == MBEDTLS_ENCRYPT ) |
| 121 | { |
| 122 | mbedtls_test_rnd_pseudo_info rnd_info; |
| 123 | memset( &rnd_info, 0x5A, sizeof( mbedtls_test_rnd_pseudo_info ) ); |
| 124 | |
| 125 | ret = mbedtls_test_rnd_pseudo_rand( &rnd_info, |
| 126 | temp_output_buffer, |
| 127 | 16 ); |
| 128 | if( ret != 0 ) |
| 129 | goto exit; |
| 130 | |
| 131 | ret = mbedtls_cipher_set_iv( &cipher, temp_output_buffer, 16 ); |
| 132 | } |
| 133 | else |
| 134 | ret = mbedtls_cipher_set_iv( &cipher, input, 16 ); |
| 135 | |
| 136 | if( ret != 0 ) |
| 137 | goto exit; |
| 138 | |
| 139 | if( direction == MBEDTLS_ENCRYPT ) |
| 140 | { |
| 141 | ret = mbedtls_cipher_update( &cipher, |
| 142 | input, input_length, |
| 143 | &output[16], output_length ); |
| 144 | if( ret == 0 ) |
| 145 | { |
| 146 | memcpy( output, temp_output_buffer, 16 ); |
| 147 | *output_length += 16; |
| 148 | } |
| 149 | } |
| 150 | else |
| 151 | ret = mbedtls_cipher_update( &cipher, |
| 152 | &input[16], input_length - 16, |
| 153 | output, output_length ); |
| 154 | |
| 155 | if( ret != 0 ) |
| 156 | goto exit; |
| 157 | |
| 158 | ret = mbedtls_cipher_finish( &cipher, |
| 159 | temp_output_buffer, |
| 160 | &temp_output_length ); |
| 161 | |
| 162 | exit: |
| 163 | if( ret != 0 ) |
| 164 | { |
| 165 | *output_length = 0; |
| 166 | memset(output, 0, output_size); |
| 167 | } |
| 168 | |
| 169 | mbedtls_cipher_free( &cipher ); |
| 170 | return( mbedtls_to_psa_error( ret ) ); |
| 171 | } |
| 172 | } |
| 173 | |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 174 | psa_status_t test_transparent_cipher_encrypt( |
| 175 | const psa_key_attributes_t *attributes, |
| 176 | const uint8_t *key, size_t key_length, |
| 177 | psa_algorithm_t alg, |
| 178 | const uint8_t *input, size_t input_length, |
| 179 | uint8_t *output, size_t output_size, size_t *output_length) |
| 180 | { |
Steven Cooreman | fe0ab55 | 2020-09-10 13:07:02 +0200 | [diff] [blame] | 181 | return ( |
| 182 | test_transparent_cipher_oneshot( |
| 183 | MBEDTLS_ENCRYPT, |
| 184 | attributes, |
| 185 | key, key_length, |
| 186 | alg, |
| 187 | input, input_length, |
| 188 | output, output_size, output_length) ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 189 | } |
| 190 | |
| 191 | psa_status_t test_transparent_cipher_decrypt( |
| 192 | const psa_key_attributes_t *attributes, |
| 193 | const uint8_t *key, size_t key_length, |
| 194 | psa_algorithm_t alg, |
| 195 | const uint8_t *input, size_t input_length, |
| 196 | uint8_t *output, size_t output_size, size_t *output_length) |
| 197 | { |
Steven Cooreman | fe0ab55 | 2020-09-10 13:07:02 +0200 | [diff] [blame] | 198 | return ( |
| 199 | test_transparent_cipher_oneshot( |
| 200 | MBEDTLS_DECRYPT, |
| 201 | attributes, |
| 202 | key, key_length, |
| 203 | alg, |
| 204 | input, input_length, |
| 205 | output, output_size, output_length) ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 206 | } |
| 207 | |
Steven Cooreman | 16afd3d | 2020-09-09 15:36:39 +0200 | [diff] [blame] | 208 | psa_status_t test_transparent_cipher_encrypt_setup( |
| 209 | test_transparent_cipher_operation_t *operation, |
| 210 | const psa_key_attributes_t *attributes, |
| 211 | const uint8_t *key, size_t key_length, |
| 212 | psa_algorithm_t alg) |
| 213 | { |
Ronald Cron | 8d310ad | 2020-12-15 15:17:20 +0100 | [diff] [blame^] | 214 | test_driver_cipher_hooks.hits++; |
| 215 | |
| 216 | /* Wiping the entire struct here, instead of member-by-member. This is |
| 217 | * useful for the test suite, since it gives a chance of catching memory |
| 218 | * corruption errors should the core not have allocated (enough) memory for |
| 219 | * our context struct. */ |
| 220 | memset( operation, 0, sizeof( *operation ) ); |
| 221 | |
| 222 | if( test_driver_cipher_hooks.forced_status != PSA_SUCCESS ) |
| 223 | return( test_driver_cipher_hooks.forced_status ); |
| 224 | |
| 225 | return ( mbedtls_psa_cipher_encrypt_setup( operation, |
| 226 | attributes, |
| 227 | key, |
| 228 | key_length, |
| 229 | alg ) ); |
Steven Cooreman | 16afd3d | 2020-09-09 15:36:39 +0200 | [diff] [blame] | 230 | } |
| 231 | |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 232 | psa_status_t test_transparent_cipher_decrypt_setup( |
| 233 | test_transparent_cipher_operation_t *operation, |
| 234 | const psa_key_attributes_t *attributes, |
| 235 | const uint8_t *key, size_t key_length, |
| 236 | psa_algorithm_t alg) |
| 237 | { |
Ronald Cron | 8d310ad | 2020-12-15 15:17:20 +0100 | [diff] [blame^] | 238 | test_driver_cipher_hooks.hits++; |
| 239 | |
| 240 | if( test_driver_cipher_hooks.forced_status != PSA_SUCCESS ) |
| 241 | return( test_driver_cipher_hooks.forced_status ); |
| 242 | |
| 243 | return ( mbedtls_psa_cipher_decrypt_setup( operation, |
| 244 | attributes, |
| 245 | key, |
| 246 | key_length, |
| 247 | alg ) ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 248 | } |
| 249 | |
| 250 | psa_status_t test_transparent_cipher_abort( |
| 251 | test_transparent_cipher_operation_t *operation) |
| 252 | { |
Steven Cooreman | 89e54f2 | 2020-09-10 18:07:57 +0200 | [diff] [blame] | 253 | test_driver_cipher_hooks.hits++; |
| 254 | |
Steven Cooreman | 8b12225 | 2020-09-03 15:30:32 +0200 | [diff] [blame] | 255 | if( operation->alg == 0 ) |
| 256 | return( PSA_SUCCESS ); |
Steven Cooreman | 8b12225 | 2020-09-03 15:30:32 +0200 | [diff] [blame] | 257 | |
Ronald Cron | 8d310ad | 2020-12-15 15:17:20 +0100 | [diff] [blame^] | 258 | mbedtls_psa_cipher_abort( operation ); |
Steven Cooreman | 8b12225 | 2020-09-03 15:30:32 +0200 | [diff] [blame] | 259 | |
Ronald Cron | 8d310ad | 2020-12-15 15:17:20 +0100 | [diff] [blame^] | 260 | /* Wiping the entire struct here, instead of member-by-member. This is |
| 261 | * useful for the test suite, since it gives a chance of catching memory |
| 262 | * corruption errors should the core not have allocated (enough) memory for |
| 263 | * our context struct. */ |
Steven Cooreman | 5240e8b | 2020-09-09 11:51:45 +0200 | [diff] [blame] | 264 | memset( operation, 0, sizeof( *operation ) ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 265 | |
Ronald Cron | 8d310ad | 2020-12-15 15:17:20 +0100 | [diff] [blame^] | 266 | return( test_driver_cipher_hooks.forced_status ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 267 | } |
| 268 | |
| 269 | psa_status_t test_transparent_cipher_generate_iv( |
| 270 | test_transparent_cipher_operation_t *operation, |
| 271 | uint8_t *iv, |
| 272 | size_t iv_size, |
| 273 | size_t *iv_length) |
| 274 | { |
Steven Cooreman | acb5a10 | 2020-09-08 14:06:57 +0200 | [diff] [blame] | 275 | test_driver_cipher_hooks.hits++; |
Steven Cooreman | 8b12225 | 2020-09-03 15:30:32 +0200 | [diff] [blame] | 276 | |
Steven Cooreman | 89e54f2 | 2020-09-10 18:07:57 +0200 | [diff] [blame] | 277 | if( test_driver_cipher_hooks.forced_status != PSA_SUCCESS ) |
| 278 | return( test_driver_cipher_hooks.forced_status ); |
| 279 | |
Ronald Cron | 8d310ad | 2020-12-15 15:17:20 +0100 | [diff] [blame^] | 280 | return( mbedtls_psa_cipher_generate_iv( operation, |
| 281 | iv, |
| 282 | iv_size, |
| 283 | iv_length ) ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 284 | } |
| 285 | |
| 286 | psa_status_t test_transparent_cipher_set_iv( |
| 287 | test_transparent_cipher_operation_t *operation, |
| 288 | const uint8_t *iv, |
| 289 | size_t iv_length) |
| 290 | { |
Steven Cooreman | acb5a10 | 2020-09-08 14:06:57 +0200 | [diff] [blame] | 291 | test_driver_cipher_hooks.hits++; |
Steven Cooreman | 8b12225 | 2020-09-03 15:30:32 +0200 | [diff] [blame] | 292 | |
Steven Cooreman | 89e54f2 | 2020-09-10 18:07:57 +0200 | [diff] [blame] | 293 | if( test_driver_cipher_hooks.forced_status != PSA_SUCCESS ) |
| 294 | return( test_driver_cipher_hooks.forced_status ); |
| 295 | |
Ronald Cron | 8d310ad | 2020-12-15 15:17:20 +0100 | [diff] [blame^] | 296 | return( mbedtls_psa_cipher_set_iv( operation, |
| 297 | iv, |
| 298 | iv_length ) ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 299 | } |
| 300 | |
| 301 | psa_status_t test_transparent_cipher_update( |
| 302 | test_transparent_cipher_operation_t *operation, |
| 303 | const uint8_t *input, |
| 304 | size_t input_length, |
| 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 | |
| 327 | return( mbedtls_psa_cipher_update( operation, |
| 328 | input, input_length, |
| 329 | output, output_size, |
| 330 | output_length ) ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 331 | } |
| 332 | |
| 333 | psa_status_t test_transparent_cipher_finish( |
| 334 | test_transparent_cipher_operation_t *operation, |
| 335 | uint8_t *output, |
| 336 | size_t output_size, |
| 337 | size_t *output_length) |
| 338 | { |
Steven Cooreman | acb5a10 | 2020-09-08 14:06:57 +0200 | [diff] [blame] | 339 | test_driver_cipher_hooks.hits++; |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 340 | |
Steven Cooreman | acb5a10 | 2020-09-08 14:06:57 +0200 | [diff] [blame] | 341 | if( test_driver_cipher_hooks.forced_output != NULL ) |
Steven Cooreman | 8b12225 | 2020-09-03 15:30:32 +0200 | [diff] [blame] | 342 | { |
Steven Cooreman | acb5a10 | 2020-09-08 14:06:57 +0200 | [diff] [blame] | 343 | if( output_size < test_driver_cipher_hooks.forced_output_length ) |
Steven Cooreman | 8b12225 | 2020-09-03 15:30:32 +0200 | [diff] [blame] | 344 | return PSA_ERROR_BUFFER_TOO_SMALL; |
| 345 | |
Steven Cooreman | acb5a10 | 2020-09-08 14:06:57 +0200 | [diff] [blame] | 346 | memcpy( output, |
| 347 | test_driver_cipher_hooks.forced_output, |
| 348 | test_driver_cipher_hooks.forced_output_length ); |
| 349 | *output_length = test_driver_cipher_hooks.forced_output_length; |
Ronald Cron | 8d310ad | 2020-12-15 15:17:20 +0100 | [diff] [blame^] | 350 | |
| 351 | return( test_driver_cipher_hooks.forced_status ); |
Steven Cooreman | 8b12225 | 2020-09-03 15:30:32 +0200 | [diff] [blame] | 352 | } |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 353 | |
Ronald Cron | 8d310ad | 2020-12-15 15:17:20 +0100 | [diff] [blame^] | 354 | if( test_driver_cipher_hooks.forced_status != PSA_SUCCESS ) |
| 355 | return( test_driver_cipher_hooks.forced_status ); |
| 356 | |
| 357 | return( mbedtls_psa_cipher_finish( operation, |
| 358 | output, output_size, |
| 359 | output_length ) ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 360 | } |
| 361 | |
| 362 | /* |
| 363 | * opaque versions, to do |
| 364 | */ |
| 365 | psa_status_t test_opaque_cipher_encrypt( |
| 366 | const psa_key_attributes_t *attributes, |
| 367 | const uint8_t *key, size_t key_length, |
| 368 | psa_algorithm_t alg, |
| 369 | const uint8_t *input, size_t input_length, |
| 370 | uint8_t *output, size_t output_size, size_t *output_length) |
| 371 | { |
| 372 | (void) attributes; |
| 373 | (void) key; |
| 374 | (void) key_length; |
| 375 | (void) alg; |
| 376 | (void) input; |
| 377 | (void) input_length; |
| 378 | (void) output; |
| 379 | (void) output_size; |
| 380 | (void) output_length; |
Steven Cooreman | acb5a10 | 2020-09-08 14:06:57 +0200 | [diff] [blame] | 381 | return( PSA_ERROR_NOT_SUPPORTED ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 382 | } |
| 383 | |
| 384 | psa_status_t test_opaque_cipher_decrypt( |
| 385 | const psa_key_attributes_t *attributes, |
| 386 | const uint8_t *key, size_t key_length, |
| 387 | psa_algorithm_t alg, |
| 388 | const uint8_t *input, size_t input_length, |
| 389 | uint8_t *output, size_t output_size, size_t *output_length) |
| 390 | { |
| 391 | (void) attributes; |
| 392 | (void) key; |
| 393 | (void) key_length; |
| 394 | (void) alg; |
| 395 | (void) input; |
| 396 | (void) input_length; |
| 397 | (void) output; |
| 398 | (void) output_size; |
| 399 | (void) output_length; |
Steven Cooreman | acb5a10 | 2020-09-08 14:06:57 +0200 | [diff] [blame] | 400 | return( PSA_ERROR_NOT_SUPPORTED ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 401 | } |
| 402 | |
| 403 | psa_status_t test_opaque_cipher_encrypt_setup( |
| 404 | test_opaque_cipher_operation_t *operation, |
| 405 | const psa_key_attributes_t *attributes, |
| 406 | const uint8_t *key, size_t key_length, |
| 407 | psa_algorithm_t alg) |
| 408 | { |
| 409 | (void) operation; |
| 410 | (void) attributes; |
| 411 | (void) key; |
| 412 | (void) key_length; |
| 413 | (void) alg; |
Steven Cooreman | acb5a10 | 2020-09-08 14:06:57 +0200 | [diff] [blame] | 414 | return( PSA_ERROR_NOT_SUPPORTED ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 415 | } |
| 416 | |
| 417 | psa_status_t test_opaque_cipher_decrypt_setup( |
| 418 | test_opaque_cipher_operation_t *operation, |
| 419 | const psa_key_attributes_t *attributes, |
| 420 | const uint8_t *key, size_t key_length, |
| 421 | psa_algorithm_t alg) |
| 422 | { |
| 423 | (void) operation; |
| 424 | (void) attributes; |
| 425 | (void) key; |
| 426 | (void) key_length; |
| 427 | (void) alg; |
Steven Cooreman | acb5a10 | 2020-09-08 14:06:57 +0200 | [diff] [blame] | 428 | return( PSA_ERROR_NOT_SUPPORTED ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 429 | } |
| 430 | |
| 431 | psa_status_t test_opaque_cipher_abort( |
| 432 | test_opaque_cipher_operation_t *operation) |
| 433 | { |
| 434 | (void) operation; |
Steven Cooreman | acb5a10 | 2020-09-08 14:06:57 +0200 | [diff] [blame] | 435 | return( PSA_ERROR_NOT_SUPPORTED ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 436 | } |
| 437 | |
| 438 | psa_status_t test_opaque_cipher_generate_iv( |
| 439 | test_opaque_cipher_operation_t *operation, |
| 440 | uint8_t *iv, |
| 441 | size_t iv_size, |
| 442 | size_t *iv_length) |
| 443 | { |
| 444 | (void) operation; |
| 445 | (void) iv; |
| 446 | (void) iv_size; |
| 447 | (void) iv_length; |
Steven Cooreman | acb5a10 | 2020-09-08 14:06:57 +0200 | [diff] [blame] | 448 | return( PSA_ERROR_NOT_SUPPORTED ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 449 | } |
| 450 | |
| 451 | psa_status_t test_opaque_cipher_set_iv( |
| 452 | test_opaque_cipher_operation_t *operation, |
| 453 | const uint8_t *iv, |
| 454 | size_t iv_length) |
| 455 | { |
| 456 | (void) operation; |
| 457 | (void) iv; |
| 458 | (void) iv_length; |
Steven Cooreman | acb5a10 | 2020-09-08 14:06:57 +0200 | [diff] [blame] | 459 | return( PSA_ERROR_NOT_SUPPORTED ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 460 | } |
| 461 | |
| 462 | psa_status_t test_opaque_cipher_update( |
| 463 | test_opaque_cipher_operation_t *operation, |
| 464 | const uint8_t *input, |
| 465 | size_t input_length, |
| 466 | uint8_t *output, |
| 467 | size_t output_size, |
| 468 | size_t *output_length) |
| 469 | { |
| 470 | (void) operation; |
| 471 | (void) input; |
| 472 | (void) input_length; |
| 473 | (void) output; |
| 474 | (void) output_size; |
| 475 | (void) output_length; |
Steven Cooreman | acb5a10 | 2020-09-08 14:06:57 +0200 | [diff] [blame] | 476 | return( PSA_ERROR_NOT_SUPPORTED ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 477 | } |
| 478 | |
| 479 | psa_status_t test_opaque_cipher_finish( |
| 480 | test_opaque_cipher_operation_t *operation, |
| 481 | uint8_t *output, |
| 482 | size_t output_size, |
| 483 | size_t *output_length) |
| 484 | { |
| 485 | (void) operation; |
| 486 | (void) output; |
| 487 | (void) output_size; |
| 488 | (void) output_length; |
Steven Cooreman | acb5a10 | 2020-09-08 14:06:57 +0200 | [diff] [blame] | 489 | return( PSA_ERROR_NOT_SUPPORTED ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 490 | } |
| 491 | #endif /* MBEDTLS_PSA_CRYPTO_DRIVERS && PSA_CRYPTO_DRIVER_TEST */ |