Revert "Auto-generated files for v3.5.0"
This reverts commit 591416f32b7a6472aa988c5106edbf334e228d2e.
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
diff --git a/library/.gitignore b/library/.gitignore
index ba2784d..c6a39f5 100644
--- a/library/.gitignore
+++ b/library/.gitignore
@@ -2,10 +2,10 @@
*.sln
*.vcxproj
-# ###START_COMMENTED_GENERATED_FILES###
-# /error.c
-# /version_features.c
-# /ssl_debug_helpers_generated.c
-# /psa_crypto_driver_wrappers.h
-# /psa_crypto_driver_wrappers_no_static.c
-# ###END_COMMENTED_GENERATED_FILES###
+###START_GENERATED_FILES###
+/error.c
+/version_features.c
+/ssl_debug_helpers_generated.c
+/psa_crypto_driver_wrappers.h
+/psa_crypto_driver_wrappers_no_static.c
+###END_GENERATED_FILES###
diff --git a/library/Makefile b/library/Makefile
index 8e94f73..9e2d723 100644
--- a/library/Makefile
+++ b/library/Makefile
@@ -321,7 +321,7 @@
generated_files: $(GENERATED_FILES)
# See root Makefile
-GEN_FILES ?=
+GEN_FILES ?= yes
ifdef GEN_FILES
gen_file_dep =
else
diff --git a/library/error.c b/library/error.c
deleted file mode 100644
index 2656e13..0000000
--- a/library/error.c
+++ /dev/null
@@ -1,890 +0,0 @@
-/*
- * Error message information
- *
- * Copyright The Mbed TLS Contributors
- * SPDX-License-Identifier: Apache-2.0
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may
- * not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "common.h"
-
-#include "mbedtls/error.h"
-
-#if defined(MBEDTLS_ERROR_C) || defined(MBEDTLS_ERROR_STRERROR_DUMMY)
-
-#if defined(MBEDTLS_ERROR_C)
-
-#include "mbedtls/platform.h"
-
-#include <stdio.h>
-#include <string.h>
-
-#if defined(MBEDTLS_AES_C)
-#include "mbedtls/aes.h"
-#endif
-
-#if defined(MBEDTLS_ARIA_C)
-#include "mbedtls/aria.h"
-#endif
-
-#if defined(MBEDTLS_ASN1_PARSE_C)
-#include "mbedtls/asn1.h"
-#endif
-
-#if defined(MBEDTLS_BASE64_C)
-#include "mbedtls/base64.h"
-#endif
-
-#if defined(MBEDTLS_BIGNUM_C)
-#include "mbedtls/bignum.h"
-#endif
-
-#if defined(MBEDTLS_CAMELLIA_C)
-#include "mbedtls/camellia.h"
-#endif
-
-#if defined(MBEDTLS_CCM_C)
-#include "mbedtls/ccm.h"
-#endif
-
-#if defined(MBEDTLS_CHACHA20_C)
-#include "mbedtls/chacha20.h"
-#endif
-
-#if defined(MBEDTLS_CHACHAPOLY_C)
-#include "mbedtls/chachapoly.h"
-#endif
-
-#if defined(MBEDTLS_CIPHER_C)
-#include "mbedtls/cipher.h"
-#endif
-
-#if defined(MBEDTLS_CTR_DRBG_C)
-#include "mbedtls/ctr_drbg.h"
-#endif
-
-#if defined(MBEDTLS_DES_C)
-#include "mbedtls/des.h"
-#endif
-
-#if defined(MBEDTLS_DHM_C)
-#include "mbedtls/dhm.h"
-#endif
-
-#if defined(MBEDTLS_ECP_C)
-#include "mbedtls/ecp.h"
-#endif
-
-#if defined(MBEDTLS_ENTROPY_C)
-#include "mbedtls/entropy.h"
-#endif
-
-#if defined(MBEDTLS_ERROR_C)
-#include "mbedtls/error.h"
-#endif
-
-#if defined(MBEDTLS_PLATFORM_C)
-#include "mbedtls/platform.h"
-#endif
-
-#if defined(MBEDTLS_GCM_C)
-#include "mbedtls/gcm.h"
-#endif
-
-#if defined(MBEDTLS_HKDF_C)
-#include "mbedtls/hkdf.h"
-#endif
-
-#if defined(MBEDTLS_HMAC_DRBG_C)
-#include "mbedtls/hmac_drbg.h"
-#endif
-
-#if defined(MBEDTLS_LMS_C)
-#include "mbedtls/lms.h"
-#endif
-
-#if defined(MBEDTLS_MD_C)
-#include "mbedtls/md.h"
-#endif
-
-#if defined(MBEDTLS_NET_C)
-#include "mbedtls/net_sockets.h"
-#endif
-
-#if defined(MBEDTLS_OID_C)
-#include "mbedtls/oid.h"
-#endif
-
-#if defined(MBEDTLS_PEM_PARSE_C) || defined(MBEDTLS_PEM_WRITE_C)
-#include "mbedtls/pem.h"
-#endif
-
-#if defined(MBEDTLS_PK_C)
-#include "mbedtls/pk.h"
-#endif
-
-#if defined(MBEDTLS_PKCS12_C)
-#include "mbedtls/pkcs12.h"
-#endif
-
-#if defined(MBEDTLS_PKCS5_C)
-#include "mbedtls/pkcs5.h"
-#endif
-
-#if defined(MBEDTLS_PKCS7_C)
-#include "mbedtls/pkcs7.h"
-#endif
-
-#if defined(MBEDTLS_POLY1305_C)
-#include "mbedtls/poly1305.h"
-#endif
-
-#if defined(MBEDTLS_RSA_C)
-#include "mbedtls/rsa.h"
-#endif
-
-#if defined(MBEDTLS_SHA1_C)
-#include "mbedtls/sha1.h"
-#endif
-
-#if defined(MBEDTLS_SHA256_C)
-#include "mbedtls/sha256.h"
-#endif
-
-#if defined(MBEDTLS_SHA3_C)
-#include "mbedtls/sha3.h"
-#endif
-
-#if defined(MBEDTLS_SHA512_C)
-#include "mbedtls/sha512.h"
-#endif
-
-#if defined(MBEDTLS_SSL_TLS_C)
-#include "mbedtls/ssl.h"
-#endif
-
-#if defined(MBEDTLS_THREADING_C)
-#include "mbedtls/threading.h"
-#endif
-
-#if defined(MBEDTLS_X509_USE_C) || defined(MBEDTLS_X509_CREATE_C)
-#include "mbedtls/x509.h"
-#endif
-
-
-const char *mbedtls_high_level_strerr(int error_code)
-{
- int high_level_error_code;
-
- if (error_code < 0) {
- error_code = -error_code;
- }
-
- /* Extract the high-level part from the error code. */
- high_level_error_code = error_code & 0xFF80;
-
- switch (high_level_error_code) {
- /* Begin Auto-Generated Code. */
- #if defined(MBEDTLS_CIPHER_C)
- case -(MBEDTLS_ERR_CIPHER_FEATURE_UNAVAILABLE):
- return( "CIPHER - The selected feature is not available" );
- case -(MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA):
- return( "CIPHER - Bad input parameters" );
- case -(MBEDTLS_ERR_CIPHER_ALLOC_FAILED):
- return( "CIPHER - Failed to allocate memory" );
- case -(MBEDTLS_ERR_CIPHER_INVALID_PADDING):
- return( "CIPHER - Input data contains invalid padding and is rejected" );
- case -(MBEDTLS_ERR_CIPHER_FULL_BLOCK_EXPECTED):
- return( "CIPHER - Decryption of block requires a full block" );
- case -(MBEDTLS_ERR_CIPHER_AUTH_FAILED):
- return( "CIPHER - Authentication failed (for AEAD modes)" );
- case -(MBEDTLS_ERR_CIPHER_INVALID_CONTEXT):
- return( "CIPHER - The context is invalid. For example, because it was freed" );
-#endif /* MBEDTLS_CIPHER_C */
-
-#if defined(MBEDTLS_DHM_C)
- case -(MBEDTLS_ERR_DHM_BAD_INPUT_DATA):
- return( "DHM - Bad input parameters" );
- case -(MBEDTLS_ERR_DHM_READ_PARAMS_FAILED):
- return( "DHM - Reading of the DHM parameters failed" );
- case -(MBEDTLS_ERR_DHM_MAKE_PARAMS_FAILED):
- return( "DHM - Making of the DHM parameters failed" );
- case -(MBEDTLS_ERR_DHM_READ_PUBLIC_FAILED):
- return( "DHM - Reading of the public values failed" );
- case -(MBEDTLS_ERR_DHM_MAKE_PUBLIC_FAILED):
- return( "DHM - Making of the public value failed" );
- case -(MBEDTLS_ERR_DHM_CALC_SECRET_FAILED):
- return( "DHM - Calculation of the DHM secret failed" );
- case -(MBEDTLS_ERR_DHM_INVALID_FORMAT):
- return( "DHM - The ASN.1 data is not formatted correctly" );
- case -(MBEDTLS_ERR_DHM_ALLOC_FAILED):
- return( "DHM - Allocation of memory failed" );
- case -(MBEDTLS_ERR_DHM_FILE_IO_ERROR):
- return( "DHM - Read or write of file failed" );
- case -(MBEDTLS_ERR_DHM_SET_GROUP_FAILED):
- return( "DHM - Setting the modulus and generator failed" );
-#endif /* MBEDTLS_DHM_C */
-
-#if defined(MBEDTLS_ECP_C)
- case -(MBEDTLS_ERR_ECP_BAD_INPUT_DATA):
- return( "ECP - Bad input parameters to function" );
- case -(MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL):
- return( "ECP - The buffer is too small to write to" );
- case -(MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE):
- return( "ECP - The requested feature is not available, for example, the requested curve is not supported" );
- case -(MBEDTLS_ERR_ECP_VERIFY_FAILED):
- return( "ECP - The signature is not valid" );
- case -(MBEDTLS_ERR_ECP_ALLOC_FAILED):
- return( "ECP - Memory allocation failed" );
- case -(MBEDTLS_ERR_ECP_RANDOM_FAILED):
- return( "ECP - Generation of random value, such as ephemeral key, failed" );
- case -(MBEDTLS_ERR_ECP_INVALID_KEY):
- return( "ECP - Invalid private or public key" );
- case -(MBEDTLS_ERR_ECP_SIG_LEN_MISMATCH):
- return( "ECP - The buffer contains a valid signature followed by more data" );
- case -(MBEDTLS_ERR_ECP_IN_PROGRESS):
- return( "ECP - Operation in progress, call again with the same parameters to continue" );
-#endif /* MBEDTLS_ECP_C */
-
-#if defined(MBEDTLS_MD_C)
- case -(MBEDTLS_ERR_MD_FEATURE_UNAVAILABLE):
- return( "MD - The selected feature is not available" );
- case -(MBEDTLS_ERR_MD_BAD_INPUT_DATA):
- return( "MD - Bad input parameters to function" );
- case -(MBEDTLS_ERR_MD_ALLOC_FAILED):
- return( "MD - Failed to allocate memory" );
- case -(MBEDTLS_ERR_MD_FILE_IO_ERROR):
- return( "MD - Opening or reading of file failed" );
-#endif /* MBEDTLS_MD_C */
-
-#if defined(MBEDTLS_PEM_PARSE_C) || defined(MBEDTLS_PEM_WRITE_C)
- case -(MBEDTLS_ERR_PEM_NO_HEADER_FOOTER_PRESENT):
- return( "PEM - No PEM header or footer found" );
- case -(MBEDTLS_ERR_PEM_INVALID_DATA):
- return( "PEM - PEM string is not as expected" );
- case -(MBEDTLS_ERR_PEM_ALLOC_FAILED):
- return( "PEM - Failed to allocate memory" );
- case -(MBEDTLS_ERR_PEM_INVALID_ENC_IV):
- return( "PEM - RSA IV is not in hex-format" );
- case -(MBEDTLS_ERR_PEM_UNKNOWN_ENC_ALG):
- return( "PEM - Unsupported key encryption algorithm" );
- case -(MBEDTLS_ERR_PEM_PASSWORD_REQUIRED):
- return( "PEM - Private key password can't be empty" );
- case -(MBEDTLS_ERR_PEM_PASSWORD_MISMATCH):
- return( "PEM - Given private key password does not allow for correct decryption" );
- case -(MBEDTLS_ERR_PEM_FEATURE_UNAVAILABLE):
- return( "PEM - Unavailable feature, e.g. hashing/encryption combination" );
- case -(MBEDTLS_ERR_PEM_BAD_INPUT_DATA):
- return( "PEM - Bad input parameters to function" );
-#endif /* MBEDTLS_PEM_PARSE_C || MBEDTLS_PEM_WRITE_C */
-
-#if defined(MBEDTLS_PK_C)
- case -(MBEDTLS_ERR_PK_ALLOC_FAILED):
- return( "PK - Memory allocation failed" );
- case -(MBEDTLS_ERR_PK_TYPE_MISMATCH):
- return( "PK - Type mismatch, eg attempt to encrypt with an ECDSA key" );
- case -(MBEDTLS_ERR_PK_BAD_INPUT_DATA):
- return( "PK - Bad input parameters to function" );
- case -(MBEDTLS_ERR_PK_FILE_IO_ERROR):
- return( "PK - Read/write of file failed" );
- case -(MBEDTLS_ERR_PK_KEY_INVALID_VERSION):
- return( "PK - Unsupported key version" );
- case -(MBEDTLS_ERR_PK_KEY_INVALID_FORMAT):
- return( "PK - Invalid key tag or value" );
- case -(MBEDTLS_ERR_PK_UNKNOWN_PK_ALG):
- return( "PK - Key algorithm is unsupported (only RSA and EC are supported)" );
- case -(MBEDTLS_ERR_PK_PASSWORD_REQUIRED):
- return( "PK - Private key password can't be empty" );
- case -(MBEDTLS_ERR_PK_PASSWORD_MISMATCH):
- return( "PK - Given private key password does not allow for correct decryption" );
- case -(MBEDTLS_ERR_PK_INVALID_PUBKEY):
- return( "PK - The pubkey tag or value is invalid (only RSA and EC are supported)" );
- case -(MBEDTLS_ERR_PK_INVALID_ALG):
- return( "PK - The algorithm tag or value is invalid" );
- case -(MBEDTLS_ERR_PK_UNKNOWN_NAMED_CURVE):
- return( "PK - Elliptic curve is unsupported (only NIST curves are supported)" );
- case -(MBEDTLS_ERR_PK_FEATURE_UNAVAILABLE):
- return( "PK - Unavailable feature, e.g. RSA disabled for RSA key" );
- case -(MBEDTLS_ERR_PK_SIG_LEN_MISMATCH):
- return( "PK - The buffer contains a valid signature followed by more data" );
- case -(MBEDTLS_ERR_PK_BUFFER_TOO_SMALL):
- return( "PK - The output buffer is too small" );
-#endif /* MBEDTLS_PK_C */
-
-#if defined(MBEDTLS_PKCS12_C)
- case -(MBEDTLS_ERR_PKCS12_BAD_INPUT_DATA):
- return( "PKCS12 - Bad input parameters to function" );
- case -(MBEDTLS_ERR_PKCS12_FEATURE_UNAVAILABLE):
- return( "PKCS12 - Feature not available, e.g. unsupported encryption scheme" );
- case -(MBEDTLS_ERR_PKCS12_PBE_INVALID_FORMAT):
- return( "PKCS12 - PBE ASN.1 data not as expected" );
- case -(MBEDTLS_ERR_PKCS12_PASSWORD_MISMATCH):
- return( "PKCS12 - Given private key password does not allow for correct decryption" );
-#endif /* MBEDTLS_PKCS12_C */
-
-#if defined(MBEDTLS_PKCS5_C)
- case -(MBEDTLS_ERR_PKCS5_BAD_INPUT_DATA):
- return( "PKCS5 - Bad input parameters to function" );
- case -(MBEDTLS_ERR_PKCS5_INVALID_FORMAT):
- return( "PKCS5 - Unexpected ASN.1 data" );
- case -(MBEDTLS_ERR_PKCS5_FEATURE_UNAVAILABLE):
- return( "PKCS5 - Requested encryption or digest alg not available" );
- case -(MBEDTLS_ERR_PKCS5_PASSWORD_MISMATCH):
- return( "PKCS5 - Given private key password does not allow for correct decryption" );
-#endif /* MBEDTLS_PKCS5_C */
-
-#if defined(MBEDTLS_PKCS7_C)
- case -(MBEDTLS_ERR_PKCS7_INVALID_FORMAT):
- return( "PKCS7 - The format is invalid, e.g. different type expected" );
- case -(MBEDTLS_ERR_PKCS7_FEATURE_UNAVAILABLE):
- return( "PKCS7 - Unavailable feature, e.g. anything other than signed data" );
- case -(MBEDTLS_ERR_PKCS7_INVALID_VERSION):
- return( "PKCS7 - The PKCS #7 version element is invalid or cannot be parsed" );
- case -(MBEDTLS_ERR_PKCS7_INVALID_CONTENT_INFO):
- return( "PKCS7 - The PKCS #7 content info is invalid or cannot be parsed" );
- case -(MBEDTLS_ERR_PKCS7_INVALID_ALG):
- return( "PKCS7 - The algorithm tag or value is invalid or cannot be parsed" );
- case -(MBEDTLS_ERR_PKCS7_INVALID_CERT):
- return( "PKCS7 - The certificate tag or value is invalid or cannot be parsed" );
- case -(MBEDTLS_ERR_PKCS7_INVALID_SIGNATURE):
- return( "PKCS7 - Error parsing the signature" );
- case -(MBEDTLS_ERR_PKCS7_INVALID_SIGNER_INFO):
- return( "PKCS7 - Error parsing the signer's info" );
- case -(MBEDTLS_ERR_PKCS7_BAD_INPUT_DATA):
- return( "PKCS7 - Input invalid" );
- case -(MBEDTLS_ERR_PKCS7_ALLOC_FAILED):
- return( "PKCS7 - Allocation of memory failed" );
- case -(MBEDTLS_ERR_PKCS7_VERIFY_FAIL):
- return( "PKCS7 - Verification Failed" );
- case -(MBEDTLS_ERR_PKCS7_CERT_DATE_INVALID):
- return( "PKCS7 - The PKCS #7 date issued/expired dates are invalid" );
-#endif /* MBEDTLS_PKCS7_C */
-
-#if defined(MBEDTLS_RSA_C)
- case -(MBEDTLS_ERR_RSA_BAD_INPUT_DATA):
- return( "RSA - Bad input parameters to function" );
- case -(MBEDTLS_ERR_RSA_INVALID_PADDING):
- return( "RSA - Input data contains invalid padding and is rejected" );
- case -(MBEDTLS_ERR_RSA_KEY_GEN_FAILED):
- return( "RSA - Something failed during generation of a key" );
- case -(MBEDTLS_ERR_RSA_KEY_CHECK_FAILED):
- return( "RSA - Key failed to pass the validity check of the library" );
- case -(MBEDTLS_ERR_RSA_PUBLIC_FAILED):
- return( "RSA - The public key operation failed" );
- case -(MBEDTLS_ERR_RSA_PRIVATE_FAILED):
- return( "RSA - The private key operation failed" );
- case -(MBEDTLS_ERR_RSA_VERIFY_FAILED):
- return( "RSA - The PKCS#1 verification failed" );
- case -(MBEDTLS_ERR_RSA_OUTPUT_TOO_LARGE):
- return( "RSA - The output buffer for decryption is not large enough" );
- case -(MBEDTLS_ERR_RSA_RNG_FAILED):
- return( "RSA - The random generator failed to generate non-zeros" );
-#endif /* MBEDTLS_RSA_C */
-
-#if defined(MBEDTLS_SSL_TLS_C)
- case -(MBEDTLS_ERR_SSL_CRYPTO_IN_PROGRESS):
- return( "SSL - A cryptographic operation is in progress. Try again later" );
- case -(MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE):
- return( "SSL - The requested feature is not available" );
- case -(MBEDTLS_ERR_SSL_BAD_INPUT_DATA):
- return( "SSL - Bad input parameters to function" );
- case -(MBEDTLS_ERR_SSL_INVALID_MAC):
- return( "SSL - Verification of the message MAC failed" );
- case -(MBEDTLS_ERR_SSL_INVALID_RECORD):
- return( "SSL - An invalid SSL record was received" );
- case -(MBEDTLS_ERR_SSL_CONN_EOF):
- return( "SSL - The connection indicated an EOF" );
- case -(MBEDTLS_ERR_SSL_DECODE_ERROR):
- return( "SSL - A message could not be parsed due to a syntactic error" );
- case -(MBEDTLS_ERR_SSL_NO_RNG):
- return( "SSL - No RNG was provided to the SSL module" );
- case -(MBEDTLS_ERR_SSL_NO_CLIENT_CERTIFICATE):
- return( "SSL - No client certification received from the client, but required by the authentication mode" );
- case -(MBEDTLS_ERR_SSL_UNSUPPORTED_EXTENSION):
- return( "SSL - Client received an extended server hello containing an unsupported extension" );
- case -(MBEDTLS_ERR_SSL_NO_APPLICATION_PROTOCOL):
- return( "SSL - No ALPN protocols supported that the client advertises" );
- case -(MBEDTLS_ERR_SSL_PRIVATE_KEY_REQUIRED):
- return( "SSL - The own private key or pre-shared key is not set, but needed" );
- case -(MBEDTLS_ERR_SSL_CA_CHAIN_REQUIRED):
- return( "SSL - No CA Chain is set, but required to operate" );
- case -(MBEDTLS_ERR_SSL_UNEXPECTED_MESSAGE):
- return( "SSL - An unexpected message was received from our peer" );
- case -(MBEDTLS_ERR_SSL_FATAL_ALERT_MESSAGE):
- return( "SSL - A fatal alert message was received from our peer" );
- case -(MBEDTLS_ERR_SSL_UNRECOGNIZED_NAME):
- return( "SSL - No server could be identified matching the client's SNI" );
- case -(MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY):
- return( "SSL - The peer notified us that the connection is going to be closed" );
- case -(MBEDTLS_ERR_SSL_BAD_CERTIFICATE):
- return( "SSL - Processing of the Certificate handshake message failed" );
- case -(MBEDTLS_ERR_SSL_RECEIVED_NEW_SESSION_TICKET):
- return( "SSL - * Received NewSessionTicket Post Handshake Message. This error code is experimental and may be changed or removed without notice" );
- case -(MBEDTLS_ERR_SSL_CANNOT_READ_EARLY_DATA):
- return( "SSL - Not possible to read early data" );
- case -(MBEDTLS_ERR_SSL_CANNOT_WRITE_EARLY_DATA):
- return( "SSL - Not possible to write early data" );
- case -(MBEDTLS_ERR_SSL_CACHE_ENTRY_NOT_FOUND):
- return( "SSL - Cache entry not found" );
- case -(MBEDTLS_ERR_SSL_ALLOC_FAILED):
- return( "SSL - Memory allocation failed" );
- case -(MBEDTLS_ERR_SSL_HW_ACCEL_FAILED):
- return( "SSL - Hardware acceleration function returned with error" );
- case -(MBEDTLS_ERR_SSL_HW_ACCEL_FALLTHROUGH):
- return( "SSL - Hardware acceleration function skipped / left alone data" );
- case -(MBEDTLS_ERR_SSL_BAD_PROTOCOL_VERSION):
- return( "SSL - Handshake protocol not within min/max boundaries" );
- case -(MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE):
- return( "SSL - The handshake negotiation failed" );
- case -(MBEDTLS_ERR_SSL_SESSION_TICKET_EXPIRED):
- return( "SSL - Session ticket has expired" );
- case -(MBEDTLS_ERR_SSL_PK_TYPE_MISMATCH):
- return( "SSL - Public key type mismatch (eg, asked for RSA key exchange and presented EC key)" );
- case -(MBEDTLS_ERR_SSL_UNKNOWN_IDENTITY):
- return( "SSL - Unknown identity received (eg, PSK identity)" );
- case -(MBEDTLS_ERR_SSL_INTERNAL_ERROR):
- return( "SSL - Internal error (eg, unexpected failure in lower-level module)" );
- case -(MBEDTLS_ERR_SSL_COUNTER_WRAPPING):
- return( "SSL - A counter would wrap (eg, too many messages exchanged)" );
- case -(MBEDTLS_ERR_SSL_WAITING_SERVER_HELLO_RENEGO):
- return( "SSL - Unexpected message at ServerHello in renegotiation" );
- case -(MBEDTLS_ERR_SSL_HELLO_VERIFY_REQUIRED):
- return( "SSL - DTLS client must retry for hello verification" );
- case -(MBEDTLS_ERR_SSL_BUFFER_TOO_SMALL):
- return( "SSL - A buffer is too small to receive or write a message" );
- case -(MBEDTLS_ERR_SSL_WANT_READ):
- return( "SSL - No data of requested type currently available on underlying transport" );
- case -(MBEDTLS_ERR_SSL_WANT_WRITE):
- return( "SSL - Connection requires a write call" );
- case -(MBEDTLS_ERR_SSL_TIMEOUT):
- return( "SSL - The operation timed out" );
- case -(MBEDTLS_ERR_SSL_CLIENT_RECONNECT):
- return( "SSL - The client initiated a reconnect from the same port" );
- case -(MBEDTLS_ERR_SSL_UNEXPECTED_RECORD):
- return( "SSL - Record header looks valid but is not expected" );
- case -(MBEDTLS_ERR_SSL_NON_FATAL):
- return( "SSL - The alert message received indicates a non-fatal error" );
- case -(MBEDTLS_ERR_SSL_ILLEGAL_PARAMETER):
- return( "SSL - A field in a message was incorrect or inconsistent with other fields" );
- case -(MBEDTLS_ERR_SSL_CONTINUE_PROCESSING):
- return( "SSL - Internal-only message signaling that further message-processing should be done" );
- case -(MBEDTLS_ERR_SSL_ASYNC_IN_PROGRESS):
- return( "SSL - The asynchronous operation is not completed yet" );
- case -(MBEDTLS_ERR_SSL_EARLY_MESSAGE):
- return( "SSL - Internal-only message signaling that a message arrived early" );
- case -(MBEDTLS_ERR_SSL_UNEXPECTED_CID):
- return( "SSL - An encrypted DTLS-frame with an unexpected CID was received" );
- case -(MBEDTLS_ERR_SSL_VERSION_MISMATCH):
- return( "SSL - An operation failed due to an unexpected version or configuration" );
- case -(MBEDTLS_ERR_SSL_BAD_CONFIG):
- return( "SSL - Invalid value in SSL config" );
-#endif /* MBEDTLS_SSL_TLS_C */
-
-#if defined(MBEDTLS_X509_USE_C) || defined(MBEDTLS_X509_CREATE_C)
- case -(MBEDTLS_ERR_X509_FEATURE_UNAVAILABLE):
- return( "X509 - Unavailable feature, e.g. RSA hashing/encryption combination" );
- case -(MBEDTLS_ERR_X509_UNKNOWN_OID):
- return( "X509 - Requested OID is unknown" );
- case -(MBEDTLS_ERR_X509_INVALID_FORMAT):
- return( "X509 - The CRT/CRL/CSR format is invalid, e.g. different type expected" );
- case -(MBEDTLS_ERR_X509_INVALID_VERSION):
- return( "X509 - The CRT/CRL/CSR version element is invalid" );
- case -(MBEDTLS_ERR_X509_INVALID_SERIAL):
- return( "X509 - The serial tag or value is invalid" );
- case -(MBEDTLS_ERR_X509_INVALID_ALG):
- return( "X509 - The algorithm tag or value is invalid" );
- case -(MBEDTLS_ERR_X509_INVALID_NAME):
- return( "X509 - The name tag or value is invalid" );
- case -(MBEDTLS_ERR_X509_INVALID_DATE):
- return( "X509 - The date tag or value is invalid" );
- case -(MBEDTLS_ERR_X509_INVALID_SIGNATURE):
- return( "X509 - The signature tag or value invalid" );
- case -(MBEDTLS_ERR_X509_INVALID_EXTENSIONS):
- return( "X509 - The extension tag or value is invalid" );
- case -(MBEDTLS_ERR_X509_UNKNOWN_VERSION):
- return( "X509 - CRT/CRL/CSR has an unsupported version number" );
- case -(MBEDTLS_ERR_X509_UNKNOWN_SIG_ALG):
- return( "X509 - Signature algorithm (oid) is unsupported" );
- case -(MBEDTLS_ERR_X509_SIG_MISMATCH):
- return( "X509 - Signature algorithms do not match. (see \\c ::mbedtls_x509_crt sig_oid)" );
- case -(MBEDTLS_ERR_X509_CERT_VERIFY_FAILED):
- return( "X509 - Certificate verification failed, e.g. CRL, CA or signature check failed" );
- case -(MBEDTLS_ERR_X509_CERT_UNKNOWN_FORMAT):
- return( "X509 - Format not recognized as DER or PEM" );
- case -(MBEDTLS_ERR_X509_BAD_INPUT_DATA):
- return( "X509 - Input invalid" );
- case -(MBEDTLS_ERR_X509_ALLOC_FAILED):
- return( "X509 - Allocation of memory failed" );
- case -(MBEDTLS_ERR_X509_FILE_IO_ERROR):
- return( "X509 - Read/write of file failed" );
- case -(MBEDTLS_ERR_X509_BUFFER_TOO_SMALL):
- return( "X509 - Destination buffer is too small" );
- case -(MBEDTLS_ERR_X509_FATAL_ERROR):
- return( "X509 - A fatal error occurred, eg the chain is too long or the vrfy callback failed" );
-#endif /* MBEDTLS_X509_USE_C || MBEDTLS_X509_CREATE_C */
- /* End Auto-Generated Code. */
-
- default:
- break;
- }
-
- return NULL;
-}
-
-const char *mbedtls_low_level_strerr(int error_code)
-{
- int low_level_error_code;
-
- if (error_code < 0) {
- error_code = -error_code;
- }
-
- /* Extract the low-level part from the error code. */
- low_level_error_code = error_code & ~0xFF80;
-
- switch (low_level_error_code) {
- /* Begin Auto-Generated Code. */
- #if defined(MBEDTLS_AES_C)
- case -(MBEDTLS_ERR_AES_INVALID_KEY_LENGTH):
- return( "AES - Invalid key length" );
- case -(MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH):
- return( "AES - Invalid data input length" );
- case -(MBEDTLS_ERR_AES_BAD_INPUT_DATA):
- return( "AES - Invalid input data" );
-#endif /* MBEDTLS_AES_C */
-
-#if defined(MBEDTLS_ARIA_C)
- case -(MBEDTLS_ERR_ARIA_BAD_INPUT_DATA):
- return( "ARIA - Bad input data" );
- case -(MBEDTLS_ERR_ARIA_INVALID_INPUT_LENGTH):
- return( "ARIA - Invalid data input length" );
-#endif /* MBEDTLS_ARIA_C */
-
-#if defined(MBEDTLS_ASN1_PARSE_C)
- case -(MBEDTLS_ERR_ASN1_OUT_OF_DATA):
- return( "ASN1 - Out of data when parsing an ASN1 data structure" );
- case -(MBEDTLS_ERR_ASN1_UNEXPECTED_TAG):
- return( "ASN1 - ASN1 tag was of an unexpected value" );
- case -(MBEDTLS_ERR_ASN1_INVALID_LENGTH):
- return( "ASN1 - Error when trying to determine the length or invalid length" );
- case -(MBEDTLS_ERR_ASN1_LENGTH_MISMATCH):
- return( "ASN1 - Actual length differs from expected length" );
- case -(MBEDTLS_ERR_ASN1_INVALID_DATA):
- return( "ASN1 - Data is invalid" );
- case -(MBEDTLS_ERR_ASN1_ALLOC_FAILED):
- return( "ASN1 - Memory allocation failed" );
- case -(MBEDTLS_ERR_ASN1_BUF_TOO_SMALL):
- return( "ASN1 - Buffer too small when writing ASN.1 data structure" );
-#endif /* MBEDTLS_ASN1_PARSE_C */
-
-#if defined(MBEDTLS_BASE64_C)
- case -(MBEDTLS_ERR_BASE64_BUFFER_TOO_SMALL):
- return( "BASE64 - Output buffer too small" );
- case -(MBEDTLS_ERR_BASE64_INVALID_CHARACTER):
- return( "BASE64 - Invalid character in input" );
-#endif /* MBEDTLS_BASE64_C */
-
-#if defined(MBEDTLS_BIGNUM_C)
- case -(MBEDTLS_ERR_MPI_FILE_IO_ERROR):
- return( "BIGNUM - An error occurred while reading from or writing to a file" );
- case -(MBEDTLS_ERR_MPI_BAD_INPUT_DATA):
- return( "BIGNUM - Bad input parameters to function" );
- case -(MBEDTLS_ERR_MPI_INVALID_CHARACTER):
- return( "BIGNUM - There is an invalid character in the digit string" );
- case -(MBEDTLS_ERR_MPI_BUFFER_TOO_SMALL):
- return( "BIGNUM - The buffer is too small to write to" );
- case -(MBEDTLS_ERR_MPI_NEGATIVE_VALUE):
- return( "BIGNUM - The input arguments are negative or result in illegal output" );
- case -(MBEDTLS_ERR_MPI_DIVISION_BY_ZERO):
- return( "BIGNUM - The input argument for division is zero, which is not allowed" );
- case -(MBEDTLS_ERR_MPI_NOT_ACCEPTABLE):
- return( "BIGNUM - The input arguments are not acceptable" );
- case -(MBEDTLS_ERR_MPI_ALLOC_FAILED):
- return( "BIGNUM - Memory allocation failed" );
-#endif /* MBEDTLS_BIGNUM_C */
-
-#if defined(MBEDTLS_CAMELLIA_C)
- case -(MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA):
- return( "CAMELLIA - Bad input data" );
- case -(MBEDTLS_ERR_CAMELLIA_INVALID_INPUT_LENGTH):
- return( "CAMELLIA - Invalid data input length" );
-#endif /* MBEDTLS_CAMELLIA_C */
-
-#if defined(MBEDTLS_CCM_C)
- case -(MBEDTLS_ERR_CCM_BAD_INPUT):
- return( "CCM - Bad input parameters to the function" );
- case -(MBEDTLS_ERR_CCM_AUTH_FAILED):
- return( "CCM - Authenticated decryption failed" );
-#endif /* MBEDTLS_CCM_C */
-
-#if defined(MBEDTLS_CHACHA20_C)
- case -(MBEDTLS_ERR_CHACHA20_BAD_INPUT_DATA):
- return( "CHACHA20 - Invalid input parameter(s)" );
-#endif /* MBEDTLS_CHACHA20_C */
-
-#if defined(MBEDTLS_CHACHAPOLY_C)
- case -(MBEDTLS_ERR_CHACHAPOLY_BAD_STATE):
- return( "CHACHAPOLY - The requested operation is not permitted in the current state" );
- case -(MBEDTLS_ERR_CHACHAPOLY_AUTH_FAILED):
- return( "CHACHAPOLY - Authenticated decryption failed: data was not authentic" );
-#endif /* MBEDTLS_CHACHAPOLY_C */
-
-#if defined(MBEDTLS_CTR_DRBG_C)
- case -(MBEDTLS_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED):
- return( "CTR_DRBG - The entropy source failed" );
- case -(MBEDTLS_ERR_CTR_DRBG_REQUEST_TOO_BIG):
- return( "CTR_DRBG - The requested random buffer length is too big" );
- case -(MBEDTLS_ERR_CTR_DRBG_INPUT_TOO_BIG):
- return( "CTR_DRBG - The input (entropy + additional data) is too large" );
- case -(MBEDTLS_ERR_CTR_DRBG_FILE_IO_ERROR):
- return( "CTR_DRBG - Read or write error in file" );
-#endif /* MBEDTLS_CTR_DRBG_C */
-
-#if defined(MBEDTLS_DES_C)
- case -(MBEDTLS_ERR_DES_INVALID_INPUT_LENGTH):
- return( "DES - The data input has an invalid length" );
-#endif /* MBEDTLS_DES_C */
-
-#if defined(MBEDTLS_ENTROPY_C)
- case -(MBEDTLS_ERR_ENTROPY_SOURCE_FAILED):
- return( "ENTROPY - Critical entropy source failure" );
- case -(MBEDTLS_ERR_ENTROPY_MAX_SOURCES):
- return( "ENTROPY - No more sources can be added" );
- case -(MBEDTLS_ERR_ENTROPY_NO_SOURCES_DEFINED):
- return( "ENTROPY - No sources have been added to poll" );
- case -(MBEDTLS_ERR_ENTROPY_NO_STRONG_SOURCE):
- return( "ENTROPY - No strong sources have been added to poll" );
- case -(MBEDTLS_ERR_ENTROPY_FILE_IO_ERROR):
- return( "ENTROPY - Read/write error in file" );
-#endif /* MBEDTLS_ENTROPY_C */
-
-#if defined(MBEDTLS_ERROR_C)
- case -(MBEDTLS_ERR_ERROR_GENERIC_ERROR):
- return( "ERROR - Generic error" );
- case -(MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED):
- return( "ERROR - This is a bug in the library" );
-#endif /* MBEDTLS_ERROR_C */
-
-#if defined(MBEDTLS_PLATFORM_C)
- case -(MBEDTLS_ERR_PLATFORM_HW_ACCEL_FAILED):
- return( "PLATFORM - Hardware accelerator failed" );
- case -(MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED):
- return( "PLATFORM - The requested feature is not supported by the platform" );
-#endif /* MBEDTLS_PLATFORM_C */
-
-#if defined(MBEDTLS_GCM_C)
- case -(MBEDTLS_ERR_GCM_AUTH_FAILED):
- return( "GCM - Authenticated decryption failed" );
- case -(MBEDTLS_ERR_GCM_BAD_INPUT):
- return( "GCM - Bad input parameters to function" );
- case -(MBEDTLS_ERR_GCM_BUFFER_TOO_SMALL):
- return( "GCM - An output buffer is too small" );
-#endif /* MBEDTLS_GCM_C */
-
-#if defined(MBEDTLS_HKDF_C)
- case -(MBEDTLS_ERR_HKDF_BAD_INPUT_DATA):
- return( "HKDF - Bad input parameters to function" );
-#endif /* MBEDTLS_HKDF_C */
-
-#if defined(MBEDTLS_HMAC_DRBG_C)
- case -(MBEDTLS_ERR_HMAC_DRBG_REQUEST_TOO_BIG):
- return( "HMAC_DRBG - Too many random requested in single call" );
- case -(MBEDTLS_ERR_HMAC_DRBG_INPUT_TOO_BIG):
- return( "HMAC_DRBG - Input too large (Entropy + additional)" );
- case -(MBEDTLS_ERR_HMAC_DRBG_FILE_IO_ERROR):
- return( "HMAC_DRBG - Read/write error in file" );
- case -(MBEDTLS_ERR_HMAC_DRBG_ENTROPY_SOURCE_FAILED):
- return( "HMAC_DRBG - The entropy source failed" );
-#endif /* MBEDTLS_HMAC_DRBG_C */
-
-#if defined(MBEDTLS_LMS_C)
- case -(MBEDTLS_ERR_LMS_BAD_INPUT_DATA):
- return( "LMS - Bad data has been input to an LMS function" );
- case -(MBEDTLS_ERR_LMS_OUT_OF_PRIVATE_KEYS):
- return( "LMS - Specified LMS key has utilised all of its private keys" );
- case -(MBEDTLS_ERR_LMS_VERIFY_FAILED):
- return( "LMS - LMS signature verification failed" );
- case -(MBEDTLS_ERR_LMS_ALLOC_FAILED):
- return( "LMS - LMS failed to allocate space for a private key" );
- case -(MBEDTLS_ERR_LMS_BUFFER_TOO_SMALL):
- return( "LMS - Input/output buffer is too small to contain requited data" );
-#endif /* MBEDTLS_LMS_C */
-
-#if defined(MBEDTLS_NET_C)
- case -(MBEDTLS_ERR_NET_SOCKET_FAILED):
- return( "NET - Failed to open a socket" );
- case -(MBEDTLS_ERR_NET_CONNECT_FAILED):
- return( "NET - The connection to the given server / port failed" );
- case -(MBEDTLS_ERR_NET_BIND_FAILED):
- return( "NET - Binding of the socket failed" );
- case -(MBEDTLS_ERR_NET_LISTEN_FAILED):
- return( "NET - Could not listen on the socket" );
- case -(MBEDTLS_ERR_NET_ACCEPT_FAILED):
- return( "NET - Could not accept the incoming connection" );
- case -(MBEDTLS_ERR_NET_RECV_FAILED):
- return( "NET - Reading information from the socket failed" );
- case -(MBEDTLS_ERR_NET_SEND_FAILED):
- return( "NET - Sending information through the socket failed" );
- case -(MBEDTLS_ERR_NET_CONN_RESET):
- return( "NET - Connection was reset by peer" );
- case -(MBEDTLS_ERR_NET_UNKNOWN_HOST):
- return( "NET - Failed to get an IP address for the given hostname" );
- case -(MBEDTLS_ERR_NET_BUFFER_TOO_SMALL):
- return( "NET - Buffer is too small to hold the data" );
- case -(MBEDTLS_ERR_NET_INVALID_CONTEXT):
- return( "NET - The context is invalid, eg because it was free()ed" );
- case -(MBEDTLS_ERR_NET_POLL_FAILED):
- return( "NET - Polling the net context failed" );
- case -(MBEDTLS_ERR_NET_BAD_INPUT_DATA):
- return( "NET - Input invalid" );
-#endif /* MBEDTLS_NET_C */
-
-#if defined(MBEDTLS_OID_C)
- case -(MBEDTLS_ERR_OID_NOT_FOUND):
- return( "OID - OID is not found" );
- case -(MBEDTLS_ERR_OID_BUF_TOO_SMALL):
- return( "OID - output buffer is too small" );
-#endif /* MBEDTLS_OID_C */
-
-#if defined(MBEDTLS_POLY1305_C)
- case -(MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA):
- return( "POLY1305 - Invalid input parameter(s)" );
-#endif /* MBEDTLS_POLY1305_C */
-
-#if defined(MBEDTLS_SHA1_C)
- case -(MBEDTLS_ERR_SHA1_BAD_INPUT_DATA):
- return( "SHA1 - SHA-1 input data was malformed" );
-#endif /* MBEDTLS_SHA1_C */
-
-#if defined(MBEDTLS_SHA256_C)
- case -(MBEDTLS_ERR_SHA256_BAD_INPUT_DATA):
- return( "SHA256 - SHA-256 input data was malformed" );
-#endif /* MBEDTLS_SHA256_C */
-
-#if defined(MBEDTLS_SHA3_C)
- case -(MBEDTLS_ERR_SHA3_BAD_INPUT_DATA):
- return( "SHA3 - SHA-3 input data was malformed" );
-#endif /* MBEDTLS_SHA3_C */
-
-#if defined(MBEDTLS_SHA512_C)
- case -(MBEDTLS_ERR_SHA512_BAD_INPUT_DATA):
- return( "SHA512 - SHA-512 input data was malformed" );
-#endif /* MBEDTLS_SHA512_C */
-
-#if defined(MBEDTLS_THREADING_C)
- case -(MBEDTLS_ERR_THREADING_BAD_INPUT_DATA):
- return( "THREADING - Bad input parameters to function" );
- case -(MBEDTLS_ERR_THREADING_MUTEX_ERROR):
- return( "THREADING - Locking / unlocking / free failed with error code" );
-#endif /* MBEDTLS_THREADING_C */
- /* End Auto-Generated Code. */
-
- default:
- break;
- }
-
- return NULL;
-}
-
-void mbedtls_strerror(int ret, char *buf, size_t buflen)
-{
- size_t len;
- int use_ret;
- const char *high_level_error_description = NULL;
- const char *low_level_error_description = NULL;
-
- if (buflen == 0) {
- return;
- }
-
- memset(buf, 0x00, buflen);
-
- if (ret < 0) {
- ret = -ret;
- }
-
- if (ret & 0xFF80) {
- use_ret = ret & 0xFF80;
-
- // Translate high level error code.
- high_level_error_description = mbedtls_high_level_strerr(ret);
-
- if (high_level_error_description == NULL) {
- mbedtls_snprintf(buf, buflen, "UNKNOWN ERROR CODE (%04X)", (unsigned int) use_ret);
- } else {
- mbedtls_snprintf(buf, buflen, "%s", high_level_error_description);
- }
-
-#if defined(MBEDTLS_SSL_TLS_C)
- // Early return in case of a fatal error - do not try to translate low
- // level code.
- if (use_ret == -(MBEDTLS_ERR_SSL_FATAL_ALERT_MESSAGE)) {
- return;
- }
-#endif /* MBEDTLS_SSL_TLS_C */
- }
-
- use_ret = ret & ~0xFF80;
-
- if (use_ret == 0) {
- return;
- }
-
- // If high level code is present, make a concatenation between both
- // error strings.
- //
- len = strlen(buf);
-
- if (len > 0) {
- if (buflen - len < 5) {
- return;
- }
-
- mbedtls_snprintf(buf + len, buflen - len, " : ");
-
- buf += len + 3;
- buflen -= len + 3;
- }
-
- // Translate low level error code.
- low_level_error_description = mbedtls_low_level_strerr(ret);
-
- if (low_level_error_description == NULL) {
- mbedtls_snprintf(buf, buflen, "UNKNOWN ERROR CODE (%04X)", (unsigned int) use_ret);
- } else {
- mbedtls_snprintf(buf, buflen, "%s", low_level_error_description);
- }
-}
-
-#else /* MBEDTLS_ERROR_C */
-
-/*
- * Provide a dummy implementation when MBEDTLS_ERROR_C is not defined
- */
-void mbedtls_strerror(int ret, char *buf, size_t buflen)
-{
- ((void) ret);
-
- if (buflen > 0) {
- buf[0] = '\0';
- }
-}
-
-#endif /* MBEDTLS_ERROR_C */
-
-#if defined(MBEDTLS_TEST_HOOKS)
-void (*mbedtls_test_hook_error_add)(int, int, const char *, int);
-#endif
-
-#endif /* MBEDTLS_ERROR_C || MBEDTLS_ERROR_STRERROR_DUMMY */
diff --git a/library/psa_crypto_driver_wrappers.h b/library/psa_crypto_driver_wrappers.h
deleted file mode 100644
index 6ab9597..0000000
--- a/library/psa_crypto_driver_wrappers.h
+++ /dev/null
@@ -1,2883 +0,0 @@
-/*
- * Functions to delegate cryptographic operations to an available
- * and appropriate accelerator.
- * Warning: This file is now auto-generated.
- */
-/* Copyright The Mbed TLS Contributors
- * SPDX-License-Identifier: Apache-2.0
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may
- * not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-/* BEGIN-common headers */
-#include "common.h"
-#include "psa_crypto_aead.h"
-#include "psa_crypto_cipher.h"
-#include "psa_crypto_core.h"
-#include "psa_crypto_driver_wrappers_no_static.h"
-#include "psa_crypto_hash.h"
-#include "psa_crypto_mac.h"
-#include "psa_crypto_pake.h"
-#include "psa_crypto_rsa.h"
-
-#include "mbedtls/platform.h"
-#include "mbedtls/constant_time.h"
-/* END-common headers */
-
-#if defined(MBEDTLS_PSA_CRYPTO_C)
-
-/* BEGIN-driver headers */
-/* Headers for mbedtls_test opaque driver */
-#if defined(PSA_CRYPTO_DRIVER_TEST)
-#include "test/drivers/test_driver.h"
-
-#endif
-/* Headers for mbedtls_test transparent driver */
-#if defined(PSA_CRYPTO_DRIVER_TEST)
-#include "test/drivers/test_driver.h"
-
-#endif
-/* Headers for p256 transparent driver */
-#if defined(MBEDTLS_PSA_P256M_DRIVER_ENABLED)
-#include "../3rdparty/p256-m/p256-m_driver_entrypoints.h"
-
-#endif
-
-/* END-driver headers */
-
-/* Auto-generated values depending on which drivers are registered.
- * ID 0 is reserved for unallocated operations.
- * ID 1 is reserved for the Mbed TLS software driver. */
-/* BEGIN-driver id definition */
-#define PSA_CRYPTO_MBED_TLS_DRIVER_ID (1)
-#define MBEDTLS_TEST_OPAQUE_DRIVER_ID (2)
-#define MBEDTLS_TEST_TRANSPARENT_DRIVER_ID (3)
-#define P256_TRANSPARENT_DRIVER_ID (4)
-
-/* END-driver id */
-
-/* BEGIN-Common Macro definitions */
-
-/* END-Common Macro definitions */
-
-/* Support the 'old' SE interface when asked to */
-#if defined(MBEDTLS_PSA_CRYPTO_SE_C)
-/* PSA_CRYPTO_DRIVER_PRESENT is defined when either a new-style or old-style
- * SE driver is present, to avoid unused argument errors at compile time. */
-#ifndef PSA_CRYPTO_DRIVER_PRESENT
-#define PSA_CRYPTO_DRIVER_PRESENT
-#endif
-#include "psa_crypto_se.h"
-#endif
-
-static inline psa_status_t psa_driver_wrapper_init( void )
-{
- psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
-
-#if defined(MBEDTLS_PSA_CRYPTO_SE_C)
- status = psa_init_all_se_drivers( );
- if( status != PSA_SUCCESS )
- return( status );
-#endif
-
-#if defined(PSA_CRYPTO_DRIVER_TEST)
- status = mbedtls_test_transparent_init( );
- if( status != PSA_SUCCESS )
- return( status );
-
- status = mbedtls_test_opaque_init( );
- if( status != PSA_SUCCESS )
- return( status );
-#endif
-
- (void) status;
- return( PSA_SUCCESS );
-}
-
-static inline void psa_driver_wrapper_free( void )
-{
-#if defined(MBEDTLS_PSA_CRYPTO_SE_C)
- /* Unregister all secure element drivers, so that we restart from
- * a pristine state. */
- psa_unregister_all_se_drivers( );
-#endif /* MBEDTLS_PSA_CRYPTO_SE_C */
-
-#if defined(PSA_CRYPTO_DRIVER_TEST)
- mbedtls_test_transparent_free( );
- mbedtls_test_opaque_free( );
-#endif
-}
-
-/* Start delegation functions */
-static inline psa_status_t psa_driver_wrapper_sign_message(
- const psa_key_attributes_t *attributes,
- const uint8_t *key_buffer,
- size_t key_buffer_size,
- psa_algorithm_t alg,
- const uint8_t *input,
- size_t input_length,
- uint8_t *signature,
- size_t signature_size,
- size_t *signature_length )
-{
- psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
- psa_key_location_t location =
- PSA_KEY_LIFETIME_GET_LOCATION( attributes->core.lifetime );
-
- switch( location )
- {
- case PSA_KEY_LOCATION_LOCAL_STORAGE:
- /* Key is stored in the slot in export representation, so
- * cycle through all known transparent accelerators */
-#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
-#if defined(PSA_CRYPTO_DRIVER_TEST)
- status = mbedtls_test_transparent_signature_sign_message(
- attributes,
- key_buffer,
- key_buffer_size,
- alg,
- input,
- input_length,
- signature,
- signature_size,
- signature_length );
- /* Declared with fallback == true */
- if( status != PSA_ERROR_NOT_SUPPORTED )
- return( status );
-#endif /* PSA_CRYPTO_DRIVER_TEST */
-#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
- break;
-
- /* Add cases for opaque driver here */
-#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
-#if defined(PSA_CRYPTO_DRIVER_TEST)
- case PSA_CRYPTO_TEST_DRIVER_LOCATION:
- status = mbedtls_test_opaque_signature_sign_message(
- attributes,
- key_buffer,
- key_buffer_size,
- alg,
- input,
- input_length,
- signature,
- signature_size,
- signature_length );
- if( status != PSA_ERROR_NOT_SUPPORTED )
- return( status );
- break;
-#endif /* PSA_CRYPTO_DRIVER_TEST */
-#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
- default:
- /* Key is declared with a lifetime not known to us */
- (void)status;
- break;
- }
-
- return( psa_sign_message_builtin( attributes,
- key_buffer,
- key_buffer_size,
- alg,
- input,
- input_length,
- signature,
- signature_size,
- signature_length ) );
-}
-
-static inline psa_status_t psa_driver_wrapper_verify_message(
- const psa_key_attributes_t *attributes,
- const uint8_t *key_buffer,
- size_t key_buffer_size,
- psa_algorithm_t alg,
- const uint8_t *input,
- size_t input_length,
- const uint8_t *signature,
- size_t signature_length )
-{
- psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
- psa_key_location_t location =
- PSA_KEY_LIFETIME_GET_LOCATION( attributes->core.lifetime );
-
- switch( location )
- {
- case PSA_KEY_LOCATION_LOCAL_STORAGE:
- /* Key is stored in the slot in export representation, so
- * cycle through all known transparent accelerators */
-#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
-#if defined(PSA_CRYPTO_DRIVER_TEST)
- status = mbedtls_test_transparent_signature_verify_message(
- attributes,
- key_buffer,
- key_buffer_size,
- alg,
- input,
- input_length,
- signature,
- signature_length );
- /* Declared with fallback == true */
- if( status != PSA_ERROR_NOT_SUPPORTED )
- return( status );
-#endif /* PSA_CRYPTO_DRIVER_TEST */
-#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
- break;
-
- /* Add cases for opaque driver here */
-#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
-#if defined(PSA_CRYPTO_DRIVER_TEST)
- case PSA_CRYPTO_TEST_DRIVER_LOCATION:
- return( mbedtls_test_opaque_signature_verify_message(
- attributes,
- key_buffer,
- key_buffer_size,
- alg,
- input,
- input_length,
- signature,
- signature_length ) );
- if( status != PSA_ERROR_NOT_SUPPORTED )
- return( status );
- break;
-#endif /* PSA_CRYPTO_DRIVER_TEST */
-#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
- default:
- /* Key is declared with a lifetime not known to us */
- (void)status;
- break;
- }
-
- return( psa_verify_message_builtin( attributes,
- key_buffer,
- key_buffer_size,
- alg,
- input,
- input_length,
- signature,
- signature_length ) );
-}
-
-static inline psa_status_t psa_driver_wrapper_sign_hash(
- const psa_key_attributes_t *attributes,
- const uint8_t *key_buffer, size_t key_buffer_size,
- psa_algorithm_t alg, const uint8_t *hash, size_t hash_length,
- uint8_t *signature, size_t signature_size, size_t *signature_length )
-{
- /* Try dynamically-registered SE interface first */
-#if defined(MBEDTLS_PSA_CRYPTO_SE_C)
- const psa_drv_se_t *drv;
- psa_drv_se_context_t *drv_context;
-
- if( psa_get_se_driver( attributes->core.lifetime, &drv, &drv_context ) )
- {
- if( drv->asymmetric == NULL ||
- drv->asymmetric->p_sign == NULL )
- {
- /* Key is defined in SE, but we have no way to exercise it */
- return( PSA_ERROR_NOT_SUPPORTED );
- }
- return( drv->asymmetric->p_sign(
- drv_context, *( (psa_key_slot_number_t *)key_buffer ),
- alg, hash, hash_length,
- signature, signature_size, signature_length ) );
- }
-#endif /* MBEDTLS_PSA_CRYPTO_SE_C */
-
- psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
- psa_key_location_t location =
- PSA_KEY_LIFETIME_GET_LOCATION( attributes->core.lifetime );
-
- switch( location )
- {
- case PSA_KEY_LOCATION_LOCAL_STORAGE:
- /* Key is stored in the slot in export representation, so
- * cycle through all known transparent accelerators */
-#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
-#if defined(PSA_CRYPTO_DRIVER_TEST)
- status = mbedtls_test_transparent_signature_sign_hash( attributes,
- key_buffer,
- key_buffer_size,
- alg,
- hash,
- hash_length,
- signature,
- signature_size,
- signature_length );
- /* Declared with fallback == true */
- if( status != PSA_ERROR_NOT_SUPPORTED )
- return( status );
-#endif /* PSA_CRYPTO_DRIVER_TEST */
-#if defined (MBEDTLS_PSA_P256M_DRIVER_ENABLED)
- if( PSA_KEY_TYPE_IS_ECC( attributes->core.type ) &&
- PSA_ALG_IS_ECDSA(alg) &&
- !PSA_ALG_ECDSA_IS_DETERMINISTIC( alg ) &&
- PSA_KEY_TYPE_ECC_GET_FAMILY(attributes->core.type) == PSA_ECC_FAMILY_SECP_R1 &&
- attributes->core.bits == 256 )
- {
- status = p256_transparent_sign_hash( attributes,
- key_buffer,
- key_buffer_size,
- alg,
- hash,
- hash_length,
- signature,
- signature_size,
- signature_length );
- if( status != PSA_ERROR_NOT_SUPPORTED )
- return( status );
- }
-#endif /* MBEDTLS_PSA_P256M_DRIVER_ENABLED */
-#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
- /* Fell through, meaning no accelerator supports this operation */
- return( psa_sign_hash_builtin( attributes,
- key_buffer,
- key_buffer_size,
- alg,
- hash,
- hash_length,
- signature,
- signature_size,
- signature_length ) );
-
- /* Add cases for opaque driver here */
-#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
-#if defined(PSA_CRYPTO_DRIVER_TEST)
- case PSA_CRYPTO_TEST_DRIVER_LOCATION:
- return( mbedtls_test_opaque_signature_sign_hash( attributes,
- key_buffer,
- key_buffer_size,
- alg,
- hash,
- hash_length,
- signature,
- signature_size,
- signature_length ) );
-#endif /* PSA_CRYPTO_DRIVER_TEST */
-#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
- default:
- /* Key is declared with a lifetime not known to us */
- (void)status;
- return( PSA_ERROR_INVALID_ARGUMENT );
- }
-}
-
-static inline psa_status_t psa_driver_wrapper_verify_hash(
- const psa_key_attributes_t *attributes,
- const uint8_t *key_buffer, size_t key_buffer_size,
- psa_algorithm_t alg, const uint8_t *hash, size_t hash_length,
- const uint8_t *signature, size_t signature_length )
-{
- /* Try dynamically-registered SE interface first */
-#if defined(MBEDTLS_PSA_CRYPTO_SE_C)
- const psa_drv_se_t *drv;
- psa_drv_se_context_t *drv_context;
-
- if( psa_get_se_driver( attributes->core.lifetime, &drv, &drv_context ) )
- {
- if( drv->asymmetric == NULL ||
- drv->asymmetric->p_verify == NULL )
- {
- /* Key is defined in SE, but we have no way to exercise it */
- return( PSA_ERROR_NOT_SUPPORTED );
- }
- return( drv->asymmetric->p_verify(
- drv_context, *( (psa_key_slot_number_t *)key_buffer ),
- alg, hash, hash_length,
- signature, signature_length ) );
- }
-#endif /* MBEDTLS_PSA_CRYPTO_SE_C */
-
- psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
- psa_key_location_t location =
- PSA_KEY_LIFETIME_GET_LOCATION( attributes->core.lifetime );
-
- switch( location )
- {
- case PSA_KEY_LOCATION_LOCAL_STORAGE:
- /* Key is stored in the slot in export representation, so
- * cycle through all known transparent accelerators */
-#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
-#if defined(PSA_CRYPTO_DRIVER_TEST)
- status = mbedtls_test_transparent_signature_verify_hash(
- attributes,
- key_buffer,
- key_buffer_size,
- alg,
- hash,
- hash_length,
- signature,
- signature_length );
- /* Declared with fallback == true */
- if( status != PSA_ERROR_NOT_SUPPORTED )
- return( status );
-#endif /* PSA_CRYPTO_DRIVER_TEST */
-#if defined (MBEDTLS_PSA_P256M_DRIVER_ENABLED)
- if( PSA_KEY_TYPE_IS_ECC( attributes->core.type ) &&
- PSA_ALG_IS_ECDSA(alg) &&
- !PSA_ALG_ECDSA_IS_DETERMINISTIC( alg ) &&
- PSA_KEY_TYPE_ECC_GET_FAMILY(attributes->core.type) == PSA_ECC_FAMILY_SECP_R1 &&
- attributes->core.bits == 256 )
- {
- status = p256_transparent_verify_hash( attributes,
- key_buffer,
- key_buffer_size,
- alg,
- hash,
- hash_length,
- signature,
- signature_length );
- if( status != PSA_ERROR_NOT_SUPPORTED )
- return( status );
- }
-#endif /* MBEDTLS_PSA_P256M_DRIVER_ENABLED */
-#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
-
- return( psa_verify_hash_builtin( attributes,
- key_buffer,
- key_buffer_size,
- alg,
- hash,
- hash_length,
- signature,
- signature_length ) );
-
- /* Add cases for opaque driver here */
-#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
-#if defined(PSA_CRYPTO_DRIVER_TEST)
- case PSA_CRYPTO_TEST_DRIVER_LOCATION:
- return( mbedtls_test_opaque_signature_verify_hash( attributes,
- key_buffer,
- key_buffer_size,
- alg,
- hash,
- hash_length,
- signature,
- signature_length ) );
-#endif /* PSA_CRYPTO_DRIVER_TEST */
-#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
- default:
- /* Key is declared with a lifetime not known to us */
- (void)status;
- return( PSA_ERROR_INVALID_ARGUMENT );
- }
-}
-
-static inline uint32_t psa_driver_wrapper_sign_hash_get_num_ops(
- psa_sign_hash_interruptible_operation_t *operation )
-{
- switch( operation->id )
- {
- /* If uninitialised, return 0, as no work can have been done. */
- case 0:
- return 0;
-
- case PSA_CRYPTO_MBED_TLS_DRIVER_ID:
- return(mbedtls_psa_sign_hash_get_num_ops(&operation->ctx.mbedtls_ctx));
-
-#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
-#if defined(PSA_CRYPTO_DRIVER_TEST)
- /* Add test driver tests here */
-
-#endif /* PSA_CRYPTO_DRIVER_TEST */
-#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
- }
-
- /* Can't happen (see discussion in #8271) */
- return 0;
-}
-
-static inline uint32_t psa_driver_wrapper_verify_hash_get_num_ops(
- psa_verify_hash_interruptible_operation_t *operation )
-{
- switch( operation->id )
- {
- /* If uninitialised, return 0, as no work can have been done. */
- case 0:
- return 0;
-
- case PSA_CRYPTO_MBED_TLS_DRIVER_ID:
- return (mbedtls_psa_verify_hash_get_num_ops(&operation->ctx.mbedtls_ctx));
-
-#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
-#if defined(PSA_CRYPTO_DRIVER_TEST)
- /* Add test driver tests here */
-
-#endif /* PSA_CRYPTO_DRIVER_TEST */
-#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
-
- }
-
- /* Can't happen (see discussion in #8271) */
- return 0;
-}
-
-static inline psa_status_t psa_driver_wrapper_sign_hash_start(
- psa_sign_hash_interruptible_operation_t *operation,
- const psa_key_attributes_t *attributes, const uint8_t *key_buffer,
- size_t key_buffer_size, psa_algorithm_t alg,
- const uint8_t *hash, size_t hash_length )
-{
- psa_key_location_t location = PSA_KEY_LIFETIME_GET_LOCATION(
- attributes->core.lifetime );
-
- switch( location )
- {
- case PSA_KEY_LOCATION_LOCAL_STORAGE:
- /* Key is stored in the slot in export representation, so
- * cycle through all known transparent accelerators */
-
-#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
-#if defined(PSA_CRYPTO_DRIVER_TEST)
-
- /* Add test driver tests here */
-
- /* Declared with fallback == true */
-
-#endif /* PSA_CRYPTO_DRIVER_TEST */
-#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
-
- /* Fell through, meaning no accelerator supports this operation */
- operation->id = PSA_CRYPTO_MBED_TLS_DRIVER_ID;
- return( mbedtls_psa_sign_hash_start( &operation->ctx.mbedtls_ctx,
- attributes,
- key_buffer, key_buffer_size,
- alg, hash, hash_length ) );
- break;
-
- /* Add cases for opaque driver here */
-
- default:
- /* Key is declared with a lifetime not known to us */
- return( PSA_ERROR_INVALID_ARGUMENT );
- }
-}
-
-static inline psa_status_t psa_driver_wrapper_sign_hash_complete(
- psa_sign_hash_interruptible_operation_t *operation,
- uint8_t *signature, size_t signature_size,
- size_t *signature_length )
-{
- switch( operation->id )
- {
- case PSA_CRYPTO_MBED_TLS_DRIVER_ID:
- return( mbedtls_psa_sign_hash_complete( &operation->ctx.mbedtls_ctx,
- signature, signature_size,
- signature_length ) );
-
-#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
-#if defined(PSA_CRYPTO_DRIVER_TEST)
- /* Add test driver tests here */
-
-#endif /* PSA_CRYPTO_DRIVER_TEST */
-#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
- }
-
- ( void ) signature;
- ( void ) signature_size;
- ( void ) signature_length;
-
- return( PSA_ERROR_INVALID_ARGUMENT );
-}
-
-static inline psa_status_t psa_driver_wrapper_sign_hash_abort(
- psa_sign_hash_interruptible_operation_t *operation )
-{
- switch( operation->id )
- {
- case PSA_CRYPTO_MBED_TLS_DRIVER_ID:
- return( mbedtls_psa_sign_hash_abort( &operation->ctx.mbedtls_ctx ) );
-
-#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
-#if defined(PSA_CRYPTO_DRIVER_TEST)
- /* Add test driver tests here */
-
-#endif /* PSA_CRYPTO_DRIVER_TEST */
-#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
- }
-
- return( PSA_ERROR_INVALID_ARGUMENT );
-}
-
-static inline psa_status_t psa_driver_wrapper_verify_hash_start(
- psa_verify_hash_interruptible_operation_t *operation,
- const psa_key_attributes_t *attributes, const uint8_t *key_buffer,
- size_t key_buffer_size, psa_algorithm_t alg,
- const uint8_t *hash, size_t hash_length,
- const uint8_t *signature, size_t signature_length )
-{
- psa_key_location_t location = PSA_KEY_LIFETIME_GET_LOCATION(
- attributes->core.lifetime );
-
- switch( location )
- {
- case PSA_KEY_LOCATION_LOCAL_STORAGE:
- /* Key is stored in the slot in export representation, so
- * cycle through all known transparent accelerators */
-
-#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
-#if defined(PSA_CRYPTO_DRIVER_TEST)
-
- /* Add test driver tests here */
-
- /* Declared with fallback == true */
-
-#endif /* PSA_CRYPTO_DRIVER_TEST */
-#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
-
- /* Fell through, meaning no accelerator supports this operation */
- operation->id = PSA_CRYPTO_MBED_TLS_DRIVER_ID;
- return( mbedtls_psa_verify_hash_start( &operation->ctx.mbedtls_ctx,
- attributes,
- key_buffer, key_buffer_size,
- alg, hash, hash_length,
- signature, signature_length
- ) );
- break;
-
- /* Add cases for opaque driver here */
-
- default:
- /* Key is declared with a lifetime not known to us */
- return( PSA_ERROR_INVALID_ARGUMENT );
- }
-}
-
-static inline psa_status_t psa_driver_wrapper_verify_hash_complete(
- psa_verify_hash_interruptible_operation_t *operation )
-{
- switch( operation->id )
- {
- case PSA_CRYPTO_MBED_TLS_DRIVER_ID:
- return( mbedtls_psa_verify_hash_complete(
- &operation->ctx.mbedtls_ctx
- ) );
-
-#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
-#if defined(PSA_CRYPTO_DRIVER_TEST)
- /* Add test driver tests here */
-
-#endif /* PSA_CRYPTO_DRIVER_TEST */
-#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
- }
-
- return( PSA_ERROR_INVALID_ARGUMENT );
-}
-
-static inline psa_status_t psa_driver_wrapper_verify_hash_abort(
- psa_verify_hash_interruptible_operation_t *operation )
-{
- switch( operation->id )
- {
- case PSA_CRYPTO_MBED_TLS_DRIVER_ID:
- return( mbedtls_psa_verify_hash_abort( &operation->ctx.mbedtls_ctx
- ) );
-
-#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
-#if defined(PSA_CRYPTO_DRIVER_TEST)
- /* Add test driver tests here */
-
-#endif /* PSA_CRYPTO_DRIVER_TEST */
-#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
- }
-
- return( PSA_ERROR_INVALID_ARGUMENT );
-}
-
-/** Calculate the key buffer size required to store the key material of a key
- * associated with an opaque driver from input key data.
- *
- * \param[in] attributes The key attributes
- * \param[in] data The input key data.
- * \param[in] data_length The input data length.
- * \param[out] key_buffer_size Minimum buffer size to contain the key material.
- *
- * \retval #PSA_SUCCESS \emptydescription
- * \retval #PSA_ERROR_INVALID_ARGUMENT \emptydescription
- * \retval #PSA_ERROR_NOT_SUPPORTED \emptydescription
- */
-static inline psa_status_t psa_driver_wrapper_get_key_buffer_size_from_key_data(
- const psa_key_attributes_t *attributes,
- const uint8_t *data,
- size_t data_length,
- size_t *key_buffer_size )
-{
- psa_key_location_t location =
- PSA_KEY_LIFETIME_GET_LOCATION( attributes->core.lifetime );
- psa_key_type_t key_type = attributes->core.type;
-
- *key_buffer_size = 0;
- switch( location )
- {
-#if defined(PSA_CRYPTO_DRIVER_TEST)
- case PSA_CRYPTO_TEST_DRIVER_LOCATION:
- *key_buffer_size = mbedtls_test_opaque_size_function( key_type,
- PSA_BYTES_TO_BITS( data_length ) );
- return( ( *key_buffer_size != 0 ) ?
- PSA_SUCCESS : PSA_ERROR_NOT_SUPPORTED );
-#endif /* PSA_CRYPTO_DRIVER_TEST */
-
- default:
- (void)key_type;
- (void)data;
- (void)data_length;
- return( PSA_ERROR_INVALID_ARGUMENT );
- }
-}
-
-static inline psa_status_t psa_driver_wrapper_generate_key(
- const psa_key_attributes_t *attributes,
- uint8_t *key_buffer, size_t key_buffer_size, size_t *key_buffer_length )
-{
- psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
- psa_key_location_t location =
- PSA_KEY_LIFETIME_GET_LOCATION(attributes->core.lifetime);
-
- /* Try dynamically-registered SE interface first */
-#if defined(MBEDTLS_PSA_CRYPTO_SE_C)
- const psa_drv_se_t *drv;
- psa_drv_se_context_t *drv_context;
-
- if( psa_get_se_driver( attributes->core.lifetime, &drv, &drv_context ) )
- {
- size_t pubkey_length = 0; /* We don't support this feature yet */
- if( drv->key_management == NULL ||
- drv->key_management->p_generate == NULL )
- {
- /* Key is defined as being in SE, but we have no way to generate it */
- return( PSA_ERROR_NOT_SUPPORTED );
- }
- return( drv->key_management->p_generate(
- drv_context,
- *( (psa_key_slot_number_t *)key_buffer ),
- attributes, NULL, 0, &pubkey_length ) );
- }
-#endif /* MBEDTLS_PSA_CRYPTO_SE_C */
-
- switch( location )
- {
- case PSA_KEY_LOCATION_LOCAL_STORAGE:
-#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
- /* Transparent drivers are limited to generating asymmetric keys */
- if( PSA_KEY_TYPE_IS_ASYMMETRIC( attributes->core.type ) )
- {
- /* Cycle through all known transparent accelerators */
-#if defined(PSA_CRYPTO_DRIVER_TEST)
- status = mbedtls_test_transparent_generate_key(
- attributes, key_buffer, key_buffer_size,
- key_buffer_length );
- /* Declared with fallback == true */
- if( status != PSA_ERROR_NOT_SUPPORTED )
- break;
-#endif /* PSA_CRYPTO_DRIVER_TEST */
-#if defined(MBEDTLS_PSA_P256M_DRIVER_ENABLED)
- if( PSA_KEY_TYPE_IS_ECC( attributes->core.type ) &&
- attributes->core.type == PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_SECP_R1) &&
- attributes->core.bits == 256 )
- {
- status = p256_transparent_generate_key( attributes,
- key_buffer,
- key_buffer_size,
- key_buffer_length );
- if( status != PSA_ERROR_NOT_SUPPORTED )
- break;
- }
-
-#endif /* MBEDTLS_PSA_P256M_DRIVER_ENABLED */
- }
-#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
-
- /* Software fallback */
- status = psa_generate_key_internal(
- attributes, key_buffer, key_buffer_size, key_buffer_length );
- break;
-
- /* Add cases for opaque driver here */
-#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
-#if defined(PSA_CRYPTO_DRIVER_TEST)
- case PSA_CRYPTO_TEST_DRIVER_LOCATION:
- status = mbedtls_test_opaque_generate_key(
- attributes, key_buffer, key_buffer_size, key_buffer_length );
- break;
-#endif /* PSA_CRYPTO_DRIVER_TEST */
-#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
-
- default:
- /* Key is declared with a lifetime not known to us */
- status = PSA_ERROR_INVALID_ARGUMENT;
- break;
- }
-
- return( status );
-}
-
-static inline psa_status_t psa_driver_wrapper_import_key(
- const psa_key_attributes_t *attributes,
- const uint8_t *data,
- size_t data_length,
- uint8_t *key_buffer,
- size_t key_buffer_size,
- size_t *key_buffer_length,
- size_t *bits )
-{
-
- psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
- psa_key_location_t location = PSA_KEY_LIFETIME_GET_LOCATION(
- psa_get_key_lifetime( attributes ) );
-
- /* Try dynamically-registered SE interface first */
-#if defined(MBEDTLS_PSA_CRYPTO_SE_C)
- const psa_drv_se_t *drv;
- psa_drv_se_context_t *drv_context;
-
- if( psa_get_se_driver( attributes->core.lifetime, &drv, &drv_context ) )
- {
- if( drv->key_management == NULL ||
- drv->key_management->p_import == NULL )
- return( PSA_ERROR_NOT_SUPPORTED );
-
- /* The driver should set the number of key bits, however in
- * case it doesn't, we initialize bits to an invalid value. */
- *bits = PSA_MAX_KEY_BITS + 1;
- status = drv->key_management->p_import(
- drv_context,
- *( (psa_key_slot_number_t *)key_buffer ),
- attributes, data, data_length, bits );
-
- if( status != PSA_SUCCESS )
- return( status );
-
- if( (*bits) > PSA_MAX_KEY_BITS )
- return( PSA_ERROR_NOT_SUPPORTED );
-
- return( PSA_SUCCESS );
- }
-#endif /* MBEDTLS_PSA_CRYPTO_SE_C */
-
- switch( location )
- {
- case PSA_KEY_LOCATION_LOCAL_STORAGE:
- /* Key is stored in the slot in export representation, so
- * cycle through all known transparent accelerators */
-#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
-
-#if (defined(PSA_CRYPTO_DRIVER_TEST) )
- status = mbedtls_test_transparent_import_key
- (attributes,
- data,
- data_length,
- key_buffer,
- key_buffer_size,
- key_buffer_length,
- bits
- );
-
- if( status != PSA_ERROR_NOT_SUPPORTED )
- return( status );
-#endif
-
-#if (defined(MBEDTLS_PSA_P256M_DRIVER_ENABLED) )
- status = p256_transparent_import_key
- (attributes,
- data,
- data_length,
- key_buffer,
- key_buffer_size,
- key_buffer_length,
- bits
- );
-
- if( status != PSA_ERROR_NOT_SUPPORTED )
- return( status );
-#endif
-
-
-#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
-
- /* Fell through, meaning no accelerator supports this operation */
- return( psa_import_key_into_slot( attributes,
- data, data_length,
- key_buffer, key_buffer_size,
- key_buffer_length, bits ) );
- /* Add cases for opaque driver here */
-#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
-
-#if (defined(PSA_CRYPTO_DRIVER_TEST) )
- case 0x7fffff:
- return( mbedtls_test_opaque_import_key
- (attributes,
- data,
- data_length,
- key_buffer,
- key_buffer_size,
- key_buffer_length,
- bits
- ));
-#endif
-
-
-#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
- default:
- (void)status;
- return( PSA_ERROR_INVALID_ARGUMENT );
- }
-
-}
-
-static inline psa_status_t psa_driver_wrapper_export_key(
- const psa_key_attributes_t *attributes,
- const uint8_t *key_buffer, size_t key_buffer_size,
- uint8_t *data, size_t data_size, size_t *data_length )
-
-{
-
- psa_status_t status = PSA_ERROR_INVALID_ARGUMENT;
- psa_key_location_t location = PSA_KEY_LIFETIME_GET_LOCATION(
- psa_get_key_lifetime( attributes ) );
-
- /* Try dynamically-registered SE interface first */
-#if defined(MBEDTLS_PSA_CRYPTO_SE_C)
- const psa_drv_se_t *drv;
- psa_drv_se_context_t *drv_context;
-
- if( psa_get_se_driver( attributes->core.lifetime, &drv, &drv_context ) )
- {
- if( ( drv->key_management == NULL ) ||
- ( drv->key_management->p_export == NULL ) )
- {
- return( PSA_ERROR_NOT_SUPPORTED );
- }
-
- return( drv->key_management->p_export(
- drv_context,
- *( (psa_key_slot_number_t *)key_buffer ),
- data, data_size, data_length ) );
- }
-#endif /* MBEDTLS_PSA_CRYPTO_SE_C */
-
- switch( location )
- {
- case PSA_KEY_LOCATION_LOCAL_STORAGE:
- return( psa_export_key_internal( attributes,
- key_buffer,
- key_buffer_size,
- data,
- data_size,
- data_length ) );
-
- /* Add cases for opaque driver here */
-#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
-
-#if (defined(PSA_CRYPTO_DRIVER_TEST) )
- case 0x7fffff:
- return( mbedtls_test_opaque_export_key
- (attributes,
- key_buffer,
- key_buffer_size,
- data,
- data_size,
- data_length
- ));
-#endif
-
-
-#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
- default:
- /* Key is declared with a lifetime not known to us */
- return( status );
- }
-
-}
-
-static inline psa_status_t psa_driver_wrapper_copy_key(
- psa_key_attributes_t *attributes,
- const uint8_t *source_key, size_t source_key_length,
- uint8_t *target_key_buffer, size_t target_key_buffer_size,
- size_t *target_key_buffer_length )
-{
-
- psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
- psa_key_location_t location =
- PSA_KEY_LIFETIME_GET_LOCATION( attributes->core.lifetime );
-
-#if defined(MBEDTLS_PSA_CRYPTO_SE_C)
- const psa_drv_se_t *drv;
- psa_drv_se_context_t *drv_context;
-
- if( psa_get_se_driver( attributes->core.lifetime, &drv, &drv_context ) )
- {
- /* Copying to a secure element is not implemented yet. */
- return( PSA_ERROR_NOT_SUPPORTED );
- }
-#endif /* MBEDTLS_PSA_CRYPTO_SE_C */
-
- switch( location )
- {
-#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
-
-#if (defined(PSA_CRYPTO_DRIVER_TEST) )
- case 0x7fffff:
- return( mbedtls_test_opaque_copy_key
- (attributes,
- source_key,
- source_key_length,
- target_key_buffer,
- target_key_buffer_size,
- target_key_buffer_length
- ));
-#endif
-
-
-#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
- default:
- (void)source_key;
- (void)source_key_length;
- (void)target_key_buffer;
- (void)target_key_buffer_size;
- (void)target_key_buffer_length;
- status = PSA_ERROR_INVALID_ARGUMENT;
- }
- return( status );
-
-}
-
-/*
- * Cipher functions
- */
-static inline psa_status_t psa_driver_wrapper_cipher_encrypt(
- const psa_key_attributes_t *attributes,
- const uint8_t *key_buffer,
- size_t key_buffer_size,
- psa_algorithm_t alg,
- const uint8_t *iv,
- size_t iv_length,
- const uint8_t *input,
- size_t input_length,
- uint8_t *output,
- size_t output_size,
- size_t *output_length )
-{
- psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
- psa_key_location_t location =
- PSA_KEY_LIFETIME_GET_LOCATION( attributes->core.lifetime );
-
- switch( location )
- {
- case PSA_KEY_LOCATION_LOCAL_STORAGE:
- /* Key is stored in the slot in export representation, so
- * cycle through all known transparent accelerators */
-#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
-#if defined(PSA_CRYPTO_DRIVER_TEST)
- status = mbedtls_test_transparent_cipher_encrypt( attributes,
- key_buffer,
- key_buffer_size,
- alg,
- iv,
- iv_length,
- input,
- input_length,
- output,
- output_size,
- output_length );
- /* Declared with fallback == true */
- if( status != PSA_ERROR_NOT_SUPPORTED )
- return( status );
-#endif /* PSA_CRYPTO_DRIVER_TEST */
-#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
-
-#if defined(MBEDTLS_PSA_BUILTIN_CIPHER)
- return( mbedtls_psa_cipher_encrypt( attributes,
- key_buffer,
- key_buffer_size,
- alg,
- iv,
- iv_length,
- input,
- input_length,
- output,
- output_size,
- output_length ) );
-#else
- return( PSA_ERROR_NOT_SUPPORTED );
-#endif /* MBEDTLS_PSA_BUILTIN_CIPHER */
-
- /* Add cases for opaque driver here */
-#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
-#if defined(PSA_CRYPTO_DRIVER_TEST)
- case PSA_CRYPTO_TEST_DRIVER_LOCATION:
- return( mbedtls_test_opaque_cipher_encrypt( attributes,
- key_buffer,
- key_buffer_size,
- alg,
- iv,
- iv_length,
- input,
- input_length,
- output,
- output_size,
- output_length ) );
-#endif /* PSA_CRYPTO_DRIVER_TEST */
-#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
-
- default:
- /* Key is declared with a lifetime not known to us */
- (void)status;
- (void)key_buffer;
- (void)key_buffer_size;
- (void)alg;
- (void)iv;
- (void)iv_length;
- (void)input;
- (void)input_length;
- (void)output;
- (void)output_size;
- (void)output_length;
- return( PSA_ERROR_INVALID_ARGUMENT );
- }
-}
-
-static inline psa_status_t psa_driver_wrapper_cipher_decrypt(
- const psa_key_attributes_t *attributes,
- const uint8_t *key_buffer,
- size_t key_buffer_size,
- psa_algorithm_t alg,
- const uint8_t *input,
- size_t input_length,
- uint8_t *output,
- size_t output_size,
- size_t *output_length )
-{
- psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
- psa_key_location_t location =
- PSA_KEY_LIFETIME_GET_LOCATION( attributes->core.lifetime );
-
- switch( location )
- {
- case PSA_KEY_LOCATION_LOCAL_STORAGE:
- /* Key is stored in the slot in export representation, so
- * cycle through all known transparent accelerators */
-#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
-#if defined(PSA_CRYPTO_DRIVER_TEST)
- status = mbedtls_test_transparent_cipher_decrypt( attributes,
- key_buffer,
- key_buffer_size,
- alg,
- input,
- input_length,
- output,
- output_size,
- output_length );
- /* Declared with fallback == true */
- if( status != PSA_ERROR_NOT_SUPPORTED )
- return( status );
-#endif /* PSA_CRYPTO_DRIVER_TEST */
-#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
-
-#if defined(MBEDTLS_PSA_BUILTIN_CIPHER)
- return( mbedtls_psa_cipher_decrypt( attributes,
- key_buffer,
- key_buffer_size,
- alg,
- input,
- input_length,
- output,
- output_size,
- output_length ) );
-#else
- return( PSA_ERROR_NOT_SUPPORTED );
-#endif /* MBEDTLS_PSA_BUILTIN_CIPHER */
-
- /* Add cases for opaque driver here */
-#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
-#if defined(PSA_CRYPTO_DRIVER_TEST)
- case PSA_CRYPTO_TEST_DRIVER_LOCATION:
- return( mbedtls_test_opaque_cipher_decrypt( attributes,
- key_buffer,
- key_buffer_size,
- alg,
- input,
- input_length,
- output,
- output_size,
- output_length ) );
-#endif /* PSA_CRYPTO_DRIVER_TEST */
-#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
-
- default:
- /* Key is declared with a lifetime not known to us */
- (void)status;
- (void)key_buffer;
- (void)key_buffer_size;
- (void)alg;
- (void)input;
- (void)input_length;
- (void)output;
- (void)output_size;
- (void)output_length;
- return( PSA_ERROR_INVALID_ARGUMENT );
- }
-}
-
-static inline psa_status_t psa_driver_wrapper_cipher_encrypt_setup(
- psa_cipher_operation_t *operation,
- const psa_key_attributes_t *attributes,
- const uint8_t *key_buffer, size_t key_buffer_size,
- psa_algorithm_t alg )
-{
- psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
- psa_key_location_t location =
- PSA_KEY_LIFETIME_GET_LOCATION( attributes->core.lifetime );
-
- switch( location )
- {
- case PSA_KEY_LOCATION_LOCAL_STORAGE:
- /* Key is stored in the slot in export representation, so
- * cycle through all known transparent accelerators */
-#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
-#if defined(PSA_CRYPTO_DRIVER_TEST)
- status = mbedtls_test_transparent_cipher_encrypt_setup(
- &operation->ctx.transparent_test_driver_ctx,
- attributes,
- key_buffer,
- key_buffer_size,
- alg );
- /* Declared with fallback == true */
- if( status == PSA_SUCCESS )
- operation->id = MBEDTLS_TEST_TRANSPARENT_DRIVER_ID;
-
- if( status != PSA_ERROR_NOT_SUPPORTED )
- return( status );
-#endif /* PSA_CRYPTO_DRIVER_TEST */
-#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
-#if defined(MBEDTLS_PSA_BUILTIN_CIPHER)
- /* Fell through, meaning no accelerator supports this operation */
- status = mbedtls_psa_cipher_encrypt_setup( &operation->ctx.mbedtls_ctx,
- attributes,
- key_buffer,
- key_buffer_size,
- alg );
- if( status == PSA_SUCCESS )
- operation->id = PSA_CRYPTO_MBED_TLS_DRIVER_ID;
-
- if( status != PSA_ERROR_NOT_SUPPORTED )
- return( status );
-#endif /* MBEDTLS_PSA_BUILTIN_CIPHER */
- return( PSA_ERROR_NOT_SUPPORTED );
-
- /* Add cases for opaque driver here */
-#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
-#if defined(PSA_CRYPTO_DRIVER_TEST)
- case PSA_CRYPTO_TEST_DRIVER_LOCATION:
- status = mbedtls_test_opaque_cipher_encrypt_setup(
- &operation->ctx.opaque_test_driver_ctx,
- attributes,
- key_buffer, key_buffer_size,
- alg );
-
- if( status == PSA_SUCCESS )
- operation->id = MBEDTLS_TEST_OPAQUE_DRIVER_ID;
-
- return( status );
-#endif /* PSA_CRYPTO_DRIVER_TEST */
-#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
- default:
- /* Key is declared with a lifetime not known to us */
- (void)status;
- (void)operation;
- (void)key_buffer;
- (void)key_buffer_size;
- (void)alg;
- return( PSA_ERROR_INVALID_ARGUMENT );
- }
-}
-
-static inline psa_status_t psa_driver_wrapper_cipher_decrypt_setup(
- psa_cipher_operation_t *operation,
- const psa_key_attributes_t *attributes,
- const uint8_t *key_buffer, size_t key_buffer_size,
- psa_algorithm_t alg )
-{
- psa_status_t status = PSA_ERROR_INVALID_ARGUMENT;
- psa_key_location_t location =
- PSA_KEY_LIFETIME_GET_LOCATION( attributes->core.lifetime );
-
- switch( location )
- {
- case PSA_KEY_LOCATION_LOCAL_STORAGE:
- /* Key is stored in the slot in export representation, so
- * cycle through all known transparent accelerators */
-#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
-#if defined(PSA_CRYPTO_DRIVER_TEST)
- status = mbedtls_test_transparent_cipher_decrypt_setup(
- &operation->ctx.transparent_test_driver_ctx,
- attributes,
- key_buffer,
- key_buffer_size,
- alg );
- /* Declared with fallback == true */
- if( status == PSA_SUCCESS )
- operation->id = MBEDTLS_TEST_TRANSPARENT_DRIVER_ID;
-
- if( status != PSA_ERROR_NOT_SUPPORTED )
- return( status );
-#endif /* PSA_CRYPTO_DRIVER_TEST */
-#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
-#if defined(MBEDTLS_PSA_BUILTIN_CIPHER)
- /* Fell through, meaning no accelerator supports this operation */
- status = mbedtls_psa_cipher_decrypt_setup( &operation->ctx.mbedtls_ctx,
- attributes,
- key_buffer,
- key_buffer_size,
- alg );
- if( status == PSA_SUCCESS )
- operation->id = PSA_CRYPTO_MBED_TLS_DRIVER_ID;
-
- return( status );
-#else /* MBEDTLS_PSA_BUILTIN_CIPHER */
- return( PSA_ERROR_NOT_SUPPORTED );
-#endif /* MBEDTLS_PSA_BUILTIN_CIPHER */
-
- /* Add cases for opaque driver here */
-#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
-#if defined(PSA_CRYPTO_DRIVER_TEST)
- case PSA_CRYPTO_TEST_DRIVER_LOCATION:
- status = mbedtls_test_opaque_cipher_decrypt_setup(
- &operation->ctx.opaque_test_driver_ctx,
- attributes,
- key_buffer, key_buffer_size,
- alg );
-
- if( status == PSA_SUCCESS )
- operation->id = MBEDTLS_TEST_OPAQUE_DRIVER_ID;
-
- return( status );
-#endif /* PSA_CRYPTO_DRIVER_TEST */
-#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
- default:
- /* Key is declared with a lifetime not known to us */
- (void)status;
- (void)operation;
- (void)key_buffer;
- (void)key_buffer_size;
- (void)alg;
- return( PSA_ERROR_INVALID_ARGUMENT );
- }
-}
-
-static inline psa_status_t psa_driver_wrapper_cipher_set_iv(
- psa_cipher_operation_t *operation,
- const uint8_t *iv,
- size_t iv_length )
-{
- switch( operation->id )
- {
-#if defined(MBEDTLS_PSA_BUILTIN_CIPHER)
- case PSA_CRYPTO_MBED_TLS_DRIVER_ID:
- return( mbedtls_psa_cipher_set_iv( &operation->ctx.mbedtls_ctx,
- iv,
- iv_length ) );
-#endif /* MBEDTLS_PSA_BUILTIN_CIPHER */
-
-#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
-#if defined(PSA_CRYPTO_DRIVER_TEST)
- case MBEDTLS_TEST_TRANSPARENT_DRIVER_ID:
- return( mbedtls_test_transparent_cipher_set_iv(
- &operation->ctx.transparent_test_driver_ctx,
- iv, iv_length ) );
-
- case MBEDTLS_TEST_OPAQUE_DRIVER_ID:
- return( mbedtls_test_opaque_cipher_set_iv(
- &operation->ctx.opaque_test_driver_ctx,
- iv, iv_length ) );
-#endif /* PSA_CRYPTO_DRIVER_TEST */
-#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
- }
-
- (void)iv;
- (void)iv_length;
-
- return( PSA_ERROR_INVALID_ARGUMENT );
-}
-
-static inline psa_status_t psa_driver_wrapper_cipher_update(
- psa_cipher_operation_t *operation,
- const uint8_t *input,
- size_t input_length,
- uint8_t *output,
- size_t output_size,
- size_t *output_length )
-{
- switch( operation->id )
- {
-#if defined(MBEDTLS_PSA_BUILTIN_CIPHER)
- case PSA_CRYPTO_MBED_TLS_DRIVER_ID:
- return( mbedtls_psa_cipher_update( &operation->ctx.mbedtls_ctx,
- input,
- input_length,
- output,
- output_size,
- output_length ) );
-#endif /* MBEDTLS_PSA_BUILTIN_CIPHER */
-
-#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
-#if defined(PSA_CRYPTO_DRIVER_TEST)
- case MBEDTLS_TEST_TRANSPARENT_DRIVER_ID:
- return( mbedtls_test_transparent_cipher_update(
- &operation->ctx.transparent_test_driver_ctx,
- input, input_length,
- output, output_size, output_length ) );
-
- case MBEDTLS_TEST_OPAQUE_DRIVER_ID:
- return( mbedtls_test_opaque_cipher_update(
- &operation->ctx.opaque_test_driver_ctx,
- input, input_length,
- output, output_size, output_length ) );
-#endif /* PSA_CRYPTO_DRIVER_TEST */
-#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
- }
-
- (void)input;
- (void)input_length;
- (void)output;
- (void)output_size;
- (void)output_length;
-
- return( PSA_ERROR_INVALID_ARGUMENT );
-}
-
-static inline psa_status_t psa_driver_wrapper_cipher_finish(
- psa_cipher_operation_t *operation,
- uint8_t *output,
- size_t output_size,
- size_t *output_length )
-{
- switch( operation->id )
- {
-#if defined(MBEDTLS_PSA_BUILTIN_CIPHER)
- case PSA_CRYPTO_MBED_TLS_DRIVER_ID:
- return( mbedtls_psa_cipher_finish( &operation->ctx.mbedtls_ctx,
- output,
- output_size,
- output_length ) );
-#endif /* MBEDTLS_PSA_BUILTIN_CIPHER */
-
-#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
-#if defined(PSA_CRYPTO_DRIVER_TEST)
- case MBEDTLS_TEST_TRANSPARENT_DRIVER_ID:
- return( mbedtls_test_transparent_cipher_finish(
- &operation->ctx.transparent_test_driver_ctx,
- output, output_size, output_length ) );
-
- case MBEDTLS_TEST_OPAQUE_DRIVER_ID:
- return( mbedtls_test_opaque_cipher_finish(
- &operation->ctx.opaque_test_driver_ctx,
- output, output_size, output_length ) );
-#endif /* PSA_CRYPTO_DRIVER_TEST */
-#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
- }
-
- (void)output;
- (void)output_size;
- (void)output_length;
-
- return( PSA_ERROR_INVALID_ARGUMENT );
-}
-
-static inline psa_status_t psa_driver_wrapper_cipher_abort(
- psa_cipher_operation_t *operation )
-{
- psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
-
- switch( operation->id )
- {
-#if defined(MBEDTLS_PSA_BUILTIN_CIPHER)
- case PSA_CRYPTO_MBED_TLS_DRIVER_ID:
- return( mbedtls_psa_cipher_abort( &operation->ctx.mbedtls_ctx ) );
-#endif /* MBEDTLS_PSA_BUILTIN_CIPHER */
-
-#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
-#if defined(PSA_CRYPTO_DRIVER_TEST)
- case MBEDTLS_TEST_TRANSPARENT_DRIVER_ID:
- status = mbedtls_test_transparent_cipher_abort(
- &operation->ctx.transparent_test_driver_ctx );
- mbedtls_platform_zeroize(
- &operation->ctx.transparent_test_driver_ctx,
- sizeof( operation->ctx.transparent_test_driver_ctx ) );
- return( status );
-
- case MBEDTLS_TEST_OPAQUE_DRIVER_ID:
- status = mbedtls_test_opaque_cipher_abort(
- &operation->ctx.opaque_test_driver_ctx );
- mbedtls_platform_zeroize(
- &operation->ctx.opaque_test_driver_ctx,
- sizeof( operation->ctx.opaque_test_driver_ctx ) );
- return( status );
-#endif /* PSA_CRYPTO_DRIVER_TEST */
-#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
- }
-
- (void)status;
- return( PSA_ERROR_INVALID_ARGUMENT );
-}
-
-/*
- * Hashing functions
- */
-static inline psa_status_t psa_driver_wrapper_hash_compute(
- psa_algorithm_t alg,
- const uint8_t *input,
- size_t input_length,
- uint8_t *hash,
- size_t hash_size,
- size_t *hash_length)
-{
- psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
-
- /* Try accelerators first */
-#if defined(PSA_CRYPTO_DRIVER_TEST)
- status = mbedtls_test_transparent_hash_compute(
- alg, input, input_length, hash, hash_size, hash_length );
- if( status != PSA_ERROR_NOT_SUPPORTED )
- return( status );
-#endif
-
- /* If software fallback is compiled in, try fallback */
-#if defined(MBEDTLS_PSA_BUILTIN_HASH)
- status = mbedtls_psa_hash_compute( alg, input, input_length,
- hash, hash_size, hash_length );
- if( status != PSA_ERROR_NOT_SUPPORTED )
- return( status );
-#endif
- (void) status;
- (void) alg;
- (void) input;
- (void) input_length;
- (void) hash;
- (void) hash_size;
- (void) hash_length;
-
- return( PSA_ERROR_NOT_SUPPORTED );
-}
-
-static inline psa_status_t psa_driver_wrapper_hash_setup(
- psa_hash_operation_t *operation,
- psa_algorithm_t alg )
-{
- psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
-
- /* Try setup on accelerators first */
-#if defined(PSA_CRYPTO_DRIVER_TEST)
- status = mbedtls_test_transparent_hash_setup(
- &operation->ctx.test_driver_ctx, alg );
- if( status == PSA_SUCCESS )
- operation->id = MBEDTLS_TEST_TRANSPARENT_DRIVER_ID;
-
- if( status != PSA_ERROR_NOT_SUPPORTED )
- return( status );
-#endif
-
- /* If software fallback is compiled in, try fallback */
-#if defined(MBEDTLS_PSA_BUILTIN_HASH)
- status = mbedtls_psa_hash_setup( &operation->ctx.mbedtls_ctx, alg );
- if( status == PSA_SUCCESS )
- operation->id = PSA_CRYPTO_MBED_TLS_DRIVER_ID;
-
- if( status != PSA_ERROR_NOT_SUPPORTED )
- return( status );
-#endif
- /* Nothing left to try if we fall through here */
- (void) status;
- (void) operation;
- (void) alg;
- return( PSA_ERROR_NOT_SUPPORTED );
-}
-
-static inline psa_status_t psa_driver_wrapper_hash_clone(
- const psa_hash_operation_t *source_operation,
- psa_hash_operation_t *target_operation )
-{
- switch( source_operation->id )
- {
-#if defined(MBEDTLS_PSA_BUILTIN_HASH)
- case PSA_CRYPTO_MBED_TLS_DRIVER_ID:
- target_operation->id = PSA_CRYPTO_MBED_TLS_DRIVER_ID;
- return( mbedtls_psa_hash_clone( &source_operation->ctx.mbedtls_ctx,
- &target_operation->ctx.mbedtls_ctx ) );
-#endif
-#if defined(PSA_CRYPTO_DRIVER_TEST)
- case MBEDTLS_TEST_TRANSPARENT_DRIVER_ID:
- target_operation->id = MBEDTLS_TEST_TRANSPARENT_DRIVER_ID;
- return( mbedtls_test_transparent_hash_clone(
- &source_operation->ctx.test_driver_ctx,
- &target_operation->ctx.test_driver_ctx ) );
-#endif
- default:
- (void) target_operation;
- return( PSA_ERROR_BAD_STATE );
- }
-}
-
-static inline psa_status_t psa_driver_wrapper_hash_update(
- psa_hash_operation_t *operation,
- const uint8_t *input,
- size_t input_length )
-{
- switch( operation->id )
- {
-#if defined(MBEDTLS_PSA_BUILTIN_HASH)
- case PSA_CRYPTO_MBED_TLS_DRIVER_ID:
- return( mbedtls_psa_hash_update( &operation->ctx.mbedtls_ctx,
- input, input_length ) );
-#endif
-#if defined(PSA_CRYPTO_DRIVER_TEST)
- case MBEDTLS_TEST_TRANSPARENT_DRIVER_ID:
- return( mbedtls_test_transparent_hash_update(
- &operation->ctx.test_driver_ctx,
- input, input_length ) );
-#endif
- default:
- (void) input;
- (void) input_length;
- return( PSA_ERROR_BAD_STATE );
- }
-}
-
-static inline psa_status_t psa_driver_wrapper_hash_finish(
- psa_hash_operation_t *operation,
- uint8_t *hash,
- size_t hash_size,
- size_t *hash_length )
-{
- switch( operation->id )
- {
-#if defined(MBEDTLS_PSA_BUILTIN_HASH)
- case PSA_CRYPTO_MBED_TLS_DRIVER_ID:
- return( mbedtls_psa_hash_finish( &operation->ctx.mbedtls_ctx,
- hash, hash_size, hash_length ) );
-#endif
-#if defined(PSA_CRYPTO_DRIVER_TEST)
- case MBEDTLS_TEST_TRANSPARENT_DRIVER_ID:
- return( mbedtls_test_transparent_hash_finish(
- &operation->ctx.test_driver_ctx,
- hash, hash_size, hash_length ) );
-#endif
- default:
- (void) hash;
- (void) hash_size;
- (void) hash_length;
- return( PSA_ERROR_BAD_STATE );
- }
-}
-
-static inline psa_status_t psa_driver_wrapper_hash_abort(
- psa_hash_operation_t *operation )
-{
- switch( operation->id )
- {
-#if defined(MBEDTLS_PSA_BUILTIN_HASH)
- case PSA_CRYPTO_MBED_TLS_DRIVER_ID:
- return( mbedtls_psa_hash_abort( &operation->ctx.mbedtls_ctx ) );
-#endif
-#if defined(PSA_CRYPTO_DRIVER_TEST)
- case MBEDTLS_TEST_TRANSPARENT_DRIVER_ID:
- return( mbedtls_test_transparent_hash_abort(
- &operation->ctx.test_driver_ctx ) );
-#endif
- default:
- return( PSA_ERROR_BAD_STATE );
- }
-}
-
-static inline psa_status_t psa_driver_wrapper_aead_encrypt(
- const psa_key_attributes_t *attributes,
- const uint8_t *key_buffer, size_t key_buffer_size,
- psa_algorithm_t alg,
- const uint8_t *nonce, size_t nonce_length,
- const uint8_t *additional_data, size_t additional_data_length,
- const uint8_t *plaintext, size_t plaintext_length,
- uint8_t *ciphertext, size_t ciphertext_size, size_t *ciphertext_length )
-{
- psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
- psa_key_location_t location =
- PSA_KEY_LIFETIME_GET_LOCATION( attributes->core.lifetime );
-
- switch( location )
- {
- case PSA_KEY_LOCATION_LOCAL_STORAGE:
- /* Key is stored in the slot in export representation, so
- * cycle through all known transparent accelerators */
-
-#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
-#if defined(PSA_CRYPTO_DRIVER_TEST)
- status = mbedtls_test_transparent_aead_encrypt(
- attributes, key_buffer, key_buffer_size,
- alg,
- nonce, nonce_length,
- additional_data, additional_data_length,
- plaintext, plaintext_length,
- ciphertext, ciphertext_size, ciphertext_length );
- /* Declared with fallback == true */
- if( status != PSA_ERROR_NOT_SUPPORTED )
- return( status );
-#endif /* PSA_CRYPTO_DRIVER_TEST */
-#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
-
- /* Fell through, meaning no accelerator supports this operation */
- return( mbedtls_psa_aead_encrypt(
- attributes, key_buffer, key_buffer_size,
- alg,
- nonce, nonce_length,
- additional_data, additional_data_length,
- plaintext, plaintext_length,
- ciphertext, ciphertext_size, ciphertext_length ) );
-
- /* Add cases for opaque driver here */
-
- default:
- /* Key is declared with a lifetime not known to us */
- (void)status;
- return( PSA_ERROR_INVALID_ARGUMENT );
- }
-}
-
-static inline psa_status_t psa_driver_wrapper_aead_decrypt(
- const psa_key_attributes_t *attributes,
- const uint8_t *key_buffer, size_t key_buffer_size,
- psa_algorithm_t alg,
- const uint8_t *nonce, size_t nonce_length,
- const uint8_t *additional_data, size_t additional_data_length,
- const uint8_t *ciphertext, size_t ciphertext_length,
- uint8_t *plaintext, size_t plaintext_size, size_t *plaintext_length )
-{
- psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
- psa_key_location_t location =
- PSA_KEY_LIFETIME_GET_LOCATION( attributes->core.lifetime );
-
- switch( location )
- {
- case PSA_KEY_LOCATION_LOCAL_STORAGE:
- /* Key is stored in the slot in export representation, so
- * cycle through all known transparent accelerators */
-
-#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
-#if defined(PSA_CRYPTO_DRIVER_TEST)
- status = mbedtls_test_transparent_aead_decrypt(
- attributes, key_buffer, key_buffer_size,
- alg,
- nonce, nonce_length,
- additional_data, additional_data_length,
- ciphertext, ciphertext_length,
- plaintext, plaintext_size, plaintext_length );
- /* Declared with fallback == true */
- if( status != PSA_ERROR_NOT_SUPPORTED )
- return( status );
-#endif /* PSA_CRYPTO_DRIVER_TEST */
-#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
-
- /* Fell through, meaning no accelerator supports this operation */
- return( mbedtls_psa_aead_decrypt(
- attributes, key_buffer, key_buffer_size,
- alg,
- nonce, nonce_length,
- additional_data, additional_data_length,
- ciphertext, ciphertext_length,
- plaintext, plaintext_size, plaintext_length ) );
-
- /* Add cases for opaque driver here */
-
- default:
- /* Key is declared with a lifetime not known to us */
- (void)status;
- return( PSA_ERROR_INVALID_ARGUMENT );
- }
-}
-
-static inline psa_status_t psa_driver_wrapper_aead_encrypt_setup(
- psa_aead_operation_t *operation,
- const psa_key_attributes_t *attributes,
- const uint8_t *key_buffer, size_t key_buffer_size,
- psa_algorithm_t alg )
-{
- psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
- psa_key_location_t location =
- PSA_KEY_LIFETIME_GET_LOCATION( attributes->core.lifetime );
-
- switch( location )
- {
- case PSA_KEY_LOCATION_LOCAL_STORAGE:
- /* Key is stored in the slot in export representation, so
- * cycle through all known transparent accelerators */
-
-#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
-#if defined(PSA_CRYPTO_DRIVER_TEST)
- operation->id = MBEDTLS_TEST_TRANSPARENT_DRIVER_ID;
- status = mbedtls_test_transparent_aead_encrypt_setup(
- &operation->ctx.transparent_test_driver_ctx,
- attributes, key_buffer, key_buffer_size,
- alg );
-
- /* Declared with fallback == true */
- if( status != PSA_ERROR_NOT_SUPPORTED )
- return( status );
-#endif /* PSA_CRYPTO_DRIVER_TEST */
-#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
-
- /* Fell through, meaning no accelerator supports this operation */
- operation->id = PSA_CRYPTO_MBED_TLS_DRIVER_ID;
- status = mbedtls_psa_aead_encrypt_setup(
- &operation->ctx.mbedtls_ctx, attributes,
- key_buffer, key_buffer_size,
- alg );
-
- return( status );
-
- /* Add cases for opaque driver here */
-
- default:
- /* Key is declared with a lifetime not known to us */
- (void)status;
- return( PSA_ERROR_INVALID_ARGUMENT );
- }
-}
-
-static inline psa_status_t psa_driver_wrapper_aead_decrypt_setup(
- psa_aead_operation_t *operation,
- const psa_key_attributes_t *attributes,
- const uint8_t *key_buffer, size_t key_buffer_size,
- psa_algorithm_t alg )
-{
- psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
- psa_key_location_t location =
- PSA_KEY_LIFETIME_GET_LOCATION( attributes->core.lifetime );
-
- switch( location )
- {
- case PSA_KEY_LOCATION_LOCAL_STORAGE:
- /* Key is stored in the slot in export representation, so
- * cycle through all known transparent accelerators */
-
-#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
-#if defined(PSA_CRYPTO_DRIVER_TEST)
- operation->id = MBEDTLS_TEST_TRANSPARENT_DRIVER_ID;
- status = mbedtls_test_transparent_aead_decrypt_setup(
- &operation->ctx.transparent_test_driver_ctx,
- attributes,
- key_buffer, key_buffer_size,
- alg );
-
- /* Declared with fallback == true */
- if( status != PSA_ERROR_NOT_SUPPORTED )
- return( status );
-#endif /* PSA_CRYPTO_DRIVER_TEST */
-#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
-
- /* Fell through, meaning no accelerator supports this operation */
- operation->id = PSA_CRYPTO_MBED_TLS_DRIVER_ID;
- status = mbedtls_psa_aead_decrypt_setup(
- &operation->ctx.mbedtls_ctx,
- attributes,
- key_buffer, key_buffer_size,
- alg );
-
- return( status );
-
- /* Add cases for opaque driver here */
-
- default:
- /* Key is declared with a lifetime not known to us */
- (void)status;
- return( PSA_ERROR_INVALID_ARGUMENT );
- }
-}
-
-static inline psa_status_t psa_driver_wrapper_aead_set_nonce(
- psa_aead_operation_t *operation,
- const uint8_t *nonce,
- size_t nonce_length )
-{
- switch( operation->id )
- {
-#if defined(MBEDTLS_PSA_BUILTIN_AEAD)
- case PSA_CRYPTO_MBED_TLS_DRIVER_ID:
- return( mbedtls_psa_aead_set_nonce( &operation->ctx.mbedtls_ctx,
- nonce,
- nonce_length ) );
-
-#endif /* MBEDTLS_PSA_BUILTIN_AEAD */
-
-#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
-#if defined(PSA_CRYPTO_DRIVER_TEST)
- case MBEDTLS_TEST_TRANSPARENT_DRIVER_ID:
- return( mbedtls_test_transparent_aead_set_nonce(
- &operation->ctx.transparent_test_driver_ctx,
- nonce, nonce_length ) );
-
- /* Add cases for opaque driver here */
-
-#endif /* PSA_CRYPTO_DRIVER_TEST */
-#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
- }
-
- (void)nonce;
- (void)nonce_length;
-
- return( PSA_ERROR_INVALID_ARGUMENT );
-}
-
-static inline psa_status_t psa_driver_wrapper_aead_set_lengths(
- psa_aead_operation_t *operation,
- size_t ad_length,
- size_t plaintext_length )
-{
- switch( operation->id )
- {
-#if defined(MBEDTLS_PSA_BUILTIN_AEAD)
- case PSA_CRYPTO_MBED_TLS_DRIVER_ID:
- return( mbedtls_psa_aead_set_lengths( &operation->ctx.mbedtls_ctx,
- ad_length,
- plaintext_length ) );
-
-#endif /* MBEDTLS_PSA_BUILTIN_AEAD */
-
-#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
-#if defined(PSA_CRYPTO_DRIVER_TEST)
- case MBEDTLS_TEST_TRANSPARENT_DRIVER_ID:
- return( mbedtls_test_transparent_aead_set_lengths(
- &operation->ctx.transparent_test_driver_ctx,
- ad_length, plaintext_length ) );
-
- /* Add cases for opaque driver here */
-
-#endif /* PSA_CRYPTO_DRIVER_TEST */
-#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
- }
-
- (void)ad_length;
- (void)plaintext_length;
-
- return( PSA_ERROR_INVALID_ARGUMENT );
-}
-
-static inline psa_status_t psa_driver_wrapper_aead_update_ad(
- psa_aead_operation_t *operation,
- const uint8_t *input,
- size_t input_length )
-{
- switch( operation->id )
- {
-#if defined(MBEDTLS_PSA_BUILTIN_AEAD)
- case PSA_CRYPTO_MBED_TLS_DRIVER_ID:
- return( mbedtls_psa_aead_update_ad( &operation->ctx.mbedtls_ctx,
- input,
- input_length ) );
-
-#endif /* MBEDTLS_PSA_BUILTIN_AEAD */
-
-#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
-#if defined(PSA_CRYPTO_DRIVER_TEST)
- case MBEDTLS_TEST_TRANSPARENT_DRIVER_ID:
- return( mbedtls_test_transparent_aead_update_ad(
- &operation->ctx.transparent_test_driver_ctx,
- input, input_length ) );
-
- /* Add cases for opaque driver here */
-
-#endif /* PSA_CRYPTO_DRIVER_TEST */
-#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
- }
-
- (void)input;
- (void)input_length;
-
- return( PSA_ERROR_INVALID_ARGUMENT );
-}
-
-static inline psa_status_t psa_driver_wrapper_aead_update(
- psa_aead_operation_t *operation,
- const uint8_t *input,
- size_t input_length,
- uint8_t *output,
- size_t output_size,
- size_t *output_length )
-{
- switch( operation->id )
- {
-#if defined(MBEDTLS_PSA_BUILTIN_AEAD)
- case PSA_CRYPTO_MBED_TLS_DRIVER_ID:
- return( mbedtls_psa_aead_update( &operation->ctx.mbedtls_ctx,
- input, input_length,
- output, output_size,
- output_length ) );
-
-#endif /* MBEDTLS_PSA_BUILTIN_AEAD */
-
-#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
-#if defined(PSA_CRYPTO_DRIVER_TEST)
- case MBEDTLS_TEST_TRANSPARENT_DRIVER_ID:
- return( mbedtls_test_transparent_aead_update(
- &operation->ctx.transparent_test_driver_ctx,
- input, input_length, output, output_size,
- output_length ) );
-
- /* Add cases for opaque driver here */
-
-#endif /* PSA_CRYPTO_DRIVER_TEST */
-#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
- }
-
- (void)input;
- (void)input_length;
- (void)output;
- (void)output_size;
- (void)output_length;
-
- return( PSA_ERROR_INVALID_ARGUMENT );
-}
-
-static inline psa_status_t psa_driver_wrapper_aead_finish(
- psa_aead_operation_t *operation,
- uint8_t *ciphertext,
- size_t ciphertext_size,
- size_t *ciphertext_length,
- uint8_t *tag,
- size_t tag_size,
- size_t *tag_length )
-{
- switch( operation->id )
- {
-#if defined(MBEDTLS_PSA_BUILTIN_AEAD)
- case PSA_CRYPTO_MBED_TLS_DRIVER_ID:
- return( mbedtls_psa_aead_finish( &operation->ctx.mbedtls_ctx,
- ciphertext,
- ciphertext_size,
- ciphertext_length, tag,
- tag_size, tag_length ) );
-
-#endif /* MBEDTLS_PSA_BUILTIN_AEAD */
-
-#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
-#if defined(PSA_CRYPTO_DRIVER_TEST)
- case MBEDTLS_TEST_TRANSPARENT_DRIVER_ID:
- return( mbedtls_test_transparent_aead_finish(
- &operation->ctx.transparent_test_driver_ctx,
- ciphertext, ciphertext_size,
- ciphertext_length, tag, tag_size, tag_length ) );
-
- /* Add cases for opaque driver here */
-
-#endif /* PSA_CRYPTO_DRIVER_TEST */
-#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
- }
-
- (void)ciphertext;
- (void)ciphertext_size;
- (void)ciphertext_length;
- (void)tag;
- (void)tag_size;
- (void)tag_length;
-
- return( PSA_ERROR_INVALID_ARGUMENT );
-}
-
-static inline psa_status_t psa_driver_wrapper_aead_verify(
- psa_aead_operation_t *operation,
- uint8_t *plaintext,
- size_t plaintext_size,
- size_t *plaintext_length,
- const uint8_t *tag,
- size_t tag_length )
-{
- switch( operation->id )
- {
-#if defined(MBEDTLS_PSA_BUILTIN_AEAD)
- case PSA_CRYPTO_MBED_TLS_DRIVER_ID:
- {
- psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
- uint8_t check_tag[PSA_AEAD_TAG_MAX_SIZE];
- size_t check_tag_length;
-
- status = mbedtls_psa_aead_finish( &operation->ctx.mbedtls_ctx,
- plaintext,
- plaintext_size,
- plaintext_length,
- check_tag,
- sizeof( check_tag ),
- &check_tag_length );
-
- if( status == PSA_SUCCESS )
- {
- if( tag_length != check_tag_length ||
- mbedtls_ct_memcmp( tag, check_tag, tag_length )
- != 0 )
- status = PSA_ERROR_INVALID_SIGNATURE;
- }
-
- mbedtls_platform_zeroize( check_tag, sizeof( check_tag ) );
-
- return( status );
- }
-
-#endif /* MBEDTLS_PSA_BUILTIN_AEAD */
-
-#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
-#if defined(PSA_CRYPTO_DRIVER_TEST)
- case MBEDTLS_TEST_TRANSPARENT_DRIVER_ID:
- return( mbedtls_test_transparent_aead_verify(
- &operation->ctx.transparent_test_driver_ctx,
- plaintext, plaintext_size,
- plaintext_length, tag, tag_length ) );
-
- /* Add cases for opaque driver here */
-
-#endif /* PSA_CRYPTO_DRIVER_TEST */
-#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
- }
-
- (void)plaintext;
- (void)plaintext_size;
- (void)plaintext_length;
- (void)tag;
- (void)tag_length;
-
- return( PSA_ERROR_INVALID_ARGUMENT );
-}
-
-static inline psa_status_t psa_driver_wrapper_aead_abort(
- psa_aead_operation_t *operation )
-{
- switch( operation->id )
- {
-#if defined(MBEDTLS_PSA_BUILTIN_AEAD)
- case PSA_CRYPTO_MBED_TLS_DRIVER_ID:
- return( mbedtls_psa_aead_abort( &operation->ctx.mbedtls_ctx ) );
-
-#endif /* MBEDTLS_PSA_BUILTIN_AEAD */
-
-#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
-#if defined(PSA_CRYPTO_DRIVER_TEST)
- case MBEDTLS_TEST_TRANSPARENT_DRIVER_ID:
- return( mbedtls_test_transparent_aead_abort(
- &operation->ctx.transparent_test_driver_ctx ) );
-
- /* Add cases for opaque driver here */
-
-#endif /* PSA_CRYPTO_DRIVER_TEST */
-#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
- }
-
- return( PSA_ERROR_INVALID_ARGUMENT );
-}
-
-/*
- * MAC functions
- */
-static inline psa_status_t psa_driver_wrapper_mac_compute(
- const psa_key_attributes_t *attributes,
- const uint8_t *key_buffer,
- size_t key_buffer_size,
- psa_algorithm_t alg,
- const uint8_t *input,
- size_t input_length,
- uint8_t *mac,
- size_t mac_size,
- size_t *mac_length )
-{
- psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
- psa_key_location_t location =
- PSA_KEY_LIFETIME_GET_LOCATION( attributes->core.lifetime );
-
- switch( location )
- {
- case PSA_KEY_LOCATION_LOCAL_STORAGE:
- /* Key is stored in the slot in export representation, so
- * cycle through all known transparent accelerators */
-#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
-#if defined(PSA_CRYPTO_DRIVER_TEST)
- status = mbedtls_test_transparent_mac_compute(
- attributes, key_buffer, key_buffer_size, alg,
- input, input_length,
- mac, mac_size, mac_length );
- /* Declared with fallback == true */
- if( status != PSA_ERROR_NOT_SUPPORTED )
- return( status );
-#endif /* PSA_CRYPTO_DRIVER_TEST */
-#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
-#if defined(MBEDTLS_PSA_BUILTIN_MAC)
- /* Fell through, meaning no accelerator supports this operation */
- status = mbedtls_psa_mac_compute(
- attributes, key_buffer, key_buffer_size, alg,
- input, input_length,
- mac, mac_size, mac_length );
- if( status != PSA_ERROR_NOT_SUPPORTED )
- return( status );
-#endif /* MBEDTLS_PSA_BUILTIN_MAC */
- return( PSA_ERROR_NOT_SUPPORTED );
-
- /* Add cases for opaque driver here */
-#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
-#if defined(PSA_CRYPTO_DRIVER_TEST)
- case PSA_CRYPTO_TEST_DRIVER_LOCATION:
- status = mbedtls_test_opaque_mac_compute(
- attributes, key_buffer, key_buffer_size, alg,
- input, input_length,
- mac, mac_size, mac_length );
- return( status );
-#endif /* PSA_CRYPTO_DRIVER_TEST */
-#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
- default:
- /* Key is declared with a lifetime not known to us */
- (void) key_buffer;
- (void) key_buffer_size;
- (void) alg;
- (void) input;
- (void) input_length;
- (void) mac;
- (void) mac_size;
- (void) mac_length;
- (void) status;
- return( PSA_ERROR_INVALID_ARGUMENT );
- }
-}
-
-static inline psa_status_t psa_driver_wrapper_mac_sign_setup(
- psa_mac_operation_t *operation,
- const psa_key_attributes_t *attributes,
- const uint8_t *key_buffer,
- size_t key_buffer_size,
- psa_algorithm_t alg )
-{
- psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
- psa_key_location_t location =
- PSA_KEY_LIFETIME_GET_LOCATION( attributes->core.lifetime );
-
- switch( location )
- {
- case PSA_KEY_LOCATION_LOCAL_STORAGE:
- /* Key is stored in the slot in export representation, so
- * cycle through all known transparent accelerators */
-#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
-#if defined(PSA_CRYPTO_DRIVER_TEST)
- status = mbedtls_test_transparent_mac_sign_setup(
- &operation->ctx.transparent_test_driver_ctx,
- attributes,
- key_buffer, key_buffer_size,
- alg );
- /* Declared with fallback == true */
- if( status == PSA_SUCCESS )
- operation->id = MBEDTLS_TEST_TRANSPARENT_DRIVER_ID;
-
- if( status != PSA_ERROR_NOT_SUPPORTED )
- return( status );
-#endif /* PSA_CRYPTO_DRIVER_TEST */
-#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
-#if defined(MBEDTLS_PSA_BUILTIN_MAC)
- /* Fell through, meaning no accelerator supports this operation */
- status = mbedtls_psa_mac_sign_setup( &operation->ctx.mbedtls_ctx,
- attributes,
- key_buffer, key_buffer_size,
- alg );
- if( status == PSA_SUCCESS )
- operation->id = PSA_CRYPTO_MBED_TLS_DRIVER_ID;
-
- if( status != PSA_ERROR_NOT_SUPPORTED )
- return( status );
-#endif /* MBEDTLS_PSA_BUILTIN_MAC */
- return( PSA_ERROR_NOT_SUPPORTED );
-
- /* Add cases for opaque driver here */
-#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
-#if defined(PSA_CRYPTO_DRIVER_TEST)
- case PSA_CRYPTO_TEST_DRIVER_LOCATION:
- status = mbedtls_test_opaque_mac_sign_setup(
- &operation->ctx.opaque_test_driver_ctx,
- attributes,
- key_buffer, key_buffer_size,
- alg );
-
- if( status == PSA_SUCCESS )
- operation->id = MBEDTLS_TEST_OPAQUE_DRIVER_ID;
-
- return( status );
-#endif /* PSA_CRYPTO_DRIVER_TEST */
-#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
- default:
- /* Key is declared with a lifetime not known to us */
- (void) status;
- (void) operation;
- (void) key_buffer;
- (void) key_buffer_size;
- (void) alg;
- return( PSA_ERROR_INVALID_ARGUMENT );
- }
-}
-
-static inline psa_status_t psa_driver_wrapper_mac_verify_setup(
- psa_mac_operation_t *operation,
- const psa_key_attributes_t *attributes,
- const uint8_t *key_buffer,
- size_t key_buffer_size,
- psa_algorithm_t alg )
-{
- psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
- psa_key_location_t location =
- PSA_KEY_LIFETIME_GET_LOCATION( attributes->core.lifetime );
-
- switch( location )
- {
- case PSA_KEY_LOCATION_LOCAL_STORAGE:
- /* Key is stored in the slot in export representation, so
- * cycle through all known transparent accelerators */
-#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
-#if defined(PSA_CRYPTO_DRIVER_TEST)
- status = mbedtls_test_transparent_mac_verify_setup(
- &operation->ctx.transparent_test_driver_ctx,
- attributes,
- key_buffer, key_buffer_size,
- alg );
- /* Declared with fallback == true */
- if( status == PSA_SUCCESS )
- operation->id = MBEDTLS_TEST_TRANSPARENT_DRIVER_ID;
-
- if( status != PSA_ERROR_NOT_SUPPORTED )
- return( status );
-#endif /* PSA_CRYPTO_DRIVER_TEST */
-#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
-#if defined(MBEDTLS_PSA_BUILTIN_MAC)
- /* Fell through, meaning no accelerator supports this operation */
- status = mbedtls_psa_mac_verify_setup( &operation->ctx.mbedtls_ctx,
- attributes,
- key_buffer, key_buffer_size,
- alg );
- if( status == PSA_SUCCESS )
- operation->id = PSA_CRYPTO_MBED_TLS_DRIVER_ID;
-
- if( status != PSA_ERROR_NOT_SUPPORTED )
- return( status );
-#endif /* MBEDTLS_PSA_BUILTIN_MAC */
- return( PSA_ERROR_NOT_SUPPORTED );
-
- /* Add cases for opaque driver here */
-#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
-#if defined(PSA_CRYPTO_DRIVER_TEST)
- case PSA_CRYPTO_TEST_DRIVER_LOCATION:
- status = mbedtls_test_opaque_mac_verify_setup(
- &operation->ctx.opaque_test_driver_ctx,
- attributes,
- key_buffer, key_buffer_size,
- alg );
-
- if( status == PSA_SUCCESS )
- operation->id = MBEDTLS_TEST_OPAQUE_DRIVER_ID;
-
- return( status );
-#endif /* PSA_CRYPTO_DRIVER_TEST */
-#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
- default:
- /* Key is declared with a lifetime not known to us */
- (void) status;
- (void) operation;
- (void) key_buffer;
- (void) key_buffer_size;
- (void) alg;
- return( PSA_ERROR_INVALID_ARGUMENT );
- }
-}
-
-static inline psa_status_t psa_driver_wrapper_mac_update(
- psa_mac_operation_t *operation,
- const uint8_t *input,
- size_t input_length )
-{
- switch( operation->id )
- {
-#if defined(MBEDTLS_PSA_BUILTIN_MAC)
- case PSA_CRYPTO_MBED_TLS_DRIVER_ID:
- return( mbedtls_psa_mac_update( &operation->ctx.mbedtls_ctx,
- input, input_length ) );
-#endif /* MBEDTLS_PSA_BUILTIN_MAC */
-
-#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
-#if defined(PSA_CRYPTO_DRIVER_TEST)
- case MBEDTLS_TEST_TRANSPARENT_DRIVER_ID:
- return( mbedtls_test_transparent_mac_update(
- &operation->ctx.transparent_test_driver_ctx,
- input, input_length ) );
-
- case MBEDTLS_TEST_OPAQUE_DRIVER_ID:
- return( mbedtls_test_opaque_mac_update(
- &operation->ctx.opaque_test_driver_ctx,
- input, input_length ) );
-#endif /* PSA_CRYPTO_DRIVER_TEST */
-#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
- default:
- (void) input;
- (void) input_length;
- return( PSA_ERROR_INVALID_ARGUMENT );
- }
-}
-
-static inline psa_status_t psa_driver_wrapper_mac_sign_finish(
- psa_mac_operation_t *operation,
- uint8_t *mac,
- size_t mac_size,
- size_t *mac_length )
-{
- switch( operation->id )
- {
-#if defined(MBEDTLS_PSA_BUILTIN_MAC)
- case PSA_CRYPTO_MBED_TLS_DRIVER_ID:
- return( mbedtls_psa_mac_sign_finish( &operation->ctx.mbedtls_ctx,
- mac, mac_size, mac_length ) );
-#endif /* MBEDTLS_PSA_BUILTIN_MAC */
-
-#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
-#if defined(PSA_CRYPTO_DRIVER_TEST)
- case MBEDTLS_TEST_TRANSPARENT_DRIVER_ID:
- return( mbedtls_test_transparent_mac_sign_finish(
- &operation->ctx.transparent_test_driver_ctx,
- mac, mac_size, mac_length ) );
-
- case MBEDTLS_TEST_OPAQUE_DRIVER_ID:
- return( mbedtls_test_opaque_mac_sign_finish(
- &operation->ctx.opaque_test_driver_ctx,
- mac, mac_size, mac_length ) );
-#endif /* PSA_CRYPTO_DRIVER_TEST */
-#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
- default:
- (void) mac;
- (void) mac_size;
- (void) mac_length;
- return( PSA_ERROR_INVALID_ARGUMENT );
- }
-}
-
-static inline psa_status_t psa_driver_wrapper_mac_verify_finish(
- psa_mac_operation_t *operation,
- const uint8_t *mac,
- size_t mac_length )
-{
- switch( operation->id )
- {
-#if defined(MBEDTLS_PSA_BUILTIN_MAC)
- case PSA_CRYPTO_MBED_TLS_DRIVER_ID:
- return( mbedtls_psa_mac_verify_finish( &operation->ctx.mbedtls_ctx,
- mac, mac_length ) );
-#endif /* MBEDTLS_PSA_BUILTIN_MAC */
-
-#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
-#if defined(PSA_CRYPTO_DRIVER_TEST)
- case MBEDTLS_TEST_TRANSPARENT_DRIVER_ID:
- return( mbedtls_test_transparent_mac_verify_finish(
- &operation->ctx.transparent_test_driver_ctx,
- mac, mac_length ) );
-
- case MBEDTLS_TEST_OPAQUE_DRIVER_ID:
- return( mbedtls_test_opaque_mac_verify_finish(
- &operation->ctx.opaque_test_driver_ctx,
- mac, mac_length ) );
-#endif /* PSA_CRYPTO_DRIVER_TEST */
-#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
- default:
- (void) mac;
- (void) mac_length;
- return( PSA_ERROR_INVALID_ARGUMENT );
- }
-}
-
-static inline psa_status_t psa_driver_wrapper_mac_abort(
- psa_mac_operation_t *operation )
-{
- switch( operation->id )
- {
-#if defined(MBEDTLS_PSA_BUILTIN_MAC)
- case PSA_CRYPTO_MBED_TLS_DRIVER_ID:
- return( mbedtls_psa_mac_abort( &operation->ctx.mbedtls_ctx ) );
-#endif /* MBEDTLS_PSA_BUILTIN_MAC */
-
-#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
-#if defined(PSA_CRYPTO_DRIVER_TEST)
- case MBEDTLS_TEST_TRANSPARENT_DRIVER_ID:
- return( mbedtls_test_transparent_mac_abort(
- &operation->ctx.transparent_test_driver_ctx ) );
- case MBEDTLS_TEST_OPAQUE_DRIVER_ID:
- return( mbedtls_test_opaque_mac_abort(
- &operation->ctx.opaque_test_driver_ctx ) );
-#endif /* PSA_CRYPTO_DRIVER_TEST */
-#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
- default:
- return( PSA_ERROR_INVALID_ARGUMENT );
- }
-}
-
-/*
- * Asymmetric cryptography
- */
-static inline psa_status_t psa_driver_wrapper_asymmetric_encrypt(
- const psa_key_attributes_t *attributes, const uint8_t *key_buffer,
- size_t key_buffer_size, psa_algorithm_t alg, const uint8_t *input,
- size_t input_length, const uint8_t *salt, size_t salt_length,
- uint8_t *output, size_t output_size, size_t *output_length )
-{
- psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
- psa_key_location_t location =
- PSA_KEY_LIFETIME_GET_LOCATION( attributes->core.lifetime );
-
- switch( location )
- {
- case PSA_KEY_LOCATION_LOCAL_STORAGE:
- /* Key is stored in the slot in export representation, so
- * cycle through all known transparent accelerators */
-#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
-#if defined(PSA_CRYPTO_DRIVER_TEST)
- status = mbedtls_test_transparent_asymmetric_encrypt( attributes,
- key_buffer, key_buffer_size, alg, input, input_length,
- salt, salt_length, output, output_size,
- output_length );
- /* Declared with fallback == true */
- if( status != PSA_ERROR_NOT_SUPPORTED )
- return( status );
-#endif /* PSA_CRYPTO_DRIVER_TEST */
-#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
- return( mbedtls_psa_asymmetric_encrypt( attributes,
- key_buffer, key_buffer_size, alg, input, input_length,
- salt, salt_length, output, output_size, output_length )
- );
- /* Add cases for opaque driver here */
-#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
-#if defined(PSA_CRYPTO_DRIVER_TEST)
- case PSA_CRYPTO_TEST_DRIVER_LOCATION:
- return( mbedtls_test_opaque_asymmetric_encrypt( attributes,
- key_buffer, key_buffer_size, alg, input, input_length,
- salt, salt_length, output, output_size, output_length )
- );
-#endif /* PSA_CRYPTO_DRIVER_TEST */
-#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
-
- default:
- /* Key is declared with a lifetime not known to us */
- (void)status;
- (void)key_buffer;
- (void)key_buffer_size;
- (void)alg;
- (void)input;
- (void)input_length;
- (void)salt;
- (void)salt_length;
- (void)output;
- (void)output_size;
- (void)output_length;
- return( PSA_ERROR_INVALID_ARGUMENT );
- }
-}
-
-static inline psa_status_t psa_driver_wrapper_asymmetric_decrypt(
- const psa_key_attributes_t *attributes, const uint8_t *key_buffer,
- size_t key_buffer_size, psa_algorithm_t alg, const uint8_t *input,
- size_t input_length, const uint8_t *salt, size_t salt_length,
- uint8_t *output, size_t output_size, size_t *output_length )
-{
- psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
- psa_key_location_t location =
- PSA_KEY_LIFETIME_GET_LOCATION( attributes->core.lifetime );
-
- switch( location )
- {
- case PSA_KEY_LOCATION_LOCAL_STORAGE:
- /* Key is stored in the slot in export representation, so
- * cycle through all known transparent accelerators */
-#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
-#if defined(PSA_CRYPTO_DRIVER_TEST)
- status = mbedtls_test_transparent_asymmetric_decrypt( attributes,
- key_buffer, key_buffer_size, alg, input, input_length,
- salt, salt_length, output, output_size,
- output_length );
- /* Declared with fallback == true */
- if( status != PSA_ERROR_NOT_SUPPORTED )
- return( status );
-#endif /* PSA_CRYPTO_DRIVER_TEST */
-#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
- return( mbedtls_psa_asymmetric_decrypt( attributes,
- key_buffer, key_buffer_size, alg,input, input_length,
- salt, salt_length, output, output_size,
- output_length ) );
- /* Add cases for opaque driver here */
-#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
-#if defined(PSA_CRYPTO_DRIVER_TEST)
- case PSA_CRYPTO_TEST_DRIVER_LOCATION:
- return( mbedtls_test_opaque_asymmetric_decrypt( attributes,
- key_buffer, key_buffer_size, alg, input, input_length,
- salt, salt_length, output, output_size,
- output_length ) );
-#endif /* PSA_CRYPTO_DRIVER_TEST */
-#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
-
- default:
- /* Key is declared with a lifetime not known to us */
- (void)status;
- (void)key_buffer;
- (void)key_buffer_size;
- (void)alg;
- (void)input;
- (void)input_length;
- (void)salt;
- (void)salt_length;
- (void)output;
- (void)output_size;
- (void)output_length;
- return( PSA_ERROR_INVALID_ARGUMENT );
- }
-}
-
-static inline psa_status_t psa_driver_wrapper_key_agreement(
- const psa_key_attributes_t *attributes,
- const uint8_t *key_buffer,
- size_t key_buffer_size,
- psa_algorithm_t alg,
- const uint8_t *peer_key,
- size_t peer_key_length,
- uint8_t *shared_secret,
- size_t shared_secret_size,
- size_t *shared_secret_length
- )
-{
- psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
- psa_key_location_t location =
- PSA_KEY_LIFETIME_GET_LOCATION( attributes->core.lifetime );
-
- switch( location )
- {
- case PSA_KEY_LOCATION_LOCAL_STORAGE:
- /* Key is stored in the slot in export representation, so
- * cycle through all known transparent accelerators */
-#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
-#if defined(PSA_CRYPTO_DRIVER_TEST)
- status =
- mbedtls_test_transparent_key_agreement( attributes,
- key_buffer, key_buffer_size, alg, peer_key,
- peer_key_length, shared_secret, shared_secret_size,
- shared_secret_length );
- if( status != PSA_ERROR_NOT_SUPPORTED )
- return( status );
-#endif /* PSA_CRYPTO_DRIVER_TEST */
-#if defined(MBEDTLS_PSA_P256M_DRIVER_ENABLED)
- if( PSA_KEY_TYPE_IS_ECC( attributes->core.type ) &&
- PSA_ALG_IS_ECDH(alg) &&
- PSA_KEY_TYPE_ECC_GET_FAMILY(attributes->core.type) == PSA_ECC_FAMILY_SECP_R1 &&
- attributes->core.bits == 256 )
- {
- status = p256_transparent_key_agreement( attributes,
- key_buffer,
- key_buffer_size,
- alg,
- peer_key,
- peer_key_length,
- shared_secret,
- shared_secret_size,
- shared_secret_length );
- if( status != PSA_ERROR_NOT_SUPPORTED)
- return( status );
- }
-#endif /* MBEDTLS_PSA_P256M_DRIVER_ENABLED */
-#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
-
- /* Software Fallback */
- status = psa_key_agreement_raw_builtin( attributes,
- key_buffer,
- key_buffer_size,
- alg,
- peer_key,
- peer_key_length,
- shared_secret,
- shared_secret_size,
- shared_secret_length );
- return( status );
-#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
-#if defined(PSA_CRYPTO_DRIVER_TEST)
- case PSA_CRYPTO_TEST_DRIVER_LOCATION:
- return( mbedtls_test_opaque_key_agreement( attributes,
- key_buffer, key_buffer_size, alg, peer_key,
- peer_key_length, shared_secret, shared_secret_size,
- shared_secret_length ) );
-#endif /* PSA_CRYPTO_DRIVER_TEST */
-#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
-
- default:
- (void) attributes;
- (void) key_buffer;
- (void) key_buffer_size;
- (void) peer_key;
- (void) peer_key_length;
- (void) shared_secret;
- (void) shared_secret_size;
- (void) shared_secret_length;
- return( PSA_ERROR_NOT_SUPPORTED );
-
- }
-}
-
-static inline psa_status_t psa_driver_wrapper_pake_setup(
- psa_pake_operation_t *operation,
- const psa_crypto_driver_pake_inputs_t *inputs )
-{
- psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
-
- psa_key_location_t location =
- PSA_KEY_LIFETIME_GET_LOCATION( psa_get_key_lifetime( &inputs->attributes ) );
-
- switch( location )
- {
- case PSA_KEY_LOCATION_LOCAL_STORAGE:
- /* Key is stored in the slot in export representation, so
- * cycle through all known transparent accelerators */
- status = PSA_ERROR_NOT_SUPPORTED;
-#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
-#if defined(PSA_CRYPTO_DRIVER_TEST)
- status = mbedtls_test_transparent_pake_setup(
- &operation->data.ctx.transparent_test_driver_ctx,
- inputs );
- if( status == PSA_SUCCESS )
- operation->id = MBEDTLS_TEST_TRANSPARENT_DRIVER_ID;
- /* Declared with fallback == true */
- if( status != PSA_ERROR_NOT_SUPPORTED )
- return( status );
-#endif /* PSA_CRYPTO_DRIVER_TEST */
-#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
-#if defined(MBEDTLS_PSA_BUILTIN_PAKE)
- status = mbedtls_psa_pake_setup( &operation->data.ctx.mbedtls_ctx,
- inputs );
- if( status == PSA_SUCCESS )
- operation->id = PSA_CRYPTO_MBED_TLS_DRIVER_ID;
-#endif
- return status;
- /* Add cases for opaque driver here */
- default:
- /* Key is declared with a lifetime not known to us */
- (void)operation;
- return( PSA_ERROR_INVALID_ARGUMENT );
- }
-}
-
-static inline psa_status_t psa_driver_wrapper_pake_output(
- psa_pake_operation_t *operation,
- psa_crypto_driver_pake_step_t step,
- uint8_t *output,
- size_t output_size,
- size_t *output_length )
-{
- switch( operation->id )
- {
-#if defined(MBEDTLS_PSA_BUILTIN_PAKE)
- case PSA_CRYPTO_MBED_TLS_DRIVER_ID:
- return( mbedtls_psa_pake_output( &operation->data.ctx.mbedtls_ctx, step,
- output, output_size, output_length ) );
-#endif /* MBEDTLS_PSA_BUILTIN_PAKE */
-
-#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
-#if defined(PSA_CRYPTO_DRIVER_TEST)
- case MBEDTLS_TEST_TRANSPARENT_DRIVER_ID:
- return( mbedtls_test_transparent_pake_output(
- &operation->data.ctx.transparent_test_driver_ctx,
- step, output, output_size, output_length ) );
-#endif /* PSA_CRYPTO_DRIVER_TEST */
-#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
- default:
- (void) step;
- (void) output;
- (void) output_size;
- (void) output_length;
- return( PSA_ERROR_INVALID_ARGUMENT );
- }
-}
-
-static inline psa_status_t psa_driver_wrapper_pake_input(
- psa_pake_operation_t *operation,
- psa_crypto_driver_pake_step_t step,
- const uint8_t *input,
- size_t input_length )
-{
- switch( operation->id )
- {
-#if defined(MBEDTLS_PSA_BUILTIN_PAKE)
- case PSA_CRYPTO_MBED_TLS_DRIVER_ID:
- return( mbedtls_psa_pake_input( &operation->data.ctx.mbedtls_ctx,
- step, input,
- input_length ) );
-#endif /* MBEDTLS_PSA_BUILTIN_PAKE */
-
-#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
-#if defined(PSA_CRYPTO_DRIVER_TEST)
- case MBEDTLS_TEST_TRANSPARENT_DRIVER_ID:
- return( mbedtls_test_transparent_pake_input(
- &operation->data.ctx.transparent_test_driver_ctx,
- step,
- input, input_length ) );
-#endif /* PSA_CRYPTO_DRIVER_TEST */
-#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
- default:
- (void) step;
- (void) input;
- (void) input_length;
- return( PSA_ERROR_INVALID_ARGUMENT );
- }
-}
-
-static inline psa_status_t psa_driver_wrapper_pake_get_implicit_key(
- psa_pake_operation_t *operation,
- uint8_t *output, size_t output_size,
- size_t *output_length )
-{
- switch( operation->id )
- {
-#if defined(MBEDTLS_PSA_BUILTIN_PAKE)
- case PSA_CRYPTO_MBED_TLS_DRIVER_ID:
- return( mbedtls_psa_pake_get_implicit_key( &operation->data.ctx.mbedtls_ctx,
- output, output_size, output_length ) );
-#endif /* MBEDTLS_PSA_BUILTIN_PAKE */
-
-#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
-#if defined(PSA_CRYPTO_DRIVER_TEST)
- case MBEDTLS_TEST_TRANSPARENT_DRIVER_ID:
- return( mbedtls_test_transparent_pake_get_implicit_key(
- &operation->data.ctx.transparent_test_driver_ctx,
- output, output_size, output_length ) );
-#endif /* PSA_CRYPTO_DRIVER_TEST */
-#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
- default:
- (void) output;
- (void) output_size;
- (void) output_length;
- return( PSA_ERROR_INVALID_ARGUMENT );
- }
-}
-
-static inline psa_status_t psa_driver_wrapper_pake_abort(
- psa_pake_operation_t * operation )
-{
- switch( operation->id )
- {
-#if defined(MBEDTLS_PSA_BUILTIN_PAKE)
- case PSA_CRYPTO_MBED_TLS_DRIVER_ID:
- return( mbedtls_psa_pake_abort( &operation->data.ctx.mbedtls_ctx ) );
-#endif /* MBEDTLS_PSA_BUILTIN_PAKE */
-
-#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
-#if defined(PSA_CRYPTO_DRIVER_TEST)
- case MBEDTLS_TEST_TRANSPARENT_DRIVER_ID:
- return( mbedtls_test_transparent_pake_abort(
- &operation->data.ctx.transparent_test_driver_ctx ) );
-#endif /* PSA_CRYPTO_DRIVER_TEST */
-#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
- default:
- return( PSA_ERROR_INVALID_ARGUMENT );
- }
-}
-
-#endif /* MBEDTLS_PSA_CRYPTO_C */
diff --git a/library/psa_crypto_driver_wrappers_no_static.c b/library/psa_crypto_driver_wrappers_no_static.c
deleted file mode 100644
index de1511b..0000000
--- a/library/psa_crypto_driver_wrappers_no_static.c
+++ /dev/null
@@ -1,268 +0,0 @@
-/*
- * Functions to delegate cryptographic operations to an available
- * and appropriate accelerator.
- * Warning: This file is now auto-generated.
- */
-/* Copyright The Mbed TLS Contributors
- * SPDX-License-Identifier: Apache-2.0
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may
- * not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-/* BEGIN-common headers */
-#include "common.h"
-#include "psa_crypto_aead.h"
-#include "psa_crypto_cipher.h"
-#include "psa_crypto_core.h"
-#include "psa_crypto_driver_wrappers_no_static.h"
-#include "psa_crypto_hash.h"
-#include "psa_crypto_mac.h"
-#include "psa_crypto_pake.h"
-#include "psa_crypto_rsa.h"
-
-#include "mbedtls/platform.h"
-/* END-common headers */
-
-#if defined(MBEDTLS_PSA_CRYPTO_C)
-
-/* BEGIN-driver headers */
-/* Headers for mbedtls_test opaque driver */
-#if defined(PSA_CRYPTO_DRIVER_TEST)
-#include "test/drivers/test_driver.h"
-
-#endif
-/* Headers for mbedtls_test transparent driver */
-#if defined(PSA_CRYPTO_DRIVER_TEST)
-#include "test/drivers/test_driver.h"
-
-#endif
-/* Headers for p256 transparent driver */
-#if defined(MBEDTLS_PSA_P256M_DRIVER_ENABLED)
-#include "../3rdparty/p256-m/p256-m_driver_entrypoints.h"
-
-#endif
-
-/* END-driver headers */
-
-/* Auto-generated values depending on which drivers are registered.
- * ID 0 is reserved for unallocated operations.
- * ID 1 is reserved for the Mbed TLS software driver. */
-/* BEGIN-driver id definition */
-#define PSA_CRYPTO_MBED_TLS_DRIVER_ID (1)
-#define MBEDTLS_TEST_OPAQUE_DRIVER_ID (2)
-#define MBEDTLS_TEST_TRANSPARENT_DRIVER_ID (3)
-#define P256_TRANSPARENT_DRIVER_ID (4)
-
-/* END-driver id */
-
-/* BEGIN-Common Macro definitions */
-
-/* END-Common Macro definitions */
-
-/* Support the 'old' SE interface when asked to */
-#if defined(MBEDTLS_PSA_CRYPTO_SE_C)
-/* PSA_CRYPTO_DRIVER_PRESENT is defined when either a new-style or old-style
- * SE driver is present, to avoid unused argument errors at compile time. */
-#ifndef PSA_CRYPTO_DRIVER_PRESENT
-#define PSA_CRYPTO_DRIVER_PRESENT
-#endif
-#include "psa_crypto_se.h"
-#endif
-
-/** Get the key buffer size required to store the key material of a key
- * associated with an opaque driver.
- *
- * \param[in] attributes The key attributes.
- * \param[out] key_buffer_size Minimum buffer size to contain the key material
- *
- * \retval #PSA_SUCCESS
- * The minimum size for a buffer to contain the key material has been
- * returned successfully.
- * \retval #PSA_ERROR_NOT_SUPPORTED
- * The type and/or the size in bits of the key or the combination of
- * the two is not supported.
- * \retval #PSA_ERROR_INVALID_ARGUMENT
- * The key is declared with a lifetime not known to us.
- */
-psa_status_t psa_driver_wrapper_get_key_buffer_size(
- const psa_key_attributes_t *attributes,
- size_t *key_buffer_size )
-{
- psa_key_location_t location = PSA_KEY_LIFETIME_GET_LOCATION( attributes->core.lifetime );
- psa_key_type_t key_type = attributes->core.type;
- size_t key_bits = attributes->core.bits;
-
- *key_buffer_size = 0;
- switch( location )
- {
-#if defined(PSA_CRYPTO_DRIVER_TEST)
- case PSA_CRYPTO_TEST_DRIVER_LOCATION:
-#if defined(MBEDTLS_PSA_CRYPTO_BUILTIN_KEYS)
- /* Emulate property 'builtin_key_size' */
- if( psa_key_id_is_builtin(
- MBEDTLS_SVC_KEY_ID_GET_KEY_ID(
- psa_get_key_id( attributes ) ) ) )
- {
- *key_buffer_size = sizeof( psa_drv_slot_number_t );
- return( PSA_SUCCESS );
- }
-#endif /* MBEDTLS_PSA_CRYPTO_BUILTIN_KEYS */
- *key_buffer_size = mbedtls_test_opaque_size_function( key_type,
- key_bits );
- return( ( *key_buffer_size != 0 ) ?
- PSA_SUCCESS : PSA_ERROR_NOT_SUPPORTED );
-#endif /* PSA_CRYPTO_DRIVER_TEST */
-
- default:
- (void)key_type;
- (void)key_bits;
- return( PSA_ERROR_INVALID_ARGUMENT );
- }
-}
-
-psa_status_t psa_driver_wrapper_export_public_key(
- const psa_key_attributes_t *attributes,
- const uint8_t *key_buffer, size_t key_buffer_size,
- uint8_t *data, size_t data_size, size_t *data_length )
-
-{
-
- psa_status_t status = PSA_ERROR_INVALID_ARGUMENT;
- psa_key_location_t location = PSA_KEY_LIFETIME_GET_LOCATION(
- psa_get_key_lifetime( attributes ) );
-
- /* Try dynamically-registered SE interface first */
-#if defined(MBEDTLS_PSA_CRYPTO_SE_C)
- const psa_drv_se_t *drv;
- psa_drv_se_context_t *drv_context;
-
- if( psa_get_se_driver( attributes->core.lifetime, &drv, &drv_context ) )
- {
- if( ( drv->key_management == NULL ) ||
- ( drv->key_management->p_export_public == NULL ) )
- {
- return( PSA_ERROR_NOT_SUPPORTED );
- }
-
- return( drv->key_management->p_export_public(
- drv_context,
- *( (psa_key_slot_number_t *)key_buffer ),
- data, data_size, data_length ) );
- }
-#endif /* MBEDTLS_PSA_CRYPTO_SE_C */
-
- switch( location )
- {
- case PSA_KEY_LOCATION_LOCAL_STORAGE:
- /* Key is stored in the slot in export representation, so
- * cycle through all known transparent accelerators */
-#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
-
-#if (defined(PSA_CRYPTO_DRIVER_TEST) )
- status = mbedtls_test_transparent_export_public_key
- (attributes,
- key_buffer,
- key_buffer_size,
- data,
- data_size,
- data_length
- );
-
- if( status != PSA_ERROR_NOT_SUPPORTED )
- return( status );
-#endif
-
-#if (defined(MBEDTLS_PSA_P256M_DRIVER_ENABLED) )
- status = p256_transparent_export_public_key
- (attributes,
- key_buffer,
- key_buffer_size,
- data,
- data_size,
- data_length
- );
-
- if( status != PSA_ERROR_NOT_SUPPORTED )
- return( status );
-#endif
-
-
-#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
- /* Fell through, meaning no accelerator supports this operation */
- return( psa_export_public_key_internal( attributes,
- key_buffer,
- key_buffer_size,
- data,
- data_size,
- data_length ) );
-
- /* Add cases for opaque driver here */
-#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
-
-#if (defined(PSA_CRYPTO_DRIVER_TEST) )
- case 0x7fffff:
- return( mbedtls_test_opaque_export_public_key
- (attributes,
- key_buffer,
- key_buffer_size,
- data,
- data_size,
- data_length
- ));
-#endif
-
-
-#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
- default:
- /* Key is declared with a lifetime not known to us */
- return( status );
- }
-
-}
-
-psa_status_t psa_driver_wrapper_get_builtin_key(
- psa_drv_slot_number_t slot_number,
- psa_key_attributes_t *attributes,
- uint8_t *key_buffer, size_t key_buffer_size, size_t *key_buffer_length )
-{
-
- psa_key_location_t location = PSA_KEY_LIFETIME_GET_LOCATION( attributes->core.lifetime );
- switch( location )
- {
-#if defined(PSA_CRYPTO_DRIVER_TEST)
-
-#if (defined(PSA_CRYPTO_DRIVER_TEST) )
- case 0x7fffff:
- return( mbedtls_test_opaque_get_builtin_key
- (slot_number,
- attributes,
- key_buffer,
- key_buffer_size,
- key_buffer_length
- ));
-#endif
-
-
-#endif /* PSA_CRYPTO_DRIVER_TEST */
- default:
- (void) slot_number;
- (void) key_buffer;
- (void) key_buffer_size;
- (void) key_buffer_length;
- return( PSA_ERROR_DOES_NOT_EXIST );
- }
-
-}
-
-#endif /* MBEDTLS_PSA_CRYPTO_C */
diff --git a/library/ssl_debug_helpers_generated.c b/library/ssl_debug_helpers_generated.c
deleted file mode 100644
index a8cca54..0000000
--- a/library/ssl_debug_helpers_generated.c
+++ /dev/null
@@ -1,246 +0,0 @@
-/* Automatically generated by generate_ssl_debug_helpers.py. DO NOT EDIT. */
-
-/**
- * \file ssl_debug_helpers_generated.c
- *
- * \brief Automatically generated helper functions for debugging
- */
-/*
- * Copyright The Mbed TLS Contributors
- * SPDX-License-Identifier: Apache-2.0
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may
- * not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "common.h"
-
-#if defined(MBEDTLS_DEBUG_C)
-
-#include "ssl_debug_helpers.h"
-
-
-const char *mbedtls_ssl_named_group_to_str( uint16_t in )
-{
- switch( in )
- {
- case MBEDTLS_SSL_IANA_TLS_GROUP_SECP192K1:
- return "secp192k1";
- case MBEDTLS_SSL_IANA_TLS_GROUP_SECP192R1:
- return "secp192r1";
- case MBEDTLS_SSL_IANA_TLS_GROUP_SECP224K1:
- return "secp224k1";
- case MBEDTLS_SSL_IANA_TLS_GROUP_SECP224R1:
- return "secp224r1";
- case MBEDTLS_SSL_IANA_TLS_GROUP_SECP256K1:
- return "secp256k1";
- case MBEDTLS_SSL_IANA_TLS_GROUP_SECP256R1:
- return "secp256r1";
- case MBEDTLS_SSL_IANA_TLS_GROUP_SECP384R1:
- return "secp384r1";
- case MBEDTLS_SSL_IANA_TLS_GROUP_SECP521R1:
- return "secp521r1";
- case MBEDTLS_SSL_IANA_TLS_GROUP_BP256R1:
- return "bp256r1";
- case MBEDTLS_SSL_IANA_TLS_GROUP_BP384R1:
- return "bp384r1";
- case MBEDTLS_SSL_IANA_TLS_GROUP_BP512R1:
- return "bp512r1";
- case MBEDTLS_SSL_IANA_TLS_GROUP_X25519:
- return "x25519";
- case MBEDTLS_SSL_IANA_TLS_GROUP_X448:
- return "x448";
- case MBEDTLS_SSL_IANA_TLS_GROUP_FFDHE2048:
- return "ffdhe2048";
- case MBEDTLS_SSL_IANA_TLS_GROUP_FFDHE3072:
- return "ffdhe3072";
- case MBEDTLS_SSL_IANA_TLS_GROUP_FFDHE4096:
- return "ffdhe4096";
- case MBEDTLS_SSL_IANA_TLS_GROUP_FFDHE6144:
- return "ffdhe6144";
- case MBEDTLS_SSL_IANA_TLS_GROUP_FFDHE8192:
- return "ffdhe8192";
- };
-
- return "UNKOWN";
-}
-const char *mbedtls_ssl_sig_alg_to_str( uint16_t in )
-{
- switch( in )
- {
- case MBEDTLS_TLS1_3_SIG_RSA_PKCS1_SHA256:
- return "rsa_pkcs1_sha256";
- case MBEDTLS_TLS1_3_SIG_RSA_PKCS1_SHA384:
- return "rsa_pkcs1_sha384";
- case MBEDTLS_TLS1_3_SIG_RSA_PKCS1_SHA512:
- return "rsa_pkcs1_sha512";
- case MBEDTLS_TLS1_3_SIG_ECDSA_SECP256R1_SHA256:
- return "ecdsa_secp256r1_sha256";
- case MBEDTLS_TLS1_3_SIG_ECDSA_SECP384R1_SHA384:
- return "ecdsa_secp384r1_sha384";
- case MBEDTLS_TLS1_3_SIG_ECDSA_SECP521R1_SHA512:
- return "ecdsa_secp521r1_sha512";
- case MBEDTLS_TLS1_3_SIG_RSA_PSS_RSAE_SHA256:
- return "rsa_pss_rsae_sha256";
- case MBEDTLS_TLS1_3_SIG_RSA_PSS_RSAE_SHA384:
- return "rsa_pss_rsae_sha384";
- case MBEDTLS_TLS1_3_SIG_RSA_PSS_RSAE_SHA512:
- return "rsa_pss_rsae_sha512";
- case MBEDTLS_TLS1_3_SIG_ED25519:
- return "ed25519";
- case MBEDTLS_TLS1_3_SIG_ED448:
- return "ed448";
- case MBEDTLS_TLS1_3_SIG_RSA_PSS_PSS_SHA256:
- return "rsa_pss_pss_sha256";
- case MBEDTLS_TLS1_3_SIG_RSA_PSS_PSS_SHA384:
- return "rsa_pss_pss_sha384";
- case MBEDTLS_TLS1_3_SIG_RSA_PSS_PSS_SHA512:
- return "rsa_pss_pss_sha512";
- case MBEDTLS_TLS1_3_SIG_RSA_PKCS1_SHA1:
- return "rsa_pkcs1_sha1";
- case MBEDTLS_TLS1_3_SIG_ECDSA_SHA1:
- return "ecdsa_sha1";
- case MBEDTLS_TLS1_3_SIG_NONE:
- return "none";
- };
-
- return "UNKNOWN";
-}
-const char *mbedtls_ssl_states_str( mbedtls_ssl_states in )
-{
- switch (in) {
- case MBEDTLS_SSL_HELLO_REQUEST:
- return "MBEDTLS_SSL_HELLO_REQUEST";
- case MBEDTLS_SSL_CLIENT_HELLO:
- return "MBEDTLS_SSL_CLIENT_HELLO";
- case MBEDTLS_SSL_SERVER_HELLO:
- return "MBEDTLS_SSL_SERVER_HELLO";
- case MBEDTLS_SSL_SERVER_CERTIFICATE:
- return "MBEDTLS_SSL_SERVER_CERTIFICATE";
- case MBEDTLS_SSL_SERVER_KEY_EXCHANGE:
- return "MBEDTLS_SSL_SERVER_KEY_EXCHANGE";
- case MBEDTLS_SSL_CERTIFICATE_REQUEST:
- return "MBEDTLS_SSL_CERTIFICATE_REQUEST";
- case MBEDTLS_SSL_SERVER_HELLO_DONE:
- return "MBEDTLS_SSL_SERVER_HELLO_DONE";
- case MBEDTLS_SSL_CLIENT_CERTIFICATE:
- return "MBEDTLS_SSL_CLIENT_CERTIFICATE";
- case MBEDTLS_SSL_CLIENT_KEY_EXCHANGE:
- return "MBEDTLS_SSL_CLIENT_KEY_EXCHANGE";
- case MBEDTLS_SSL_CERTIFICATE_VERIFY:
- return "MBEDTLS_SSL_CERTIFICATE_VERIFY";
- case MBEDTLS_SSL_CLIENT_CHANGE_CIPHER_SPEC:
- return "MBEDTLS_SSL_CLIENT_CHANGE_CIPHER_SPEC";
- case MBEDTLS_SSL_CLIENT_FINISHED:
- return "MBEDTLS_SSL_CLIENT_FINISHED";
- case MBEDTLS_SSL_SERVER_CHANGE_CIPHER_SPEC:
- return "MBEDTLS_SSL_SERVER_CHANGE_CIPHER_SPEC";
- case MBEDTLS_SSL_SERVER_FINISHED:
- return "MBEDTLS_SSL_SERVER_FINISHED";
- case MBEDTLS_SSL_FLUSH_BUFFERS:
- return "MBEDTLS_SSL_FLUSH_BUFFERS";
- case MBEDTLS_SSL_HANDSHAKE_WRAPUP:
- return "MBEDTLS_SSL_HANDSHAKE_WRAPUP";
- case MBEDTLS_SSL_NEW_SESSION_TICKET:
- return "MBEDTLS_SSL_NEW_SESSION_TICKET";
- case MBEDTLS_SSL_SERVER_HELLO_VERIFY_REQUEST_SENT:
- return "MBEDTLS_SSL_SERVER_HELLO_VERIFY_REQUEST_SENT";
- case MBEDTLS_SSL_HELLO_RETRY_REQUEST:
- return "MBEDTLS_SSL_HELLO_RETRY_REQUEST";
- case MBEDTLS_SSL_ENCRYPTED_EXTENSIONS:
- return "MBEDTLS_SSL_ENCRYPTED_EXTENSIONS";
- case MBEDTLS_SSL_END_OF_EARLY_DATA:
- return "MBEDTLS_SSL_END_OF_EARLY_DATA";
- case MBEDTLS_SSL_CLIENT_CERTIFICATE_VERIFY:
- return "MBEDTLS_SSL_CLIENT_CERTIFICATE_VERIFY";
- case MBEDTLS_SSL_CLIENT_CCS_AFTER_SERVER_FINISHED:
- return "MBEDTLS_SSL_CLIENT_CCS_AFTER_SERVER_FINISHED";
- case MBEDTLS_SSL_CLIENT_CCS_BEFORE_2ND_CLIENT_HELLO:
- return "MBEDTLS_SSL_CLIENT_CCS_BEFORE_2ND_CLIENT_HELLO";
- case MBEDTLS_SSL_SERVER_CCS_AFTER_SERVER_HELLO:
- return "MBEDTLS_SSL_SERVER_CCS_AFTER_SERVER_HELLO";
- case MBEDTLS_SSL_CLIENT_CCS_AFTER_CLIENT_HELLO:
- return "MBEDTLS_SSL_CLIENT_CCS_AFTER_CLIENT_HELLO";
- case MBEDTLS_SSL_SERVER_CCS_AFTER_HELLO_RETRY_REQUEST:
- return "MBEDTLS_SSL_SERVER_CCS_AFTER_HELLO_RETRY_REQUEST";
- case MBEDTLS_SSL_HANDSHAKE_OVER:
- return "MBEDTLS_SSL_HANDSHAKE_OVER";
- case MBEDTLS_SSL_TLS1_3_NEW_SESSION_TICKET:
- return "MBEDTLS_SSL_TLS1_3_NEW_SESSION_TICKET";
- case MBEDTLS_SSL_TLS1_3_NEW_SESSION_TICKET_FLUSH:
- return "MBEDTLS_SSL_TLS1_3_NEW_SESSION_TICKET_FLUSH";
- default:
- return "UNKNOWN_VALUE";
- }
-}
-
-const char *mbedtls_ssl_protocol_version_str( mbedtls_ssl_protocol_version in )
-{
- switch (in) {
- case MBEDTLS_SSL_VERSION_UNKNOWN:
- return "MBEDTLS_SSL_VERSION_UNKNOWN";
- case MBEDTLS_SSL_VERSION_TLS1_2:
- return "MBEDTLS_SSL_VERSION_TLS1_2";
- case MBEDTLS_SSL_VERSION_TLS1_3:
- return "MBEDTLS_SSL_VERSION_TLS1_3";
- default:
- return "UNKNOWN_VALUE";
- }
-}
-
-const char *mbedtls_tls_prf_types_str( mbedtls_tls_prf_types in )
-{
- switch (in) {
- case MBEDTLS_SSL_TLS_PRF_NONE:
- return "MBEDTLS_SSL_TLS_PRF_NONE";
- case MBEDTLS_SSL_TLS_PRF_SHA384:
- return "MBEDTLS_SSL_TLS_PRF_SHA384";
- case MBEDTLS_SSL_TLS_PRF_SHA256:
- return "MBEDTLS_SSL_TLS_PRF_SHA256";
- case MBEDTLS_SSL_HKDF_EXPAND_SHA384:
- return "MBEDTLS_SSL_HKDF_EXPAND_SHA384";
- case MBEDTLS_SSL_HKDF_EXPAND_SHA256:
- return "MBEDTLS_SSL_HKDF_EXPAND_SHA256";
- default:
- return "UNKNOWN_VALUE";
- }
-}
-
-const char *mbedtls_ssl_key_export_type_str( mbedtls_ssl_key_export_type in )
-{
- switch (in) {
- case MBEDTLS_SSL_KEY_EXPORT_TLS12_MASTER_SECRET:
- return "MBEDTLS_SSL_KEY_EXPORT_TLS12_MASTER_SECRET";
-#if defined(MBEDTLS_SSL_PROTO_TLS1_3)
- case MBEDTLS_SSL_KEY_EXPORT_TLS1_3_CLIENT_EARLY_SECRET:
- return "MBEDTLS_SSL_KEY_EXPORT_TLS1_3_CLIENT_EARLY_SECRET";
- case MBEDTLS_SSL_KEY_EXPORT_TLS1_3_EARLY_EXPORTER_SECRET:
- return "MBEDTLS_SSL_KEY_EXPORT_TLS1_3_EARLY_EXPORTER_SECRET";
- case MBEDTLS_SSL_KEY_EXPORT_TLS1_3_CLIENT_HANDSHAKE_TRAFFIC_SECRET:
- return "MBEDTLS_SSL_KEY_EXPORT_TLS1_3_CLIENT_HANDSHAKE_TRAFFIC_SECRET";
- case MBEDTLS_SSL_KEY_EXPORT_TLS1_3_SERVER_HANDSHAKE_TRAFFIC_SECRET:
- return "MBEDTLS_SSL_KEY_EXPORT_TLS1_3_SERVER_HANDSHAKE_TRAFFIC_SECRET";
- case MBEDTLS_SSL_KEY_EXPORT_TLS1_3_CLIENT_APPLICATION_TRAFFIC_SECRET:
- return "MBEDTLS_SSL_KEY_EXPORT_TLS1_3_CLIENT_APPLICATION_TRAFFIC_SECRET";
- case MBEDTLS_SSL_KEY_EXPORT_TLS1_3_SERVER_APPLICATION_TRAFFIC_SECRET:
- return "MBEDTLS_SSL_KEY_EXPORT_TLS1_3_SERVER_APPLICATION_TRAFFIC_SECRET";
-#endif
- default:
- return "UNKNOWN_VALUE";
- }
-}
-
-
-
-#endif /* MBEDTLS_DEBUG_C */
-/* End of automatically generated file. */
-
diff --git a/library/version_features.c b/library/version_features.c
deleted file mode 100644
index a89cef9..0000000
--- a/library/version_features.c
+++ /dev/null
@@ -1,838 +0,0 @@
-/*
- * Version feature information
- *
- * Copyright The Mbed TLS Contributors
- * SPDX-License-Identifier: Apache-2.0
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may
- * not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "common.h"
-
-#if defined(MBEDTLS_VERSION_C)
-
-#include "mbedtls/version.h"
-
-#include <string.h>
-
-static const char * const features[] = {
-#if defined(MBEDTLS_VERSION_FEATURES)
- #if defined(MBEDTLS_HAVE_ASM)
- "HAVE_ASM", //no-check-names
-#endif /* MBEDTLS_HAVE_ASM */
-#if defined(MBEDTLS_NO_UDBL_DIVISION)
- "NO_UDBL_DIVISION", //no-check-names
-#endif /* MBEDTLS_NO_UDBL_DIVISION */
-#if defined(MBEDTLS_NO_64BIT_MULTIPLICATION)
- "NO_64BIT_MULTIPLICATION", //no-check-names
-#endif /* MBEDTLS_NO_64BIT_MULTIPLICATION */
-#if defined(MBEDTLS_HAVE_SSE2)
- "HAVE_SSE2", //no-check-names
-#endif /* MBEDTLS_HAVE_SSE2 */
-#if defined(MBEDTLS_HAVE_TIME)
- "HAVE_TIME", //no-check-names
-#endif /* MBEDTLS_HAVE_TIME */
-#if defined(MBEDTLS_HAVE_TIME_DATE)
- "HAVE_TIME_DATE", //no-check-names
-#endif /* MBEDTLS_HAVE_TIME_DATE */
-#if defined(MBEDTLS_PLATFORM_MEMORY)
- "PLATFORM_MEMORY", //no-check-names
-#endif /* MBEDTLS_PLATFORM_MEMORY */
-#if defined(MBEDTLS_PLATFORM_NO_STD_FUNCTIONS)
- "PLATFORM_NO_STD_FUNCTIONS", //no-check-names
-#endif /* MBEDTLS_PLATFORM_NO_STD_FUNCTIONS */
-#if defined(MBEDTLS_PLATFORM_SETBUF_ALT)
- "PLATFORM_SETBUF_ALT", //no-check-names
-#endif /* MBEDTLS_PLATFORM_SETBUF_ALT */
-#if defined(MBEDTLS_PLATFORM_EXIT_ALT)
- "PLATFORM_EXIT_ALT", //no-check-names
-#endif /* MBEDTLS_PLATFORM_EXIT_ALT */
-#if defined(MBEDTLS_PLATFORM_TIME_ALT)
- "PLATFORM_TIME_ALT", //no-check-names
-#endif /* MBEDTLS_PLATFORM_TIME_ALT */
-#if defined(MBEDTLS_PLATFORM_FPRINTF_ALT)
- "PLATFORM_FPRINTF_ALT", //no-check-names
-#endif /* MBEDTLS_PLATFORM_FPRINTF_ALT */
-#if defined(MBEDTLS_PLATFORM_PRINTF_ALT)
- "PLATFORM_PRINTF_ALT", //no-check-names
-#endif /* MBEDTLS_PLATFORM_PRINTF_ALT */
-#if defined(MBEDTLS_PLATFORM_SNPRINTF_ALT)
- "PLATFORM_SNPRINTF_ALT", //no-check-names
-#endif /* MBEDTLS_PLATFORM_SNPRINTF_ALT */
-#if defined(MBEDTLS_PLATFORM_VSNPRINTF_ALT)
- "PLATFORM_VSNPRINTF_ALT", //no-check-names
-#endif /* MBEDTLS_PLATFORM_VSNPRINTF_ALT */
-#if defined(MBEDTLS_PLATFORM_NV_SEED_ALT)
- "PLATFORM_NV_SEED_ALT", //no-check-names
-#endif /* MBEDTLS_PLATFORM_NV_SEED_ALT */
-#if defined(MBEDTLS_PLATFORM_SETUP_TEARDOWN_ALT)
- "PLATFORM_SETUP_TEARDOWN_ALT", //no-check-names
-#endif /* MBEDTLS_PLATFORM_SETUP_TEARDOWN_ALT */
-#if defined(MBEDTLS_PLATFORM_MS_TIME_ALT)
- "PLATFORM_MS_TIME_ALT", //no-check-names
-#endif /* MBEDTLS_PLATFORM_MS_TIME_ALT */
-#if defined(MBEDTLS_PLATFORM_GMTIME_R_ALT)
- "PLATFORM_GMTIME_R_ALT", //no-check-names
-#endif /* MBEDTLS_PLATFORM_GMTIME_R_ALT */
-#if defined(MBEDTLS_PLATFORM_ZEROIZE_ALT)
- "PLATFORM_ZEROIZE_ALT", //no-check-names
-#endif /* MBEDTLS_PLATFORM_ZEROIZE_ALT */
-#if defined(MBEDTLS_DEPRECATED_WARNING)
- "DEPRECATED_WARNING", //no-check-names
-#endif /* MBEDTLS_DEPRECATED_WARNING */
-#if defined(MBEDTLS_DEPRECATED_REMOVED)
- "DEPRECATED_REMOVED", //no-check-names
-#endif /* MBEDTLS_DEPRECATED_REMOVED */
-#if defined(MBEDTLS_TIMING_ALT)
- "TIMING_ALT", //no-check-names
-#endif /* MBEDTLS_TIMING_ALT */
-#if defined(MBEDTLS_AES_ALT)
- "AES_ALT", //no-check-names
-#endif /* MBEDTLS_AES_ALT */
-#if defined(MBEDTLS_ARIA_ALT)
- "ARIA_ALT", //no-check-names
-#endif /* MBEDTLS_ARIA_ALT */
-#if defined(MBEDTLS_CAMELLIA_ALT)
- "CAMELLIA_ALT", //no-check-names
-#endif /* MBEDTLS_CAMELLIA_ALT */
-#if defined(MBEDTLS_CCM_ALT)
- "CCM_ALT", //no-check-names
-#endif /* MBEDTLS_CCM_ALT */
-#if defined(MBEDTLS_CHACHA20_ALT)
- "CHACHA20_ALT", //no-check-names
-#endif /* MBEDTLS_CHACHA20_ALT */
-#if defined(MBEDTLS_CHACHAPOLY_ALT)
- "CHACHAPOLY_ALT", //no-check-names
-#endif /* MBEDTLS_CHACHAPOLY_ALT */
-#if defined(MBEDTLS_CMAC_ALT)
- "CMAC_ALT", //no-check-names
-#endif /* MBEDTLS_CMAC_ALT */
-#if defined(MBEDTLS_DES_ALT)
- "DES_ALT", //no-check-names
-#endif /* MBEDTLS_DES_ALT */
-#if defined(MBEDTLS_DHM_ALT)
- "DHM_ALT", //no-check-names
-#endif /* MBEDTLS_DHM_ALT */
-#if defined(MBEDTLS_ECJPAKE_ALT)
- "ECJPAKE_ALT", //no-check-names
-#endif /* MBEDTLS_ECJPAKE_ALT */
-#if defined(MBEDTLS_GCM_ALT)
- "GCM_ALT", //no-check-names
-#endif /* MBEDTLS_GCM_ALT */
-#if defined(MBEDTLS_NIST_KW_ALT)
- "NIST_KW_ALT", //no-check-names
-#endif /* MBEDTLS_NIST_KW_ALT */
-#if defined(MBEDTLS_MD5_ALT)
- "MD5_ALT", //no-check-names
-#endif /* MBEDTLS_MD5_ALT */
-#if defined(MBEDTLS_POLY1305_ALT)
- "POLY1305_ALT", //no-check-names
-#endif /* MBEDTLS_POLY1305_ALT */
-#if defined(MBEDTLS_RIPEMD160_ALT)
- "RIPEMD160_ALT", //no-check-names
-#endif /* MBEDTLS_RIPEMD160_ALT */
-#if defined(MBEDTLS_RSA_ALT)
- "RSA_ALT", //no-check-names
-#endif /* MBEDTLS_RSA_ALT */
-#if defined(MBEDTLS_SHA1_ALT)
- "SHA1_ALT", //no-check-names
-#endif /* MBEDTLS_SHA1_ALT */
-#if defined(MBEDTLS_SHA256_ALT)
- "SHA256_ALT", //no-check-names
-#endif /* MBEDTLS_SHA256_ALT */
-#if defined(MBEDTLS_SHA512_ALT)
- "SHA512_ALT", //no-check-names
-#endif /* MBEDTLS_SHA512_ALT */
-#if defined(MBEDTLS_ECP_ALT)
- "ECP_ALT", //no-check-names
-#endif /* MBEDTLS_ECP_ALT */
-#if defined(MBEDTLS_MD5_PROCESS_ALT)
- "MD5_PROCESS_ALT", //no-check-names
-#endif /* MBEDTLS_MD5_PROCESS_ALT */
-#if defined(MBEDTLS_RIPEMD160_PROCESS_ALT)
- "RIPEMD160_PROCESS_ALT", //no-check-names
-#endif /* MBEDTLS_RIPEMD160_PROCESS_ALT */
-#if defined(MBEDTLS_SHA1_PROCESS_ALT)
- "SHA1_PROCESS_ALT", //no-check-names
-#endif /* MBEDTLS_SHA1_PROCESS_ALT */
-#if defined(MBEDTLS_SHA256_PROCESS_ALT)
- "SHA256_PROCESS_ALT", //no-check-names
-#endif /* MBEDTLS_SHA256_PROCESS_ALT */
-#if defined(MBEDTLS_SHA512_PROCESS_ALT)
- "SHA512_PROCESS_ALT", //no-check-names
-#endif /* MBEDTLS_SHA512_PROCESS_ALT */
-#if defined(MBEDTLS_DES_SETKEY_ALT)
- "DES_SETKEY_ALT", //no-check-names
-#endif /* MBEDTLS_DES_SETKEY_ALT */
-#if defined(MBEDTLS_DES_CRYPT_ECB_ALT)
- "DES_CRYPT_ECB_ALT", //no-check-names
-#endif /* MBEDTLS_DES_CRYPT_ECB_ALT */
-#if defined(MBEDTLS_DES3_CRYPT_ECB_ALT)
- "DES3_CRYPT_ECB_ALT", //no-check-names
-#endif /* MBEDTLS_DES3_CRYPT_ECB_ALT */
-#if defined(MBEDTLS_AES_SETKEY_ENC_ALT)
- "AES_SETKEY_ENC_ALT", //no-check-names
-#endif /* MBEDTLS_AES_SETKEY_ENC_ALT */
-#if defined(MBEDTLS_AES_SETKEY_DEC_ALT)
- "AES_SETKEY_DEC_ALT", //no-check-names
-#endif /* MBEDTLS_AES_SETKEY_DEC_ALT */
-#if defined(MBEDTLS_AES_ENCRYPT_ALT)
- "AES_ENCRYPT_ALT", //no-check-names
-#endif /* MBEDTLS_AES_ENCRYPT_ALT */
-#if defined(MBEDTLS_AES_DECRYPT_ALT)
- "AES_DECRYPT_ALT", //no-check-names
-#endif /* MBEDTLS_AES_DECRYPT_ALT */
-#if defined(MBEDTLS_ECDH_GEN_PUBLIC_ALT)
- "ECDH_GEN_PUBLIC_ALT", //no-check-names
-#endif /* MBEDTLS_ECDH_GEN_PUBLIC_ALT */
-#if defined(MBEDTLS_ECDH_COMPUTE_SHARED_ALT)
- "ECDH_COMPUTE_SHARED_ALT", //no-check-names
-#endif /* MBEDTLS_ECDH_COMPUTE_SHARED_ALT */
-#if defined(MBEDTLS_ECDSA_VERIFY_ALT)
- "ECDSA_VERIFY_ALT", //no-check-names
-#endif /* MBEDTLS_ECDSA_VERIFY_ALT */
-#if defined(MBEDTLS_ECDSA_SIGN_ALT)
- "ECDSA_SIGN_ALT", //no-check-names
-#endif /* MBEDTLS_ECDSA_SIGN_ALT */
-#if defined(MBEDTLS_ECDSA_GENKEY_ALT)
- "ECDSA_GENKEY_ALT", //no-check-names
-#endif /* MBEDTLS_ECDSA_GENKEY_ALT */
-#if defined(MBEDTLS_ECP_INTERNAL_ALT)
- "ECP_INTERNAL_ALT", //no-check-names
-#endif /* MBEDTLS_ECP_INTERNAL_ALT */
-#if defined(MBEDTLS_ECP_NO_FALLBACK)
- "ECP_NO_FALLBACK", //no-check-names
-#endif /* MBEDTLS_ECP_NO_FALLBACK */
-#if defined(MBEDTLS_ECP_RANDOMIZE_JAC_ALT)
- "ECP_RANDOMIZE_JAC_ALT", //no-check-names
-#endif /* MBEDTLS_ECP_RANDOMIZE_JAC_ALT */
-#if defined(MBEDTLS_ECP_ADD_MIXED_ALT)
- "ECP_ADD_MIXED_ALT", //no-check-names
-#endif /* MBEDTLS_ECP_ADD_MIXED_ALT */
-#if defined(MBEDTLS_ECP_DOUBLE_JAC_ALT)
- "ECP_DOUBLE_JAC_ALT", //no-check-names
-#endif /* MBEDTLS_ECP_DOUBLE_JAC_ALT */
-#if defined(MBEDTLS_ECP_NORMALIZE_JAC_MANY_ALT)
- "ECP_NORMALIZE_JAC_MANY_ALT", //no-check-names
-#endif /* MBEDTLS_ECP_NORMALIZE_JAC_MANY_ALT */
-#if defined(MBEDTLS_ECP_NORMALIZE_JAC_ALT)
- "ECP_NORMALIZE_JAC_ALT", //no-check-names
-#endif /* MBEDTLS_ECP_NORMALIZE_JAC_ALT */
-#if defined(MBEDTLS_ECP_DOUBLE_ADD_MXZ_ALT)
- "ECP_DOUBLE_ADD_MXZ_ALT", //no-check-names
-#endif /* MBEDTLS_ECP_DOUBLE_ADD_MXZ_ALT */
-#if defined(MBEDTLS_ECP_RANDOMIZE_MXZ_ALT)
- "ECP_RANDOMIZE_MXZ_ALT", //no-check-names
-#endif /* MBEDTLS_ECP_RANDOMIZE_MXZ_ALT */
-#if defined(MBEDTLS_ECP_NORMALIZE_MXZ_ALT)
- "ECP_NORMALIZE_MXZ_ALT", //no-check-names
-#endif /* MBEDTLS_ECP_NORMALIZE_MXZ_ALT */
-#if defined(MBEDTLS_ENTROPY_HARDWARE_ALT)
- "ENTROPY_HARDWARE_ALT", //no-check-names
-#endif /* MBEDTLS_ENTROPY_HARDWARE_ALT */
-#if defined(MBEDTLS_AES_ROM_TABLES)
- "AES_ROM_TABLES", //no-check-names
-#endif /* MBEDTLS_AES_ROM_TABLES */
-#if defined(MBEDTLS_AES_FEWER_TABLES)
- "AES_FEWER_TABLES", //no-check-names
-#endif /* MBEDTLS_AES_FEWER_TABLES */
-#if defined(MBEDTLS_AES_ONLY_128_BIT_KEY_LENGTH)
- "AES_ONLY_128_BIT_KEY_LENGTH", //no-check-names
-#endif /* MBEDTLS_AES_ONLY_128_BIT_KEY_LENGTH */
-#if defined(MBEDTLS_AES_USE_HARDWARE_ONLY)
- "AES_USE_HARDWARE_ONLY", //no-check-names
-#endif /* MBEDTLS_AES_USE_HARDWARE_ONLY */
-#if defined(MBEDTLS_CAMELLIA_SMALL_MEMORY)
- "CAMELLIA_SMALL_MEMORY", //no-check-names
-#endif /* MBEDTLS_CAMELLIA_SMALL_MEMORY */
-#if defined(MBEDTLS_CHECK_RETURN_WARNING)
- "CHECK_RETURN_WARNING", //no-check-names
-#endif /* MBEDTLS_CHECK_RETURN_WARNING */
-#if defined(MBEDTLS_CIPHER_MODE_CBC)
- "CIPHER_MODE_CBC", //no-check-names
-#endif /* MBEDTLS_CIPHER_MODE_CBC */
-#if defined(MBEDTLS_CIPHER_MODE_CFB)
- "CIPHER_MODE_CFB", //no-check-names
-#endif /* MBEDTLS_CIPHER_MODE_CFB */
-#if defined(MBEDTLS_CIPHER_MODE_CTR)
- "CIPHER_MODE_CTR", //no-check-names
-#endif /* MBEDTLS_CIPHER_MODE_CTR */
-#if defined(MBEDTLS_CIPHER_MODE_OFB)
- "CIPHER_MODE_OFB", //no-check-names
-#endif /* MBEDTLS_CIPHER_MODE_OFB */
-#if defined(MBEDTLS_CIPHER_MODE_XTS)
- "CIPHER_MODE_XTS", //no-check-names
-#endif /* MBEDTLS_CIPHER_MODE_XTS */
-#if defined(MBEDTLS_CIPHER_NULL_CIPHER)
- "CIPHER_NULL_CIPHER", //no-check-names
-#endif /* MBEDTLS_CIPHER_NULL_CIPHER */
-#if defined(MBEDTLS_CIPHER_PADDING_PKCS7)
- "CIPHER_PADDING_PKCS7", //no-check-names
-#endif /* MBEDTLS_CIPHER_PADDING_PKCS7 */
-#if defined(MBEDTLS_CIPHER_PADDING_ONE_AND_ZEROS)
- "CIPHER_PADDING_ONE_AND_ZEROS", //no-check-names
-#endif /* MBEDTLS_CIPHER_PADDING_ONE_AND_ZEROS */
-#if defined(MBEDTLS_CIPHER_PADDING_ZEROS_AND_LEN)
- "CIPHER_PADDING_ZEROS_AND_LEN", //no-check-names
-#endif /* MBEDTLS_CIPHER_PADDING_ZEROS_AND_LEN */
-#if defined(MBEDTLS_CIPHER_PADDING_ZEROS)
- "CIPHER_PADDING_ZEROS", //no-check-names
-#endif /* MBEDTLS_CIPHER_PADDING_ZEROS */
-#if defined(MBEDTLS_CTR_DRBG_USE_128_BIT_KEY)
- "CTR_DRBG_USE_128_BIT_KEY", //no-check-names
-#endif /* MBEDTLS_CTR_DRBG_USE_128_BIT_KEY */
-#if defined(MBEDTLS_ECDH_VARIANT_EVEREST_ENABLED)
- "ECDH_VARIANT_EVEREST_ENABLED", //no-check-names
-#endif /* MBEDTLS_ECDH_VARIANT_EVEREST_ENABLED */
-#if defined(MBEDTLS_ECP_DP_SECP192R1_ENABLED)
- "ECP_DP_SECP192R1_ENABLED", //no-check-names
-#endif /* MBEDTLS_ECP_DP_SECP192R1_ENABLED */
-#if defined(MBEDTLS_ECP_DP_SECP224R1_ENABLED)
- "ECP_DP_SECP224R1_ENABLED", //no-check-names
-#endif /* MBEDTLS_ECP_DP_SECP224R1_ENABLED */
-#if defined(MBEDTLS_ECP_DP_SECP256R1_ENABLED)
- "ECP_DP_SECP256R1_ENABLED", //no-check-names
-#endif /* MBEDTLS_ECP_DP_SECP256R1_ENABLED */
-#if defined(MBEDTLS_ECP_DP_SECP384R1_ENABLED)
- "ECP_DP_SECP384R1_ENABLED", //no-check-names
-#endif /* MBEDTLS_ECP_DP_SECP384R1_ENABLED */
-#if defined(MBEDTLS_ECP_DP_SECP521R1_ENABLED)
- "ECP_DP_SECP521R1_ENABLED", //no-check-names
-#endif /* MBEDTLS_ECP_DP_SECP521R1_ENABLED */
-#if defined(MBEDTLS_ECP_DP_SECP192K1_ENABLED)
- "ECP_DP_SECP192K1_ENABLED", //no-check-names
-#endif /* MBEDTLS_ECP_DP_SECP192K1_ENABLED */
-#if defined(MBEDTLS_ECP_DP_SECP224K1_ENABLED)
- "ECP_DP_SECP224K1_ENABLED", //no-check-names
-#endif /* MBEDTLS_ECP_DP_SECP224K1_ENABLED */
-#if defined(MBEDTLS_ECP_DP_SECP256K1_ENABLED)
- "ECP_DP_SECP256K1_ENABLED", //no-check-names
-#endif /* MBEDTLS_ECP_DP_SECP256K1_ENABLED */
-#if defined(MBEDTLS_ECP_DP_BP256R1_ENABLED)
- "ECP_DP_BP256R1_ENABLED", //no-check-names
-#endif /* MBEDTLS_ECP_DP_BP256R1_ENABLED */
-#if defined(MBEDTLS_ECP_DP_BP384R1_ENABLED)
- "ECP_DP_BP384R1_ENABLED", //no-check-names
-#endif /* MBEDTLS_ECP_DP_BP384R1_ENABLED */
-#if defined(MBEDTLS_ECP_DP_BP512R1_ENABLED)
- "ECP_DP_BP512R1_ENABLED", //no-check-names
-#endif /* MBEDTLS_ECP_DP_BP512R1_ENABLED */
-#if defined(MBEDTLS_ECP_DP_CURVE25519_ENABLED)
- "ECP_DP_CURVE25519_ENABLED", //no-check-names
-#endif /* MBEDTLS_ECP_DP_CURVE25519_ENABLED */
-#if defined(MBEDTLS_ECP_DP_CURVE448_ENABLED)
- "ECP_DP_CURVE448_ENABLED", //no-check-names
-#endif /* MBEDTLS_ECP_DP_CURVE448_ENABLED */
-#if defined(MBEDTLS_ECP_NIST_OPTIM)
- "ECP_NIST_OPTIM", //no-check-names
-#endif /* MBEDTLS_ECP_NIST_OPTIM */
-#if defined(MBEDTLS_ECP_RESTARTABLE)
- "ECP_RESTARTABLE", //no-check-names
-#endif /* MBEDTLS_ECP_RESTARTABLE */
-#if defined(MBEDTLS_ECP_WITH_MPI_UINT)
- "ECP_WITH_MPI_UINT", //no-check-names
-#endif /* MBEDTLS_ECP_WITH_MPI_UINT */
-#if defined(MBEDTLS_ECDSA_DETERMINISTIC)
- "ECDSA_DETERMINISTIC", //no-check-names
-#endif /* MBEDTLS_ECDSA_DETERMINISTIC */
-#if defined(MBEDTLS_KEY_EXCHANGE_PSK_ENABLED)
- "KEY_EXCHANGE_PSK_ENABLED", //no-check-names
-#endif /* MBEDTLS_KEY_EXCHANGE_PSK_ENABLED */
-#if defined(MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED)
- "KEY_EXCHANGE_DHE_PSK_ENABLED", //no-check-names
-#endif /* MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED */
-#if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED)
- "KEY_EXCHANGE_ECDHE_PSK_ENABLED", //no-check-names
-#endif /* MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED */
-#if defined(MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED)
- "KEY_EXCHANGE_RSA_PSK_ENABLED", //no-check-names
-#endif /* MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED */
-#if defined(MBEDTLS_KEY_EXCHANGE_RSA_ENABLED)
- "KEY_EXCHANGE_RSA_ENABLED", //no-check-names
-#endif /* MBEDTLS_KEY_EXCHANGE_RSA_ENABLED */
-#if defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED)
- "KEY_EXCHANGE_DHE_RSA_ENABLED", //no-check-names
-#endif /* MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED */
-#if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED)
- "KEY_EXCHANGE_ECDHE_RSA_ENABLED", //no-check-names
-#endif /* MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED */
-#if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED)
- "KEY_EXCHANGE_ECDHE_ECDSA_ENABLED", //no-check-names
-#endif /* MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED */
-#if defined(MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED)
- "KEY_EXCHANGE_ECDH_ECDSA_ENABLED", //no-check-names
-#endif /* MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED */
-#if defined(MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED)
- "KEY_EXCHANGE_ECDH_RSA_ENABLED", //no-check-names
-#endif /* MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED */
-#if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED)
- "KEY_EXCHANGE_ECJPAKE_ENABLED", //no-check-names
-#endif /* MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED */
-#if defined(MBEDTLS_PK_PARSE_EC_EXTENDED)
- "PK_PARSE_EC_EXTENDED", //no-check-names
-#endif /* MBEDTLS_PK_PARSE_EC_EXTENDED */
-#if defined(MBEDTLS_PK_PARSE_EC_COMPRESSED)
- "PK_PARSE_EC_COMPRESSED", //no-check-names
-#endif /* MBEDTLS_PK_PARSE_EC_COMPRESSED */
-#if defined(MBEDTLS_ERROR_STRERROR_DUMMY)
- "ERROR_STRERROR_DUMMY", //no-check-names
-#endif /* MBEDTLS_ERROR_STRERROR_DUMMY */
-#if defined(MBEDTLS_GENPRIME)
- "GENPRIME", //no-check-names
-#endif /* MBEDTLS_GENPRIME */
-#if defined(MBEDTLS_FS_IO)
- "FS_IO", //no-check-names
-#endif /* MBEDTLS_FS_IO */
-#if defined(MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES)
- "NO_DEFAULT_ENTROPY_SOURCES", //no-check-names
-#endif /* MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES */
-#if defined(MBEDTLS_NO_PLATFORM_ENTROPY)
- "NO_PLATFORM_ENTROPY", //no-check-names
-#endif /* MBEDTLS_NO_PLATFORM_ENTROPY */
-#if defined(MBEDTLS_ENTROPY_FORCE_SHA256)
- "ENTROPY_FORCE_SHA256", //no-check-names
-#endif /* MBEDTLS_ENTROPY_FORCE_SHA256 */
-#if defined(MBEDTLS_ENTROPY_NV_SEED)
- "ENTROPY_NV_SEED", //no-check-names
-#endif /* MBEDTLS_ENTROPY_NV_SEED */
-#if defined(MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER)
- "PSA_CRYPTO_KEY_ID_ENCODES_OWNER", //no-check-names
-#endif /* MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER */
-#if defined(MBEDTLS_MEMORY_DEBUG)
- "MEMORY_DEBUG", //no-check-names
-#endif /* MBEDTLS_MEMORY_DEBUG */
-#if defined(MBEDTLS_MEMORY_BACKTRACE)
- "MEMORY_BACKTRACE", //no-check-names
-#endif /* MBEDTLS_MEMORY_BACKTRACE */
-#if defined(MBEDTLS_PK_RSA_ALT_SUPPORT)
- "PK_RSA_ALT_SUPPORT", //no-check-names
-#endif /* MBEDTLS_PK_RSA_ALT_SUPPORT */
-#if defined(MBEDTLS_PKCS1_V15)
- "PKCS1_V15", //no-check-names
-#endif /* MBEDTLS_PKCS1_V15 */
-#if defined(MBEDTLS_PKCS1_V21)
- "PKCS1_V21", //no-check-names
-#endif /* MBEDTLS_PKCS1_V21 */
-#if defined(MBEDTLS_PSA_CRYPTO_BUILTIN_KEYS)
- "PSA_CRYPTO_BUILTIN_KEYS", //no-check-names
-#endif /* MBEDTLS_PSA_CRYPTO_BUILTIN_KEYS */
-#if defined(MBEDTLS_PSA_CRYPTO_CLIENT)
- "PSA_CRYPTO_CLIENT", //no-check-names
-#endif /* MBEDTLS_PSA_CRYPTO_CLIENT */
-#if defined(MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG)
- "PSA_CRYPTO_EXTERNAL_RNG", //no-check-names
-#endif /* MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG */
-#if defined(MBEDTLS_PSA_CRYPTO_SPM)
- "PSA_CRYPTO_SPM", //no-check-names
-#endif /* MBEDTLS_PSA_CRYPTO_SPM */
-#if defined(MBEDTLS_PSA_P256M_DRIVER_ENABLED)
- "PSA_P256M_DRIVER_ENABLED", //no-check-names
-#endif /* MBEDTLS_PSA_P256M_DRIVER_ENABLED */
-#if defined(MBEDTLS_PSA_INJECT_ENTROPY)
- "PSA_INJECT_ENTROPY", //no-check-names
-#endif /* MBEDTLS_PSA_INJECT_ENTROPY */
-#if defined(MBEDTLS_RSA_NO_CRT)
- "RSA_NO_CRT", //no-check-names
-#endif /* MBEDTLS_RSA_NO_CRT */
-#if defined(MBEDTLS_SELF_TEST)
- "SELF_TEST", //no-check-names
-#endif /* MBEDTLS_SELF_TEST */
-#if defined(MBEDTLS_SHA256_SMALLER)
- "SHA256_SMALLER", //no-check-names
-#endif /* MBEDTLS_SHA256_SMALLER */
-#if defined(MBEDTLS_SHA512_SMALLER)
- "SHA512_SMALLER", //no-check-names
-#endif /* MBEDTLS_SHA512_SMALLER */
-#if defined(MBEDTLS_SSL_ALL_ALERT_MESSAGES)
- "SSL_ALL_ALERT_MESSAGES", //no-check-names
-#endif /* MBEDTLS_SSL_ALL_ALERT_MESSAGES */
-#if defined(MBEDTLS_SSL_DTLS_CONNECTION_ID)
- "SSL_DTLS_CONNECTION_ID", //no-check-names
-#endif /* MBEDTLS_SSL_DTLS_CONNECTION_ID */
-#if defined(MBEDTLS_SSL_DTLS_CONNECTION_ID_COMPAT)
- "SSL_DTLS_CONNECTION_ID_COMPAT", //no-check-names
-#endif /* MBEDTLS_SSL_DTLS_CONNECTION_ID_COMPAT */
-#if defined(MBEDTLS_SSL_ASYNC_PRIVATE)
- "SSL_ASYNC_PRIVATE", //no-check-names
-#endif /* MBEDTLS_SSL_ASYNC_PRIVATE */
-#if defined(MBEDTLS_SSL_CONTEXT_SERIALIZATION)
- "SSL_CONTEXT_SERIALIZATION", //no-check-names
-#endif /* MBEDTLS_SSL_CONTEXT_SERIALIZATION */
-#if defined(MBEDTLS_SSL_DEBUG_ALL)
- "SSL_DEBUG_ALL", //no-check-names
-#endif /* MBEDTLS_SSL_DEBUG_ALL */
-#if defined(MBEDTLS_SSL_ENCRYPT_THEN_MAC)
- "SSL_ENCRYPT_THEN_MAC", //no-check-names
-#endif /* MBEDTLS_SSL_ENCRYPT_THEN_MAC */
-#if defined(MBEDTLS_SSL_EXTENDED_MASTER_SECRET)
- "SSL_EXTENDED_MASTER_SECRET", //no-check-names
-#endif /* MBEDTLS_SSL_EXTENDED_MASTER_SECRET */
-#if defined(MBEDTLS_SSL_KEEP_PEER_CERTIFICATE)
- "SSL_KEEP_PEER_CERTIFICATE", //no-check-names
-#endif /* MBEDTLS_SSL_KEEP_PEER_CERTIFICATE */
-#if defined(MBEDTLS_SSL_RENEGOTIATION)
- "SSL_RENEGOTIATION", //no-check-names
-#endif /* MBEDTLS_SSL_RENEGOTIATION */
-#if defined(MBEDTLS_SSL_MAX_FRAGMENT_LENGTH)
- "SSL_MAX_FRAGMENT_LENGTH", //no-check-names
-#endif /* MBEDTLS_SSL_MAX_FRAGMENT_LENGTH */
-#if defined(MBEDTLS_SSL_RECORD_SIZE_LIMIT)
- "SSL_RECORD_SIZE_LIMIT", //no-check-names
-#endif /* MBEDTLS_SSL_RECORD_SIZE_LIMIT */
-#if defined(MBEDTLS_SSL_PROTO_TLS1_2)
- "SSL_PROTO_TLS1_2", //no-check-names
-#endif /* MBEDTLS_SSL_PROTO_TLS1_2 */
-#if defined(MBEDTLS_SSL_PROTO_TLS1_3)
- "SSL_PROTO_TLS1_3", //no-check-names
-#endif /* MBEDTLS_SSL_PROTO_TLS1_3 */
-#if defined(MBEDTLS_SSL_TLS1_3_COMPATIBILITY_MODE)
- "SSL_TLS1_3_COMPATIBILITY_MODE", //no-check-names
-#endif /* MBEDTLS_SSL_TLS1_3_COMPATIBILITY_MODE */
-#if defined(MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_PSK_ENABLED)
- "SSL_TLS1_3_KEY_EXCHANGE_MODE_PSK_ENABLED", //no-check-names
-#endif /* MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_PSK_ENABLED */
-#if defined(MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_EPHEMERAL_ENABLED)
- "SSL_TLS1_3_KEY_EXCHANGE_MODE_EPHEMERAL_ENABLED", //no-check-names
-#endif /* MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_EPHEMERAL_ENABLED */
-#if defined(MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_PSK_EPHEMERAL_ENABLED)
- "SSL_TLS1_3_KEY_EXCHANGE_MODE_PSK_EPHEMERAL_ENABLED", //no-check-names
-#endif /* MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_PSK_EPHEMERAL_ENABLED */
-#if defined(MBEDTLS_SSL_EARLY_DATA)
- "SSL_EARLY_DATA", //no-check-names
-#endif /* MBEDTLS_SSL_EARLY_DATA */
-#if defined(MBEDTLS_SSL_PROTO_DTLS)
- "SSL_PROTO_DTLS", //no-check-names
-#endif /* MBEDTLS_SSL_PROTO_DTLS */
-#if defined(MBEDTLS_SSL_ALPN)
- "SSL_ALPN", //no-check-names
-#endif /* MBEDTLS_SSL_ALPN */
-#if defined(MBEDTLS_SSL_DTLS_ANTI_REPLAY)
- "SSL_DTLS_ANTI_REPLAY", //no-check-names
-#endif /* MBEDTLS_SSL_DTLS_ANTI_REPLAY */
-#if defined(MBEDTLS_SSL_DTLS_HELLO_VERIFY)
- "SSL_DTLS_HELLO_VERIFY", //no-check-names
-#endif /* MBEDTLS_SSL_DTLS_HELLO_VERIFY */
-#if defined(MBEDTLS_SSL_DTLS_SRTP)
- "SSL_DTLS_SRTP", //no-check-names
-#endif /* MBEDTLS_SSL_DTLS_SRTP */
-#if defined(MBEDTLS_SSL_DTLS_CLIENT_PORT_REUSE)
- "SSL_DTLS_CLIENT_PORT_REUSE", //no-check-names
-#endif /* MBEDTLS_SSL_DTLS_CLIENT_PORT_REUSE */
-#if defined(MBEDTLS_SSL_SESSION_TICKETS)
- "SSL_SESSION_TICKETS", //no-check-names
-#endif /* MBEDTLS_SSL_SESSION_TICKETS */
-#if defined(MBEDTLS_SSL_SERVER_NAME_INDICATION)
- "SSL_SERVER_NAME_INDICATION", //no-check-names
-#endif /* MBEDTLS_SSL_SERVER_NAME_INDICATION */
-#if defined(MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH)
- "SSL_VARIABLE_BUFFER_LENGTH", //no-check-names
-#endif /* MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH */
-#if defined(MBEDTLS_TEST_CONSTANT_FLOW_MEMSAN)
- "TEST_CONSTANT_FLOW_MEMSAN", //no-check-names
-#endif /* MBEDTLS_TEST_CONSTANT_FLOW_MEMSAN */
-#if defined(MBEDTLS_TEST_CONSTANT_FLOW_VALGRIND)
- "TEST_CONSTANT_FLOW_VALGRIND", //no-check-names
-#endif /* MBEDTLS_TEST_CONSTANT_FLOW_VALGRIND */
-#if defined(MBEDTLS_TEST_HOOKS)
- "TEST_HOOKS", //no-check-names
-#endif /* MBEDTLS_TEST_HOOKS */
-#if defined(MBEDTLS_THREADING_ALT)
- "THREADING_ALT", //no-check-names
-#endif /* MBEDTLS_THREADING_ALT */
-#if defined(MBEDTLS_THREADING_PTHREAD)
- "THREADING_PTHREAD", //no-check-names
-#endif /* MBEDTLS_THREADING_PTHREAD */
-#if defined(MBEDTLS_USE_PSA_CRYPTO)
- "USE_PSA_CRYPTO", //no-check-names
-#endif /* MBEDTLS_USE_PSA_CRYPTO */
-#if defined(MBEDTLS_PSA_CRYPTO_CONFIG)
- "PSA_CRYPTO_CONFIG", //no-check-names
-#endif /* MBEDTLS_PSA_CRYPTO_CONFIG */
-#if defined(MBEDTLS_VERSION_FEATURES)
- "VERSION_FEATURES", //no-check-names
-#endif /* MBEDTLS_VERSION_FEATURES */
-#if defined(MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK)
- "X509_TRUSTED_CERTIFICATE_CALLBACK", //no-check-names
-#endif /* MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK */
-#if defined(MBEDTLS_X509_REMOVE_INFO)
- "X509_REMOVE_INFO", //no-check-names
-#endif /* MBEDTLS_X509_REMOVE_INFO */
-#if defined(MBEDTLS_X509_RSASSA_PSS_SUPPORT)
- "X509_RSASSA_PSS_SUPPORT", //no-check-names
-#endif /* MBEDTLS_X509_RSASSA_PSS_SUPPORT */
-#if defined(MBEDTLS_AESNI_C)
- "AESNI_C", //no-check-names
-#endif /* MBEDTLS_AESNI_C */
-#if defined(MBEDTLS_AESCE_C)
- "AESCE_C", //no-check-names
-#endif /* MBEDTLS_AESCE_C */
-#if defined(MBEDTLS_AES_C)
- "AES_C", //no-check-names
-#endif /* MBEDTLS_AES_C */
-#if defined(MBEDTLS_ASN1_PARSE_C)
- "ASN1_PARSE_C", //no-check-names
-#endif /* MBEDTLS_ASN1_PARSE_C */
-#if defined(MBEDTLS_ASN1_WRITE_C)
- "ASN1_WRITE_C", //no-check-names
-#endif /* MBEDTLS_ASN1_WRITE_C */
-#if defined(MBEDTLS_BASE64_C)
- "BASE64_C", //no-check-names
-#endif /* MBEDTLS_BASE64_C */
-#if defined(MBEDTLS_BIGNUM_C)
- "BIGNUM_C", //no-check-names
-#endif /* MBEDTLS_BIGNUM_C */
-#if defined(MBEDTLS_CAMELLIA_C)
- "CAMELLIA_C", //no-check-names
-#endif /* MBEDTLS_CAMELLIA_C */
-#if defined(MBEDTLS_ARIA_C)
- "ARIA_C", //no-check-names
-#endif /* MBEDTLS_ARIA_C */
-#if defined(MBEDTLS_CCM_C)
- "CCM_C", //no-check-names
-#endif /* MBEDTLS_CCM_C */
-#if defined(MBEDTLS_CHACHA20_C)
- "CHACHA20_C", //no-check-names
-#endif /* MBEDTLS_CHACHA20_C */
-#if defined(MBEDTLS_CHACHAPOLY_C)
- "CHACHAPOLY_C", //no-check-names
-#endif /* MBEDTLS_CHACHAPOLY_C */
-#if defined(MBEDTLS_CIPHER_C)
- "CIPHER_C", //no-check-names
-#endif /* MBEDTLS_CIPHER_C */
-#if defined(MBEDTLS_CMAC_C)
- "CMAC_C", //no-check-names
-#endif /* MBEDTLS_CMAC_C */
-#if defined(MBEDTLS_CTR_DRBG_C)
- "CTR_DRBG_C", //no-check-names
-#endif /* MBEDTLS_CTR_DRBG_C */
-#if defined(MBEDTLS_DEBUG_C)
- "DEBUG_C", //no-check-names
-#endif /* MBEDTLS_DEBUG_C */
-#if defined(MBEDTLS_DES_C)
- "DES_C", //no-check-names
-#endif /* MBEDTLS_DES_C */
-#if defined(MBEDTLS_DHM_C)
- "DHM_C", //no-check-names
-#endif /* MBEDTLS_DHM_C */
-#if defined(MBEDTLS_ECDH_C)
- "ECDH_C", //no-check-names
-#endif /* MBEDTLS_ECDH_C */
-#if defined(MBEDTLS_ECDSA_C)
- "ECDSA_C", //no-check-names
-#endif /* MBEDTLS_ECDSA_C */
-#if defined(MBEDTLS_ECJPAKE_C)
- "ECJPAKE_C", //no-check-names
-#endif /* MBEDTLS_ECJPAKE_C */
-#if defined(MBEDTLS_ECP_C)
- "ECP_C", //no-check-names
-#endif /* MBEDTLS_ECP_C */
-#if defined(MBEDTLS_ENTROPY_C)
- "ENTROPY_C", //no-check-names
-#endif /* MBEDTLS_ENTROPY_C */
-#if defined(MBEDTLS_ERROR_C)
- "ERROR_C", //no-check-names
-#endif /* MBEDTLS_ERROR_C */
-#if defined(MBEDTLS_GCM_C)
- "GCM_C", //no-check-names
-#endif /* MBEDTLS_GCM_C */
-#if defined(MBEDTLS_HKDF_C)
- "HKDF_C", //no-check-names
-#endif /* MBEDTLS_HKDF_C */
-#if defined(MBEDTLS_HMAC_DRBG_C)
- "HMAC_DRBG_C", //no-check-names
-#endif /* MBEDTLS_HMAC_DRBG_C */
-#if defined(MBEDTLS_LMS_C)
- "LMS_C", //no-check-names
-#endif /* MBEDTLS_LMS_C */
-#if defined(MBEDTLS_LMS_PRIVATE)
- "LMS_PRIVATE", //no-check-names
-#endif /* MBEDTLS_LMS_PRIVATE */
-#if defined(MBEDTLS_NIST_KW_C)
- "NIST_KW_C", //no-check-names
-#endif /* MBEDTLS_NIST_KW_C */
-#if defined(MBEDTLS_MD_C)
- "MD_C", //no-check-names
-#endif /* MBEDTLS_MD_C */
-#if defined(MBEDTLS_MD5_C)
- "MD5_C", //no-check-names
-#endif /* MBEDTLS_MD5_C */
-#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C)
- "MEMORY_BUFFER_ALLOC_C", //no-check-names
-#endif /* MBEDTLS_MEMORY_BUFFER_ALLOC_C */
-#if defined(MBEDTLS_NET_C)
- "NET_C", //no-check-names
-#endif /* MBEDTLS_NET_C */
-#if defined(MBEDTLS_OID_C)
- "OID_C", //no-check-names
-#endif /* MBEDTLS_OID_C */
-#if defined(MBEDTLS_PADLOCK_C)
- "PADLOCK_C", //no-check-names
-#endif /* MBEDTLS_PADLOCK_C */
-#if defined(MBEDTLS_PEM_PARSE_C)
- "PEM_PARSE_C", //no-check-names
-#endif /* MBEDTLS_PEM_PARSE_C */
-#if defined(MBEDTLS_PEM_WRITE_C)
- "PEM_WRITE_C", //no-check-names
-#endif /* MBEDTLS_PEM_WRITE_C */
-#if defined(MBEDTLS_PK_C)
- "PK_C", //no-check-names
-#endif /* MBEDTLS_PK_C */
-#if defined(MBEDTLS_PK_PARSE_C)
- "PK_PARSE_C", //no-check-names
-#endif /* MBEDTLS_PK_PARSE_C */
-#if defined(MBEDTLS_PK_WRITE_C)
- "PK_WRITE_C", //no-check-names
-#endif /* MBEDTLS_PK_WRITE_C */
-#if defined(MBEDTLS_PKCS5_C)
- "PKCS5_C", //no-check-names
-#endif /* MBEDTLS_PKCS5_C */
-#if defined(MBEDTLS_PKCS7_C)
- "PKCS7_C", //no-check-names
-#endif /* MBEDTLS_PKCS7_C */
-#if defined(MBEDTLS_PKCS12_C)
- "PKCS12_C", //no-check-names
-#endif /* MBEDTLS_PKCS12_C */
-#if defined(MBEDTLS_PLATFORM_C)
- "PLATFORM_C", //no-check-names
-#endif /* MBEDTLS_PLATFORM_C */
-#if defined(MBEDTLS_POLY1305_C)
- "POLY1305_C", //no-check-names
-#endif /* MBEDTLS_POLY1305_C */
-#if defined(MBEDTLS_PSA_CRYPTO_C)
- "PSA_CRYPTO_C", //no-check-names
-#endif /* MBEDTLS_PSA_CRYPTO_C */
-#if defined(MBEDTLS_PSA_CRYPTO_SE_C)
- "PSA_CRYPTO_SE_C", //no-check-names
-#endif /* MBEDTLS_PSA_CRYPTO_SE_C */
-#if defined(MBEDTLS_PSA_CRYPTO_STORAGE_C)
- "PSA_CRYPTO_STORAGE_C", //no-check-names
-#endif /* MBEDTLS_PSA_CRYPTO_STORAGE_C */
-#if defined(MBEDTLS_PSA_ITS_FILE_C)
- "PSA_ITS_FILE_C", //no-check-names
-#endif /* MBEDTLS_PSA_ITS_FILE_C */
-#if defined(MBEDTLS_RIPEMD160_C)
- "RIPEMD160_C", //no-check-names
-#endif /* MBEDTLS_RIPEMD160_C */
-#if defined(MBEDTLS_RSA_C)
- "RSA_C", //no-check-names
-#endif /* MBEDTLS_RSA_C */
-#if defined(MBEDTLS_SHA1_C)
- "SHA1_C", //no-check-names
-#endif /* MBEDTLS_SHA1_C */
-#if defined(MBEDTLS_SHA224_C)
- "SHA224_C", //no-check-names
-#endif /* MBEDTLS_SHA224_C */
-#if defined(MBEDTLS_SHA256_C)
- "SHA256_C", //no-check-names
-#endif /* MBEDTLS_SHA256_C */
-#if defined(MBEDTLS_SHA256_USE_A64_CRYPTO_IF_PRESENT)
- "SHA256_USE_A64_CRYPTO_IF_PRESENT", //no-check-names
-#endif /* MBEDTLS_SHA256_USE_A64_CRYPTO_IF_PRESENT */
-#if defined(MBEDTLS_SHA256_USE_A64_CRYPTO_ONLY)
- "SHA256_USE_A64_CRYPTO_ONLY", //no-check-names
-#endif /* MBEDTLS_SHA256_USE_A64_CRYPTO_ONLY */
-#if defined(MBEDTLS_SHA384_C)
- "SHA384_C", //no-check-names
-#endif /* MBEDTLS_SHA384_C */
-#if defined(MBEDTLS_SHA512_C)
- "SHA512_C", //no-check-names
-#endif /* MBEDTLS_SHA512_C */
-#if defined(MBEDTLS_SHA3_C)
- "SHA3_C", //no-check-names
-#endif /* MBEDTLS_SHA3_C */
-#if defined(MBEDTLS_SHA512_USE_A64_CRYPTO_IF_PRESENT)
- "SHA512_USE_A64_CRYPTO_IF_PRESENT", //no-check-names
-#endif /* MBEDTLS_SHA512_USE_A64_CRYPTO_IF_PRESENT */
-#if defined(MBEDTLS_SHA512_USE_A64_CRYPTO_ONLY)
- "SHA512_USE_A64_CRYPTO_ONLY", //no-check-names
-#endif /* MBEDTLS_SHA512_USE_A64_CRYPTO_ONLY */
-#if defined(MBEDTLS_SSL_CACHE_C)
- "SSL_CACHE_C", //no-check-names
-#endif /* MBEDTLS_SSL_CACHE_C */
-#if defined(MBEDTLS_SSL_COOKIE_C)
- "SSL_COOKIE_C", //no-check-names
-#endif /* MBEDTLS_SSL_COOKIE_C */
-#if defined(MBEDTLS_SSL_TICKET_C)
- "SSL_TICKET_C", //no-check-names
-#endif /* MBEDTLS_SSL_TICKET_C */
-#if defined(MBEDTLS_SSL_CLI_C)
- "SSL_CLI_C", //no-check-names
-#endif /* MBEDTLS_SSL_CLI_C */
-#if defined(MBEDTLS_SSL_SRV_C)
- "SSL_SRV_C", //no-check-names
-#endif /* MBEDTLS_SSL_SRV_C */
-#if defined(MBEDTLS_SSL_TLS_C)
- "SSL_TLS_C", //no-check-names
-#endif /* MBEDTLS_SSL_TLS_C */
-#if defined(MBEDTLS_THREADING_C)
- "THREADING_C", //no-check-names
-#endif /* MBEDTLS_THREADING_C */
-#if defined(MBEDTLS_TIMING_C)
- "TIMING_C", //no-check-names
-#endif /* MBEDTLS_TIMING_C */
-#if defined(MBEDTLS_VERSION_C)
- "VERSION_C", //no-check-names
-#endif /* MBEDTLS_VERSION_C */
-#if defined(MBEDTLS_X509_USE_C)
- "X509_USE_C", //no-check-names
-#endif /* MBEDTLS_X509_USE_C */
-#if defined(MBEDTLS_X509_CRT_PARSE_C)
- "X509_CRT_PARSE_C", //no-check-names
-#endif /* MBEDTLS_X509_CRT_PARSE_C */
-#if defined(MBEDTLS_X509_CRL_PARSE_C)
- "X509_CRL_PARSE_C", //no-check-names
-#endif /* MBEDTLS_X509_CRL_PARSE_C */
-#if defined(MBEDTLS_X509_CSR_PARSE_C)
- "X509_CSR_PARSE_C", //no-check-names
-#endif /* MBEDTLS_X509_CSR_PARSE_C */
-#if defined(MBEDTLS_X509_CREATE_C)
- "X509_CREATE_C", //no-check-names
-#endif /* MBEDTLS_X509_CREATE_C */
-#if defined(MBEDTLS_X509_CRT_WRITE_C)
- "X509_CRT_WRITE_C", //no-check-names
-#endif /* MBEDTLS_X509_CRT_WRITE_C */
-#if defined(MBEDTLS_X509_CSR_WRITE_C)
- "X509_CSR_WRITE_C", //no-check-names
-#endif /* MBEDTLS_X509_CSR_WRITE_C */
-#endif /* MBEDTLS_VERSION_FEATURES */
- NULL
-};
-
-int mbedtls_version_check_feature(const char *feature)
-{
- const char * const *idx = features;
-
- if (*idx == NULL) {
- return -2;
- }
-
- if (feature == NULL) {
- return -1;
- }
-
- if (strncmp(feature, "MBEDTLS_", 8)) {
- return -1;
- }
-
- feature += 8;
-
- while (*idx != NULL) {
- if (!strcmp(*idx, feature)) {
- return 0;
- }
- idx++;
- }
- return -1;
-}
-
-#endif /* MBEDTLS_VERSION_C */