Steven Cooreman | cd84cb4 | 2020-07-16 20:28:36 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Functions to delegate cryptographic operations to an available |
| 3 | * and appropriate accelerator. |
Steven Cooreman | 56250fd | 2020-09-04 13:07:15 +0200 | [diff] [blame] | 4 | * Warning: This file will be auto-generated in the future. |
Steven Cooreman | cd84cb4 | 2020-07-16 20:28:36 +0200 | [diff] [blame] | 5 | */ |
Steven Cooreman | 2c7b2f8 | 2020-09-02 13:43:46 +0200 | [diff] [blame] | 6 | /* Copyright The Mbed TLS Contributors |
Steven Cooreman | cd84cb4 | 2020-07-16 20:28:36 +0200 | [diff] [blame] | 7 | * SPDX-License-Identifier: Apache-2.0 |
| 8 | * |
| 9 | * Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 10 | * not use this file except in compliance with the License. |
| 11 | * You may obtain a copy of the License at |
| 12 | * |
| 13 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 14 | * |
| 15 | * Unless required by applicable law or agreed to in writing, software |
| 16 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 17 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 18 | * See the License for the specific language governing permissions and |
| 19 | * limitations under the License. |
Steven Cooreman | cd84cb4 | 2020-07-16 20:28:36 +0200 | [diff] [blame] | 20 | */ |
| 21 | |
| 22 | #include "psa_crypto_core.h" |
| 23 | #include "psa_crypto_driver_wrappers.h" |
Steven Cooreman | 2a1664c | 2020-07-20 15:33:08 +0200 | [diff] [blame] | 24 | #include "mbedtls/platform.h" |
| 25 | |
| 26 | #if defined(MBEDTLS_PSA_CRYPTO_DRIVERS) |
Steven Cooreman | cd84cb4 | 2020-07-16 20:28:36 +0200 | [diff] [blame] | 27 | |
| 28 | /* Include test driver definition when running tests */ |
Steven Cooreman | f1720ea | 2020-07-24 18:41:58 +0200 | [diff] [blame] | 29 | #if defined(PSA_CRYPTO_DRIVER_TEST) |
Steven Cooreman | 56250fd | 2020-09-04 13:07:15 +0200 | [diff] [blame] | 30 | #ifndef PSA_CRYPTO_DRIVER_PRESENT |
Steven Cooreman | f1720ea | 2020-07-24 18:41:58 +0200 | [diff] [blame] | 31 | #define PSA_CRYPTO_DRIVER_PRESENT |
Steven Cooreman | 56250fd | 2020-09-04 13:07:15 +0200 | [diff] [blame] | 32 | #endif |
| 33 | #ifndef PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT |
Steven Cooreman | f1720ea | 2020-07-24 18:41:58 +0200 | [diff] [blame] | 34 | #define PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT |
Steven Cooreman | 56250fd | 2020-09-04 13:07:15 +0200 | [diff] [blame] | 35 | #endif |
Steven Cooreman | 0d7c64d | 2020-09-07 16:17:55 +0200 | [diff] [blame] | 36 | #include "test/drivers/test_driver.h" |
Steven Cooreman | f1720ea | 2020-07-24 18:41:58 +0200 | [diff] [blame] | 37 | #endif /* PSA_CRYPTO_DRIVER_TEST */ |
Steven Cooreman | cd84cb4 | 2020-07-16 20:28:36 +0200 | [diff] [blame] | 38 | |
Steven Cooreman | 56250fd | 2020-09-04 13:07:15 +0200 | [diff] [blame] | 39 | /* Repeat above block for each JSON-declared driver during autogeneration */ |
| 40 | |
Steven Cooreman | fb81aa5 | 2020-09-09 12:01:43 +0200 | [diff] [blame] | 41 | /* Auto-generated values depending on which drivers are registered. ID 0 is |
| 42 | * reserved for unallocated operations. */ |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 43 | #if defined(PSA_CRYPTO_DRIVER_TEST) |
| 44 | #define PSA_CRYPTO_TRANSPARENT_TEST_DRIVER_ID (1) |
| 45 | #define PSA_CRYPTO_OPAQUE_TEST_DRIVER_ID (2) |
| 46 | #endif /* PSA_CRYPTO_DRIVER_TEST */ |
Steven Cooreman | 2a1664c | 2020-07-20 15:33:08 +0200 | [diff] [blame] | 47 | #endif /* MBEDTLS_PSA_CRYPTO_DRIVERS */ |
| 48 | |
| 49 | /* Support the 'old' SE interface when asked to */ |
Steven Cooreman | 7a25057 | 2020-07-17 16:43:05 +0200 | [diff] [blame] | 50 | #if defined(MBEDTLS_PSA_CRYPTO_SE_C) |
Steven Cooreman | 56250fd | 2020-09-04 13:07:15 +0200 | [diff] [blame] | 51 | /* PSA_CRYPTO_DRIVER_PRESENT is defined when either a new-style or old-style |
| 52 | * SE driver is present, to avoid unused argument errors at compile time. */ |
| 53 | #ifndef PSA_CRYPTO_DRIVER_PRESENT |
Steven Cooreman | f1720ea | 2020-07-24 18:41:58 +0200 | [diff] [blame] | 54 | #define PSA_CRYPTO_DRIVER_PRESENT |
Steven Cooreman | 56250fd | 2020-09-04 13:07:15 +0200 | [diff] [blame] | 55 | #endif |
Steven Cooreman | 7a25057 | 2020-07-17 16:43:05 +0200 | [diff] [blame] | 56 | #include "psa_crypto_se.h" |
| 57 | #endif |
| 58 | |
Steven Cooreman | cd84cb4 | 2020-07-16 20:28:36 +0200 | [diff] [blame] | 59 | /* Start delegation functions */ |
| 60 | psa_status_t psa_driver_wrapper_sign_hash( psa_key_slot_t *slot, |
| 61 | psa_algorithm_t alg, |
| 62 | const uint8_t *hash, |
| 63 | size_t hash_length, |
| 64 | uint8_t *signature, |
| 65 | size_t signature_size, |
| 66 | size_t *signature_length ) |
| 67 | { |
Steven Cooreman | f1720ea | 2020-07-24 18:41:58 +0200 | [diff] [blame] | 68 | #if defined(PSA_CRYPTO_DRIVER_PRESENT) |
Steven Cooreman | 7a25057 | 2020-07-17 16:43:05 +0200 | [diff] [blame] | 69 | /* Try dynamically-registered SE interface first */ |
| 70 | #if defined(MBEDTLS_PSA_CRYPTO_SE_C) |
| 71 | const psa_drv_se_t *drv; |
| 72 | psa_drv_se_context_t *drv_context; |
| 73 | |
| 74 | if( psa_get_se_driver( slot->attr.lifetime, &drv, &drv_context ) ) |
| 75 | { |
| 76 | if( drv->asymmetric == NULL || |
| 77 | drv->asymmetric->p_sign == NULL ) |
| 78 | { |
| 79 | /* Key is defined in SE, but we have no way to exercise it */ |
Steven Cooreman | 56250fd | 2020-09-04 13:07:15 +0200 | [diff] [blame] | 80 | return( PSA_ERROR_NOT_SUPPORTED ); |
Steven Cooreman | 7a25057 | 2020-07-17 16:43:05 +0200 | [diff] [blame] | 81 | } |
| 82 | return( drv->asymmetric->p_sign( drv_context, |
| 83 | slot->data.se.slot_number, |
| 84 | alg, |
| 85 | hash, hash_length, |
| 86 | signature, signature_size, |
| 87 | signature_length ) ); |
| 88 | } |
Steven Cooreman | f1720ea | 2020-07-24 18:41:58 +0200 | [diff] [blame] | 89 | #endif /* PSA_CRYPTO_SE_C */ |
Steven Cooreman | 7a25057 | 2020-07-17 16:43:05 +0200 | [diff] [blame] | 90 | |
| 91 | /* Then try accelerator API */ |
Steven Cooreman | f1720ea | 2020-07-24 18:41:58 +0200 | [diff] [blame] | 92 | #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT) |
Steven Cooreman | cd84cb4 | 2020-07-16 20:28:36 +0200 | [diff] [blame] | 93 | psa_status_t status = PSA_ERROR_INVALID_ARGUMENT; |
| 94 | psa_key_location_t location = PSA_KEY_LIFETIME_GET_LOCATION(slot->attr.lifetime); |
| 95 | psa_key_attributes_t attributes = { |
| 96 | .core = slot->attr |
| 97 | }; |
| 98 | |
| 99 | switch( location ) |
| 100 | { |
| 101 | case PSA_KEY_LOCATION_LOCAL_STORAGE: |
| 102 | /* Key is stored in the slot in export representation, so |
| 103 | * cycle through all known transparent accelerators */ |
Steven Cooreman | f1720ea | 2020-07-24 18:41:58 +0200 | [diff] [blame] | 104 | #if defined(PSA_CRYPTO_DRIVER_TEST) |
Steven Cooreman | cd84cb4 | 2020-07-16 20:28:36 +0200 | [diff] [blame] | 105 | status = test_transparent_signature_sign_hash( &attributes, |
| 106 | slot->data.key.data, |
| 107 | slot->data.key.bytes, |
| 108 | alg, |
| 109 | hash, |
| 110 | hash_length, |
| 111 | signature, |
| 112 | signature_size, |
| 113 | signature_length ); |
| 114 | /* Declared with fallback == true */ |
| 115 | if( status != PSA_ERROR_NOT_SUPPORTED ) |
Steven Cooreman | 56250fd | 2020-09-04 13:07:15 +0200 | [diff] [blame] | 116 | return( status ); |
Steven Cooreman | f1720ea | 2020-07-24 18:41:58 +0200 | [diff] [blame] | 117 | #endif /* PSA_CRYPTO_DRIVER_TEST */ |
Steven Cooreman | cd84cb4 | 2020-07-16 20:28:36 +0200 | [diff] [blame] | 118 | /* Fell through, meaning no accelerator supports this operation */ |
Steven Cooreman | 56250fd | 2020-09-04 13:07:15 +0200 | [diff] [blame] | 119 | return( PSA_ERROR_NOT_SUPPORTED ); |
Steven Cooreman | cd84cb4 | 2020-07-16 20:28:36 +0200 | [diff] [blame] | 120 | /* Add cases for opaque driver here */ |
Steven Cooreman | f1720ea | 2020-07-24 18:41:58 +0200 | [diff] [blame] | 121 | #if defined(PSA_CRYPTO_DRIVER_TEST) |
| 122 | case PSA_CRYPTO_TEST_DRIVER_LIFETIME: |
Steven Cooreman | cd84cb4 | 2020-07-16 20:28:36 +0200 | [diff] [blame] | 123 | return( test_opaque_signature_sign_hash( &attributes, |
| 124 | slot->data.key.data, |
| 125 | slot->data.key.bytes, |
| 126 | alg, |
| 127 | hash, |
| 128 | hash_length, |
| 129 | signature, |
| 130 | signature_size, |
| 131 | signature_length ) ); |
Steven Cooreman | f1720ea | 2020-07-24 18:41:58 +0200 | [diff] [blame] | 132 | #endif /* PSA_CRYPTO_DRIVER_TEST */ |
Steven Cooreman | cd84cb4 | 2020-07-16 20:28:36 +0200 | [diff] [blame] | 133 | default: |
| 134 | /* Key is declared with a lifetime not known to us */ |
Steven Cooreman | 56250fd | 2020-09-04 13:07:15 +0200 | [diff] [blame] | 135 | return( status ); |
Steven Cooreman | cd84cb4 | 2020-07-16 20:28:36 +0200 | [diff] [blame] | 136 | } |
Steven Cooreman | f1720ea | 2020-07-24 18:41:58 +0200 | [diff] [blame] | 137 | #else /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */ |
Steven Cooreman | 56250fd | 2020-09-04 13:07:15 +0200 | [diff] [blame] | 138 | return( PSA_ERROR_NOT_SUPPORTED ); |
Steven Cooreman | f1720ea | 2020-07-24 18:41:58 +0200 | [diff] [blame] | 139 | #endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */ |
| 140 | #else /* PSA_CRYPTO_DRIVER_PRESENT */ |
Steven Cooreman | cd84cb4 | 2020-07-16 20:28:36 +0200 | [diff] [blame] | 141 | (void)slot; |
| 142 | (void)alg; |
| 143 | (void)hash; |
| 144 | (void)hash_length; |
| 145 | (void)signature; |
| 146 | (void)signature_size; |
| 147 | (void)signature_length; |
| 148 | |
Steven Cooreman | 56250fd | 2020-09-04 13:07:15 +0200 | [diff] [blame] | 149 | return( PSA_ERROR_NOT_SUPPORTED ); |
Steven Cooreman | f1720ea | 2020-07-24 18:41:58 +0200 | [diff] [blame] | 150 | #endif /* PSA_CRYPTO_DRIVER_PRESENT */ |
Steven Cooreman | cd84cb4 | 2020-07-16 20:28:36 +0200 | [diff] [blame] | 151 | } |
| 152 | |
Steven Cooreman | 55ae217 | 2020-07-17 19:46:15 +0200 | [diff] [blame] | 153 | psa_status_t psa_driver_wrapper_verify_hash( psa_key_slot_t *slot, |
| 154 | psa_algorithm_t alg, |
| 155 | const uint8_t *hash, |
| 156 | size_t hash_length, |
| 157 | const uint8_t *signature, |
| 158 | size_t signature_length ) |
| 159 | { |
Steven Cooreman | f1720ea | 2020-07-24 18:41:58 +0200 | [diff] [blame] | 160 | #if defined(PSA_CRYPTO_DRIVER_PRESENT) |
Steven Cooreman | 55ae217 | 2020-07-17 19:46:15 +0200 | [diff] [blame] | 161 | /* Try dynamically-registered SE interface first */ |
| 162 | #if defined(MBEDTLS_PSA_CRYPTO_SE_C) |
| 163 | const psa_drv_se_t *drv; |
| 164 | psa_drv_se_context_t *drv_context; |
| 165 | |
| 166 | if( psa_get_se_driver( slot->attr.lifetime, &drv, &drv_context ) ) |
| 167 | { |
| 168 | if( drv->asymmetric == NULL || |
| 169 | drv->asymmetric->p_verify == NULL ) |
| 170 | { |
| 171 | /* Key is defined in SE, but we have no way to exercise it */ |
Steven Cooreman | 56250fd | 2020-09-04 13:07:15 +0200 | [diff] [blame] | 172 | return( PSA_ERROR_NOT_SUPPORTED ); |
Steven Cooreman | 55ae217 | 2020-07-17 19:46:15 +0200 | [diff] [blame] | 173 | } |
| 174 | return( drv->asymmetric->p_verify( drv_context, |
| 175 | slot->data.se.slot_number, |
| 176 | alg, |
| 177 | hash, hash_length, |
| 178 | signature, signature_length ) ); |
| 179 | } |
Steven Cooreman | f1720ea | 2020-07-24 18:41:58 +0200 | [diff] [blame] | 180 | #endif /* PSA_CRYPTO_SE_C */ |
Steven Cooreman | 55ae217 | 2020-07-17 19:46:15 +0200 | [diff] [blame] | 181 | |
| 182 | /* Then try accelerator API */ |
Steven Cooreman | f1720ea | 2020-07-24 18:41:58 +0200 | [diff] [blame] | 183 | #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT) |
Steven Cooreman | 55ae217 | 2020-07-17 19:46:15 +0200 | [diff] [blame] | 184 | psa_status_t status = PSA_ERROR_INVALID_ARGUMENT; |
| 185 | psa_key_location_t location = PSA_KEY_LIFETIME_GET_LOCATION(slot->attr.lifetime); |
| 186 | psa_key_attributes_t attributes = { |
| 187 | .core = slot->attr |
| 188 | }; |
| 189 | |
| 190 | switch( location ) |
| 191 | { |
| 192 | case PSA_KEY_LOCATION_LOCAL_STORAGE: |
| 193 | /* Key is stored in the slot in export representation, so |
| 194 | * cycle through all known transparent accelerators */ |
Steven Cooreman | f1720ea | 2020-07-24 18:41:58 +0200 | [diff] [blame] | 195 | #if defined(PSA_CRYPTO_DRIVER_TEST) |
Steven Cooreman | 55ae217 | 2020-07-17 19:46:15 +0200 | [diff] [blame] | 196 | status = test_transparent_signature_verify_hash( &attributes, |
| 197 | slot->data.key.data, |
| 198 | slot->data.key.bytes, |
| 199 | alg, |
| 200 | hash, |
| 201 | hash_length, |
| 202 | signature, |
| 203 | signature_length ); |
| 204 | /* Declared with fallback == true */ |
| 205 | if( status != PSA_ERROR_NOT_SUPPORTED ) |
Steven Cooreman | 56250fd | 2020-09-04 13:07:15 +0200 | [diff] [blame] | 206 | return( status ); |
Steven Cooreman | f1720ea | 2020-07-24 18:41:58 +0200 | [diff] [blame] | 207 | #endif /* PSA_CRYPTO_DRIVER_TEST */ |
Steven Cooreman | 55ae217 | 2020-07-17 19:46:15 +0200 | [diff] [blame] | 208 | /* Fell through, meaning no accelerator supports this operation */ |
Steven Cooreman | 56250fd | 2020-09-04 13:07:15 +0200 | [diff] [blame] | 209 | return( PSA_ERROR_NOT_SUPPORTED ); |
Steven Cooreman | 55ae217 | 2020-07-17 19:46:15 +0200 | [diff] [blame] | 210 | /* Add cases for opaque driver here */ |
Steven Cooreman | f1720ea | 2020-07-24 18:41:58 +0200 | [diff] [blame] | 211 | #if defined(PSA_CRYPTO_DRIVER_TEST) |
| 212 | case PSA_CRYPTO_TEST_DRIVER_LIFETIME: |
Steven Cooreman | 55ae217 | 2020-07-17 19:46:15 +0200 | [diff] [blame] | 213 | return( test_opaque_signature_verify_hash( &attributes, |
| 214 | slot->data.key.data, |
| 215 | slot->data.key.bytes, |
| 216 | alg, |
| 217 | hash, |
| 218 | hash_length, |
| 219 | signature, |
| 220 | signature_length ) ); |
Steven Cooreman | f1720ea | 2020-07-24 18:41:58 +0200 | [diff] [blame] | 221 | #endif /* PSA_CRYPTO_DRIVER_TEST */ |
Steven Cooreman | 55ae217 | 2020-07-17 19:46:15 +0200 | [diff] [blame] | 222 | default: |
| 223 | /* Key is declared with a lifetime not known to us */ |
Steven Cooreman | 56250fd | 2020-09-04 13:07:15 +0200 | [diff] [blame] | 224 | return( status ); |
Steven Cooreman | 55ae217 | 2020-07-17 19:46:15 +0200 | [diff] [blame] | 225 | } |
Steven Cooreman | f1720ea | 2020-07-24 18:41:58 +0200 | [diff] [blame] | 226 | #else /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */ |
Steven Cooreman | 56250fd | 2020-09-04 13:07:15 +0200 | [diff] [blame] | 227 | return( PSA_ERROR_NOT_SUPPORTED ); |
Steven Cooreman | f1720ea | 2020-07-24 18:41:58 +0200 | [diff] [blame] | 228 | #endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */ |
| 229 | #else /* PSA_CRYPTO_DRIVER_PRESENT */ |
Steven Cooreman | 55ae217 | 2020-07-17 19:46:15 +0200 | [diff] [blame] | 230 | (void)slot; |
| 231 | (void)alg; |
| 232 | (void)hash; |
| 233 | (void)hash_length; |
| 234 | (void)signature; |
| 235 | (void)signature_length; |
| 236 | |
Steven Cooreman | 56250fd | 2020-09-04 13:07:15 +0200 | [diff] [blame] | 237 | return( PSA_ERROR_NOT_SUPPORTED ); |
Steven Cooreman | f1720ea | 2020-07-24 18:41:58 +0200 | [diff] [blame] | 238 | #endif /* PSA_CRYPTO_DRIVER_PRESENT */ |
Steven Cooreman | 55ae217 | 2020-07-17 19:46:15 +0200 | [diff] [blame] | 239 | } |
| 240 | |
Steven Cooreman | f1720ea | 2020-07-24 18:41:58 +0200 | [diff] [blame] | 241 | #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT) |
Steven Cooreman | 56250fd | 2020-09-04 13:07:15 +0200 | [diff] [blame] | 242 | /** Calculate the size to allocate for buffering a key with given attributes. |
| 243 | * |
| 244 | * This function provides a way to get the expected size for storing a key with |
| 245 | * the given attributes. This will be the size of the export representation for |
| 246 | * cleartext keys, and a driver-defined size for keys stored by opaque drivers. |
| 247 | * |
| 248 | * \param[in] attributes The key attribute structure of the key to store. |
| 249 | * \param[out] expected_size On success, a byte size large enough to contain |
| 250 | * the declared key. |
| 251 | * |
| 252 | * \retval #PSA_SUCCESS |
| 253 | * \retval #PSA_ERROR_NOT_SUPPORTED |
| 254 | */ |
Steven Cooreman | 2a1664c | 2020-07-20 15:33:08 +0200 | [diff] [blame] | 255 | static psa_status_t get_expected_key_size( const psa_key_attributes_t *attributes, |
| 256 | size_t *expected_size ) |
| 257 | { |
Steven Cooreman | 56250fd | 2020-09-04 13:07:15 +0200 | [diff] [blame] | 258 | size_t buffer_size = 0; |
John Durkop | 2c61835 | 2020-09-22 06:54:01 -0700 | [diff] [blame^] | 259 | psa_key_location_t location = PSA_KEY_LIFETIME_GET_LOCATION( attributes->core.lifetime ); |
| 260 | psa_key_type_t key_type = attributes->core.type; |
| 261 | size_t key_bits = attributes->core.bits; |
Steven Cooreman | 2a1664c | 2020-07-20 15:33:08 +0200 | [diff] [blame] | 262 | |
John Durkop | 2c61835 | 2020-09-22 06:54:01 -0700 | [diff] [blame^] | 263 | switch( location ) |
| 264 | { |
| 265 | case PSA_KEY_LOCATION_LOCAL_STORAGE: |
| 266 | buffer_size = PSA_KEY_EXPORT_MAX_SIZE( key_type, key_bits ); |
| 267 | |
| 268 | if( buffer_size == 0 ) |
| 269 | return( PSA_ERROR_NOT_SUPPORTED ); |
| 270 | |
| 271 | *expected_size = buffer_size; |
| 272 | return( PSA_SUCCESS ); |
| 273 | |
| 274 | #if defined(PSA_CRYPTO_DRIVER_TEST) |
| 275 | case PSA_CRYPTO_TEST_DRIVER_LIFETIME: |
| 276 | /* TBD: opaque driver support: need to calculate size through a |
| 277 | * driver-defined size function, since the size of an opaque (wrapped) |
| 278 | * key will be different for each implementation. */ |
| 279 | #ifdef TEST_KEY_CONTEXT_SIZE_FUNCTION |
| 280 | *expected_size = test_size_function( key_type, key_bits ); |
| 281 | return( PSA_SUCCESS ); |
| 282 | #else /* TEST_DRIVER_KEY_CONTEXT_SIZE_FUNCTION */ |
| 283 | if( PSA_KEY_TYPE_IS_KEY_PAIR( key_type ) ) |
| 284 | { |
| 285 | *expected_size = TEST_DRIVER_KEY_CONTEXT_BASE_SIZE |
| 286 | + TEST_DRIVER_KEY_CONTEXT_PUBLIC_KEY_SIZE; |
| 287 | } |
| 288 | else if( PSA_KEY_TYPE_IS_PUBLIC_KEY( attributes->core.type ) ) |
| 289 | { |
| 290 | *expected_size = TEST_DRIVER_KEY_CONTEXT_BASE_SIZE |
| 291 | + TEST_DRIVER_KEY_CONTEXT_SYMMETRIC_FACTOR |
| 292 | * ( ( key_bits + 7 ) / 8 ); |
| 293 | } |
| 294 | else |
| 295 | { |
| 296 | return( PSA_ERROR_NOT_SUPPORTED ); |
| 297 | } |
| 298 | return( PSA_SUCCESS ); |
| 299 | #endif /* TEST_DRIVER_KEY_CONTEXT_SIZE_FUNCTION */ |
| 300 | #endif /* PSA_CRYPTO_DRIVER_TEST */ |
| 301 | |
| 302 | default: |
Steven Cooreman | 56250fd | 2020-09-04 13:07:15 +0200 | [diff] [blame] | 303 | return( PSA_ERROR_NOT_SUPPORTED ); |
Steven Cooreman | 2a1664c | 2020-07-20 15:33:08 +0200 | [diff] [blame] | 304 | } |
| 305 | } |
Steven Cooreman | f1720ea | 2020-07-24 18:41:58 +0200 | [diff] [blame] | 306 | #endif /* PSA_CRYPTO_DRIVER_PRESENT */ |
Steven Cooreman | 2a1664c | 2020-07-20 15:33:08 +0200 | [diff] [blame] | 307 | |
Steven Cooreman | 55ae217 | 2020-07-17 19:46:15 +0200 | [diff] [blame] | 308 | psa_status_t psa_driver_wrapper_generate_key( const psa_key_attributes_t *attributes, |
| 309 | psa_key_slot_t *slot ) |
| 310 | { |
Steven Cooreman | f1720ea | 2020-07-24 18:41:58 +0200 | [diff] [blame] | 311 | #if defined(PSA_CRYPTO_DRIVER_PRESENT) |
Steven Cooreman | 2a1664c | 2020-07-20 15:33:08 +0200 | [diff] [blame] | 312 | /* Try dynamically-registered SE interface first */ |
| 313 | #if defined(MBEDTLS_PSA_CRYPTO_SE_C) |
| 314 | const psa_drv_se_t *drv; |
| 315 | psa_drv_se_context_t *drv_context; |
| 316 | |
| 317 | if( psa_get_se_driver( slot->attr.lifetime, &drv, &drv_context ) ) |
| 318 | { |
| 319 | size_t pubkey_length = 0; /* We don't support this feature yet */ |
| 320 | if( drv->key_management == NULL || |
| 321 | drv->key_management->p_generate == NULL ) |
| 322 | { |
| 323 | /* Key is defined as being in SE, but we have no way to generate it */ |
Steven Cooreman | 56250fd | 2020-09-04 13:07:15 +0200 | [diff] [blame] | 324 | return( PSA_ERROR_NOT_SUPPORTED ); |
Steven Cooreman | 2a1664c | 2020-07-20 15:33:08 +0200 | [diff] [blame] | 325 | } |
| 326 | return( drv->key_management->p_generate( |
| 327 | drv_context, |
| 328 | slot->data.se.slot_number, attributes, |
| 329 | NULL, 0, &pubkey_length ) ); |
| 330 | } |
| 331 | #endif /* MBEDTLS_PSA_CRYPTO_SE_C */ |
| 332 | |
| 333 | /* Then try accelerator API */ |
Steven Cooreman | f1720ea | 2020-07-24 18:41:58 +0200 | [diff] [blame] | 334 | #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT) |
Steven Cooreman | 2a1664c | 2020-07-20 15:33:08 +0200 | [diff] [blame] | 335 | psa_status_t status = PSA_ERROR_INVALID_ARGUMENT; |
| 336 | psa_key_location_t location = PSA_KEY_LIFETIME_GET_LOCATION(slot->attr.lifetime); |
| 337 | size_t export_size = 0; |
| 338 | |
| 339 | status = get_expected_key_size( attributes, &export_size ); |
| 340 | if( status != PSA_SUCCESS ) |
Steven Cooreman | 56250fd | 2020-09-04 13:07:15 +0200 | [diff] [blame] | 341 | return( status ); |
Steven Cooreman | 2a1664c | 2020-07-20 15:33:08 +0200 | [diff] [blame] | 342 | |
| 343 | slot->data.key.data = mbedtls_calloc(1, export_size); |
| 344 | if( slot->data.key.data == NULL ) |
Steven Cooreman | 56250fd | 2020-09-04 13:07:15 +0200 | [diff] [blame] | 345 | return( PSA_ERROR_INSUFFICIENT_MEMORY ); |
Steven Cooreman | 2a1664c | 2020-07-20 15:33:08 +0200 | [diff] [blame] | 346 | slot->data.key.bytes = export_size; |
| 347 | |
| 348 | switch( location ) |
| 349 | { |
| 350 | case PSA_KEY_LOCATION_LOCAL_STORAGE: |
| 351 | /* Key is stored in the slot in export representation, so |
| 352 | * cycle through all known transparent accelerators */ |
| 353 | |
| 354 | /* Transparent drivers are limited to generating asymmetric keys */ |
| 355 | if( ! PSA_KEY_TYPE_IS_ASYMMETRIC( slot->attr.type ) ) |
| 356 | { |
| 357 | status = PSA_ERROR_NOT_SUPPORTED; |
| 358 | break; |
| 359 | } |
Steven Cooreman | f1720ea | 2020-07-24 18:41:58 +0200 | [diff] [blame] | 360 | #if defined(PSA_CRYPTO_DRIVER_TEST) |
Steven Cooreman | 2a1664c | 2020-07-20 15:33:08 +0200 | [diff] [blame] | 361 | status = test_transparent_generate_key( attributes, |
| 362 | slot->data.key.data, |
| 363 | slot->data.key.bytes, |
| 364 | &slot->data.key.bytes ); |
| 365 | /* Declared with fallback == true */ |
| 366 | if( status != PSA_ERROR_NOT_SUPPORTED ) |
| 367 | break; |
Steven Cooreman | f1720ea | 2020-07-24 18:41:58 +0200 | [diff] [blame] | 368 | #endif /* PSA_CRYPTO_DRIVER_TEST */ |
Steven Cooreman | 2a1664c | 2020-07-20 15:33:08 +0200 | [diff] [blame] | 369 | /* Fell through, meaning no accelerator supports this operation */ |
| 370 | status = PSA_ERROR_NOT_SUPPORTED; |
| 371 | break; |
| 372 | /* Add cases for opaque driver here */ |
Steven Cooreman | f1720ea | 2020-07-24 18:41:58 +0200 | [diff] [blame] | 373 | #if defined(PSA_CRYPTO_DRIVER_TEST) |
| 374 | case PSA_CRYPTO_TEST_DRIVER_LIFETIME: |
Steven Cooreman | 2a1664c | 2020-07-20 15:33:08 +0200 | [diff] [blame] | 375 | status = test_opaque_generate_key( attributes, |
| 376 | slot->data.key.data, |
| 377 | slot->data.key.bytes, |
| 378 | &slot->data.key.bytes ); |
| 379 | break; |
Steven Cooreman | f1720ea | 2020-07-24 18:41:58 +0200 | [diff] [blame] | 380 | #endif /* PSA_CRYPTO_DRIVER_TEST */ |
Steven Cooreman | 2a1664c | 2020-07-20 15:33:08 +0200 | [diff] [blame] | 381 | default: |
| 382 | /* Key is declared with a lifetime not known to us */ |
| 383 | status = PSA_ERROR_INVALID_ARGUMENT; |
| 384 | break; |
| 385 | } |
| 386 | |
| 387 | if( status != PSA_SUCCESS ) |
| 388 | { |
| 389 | /* free allocated buffer */ |
| 390 | mbedtls_free( slot->data.key.data ); |
| 391 | slot->data.key.data = NULL; |
| 392 | slot->data.key.bytes = 0; |
| 393 | } |
| 394 | |
| 395 | return( status ); |
Steven Cooreman | f1720ea | 2020-07-24 18:41:58 +0200 | [diff] [blame] | 396 | #else /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */ |
Steven Cooreman | 56250fd | 2020-09-04 13:07:15 +0200 | [diff] [blame] | 397 | return( PSA_ERROR_NOT_SUPPORTED ); |
Steven Cooreman | f1720ea | 2020-07-24 18:41:58 +0200 | [diff] [blame] | 398 | #endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */ |
| 399 | #else /* PSA_CRYPTO_DRIVER_PRESENT */ |
Steven Cooreman | 55ae217 | 2020-07-17 19:46:15 +0200 | [diff] [blame] | 400 | (void) attributes; |
| 401 | (void) slot; |
| 402 | |
Steven Cooreman | 56250fd | 2020-09-04 13:07:15 +0200 | [diff] [blame] | 403 | return( PSA_ERROR_NOT_SUPPORTED ); |
Steven Cooreman | f1720ea | 2020-07-24 18:41:58 +0200 | [diff] [blame] | 404 | #endif /* PSA_CRYPTO_DRIVER_PRESENT */ |
Steven Cooreman | 55ae217 | 2020-07-17 19:46:15 +0200 | [diff] [blame] | 405 | } |
| 406 | |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 407 | /* |
| 408 | * Cipher functions |
| 409 | */ |
| 410 | psa_status_t psa_driver_wrapper_cipher_encrypt( |
| 411 | psa_key_slot_t *slot, |
| 412 | psa_algorithm_t alg, |
| 413 | const uint8_t *input, |
| 414 | size_t input_length, |
| 415 | uint8_t *output, |
| 416 | size_t output_size, |
| 417 | size_t *output_length ) |
| 418 | { |
| 419 | #if defined(PSA_CRYPTO_DRIVER_PRESENT) && defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT) |
| 420 | psa_status_t status = PSA_ERROR_INVALID_ARGUMENT; |
| 421 | psa_key_location_t location = PSA_KEY_LIFETIME_GET_LOCATION(slot->attr.lifetime); |
| 422 | psa_key_attributes_t attributes = { |
| 423 | .core = slot->attr |
| 424 | }; |
| 425 | |
| 426 | switch( location ) |
| 427 | { |
| 428 | case PSA_KEY_LOCATION_LOCAL_STORAGE: |
| 429 | /* Key is stored in the slot in export representation, so |
| 430 | * cycle through all known transparent accelerators */ |
| 431 | #if defined(PSA_CRYPTO_DRIVER_TEST) |
| 432 | status = test_transparent_cipher_encrypt( &attributes, |
| 433 | slot->data.key.data, |
| 434 | slot->data.key.bytes, |
| 435 | alg, |
| 436 | input, |
| 437 | input_length, |
| 438 | output, |
| 439 | output_size, |
| 440 | output_length ); |
| 441 | /* Declared with fallback == true */ |
| 442 | if( status != PSA_ERROR_NOT_SUPPORTED ) |
Steven Cooreman | 5240e8b | 2020-09-09 11:51:45 +0200 | [diff] [blame] | 443 | return( status ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 444 | #endif /* PSA_CRYPTO_DRIVER_TEST */ |
| 445 | /* Fell through, meaning no accelerator supports this operation */ |
Steven Cooreman | 5240e8b | 2020-09-09 11:51:45 +0200 | [diff] [blame] | 446 | return( PSA_ERROR_NOT_SUPPORTED ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 447 | /* Add cases for opaque driver here */ |
| 448 | #if defined(PSA_CRYPTO_DRIVER_TEST) |
| 449 | case PSA_CRYPTO_TEST_DRIVER_LIFETIME: |
| 450 | return( test_opaque_cipher_encrypt( &attributes, |
| 451 | slot->data.key.data, |
| 452 | slot->data.key.bytes, |
| 453 | alg, |
| 454 | input, |
| 455 | input_length, |
| 456 | output, |
| 457 | output_size, |
| 458 | output_length ) ); |
| 459 | #endif /* PSA_CRYPTO_DRIVER_TEST */ |
| 460 | default: |
| 461 | /* Key is declared with a lifetime not known to us */ |
Steven Cooreman | 5240e8b | 2020-09-09 11:51:45 +0200 | [diff] [blame] | 462 | return( status ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 463 | } |
| 464 | #else /* PSA_CRYPTO_DRIVER_PRESENT */ |
| 465 | (void) slot; |
| 466 | (void) alg; |
| 467 | (void) input; |
| 468 | (void) input_length; |
| 469 | (void) output; |
| 470 | (void) output_size; |
| 471 | (void) output_length; |
| 472 | |
Steven Cooreman | 5240e8b | 2020-09-09 11:51:45 +0200 | [diff] [blame] | 473 | return( PSA_ERROR_NOT_SUPPORTED ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 474 | #endif /* PSA_CRYPTO_DRIVER_PRESENT */ |
| 475 | } |
| 476 | |
| 477 | psa_status_t psa_driver_wrapper_cipher_decrypt( |
| 478 | psa_key_slot_t *slot, |
| 479 | psa_algorithm_t alg, |
| 480 | const uint8_t *input, |
| 481 | size_t input_length, |
| 482 | uint8_t *output, |
| 483 | size_t output_size, |
| 484 | size_t *output_length ) |
| 485 | { |
| 486 | #if defined(PSA_CRYPTO_DRIVER_PRESENT) && defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT) |
| 487 | psa_status_t status = PSA_ERROR_INVALID_ARGUMENT; |
| 488 | psa_key_location_t location = PSA_KEY_LIFETIME_GET_LOCATION(slot->attr.lifetime); |
| 489 | psa_key_attributes_t attributes = { |
| 490 | .core = slot->attr |
| 491 | }; |
| 492 | |
| 493 | switch( location ) |
| 494 | { |
| 495 | case PSA_KEY_LOCATION_LOCAL_STORAGE: |
| 496 | /* Key is stored in the slot in export representation, so |
| 497 | * cycle through all known transparent accelerators */ |
| 498 | #if defined(PSA_CRYPTO_DRIVER_TEST) |
| 499 | status = test_transparent_cipher_decrypt( &attributes, |
| 500 | slot->data.key.data, |
| 501 | slot->data.key.bytes, |
| 502 | alg, |
| 503 | input, |
| 504 | input_length, |
| 505 | output, |
| 506 | output_size, |
| 507 | output_length ); |
| 508 | /* Declared with fallback == true */ |
| 509 | if( status != PSA_ERROR_NOT_SUPPORTED ) |
Steven Cooreman | 5240e8b | 2020-09-09 11:51:45 +0200 | [diff] [blame] | 510 | return( status ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 511 | #endif /* PSA_CRYPTO_DRIVER_TEST */ |
| 512 | /* Fell through, meaning no accelerator supports this operation */ |
Steven Cooreman | 5240e8b | 2020-09-09 11:51:45 +0200 | [diff] [blame] | 513 | return( PSA_ERROR_NOT_SUPPORTED ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 514 | /* Add cases for opaque driver here */ |
| 515 | #if defined(PSA_CRYPTO_DRIVER_TEST) |
| 516 | case PSA_CRYPTO_TEST_DRIVER_LIFETIME: |
| 517 | return( test_opaque_cipher_decrypt( &attributes, |
| 518 | slot->data.key.data, |
| 519 | slot->data.key.bytes, |
| 520 | alg, |
| 521 | input, |
| 522 | input_length, |
| 523 | output, |
| 524 | output_size, |
| 525 | output_length ) ); |
| 526 | #endif /* PSA_CRYPTO_DRIVER_TEST */ |
| 527 | default: |
| 528 | /* Key is declared with a lifetime not known to us */ |
Steven Cooreman | 5240e8b | 2020-09-09 11:51:45 +0200 | [diff] [blame] | 529 | return( status ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 530 | } |
| 531 | #else /* PSA_CRYPTO_DRIVER_PRESENT */ |
| 532 | (void) slot; |
| 533 | (void) alg; |
| 534 | (void) input; |
| 535 | (void) input_length; |
| 536 | (void) output; |
| 537 | (void) output_size; |
| 538 | (void) output_length; |
| 539 | |
Steven Cooreman | 5240e8b | 2020-09-09 11:51:45 +0200 | [diff] [blame] | 540 | return( PSA_ERROR_NOT_SUPPORTED ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 541 | #endif /* PSA_CRYPTO_DRIVER_PRESENT */ |
| 542 | } |
| 543 | |
| 544 | psa_status_t psa_driver_wrapper_cipher_encrypt_setup( |
Steven Cooreman | fb81aa5 | 2020-09-09 12:01:43 +0200 | [diff] [blame] | 545 | psa_operation_driver_context_t *operation, |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 546 | psa_key_slot_t *slot, |
| 547 | psa_algorithm_t alg ) |
| 548 | { |
| 549 | #if defined(PSA_CRYPTO_DRIVER_PRESENT) && defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT) |
| 550 | psa_status_t status = PSA_ERROR_INVALID_ARGUMENT; |
| 551 | psa_key_location_t location = PSA_KEY_LIFETIME_GET_LOCATION(slot->attr.lifetime); |
| 552 | psa_key_attributes_t attributes = { |
| 553 | .core = slot->attr |
| 554 | }; |
| 555 | |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 556 | switch( location ) |
| 557 | { |
| 558 | case PSA_KEY_LOCATION_LOCAL_STORAGE: |
| 559 | /* Key is stored in the slot in export representation, so |
| 560 | * cycle through all known transparent accelerators */ |
| 561 | #if defined(PSA_CRYPTO_DRIVER_TEST) |
Steven Cooreman | fb81aa5 | 2020-09-09 12:01:43 +0200 | [diff] [blame] | 562 | operation->ctx = mbedtls_calloc( 1, sizeof(test_transparent_cipher_operation_t) ); |
| 563 | if( operation->ctx == NULL ) |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 564 | return PSA_ERROR_INSUFFICIENT_MEMORY; |
| 565 | |
Steven Cooreman | fb81aa5 | 2020-09-09 12:01:43 +0200 | [diff] [blame] | 566 | status = test_transparent_cipher_encrypt_setup( operation->ctx, |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 567 | &attributes, |
| 568 | slot->data.key.data, |
| 569 | slot->data.key.bytes, |
| 570 | alg ); |
| 571 | /* Declared with fallback == true */ |
Steven Cooreman | 150c99b | 2020-09-09 14:32:44 +0200 | [diff] [blame] | 572 | if( status == PSA_SUCCESS ) |
| 573 | operation->id = PSA_CRYPTO_TRANSPARENT_TEST_DRIVER_ID; |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 574 | else |
| 575 | { |
Steven Cooreman | cfeea8f | 2020-09-09 15:09:18 +0200 | [diff] [blame] | 576 | mbedtls_platform_zeroize( |
| 577 | operation->ctx, |
| 578 | sizeof( test_transparent_cipher_operation_t ) ); |
Steven Cooreman | fb81aa5 | 2020-09-09 12:01:43 +0200 | [diff] [blame] | 579 | mbedtls_free( operation->ctx ); |
| 580 | operation->ctx = NULL; |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 581 | } |
Steven Cooreman | 150c99b | 2020-09-09 14:32:44 +0200 | [diff] [blame] | 582 | |
| 583 | return( status ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 584 | #endif /* PSA_CRYPTO_DRIVER_TEST */ |
| 585 | /* Fell through, meaning no accelerator supports this operation */ |
Steven Cooreman | 5240e8b | 2020-09-09 11:51:45 +0200 | [diff] [blame] | 586 | return( PSA_ERROR_NOT_SUPPORTED ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 587 | /* Add cases for opaque driver here */ |
| 588 | #if defined(PSA_CRYPTO_DRIVER_TEST) |
| 589 | case PSA_CRYPTO_TEST_DRIVER_LIFETIME: |
Steven Cooreman | fb81aa5 | 2020-09-09 12:01:43 +0200 | [diff] [blame] | 590 | operation->ctx = mbedtls_calloc( 1, sizeof(test_opaque_cipher_operation_t) ); |
| 591 | if( operation->ctx == NULL ) |
Steven Cooreman | 5240e8b | 2020-09-09 11:51:45 +0200 | [diff] [blame] | 592 | return( PSA_ERROR_INSUFFICIENT_MEMORY ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 593 | |
Steven Cooreman | fb81aa5 | 2020-09-09 12:01:43 +0200 | [diff] [blame] | 594 | status = test_opaque_cipher_encrypt_setup( operation->ctx, |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 595 | &attributes, |
| 596 | slot->data.key.data, |
| 597 | slot->data.key.bytes, |
| 598 | alg ); |
| 599 | if( status == PSA_SUCCESS ) |
Steven Cooreman | fb81aa5 | 2020-09-09 12:01:43 +0200 | [diff] [blame] | 600 | operation->id = PSA_CRYPTO_OPAQUE_TEST_DRIVER_ID; |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 601 | else |
| 602 | { |
Steven Cooreman | cfeea8f | 2020-09-09 15:09:18 +0200 | [diff] [blame] | 603 | mbedtls_platform_zeroize( |
| 604 | operation->ctx, |
| 605 | sizeof( test_opaque_cipher_operation_t ) ); |
Steven Cooreman | fb81aa5 | 2020-09-09 12:01:43 +0200 | [diff] [blame] | 606 | mbedtls_free( operation->ctx ); |
| 607 | operation->ctx = NULL; |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 608 | } |
| 609 | |
Steven Cooreman | 5240e8b | 2020-09-09 11:51:45 +0200 | [diff] [blame] | 610 | return( status ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 611 | #endif /* PSA_CRYPTO_DRIVER_TEST */ |
| 612 | default: |
| 613 | /* Key is declared with a lifetime not known to us */ |
Steven Cooreman | 5240e8b | 2020-09-09 11:51:45 +0200 | [diff] [blame] | 614 | return( PSA_ERROR_BAD_STATE ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 615 | } |
| 616 | #else /* PSA_CRYPTO_DRIVER_PRESENT */ |
| 617 | (void)slot; |
| 618 | (void)alg; |
| 619 | (void)operation; |
| 620 | |
Steven Cooreman | 5240e8b | 2020-09-09 11:51:45 +0200 | [diff] [blame] | 621 | return( PSA_ERROR_NOT_SUPPORTED ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 622 | #endif /* PSA_CRYPTO_DRIVER_PRESENT */ |
| 623 | } |
| 624 | |
| 625 | psa_status_t psa_driver_wrapper_cipher_decrypt_setup( |
Steven Cooreman | fb81aa5 | 2020-09-09 12:01:43 +0200 | [diff] [blame] | 626 | psa_operation_driver_context_t *operation, |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 627 | psa_key_slot_t *slot, |
| 628 | psa_algorithm_t alg ) |
| 629 | { |
| 630 | #if defined(PSA_CRYPTO_DRIVER_PRESENT) && defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT) |
| 631 | psa_status_t status = PSA_ERROR_INVALID_ARGUMENT; |
| 632 | psa_key_location_t location = PSA_KEY_LIFETIME_GET_LOCATION(slot->attr.lifetime); |
| 633 | psa_key_attributes_t attributes = { |
| 634 | .core = slot->attr |
| 635 | }; |
| 636 | |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 637 | switch( location ) |
| 638 | { |
| 639 | case PSA_KEY_LOCATION_LOCAL_STORAGE: |
| 640 | /* Key is stored in the slot in export representation, so |
| 641 | * cycle through all known transparent accelerators */ |
| 642 | #if defined(PSA_CRYPTO_DRIVER_TEST) |
Steven Cooreman | fb81aa5 | 2020-09-09 12:01:43 +0200 | [diff] [blame] | 643 | operation->ctx = mbedtls_calloc( 1, sizeof(test_transparent_cipher_operation_t) ); |
| 644 | if( operation->ctx == NULL ) |
Steven Cooreman | 5240e8b | 2020-09-09 11:51:45 +0200 | [diff] [blame] | 645 | return( PSA_ERROR_INSUFFICIENT_MEMORY ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 646 | |
Steven Cooreman | fb81aa5 | 2020-09-09 12:01:43 +0200 | [diff] [blame] | 647 | status = test_transparent_cipher_decrypt_setup( operation->ctx, |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 648 | &attributes, |
| 649 | slot->data.key.data, |
| 650 | slot->data.key.bytes, |
| 651 | alg ); |
| 652 | /* Declared with fallback == true */ |
Steven Cooreman | 150c99b | 2020-09-09 14:32:44 +0200 | [diff] [blame] | 653 | if( status == PSA_SUCCESS ) |
| 654 | operation->id = PSA_CRYPTO_TRANSPARENT_TEST_DRIVER_ID; |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 655 | else |
| 656 | { |
Steven Cooreman | cfeea8f | 2020-09-09 15:09:18 +0200 | [diff] [blame] | 657 | mbedtls_platform_zeroize( |
| 658 | operation->ctx, |
| 659 | sizeof( test_transparent_cipher_operation_t ) ); |
Steven Cooreman | fb81aa5 | 2020-09-09 12:01:43 +0200 | [diff] [blame] | 660 | mbedtls_free( operation->ctx ); |
| 661 | operation->ctx = NULL; |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 662 | } |
Steven Cooreman | 150c99b | 2020-09-09 14:32:44 +0200 | [diff] [blame] | 663 | |
| 664 | return( status ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 665 | #endif /* PSA_CRYPTO_DRIVER_TEST */ |
| 666 | /* Fell through, meaning no accelerator supports this operation */ |
Steven Cooreman | 5240e8b | 2020-09-09 11:51:45 +0200 | [diff] [blame] | 667 | return( PSA_ERROR_NOT_SUPPORTED ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 668 | /* Add cases for opaque driver here */ |
| 669 | #if defined(PSA_CRYPTO_DRIVER_TEST) |
| 670 | case PSA_CRYPTO_TEST_DRIVER_LIFETIME: |
Steven Cooreman | fb81aa5 | 2020-09-09 12:01:43 +0200 | [diff] [blame] | 671 | operation->ctx = mbedtls_calloc( 1, sizeof(test_opaque_cipher_operation_t) ); |
| 672 | if( operation->ctx == NULL ) |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 673 | return PSA_ERROR_INSUFFICIENT_MEMORY; |
| 674 | |
Steven Cooreman | fb81aa5 | 2020-09-09 12:01:43 +0200 | [diff] [blame] | 675 | status = test_opaque_cipher_decrypt_setup( operation->ctx, |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 676 | &attributes, |
| 677 | slot->data.key.data, |
| 678 | slot->data.key.bytes, |
| 679 | alg ); |
| 680 | if( status == PSA_SUCCESS ) |
Steven Cooreman | fb81aa5 | 2020-09-09 12:01:43 +0200 | [diff] [blame] | 681 | operation->id = PSA_CRYPTO_OPAQUE_TEST_DRIVER_ID; |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 682 | else |
| 683 | { |
Steven Cooreman | cfeea8f | 2020-09-09 15:09:18 +0200 | [diff] [blame] | 684 | mbedtls_platform_zeroize( |
| 685 | operation->ctx, |
| 686 | sizeof( test_opaque_cipher_operation_t ) ); |
Steven Cooreman | fb81aa5 | 2020-09-09 12:01:43 +0200 | [diff] [blame] | 687 | mbedtls_free( operation->ctx ); |
| 688 | operation->ctx = NULL; |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 689 | } |
| 690 | |
Steven Cooreman | 5240e8b | 2020-09-09 11:51:45 +0200 | [diff] [blame] | 691 | return( status ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 692 | #endif /* PSA_CRYPTO_DRIVER_TEST */ |
| 693 | default: |
| 694 | /* Key is declared with a lifetime not known to us */ |
Steven Cooreman | 5240e8b | 2020-09-09 11:51:45 +0200 | [diff] [blame] | 695 | return( PSA_ERROR_BAD_STATE ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 696 | } |
| 697 | #else /* PSA_CRYPTO_DRIVER_PRESENT */ |
| 698 | (void)slot; |
| 699 | (void)alg; |
| 700 | (void)operation; |
| 701 | |
Steven Cooreman | 5240e8b | 2020-09-09 11:51:45 +0200 | [diff] [blame] | 702 | return( PSA_ERROR_NOT_SUPPORTED ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 703 | #endif /* PSA_CRYPTO_DRIVER_PRESENT */ |
| 704 | } |
| 705 | |
| 706 | psa_status_t psa_driver_wrapper_cipher_generate_iv( |
Steven Cooreman | fb81aa5 | 2020-09-09 12:01:43 +0200 | [diff] [blame] | 707 | psa_operation_driver_context_t *operation, |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 708 | uint8_t *iv, |
| 709 | size_t iv_size, |
| 710 | size_t *iv_length ) |
| 711 | { |
| 712 | #if defined(PSA_CRYPTO_DRIVER_PRESENT) && defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT) |
Steven Cooreman | fb81aa5 | 2020-09-09 12:01:43 +0200 | [diff] [blame] | 713 | switch( operation->id ) |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 714 | { |
| 715 | #if defined(PSA_CRYPTO_DRIVER_TEST) |
| 716 | case PSA_CRYPTO_TRANSPARENT_TEST_DRIVER_ID: |
Steven Cooreman | fb81aa5 | 2020-09-09 12:01:43 +0200 | [diff] [blame] | 717 | return( test_transparent_cipher_generate_iv( operation->ctx, |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 718 | iv, |
| 719 | iv_size, |
| 720 | iv_length ) ); |
| 721 | #endif /* PSA_CRYPTO_DRIVER_TEST */ |
| 722 | #if defined(PSA_CRYPTO_DRIVER_TEST) |
| 723 | case PSA_CRYPTO_OPAQUE_TEST_DRIVER_ID: |
Steven Cooreman | fb81aa5 | 2020-09-09 12:01:43 +0200 | [diff] [blame] | 724 | return( test_opaque_cipher_generate_iv( operation->ctx, |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 725 | iv, |
| 726 | iv_size, |
| 727 | iv_length ) ); |
| 728 | #endif /* PSA_CRYPTO_DRIVER_TEST */ |
| 729 | default: |
| 730 | /* Key is attached to a driver not known to us */ |
Steven Cooreman | 5240e8b | 2020-09-09 11:51:45 +0200 | [diff] [blame] | 731 | return( PSA_ERROR_BAD_STATE ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 732 | } |
| 733 | #else /* PSA_CRYPTO_DRIVER_PRESENT */ |
| 734 | (void) operation; |
| 735 | (void) iv; |
| 736 | (void) iv_size; |
| 737 | (void) iv_length; |
| 738 | |
Steven Cooreman | 5240e8b | 2020-09-09 11:51:45 +0200 | [diff] [blame] | 739 | return( PSA_ERROR_NOT_SUPPORTED ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 740 | #endif /* PSA_CRYPTO_DRIVER_PRESENT */ |
| 741 | } |
| 742 | |
| 743 | psa_status_t psa_driver_wrapper_cipher_set_iv( |
Steven Cooreman | fb81aa5 | 2020-09-09 12:01:43 +0200 | [diff] [blame] | 744 | psa_operation_driver_context_t *operation, |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 745 | const uint8_t *iv, |
| 746 | size_t iv_length ) |
| 747 | { |
| 748 | #if defined(PSA_CRYPTO_DRIVER_PRESENT) && defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT) |
Steven Cooreman | fb81aa5 | 2020-09-09 12:01:43 +0200 | [diff] [blame] | 749 | switch( operation->id ) |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 750 | { |
| 751 | #if defined(PSA_CRYPTO_DRIVER_TEST) |
| 752 | case PSA_CRYPTO_TRANSPARENT_TEST_DRIVER_ID: |
Steven Cooreman | fb81aa5 | 2020-09-09 12:01:43 +0200 | [diff] [blame] | 753 | return( test_transparent_cipher_set_iv( operation->ctx, |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 754 | iv, |
| 755 | iv_length ) ); |
| 756 | #endif /* PSA_CRYPTO_DRIVER_TEST */ |
| 757 | #if defined(PSA_CRYPTO_DRIVER_TEST) |
| 758 | case PSA_CRYPTO_OPAQUE_TEST_DRIVER_ID: |
Steven Cooreman | fb81aa5 | 2020-09-09 12:01:43 +0200 | [diff] [blame] | 759 | return( test_opaque_cipher_set_iv( operation->ctx, |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 760 | iv, |
| 761 | iv_length ) ); |
| 762 | #endif /* PSA_CRYPTO_DRIVER_TEST */ |
| 763 | default: |
| 764 | /* Key is attached to a driver not known to us */ |
Steven Cooreman | 5240e8b | 2020-09-09 11:51:45 +0200 | [diff] [blame] | 765 | return( PSA_ERROR_BAD_STATE ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 766 | } |
| 767 | #else /* PSA_CRYPTO_DRIVER_PRESENT */ |
| 768 | (void) operation; |
| 769 | (void) iv; |
| 770 | (void) iv_length; |
| 771 | |
Steven Cooreman | 5240e8b | 2020-09-09 11:51:45 +0200 | [diff] [blame] | 772 | return( PSA_ERROR_NOT_SUPPORTED ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 773 | #endif /* PSA_CRYPTO_DRIVER_PRESENT */ |
| 774 | } |
| 775 | |
| 776 | psa_status_t psa_driver_wrapper_cipher_update( |
Steven Cooreman | fb81aa5 | 2020-09-09 12:01:43 +0200 | [diff] [blame] | 777 | psa_operation_driver_context_t *operation, |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 778 | const uint8_t *input, |
| 779 | size_t input_length, |
| 780 | uint8_t *output, |
| 781 | size_t output_size, |
| 782 | size_t *output_length ) |
| 783 | { |
| 784 | #if defined(PSA_CRYPTO_DRIVER_PRESENT) && defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT) |
Steven Cooreman | fb81aa5 | 2020-09-09 12:01:43 +0200 | [diff] [blame] | 785 | switch( operation->id ) |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 786 | { |
| 787 | #if defined(PSA_CRYPTO_DRIVER_TEST) |
| 788 | case PSA_CRYPTO_TRANSPARENT_TEST_DRIVER_ID: |
Steven Cooreman | fb81aa5 | 2020-09-09 12:01:43 +0200 | [diff] [blame] | 789 | return( test_transparent_cipher_update( operation->ctx, |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 790 | input, |
| 791 | input_length, |
| 792 | output, |
| 793 | output_size, |
| 794 | output_length ) ); |
| 795 | #endif /* PSA_CRYPTO_DRIVER_TEST */ |
| 796 | #if defined(PSA_CRYPTO_DRIVER_TEST) |
| 797 | case PSA_CRYPTO_OPAQUE_TEST_DRIVER_ID: |
Steven Cooreman | fb81aa5 | 2020-09-09 12:01:43 +0200 | [diff] [blame] | 798 | return( test_opaque_cipher_update( operation->ctx, |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 799 | input, |
| 800 | input_length, |
| 801 | output, |
| 802 | output_size, |
| 803 | output_length ) ); |
| 804 | #endif /* PSA_CRYPTO_DRIVER_TEST */ |
| 805 | default: |
| 806 | /* Key is attached to a driver not known to us */ |
Steven Cooreman | 5240e8b | 2020-09-09 11:51:45 +0200 | [diff] [blame] | 807 | return( PSA_ERROR_BAD_STATE ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 808 | } |
| 809 | #else /* PSA_CRYPTO_DRIVER_PRESENT */ |
| 810 | (void) operation; |
| 811 | (void) input; |
| 812 | (void) input_length; |
| 813 | (void) output; |
| 814 | (void) output_length; |
| 815 | (void) output_size; |
| 816 | |
Steven Cooreman | 5240e8b | 2020-09-09 11:51:45 +0200 | [diff] [blame] | 817 | return( PSA_ERROR_NOT_SUPPORTED ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 818 | #endif /* PSA_CRYPTO_DRIVER_PRESENT */ |
| 819 | } |
| 820 | |
| 821 | psa_status_t psa_driver_wrapper_cipher_finish( |
Steven Cooreman | fb81aa5 | 2020-09-09 12:01:43 +0200 | [diff] [blame] | 822 | psa_operation_driver_context_t *operation, |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 823 | uint8_t *output, |
| 824 | size_t output_size, |
| 825 | size_t *output_length ) |
| 826 | { |
| 827 | #if defined(PSA_CRYPTO_DRIVER_PRESENT) && defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT) |
Steven Cooreman | fb81aa5 | 2020-09-09 12:01:43 +0200 | [diff] [blame] | 828 | switch( operation->id ) |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 829 | { |
| 830 | #if defined(PSA_CRYPTO_DRIVER_TEST) |
| 831 | case PSA_CRYPTO_TRANSPARENT_TEST_DRIVER_ID: |
Steven Cooreman | fb81aa5 | 2020-09-09 12:01:43 +0200 | [diff] [blame] | 832 | return( test_transparent_cipher_finish( operation->ctx, |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 833 | output, |
| 834 | output_size, |
| 835 | output_length ) ); |
| 836 | #endif /* PSA_CRYPTO_DRIVER_TEST */ |
| 837 | #if defined(PSA_CRYPTO_DRIVER_TEST) |
| 838 | case PSA_CRYPTO_OPAQUE_TEST_DRIVER_ID: |
Steven Cooreman | fb81aa5 | 2020-09-09 12:01:43 +0200 | [diff] [blame] | 839 | return( test_opaque_cipher_finish( operation->ctx, |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 840 | output, |
| 841 | output_size, |
| 842 | output_length ) ); |
| 843 | #endif /* PSA_CRYPTO_DRIVER_TEST */ |
| 844 | default: |
| 845 | /* Key is attached to a driver not known to us */ |
Steven Cooreman | 5240e8b | 2020-09-09 11:51:45 +0200 | [diff] [blame] | 846 | return( PSA_ERROR_BAD_STATE ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 847 | } |
| 848 | #else /* PSA_CRYPTO_DRIVER_PRESENT */ |
| 849 | (void) operation; |
| 850 | (void) output; |
| 851 | (void) output_size; |
| 852 | (void) output_length; |
| 853 | |
Steven Cooreman | 5240e8b | 2020-09-09 11:51:45 +0200 | [diff] [blame] | 854 | return( PSA_ERROR_NOT_SUPPORTED ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 855 | #endif /* PSA_CRYPTO_DRIVER_PRESENT */ |
| 856 | } |
| 857 | |
| 858 | psa_status_t psa_driver_wrapper_cipher_abort( |
Steven Cooreman | fb81aa5 | 2020-09-09 12:01:43 +0200 | [diff] [blame] | 859 | psa_operation_driver_context_t *operation ) |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 860 | { |
| 861 | #if defined(PSA_CRYPTO_DRIVER_PRESENT) && defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT) |
| 862 | psa_status_t status = PSA_ERROR_INVALID_ARGUMENT; |
Steven Cooreman | cfeea8f | 2020-09-09 15:09:18 +0200 | [diff] [blame] | 863 | |
| 864 | /* The object has (apparently) been initialized but it is not in use. It's |
| 865 | * ok to call abort on such an object, and there's nothing to do. */ |
| 866 | if( operation->ctx == NULL && operation->id == 0 ) |
| 867 | return( PSA_SUCCESS ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 868 | |
Steven Cooreman | fb81aa5 | 2020-09-09 12:01:43 +0200 | [diff] [blame] | 869 | switch( operation->id ) |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 870 | { |
| 871 | #if defined(PSA_CRYPTO_DRIVER_TEST) |
| 872 | case PSA_CRYPTO_TRANSPARENT_TEST_DRIVER_ID: |
Steven Cooreman | fb81aa5 | 2020-09-09 12:01:43 +0200 | [diff] [blame] | 873 | status = test_transparent_cipher_abort( operation->ctx ); |
Steven Cooreman | cfeea8f | 2020-09-09 15:09:18 +0200 | [diff] [blame] | 874 | mbedtls_platform_zeroize( |
| 875 | operation->ctx, |
| 876 | sizeof( test_transparent_cipher_operation_t ) ); |
Steven Cooreman | fb81aa5 | 2020-09-09 12:01:43 +0200 | [diff] [blame] | 877 | mbedtls_free( operation->ctx ); |
| 878 | operation->ctx = NULL; |
| 879 | operation->id = 0; |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 880 | |
Steven Cooreman | 5240e8b | 2020-09-09 11:51:45 +0200 | [diff] [blame] | 881 | return( status ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 882 | #endif /* PSA_CRYPTO_DRIVER_TEST */ |
| 883 | #if defined(PSA_CRYPTO_DRIVER_TEST) |
| 884 | case PSA_CRYPTO_OPAQUE_TEST_DRIVER_ID: |
Steven Cooreman | fb81aa5 | 2020-09-09 12:01:43 +0200 | [diff] [blame] | 885 | status = test_opaque_cipher_abort( operation->ctx ); |
Steven Cooreman | cfeea8f | 2020-09-09 15:09:18 +0200 | [diff] [blame] | 886 | mbedtls_platform_zeroize( |
| 887 | operation->ctx, |
| 888 | sizeof( test_opaque_cipher_operation_t ) ); |
Steven Cooreman | fb81aa5 | 2020-09-09 12:01:43 +0200 | [diff] [blame] | 889 | mbedtls_free( operation->ctx ); |
| 890 | operation->ctx = NULL; |
Steven Cooreman | cfeea8f | 2020-09-09 15:09:18 +0200 | [diff] [blame] | 891 | operation->id = 0; |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 892 | |
Steven Cooreman | 5240e8b | 2020-09-09 11:51:45 +0200 | [diff] [blame] | 893 | return( status ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 894 | #endif /* PSA_CRYPTO_DRIVER_TEST */ |
| 895 | default: |
| 896 | /* Operation is attached to a driver not known to us */ |
Steven Cooreman | 5240e8b | 2020-09-09 11:51:45 +0200 | [diff] [blame] | 897 | return( PSA_ERROR_BAD_STATE ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 898 | } |
| 899 | #else /* PSA_CRYPTO_DRIVER_PRESENT */ |
| 900 | (void)operation; |
| 901 | |
Steven Cooreman | 5240e8b | 2020-09-09 11:51:45 +0200 | [diff] [blame] | 902 | return( PSA_ERROR_NOT_SUPPORTED ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 903 | #endif /* PSA_CRYPTO_DRIVER_PRESENT */ |
| 904 | } |
| 905 | |
Steven Cooreman | cd84cb4 | 2020-07-16 20:28:36 +0200 | [diff] [blame] | 906 | /* End of automatically generated file. */ |