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; |
Steven Cooreman | 2a1664c | 2020-07-20 15:33:08 +0200 | [diff] [blame] | 259 | if( PSA_KEY_LIFETIME_GET_LOCATION( attributes->core.lifetime ) == PSA_KEY_LOCATION_LOCAL_STORAGE ) |
| 260 | { |
Steven Cooreman | 56250fd | 2020-09-04 13:07:15 +0200 | [diff] [blame] | 261 | buffer_size = PSA_KEY_EXPORT_MAX_SIZE( attributes->core.type, |
| 262 | attributes->core.bits ); |
Steven Cooreman | 2a1664c | 2020-07-20 15:33:08 +0200 | [diff] [blame] | 263 | |
Steven Cooreman | 56250fd | 2020-09-04 13:07:15 +0200 | [diff] [blame] | 264 | if( buffer_size == 0 ) |
| 265 | return( PSA_ERROR_NOT_SUPPORTED ); |
Steven Cooreman | 2a1664c | 2020-07-20 15:33:08 +0200 | [diff] [blame] | 266 | |
Steven Cooreman | 56250fd | 2020-09-04 13:07:15 +0200 | [diff] [blame] | 267 | *expected_size = buffer_size; |
| 268 | return( PSA_SUCCESS ); |
Steven Cooreman | 2a1664c | 2020-07-20 15:33:08 +0200 | [diff] [blame] | 269 | } |
| 270 | else |
| 271 | { |
Steven Cooreman | 56250fd | 2020-09-04 13:07:15 +0200 | [diff] [blame] | 272 | /* TBD: opaque driver support: need to calculate size through a |
| 273 | * driver-defined size function, since the size of an opaque (wrapped) |
| 274 | * key will be different for each implementation. */ |
| 275 | return( PSA_ERROR_NOT_SUPPORTED ); |
Steven Cooreman | 2a1664c | 2020-07-20 15:33:08 +0200 | [diff] [blame] | 276 | } |
| 277 | } |
Steven Cooreman | f1720ea | 2020-07-24 18:41:58 +0200 | [diff] [blame] | 278 | #endif /* PSA_CRYPTO_DRIVER_PRESENT */ |
Steven Cooreman | 2a1664c | 2020-07-20 15:33:08 +0200 | [diff] [blame] | 279 | |
Steven Cooreman | 55ae217 | 2020-07-17 19:46:15 +0200 | [diff] [blame] | 280 | psa_status_t psa_driver_wrapper_generate_key( const psa_key_attributes_t *attributes, |
| 281 | psa_key_slot_t *slot ) |
| 282 | { |
Steven Cooreman | f1720ea | 2020-07-24 18:41:58 +0200 | [diff] [blame] | 283 | #if defined(PSA_CRYPTO_DRIVER_PRESENT) |
Steven Cooreman | 2a1664c | 2020-07-20 15:33:08 +0200 | [diff] [blame] | 284 | /* Try dynamically-registered SE interface first */ |
| 285 | #if defined(MBEDTLS_PSA_CRYPTO_SE_C) |
| 286 | const psa_drv_se_t *drv; |
| 287 | psa_drv_se_context_t *drv_context; |
| 288 | |
| 289 | if( psa_get_se_driver( slot->attr.lifetime, &drv, &drv_context ) ) |
| 290 | { |
| 291 | size_t pubkey_length = 0; /* We don't support this feature yet */ |
| 292 | if( drv->key_management == NULL || |
| 293 | drv->key_management->p_generate == NULL ) |
| 294 | { |
| 295 | /* 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] | 296 | return( PSA_ERROR_NOT_SUPPORTED ); |
Steven Cooreman | 2a1664c | 2020-07-20 15:33:08 +0200 | [diff] [blame] | 297 | } |
| 298 | return( drv->key_management->p_generate( |
| 299 | drv_context, |
| 300 | slot->data.se.slot_number, attributes, |
| 301 | NULL, 0, &pubkey_length ) ); |
| 302 | } |
| 303 | #endif /* MBEDTLS_PSA_CRYPTO_SE_C */ |
| 304 | |
| 305 | /* Then try accelerator API */ |
Steven Cooreman | f1720ea | 2020-07-24 18:41:58 +0200 | [diff] [blame] | 306 | #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT) |
Steven Cooreman | 2a1664c | 2020-07-20 15:33:08 +0200 | [diff] [blame] | 307 | psa_status_t status = PSA_ERROR_INVALID_ARGUMENT; |
| 308 | psa_key_location_t location = PSA_KEY_LIFETIME_GET_LOCATION(slot->attr.lifetime); |
| 309 | size_t export_size = 0; |
| 310 | |
| 311 | status = get_expected_key_size( attributes, &export_size ); |
| 312 | if( status != PSA_SUCCESS ) |
Steven Cooreman | 56250fd | 2020-09-04 13:07:15 +0200 | [diff] [blame] | 313 | return( status ); |
Steven Cooreman | 2a1664c | 2020-07-20 15:33:08 +0200 | [diff] [blame] | 314 | |
| 315 | slot->data.key.data = mbedtls_calloc(1, export_size); |
| 316 | if( slot->data.key.data == NULL ) |
Steven Cooreman | 56250fd | 2020-09-04 13:07:15 +0200 | [diff] [blame] | 317 | return( PSA_ERROR_INSUFFICIENT_MEMORY ); |
Steven Cooreman | 2a1664c | 2020-07-20 15:33:08 +0200 | [diff] [blame] | 318 | slot->data.key.bytes = export_size; |
| 319 | |
| 320 | switch( location ) |
| 321 | { |
| 322 | case PSA_KEY_LOCATION_LOCAL_STORAGE: |
| 323 | /* Key is stored in the slot in export representation, so |
| 324 | * cycle through all known transparent accelerators */ |
| 325 | |
| 326 | /* Transparent drivers are limited to generating asymmetric keys */ |
| 327 | if( ! PSA_KEY_TYPE_IS_ASYMMETRIC( slot->attr.type ) ) |
| 328 | { |
| 329 | status = PSA_ERROR_NOT_SUPPORTED; |
| 330 | break; |
| 331 | } |
Steven Cooreman | f1720ea | 2020-07-24 18:41:58 +0200 | [diff] [blame] | 332 | #if defined(PSA_CRYPTO_DRIVER_TEST) |
Steven Cooreman | 2a1664c | 2020-07-20 15:33:08 +0200 | [diff] [blame] | 333 | status = test_transparent_generate_key( attributes, |
| 334 | slot->data.key.data, |
| 335 | slot->data.key.bytes, |
| 336 | &slot->data.key.bytes ); |
| 337 | /* Declared with fallback == true */ |
| 338 | if( status != PSA_ERROR_NOT_SUPPORTED ) |
| 339 | break; |
Steven Cooreman | f1720ea | 2020-07-24 18:41:58 +0200 | [diff] [blame] | 340 | #endif /* PSA_CRYPTO_DRIVER_TEST */ |
Steven Cooreman | 2a1664c | 2020-07-20 15:33:08 +0200 | [diff] [blame] | 341 | /* Fell through, meaning no accelerator supports this operation */ |
| 342 | status = PSA_ERROR_NOT_SUPPORTED; |
| 343 | break; |
| 344 | /* Add cases for opaque driver here */ |
Steven Cooreman | f1720ea | 2020-07-24 18:41:58 +0200 | [diff] [blame] | 345 | #if defined(PSA_CRYPTO_DRIVER_TEST) |
| 346 | case PSA_CRYPTO_TEST_DRIVER_LIFETIME: |
Steven Cooreman | 2a1664c | 2020-07-20 15:33:08 +0200 | [diff] [blame] | 347 | status = test_opaque_generate_key( attributes, |
| 348 | slot->data.key.data, |
| 349 | slot->data.key.bytes, |
| 350 | &slot->data.key.bytes ); |
| 351 | break; |
Steven Cooreman | f1720ea | 2020-07-24 18:41:58 +0200 | [diff] [blame] | 352 | #endif /* PSA_CRYPTO_DRIVER_TEST */ |
Steven Cooreman | 2a1664c | 2020-07-20 15:33:08 +0200 | [diff] [blame] | 353 | default: |
| 354 | /* Key is declared with a lifetime not known to us */ |
| 355 | status = PSA_ERROR_INVALID_ARGUMENT; |
| 356 | break; |
| 357 | } |
| 358 | |
| 359 | if( status != PSA_SUCCESS ) |
| 360 | { |
| 361 | /* free allocated buffer */ |
| 362 | mbedtls_free( slot->data.key.data ); |
| 363 | slot->data.key.data = NULL; |
| 364 | slot->data.key.bytes = 0; |
| 365 | } |
| 366 | |
| 367 | return( status ); |
Steven Cooreman | f1720ea | 2020-07-24 18:41:58 +0200 | [diff] [blame] | 368 | #else /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */ |
Steven Cooreman | 56250fd | 2020-09-04 13:07:15 +0200 | [diff] [blame] | 369 | return( PSA_ERROR_NOT_SUPPORTED ); |
Steven Cooreman | f1720ea | 2020-07-24 18:41:58 +0200 | [diff] [blame] | 370 | #endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */ |
| 371 | #else /* PSA_CRYPTO_DRIVER_PRESENT */ |
Steven Cooreman | 55ae217 | 2020-07-17 19:46:15 +0200 | [diff] [blame] | 372 | (void) attributes; |
| 373 | (void) slot; |
| 374 | |
Steven Cooreman | 56250fd | 2020-09-04 13:07:15 +0200 | [diff] [blame] | 375 | return( PSA_ERROR_NOT_SUPPORTED ); |
Steven Cooreman | f1720ea | 2020-07-24 18:41:58 +0200 | [diff] [blame] | 376 | #endif /* PSA_CRYPTO_DRIVER_PRESENT */ |
Steven Cooreman | 55ae217 | 2020-07-17 19:46:15 +0200 | [diff] [blame] | 377 | } |
| 378 | |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 379 | /* |
| 380 | * Cipher functions |
| 381 | */ |
| 382 | psa_status_t psa_driver_wrapper_cipher_encrypt( |
| 383 | psa_key_slot_t *slot, |
| 384 | psa_algorithm_t alg, |
| 385 | const uint8_t *input, |
| 386 | size_t input_length, |
| 387 | uint8_t *output, |
| 388 | size_t output_size, |
| 389 | size_t *output_length ) |
| 390 | { |
| 391 | #if defined(PSA_CRYPTO_DRIVER_PRESENT) && defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT) |
| 392 | psa_status_t status = PSA_ERROR_INVALID_ARGUMENT; |
| 393 | psa_key_location_t location = PSA_KEY_LIFETIME_GET_LOCATION(slot->attr.lifetime); |
| 394 | psa_key_attributes_t attributes = { |
| 395 | .core = slot->attr |
| 396 | }; |
| 397 | |
| 398 | switch( location ) |
| 399 | { |
| 400 | case PSA_KEY_LOCATION_LOCAL_STORAGE: |
| 401 | /* Key is stored in the slot in export representation, so |
| 402 | * cycle through all known transparent accelerators */ |
| 403 | #if defined(PSA_CRYPTO_DRIVER_TEST) |
| 404 | status = test_transparent_cipher_encrypt( &attributes, |
| 405 | slot->data.key.data, |
| 406 | slot->data.key.bytes, |
| 407 | alg, |
| 408 | input, |
| 409 | input_length, |
| 410 | output, |
| 411 | output_size, |
| 412 | output_length ); |
| 413 | /* Declared with fallback == true */ |
| 414 | if( status != PSA_ERROR_NOT_SUPPORTED ) |
Steven Cooreman | 5240e8b | 2020-09-09 11:51:45 +0200 | [diff] [blame] | 415 | return( status ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 416 | #endif /* PSA_CRYPTO_DRIVER_TEST */ |
| 417 | /* Fell through, meaning no accelerator supports this operation */ |
Steven Cooreman | 5240e8b | 2020-09-09 11:51:45 +0200 | [diff] [blame] | 418 | return( PSA_ERROR_NOT_SUPPORTED ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 419 | /* Add cases for opaque driver here */ |
| 420 | #if defined(PSA_CRYPTO_DRIVER_TEST) |
| 421 | case PSA_CRYPTO_TEST_DRIVER_LIFETIME: |
| 422 | return( test_opaque_cipher_encrypt( &attributes, |
| 423 | slot->data.key.data, |
| 424 | slot->data.key.bytes, |
| 425 | alg, |
| 426 | input, |
| 427 | input_length, |
| 428 | output, |
| 429 | output_size, |
| 430 | output_length ) ); |
| 431 | #endif /* PSA_CRYPTO_DRIVER_TEST */ |
| 432 | default: |
| 433 | /* Key is declared with a lifetime not known to us */ |
Steven Cooreman | 5240e8b | 2020-09-09 11:51:45 +0200 | [diff] [blame] | 434 | return( status ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 435 | } |
| 436 | #else /* PSA_CRYPTO_DRIVER_PRESENT */ |
| 437 | (void) slot; |
| 438 | (void) alg; |
| 439 | (void) input; |
| 440 | (void) input_length; |
| 441 | (void) output; |
| 442 | (void) output_size; |
| 443 | (void) output_length; |
| 444 | |
Steven Cooreman | 5240e8b | 2020-09-09 11:51:45 +0200 | [diff] [blame] | 445 | return( PSA_ERROR_NOT_SUPPORTED ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 446 | #endif /* PSA_CRYPTO_DRIVER_PRESENT */ |
| 447 | } |
| 448 | |
| 449 | psa_status_t psa_driver_wrapper_cipher_decrypt( |
| 450 | psa_key_slot_t *slot, |
| 451 | psa_algorithm_t alg, |
| 452 | const uint8_t *input, |
| 453 | size_t input_length, |
| 454 | uint8_t *output, |
| 455 | size_t output_size, |
| 456 | size_t *output_length ) |
| 457 | { |
| 458 | #if defined(PSA_CRYPTO_DRIVER_PRESENT) && defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT) |
| 459 | psa_status_t status = PSA_ERROR_INVALID_ARGUMENT; |
| 460 | psa_key_location_t location = PSA_KEY_LIFETIME_GET_LOCATION(slot->attr.lifetime); |
| 461 | psa_key_attributes_t attributes = { |
| 462 | .core = slot->attr |
| 463 | }; |
| 464 | |
| 465 | switch( location ) |
| 466 | { |
| 467 | case PSA_KEY_LOCATION_LOCAL_STORAGE: |
| 468 | /* Key is stored in the slot in export representation, so |
| 469 | * cycle through all known transparent accelerators */ |
| 470 | #if defined(PSA_CRYPTO_DRIVER_TEST) |
| 471 | status = test_transparent_cipher_decrypt( &attributes, |
| 472 | slot->data.key.data, |
| 473 | slot->data.key.bytes, |
| 474 | alg, |
| 475 | input, |
| 476 | input_length, |
| 477 | output, |
| 478 | output_size, |
| 479 | output_length ); |
| 480 | /* Declared with fallback == true */ |
| 481 | if( status != PSA_ERROR_NOT_SUPPORTED ) |
Steven Cooreman | 5240e8b | 2020-09-09 11:51:45 +0200 | [diff] [blame] | 482 | return( status ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 483 | #endif /* PSA_CRYPTO_DRIVER_TEST */ |
| 484 | /* Fell through, meaning no accelerator supports this operation */ |
Steven Cooreman | 5240e8b | 2020-09-09 11:51:45 +0200 | [diff] [blame] | 485 | return( PSA_ERROR_NOT_SUPPORTED ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 486 | /* Add cases for opaque driver here */ |
| 487 | #if defined(PSA_CRYPTO_DRIVER_TEST) |
| 488 | case PSA_CRYPTO_TEST_DRIVER_LIFETIME: |
| 489 | return( test_opaque_cipher_decrypt( &attributes, |
| 490 | slot->data.key.data, |
| 491 | slot->data.key.bytes, |
| 492 | alg, |
| 493 | input, |
| 494 | input_length, |
| 495 | output, |
| 496 | output_size, |
| 497 | output_length ) ); |
| 498 | #endif /* PSA_CRYPTO_DRIVER_TEST */ |
| 499 | default: |
| 500 | /* Key is declared with a lifetime not known to us */ |
Steven Cooreman | 5240e8b | 2020-09-09 11:51:45 +0200 | [diff] [blame] | 501 | return( status ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 502 | } |
| 503 | #else /* PSA_CRYPTO_DRIVER_PRESENT */ |
| 504 | (void) slot; |
| 505 | (void) alg; |
| 506 | (void) input; |
| 507 | (void) input_length; |
| 508 | (void) output; |
| 509 | (void) output_size; |
| 510 | (void) output_length; |
| 511 | |
Steven Cooreman | 5240e8b | 2020-09-09 11:51:45 +0200 | [diff] [blame] | 512 | return( PSA_ERROR_NOT_SUPPORTED ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 513 | #endif /* PSA_CRYPTO_DRIVER_PRESENT */ |
| 514 | } |
| 515 | |
| 516 | psa_status_t psa_driver_wrapper_cipher_encrypt_setup( |
Steven Cooreman | fb81aa5 | 2020-09-09 12:01:43 +0200 | [diff] [blame] | 517 | psa_operation_driver_context_t *operation, |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 518 | psa_key_slot_t *slot, |
| 519 | psa_algorithm_t alg ) |
| 520 | { |
| 521 | #if defined(PSA_CRYPTO_DRIVER_PRESENT) && defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT) |
| 522 | psa_status_t status = PSA_ERROR_INVALID_ARGUMENT; |
| 523 | psa_key_location_t location = PSA_KEY_LIFETIME_GET_LOCATION(slot->attr.lifetime); |
| 524 | psa_key_attributes_t attributes = { |
| 525 | .core = slot->attr |
| 526 | }; |
| 527 | |
| 528 | /* Check for operation already allocated */ |
Steven Cooreman | fb81aa5 | 2020-09-09 12:01:43 +0200 | [diff] [blame] | 529 | if( operation->ctx != NULL || operation->id != 0 ) |
Steven Cooreman | 5240e8b | 2020-09-09 11:51:45 +0200 | [diff] [blame] | 530 | return( PSA_ERROR_BAD_STATE ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 531 | |
| 532 | switch( location ) |
| 533 | { |
| 534 | case PSA_KEY_LOCATION_LOCAL_STORAGE: |
| 535 | /* Key is stored in the slot in export representation, so |
| 536 | * cycle through all known transparent accelerators */ |
| 537 | #if defined(PSA_CRYPTO_DRIVER_TEST) |
Steven Cooreman | fb81aa5 | 2020-09-09 12:01:43 +0200 | [diff] [blame] | 538 | operation->ctx = mbedtls_calloc( 1, sizeof(test_transparent_cipher_operation_t) ); |
| 539 | if( operation->ctx == NULL ) |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 540 | return PSA_ERROR_INSUFFICIENT_MEMORY; |
| 541 | |
Steven Cooreman | fb81aa5 | 2020-09-09 12:01:43 +0200 | [diff] [blame] | 542 | status = test_transparent_cipher_encrypt_setup( operation->ctx, |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 543 | &attributes, |
| 544 | slot->data.key.data, |
| 545 | slot->data.key.bytes, |
| 546 | alg ); |
| 547 | /* Declared with fallback == true */ |
Steven Cooreman | 150c99b | 2020-09-09 14:32:44 +0200 | [diff] [blame^] | 548 | if( status == PSA_SUCCESS ) |
| 549 | operation->id = PSA_CRYPTO_TRANSPARENT_TEST_DRIVER_ID; |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 550 | else |
| 551 | { |
Steven Cooreman | fb81aa5 | 2020-09-09 12:01:43 +0200 | [diff] [blame] | 552 | mbedtls_free( operation->ctx ); |
| 553 | operation->ctx = NULL; |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 554 | } |
Steven Cooreman | 150c99b | 2020-09-09 14:32:44 +0200 | [diff] [blame^] | 555 | |
| 556 | return( status ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 557 | #endif /* PSA_CRYPTO_DRIVER_TEST */ |
| 558 | /* Fell through, meaning no accelerator supports this operation */ |
Steven Cooreman | 5240e8b | 2020-09-09 11:51:45 +0200 | [diff] [blame] | 559 | return( PSA_ERROR_NOT_SUPPORTED ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 560 | /* Add cases for opaque driver here */ |
| 561 | #if defined(PSA_CRYPTO_DRIVER_TEST) |
| 562 | case PSA_CRYPTO_TEST_DRIVER_LIFETIME: |
Steven Cooreman | fb81aa5 | 2020-09-09 12:01:43 +0200 | [diff] [blame] | 563 | operation->ctx = mbedtls_calloc( 1, sizeof(test_opaque_cipher_operation_t) ); |
| 564 | if( operation->ctx == NULL ) |
Steven Cooreman | 5240e8b | 2020-09-09 11:51:45 +0200 | [diff] [blame] | 565 | return( PSA_ERROR_INSUFFICIENT_MEMORY ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 566 | |
Steven Cooreman | fb81aa5 | 2020-09-09 12:01:43 +0200 | [diff] [blame] | 567 | status = test_opaque_cipher_encrypt_setup( operation->ctx, |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 568 | &attributes, |
| 569 | slot->data.key.data, |
| 570 | slot->data.key.bytes, |
| 571 | alg ); |
| 572 | if( status == PSA_SUCCESS ) |
Steven Cooreman | fb81aa5 | 2020-09-09 12:01:43 +0200 | [diff] [blame] | 573 | operation->id = PSA_CRYPTO_OPAQUE_TEST_DRIVER_ID; |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 574 | else |
| 575 | { |
Steven Cooreman | fb81aa5 | 2020-09-09 12:01:43 +0200 | [diff] [blame] | 576 | mbedtls_free( operation->ctx ); |
| 577 | operation->ctx = NULL; |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 578 | } |
| 579 | |
Steven Cooreman | 5240e8b | 2020-09-09 11:51:45 +0200 | [diff] [blame] | 580 | return( status ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 581 | #endif /* PSA_CRYPTO_DRIVER_TEST */ |
| 582 | default: |
| 583 | /* Key is declared with a lifetime not known to us */ |
Steven Cooreman | 5240e8b | 2020-09-09 11:51:45 +0200 | [diff] [blame] | 584 | return( PSA_ERROR_BAD_STATE ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 585 | } |
| 586 | #else /* PSA_CRYPTO_DRIVER_PRESENT */ |
| 587 | (void)slot; |
| 588 | (void)alg; |
| 589 | (void)operation; |
| 590 | |
Steven Cooreman | 5240e8b | 2020-09-09 11:51:45 +0200 | [diff] [blame] | 591 | return( PSA_ERROR_NOT_SUPPORTED ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 592 | #endif /* PSA_CRYPTO_DRIVER_PRESENT */ |
| 593 | } |
| 594 | |
| 595 | psa_status_t psa_driver_wrapper_cipher_decrypt_setup( |
Steven Cooreman | fb81aa5 | 2020-09-09 12:01:43 +0200 | [diff] [blame] | 596 | psa_operation_driver_context_t *operation, |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 597 | psa_key_slot_t *slot, |
| 598 | psa_algorithm_t alg ) |
| 599 | { |
| 600 | #if defined(PSA_CRYPTO_DRIVER_PRESENT) && defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT) |
| 601 | psa_status_t status = PSA_ERROR_INVALID_ARGUMENT; |
| 602 | psa_key_location_t location = PSA_KEY_LIFETIME_GET_LOCATION(slot->attr.lifetime); |
| 603 | psa_key_attributes_t attributes = { |
| 604 | .core = slot->attr |
| 605 | }; |
| 606 | |
| 607 | /* Check for operation already allocated */ |
Steven Cooreman | fb81aa5 | 2020-09-09 12:01:43 +0200 | [diff] [blame] | 608 | if( operation->ctx != NULL ) |
Steven Cooreman | 5240e8b | 2020-09-09 11:51:45 +0200 | [diff] [blame] | 609 | return( PSA_ERROR_BAD_STATE ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 610 | |
| 611 | switch( location ) |
| 612 | { |
| 613 | case PSA_KEY_LOCATION_LOCAL_STORAGE: |
| 614 | /* Key is stored in the slot in export representation, so |
| 615 | * cycle through all known transparent accelerators */ |
| 616 | #if defined(PSA_CRYPTO_DRIVER_TEST) |
Steven Cooreman | fb81aa5 | 2020-09-09 12:01:43 +0200 | [diff] [blame] | 617 | operation->ctx = mbedtls_calloc( 1, sizeof(test_transparent_cipher_operation_t) ); |
| 618 | if( operation->ctx == NULL ) |
Steven Cooreman | 5240e8b | 2020-09-09 11:51:45 +0200 | [diff] [blame] | 619 | return( PSA_ERROR_INSUFFICIENT_MEMORY ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 620 | |
Steven Cooreman | fb81aa5 | 2020-09-09 12:01:43 +0200 | [diff] [blame] | 621 | status = test_transparent_cipher_decrypt_setup( operation->ctx, |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 622 | &attributes, |
| 623 | slot->data.key.data, |
| 624 | slot->data.key.bytes, |
| 625 | alg ); |
| 626 | /* Declared with fallback == true */ |
Steven Cooreman | 150c99b | 2020-09-09 14:32:44 +0200 | [diff] [blame^] | 627 | if( status == PSA_SUCCESS ) |
| 628 | operation->id = PSA_CRYPTO_TRANSPARENT_TEST_DRIVER_ID; |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 629 | else |
| 630 | { |
Steven Cooreman | fb81aa5 | 2020-09-09 12:01:43 +0200 | [diff] [blame] | 631 | mbedtls_free( operation->ctx ); |
| 632 | operation->ctx = NULL; |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 633 | } |
Steven Cooreman | 150c99b | 2020-09-09 14:32:44 +0200 | [diff] [blame^] | 634 | |
| 635 | return( status ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 636 | #endif /* PSA_CRYPTO_DRIVER_TEST */ |
| 637 | /* Fell through, meaning no accelerator supports this operation */ |
Steven Cooreman | 5240e8b | 2020-09-09 11:51:45 +0200 | [diff] [blame] | 638 | return( PSA_ERROR_NOT_SUPPORTED ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 639 | /* Add cases for opaque driver here */ |
| 640 | #if defined(PSA_CRYPTO_DRIVER_TEST) |
| 641 | case PSA_CRYPTO_TEST_DRIVER_LIFETIME: |
Steven Cooreman | fb81aa5 | 2020-09-09 12:01:43 +0200 | [diff] [blame] | 642 | operation->ctx = mbedtls_calloc( 1, sizeof(test_opaque_cipher_operation_t) ); |
| 643 | if( operation->ctx == NULL ) |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 644 | return PSA_ERROR_INSUFFICIENT_MEMORY; |
| 645 | |
Steven Cooreman | fb81aa5 | 2020-09-09 12:01:43 +0200 | [diff] [blame] | 646 | status = test_opaque_cipher_decrypt_setup( operation->ctx, |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 647 | &attributes, |
| 648 | slot->data.key.data, |
| 649 | slot->data.key.bytes, |
| 650 | alg ); |
| 651 | if( status == PSA_SUCCESS ) |
Steven Cooreman | fb81aa5 | 2020-09-09 12:01:43 +0200 | [diff] [blame] | 652 | operation->id = PSA_CRYPTO_OPAQUE_TEST_DRIVER_ID; |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 653 | else |
| 654 | { |
Steven Cooreman | fb81aa5 | 2020-09-09 12:01:43 +0200 | [diff] [blame] | 655 | mbedtls_free( operation->ctx ); |
| 656 | operation->ctx = NULL; |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 657 | } |
| 658 | |
Steven Cooreman | 5240e8b | 2020-09-09 11:51:45 +0200 | [diff] [blame] | 659 | return( status ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 660 | #endif /* PSA_CRYPTO_DRIVER_TEST */ |
| 661 | default: |
| 662 | /* Key is declared with a lifetime not known to us */ |
Steven Cooreman | 5240e8b | 2020-09-09 11:51:45 +0200 | [diff] [blame] | 663 | return( PSA_ERROR_BAD_STATE ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 664 | } |
| 665 | #else /* PSA_CRYPTO_DRIVER_PRESENT */ |
| 666 | (void)slot; |
| 667 | (void)alg; |
| 668 | (void)operation; |
| 669 | |
Steven Cooreman | 5240e8b | 2020-09-09 11:51:45 +0200 | [diff] [blame] | 670 | return( PSA_ERROR_NOT_SUPPORTED ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 671 | #endif /* PSA_CRYPTO_DRIVER_PRESENT */ |
| 672 | } |
| 673 | |
| 674 | psa_status_t psa_driver_wrapper_cipher_generate_iv( |
Steven Cooreman | fb81aa5 | 2020-09-09 12:01:43 +0200 | [diff] [blame] | 675 | psa_operation_driver_context_t *operation, |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 676 | uint8_t *iv, |
| 677 | size_t iv_size, |
| 678 | size_t *iv_length ) |
| 679 | { |
| 680 | #if defined(PSA_CRYPTO_DRIVER_PRESENT) && defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT) |
| 681 | /* Check for operation already allocated */ |
Steven Cooreman | fb81aa5 | 2020-09-09 12:01:43 +0200 | [diff] [blame] | 682 | if( operation->ctx == NULL ) |
Steven Cooreman | 5240e8b | 2020-09-09 11:51:45 +0200 | [diff] [blame] | 683 | return( PSA_ERROR_INVALID_ARGUMENT ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 684 | |
Steven Cooreman | fb81aa5 | 2020-09-09 12:01:43 +0200 | [diff] [blame] | 685 | switch( operation->id ) |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 686 | { |
| 687 | #if defined(PSA_CRYPTO_DRIVER_TEST) |
| 688 | case PSA_CRYPTO_TRANSPARENT_TEST_DRIVER_ID: |
Steven Cooreman | fb81aa5 | 2020-09-09 12:01:43 +0200 | [diff] [blame] | 689 | return( test_transparent_cipher_generate_iv( operation->ctx, |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 690 | iv, |
| 691 | iv_size, |
| 692 | iv_length ) ); |
| 693 | #endif /* PSA_CRYPTO_DRIVER_TEST */ |
| 694 | #if defined(PSA_CRYPTO_DRIVER_TEST) |
| 695 | case PSA_CRYPTO_OPAQUE_TEST_DRIVER_ID: |
Steven Cooreman | fb81aa5 | 2020-09-09 12:01:43 +0200 | [diff] [blame] | 696 | return( test_opaque_cipher_generate_iv( operation->ctx, |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 697 | iv, |
| 698 | iv_size, |
| 699 | iv_length ) ); |
| 700 | #endif /* PSA_CRYPTO_DRIVER_TEST */ |
| 701 | default: |
| 702 | /* Key is attached to a driver not known to us */ |
Steven Cooreman | 5240e8b | 2020-09-09 11:51:45 +0200 | [diff] [blame] | 703 | return( PSA_ERROR_BAD_STATE ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 704 | } |
| 705 | #else /* PSA_CRYPTO_DRIVER_PRESENT */ |
| 706 | (void) operation; |
| 707 | (void) iv; |
| 708 | (void) iv_size; |
| 709 | (void) iv_length; |
| 710 | |
Steven Cooreman | 5240e8b | 2020-09-09 11:51:45 +0200 | [diff] [blame] | 711 | return( PSA_ERROR_NOT_SUPPORTED ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 712 | #endif /* PSA_CRYPTO_DRIVER_PRESENT */ |
| 713 | } |
| 714 | |
| 715 | psa_status_t psa_driver_wrapper_cipher_set_iv( |
Steven Cooreman | fb81aa5 | 2020-09-09 12:01:43 +0200 | [diff] [blame] | 716 | psa_operation_driver_context_t *operation, |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 717 | const uint8_t *iv, |
| 718 | size_t iv_length ) |
| 719 | { |
| 720 | #if defined(PSA_CRYPTO_DRIVER_PRESENT) && defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT) |
| 721 | /* Check for operation already allocated */ |
Steven Cooreman | fb81aa5 | 2020-09-09 12:01:43 +0200 | [diff] [blame] | 722 | if( operation->ctx == NULL ) |
Steven Cooreman | 5240e8b | 2020-09-09 11:51:45 +0200 | [diff] [blame] | 723 | return( PSA_ERROR_INVALID_ARGUMENT ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 724 | |
Steven Cooreman | fb81aa5 | 2020-09-09 12:01:43 +0200 | [diff] [blame] | 725 | switch( operation->id ) |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 726 | { |
| 727 | #if defined(PSA_CRYPTO_DRIVER_TEST) |
| 728 | case PSA_CRYPTO_TRANSPARENT_TEST_DRIVER_ID: |
Steven Cooreman | fb81aa5 | 2020-09-09 12:01:43 +0200 | [diff] [blame] | 729 | return( test_transparent_cipher_set_iv( operation->ctx, |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 730 | iv, |
| 731 | iv_length ) ); |
| 732 | #endif /* PSA_CRYPTO_DRIVER_TEST */ |
| 733 | #if defined(PSA_CRYPTO_DRIVER_TEST) |
| 734 | case PSA_CRYPTO_OPAQUE_TEST_DRIVER_ID: |
Steven Cooreman | fb81aa5 | 2020-09-09 12:01:43 +0200 | [diff] [blame] | 735 | return( test_opaque_cipher_set_iv( operation->ctx, |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 736 | iv, |
| 737 | iv_length ) ); |
| 738 | #endif /* PSA_CRYPTO_DRIVER_TEST */ |
| 739 | default: |
| 740 | /* Key is attached to a driver not known to us */ |
Steven Cooreman | 5240e8b | 2020-09-09 11:51:45 +0200 | [diff] [blame] | 741 | return( PSA_ERROR_BAD_STATE ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 742 | } |
| 743 | #else /* PSA_CRYPTO_DRIVER_PRESENT */ |
| 744 | (void) operation; |
| 745 | (void) iv; |
| 746 | (void) iv_length; |
| 747 | |
Steven Cooreman | 5240e8b | 2020-09-09 11:51:45 +0200 | [diff] [blame] | 748 | return( PSA_ERROR_NOT_SUPPORTED ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 749 | #endif /* PSA_CRYPTO_DRIVER_PRESENT */ |
| 750 | } |
| 751 | |
| 752 | psa_status_t psa_driver_wrapper_cipher_update( |
Steven Cooreman | fb81aa5 | 2020-09-09 12:01:43 +0200 | [diff] [blame] | 753 | psa_operation_driver_context_t *operation, |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 754 | const uint8_t *input, |
| 755 | size_t input_length, |
| 756 | uint8_t *output, |
| 757 | size_t output_size, |
| 758 | size_t *output_length ) |
| 759 | { |
| 760 | #if defined(PSA_CRYPTO_DRIVER_PRESENT) && defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT) |
| 761 | /* Check for operation already allocated */ |
Steven Cooreman | fb81aa5 | 2020-09-09 12:01:43 +0200 | [diff] [blame] | 762 | if( operation->ctx == NULL ) |
Steven Cooreman | 5240e8b | 2020-09-09 11:51:45 +0200 | [diff] [blame] | 763 | return( PSA_ERROR_INVALID_ARGUMENT ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 764 | |
Steven Cooreman | fb81aa5 | 2020-09-09 12:01:43 +0200 | [diff] [blame] | 765 | switch( operation->id ) |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 766 | { |
| 767 | #if defined(PSA_CRYPTO_DRIVER_TEST) |
| 768 | case PSA_CRYPTO_TRANSPARENT_TEST_DRIVER_ID: |
Steven Cooreman | fb81aa5 | 2020-09-09 12:01:43 +0200 | [diff] [blame] | 769 | return( test_transparent_cipher_update( operation->ctx, |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 770 | input, |
| 771 | input_length, |
| 772 | output, |
| 773 | output_size, |
| 774 | output_length ) ); |
| 775 | #endif /* PSA_CRYPTO_DRIVER_TEST */ |
| 776 | #if defined(PSA_CRYPTO_DRIVER_TEST) |
| 777 | case PSA_CRYPTO_OPAQUE_TEST_DRIVER_ID: |
Steven Cooreman | fb81aa5 | 2020-09-09 12:01:43 +0200 | [diff] [blame] | 778 | return( test_opaque_cipher_update( operation->ctx, |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 779 | input, |
| 780 | input_length, |
| 781 | output, |
| 782 | output_size, |
| 783 | output_length ) ); |
| 784 | #endif /* PSA_CRYPTO_DRIVER_TEST */ |
| 785 | default: |
| 786 | /* Key is attached to a driver not known to us */ |
Steven Cooreman | 5240e8b | 2020-09-09 11:51:45 +0200 | [diff] [blame] | 787 | return( PSA_ERROR_BAD_STATE ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 788 | } |
| 789 | #else /* PSA_CRYPTO_DRIVER_PRESENT */ |
| 790 | (void) operation; |
| 791 | (void) input; |
| 792 | (void) input_length; |
| 793 | (void) output; |
| 794 | (void) output_length; |
| 795 | (void) output_size; |
| 796 | |
Steven Cooreman | 5240e8b | 2020-09-09 11:51:45 +0200 | [diff] [blame] | 797 | return( PSA_ERROR_NOT_SUPPORTED ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 798 | #endif /* PSA_CRYPTO_DRIVER_PRESENT */ |
| 799 | } |
| 800 | |
| 801 | psa_status_t psa_driver_wrapper_cipher_finish( |
Steven Cooreman | fb81aa5 | 2020-09-09 12:01:43 +0200 | [diff] [blame] | 802 | psa_operation_driver_context_t *operation, |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 803 | uint8_t *output, |
| 804 | size_t output_size, |
| 805 | size_t *output_length ) |
| 806 | { |
| 807 | #if defined(PSA_CRYPTO_DRIVER_PRESENT) && defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT) |
| 808 | /* Check for operation already allocated */ |
Steven Cooreman | fb81aa5 | 2020-09-09 12:01:43 +0200 | [diff] [blame] | 809 | if( operation->ctx == NULL ) |
Steven Cooreman | 5240e8b | 2020-09-09 11:51:45 +0200 | [diff] [blame] | 810 | return( PSA_ERROR_INVALID_ARGUMENT ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 811 | |
Steven Cooreman | fb81aa5 | 2020-09-09 12:01:43 +0200 | [diff] [blame] | 812 | switch( operation->id ) |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 813 | { |
| 814 | #if defined(PSA_CRYPTO_DRIVER_TEST) |
| 815 | case PSA_CRYPTO_TRANSPARENT_TEST_DRIVER_ID: |
Steven Cooreman | fb81aa5 | 2020-09-09 12:01:43 +0200 | [diff] [blame] | 816 | return( test_transparent_cipher_finish( operation->ctx, |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 817 | output, |
| 818 | output_size, |
| 819 | output_length ) ); |
| 820 | #endif /* PSA_CRYPTO_DRIVER_TEST */ |
| 821 | #if defined(PSA_CRYPTO_DRIVER_TEST) |
| 822 | case PSA_CRYPTO_OPAQUE_TEST_DRIVER_ID: |
Steven Cooreman | fb81aa5 | 2020-09-09 12:01:43 +0200 | [diff] [blame] | 823 | return( test_opaque_cipher_finish( operation->ctx, |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 824 | output, |
| 825 | output_size, |
| 826 | output_length ) ); |
| 827 | #endif /* PSA_CRYPTO_DRIVER_TEST */ |
| 828 | default: |
| 829 | /* Key is attached to a driver not known to us */ |
Steven Cooreman | 5240e8b | 2020-09-09 11:51:45 +0200 | [diff] [blame] | 830 | return( PSA_ERROR_BAD_STATE ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 831 | } |
| 832 | #else /* PSA_CRYPTO_DRIVER_PRESENT */ |
| 833 | (void) operation; |
| 834 | (void) output; |
| 835 | (void) output_size; |
| 836 | (void) output_length; |
| 837 | |
Steven Cooreman | 5240e8b | 2020-09-09 11:51:45 +0200 | [diff] [blame] | 838 | return( PSA_ERROR_NOT_SUPPORTED ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 839 | #endif /* PSA_CRYPTO_DRIVER_PRESENT */ |
| 840 | } |
| 841 | |
| 842 | psa_status_t psa_driver_wrapper_cipher_abort( |
Steven Cooreman | fb81aa5 | 2020-09-09 12:01:43 +0200 | [diff] [blame] | 843 | psa_operation_driver_context_t *operation ) |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 844 | { |
| 845 | #if defined(PSA_CRYPTO_DRIVER_PRESENT) && defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT) |
| 846 | psa_status_t status = PSA_ERROR_INVALID_ARGUMENT; |
| 847 | /* Check for operation already allocated */ |
Steven Cooreman | fb81aa5 | 2020-09-09 12:01:43 +0200 | [diff] [blame] | 848 | if( operation->ctx == NULL ) |
Steven Cooreman | 5240e8b | 2020-09-09 11:51:45 +0200 | [diff] [blame] | 849 | return( PSA_ERROR_INVALID_ARGUMENT ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 850 | |
Steven Cooreman | fb81aa5 | 2020-09-09 12:01:43 +0200 | [diff] [blame] | 851 | switch( operation->id ) |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 852 | { |
| 853 | #if defined(PSA_CRYPTO_DRIVER_TEST) |
| 854 | case PSA_CRYPTO_TRANSPARENT_TEST_DRIVER_ID: |
Steven Cooreman | fb81aa5 | 2020-09-09 12:01:43 +0200 | [diff] [blame] | 855 | status = test_transparent_cipher_abort( operation->ctx ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 856 | |
Steven Cooreman | fb81aa5 | 2020-09-09 12:01:43 +0200 | [diff] [blame] | 857 | mbedtls_free( operation->ctx ); |
| 858 | operation->ctx = NULL; |
| 859 | operation->id = 0; |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 860 | |
Steven Cooreman | 5240e8b | 2020-09-09 11:51:45 +0200 | [diff] [blame] | 861 | return( status ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 862 | #endif /* PSA_CRYPTO_DRIVER_TEST */ |
| 863 | #if defined(PSA_CRYPTO_DRIVER_TEST) |
| 864 | case PSA_CRYPTO_OPAQUE_TEST_DRIVER_ID: |
Steven Cooreman | fb81aa5 | 2020-09-09 12:01:43 +0200 | [diff] [blame] | 865 | status = test_opaque_cipher_abort( operation->ctx ); |
| 866 | mbedtls_free( operation->ctx ); |
| 867 | operation->ctx = NULL; |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 868 | |
Steven Cooreman | 5240e8b | 2020-09-09 11:51:45 +0200 | [diff] [blame] | 869 | return( status ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 870 | #endif /* PSA_CRYPTO_DRIVER_TEST */ |
| 871 | default: |
| 872 | /* Operation is attached to a driver not known to us */ |
Steven Cooreman | 5240e8b | 2020-09-09 11:51:45 +0200 | [diff] [blame] | 873 | return( PSA_ERROR_BAD_STATE ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 874 | } |
| 875 | #else /* PSA_CRYPTO_DRIVER_PRESENT */ |
| 876 | (void)operation; |
| 877 | |
Steven Cooreman | 5240e8b | 2020-09-09 11:51:45 +0200 | [diff] [blame] | 878 | return( PSA_ERROR_NOT_SUPPORTED ); |
Steven Cooreman | 37941cb | 2020-07-28 18:49:51 +0200 | [diff] [blame] | 879 | #endif /* PSA_CRYPTO_DRIVER_PRESENT */ |
| 880 | } |
| 881 | |
Steven Cooreman | cd84cb4 | 2020-07-16 20:28:36 +0200 | [diff] [blame] | 882 | /* End of automatically generated file. */ |