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 | |
Ronald Cron | c4bc12e | 2021-04-13 12:41:34 +0200 | [diff] [blame] | 39 | mbedtls_test_driver_cipher_hooks_t mbedtls_test_driver_cipher_hooks = |
| 40 | MBEDTLS_TEST_DRIVER_CIPHER_INIT; |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 41 | |
gabor-mezei-arm | fa990b5 | 2021-03-25 11:17:10 +0100 | [diff] [blame] | 42 | psa_status_t mbedtls_test_transparent_cipher_encrypt( |
Steven Cooreman | fe0ab55 | 2020-09-10 13:07:02 +0200 | [diff] [blame] | 43 | const psa_key_attributes_t *attributes, |
gabor-mezei-arm | fa990b5 | 2021-03-25 11:17:10 +0100 | [diff] [blame] | 44 | const uint8_t *key_buffer, |
| 45 | size_t key_buffer_size, |
Steven Cooreman | fe0ab55 | 2020-09-10 13:07:02 +0200 | [diff] [blame] | 46 | psa_algorithm_t alg, |
gabor-mezei-arm | fa990b5 | 2021-03-25 11:17:10 +0100 | [diff] [blame] | 47 | const uint8_t *input, |
| 48 | size_t input_length, |
| 49 | uint8_t *output, |
| 50 | size_t output_size, |
| 51 | size_t *output_length ) |
Steven Cooreman | fe0ab55 | 2020-09-10 13:07:02 +0200 | [diff] [blame] | 52 | { |
Ronald Cron | c4bc12e | 2021-04-13 12:41:34 +0200 | [diff] [blame] | 53 | mbedtls_test_driver_cipher_hooks.hits++; |
Steven Cooreman | fe0ab55 | 2020-09-10 13:07:02 +0200 | [diff] [blame] | 54 | |
Ronald Cron | c4bc12e | 2021-04-13 12:41:34 +0200 | [diff] [blame] | 55 | if( mbedtls_test_driver_cipher_hooks.forced_output != NULL ) |
Steven Cooreman | fe0ab55 | 2020-09-10 13:07:02 +0200 | [diff] [blame] | 56 | { |
Ronald Cron | c4bc12e | 2021-04-13 12:41:34 +0200 | [diff] [blame] | 57 | if( output_size < mbedtls_test_driver_cipher_hooks.forced_output_length ) |
Steven Cooreman | fe0ab55 | 2020-09-10 13:07:02 +0200 | [diff] [blame] | 58 | return( PSA_ERROR_BUFFER_TOO_SMALL ); |
| 59 | |
| 60 | memcpy( output, |
Ronald Cron | c4bc12e | 2021-04-13 12:41:34 +0200 | [diff] [blame] | 61 | mbedtls_test_driver_cipher_hooks.forced_output, |
| 62 | mbedtls_test_driver_cipher_hooks.forced_output_length ); |
| 63 | *output_length = mbedtls_test_driver_cipher_hooks.forced_output_length; |
Steven Cooreman | fe0ab55 | 2020-09-10 13:07:02 +0200 | [diff] [blame] | 64 | |
Ronald Cron | c4bc12e | 2021-04-13 12:41:34 +0200 | [diff] [blame] | 65 | return( mbedtls_test_driver_cipher_hooks.forced_status ); |
Steven Cooreman | fe0ab55 | 2020-09-10 13:07:02 +0200 | [diff] [blame] | 66 | } |
| 67 | |
gabor-mezei-arm | fa990b5 | 2021-03-25 11:17:10 +0100 | [diff] [blame] | 68 | if( mbedtls_test_driver_cipher_hooks.forced_status != PSA_SUCCESS ) |
| 69 | return( mbedtls_test_driver_cipher_hooks.forced_status ); |
Steven Cooreman | fe0ab55 | 2020-09-10 13:07:02 +0200 | [diff] [blame] | 70 | |
gabor-mezei-arm | fa990b5 | 2021-03-25 11:17:10 +0100 | [diff] [blame] | 71 | psa_generate_random( output, PSA_CIPHER_IV_LENGTH( attributes->core.type, alg ) ); |
Steven Cooreman | fe0ab55 | 2020-09-10 13:07:02 +0200 | [diff] [blame] | 72 | |
gabor-mezei-arm | fa990b5 | 2021-03-25 11:17:10 +0100 | [diff] [blame] | 73 | return( mbedtls_transparent_test_driver_cipher_encrypt( |
| 74 | attributes, key_buffer, key_buffer_size, |
| 75 | alg, input, input_length, |
| 76 | output, output_size, output_length ) ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 77 | } |
| 78 | |
Ronald Cron | c4bc12e | 2021-04-13 12:41:34 +0200 | [diff] [blame] | 79 | psa_status_t mbedtls_test_transparent_cipher_decrypt( |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 80 | const psa_key_attributes_t *attributes, |
gabor-mezei-arm | fa990b5 | 2021-03-25 11:17:10 +0100 | [diff] [blame] | 81 | const uint8_t *key_buffer, |
| 82 | size_t key_buffer_size, |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 83 | psa_algorithm_t alg, |
gabor-mezei-arm | fa990b5 | 2021-03-25 11:17:10 +0100 | [diff] [blame] | 84 | const uint8_t *input, |
| 85 | size_t input_length, |
| 86 | uint8_t *output, |
| 87 | size_t output_size, |
| 88 | size_t *output_length ) |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 89 | { |
gabor-mezei-arm | fa990b5 | 2021-03-25 11:17:10 +0100 | [diff] [blame] | 90 | mbedtls_test_driver_cipher_hooks.hits++; |
| 91 | |
| 92 | if( mbedtls_test_driver_cipher_hooks.forced_output != NULL ) |
| 93 | { |
| 94 | if( output_size < mbedtls_test_driver_cipher_hooks.forced_output_length ) |
| 95 | return( PSA_ERROR_BUFFER_TOO_SMALL ); |
| 96 | |
| 97 | memcpy( output, |
| 98 | mbedtls_test_driver_cipher_hooks.forced_output, |
| 99 | mbedtls_test_driver_cipher_hooks.forced_output_length ); |
| 100 | *output_length = mbedtls_test_driver_cipher_hooks.forced_output_length; |
| 101 | |
| 102 | return( mbedtls_test_driver_cipher_hooks.forced_status ); |
| 103 | } |
| 104 | |
| 105 | if( mbedtls_test_driver_cipher_hooks.forced_status != PSA_SUCCESS ) |
| 106 | return( mbedtls_test_driver_cipher_hooks.forced_status ); |
| 107 | |
| 108 | return( mbedtls_transparent_test_driver_cipher_decrypt( |
| 109 | attributes, key_buffer, key_buffer_size, |
| 110 | alg, input, input_length, |
| 111 | output, output_size, output_length ) ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 112 | } |
| 113 | |
Ronald Cron | c4bc12e | 2021-04-13 12:41:34 +0200 | [diff] [blame] | 114 | psa_status_t mbedtls_test_transparent_cipher_encrypt_setup( |
Ronald Cron | 7cb9c3d | 2021-03-10 12:21:48 +0100 | [diff] [blame] | 115 | mbedtls_transparent_test_driver_cipher_operation_t *operation, |
Steven Cooreman | 16afd3d | 2020-09-09 15:36:39 +0200 | [diff] [blame] | 116 | const psa_key_attributes_t *attributes, |
| 117 | const uint8_t *key, size_t key_length, |
| 118 | psa_algorithm_t alg) |
| 119 | { |
Ronald Cron | c4bc12e | 2021-04-13 12:41:34 +0200 | [diff] [blame] | 120 | mbedtls_test_driver_cipher_hooks.hits++; |
Ronald Cron | 8d310ad | 2020-12-15 15:17:20 +0100 | [diff] [blame] | 121 | |
| 122 | /* Wiping the entire struct here, instead of member-by-member. This is |
| 123 | * useful for the test suite, since it gives a chance of catching memory |
| 124 | * corruption errors should the core not have allocated (enough) memory for |
| 125 | * our context struct. */ |
| 126 | memset( operation, 0, sizeof( *operation ) ); |
| 127 | |
Ronald Cron | c4bc12e | 2021-04-13 12:41:34 +0200 | [diff] [blame] | 128 | if( mbedtls_test_driver_cipher_hooks.forced_status != PSA_SUCCESS ) |
| 129 | return( mbedtls_test_driver_cipher_hooks.forced_status ); |
Ronald Cron | 8d310ad | 2020-12-15 15:17:20 +0100 | [diff] [blame] | 130 | |
Ronald Cron | 3522e32 | 2021-03-12 11:08:49 +0100 | [diff] [blame] | 131 | return ( mbedtls_transparent_test_driver_cipher_encrypt_setup( |
| 132 | operation, attributes, key, key_length, alg ) ); |
Steven Cooreman | 16afd3d | 2020-09-09 15:36:39 +0200 | [diff] [blame] | 133 | } |
| 134 | |
Ronald Cron | c4bc12e | 2021-04-13 12:41:34 +0200 | [diff] [blame] | 135 | psa_status_t mbedtls_test_transparent_cipher_decrypt_setup( |
Ronald Cron | 7cb9c3d | 2021-03-10 12:21:48 +0100 | [diff] [blame] | 136 | mbedtls_transparent_test_driver_cipher_operation_t *operation, |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 137 | const psa_key_attributes_t *attributes, |
| 138 | const uint8_t *key, size_t key_length, |
| 139 | psa_algorithm_t alg) |
| 140 | { |
Ronald Cron | c4bc12e | 2021-04-13 12:41:34 +0200 | [diff] [blame] | 141 | mbedtls_test_driver_cipher_hooks.hits++; |
Ronald Cron | 8d310ad | 2020-12-15 15:17:20 +0100 | [diff] [blame] | 142 | |
Ronald Cron | c4bc12e | 2021-04-13 12:41:34 +0200 | [diff] [blame] | 143 | if( mbedtls_test_driver_cipher_hooks.forced_status != PSA_SUCCESS ) |
| 144 | return( mbedtls_test_driver_cipher_hooks.forced_status ); |
Ronald Cron | 8d310ad | 2020-12-15 15:17:20 +0100 | [diff] [blame] | 145 | |
Ronald Cron | 3522e32 | 2021-03-12 11:08:49 +0100 | [diff] [blame] | 146 | return ( mbedtls_transparent_test_driver_cipher_decrypt_setup( |
| 147 | operation, attributes, key, key_length, alg ) ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 148 | } |
| 149 | |
Ronald Cron | c4bc12e | 2021-04-13 12:41:34 +0200 | [diff] [blame] | 150 | psa_status_t mbedtls_test_transparent_cipher_abort( |
Ronald Cron | 7cb9c3d | 2021-03-10 12:21:48 +0100 | [diff] [blame] | 151 | mbedtls_transparent_test_driver_cipher_operation_t *operation) |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 152 | { |
Ronald Cron | c4bc12e | 2021-04-13 12:41:34 +0200 | [diff] [blame] | 153 | mbedtls_test_driver_cipher_hooks.hits++; |
Steven Cooreman | 89e54f2 | 2020-09-10 18:07:57 +0200 | [diff] [blame] | 154 | |
Steven Cooreman | 8b12225 | 2020-09-03 15:30:32 +0200 | [diff] [blame] | 155 | if( operation->alg == 0 ) |
| 156 | return( PSA_SUCCESS ); |
Steven Cooreman | 8b12225 | 2020-09-03 15:30:32 +0200 | [diff] [blame] | 157 | |
Ronald Cron | 3522e32 | 2021-03-12 11:08:49 +0100 | [diff] [blame] | 158 | mbedtls_transparent_test_driver_cipher_abort( operation ); |
Steven Cooreman | 8b12225 | 2020-09-03 15:30:32 +0200 | [diff] [blame] | 159 | |
Ronald Cron | 8d310ad | 2020-12-15 15:17:20 +0100 | [diff] [blame] | 160 | /* Wiping the entire struct here, instead of member-by-member. This is |
| 161 | * useful for the test suite, since it gives a chance of catching memory |
| 162 | * corruption errors should the core not have allocated (enough) memory for |
| 163 | * our context struct. */ |
Steven Cooreman | 5240e8b | 2020-09-09 11:51:45 +0200 | [diff] [blame] | 164 | memset( operation, 0, sizeof( *operation ) ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 165 | |
Ronald Cron | c4bc12e | 2021-04-13 12:41:34 +0200 | [diff] [blame] | 166 | return( mbedtls_test_driver_cipher_hooks.forced_status ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 167 | } |
| 168 | |
Ronald Cron | c4bc12e | 2021-04-13 12:41:34 +0200 | [diff] [blame] | 169 | psa_status_t mbedtls_test_transparent_cipher_set_iv( |
Ronald Cron | 7cb9c3d | 2021-03-10 12:21:48 +0100 | [diff] [blame] | 170 | mbedtls_transparent_test_driver_cipher_operation_t *operation, |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 171 | const uint8_t *iv, |
| 172 | size_t iv_length) |
| 173 | { |
Ronald Cron | c4bc12e | 2021-04-13 12:41:34 +0200 | [diff] [blame] | 174 | mbedtls_test_driver_cipher_hooks.hits++; |
Steven Cooreman | 8b12225 | 2020-09-03 15:30:32 +0200 | [diff] [blame] | 175 | |
Ronald Cron | c4bc12e | 2021-04-13 12:41:34 +0200 | [diff] [blame] | 176 | if( mbedtls_test_driver_cipher_hooks.forced_status != PSA_SUCCESS ) |
| 177 | return( mbedtls_test_driver_cipher_hooks.forced_status ); |
Steven Cooreman | 89e54f2 | 2020-09-10 18:07:57 +0200 | [diff] [blame] | 178 | |
Ronald Cron | 3522e32 | 2021-03-12 11:08:49 +0100 | [diff] [blame] | 179 | return( mbedtls_transparent_test_driver_cipher_set_iv( |
| 180 | operation, iv, iv_length ) ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 181 | } |
| 182 | |
Ronald Cron | c4bc12e | 2021-04-13 12:41:34 +0200 | [diff] [blame] | 183 | psa_status_t mbedtls_test_transparent_cipher_update( |
Ronald Cron | 7cb9c3d | 2021-03-10 12:21:48 +0100 | [diff] [blame] | 184 | mbedtls_transparent_test_driver_cipher_operation_t *operation, |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 185 | const uint8_t *input, |
| 186 | size_t input_length, |
| 187 | uint8_t *output, |
| 188 | size_t output_size, |
| 189 | size_t *output_length) |
| 190 | { |
Ronald Cron | c4bc12e | 2021-04-13 12:41:34 +0200 | [diff] [blame] | 191 | mbedtls_test_driver_cipher_hooks.hits++; |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 192 | |
Ronald Cron | c4bc12e | 2021-04-13 12:41:34 +0200 | [diff] [blame] | 193 | if( mbedtls_test_driver_cipher_hooks.forced_output != NULL ) |
Steven Cooreman | 8b12225 | 2020-09-03 15:30:32 +0200 | [diff] [blame] | 194 | { |
Ronald Cron | c4bc12e | 2021-04-13 12:41:34 +0200 | [diff] [blame] | 195 | if( output_size < mbedtls_test_driver_cipher_hooks.forced_output_length ) |
Steven Cooreman | 8b12225 | 2020-09-03 15:30:32 +0200 | [diff] [blame] | 196 | return PSA_ERROR_BUFFER_TOO_SMALL; |
| 197 | |
Steven Cooreman | acb5a10 | 2020-09-08 14:06:57 +0200 | [diff] [blame] | 198 | memcpy( output, |
Ronald Cron | c4bc12e | 2021-04-13 12:41:34 +0200 | [diff] [blame] | 199 | mbedtls_test_driver_cipher_hooks.forced_output, |
| 200 | mbedtls_test_driver_cipher_hooks.forced_output_length ); |
| 201 | *output_length = mbedtls_test_driver_cipher_hooks.forced_output_length; |
Ronald Cron | 8d310ad | 2020-12-15 15:17:20 +0100 | [diff] [blame] | 202 | |
Ronald Cron | c4bc12e | 2021-04-13 12:41:34 +0200 | [diff] [blame] | 203 | return( mbedtls_test_driver_cipher_hooks.forced_status ); |
Steven Cooreman | 8b12225 | 2020-09-03 15:30:32 +0200 | [diff] [blame] | 204 | } |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 205 | |
Ronald Cron | c4bc12e | 2021-04-13 12:41:34 +0200 | [diff] [blame] | 206 | if( mbedtls_test_driver_cipher_hooks.forced_status != PSA_SUCCESS ) |
| 207 | return( mbedtls_test_driver_cipher_hooks.forced_status ); |
Ronald Cron | 8d310ad | 2020-12-15 15:17:20 +0100 | [diff] [blame] | 208 | |
Ronald Cron | 3522e32 | 2021-03-12 11:08:49 +0100 | [diff] [blame] | 209 | return( mbedtls_transparent_test_driver_cipher_update( |
| 210 | operation, input, input_length, |
| 211 | output, output_size, output_length ) ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 212 | } |
| 213 | |
Ronald Cron | c4bc12e | 2021-04-13 12:41:34 +0200 | [diff] [blame] | 214 | psa_status_t mbedtls_test_transparent_cipher_finish( |
Ronald Cron | 7cb9c3d | 2021-03-10 12:21:48 +0100 | [diff] [blame] | 215 | mbedtls_transparent_test_driver_cipher_operation_t *operation, |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 216 | uint8_t *output, |
| 217 | size_t output_size, |
| 218 | size_t *output_length) |
| 219 | { |
Ronald Cron | c4bc12e | 2021-04-13 12:41:34 +0200 | [diff] [blame] | 220 | mbedtls_test_driver_cipher_hooks.hits++; |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 221 | |
Ronald Cron | c4bc12e | 2021-04-13 12:41:34 +0200 | [diff] [blame] | 222 | if( mbedtls_test_driver_cipher_hooks.forced_output != NULL ) |
Steven Cooreman | 8b12225 | 2020-09-03 15:30:32 +0200 | [diff] [blame] | 223 | { |
Ronald Cron | c4bc12e | 2021-04-13 12:41:34 +0200 | [diff] [blame] | 224 | if( output_size < mbedtls_test_driver_cipher_hooks.forced_output_length ) |
Steven Cooreman | 8b12225 | 2020-09-03 15:30:32 +0200 | [diff] [blame] | 225 | return PSA_ERROR_BUFFER_TOO_SMALL; |
| 226 | |
Steven Cooreman | acb5a10 | 2020-09-08 14:06:57 +0200 | [diff] [blame] | 227 | memcpy( output, |
Ronald Cron | c4bc12e | 2021-04-13 12:41:34 +0200 | [diff] [blame] | 228 | mbedtls_test_driver_cipher_hooks.forced_output, |
| 229 | mbedtls_test_driver_cipher_hooks.forced_output_length ); |
| 230 | *output_length = mbedtls_test_driver_cipher_hooks.forced_output_length; |
Ronald Cron | 8d310ad | 2020-12-15 15:17:20 +0100 | [diff] [blame] | 231 | |
Ronald Cron | c4bc12e | 2021-04-13 12:41:34 +0200 | [diff] [blame] | 232 | return( mbedtls_test_driver_cipher_hooks.forced_status ); |
Steven Cooreman | 8b12225 | 2020-09-03 15:30:32 +0200 | [diff] [blame] | 233 | } |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 234 | |
Ronald Cron | c4bc12e | 2021-04-13 12:41:34 +0200 | [diff] [blame] | 235 | if( mbedtls_test_driver_cipher_hooks.forced_status != PSA_SUCCESS ) |
| 236 | return( mbedtls_test_driver_cipher_hooks.forced_status ); |
Ronald Cron | 8d310ad | 2020-12-15 15:17:20 +0100 | [diff] [blame] | 237 | |
Ronald Cron | 3522e32 | 2021-03-12 11:08:49 +0100 | [diff] [blame] | 238 | return( mbedtls_transparent_test_driver_cipher_finish( |
| 239 | operation, output, output_size, output_length ) ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 240 | } |
| 241 | |
| 242 | /* |
| 243 | * opaque versions, to do |
| 244 | */ |
Ronald Cron | c4bc12e | 2021-04-13 12:41:34 +0200 | [diff] [blame] | 245 | psa_status_t mbedtls_test_opaque_cipher_encrypt( |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 246 | const psa_key_attributes_t *attributes, |
| 247 | const uint8_t *key, size_t key_length, |
| 248 | psa_algorithm_t alg, |
| 249 | const uint8_t *input, size_t input_length, |
| 250 | uint8_t *output, size_t output_size, size_t *output_length) |
| 251 | { |
| 252 | (void) attributes; |
| 253 | (void) key; |
| 254 | (void) key_length; |
| 255 | (void) alg; |
| 256 | (void) input; |
| 257 | (void) input_length; |
| 258 | (void) output; |
| 259 | (void) output_size; |
| 260 | (void) output_length; |
Steven Cooreman | acb5a10 | 2020-09-08 14:06:57 +0200 | [diff] [blame] | 261 | return( PSA_ERROR_NOT_SUPPORTED ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 262 | } |
| 263 | |
Ronald Cron | c4bc12e | 2021-04-13 12:41:34 +0200 | [diff] [blame] | 264 | psa_status_t mbedtls_test_opaque_cipher_decrypt( |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 265 | const psa_key_attributes_t *attributes, |
| 266 | const uint8_t *key, size_t key_length, |
| 267 | psa_algorithm_t alg, |
| 268 | const uint8_t *input, size_t input_length, |
| 269 | uint8_t *output, size_t output_size, size_t *output_length) |
| 270 | { |
| 271 | (void) attributes; |
| 272 | (void) key; |
| 273 | (void) key_length; |
| 274 | (void) alg; |
| 275 | (void) input; |
| 276 | (void) input_length; |
| 277 | (void) output; |
| 278 | (void) output_size; |
| 279 | (void) output_length; |
Steven Cooreman | acb5a10 | 2020-09-08 14:06:57 +0200 | [diff] [blame] | 280 | return( PSA_ERROR_NOT_SUPPORTED ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 281 | } |
| 282 | |
Ronald Cron | c4bc12e | 2021-04-13 12:41:34 +0200 | [diff] [blame] | 283 | psa_status_t mbedtls_test_opaque_cipher_encrypt_setup( |
Ronald Cron | 7cb9c3d | 2021-03-10 12:21:48 +0100 | [diff] [blame] | 284 | mbedtls_opaque_test_driver_cipher_operation_t *operation, |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 285 | const psa_key_attributes_t *attributes, |
| 286 | const uint8_t *key, size_t key_length, |
| 287 | psa_algorithm_t alg) |
| 288 | { |
| 289 | (void) operation; |
| 290 | (void) attributes; |
| 291 | (void) key; |
| 292 | (void) key_length; |
| 293 | (void) alg; |
Steven Cooreman | acb5a10 | 2020-09-08 14:06:57 +0200 | [diff] [blame] | 294 | return( PSA_ERROR_NOT_SUPPORTED ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 295 | } |
| 296 | |
Ronald Cron | c4bc12e | 2021-04-13 12:41:34 +0200 | [diff] [blame] | 297 | psa_status_t mbedtls_test_opaque_cipher_decrypt_setup( |
Ronald Cron | 7cb9c3d | 2021-03-10 12:21:48 +0100 | [diff] [blame] | 298 | mbedtls_opaque_test_driver_cipher_operation_t *operation, |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 299 | const psa_key_attributes_t *attributes, |
| 300 | const uint8_t *key, size_t key_length, |
| 301 | psa_algorithm_t alg) |
| 302 | { |
| 303 | (void) operation; |
| 304 | (void) attributes; |
| 305 | (void) key; |
| 306 | (void) key_length; |
| 307 | (void) alg; |
Steven Cooreman | acb5a10 | 2020-09-08 14:06:57 +0200 | [diff] [blame] | 308 | return( PSA_ERROR_NOT_SUPPORTED ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 309 | } |
| 310 | |
Ronald Cron | c4bc12e | 2021-04-13 12:41:34 +0200 | [diff] [blame] | 311 | psa_status_t mbedtls_test_opaque_cipher_abort( |
Ronald Cron | 7cb9c3d | 2021-03-10 12:21:48 +0100 | [diff] [blame] | 312 | mbedtls_opaque_test_driver_cipher_operation_t *operation ) |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 313 | { |
| 314 | (void) operation; |
Steven Cooreman | acb5a10 | 2020-09-08 14:06:57 +0200 | [diff] [blame] | 315 | return( PSA_ERROR_NOT_SUPPORTED ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 316 | } |
| 317 | |
Ronald Cron | c4bc12e | 2021-04-13 12:41:34 +0200 | [diff] [blame] | 318 | psa_status_t mbedtls_test_opaque_cipher_set_iv( |
Ronald Cron | 7cb9c3d | 2021-03-10 12:21:48 +0100 | [diff] [blame] | 319 | mbedtls_opaque_test_driver_cipher_operation_t *operation, |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 320 | const uint8_t *iv, |
| 321 | size_t iv_length) |
| 322 | { |
| 323 | (void) operation; |
| 324 | (void) iv; |
| 325 | (void) iv_length; |
Steven Cooreman | acb5a10 | 2020-09-08 14:06:57 +0200 | [diff] [blame] | 326 | return( PSA_ERROR_NOT_SUPPORTED ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 327 | } |
| 328 | |
Ronald Cron | c4bc12e | 2021-04-13 12:41:34 +0200 | [diff] [blame] | 329 | psa_status_t mbedtls_test_opaque_cipher_update( |
Ronald Cron | 7cb9c3d | 2021-03-10 12:21:48 +0100 | [diff] [blame] | 330 | mbedtls_opaque_test_driver_cipher_operation_t *operation, |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 331 | const uint8_t *input, |
| 332 | size_t input_length, |
| 333 | uint8_t *output, |
| 334 | size_t output_size, |
| 335 | size_t *output_length) |
| 336 | { |
| 337 | (void) operation; |
| 338 | (void) input; |
| 339 | (void) input_length; |
| 340 | (void) output; |
| 341 | (void) output_size; |
| 342 | (void) output_length; |
Steven Cooreman | acb5a10 | 2020-09-08 14:06:57 +0200 | [diff] [blame] | 343 | return( PSA_ERROR_NOT_SUPPORTED ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 344 | } |
| 345 | |
Ronald Cron | c4bc12e | 2021-04-13 12:41:34 +0200 | [diff] [blame] | 346 | psa_status_t mbedtls_test_opaque_cipher_finish( |
Ronald Cron | 7cb9c3d | 2021-03-10 12:21:48 +0100 | [diff] [blame] | 347 | mbedtls_opaque_test_driver_cipher_operation_t *operation, |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 348 | uint8_t *output, |
| 349 | size_t output_size, |
| 350 | size_t *output_length) |
| 351 | { |
| 352 | (void) operation; |
| 353 | (void) output; |
| 354 | (void) output_size; |
| 355 | (void) output_length; |
Steven Cooreman | acb5a10 | 2020-09-08 14:06:57 +0200 | [diff] [blame] | 356 | return( PSA_ERROR_NOT_SUPPORTED ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 357 | } |
| 358 | #endif /* MBEDTLS_PSA_CRYPTO_DRIVERS && PSA_CRYPTO_DRIVER_TEST */ |