mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2026-01-06 11:41:12 +03:00
Merge branch 'development' into convert_NO_SHA384_to_positive
Conflicts: library/version_features.c programs/test/query_config.c Files were removed in development branch and modified by current branch. Conflicts fixes by removing them.
This commit is contained in:
4
library/.gitignore
vendored
4
library/.gitignore
vendored
@@ -2,3 +2,7 @@
|
||||
libmbed*
|
||||
*.sln
|
||||
*.vcxproj
|
||||
|
||||
# Automatically generated files
|
||||
/error.c
|
||||
/version_features.c
|
||||
|
||||
@@ -68,6 +68,7 @@ set(src_crypto
|
||||
psa_crypto_driver_wrappers.c
|
||||
psa_crypto_ecp.c
|
||||
psa_crypto_hash.c
|
||||
psa_crypto_mac.c
|
||||
psa_crypto_rsa.c
|
||||
psa_crypto_se.c
|
||||
psa_crypto_slot_management.c
|
||||
|
||||
@@ -22,6 +22,8 @@ endif
|
||||
# To compile on Plan9:
|
||||
# CFLAGS += -D_BSD_EXTENSION
|
||||
|
||||
PERL ?= perl
|
||||
|
||||
# if were running on Windows build for Windows
|
||||
ifdef WINDOWS
|
||||
WINDOWS_BUILD=1
|
||||
@@ -125,6 +127,7 @@ OBJS_CRYPTO= \
|
||||
psa_crypto_driver_wrappers.o \
|
||||
psa_crypto_ecp.o \
|
||||
psa_crypto_hash.o \
|
||||
psa_crypto_mac.o \
|
||||
psa_crypto_rsa.o \
|
||||
psa_crypto_se.o \
|
||||
psa_crypto_slot_management.o \
|
||||
@@ -270,6 +273,29 @@ libmbedcrypto.dll: $(OBJS_CRYPTO)
|
||||
echo " CC $<"
|
||||
$(CC) $(LOCAL_CFLAGS) $(CFLAGS) -o $@ -c $<
|
||||
|
||||
.PHONY: generated_files
|
||||
GENERATED_FILES = error.c version_features.c
|
||||
generated_files: $(GENERATED_FILES)
|
||||
|
||||
error.c: ../scripts/generate_errors.pl
|
||||
error.c: ../scripts/data_files/error.fmt
|
||||
error.c: $(filter-out %config%,$(wildcard ../include/mbedtls/*.h))
|
||||
error.c:
|
||||
echo " Gen $@"
|
||||
$(PERL) ../scripts/generate_errors.pl
|
||||
|
||||
version_features.c: ../scripts/generate_features.pl
|
||||
version_features.c: ../scripts/data_files/version_features.fmt
|
||||
## The generated file only depends on the options that are present in config.h,
|
||||
## not on which options are set. To avoid regenerating this file all the time
|
||||
## when switching between configurations, don't declare config.h as a
|
||||
## dependency. Remove this file from your working tree if you've just added or
|
||||
## removed an option in config.h.
|
||||
#version_features.c: ../include/mbedtls/config.h
|
||||
version_features.c:
|
||||
echo " Gen $@"
|
||||
$(PERL) ../scripts/generate_features.pl
|
||||
|
||||
clean:
|
||||
ifndef WINDOWS
|
||||
rm -f *.o libmbed*
|
||||
@@ -279,3 +305,10 @@ else
|
||||
if exist libmbed* del /Q /F libmbed*
|
||||
del /Q /F del_errors_out_if_the_file_list_is_empty_but_not_if_a_file_does_not_exist $(subst /,\,$(THIRDPARTY_CRYPTO_OBJECTS))
|
||||
endif
|
||||
|
||||
neat: clean
|
||||
ifndef WINDOWS
|
||||
rm -f $(GENERATED_FILES)
|
||||
else
|
||||
for %f in ($(subst /,\,$(GENERATED_FILES))) if exist %f del /Q /F %f
|
||||
endif
|
||||
|
||||
@@ -21,12 +21,6 @@
|
||||
|
||||
#if defined(MBEDTLS_ENTROPY_C)
|
||||
|
||||
#if defined(MBEDTLS_TEST_NULL_ENTROPY)
|
||||
#warning "**** WARNING! MBEDTLS_TEST_NULL_ENTROPY defined! "
|
||||
#warning "**** THIS BUILD HAS NO DEFINED ENTROPY SOURCES "
|
||||
#warning "**** THIS BUILD IS *NOT* SUITABLE FOR PRODUCTION USE "
|
||||
#endif
|
||||
|
||||
#include "mbedtls/entropy.h"
|
||||
#include "entropy_poll.h"
|
||||
#include "mbedtls/platform_util.h"
|
||||
@@ -73,11 +67,6 @@ void mbedtls_entropy_init( mbedtls_entropy_context *ctx )
|
||||
/* Reminder: Update ENTROPY_HAVE_STRONG in the test files
|
||||
* when adding more strong entropy sources here. */
|
||||
|
||||
#if defined(MBEDTLS_TEST_NULL_ENTROPY)
|
||||
mbedtls_entropy_add_source( ctx, mbedtls_null_entropy_poll, NULL,
|
||||
1, MBEDTLS_ENTROPY_SOURCE_STRONG );
|
||||
#endif
|
||||
|
||||
#if !defined(MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES)
|
||||
#if !defined(MBEDTLS_NO_PLATFORM_ENTROPY)
|
||||
mbedtls_entropy_add_source( ctx, mbedtls_platform_entropy_poll, NULL,
|
||||
@@ -524,7 +513,6 @@ int mbedtls_entropy_update_seed_file( mbedtls_entropy_context *ctx, const char *
|
||||
#endif /* MBEDTLS_FS_IO */
|
||||
|
||||
#if defined(MBEDTLS_SELF_TEST)
|
||||
#if !defined(MBEDTLS_TEST_NULL_ENTROPY)
|
||||
/*
|
||||
* Dummy source function
|
||||
*/
|
||||
@@ -538,7 +526,6 @@ static int entropy_dummy_source( void *data, unsigned char *output,
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
#endif /* !MBEDTLS_TEST_NULL_ENTROPY */
|
||||
|
||||
#if defined(MBEDTLS_ENTROPY_HARDWARE_ALT)
|
||||
|
||||
@@ -646,17 +633,14 @@ cleanup:
|
||||
int mbedtls_entropy_self_test( int verbose )
|
||||
{
|
||||
int ret = 1;
|
||||
#if !defined(MBEDTLS_TEST_NULL_ENTROPY)
|
||||
mbedtls_entropy_context ctx;
|
||||
unsigned char buf[MBEDTLS_ENTROPY_BLOCK_SIZE] = { 0 };
|
||||
unsigned char acc[MBEDTLS_ENTROPY_BLOCK_SIZE] = { 0 };
|
||||
size_t i, j;
|
||||
#endif /* !MBEDTLS_TEST_NULL_ENTROPY */
|
||||
|
||||
if( verbose != 0 )
|
||||
mbedtls_printf( " ENTROPY test: " );
|
||||
|
||||
#if !defined(MBEDTLS_TEST_NULL_ENTROPY)
|
||||
mbedtls_entropy_init( &ctx );
|
||||
|
||||
/* First do a gather to make sure we have default sources */
|
||||
@@ -704,7 +688,6 @@ int mbedtls_entropy_self_test( int verbose )
|
||||
|
||||
cleanup:
|
||||
mbedtls_entropy_free( &ctx );
|
||||
#endif /* !MBEDTLS_TEST_NULL_ENTROPY */
|
||||
|
||||
if( verbose != 0 )
|
||||
{
|
||||
|
||||
@@ -211,23 +211,6 @@ int mbedtls_platform_entropy_poll( void *data,
|
||||
#endif /* _WIN32 && !EFIX64 && !EFI32 */
|
||||
#endif /* !MBEDTLS_NO_PLATFORM_ENTROPY */
|
||||
|
||||
#if defined(MBEDTLS_TEST_NULL_ENTROPY)
|
||||
int mbedtls_null_entropy_poll( void *data,
|
||||
unsigned char *output, size_t len, size_t *olen )
|
||||
{
|
||||
((void) data);
|
||||
((void) output);
|
||||
|
||||
*olen = 0;
|
||||
if( len < sizeof(unsigned char) )
|
||||
return( 0 );
|
||||
|
||||
output[0] = 0;
|
||||
*olen = sizeof(unsigned char);
|
||||
return( 0 );
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_TIMING_C)
|
||||
int mbedtls_hardclock_poll( void *data,
|
||||
unsigned char *output, size_t len, size_t *olen )
|
||||
|
||||
@@ -43,14 +43,6 @@ extern "C" {
|
||||
#define MBEDTLS_ENTROPY_MIN_HARDWARE 32 /**< Minimum for the hardware source */
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief Entropy poll callback that provides 0 entropy.
|
||||
*/
|
||||
#if defined(MBEDTLS_TEST_NULL_ENTROPY)
|
||||
int mbedtls_null_entropy_poll( void *data,
|
||||
unsigned char *output, size_t len, size_t *olen );
|
||||
#endif
|
||||
|
||||
#if !defined(MBEDTLS_NO_PLATFORM_ENTROPY)
|
||||
/**
|
||||
* \brief Platform-specific entropy poll callback
|
||||
|
||||
865
library/error.c
865
library/error.c
@@ -1,865 +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)
|
||||
|
||||
#if defined(MBEDTLS_PLATFORM_C)
|
||||
#include "mbedtls/platform.h"
|
||||
#else
|
||||
#define mbedtls_snprintf snprintf
|
||||
#endif
|
||||
|
||||
#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_BLOWFISH_C)
|
||||
#include "mbedtls/blowfish.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_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_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_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
|
||||
|
||||
#if defined(MBEDTLS_XTEA_C)
|
||||
#include "mbedtls/xtea.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" );
|
||||
#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_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_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_UNKNOWN_CIPHER):
|
||||
return( "SSL - An unknown cipher was received" );
|
||||
case -(MBEDTLS_ERR_SSL_NO_CIPHER_CHOSEN):
|
||||
return( "SSL - The server has no ciphersuites in common with the client" );
|
||||
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_CERTIFICATE_TOO_LARGE):
|
||||
return( "SSL - Our own certificate(s) is/are too large to send in an SSL message" );
|
||||
case -(MBEDTLS_ERR_SSL_CERTIFICATE_REQUIRED):
|
||||
return( "SSL - The own certificate is not set, but needed by the server" );
|
||||
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_PEER_VERIFY_FAILED):
|
||||
return( "SSL - Verification of our peer failed" );
|
||||
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_HS_CLIENT_HELLO):
|
||||
return( "SSL - Processing of the ClientHello handshake message failed" );
|
||||
case -(MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO):
|
||||
return( "SSL - Processing of the ServerHello handshake message failed" );
|
||||
case -(MBEDTLS_ERR_SSL_BAD_HS_CERTIFICATE):
|
||||
return( "SSL - Processing of the Certificate handshake message failed" );
|
||||
case -(MBEDTLS_ERR_SSL_BAD_HS_CERTIFICATE_REQUEST):
|
||||
return( "SSL - Processing of the CertificateRequest handshake message failed" );
|
||||
case -(MBEDTLS_ERR_SSL_BAD_HS_SERVER_KEY_EXCHANGE):
|
||||
return( "SSL - Processing of the ServerKeyExchange handshake message failed" );
|
||||
case -(MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO_DONE):
|
||||
return( "SSL - Processing of the ServerHelloDone handshake message failed" );
|
||||
case -(MBEDTLS_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE):
|
||||
return( "SSL - Processing of the ClientKeyExchange handshake message failed" );
|
||||
case -(MBEDTLS_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE_RP):
|
||||
return( "SSL - Processing of the ClientKeyExchange handshake message failed in DHM / ECDH Read Public" );
|
||||
case -(MBEDTLS_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE_CS):
|
||||
return( "SSL - Processing of the ClientKeyExchange handshake message failed in DHM / ECDH Calculate Secret" );
|
||||
case -(MBEDTLS_ERR_SSL_BAD_HS_CERTIFICATE_VERIFY):
|
||||
return( "SSL - Processing of the CertificateVerify handshake message failed" );
|
||||
case -(MBEDTLS_ERR_SSL_BAD_HS_CHANGE_CIPHER_SPEC):
|
||||
return( "SSL - Processing of the ChangeCipherSpec handshake message failed" );
|
||||
case -(MBEDTLS_ERR_SSL_BAD_HS_FINISHED):
|
||||
return( "SSL - Processing of the Finished handshake message failed" );
|
||||
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_HS_PROTOCOL_VERSION):
|
||||
return( "SSL - Handshake protocol not within min/max boundaries" );
|
||||
case -(MBEDTLS_ERR_SSL_BAD_HS_NEW_SESSION_TICKET):
|
||||
return( "SSL - Processing of the NewSessionTicket handshake message 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_NO_USABLE_CIPHERSUITE):
|
||||
return( "SSL - None of the common ciphersuites is usable (eg, no suitable certificate, see debug messages)" );
|
||||
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_INVALID_VERIFY_HASH):
|
||||
return( "SSL - Couldn't set the hash for verifying CertificateVerify" );
|
||||
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_CRYPTO_IN_PROGRESS):
|
||||
return( "SSL - A cryptographic operation is in progress. Try again later" );
|
||||
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_BLOWFISH_C)
|
||||
case -(MBEDTLS_ERR_BLOWFISH_BAD_INPUT_DATA):
|
||||
return( "BLOWFISH - Bad input data" );
|
||||
case -(MBEDTLS_ERR_BLOWFISH_INVALID_INPUT_LENGTH):
|
||||
return( "BLOWFISH - Invalid data input length" );
|
||||
#endif /* MBEDTLS_BLOWFISH_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" );
|
||||
#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_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_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 */
|
||||
|
||||
#if defined(MBEDTLS_XTEA_C)
|
||||
case -(MBEDTLS_ERR_XTEA_INVALID_INPUT_LENGTH):
|
||||
return( "XTEA - The data input has an invalid length" );
|
||||
#endif /* MBEDTLS_XTEA_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 an non-function in case 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 */
|
||||
@@ -20,8 +20,12 @@
|
||||
/* Enable definition of getaddrinfo() even when compiling with -std=c99. Must
|
||||
* be set before config.h, which pulls in glibc's features.h indirectly.
|
||||
* Harmless on other platforms. */
|
||||
#ifndef _POSIX_C_SOURCE
|
||||
#define _POSIX_C_SOURCE 200112L
|
||||
#endif
|
||||
#ifndef _XOPEN_SOURCE
|
||||
#define _XOPEN_SOURCE 600 /* sockaddr_storage */
|
||||
#endif
|
||||
|
||||
#include "common.h"
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ extern "C" {
|
||||
*
|
||||
* \param feature The feature to detect
|
||||
*
|
||||
* \return 1 if CPU has support for the feature, 0 otherwise
|
||||
* \return non-zero if CPU has support for the feature, 0 otherwise
|
||||
*/
|
||||
int mbedtls_padlock_has_support( int feature );
|
||||
|
||||
|
||||
@@ -135,7 +135,7 @@ static int rsa_decrypt_wrap( void *ctx,
|
||||
return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
|
||||
|
||||
return( mbedtls_rsa_pkcs1_decrypt( rsa, f_rng, p_rng,
|
||||
MBEDTLS_RSA_PRIVATE, olen, input, output, osize ) );
|
||||
olen, input, output, osize ) );
|
||||
}
|
||||
|
||||
static int rsa_encrypt_wrap( void *ctx,
|
||||
@@ -788,7 +788,7 @@ static int rsa_alt_decrypt_wrap( void *ctx,
|
||||
return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
|
||||
|
||||
return( rsa_alt->decrypt_func( rsa_alt->key,
|
||||
MBEDTLS_RSA_PRIVATE, olen, input, output, osize ) );
|
||||
olen, input, output, osize ) );
|
||||
}
|
||||
|
||||
#if defined(MBEDTLS_RSA_C)
|
||||
|
||||
1051
library/psa_crypto.c
1051
library/psa_crypto.c
File diff suppressed because it is too large
Load Diff
@@ -30,6 +30,26 @@
|
||||
#include "psa/crypto.h"
|
||||
#include "psa/crypto_se_driver.h"
|
||||
|
||||
/** Constant-time buffer comparison
|
||||
*
|
||||
* \param[in] a Left-hand buffer for comparison.
|
||||
* \param[in] b Right-hand buffer for comparison.
|
||||
* \param n Amount of bytes to compare.
|
||||
*
|
||||
* \return 0 if the buffer contents are equal, non-zero otherwise
|
||||
*/
|
||||
static inline int mbedtls_psa_safer_memcmp(
|
||||
const uint8_t *a, const uint8_t *b, size_t n )
|
||||
{
|
||||
size_t i;
|
||||
unsigned char diff = 0;
|
||||
|
||||
for( i = 0; i < n; i++ )
|
||||
diff |= a[i] ^ b[i];
|
||||
|
||||
return( diff );
|
||||
}
|
||||
|
||||
/** The data structure representing a key slot, containing key material
|
||||
* and metadata for one key.
|
||||
*/
|
||||
@@ -358,6 +378,86 @@ psa_status_t psa_generate_key_internal( const psa_key_attributes_t *attributes,
|
||||
size_t key_buffer_size,
|
||||
size_t *key_buffer_length );
|
||||
|
||||
/** Sign a message with a private key. For hash-and-sign algorithms,
|
||||
* this includes the hashing step.
|
||||
*
|
||||
* \note The signature of this function is that of a PSA driver
|
||||
* sign_message entry point. This function behaves as a sign_message
|
||||
* entry point as defined in the PSA driver interface specification for
|
||||
* transparent drivers.
|
||||
*
|
||||
* \note This function will call the driver for psa_sign_hash
|
||||
* and go through driver dispatch again.
|
||||
*
|
||||
* \param[in] attributes The attributes of the key to use for the
|
||||
* operation.
|
||||
* \param[in] key_buffer The buffer containing the key context.
|
||||
* \param[in] key_buffer_size Size of the \p key_buffer buffer in bytes.
|
||||
* \param[in] alg A signature algorithm that is compatible with
|
||||
* the type of the key.
|
||||
* \param[in] input The input message to sign.
|
||||
* \param[in] input_length Size of the \p input buffer in bytes.
|
||||
* \param[out] signature Buffer where the signature is to be written.
|
||||
* \param[in] signature_size Size of the \p signature buffer in bytes.
|
||||
* \param[out] signature_length On success, the number of bytes
|
||||
* that make up the returned signature value.
|
||||
*
|
||||
* \retval #PSA_SUCCESS
|
||||
* \retval #PSA_ERROR_BUFFER_TOO_SMALL
|
||||
* The size of the \p signature buffer is too small. You can
|
||||
* determine a sufficient buffer size by calling
|
||||
* #PSA_SIGN_OUTPUT_SIZE(\c key_type, \c key_bits, \p alg)
|
||||
* where \c key_type and \c key_bits are the type and bit-size
|
||||
* respectively of the key.
|
||||
* \retval #PSA_ERROR_NOT_SUPPORTED
|
||||
* \retval #PSA_ERROR_INVALID_ARGUMENT
|
||||
* \retval #PSA_ERROR_INSUFFICIENT_MEMORY
|
||||
* \retval #PSA_ERROR_CORRUPTION_DETECTED
|
||||
* \retval #PSA_ERROR_INSUFFICIENT_ENTROPY
|
||||
*/
|
||||
psa_status_t psa_sign_message_builtin(
|
||||
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 );
|
||||
|
||||
/** Verify the signature of a message with a public key, using
|
||||
* a hash-and-sign verification algorithm.
|
||||
*
|
||||
* \note The signature of this function is that of a PSA driver
|
||||
* verify_message entry point. This function behaves as a verify_message
|
||||
* entry point as defined in the PSA driver interface specification for
|
||||
* transparent drivers.
|
||||
*
|
||||
* \note This function will call the driver for psa_verify_hash
|
||||
* and go through driver dispatch again.
|
||||
*
|
||||
* \param[in] attributes The attributes of the key to use for the
|
||||
* operation.
|
||||
* \param[in] key_buffer The buffer containing the key context.
|
||||
* \param[in] key_buffer_size Size of the \p key_buffer buffer in bytes.
|
||||
* \param[in] alg A signature algorithm that is compatible with
|
||||
* the type of the key.
|
||||
* \param[in] input The message whose signature is to be verified.
|
||||
* \param[in] input_length Size of the \p input buffer in bytes.
|
||||
* \param[in] signature Buffer containing the signature to verify.
|
||||
* \param[in] signature_length Size of the \p signature buffer in bytes.
|
||||
*
|
||||
* \retval #PSA_SUCCESS
|
||||
* The signature is valid.
|
||||
* \retval #PSA_ERROR_INVALID_SIGNATURE
|
||||
* The calculation was performed successfully, but the passed
|
||||
* signature is not a valid signature.
|
||||
* \retval #PSA_ERROR_NOT_SUPPORTED
|
||||
* \retval #PSA_ERROR_INVALID_ARGUMENT
|
||||
* \retval #PSA_ERROR_INSUFFICIENT_MEMORY
|
||||
*/
|
||||
psa_status_t psa_verify_message_builtin(
|
||||
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 );
|
||||
|
||||
/** Sign an already-calculated hash with a private key.
|
||||
*
|
||||
* \note The signature of this function is that of a PSA driver
|
||||
@@ -368,7 +468,6 @@ psa_status_t psa_generate_key_internal( const psa_key_attributes_t *attributes,
|
||||
* \param[in] attributes The attributes of the key to use for the
|
||||
* operation.
|
||||
* \param[in] key_buffer The buffer containing the key context.
|
||||
* format.
|
||||
* \param[in] key_buffer_size Size of the \p key_buffer buffer in bytes.
|
||||
* \param[in] alg A signature algorithm that is compatible with
|
||||
* the type of the key.
|
||||
@@ -392,7 +491,7 @@ psa_status_t psa_generate_key_internal( const psa_key_attributes_t *attributes,
|
||||
* \retval #PSA_ERROR_CORRUPTION_DETECTED
|
||||
* \retval #PSA_ERROR_INSUFFICIENT_ENTROPY
|
||||
*/
|
||||
psa_status_t psa_sign_hash_internal(
|
||||
psa_status_t psa_sign_hash_builtin(
|
||||
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,
|
||||
@@ -409,7 +508,6 @@ psa_status_t psa_sign_hash_internal(
|
||||
* \param[in] attributes The attributes of the key to use for the
|
||||
* operation.
|
||||
* \param[in] key_buffer The buffer containing the key context.
|
||||
* format.
|
||||
* \param[in] key_buffer_size Size of the \p key_buffer buffer in bytes.
|
||||
* \param[in] alg A signature algorithm that is compatible with
|
||||
* the type of the key.
|
||||
@@ -428,7 +526,7 @@ psa_status_t psa_sign_hash_internal(
|
||||
* \retval #PSA_ERROR_INVALID_ARGUMENT
|
||||
* \retval #PSA_ERROR_INSUFFICIENT_MEMORY
|
||||
*/
|
||||
psa_status_t psa_verify_hash_internal(
|
||||
psa_status_t psa_verify_hash_builtin(
|
||||
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,
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "psa_crypto_core.h"
|
||||
#include "psa_crypto_driver_wrappers.h"
|
||||
#include "psa_crypto_hash.h"
|
||||
#include "psa_crypto_mac.h"
|
||||
|
||||
#include "mbedtls/platform.h"
|
||||
|
||||
@@ -64,6 +65,152 @@
|
||||
#endif
|
||||
|
||||
/* Start delegation functions */
|
||||
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 ) );
|
||||
}
|
||||
|
||||
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 ) );
|
||||
}
|
||||
|
||||
psa_status_t psa_driver_wrapper_sign_hash(
|
||||
const psa_key_attributes_t *attributes,
|
||||
const uint8_t *key_buffer, size_t key_buffer_size,
|
||||
@@ -116,15 +263,15 @@ psa_status_t psa_driver_wrapper_sign_hash(
|
||||
#endif /* PSA_CRYPTO_DRIVER_TEST */
|
||||
#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
|
||||
/* Fell through, meaning no accelerator supports this operation */
|
||||
return( psa_sign_hash_internal( attributes,
|
||||
key_buffer,
|
||||
key_buffer_size,
|
||||
alg,
|
||||
hash,
|
||||
hash_length,
|
||||
signature,
|
||||
signature_size,
|
||||
signature_length ) );
|
||||
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)
|
||||
@@ -200,14 +347,14 @@ psa_status_t psa_driver_wrapper_verify_hash(
|
||||
#endif /* PSA_CRYPTO_DRIVER_TEST */
|
||||
#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
|
||||
|
||||
return( psa_verify_hash_internal( attributes,
|
||||
key_buffer,
|
||||
key_buffer_size,
|
||||
alg,
|
||||
hash,
|
||||
hash_length,
|
||||
signature,
|
||||
signature_length ) );
|
||||
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)
|
||||
@@ -1290,4 +1437,344 @@ psa_status_t psa_driver_wrapper_aead_decrypt(
|
||||
return( PSA_ERROR_INVALID_ARGUMENT );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* MAC functions
|
||||
*/
|
||||
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 );
|
||||
}
|
||||
}
|
||||
|
||||
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 = PSA_CRYPTO_TRANSPARENT_TEST_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 = PSA_CRYPTO_OPAQUE_TEST_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) key_buffer;
|
||||
(void) key_buffer_size;
|
||||
(void) alg;
|
||||
return( PSA_ERROR_INVALID_ARGUMENT );
|
||||
}
|
||||
}
|
||||
|
||||
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 = PSA_CRYPTO_TRANSPARENT_TEST_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 = PSA_CRYPTO_OPAQUE_TEST_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) key_buffer;
|
||||
(void) key_buffer_size;
|
||||
(void) alg;
|
||||
return( PSA_ERROR_INVALID_ARGUMENT );
|
||||
}
|
||||
}
|
||||
|
||||
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 PSA_CRYPTO_TRANSPARENT_TEST_DRIVER_ID:
|
||||
return( mbedtls_test_transparent_mac_update(
|
||||
&operation->ctx.transparent_test_driver_ctx,
|
||||
input, input_length ) );
|
||||
|
||||
case PSA_CRYPTO_OPAQUE_TEST_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 );
|
||||
}
|
||||
}
|
||||
|
||||
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 PSA_CRYPTO_TRANSPARENT_TEST_DRIVER_ID:
|
||||
return( mbedtls_test_transparent_mac_sign_finish(
|
||||
&operation->ctx.transparent_test_driver_ctx,
|
||||
mac, mac_size, mac_length ) );
|
||||
|
||||
case PSA_CRYPTO_OPAQUE_TEST_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 );
|
||||
}
|
||||
}
|
||||
|
||||
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 PSA_CRYPTO_TRANSPARENT_TEST_DRIVER_ID:
|
||||
return( mbedtls_test_transparent_mac_verify_finish(
|
||||
&operation->ctx.transparent_test_driver_ctx,
|
||||
mac, mac_length ) );
|
||||
|
||||
case PSA_CRYPTO_OPAQUE_TEST_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 );
|
||||
}
|
||||
}
|
||||
|
||||
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 PSA_CRYPTO_TRANSPARENT_TEST_DRIVER_ID:
|
||||
return( mbedtls_test_transparent_mac_abort(
|
||||
&operation->ctx.transparent_test_driver_ctx ) );
|
||||
case PSA_CRYPTO_OPAQUE_TEST_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 );
|
||||
}
|
||||
}
|
||||
/* End of automatically generated file. */
|
||||
|
||||
@@ -28,6 +28,27 @@
|
||||
/*
|
||||
* Signature functions
|
||||
*/
|
||||
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 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 psa_driver_wrapper_sign_hash(
|
||||
const psa_key_attributes_t *attributes,
|
||||
const uint8_t *key_buffer, size_t key_buffer_size,
|
||||
@@ -183,6 +204,53 @@ psa_status_t psa_driver_wrapper_aead_decrypt(
|
||||
const uint8_t *ciphertext, size_t ciphertext_length,
|
||||
uint8_t *plaintext, size_t plaintext_size, size_t *plaintext_length );
|
||||
|
||||
/*
|
||||
* MAC functions
|
||||
*/
|
||||
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 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 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 psa_driver_wrapper_mac_update(
|
||||
psa_mac_operation_t *operation,
|
||||
const uint8_t *input,
|
||||
size_t input_length );
|
||||
|
||||
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 );
|
||||
|
||||
psa_status_t psa_driver_wrapper_mac_verify_finish(
|
||||
psa_mac_operation_t *operation,
|
||||
const uint8_t *mac,
|
||||
size_t mac_length );
|
||||
|
||||
psa_status_t psa_driver_wrapper_mac_abort(
|
||||
psa_mac_operation_t *operation );
|
||||
|
||||
#endif /* PSA_CRYPTO_DRIVER_WRAPPERS_H */
|
||||
|
||||
/* End of automatically generated file. */
|
||||
|
||||
787
library/psa_crypto_mac.c
Normal file
787
library/psa_crypto_mac.c
Normal file
@@ -0,0 +1,787 @@
|
||||
/*
|
||||
* PSA MAC layer on top of Mbed TLS software crypto
|
||||
*/
|
||||
/*
|
||||
* 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_PSA_CRYPTO_C)
|
||||
|
||||
#include <psa/crypto.h>
|
||||
#include "psa_crypto_core.h"
|
||||
#include "psa_crypto_mac.h"
|
||||
#include <mbedtls/md.h>
|
||||
|
||||
#include <mbedtls/error.h>
|
||||
#include <string.h>
|
||||
|
||||
/* Use builtin defines specific to this compilation unit, since the test driver
|
||||
* relies on the software driver. */
|
||||
#if( defined(MBEDTLS_PSA_BUILTIN_ALG_CMAC) || \
|
||||
( defined(PSA_CRYPTO_DRIVER_TEST) && defined(MBEDTLS_PSA_ACCEL_ALG_CMAC) ) )
|
||||
#define BUILTIN_ALG_CMAC 1
|
||||
#endif
|
||||
#if( defined(MBEDTLS_PSA_BUILTIN_ALG_HMAC) || \
|
||||
( defined(PSA_CRYPTO_DRIVER_TEST) && defined(MBEDTLS_PSA_ACCEL_ALG_HMAC) ) )
|
||||
#define BUILTIN_ALG_HMAC 1
|
||||
#endif
|
||||
|
||||
#if defined(BUILTIN_ALG_HMAC)
|
||||
static size_t psa_get_hash_block_size( psa_algorithm_t alg )
|
||||
{
|
||||
switch( alg )
|
||||
{
|
||||
case PSA_ALG_MD2:
|
||||
return( 16 );
|
||||
case PSA_ALG_MD4:
|
||||
return( 64 );
|
||||
case PSA_ALG_MD5:
|
||||
return( 64 );
|
||||
case PSA_ALG_RIPEMD160:
|
||||
return( 64 );
|
||||
case PSA_ALG_SHA_1:
|
||||
return( 64 );
|
||||
case PSA_ALG_SHA_224:
|
||||
return( 64 );
|
||||
case PSA_ALG_SHA_256:
|
||||
return( 64 );
|
||||
case PSA_ALG_SHA_384:
|
||||
return( 128 );
|
||||
case PSA_ALG_SHA_512:
|
||||
return( 128 );
|
||||
default:
|
||||
return( 0 );
|
||||
}
|
||||
}
|
||||
|
||||
static psa_status_t psa_hmac_abort_internal(
|
||||
mbedtls_psa_hmac_operation_t *hmac )
|
||||
{
|
||||
mbedtls_platform_zeroize( hmac->opad, sizeof( hmac->opad ) );
|
||||
return( psa_hash_abort( &hmac->hash_ctx ) );
|
||||
}
|
||||
|
||||
static psa_status_t psa_hmac_setup_internal(
|
||||
mbedtls_psa_hmac_operation_t *hmac,
|
||||
const uint8_t *key,
|
||||
size_t key_length,
|
||||
psa_algorithm_t hash_alg )
|
||||
{
|
||||
uint8_t ipad[PSA_HMAC_MAX_HASH_BLOCK_SIZE];
|
||||
size_t i;
|
||||
size_t hash_size = PSA_HASH_LENGTH( hash_alg );
|
||||
size_t block_size = psa_get_hash_block_size( hash_alg );
|
||||
psa_status_t status;
|
||||
|
||||
hmac->alg = hash_alg;
|
||||
|
||||
/* Sanity checks on block_size, to guarantee that there won't be a buffer
|
||||
* overflow below. This should never trigger if the hash algorithm
|
||||
* is implemented correctly. */
|
||||
/* The size checks against the ipad and opad buffers cannot be written
|
||||
* `block_size > sizeof( ipad ) || block_size > sizeof( hmac->opad )`
|
||||
* because that triggers -Wlogical-op on GCC 7.3. */
|
||||
if( block_size > sizeof( ipad ) )
|
||||
return( PSA_ERROR_NOT_SUPPORTED );
|
||||
if( block_size > sizeof( hmac->opad ) )
|
||||
return( PSA_ERROR_NOT_SUPPORTED );
|
||||
if( block_size < hash_size )
|
||||
return( PSA_ERROR_NOT_SUPPORTED );
|
||||
|
||||
if( key_length > block_size )
|
||||
{
|
||||
status = psa_hash_compute( hash_alg, key, key_length,
|
||||
ipad, sizeof( ipad ), &key_length );
|
||||
if( status != PSA_SUCCESS )
|
||||
goto cleanup;
|
||||
}
|
||||
/* A 0-length key is not commonly used in HMAC when used as a MAC,
|
||||
* but it is permitted. It is common when HMAC is used in HKDF, for
|
||||
* example. Don't call `memcpy` in the 0-length because `key` could be
|
||||
* an invalid pointer which would make the behavior undefined. */
|
||||
else if( key_length != 0 )
|
||||
memcpy( ipad, key, key_length );
|
||||
|
||||
/* ipad contains the key followed by garbage. Xor and fill with 0x36
|
||||
* to create the ipad value. */
|
||||
for( i = 0; i < key_length; i++ )
|
||||
ipad[i] ^= 0x36;
|
||||
memset( ipad + key_length, 0x36, block_size - key_length );
|
||||
|
||||
/* Copy the key material from ipad to opad, flipping the requisite bits,
|
||||
* and filling the rest of opad with the requisite constant. */
|
||||
for( i = 0; i < key_length; i++ )
|
||||
hmac->opad[i] = ipad[i] ^ 0x36 ^ 0x5C;
|
||||
memset( hmac->opad + key_length, 0x5C, block_size - key_length );
|
||||
|
||||
status = psa_hash_setup( &hmac->hash_ctx, hash_alg );
|
||||
if( status != PSA_SUCCESS )
|
||||
goto cleanup;
|
||||
|
||||
status = psa_hash_update( &hmac->hash_ctx, ipad, block_size );
|
||||
|
||||
cleanup:
|
||||
mbedtls_platform_zeroize( ipad, sizeof( ipad ) );
|
||||
|
||||
return( status );
|
||||
}
|
||||
|
||||
static psa_status_t psa_hmac_update_internal(
|
||||
mbedtls_psa_hmac_operation_t *hmac,
|
||||
const uint8_t *data,
|
||||
size_t data_length )
|
||||
{
|
||||
return( psa_hash_update( &hmac->hash_ctx, data, data_length ) );
|
||||
}
|
||||
|
||||
static psa_status_t psa_hmac_finish_internal(
|
||||
mbedtls_psa_hmac_operation_t *hmac,
|
||||
uint8_t *mac,
|
||||
size_t mac_size )
|
||||
{
|
||||
uint8_t tmp[MBEDTLS_MD_MAX_SIZE];
|
||||
psa_algorithm_t hash_alg = hmac->alg;
|
||||
size_t hash_size = 0;
|
||||
size_t block_size = psa_get_hash_block_size( hash_alg );
|
||||
psa_status_t status;
|
||||
|
||||
status = psa_hash_finish( &hmac->hash_ctx, tmp, sizeof( tmp ), &hash_size );
|
||||
if( status != PSA_SUCCESS )
|
||||
return( status );
|
||||
/* From here on, tmp needs to be wiped. */
|
||||
|
||||
status = psa_hash_setup( &hmac->hash_ctx, hash_alg );
|
||||
if( status != PSA_SUCCESS )
|
||||
goto exit;
|
||||
|
||||
status = psa_hash_update( &hmac->hash_ctx, hmac->opad, block_size );
|
||||
if( status != PSA_SUCCESS )
|
||||
goto exit;
|
||||
|
||||
status = psa_hash_update( &hmac->hash_ctx, tmp, hash_size );
|
||||
if( status != PSA_SUCCESS )
|
||||
goto exit;
|
||||
|
||||
status = psa_hash_finish( &hmac->hash_ctx, tmp, sizeof( tmp ), &hash_size );
|
||||
if( status != PSA_SUCCESS )
|
||||
goto exit;
|
||||
|
||||
memcpy( mac, tmp, mac_size );
|
||||
|
||||
exit:
|
||||
mbedtls_platform_zeroize( tmp, hash_size );
|
||||
return( status );
|
||||
}
|
||||
#endif /* BUILTIN_ALG_HMAC */
|
||||
|
||||
#if defined(BUILTIN_ALG_CMAC)
|
||||
static psa_status_t cmac_setup( mbedtls_psa_mac_operation_t *operation,
|
||||
const psa_key_attributes_t *attributes,
|
||||
const uint8_t *key_buffer )
|
||||
{
|
||||
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
|
||||
|
||||
#if defined(PSA_WANT_KEY_TYPE_DES)
|
||||
/* Mbed TLS CMAC does not accept 3DES with only two keys, nor does it accept
|
||||
* to do CMAC with pure DES, so return NOT_SUPPORTED here. */
|
||||
if( psa_get_key_type( attributes ) == PSA_KEY_TYPE_DES &&
|
||||
( psa_get_key_bits( attributes ) == 64 ||
|
||||
psa_get_key_bits( attributes ) == 128 ) )
|
||||
return( PSA_ERROR_NOT_SUPPORTED );
|
||||
#endif
|
||||
|
||||
const mbedtls_cipher_info_t * cipher_info =
|
||||
mbedtls_cipher_info_from_psa(
|
||||
PSA_ALG_CMAC,
|
||||
psa_get_key_type( attributes ),
|
||||
psa_get_key_bits( attributes ),
|
||||
NULL );
|
||||
|
||||
if( cipher_info == NULL )
|
||||
return( PSA_ERROR_NOT_SUPPORTED );
|
||||
|
||||
ret = mbedtls_cipher_setup( &operation->ctx.cmac, cipher_info );
|
||||
if( ret != 0 )
|
||||
goto exit;
|
||||
|
||||
ret = mbedtls_cipher_cmac_starts( &operation->ctx.cmac,
|
||||
key_buffer,
|
||||
psa_get_key_bits( attributes ) );
|
||||
exit:
|
||||
return( mbedtls_to_psa_error( ret ) );
|
||||
}
|
||||
#endif /* BUILTIN_ALG_CMAC */
|
||||
|
||||
/* Implement the PSA driver MAC interface on top of mbed TLS if either the
|
||||
* software driver or the test driver requires it. */
|
||||
#if defined(BUILTIN_ALG_HMAC) || defined(BUILTIN_ALG_CMAC)
|
||||
|
||||
/* Initialize this driver's MAC operation structure. Once this function has been
|
||||
* called, mbedtls_psa_mac_abort can run and will do the right thing. */
|
||||
static psa_status_t mac_init(
|
||||
mbedtls_psa_mac_operation_t *operation,
|
||||
psa_algorithm_t alg )
|
||||
{
|
||||
psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
|
||||
|
||||
operation->alg = alg;
|
||||
|
||||
#if defined(BUILTIN_ALG_CMAC)
|
||||
if( PSA_ALG_FULL_LENGTH_MAC( operation->alg ) == PSA_ALG_CMAC )
|
||||
{
|
||||
mbedtls_cipher_init( &operation->ctx.cmac );
|
||||
status = PSA_SUCCESS;
|
||||
}
|
||||
else
|
||||
#endif /* BUILTIN_ALG_CMAC */
|
||||
#if defined(BUILTIN_ALG_HMAC)
|
||||
if( PSA_ALG_IS_HMAC( operation->alg ) )
|
||||
{
|
||||
/* We'll set up the hash operation later in psa_hmac_setup_internal. */
|
||||
operation->ctx.hmac.alg = 0;
|
||||
status = PSA_SUCCESS;
|
||||
}
|
||||
else
|
||||
#endif /* BUILTIN_ALG_HMAC */
|
||||
{
|
||||
status = PSA_ERROR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
if( status != PSA_SUCCESS )
|
||||
memset( operation, 0, sizeof( *operation ) );
|
||||
return( status );
|
||||
}
|
||||
|
||||
static psa_status_t mac_abort( mbedtls_psa_mac_operation_t *operation )
|
||||
{
|
||||
if( operation->alg == 0 )
|
||||
{
|
||||
/* The object has (apparently) been initialized but it is not
|
||||
* in use. It's ok to call abort on such an object, and there's
|
||||
* nothing to do. */
|
||||
return( PSA_SUCCESS );
|
||||
}
|
||||
else
|
||||
#if defined(BUILTIN_ALG_CMAC)
|
||||
if( PSA_ALG_FULL_LENGTH_MAC( operation->alg ) == PSA_ALG_CMAC )
|
||||
{
|
||||
mbedtls_cipher_free( &operation->ctx.cmac );
|
||||
}
|
||||
else
|
||||
#endif /* BUILTIN_ALG_CMAC */
|
||||
#if defined(BUILTIN_ALG_HMAC)
|
||||
if( PSA_ALG_IS_HMAC( operation->alg ) )
|
||||
{
|
||||
psa_hmac_abort_internal( &operation->ctx.hmac );
|
||||
}
|
||||
else
|
||||
#endif /* BUILTIN_ALG_HMAC */
|
||||
{
|
||||
/* Sanity check (shouldn't happen: operation->alg should
|
||||
* always have been initialized to a valid value). */
|
||||
goto bad_state;
|
||||
}
|
||||
|
||||
operation->alg = 0;
|
||||
|
||||
return( PSA_SUCCESS );
|
||||
|
||||
bad_state:
|
||||
/* If abort is called on an uninitialized object, we can't trust
|
||||
* anything. Wipe the object in case it contains confidential data.
|
||||
* This may result in a memory leak if a pointer gets overwritten,
|
||||
* but it's too late to do anything about this. */
|
||||
memset( operation, 0, sizeof( *operation ) );
|
||||
return( PSA_ERROR_BAD_STATE );
|
||||
}
|
||||
|
||||
static psa_status_t mac_setup( mbedtls_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;
|
||||
|
||||
/* A context must be freshly initialized before it can be set up. */
|
||||
if( operation->alg != 0 )
|
||||
return( PSA_ERROR_BAD_STATE );
|
||||
|
||||
status = mac_init( operation, alg );
|
||||
if( status != PSA_SUCCESS )
|
||||
return( status );
|
||||
|
||||
#if defined(BUILTIN_ALG_CMAC)
|
||||
if( PSA_ALG_FULL_LENGTH_MAC( alg ) == PSA_ALG_CMAC )
|
||||
{
|
||||
/* Key buffer size for CMAC is dictated by the key bits set on the
|
||||
* attributes, and previously validated by the core on key import. */
|
||||
(void) key_buffer_size;
|
||||
status = cmac_setup( operation, attributes, key_buffer );
|
||||
}
|
||||
else
|
||||
#endif /* BUILTIN_ALG_CMAC */
|
||||
#if defined(BUILTIN_ALG_HMAC)
|
||||
if( PSA_ALG_IS_HMAC( alg ) )
|
||||
{
|
||||
status = psa_hmac_setup_internal( &operation->ctx.hmac,
|
||||
key_buffer,
|
||||
key_buffer_size,
|
||||
PSA_ALG_HMAC_GET_HASH( alg ) );
|
||||
}
|
||||
else
|
||||
#endif /* BUILTIN_ALG_HMAC */
|
||||
{
|
||||
(void) attributes;
|
||||
(void) key_buffer;
|
||||
(void) key_buffer_size;
|
||||
status = PSA_ERROR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
if( status != PSA_SUCCESS )
|
||||
mac_abort( operation );
|
||||
|
||||
return( status );
|
||||
}
|
||||
|
||||
static psa_status_t 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 )
|
||||
{
|
||||
/* One-shot MAC has not been implemented in this PSA implementation yet. */
|
||||
(void) attributes;
|
||||
(void) key_buffer;
|
||||
(void) key_buffer_size;
|
||||
(void) alg;
|
||||
(void) input;
|
||||
(void) input_length;
|
||||
(void) mac;
|
||||
(void) mac_size;
|
||||
(void) mac_length;
|
||||
return( PSA_ERROR_NOT_SUPPORTED );
|
||||
}
|
||||
|
||||
static psa_status_t mac_update(
|
||||
mbedtls_psa_mac_operation_t *operation,
|
||||
const uint8_t *input,
|
||||
size_t input_length )
|
||||
{
|
||||
if( operation->alg == 0 )
|
||||
return( PSA_ERROR_BAD_STATE );
|
||||
|
||||
#if defined(BUILTIN_ALG_CMAC)
|
||||
if( PSA_ALG_FULL_LENGTH_MAC( operation->alg ) == PSA_ALG_CMAC )
|
||||
{
|
||||
return( mbedtls_to_psa_error(
|
||||
mbedtls_cipher_cmac_update( &operation->ctx.cmac,
|
||||
input, input_length ) ) );
|
||||
}
|
||||
else
|
||||
#endif /* BUILTIN_ALG_CMAC */
|
||||
#if defined(BUILTIN_ALG_HMAC)
|
||||
if( PSA_ALG_IS_HMAC( operation->alg ) )
|
||||
{
|
||||
return( psa_hmac_update_internal( &operation->ctx.hmac,
|
||||
input, input_length ) );
|
||||
}
|
||||
else
|
||||
#endif /* BUILTIN_ALG_HMAC */
|
||||
{
|
||||
/* This shouldn't happen if `operation` was initialized by
|
||||
* a setup function. */
|
||||
(void) input;
|
||||
(void) input_length;
|
||||
return( PSA_ERROR_BAD_STATE );
|
||||
}
|
||||
}
|
||||
|
||||
static psa_status_t mac_finish_internal( mbedtls_psa_mac_operation_t *operation,
|
||||
uint8_t *mac,
|
||||
size_t mac_size )
|
||||
{
|
||||
#if defined(BUILTIN_ALG_CMAC)
|
||||
if( PSA_ALG_FULL_LENGTH_MAC( operation->alg ) == PSA_ALG_CMAC )
|
||||
{
|
||||
uint8_t tmp[PSA_BLOCK_CIPHER_BLOCK_MAX_SIZE];
|
||||
int ret = mbedtls_cipher_cmac_finish( &operation->ctx.cmac, tmp );
|
||||
if( ret == 0 )
|
||||
memcpy( mac, tmp, mac_size );
|
||||
mbedtls_platform_zeroize( tmp, sizeof( tmp ) );
|
||||
return( mbedtls_to_psa_error( ret ) );
|
||||
}
|
||||
else
|
||||
#endif /* BUILTIN_ALG_CMAC */
|
||||
#if defined(BUILTIN_ALG_HMAC)
|
||||
if( PSA_ALG_IS_HMAC( operation->alg ) )
|
||||
{
|
||||
return( psa_hmac_finish_internal( &operation->ctx.hmac,
|
||||
mac, mac_size ) );
|
||||
}
|
||||
else
|
||||
#endif /* BUILTIN_ALG_HMAC */
|
||||
{
|
||||
/* This shouldn't happen if `operation` was initialized by
|
||||
* a setup function. */
|
||||
(void) operation;
|
||||
(void) mac;
|
||||
(void) mac_size;
|
||||
return( PSA_ERROR_BAD_STATE );
|
||||
}
|
||||
}
|
||||
|
||||
static psa_status_t mac_sign_finish(
|
||||
mbedtls_psa_mac_operation_t *operation,
|
||||
uint8_t *mac,
|
||||
size_t mac_size,
|
||||
size_t *mac_length )
|
||||
{
|
||||
psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
|
||||
|
||||
if( operation->alg == 0 )
|
||||
return( PSA_ERROR_BAD_STATE );
|
||||
|
||||
status = mac_finish_internal( operation, mac, mac_size );
|
||||
|
||||
if( status == PSA_SUCCESS )
|
||||
*mac_length = mac_size;
|
||||
|
||||
return( status );
|
||||
}
|
||||
|
||||
static psa_status_t mac_verify_finish(
|
||||
mbedtls_psa_mac_operation_t *operation,
|
||||
const uint8_t *mac,
|
||||
size_t mac_length )
|
||||
{
|
||||
uint8_t actual_mac[PSA_MAC_MAX_SIZE];
|
||||
psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
|
||||
|
||||
if( operation->alg == 0 )
|
||||
return( PSA_ERROR_BAD_STATE );
|
||||
|
||||
/* Consistency check: requested MAC length fits our local buffer */
|
||||
if( mac_length > sizeof( actual_mac ) )
|
||||
return( PSA_ERROR_INVALID_ARGUMENT );
|
||||
|
||||
status = mac_finish_internal( operation, actual_mac, mac_length );
|
||||
if( status != PSA_SUCCESS )
|
||||
goto cleanup;
|
||||
|
||||
if( mbedtls_psa_safer_memcmp( mac, actual_mac, mac_length ) != 0 )
|
||||
status = PSA_ERROR_INVALID_SIGNATURE;
|
||||
|
||||
cleanup:
|
||||
mbedtls_platform_zeroize( actual_mac, sizeof( actual_mac ) );
|
||||
|
||||
return( status );
|
||||
}
|
||||
#endif /* BUILTIN_ALG_HMAC || BUILTIN_ALG_CMAC */
|
||||
|
||||
#if defined(MBEDTLS_PSA_BUILTIN_MAC)
|
||||
psa_status_t mbedtls_psa_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 )
|
||||
{
|
||||
return( mac_compute( attributes, key_buffer, key_buffer_size, alg,
|
||||
input, input_length,
|
||||
mac, mac_size, mac_length ) );
|
||||
}
|
||||
|
||||
psa_status_t mbedtls_psa_mac_sign_setup(
|
||||
mbedtls_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 )
|
||||
{
|
||||
return( mac_setup( operation, attributes,
|
||||
key_buffer, key_buffer_size, alg ) );
|
||||
}
|
||||
|
||||
psa_status_t mbedtls_psa_mac_verify_setup(
|
||||
mbedtls_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 )
|
||||
{
|
||||
return( mac_setup( operation, attributes,
|
||||
key_buffer, key_buffer_size, alg ) );
|
||||
}
|
||||
|
||||
psa_status_t mbedtls_psa_mac_update(
|
||||
mbedtls_psa_mac_operation_t *operation,
|
||||
const uint8_t *input,
|
||||
size_t input_length )
|
||||
{
|
||||
return( mac_update( operation, input, input_length ) );
|
||||
}
|
||||
|
||||
psa_status_t mbedtls_psa_mac_sign_finish(
|
||||
mbedtls_psa_mac_operation_t *operation,
|
||||
uint8_t *mac,
|
||||
size_t mac_size,
|
||||
size_t *mac_length )
|
||||
{
|
||||
return( mac_sign_finish( operation, mac, mac_size, mac_length ) );
|
||||
}
|
||||
|
||||
psa_status_t mbedtls_psa_mac_verify_finish(
|
||||
mbedtls_psa_mac_operation_t *operation,
|
||||
const uint8_t *mac,
|
||||
size_t mac_length )
|
||||
{
|
||||
return( mac_verify_finish( operation, mac, mac_length ) );
|
||||
}
|
||||
|
||||
psa_status_t mbedtls_psa_mac_abort(
|
||||
mbedtls_psa_mac_operation_t *operation )
|
||||
{
|
||||
return( mac_abort( operation ) );
|
||||
}
|
||||
#endif /* MBEDTLS_PSA_BUILTIN_MAC */
|
||||
|
||||
/*
|
||||
* BEYOND THIS POINT, TEST DRIVER ENTRY POINTS ONLY.
|
||||
*/
|
||||
#if defined(PSA_CRYPTO_DRIVER_TEST)
|
||||
|
||||
static int is_mac_accelerated( psa_algorithm_t alg )
|
||||
{
|
||||
#if defined(MBEDTLS_PSA_ACCEL_ALG_HMAC)
|
||||
if( PSA_ALG_IS_HMAC( alg ) )
|
||||
return( 1 );
|
||||
#endif
|
||||
|
||||
switch( PSA_ALG_FULL_LENGTH_MAC( alg ) )
|
||||
{
|
||||
#if defined(MBEDTLS_PSA_ACCEL_ALG_CMAC)
|
||||
case PSA_ALG_CMAC:
|
||||
return( 1 );
|
||||
#endif
|
||||
default:
|
||||
return( 0 );
|
||||
}
|
||||
}
|
||||
|
||||
psa_status_t mbedtls_transparent_test_driver_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 )
|
||||
{
|
||||
if( is_mac_accelerated( alg ) )
|
||||
return( mac_compute( attributes, key_buffer, key_buffer_size, alg,
|
||||
input, input_length,
|
||||
mac, mac_size, mac_length ) );
|
||||
else
|
||||
return( PSA_ERROR_NOT_SUPPORTED );
|
||||
}
|
||||
|
||||
psa_status_t mbedtls_transparent_test_driver_mac_sign_setup(
|
||||
mbedtls_transparent_test_driver_mac_operation_t *operation,
|
||||
const psa_key_attributes_t *attributes,
|
||||
const uint8_t *key_buffer,
|
||||
size_t key_buffer_size,
|
||||
psa_algorithm_t alg )
|
||||
{
|
||||
if( is_mac_accelerated( alg ) )
|
||||
return( mac_setup( operation, attributes,
|
||||
key_buffer, key_buffer_size, alg ) );
|
||||
else
|
||||
return( PSA_ERROR_NOT_SUPPORTED );
|
||||
}
|
||||
|
||||
psa_status_t mbedtls_transparent_test_driver_mac_verify_setup(
|
||||
mbedtls_transparent_test_driver_mac_operation_t *operation,
|
||||
const psa_key_attributes_t *attributes,
|
||||
const uint8_t *key_buffer,
|
||||
size_t key_buffer_size,
|
||||
psa_algorithm_t alg )
|
||||
{
|
||||
if( is_mac_accelerated( alg ) )
|
||||
return( mac_setup( operation, attributes,
|
||||
key_buffer, key_buffer_size, alg ) );
|
||||
else
|
||||
return( PSA_ERROR_NOT_SUPPORTED );
|
||||
}
|
||||
|
||||
psa_status_t mbedtls_transparent_test_driver_mac_update(
|
||||
mbedtls_transparent_test_driver_mac_operation_t *operation,
|
||||
const uint8_t *input,
|
||||
size_t input_length )
|
||||
{
|
||||
if( is_mac_accelerated( operation->alg ) )
|
||||
return( mac_update( operation, input, input_length ) );
|
||||
else
|
||||
return( PSA_ERROR_BAD_STATE );
|
||||
}
|
||||
|
||||
psa_status_t mbedtls_transparent_test_driver_mac_sign_finish(
|
||||
mbedtls_transparent_test_driver_mac_operation_t *operation,
|
||||
uint8_t *mac,
|
||||
size_t mac_size,
|
||||
size_t *mac_length )
|
||||
{
|
||||
if( is_mac_accelerated( operation->alg ) )
|
||||
return( mac_sign_finish( operation, mac, mac_size, mac_length ) );
|
||||
else
|
||||
return( PSA_ERROR_BAD_STATE );
|
||||
}
|
||||
|
||||
psa_status_t mbedtls_transparent_test_driver_mac_verify_finish(
|
||||
mbedtls_transparent_test_driver_mac_operation_t *operation,
|
||||
const uint8_t *mac,
|
||||
size_t mac_length )
|
||||
{
|
||||
if( is_mac_accelerated( operation->alg ) )
|
||||
return( mac_verify_finish( operation, mac, mac_length ) );
|
||||
else
|
||||
return( PSA_ERROR_BAD_STATE );
|
||||
}
|
||||
|
||||
psa_status_t mbedtls_transparent_test_driver_mac_abort(
|
||||
mbedtls_transparent_test_driver_mac_operation_t *operation )
|
||||
{
|
||||
return( mac_abort( operation ) );
|
||||
}
|
||||
|
||||
psa_status_t mbedtls_opaque_test_driver_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 )
|
||||
{
|
||||
/* Opaque driver testing is not implemented yet through this mechanism. */
|
||||
(void) attributes;
|
||||
(void) key_buffer;
|
||||
(void) key_buffer_size;
|
||||
(void) alg;
|
||||
(void) input;
|
||||
(void) input_length;
|
||||
(void) mac;
|
||||
(void) mac_size;
|
||||
(void) mac_length;
|
||||
return( PSA_ERROR_NOT_SUPPORTED );
|
||||
}
|
||||
|
||||
psa_status_t mbedtls_opaque_test_driver_mac_sign_setup(
|
||||
mbedtls_opaque_test_driver_mac_operation_t *operation,
|
||||
const psa_key_attributes_t *attributes,
|
||||
const uint8_t *key_buffer,
|
||||
size_t key_buffer_size,
|
||||
psa_algorithm_t alg )
|
||||
{
|
||||
/* Opaque driver testing is not implemented yet through this mechanism. */
|
||||
(void) operation;
|
||||
(void) attributes;
|
||||
(void) key_buffer;
|
||||
(void) key_buffer_size;
|
||||
(void) alg;
|
||||
return( PSA_ERROR_NOT_SUPPORTED );
|
||||
}
|
||||
|
||||
psa_status_t mbedtls_opaque_test_driver_mac_verify_setup(
|
||||
mbedtls_opaque_test_driver_mac_operation_t *operation,
|
||||
const psa_key_attributes_t *attributes,
|
||||
const uint8_t *key_buffer,
|
||||
size_t key_buffer_size,
|
||||
psa_algorithm_t alg )
|
||||
{
|
||||
/* Opaque driver testing is not implemented yet through this mechanism. */
|
||||
(void) operation;
|
||||
(void) attributes;
|
||||
(void) key_buffer;
|
||||
(void) key_buffer_size;
|
||||
(void) alg;
|
||||
return( PSA_ERROR_NOT_SUPPORTED );
|
||||
}
|
||||
|
||||
psa_status_t mbedtls_opaque_test_driver_mac_update(
|
||||
mbedtls_opaque_test_driver_mac_operation_t *operation,
|
||||
const uint8_t *input,
|
||||
size_t input_length )
|
||||
{
|
||||
/* Opaque driver testing is not implemented yet through this mechanism. */
|
||||
(void) operation;
|
||||
(void) input;
|
||||
(void) input_length;
|
||||
return( PSA_ERROR_NOT_SUPPORTED );
|
||||
}
|
||||
|
||||
psa_status_t mbedtls_opaque_test_driver_mac_sign_finish(
|
||||
mbedtls_opaque_test_driver_mac_operation_t *operation,
|
||||
uint8_t *mac,
|
||||
size_t mac_size,
|
||||
size_t *mac_length )
|
||||
{
|
||||
/* Opaque driver testing is not implemented yet through this mechanism. */
|
||||
(void) operation;
|
||||
(void) mac;
|
||||
(void) mac_size;
|
||||
(void) mac_length;
|
||||
return( PSA_ERROR_NOT_SUPPORTED );
|
||||
}
|
||||
|
||||
psa_status_t mbedtls_opaque_test_driver_mac_verify_finish(
|
||||
mbedtls_opaque_test_driver_mac_operation_t *operation,
|
||||
const uint8_t *mac,
|
||||
size_t mac_length )
|
||||
{
|
||||
/* Opaque driver testing is not implemented yet through this mechanism. */
|
||||
(void) operation;
|
||||
(void) mac;
|
||||
(void) mac_length;
|
||||
return( PSA_ERROR_NOT_SUPPORTED );
|
||||
}
|
||||
|
||||
psa_status_t mbedtls_opaque_test_driver_mac_abort(
|
||||
mbedtls_opaque_test_driver_mac_operation_t *operation )
|
||||
{
|
||||
/* Opaque driver testing is not implemented yet through this mechanism. */
|
||||
(void) operation;
|
||||
return( PSA_ERROR_NOT_SUPPORTED );
|
||||
}
|
||||
|
||||
#endif /* PSA_CRYPTO_DRIVER_TEST */
|
||||
|
||||
#endif /* MBEDTLS_PSA_CRYPTO_C */
|
||||
372
library/psa_crypto_mac.h
Normal file
372
library/psa_crypto_mac.h
Normal file
@@ -0,0 +1,372 @@
|
||||
/*
|
||||
* PSA MAC layer on top of Mbed TLS software crypto
|
||||
*/
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef PSA_CRYPTO_MAC_H
|
||||
#define PSA_CRYPTO_MAC_H
|
||||
|
||||
#include <psa/crypto.h>
|
||||
|
||||
/** Calculate the MAC (message authentication code) of a message using Mbed TLS.
|
||||
*
|
||||
* \note The signature of this function is that of a PSA driver mac_compute
|
||||
* entry point. This function behaves as a mac_compute entry point as
|
||||
* defined in the PSA driver interface specification for transparent
|
||||
* drivers.
|
||||
*
|
||||
* \param[in] attributes The attributes of the key to use for the
|
||||
* operation.
|
||||
* \param[in] key_buffer The buffer containing the key to use for
|
||||
* computing the MAC. This buffer contains the key
|
||||
* in export representation as defined by
|
||||
* psa_export_key() (i.e. the raw key bytes).
|
||||
* \param key_buffer_size Size of the \p key_buffer buffer in bytes.
|
||||
* \param alg The MAC algorithm to use (\c PSA_ALG_XXX value
|
||||
* such that #PSA_ALG_IS_MAC(\p alg) is true).
|
||||
* \param[in] input Buffer containing the input message.
|
||||
* \param input_length Size of the \p input buffer in bytes.
|
||||
* \param[out] mac Buffer where the MAC value is to be written.
|
||||
* \param mac_size Size of the \p mac buffer in bytes.
|
||||
* \param[out] mac_length On success, the number of bytes
|
||||
* that make up the MAC value.
|
||||
*
|
||||
* \retval #PSA_SUCCESS
|
||||
* Success.
|
||||
* \retval #PSA_ERROR_NOT_SUPPORTED
|
||||
* \p alg is not supported.
|
||||
* \retval #PSA_ERROR_BUFFER_TOO_SMALL
|
||||
* \p mac_size is too small
|
||||
* \retval #PSA_ERROR_INSUFFICIENT_MEMORY
|
||||
* \retval #PSA_ERROR_CORRUPTION_DETECTED
|
||||
*/
|
||||
psa_status_t mbedtls_psa_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);
|
||||
|
||||
/** Set up a multipart MAC calculation operation using Mbed TLS.
|
||||
*
|
||||
* \note The signature of this function is that of a PSA driver mac_sign_setup
|
||||
* entry point. This function behaves as a mac_sign_setup entry point as
|
||||
* defined in the PSA driver interface specification for transparent
|
||||
* drivers.
|
||||
*
|
||||
* \param[in,out] operation The operation object to set up. It must have
|
||||
* been initialized and not yet in use.
|
||||
* \param[in] attributes The attributes of the key to use for the
|
||||
* operation.
|
||||
* \param[in] key_buffer The buffer containing the key to use for
|
||||
* computing the MAC. This buffer contains the key
|
||||
* in export representation as defined by
|
||||
* psa_export_key() (i.e. the raw key bytes).
|
||||
* \param key_buffer_size Size of the \p key_buffer buffer in bytes.
|
||||
* \param alg The MAC algorithm to use (\c PSA_ALG_XXX value
|
||||
* such that #PSA_ALG_IS_MAC(\p alg) is true).
|
||||
*
|
||||
* \retval #PSA_SUCCESS
|
||||
* Success.
|
||||
* \retval #PSA_ERROR_NOT_SUPPORTED
|
||||
* \p alg is not supported.
|
||||
* \retval #PSA_ERROR_INSUFFICIENT_MEMORY
|
||||
* \retval #PSA_ERROR_CORRUPTION_DETECTED
|
||||
* \retval #PSA_ERROR_BAD_STATE
|
||||
* The operation state is not valid (it must be inactive).
|
||||
*/
|
||||
psa_status_t mbedtls_psa_mac_sign_setup(
|
||||
mbedtls_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);
|
||||
|
||||
/** Set up a multipart MAC verification operation using Mbed TLS.
|
||||
*
|
||||
* \note The signature of this function is that of a PSA driver mac_verify_setup
|
||||
* entry point. This function behaves as a mac_verify_setup entry point as
|
||||
* defined in the PSA driver interface specification for transparent
|
||||
* drivers.
|
||||
*
|
||||
* \param[in,out] operation The operation object to set up. It must have
|
||||
* been initialized and not yet in use.
|
||||
* \param[in] attributes The attributes of the key to use for the
|
||||
* operation.
|
||||
* \param[in] key_buffer The buffer containing the key to use for
|
||||
* computing the MAC. This buffer contains the key
|
||||
* in export representation as defined by
|
||||
* psa_export_key() (i.e. the raw key bytes).
|
||||
* \param key_buffer_size Size of the \p key_buffer buffer in bytes.
|
||||
* \param alg The MAC algorithm to use (\c PSA_ALG_XXX value
|
||||
* such that #PSA_ALG_IS_MAC(\p alg) is true).
|
||||
*
|
||||
* \retval #PSA_SUCCESS
|
||||
* Success.
|
||||
* \retval #PSA_ERROR_NOT_SUPPORTED
|
||||
* \p alg is not supported.
|
||||
* \retval #PSA_ERROR_INSUFFICIENT_MEMORY
|
||||
* \retval #PSA_ERROR_CORRUPTION_DETECTED
|
||||
* \retval #PSA_ERROR_BAD_STATE
|
||||
* The operation state is not valid (it must be inactive).
|
||||
*/
|
||||
psa_status_t mbedtls_psa_mac_verify_setup(
|
||||
mbedtls_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);
|
||||
|
||||
/** Add a message fragment to a multipart MAC operation using Mbed TLS.
|
||||
*
|
||||
* \note The signature of this function is that of a PSA driver mac_update
|
||||
* entry point. This function behaves as a mac_update entry point as
|
||||
* defined in the PSA driver interface specification for transparent
|
||||
* drivers.
|
||||
*
|
||||
* The PSA core calls mbedtls_psa_mac_sign_setup() or
|
||||
* mbedtls_psa_mac_verify_setup() before calling this function.
|
||||
*
|
||||
* If this function returns an error status, the PSA core aborts the
|
||||
* operation by calling mbedtls_psa_mac_abort().
|
||||
*
|
||||
* \param[in,out] operation Active MAC operation.
|
||||
* \param[in] input Buffer containing the message fragment to add to
|
||||
* the MAC calculation.
|
||||
* \param input_length Size of the \p input buffer in bytes.
|
||||
*
|
||||
* \retval #PSA_SUCCESS
|
||||
* Success.
|
||||
* \retval #PSA_ERROR_BAD_STATE
|
||||
* The operation state is not valid (it must be active).
|
||||
* \retval #PSA_ERROR_INSUFFICIENT_MEMORY
|
||||
* \retval #PSA_ERROR_CORRUPTION_DETECTED
|
||||
*/
|
||||
psa_status_t mbedtls_psa_mac_update(
|
||||
mbedtls_psa_mac_operation_t *operation,
|
||||
const uint8_t *input,
|
||||
size_t input_length );
|
||||
|
||||
/** Finish the calculation of the MAC of a message using Mbed TLS.
|
||||
*
|
||||
* \note The signature of this function is that of a PSA driver mac_sign_finish
|
||||
* entry point. This function behaves as a mac_sign_finish entry point as
|
||||
* defined in the PSA driver interface specification for transparent
|
||||
* drivers.
|
||||
*
|
||||
* The PSA core calls mbedtls_psa_mac_sign_setup() before calling this function.
|
||||
* This function calculates the MAC of the message formed by concatenating
|
||||
* the inputs passed to preceding calls to mbedtls_psa_mac_update().
|
||||
*
|
||||
* Whether this function returns successfully or not, the PSA core subsequently
|
||||
* aborts the operation by calling mbedtls_psa_mac_abort().
|
||||
*
|
||||
* \param[in,out] operation Active MAC operation.
|
||||
* \param[out] mac Buffer where the MAC value is to be written.
|
||||
* \param mac_size Output size requested for the MAC algorithm. The PSA
|
||||
* core guarantees this is a valid MAC length for the
|
||||
* algorithm and key combination passed to
|
||||
* mbedtls_psa_mac_sign_setup(). It also guarantees the
|
||||
* \p mac buffer is large enough to contain the
|
||||
* requested output size.
|
||||
* \param[out] mac_length On success, the number of bytes output to buffer
|
||||
* \p mac, which will be equal to the requested length
|
||||
* \p mac_size.
|
||||
*
|
||||
* \retval #PSA_SUCCESS
|
||||
* Success.
|
||||
* \retval #PSA_ERROR_BAD_STATE
|
||||
* The operation state is not valid (it must be an active mac sign
|
||||
* operation).
|
||||
* \retval #PSA_ERROR_BUFFER_TOO_SMALL
|
||||
* The size of the \p mac buffer is too small. A sufficient buffer size
|
||||
* can be determined by calling PSA_MAC_LENGTH().
|
||||
* \retval #PSA_ERROR_INSUFFICIENT_MEMORY
|
||||
* \retval #PSA_ERROR_CORRUPTION_DETECTED
|
||||
*/
|
||||
psa_status_t mbedtls_psa_mac_sign_finish(
|
||||
mbedtls_psa_mac_operation_t *operation,
|
||||
uint8_t *mac,
|
||||
size_t mac_size,
|
||||
size_t *mac_length );
|
||||
|
||||
/** Finish the calculation of the MAC of a message and compare it with
|
||||
* an expected value using Mbed TLS.
|
||||
*
|
||||
* \note The signature of this function is that of a PSA driver
|
||||
* mac_verify_finish entry point. This function behaves as a
|
||||
* mac_verify_finish entry point as defined in the PSA driver interface
|
||||
* specification for transparent drivers.
|
||||
*
|
||||
* The PSA core calls mbedtls_psa_mac_verify_setup() before calling this
|
||||
* function. This function calculates the MAC of the message formed by
|
||||
* concatenating the inputs passed to preceding calls to
|
||||
* mbedtls_psa_mac_update(). It then compares the calculated MAC with the
|
||||
* expected MAC passed as a parameter to this function.
|
||||
*
|
||||
* Whether this function returns successfully or not, the PSA core subsequently
|
||||
* aborts the operation by calling mbedtls_psa_mac_abort().
|
||||
*
|
||||
* \param[in,out] operation Active MAC operation.
|
||||
* \param[in] mac Buffer containing the expected MAC value.
|
||||
* \param mac_length Length in bytes of the expected MAC value. The PSA
|
||||
* core guarantees that this length is a valid MAC
|
||||
* length for the algorithm and key combination passed
|
||||
* to mbedtls_psa_mac_verify_setup().
|
||||
*
|
||||
* \retval #PSA_SUCCESS
|
||||
* The expected MAC is identical to the actual MAC of the message.
|
||||
* \retval #PSA_ERROR_INVALID_SIGNATURE
|
||||
* The MAC of the message was calculated successfully, but it
|
||||
* differs from the expected MAC.
|
||||
* \retval #PSA_ERROR_BAD_STATE
|
||||
* The operation state is not valid (it must be an active mac verify
|
||||
* operation).
|
||||
* \retval #PSA_ERROR_INSUFFICIENT_MEMORY
|
||||
* \retval #PSA_ERROR_CORRUPTION_DETECTED
|
||||
*/
|
||||
psa_status_t mbedtls_psa_mac_verify_finish(
|
||||
mbedtls_psa_mac_operation_t *operation,
|
||||
const uint8_t *mac,
|
||||
size_t mac_length );
|
||||
|
||||
/** Abort a MAC operation using Mbed TLS.
|
||||
*
|
||||
* Aborting an operation frees all associated resources except for the
|
||||
* \p operation structure itself. Once aborted, the operation object
|
||||
* can be reused for another operation by calling
|
||||
* mbedtls_psa_mac_sign_setup() or mbedtls_psa_mac_verify_setup() again.
|
||||
*
|
||||
* The PSA core may call this function any time after the operation object has
|
||||
* been initialized by one of the methods described in
|
||||
* #mbedtls_psa_mac_operation_t.
|
||||
*
|
||||
* In particular, calling mbedtls_psa_mac_abort() after the operation has been
|
||||
* terminated by a call to mbedtls_psa_mac_abort(),
|
||||
* mbedtls_psa_mac_sign_finish() or mbedtls_psa_mac_verify_finish() is safe and
|
||||
* has no effect.
|
||||
*
|
||||
* \param[in,out] operation Initialized MAC operation.
|
||||
*
|
||||
* \retval #PSA_SUCCESS
|
||||
* \retval #PSA_ERROR_CORRUPTION_DETECTED
|
||||
*/
|
||||
psa_status_t mbedtls_psa_mac_abort(
|
||||
mbedtls_psa_mac_operation_t *operation );
|
||||
|
||||
/*
|
||||
* BEYOND THIS POINT, TEST DRIVER ENTRY POINTS ONLY.
|
||||
*/
|
||||
|
||||
#if defined(PSA_CRYPTO_DRIVER_TEST)
|
||||
|
||||
psa_status_t mbedtls_transparent_test_driver_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 mbedtls_transparent_test_driver_mac_sign_setup(
|
||||
mbedtls_transparent_test_driver_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 mbedtls_transparent_test_driver_mac_verify_setup(
|
||||
mbedtls_transparent_test_driver_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 mbedtls_transparent_test_driver_mac_update(
|
||||
mbedtls_transparent_test_driver_mac_operation_t *operation,
|
||||
const uint8_t *input,
|
||||
size_t input_length );
|
||||
|
||||
psa_status_t mbedtls_transparent_test_driver_mac_sign_finish(
|
||||
mbedtls_transparent_test_driver_mac_operation_t *operation,
|
||||
uint8_t *mac,
|
||||
size_t mac_size,
|
||||
size_t *mac_length );
|
||||
|
||||
psa_status_t mbedtls_transparent_test_driver_mac_verify_finish(
|
||||
mbedtls_transparent_test_driver_mac_operation_t *operation,
|
||||
const uint8_t *mac,
|
||||
size_t mac_length );
|
||||
|
||||
psa_status_t mbedtls_transparent_test_driver_mac_abort(
|
||||
mbedtls_transparent_test_driver_mac_operation_t *operation );
|
||||
|
||||
psa_status_t mbedtls_opaque_test_driver_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 mbedtls_opaque_test_driver_mac_sign_setup(
|
||||
mbedtls_opaque_test_driver_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 mbedtls_opaque_test_driver_mac_verify_setup(
|
||||
mbedtls_opaque_test_driver_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 mbedtls_opaque_test_driver_mac_update(
|
||||
mbedtls_opaque_test_driver_mac_operation_t *operation,
|
||||
const uint8_t *input,
|
||||
size_t input_length );
|
||||
|
||||
psa_status_t mbedtls_opaque_test_driver_mac_sign_finish(
|
||||
mbedtls_opaque_test_driver_mac_operation_t *operation,
|
||||
uint8_t *mac,
|
||||
size_t mac_size,
|
||||
size_t *mac_length );
|
||||
|
||||
psa_status_t mbedtls_opaque_test_driver_mac_verify_finish(
|
||||
mbedtls_opaque_test_driver_mac_operation_t *operation,
|
||||
const uint8_t *mac,
|
||||
size_t mac_length );
|
||||
|
||||
psa_status_t mbedtls_opaque_test_driver_mac_abort(
|
||||
mbedtls_opaque_test_driver_mac_operation_t *operation );
|
||||
|
||||
#endif /* PSA_CRYPTO_DRIVER_TEST */
|
||||
|
||||
#endif /* PSA_CRYPTO_MAC_H */
|
||||
@@ -1353,7 +1353,6 @@ int mbedtls_rsa_pkcs1_encrypt( mbedtls_rsa_context *ctx,
|
||||
int mbedtls_rsa_rsaes_oaep_decrypt( mbedtls_rsa_context *ctx,
|
||||
int (*f_rng)(void *, unsigned char *, size_t),
|
||||
void *p_rng,
|
||||
int mode,
|
||||
const unsigned char *label, size_t label_len,
|
||||
size_t *olen,
|
||||
const unsigned char *input,
|
||||
@@ -1370,8 +1369,6 @@ int mbedtls_rsa_rsaes_oaep_decrypt( mbedtls_rsa_context *ctx,
|
||||
mbedtls_md_context_t md_ctx;
|
||||
|
||||
RSA_VALIDATE_RET( ctx != NULL );
|
||||
RSA_VALIDATE_RET( mode == MBEDTLS_RSA_PRIVATE ||
|
||||
mode == MBEDTLS_RSA_PUBLIC );
|
||||
RSA_VALIDATE_RET( output_max_len == 0 || output != NULL );
|
||||
RSA_VALIDATE_RET( label_len == 0 || label != NULL );
|
||||
RSA_VALIDATE_RET( input != NULL );
|
||||
@@ -1380,7 +1377,7 @@ int mbedtls_rsa_rsaes_oaep_decrypt( mbedtls_rsa_context *ctx,
|
||||
/*
|
||||
* Parameters sanity checks
|
||||
*/
|
||||
if( mode == MBEDTLS_RSA_PRIVATE && ctx->padding != MBEDTLS_RSA_PKCS_V21 )
|
||||
if( ctx->padding != MBEDTLS_RSA_PKCS_V21 )
|
||||
return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
|
||||
|
||||
ilen = ctx->len;
|
||||
@@ -1401,9 +1398,7 @@ int mbedtls_rsa_rsaes_oaep_decrypt( mbedtls_rsa_context *ctx,
|
||||
/*
|
||||
* RSA operation
|
||||
*/
|
||||
ret = ( mode == MBEDTLS_RSA_PUBLIC )
|
||||
? mbedtls_rsa_public( ctx, input, buf )
|
||||
: mbedtls_rsa_private( ctx, f_rng, p_rng, input, buf );
|
||||
ret = mbedtls_rsa_private( ctx, f_rng, p_rng, input, buf );
|
||||
|
||||
if( ret != 0 )
|
||||
goto cleanup;
|
||||
@@ -1591,7 +1586,7 @@ static void mem_move_to_left( void *start,
|
||||
int mbedtls_rsa_rsaes_pkcs1_v15_decrypt( mbedtls_rsa_context *ctx,
|
||||
int (*f_rng)(void *, unsigned char *, size_t),
|
||||
void *p_rng,
|
||||
int mode, size_t *olen,
|
||||
size_t *olen,
|
||||
const unsigned char *input,
|
||||
unsigned char *output,
|
||||
size_t output_max_len )
|
||||
@@ -1616,8 +1611,6 @@ int mbedtls_rsa_rsaes_pkcs1_v15_decrypt( mbedtls_rsa_context *ctx,
|
||||
unsigned output_too_large;
|
||||
|
||||
RSA_VALIDATE_RET( ctx != NULL );
|
||||
RSA_VALIDATE_RET( mode == MBEDTLS_RSA_PRIVATE ||
|
||||
mode == MBEDTLS_RSA_PUBLIC );
|
||||
RSA_VALIDATE_RET( output_max_len == 0 || output != NULL );
|
||||
RSA_VALIDATE_RET( input != NULL );
|
||||
RSA_VALIDATE_RET( olen != NULL );
|
||||
@@ -1627,15 +1620,13 @@ int mbedtls_rsa_rsaes_pkcs1_v15_decrypt( mbedtls_rsa_context *ctx,
|
||||
ilen - 11 :
|
||||
output_max_len );
|
||||
|
||||
if( mode == MBEDTLS_RSA_PRIVATE && ctx->padding != MBEDTLS_RSA_PKCS_V15 )
|
||||
if( ctx->padding != MBEDTLS_RSA_PKCS_V15 )
|
||||
return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
|
||||
|
||||
if( ilen < 16 || ilen > sizeof( buf ) )
|
||||
return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
|
||||
|
||||
ret = ( mode == MBEDTLS_RSA_PUBLIC )
|
||||
? mbedtls_rsa_public( ctx, input, buf )
|
||||
: mbedtls_rsa_private( ctx, f_rng, p_rng, input, buf );
|
||||
ret = mbedtls_rsa_private( ctx, f_rng, p_rng, input, buf );
|
||||
|
||||
if( ret != 0 )
|
||||
goto cleanup;
|
||||
@@ -1644,37 +1635,20 @@ int mbedtls_rsa_rsaes_pkcs1_v15_decrypt( mbedtls_rsa_context *ctx,
|
||||
* memory trace. The first byte must be 0. */
|
||||
bad |= buf[0];
|
||||
|
||||
if( mode == MBEDTLS_RSA_PRIVATE )
|
||||
{
|
||||
/* Decode EME-PKCS1-v1_5 padding: 0x00 || 0x02 || PS || 0x00
|
||||
* where PS must be at least 8 nonzero bytes. */
|
||||
bad |= buf[1] ^ MBEDTLS_RSA_CRYPT;
|
||||
|
||||
/* Read the whole buffer. Set pad_done to nonzero if we find
|
||||
* the 0x00 byte and remember the padding length in pad_count. */
|
||||
for( i = 2; i < ilen; i++ )
|
||||
{
|
||||
pad_done |= ((buf[i] | (unsigned char)-buf[i]) >> 7) ^ 1;
|
||||
pad_count += ((pad_done | (unsigned char)-pad_done) >> 7) ^ 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Decode EMSA-PKCS1-v1_5 padding: 0x00 || 0x01 || PS || 0x00
|
||||
* where PS must be at least 8 bytes with the value 0xFF. */
|
||||
bad |= buf[1] ^ MBEDTLS_RSA_SIGN;
|
||||
/* Decode EME-PKCS1-v1_5 padding: 0x00 || 0x02 || PS || 0x00
|
||||
* where PS must be at least 8 nonzero bytes. */
|
||||
bad |= buf[1] ^ MBEDTLS_RSA_CRYPT;
|
||||
|
||||
/* Read the whole buffer. Set pad_done to nonzero if we find
|
||||
* the 0x00 byte and remember the padding length in pad_count.
|
||||
* If there's a non-0xff byte in the padding, the padding is bad. */
|
||||
for( i = 2; i < ilen; i++ )
|
||||
{
|
||||
pad_done |= if_int( buf[i], 0, 1 );
|
||||
pad_count += if_int( pad_done, 0, 1 );
|
||||
bad |= if_int( pad_done, 0, buf[i] ^ 0xFF );
|
||||
}
|
||||
/* Read the whole buffer. Set pad_done to nonzero if we find
|
||||
* the 0x00 byte and remember the padding length in pad_count. */
|
||||
for( i = 2; i < ilen; i++ )
|
||||
{
|
||||
pad_done |= ((buf[i] | (unsigned char)-buf[i]) >> 7) ^ 1;
|
||||
pad_count += ((pad_done | (unsigned char)-pad_done) >> 7) ^ 1;
|
||||
}
|
||||
|
||||
|
||||
/* If pad_done is still zero, there's no data, only unfinished padding. */
|
||||
bad |= if_int( pad_done, 0, 1 );
|
||||
|
||||
@@ -1763,14 +1737,12 @@ cleanup:
|
||||
int mbedtls_rsa_pkcs1_decrypt( mbedtls_rsa_context *ctx,
|
||||
int (*f_rng)(void *, unsigned char *, size_t),
|
||||
void *p_rng,
|
||||
int mode, size_t *olen,
|
||||
size_t *olen,
|
||||
const unsigned char *input,
|
||||
unsigned char *output,
|
||||
size_t output_max_len)
|
||||
{
|
||||
RSA_VALIDATE_RET( ctx != NULL );
|
||||
RSA_VALIDATE_RET( mode == MBEDTLS_RSA_PRIVATE ||
|
||||
mode == MBEDTLS_RSA_PUBLIC );
|
||||
RSA_VALIDATE_RET( output_max_len == 0 || output != NULL );
|
||||
RSA_VALIDATE_RET( input != NULL );
|
||||
RSA_VALIDATE_RET( olen != NULL );
|
||||
@@ -1779,13 +1751,13 @@ int mbedtls_rsa_pkcs1_decrypt( mbedtls_rsa_context *ctx,
|
||||
{
|
||||
#if defined(MBEDTLS_PKCS1_V15)
|
||||
case MBEDTLS_RSA_PKCS_V15:
|
||||
return mbedtls_rsa_rsaes_pkcs1_v15_decrypt( ctx, f_rng, p_rng, mode, olen,
|
||||
return mbedtls_rsa_rsaes_pkcs1_v15_decrypt( ctx, f_rng, p_rng, olen,
|
||||
input, output, output_max_len );
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_PKCS1_V21)
|
||||
case MBEDTLS_RSA_PKCS_V21:
|
||||
return mbedtls_rsa_rsaes_oaep_decrypt( ctx, f_rng, p_rng, mode, NULL, 0,
|
||||
return mbedtls_rsa_rsaes_oaep_decrypt( ctx, f_rng, p_rng, NULL, 0,
|
||||
olen, input, output,
|
||||
output_max_len );
|
||||
#endif
|
||||
@@ -2733,7 +2705,7 @@ int mbedtls_rsa_self_test( int verbose )
|
||||
if( verbose != 0 )
|
||||
mbedtls_printf( "passed\n PKCS#1 decryption : " );
|
||||
|
||||
if( mbedtls_rsa_pkcs1_decrypt( &rsa, myrand, NULL, MBEDTLS_RSA_PRIVATE,
|
||||
if( mbedtls_rsa_pkcs1_decrypt( &rsa, myrand, NULL,
|
||||
&len, rsa_ciphertext, rsa_decrypted,
|
||||
sizeof(rsa_decrypted) ) != 0 )
|
||||
{
|
||||
|
||||
@@ -339,7 +339,7 @@ int mbedtls_sha256_update_ret( mbedtls_sha256_context *ctx,
|
||||
* SHA-256 final digest
|
||||
*/
|
||||
int mbedtls_sha256_finish_ret( mbedtls_sha256_context *ctx,
|
||||
unsigned char output[32] )
|
||||
unsigned char *output )
|
||||
{
|
||||
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
|
||||
uint32_t used;
|
||||
@@ -410,7 +410,7 @@ int mbedtls_sha256_finish_ret( mbedtls_sha256_context *ctx,
|
||||
*/
|
||||
int mbedtls_sha256_ret( const unsigned char *input,
|
||||
size_t ilen,
|
||||
unsigned char output[32],
|
||||
unsigned char *output,
|
||||
int is224 )
|
||||
{
|
||||
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
|
||||
|
||||
@@ -380,7 +380,7 @@ int mbedtls_sha512_update_ret( mbedtls_sha512_context *ctx,
|
||||
* SHA-512 final digest
|
||||
*/
|
||||
int mbedtls_sha512_finish_ret( mbedtls_sha512_context *ctx,
|
||||
unsigned char output[64] )
|
||||
unsigned char *output )
|
||||
{
|
||||
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
|
||||
unsigned used;
|
||||
@@ -453,7 +453,7 @@ int mbedtls_sha512_finish_ret( mbedtls_sha512_context *ctx,
|
||||
*/
|
||||
int mbedtls_sha512_ret( const unsigned char *input,
|
||||
size_t ilen,
|
||||
unsigned char output[64],
|
||||
unsigned char *output,
|
||||
int is384 )
|
||||
{
|
||||
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
|
||||
|
||||
@@ -130,6 +130,14 @@
|
||||
* counter (8) + header (5) + IV(16) + MAC (16-48) + padding (0-256).
|
||||
*/
|
||||
|
||||
#if defined(MBEDTLS_SSL_PROTO_TLS1) || \
|
||||
defined(MBEDTLS_SSL_PROTO_TLS1_1) || \
|
||||
defined(MBEDTLS_SSL_PROTO_TLS1_2)
|
||||
#define MBEDTLS_SSL_PROTO_TLS1_2_OR_EARLIER
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_SSL_PROTO_TLS1_2_OR_EARLIER)
|
||||
|
||||
/* This macro determines whether CBC is supported. */
|
||||
#if defined(MBEDTLS_CIPHER_MODE_CBC) && \
|
||||
( defined(MBEDTLS_AES_C) || \
|
||||
@@ -139,6 +147,12 @@
|
||||
#define MBEDTLS_SSL_SOME_SUITES_USE_CBC
|
||||
#endif
|
||||
|
||||
/* This macro determines whether a ciphersuite using a
|
||||
* stream cipher can be used. */
|
||||
#if defined(MBEDTLS_CIPHER_NULL_CIPHER)
|
||||
#define MBEDTLS_SSL_SOME_SUITES_USE_STREAM
|
||||
#endif
|
||||
|
||||
/* This macro determines whether the CBC construct used in TLS 1.0-1.2 is supported. */
|
||||
#if defined(MBEDTLS_SSL_SOME_SUITES_USE_CBC) && \
|
||||
( defined(MBEDTLS_SSL_PROTO_TLS1) || \
|
||||
@@ -147,12 +161,14 @@
|
||||
#define MBEDTLS_SSL_SOME_SUITES_USE_TLS_CBC
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_CIPHER_NULL_CIPHER) || \
|
||||
#if defined(MBEDTLS_SSL_SOME_SUITES_USE_STREAM) || \
|
||||
defined(MBEDTLS_SSL_SOME_SUITES_USE_CBC)
|
||||
#define MBEDTLS_SSL_SOME_MODES_USE_MAC
|
||||
#define MBEDTLS_SSL_SOME_SUITES_USE_MAC
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_SSL_SOME_MODES_USE_MAC)
|
||||
#endif /* MBEDTLS_SSL_PROTO_TLS1_2_OR_EARLIER */
|
||||
|
||||
#if defined(MBEDTLS_SSL_SOME_SUITES_USE_MAC)
|
||||
/* Ciphersuites using HMAC */
|
||||
#if defined(MBEDTLS_SHA384_C)
|
||||
#define MBEDTLS_SSL_MAC_ADD 48 /* SHA-384 used for HMAC */
|
||||
@@ -161,7 +177,7 @@
|
||||
#else
|
||||
#define MBEDTLS_SSL_MAC_ADD 20 /* SHA-1 used for HMAC */
|
||||
#endif
|
||||
#else /* MBEDTLS_SSL_SOME_MODES_USE_MAC */
|
||||
#else /* MBEDTLS_SSL_SOME_SUITES_USE_MAC */
|
||||
/* AEAD ciphersuites: GCM and CCM use a 128 bits tag */
|
||||
#define MBEDTLS_SSL_MAC_ADD 16
|
||||
#endif
|
||||
@@ -213,23 +229,19 @@
|
||||
* Check that we obey the standard's message size bounds
|
||||
*/
|
||||
|
||||
#if MBEDTLS_SSL_MAX_CONTENT_LEN > 16384
|
||||
#error "Bad configuration - record content too large."
|
||||
#if MBEDTLS_SSL_IN_CONTENT_LEN > 16384
|
||||
#error "Bad configuration - incoming record content too large."
|
||||
#endif
|
||||
|
||||
#if MBEDTLS_SSL_IN_CONTENT_LEN > MBEDTLS_SSL_MAX_CONTENT_LEN
|
||||
#error "Bad configuration - incoming record content should not be larger than MBEDTLS_SSL_MAX_CONTENT_LEN."
|
||||
#if MBEDTLS_SSL_OUT_CONTENT_LEN > 16384
|
||||
#error "Bad configuration - outgoing record content too large."
|
||||
#endif
|
||||
|
||||
#if MBEDTLS_SSL_OUT_CONTENT_LEN > MBEDTLS_SSL_MAX_CONTENT_LEN
|
||||
#error "Bad configuration - outgoing record content should not be larger than MBEDTLS_SSL_MAX_CONTENT_LEN."
|
||||
#endif
|
||||
|
||||
#if MBEDTLS_SSL_IN_PAYLOAD_LEN > MBEDTLS_SSL_MAX_CONTENT_LEN + 2048
|
||||
#if MBEDTLS_SSL_IN_PAYLOAD_LEN > MBEDTLS_SSL_IN_CONTENT_LEN + 2048
|
||||
#error "Bad configuration - incoming protected record payload too large."
|
||||
#endif
|
||||
|
||||
#if MBEDTLS_SSL_OUT_PAYLOAD_LEN > MBEDTLS_SSL_MAX_CONTENT_LEN + 2048
|
||||
#if MBEDTLS_SSL_OUT_PAYLOAD_LEN > MBEDTLS_SSL_OUT_CONTENT_LEN + 2048
|
||||
#error "Bad configuration - outgoing protected record payload too large."
|
||||
#endif
|
||||
|
||||
@@ -711,7 +723,7 @@ struct mbedtls_ssl_transform
|
||||
unsigned char iv_enc[16]; /*!< IV (encryption) */
|
||||
unsigned char iv_dec[16]; /*!< IV (decryption) */
|
||||
|
||||
#if defined(MBEDTLS_SSL_SOME_MODES_USE_MAC)
|
||||
#if defined(MBEDTLS_SSL_SOME_SUITES_USE_MAC)
|
||||
|
||||
mbedtls_md_context_t md_ctx_enc; /*!< MAC (encryption) */
|
||||
mbedtls_md_context_t md_ctx_dec; /*!< MAC (decryption) */
|
||||
@@ -720,7 +732,7 @@ struct mbedtls_ssl_transform
|
||||
int encrypt_then_mac; /*!< flag for EtM activation */
|
||||
#endif
|
||||
|
||||
#endif /* MBEDTLS_SSL_SOME_MODES_USE_MAC */
|
||||
#endif /* MBEDTLS_SSL_SOME_SUITES_USE_MAC */
|
||||
|
||||
mbedtls_cipher_context_t cipher_ctx_enc; /*!< encryption context */
|
||||
mbedtls_cipher_context_t cipher_ctx_dec; /*!< decryption context */
|
||||
@@ -747,7 +759,7 @@ struct mbedtls_ssl_transform
|
||||
static inline int mbedtls_ssl_transform_uses_aead(
|
||||
const mbedtls_ssl_transform *transform )
|
||||
{
|
||||
#if defined(MBEDTLS_SSL_SOME_MODES_USE_MAC)
|
||||
#if defined(MBEDTLS_SSL_SOME_SUITES_USE_MAC)
|
||||
return( transform->maclen == 0 && transform->taglen != 0 );
|
||||
#else
|
||||
(void) transform;
|
||||
|
||||
@@ -86,7 +86,6 @@ int mbedtls_ssl_check_timer( mbedtls_ssl_context *ssl )
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
#if defined(MBEDTLS_SSL_RECORD_CHECKING)
|
||||
static int ssl_parse_record_header( mbedtls_ssl_context const *ssl,
|
||||
unsigned char *buf,
|
||||
size_t len,
|
||||
@@ -150,7 +149,6 @@ exit:
|
||||
MBEDTLS_SSL_DEBUG_MSG( 1, ( "<= mbedtls_ssl_check_record" ) );
|
||||
return( ret );
|
||||
}
|
||||
#endif /* MBEDTLS_SSL_RECORD_CHECKING */
|
||||
|
||||
#define SSL_DONT_FORCE_FLUSH 0
|
||||
#define SSL_FORCE_FLUSH 1
|
||||
@@ -633,7 +631,7 @@ int mbedtls_ssl_encrypt_buf( mbedtls_ssl_context *ssl,
|
||||
/*
|
||||
* Add MAC before if needed
|
||||
*/
|
||||
#if defined(MBEDTLS_SSL_SOME_MODES_USE_MAC)
|
||||
#if defined(MBEDTLS_SSL_SOME_SUITES_USE_MAC)
|
||||
if( mode == MBEDTLS_MODE_STREAM ||
|
||||
( mode == MBEDTLS_MODE_CBC
|
||||
#if defined(MBEDTLS_SSL_ENCRYPT_THEN_MAC)
|
||||
@@ -678,12 +676,12 @@ int mbedtls_ssl_encrypt_buf( mbedtls_ssl_context *ssl,
|
||||
post_avail -= transform->maclen;
|
||||
auth_done++;
|
||||
}
|
||||
#endif /* MBEDTLS_SSL_SOME_MODES_USE_MAC */
|
||||
#endif /* MBEDTLS_SSL_SOME_SUITES_USE_MAC */
|
||||
|
||||
/*
|
||||
* Encrypt
|
||||
*/
|
||||
#if defined(MBEDTLS_CIPHER_NULL_CIPHER)
|
||||
#if defined(MBEDTLS_SSL_SOME_SUITES_USE_STREAM)
|
||||
if( mode == MBEDTLS_MODE_STREAM )
|
||||
{
|
||||
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
|
||||
@@ -708,7 +706,7 @@ int mbedtls_ssl_encrypt_buf( mbedtls_ssl_context *ssl,
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif /* MBEDTLS_CIPHER_NULL_CIPHER */
|
||||
#endif /* MBEDTLS_SSL_SOME_SUITES_USE_STREAM */
|
||||
|
||||
#if defined(MBEDTLS_GCM_C) || \
|
||||
defined(MBEDTLS_CCM_C) || \
|
||||
@@ -1209,7 +1207,7 @@ int mbedtls_ssl_decrypt_buf( mbedtls_ssl_context const *ssl,
|
||||
size_t olen;
|
||||
mbedtls_cipher_mode_t mode;
|
||||
int ret, auth_done = 0;
|
||||
#if defined(MBEDTLS_SSL_SOME_MODES_USE_MAC)
|
||||
#if defined(MBEDTLS_SSL_SOME_SUITES_USE_MAC)
|
||||
size_t padlen = 0, correct = 1;
|
||||
#endif
|
||||
unsigned char* data;
|
||||
@@ -1245,7 +1243,7 @@ int mbedtls_ssl_decrypt_buf( mbedtls_ssl_context const *ssl,
|
||||
}
|
||||
#endif /* MBEDTLS_SSL_DTLS_CONNECTION_ID */
|
||||
|
||||
#if defined(MBEDTLS_CIPHER_NULL_CIPHER)
|
||||
#if defined(MBEDTLS_SSL_SOME_SUITES_USE_STREAM)
|
||||
if( mode == MBEDTLS_MODE_STREAM )
|
||||
{
|
||||
padlen = 0;
|
||||
@@ -1266,7 +1264,7 @@ int mbedtls_ssl_decrypt_buf( mbedtls_ssl_context const *ssl,
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif /* MBEDTLS_CIPHER_NULL_CIPHER */
|
||||
#endif /* MBEDTLS_SSL_SOME_SUITES_USE_STREAM */
|
||||
#if defined(MBEDTLS_GCM_C) || \
|
||||
defined(MBEDTLS_CCM_C) || \
|
||||
defined(MBEDTLS_CHACHAPOLY_C)
|
||||
@@ -1636,7 +1634,7 @@ int mbedtls_ssl_decrypt_buf( mbedtls_ssl_context const *ssl,
|
||||
* Authenticate if not done yet.
|
||||
* Compute the MAC regardless of the padding result (RFC4346, CBCTIME).
|
||||
*/
|
||||
#if defined(MBEDTLS_SSL_SOME_MODES_USE_MAC)
|
||||
#if defined(MBEDTLS_SSL_SOME_SUITES_USE_MAC)
|
||||
if( auth_done == 0 )
|
||||
{
|
||||
unsigned char mac_expect[MBEDTLS_SSL_MAC_ADD];
|
||||
@@ -1712,7 +1710,7 @@ int mbedtls_ssl_decrypt_buf( mbedtls_ssl_context const *ssl,
|
||||
*/
|
||||
if( correct == 0 )
|
||||
return( MBEDTLS_ERR_SSL_INVALID_MAC );
|
||||
#endif /* MBEDTLS_SSL_SOME_MODES_USE_MAC */
|
||||
#endif /* MBEDTLS_SSL_SOME_SUITES_USE_MAC */
|
||||
|
||||
/* Make extra sure authentication was performed, exactly once */
|
||||
if( auth_done != 1 )
|
||||
@@ -5628,7 +5626,7 @@ void mbedtls_ssl_transform_free( mbedtls_ssl_transform *transform )
|
||||
mbedtls_cipher_free( &transform->cipher_ctx_enc );
|
||||
mbedtls_cipher_free( &transform->cipher_ctx_dec );
|
||||
|
||||
#if defined(MBEDTLS_SSL_SOME_MODES_USE_MAC)
|
||||
#if defined(MBEDTLS_SSL_SOME_SUITES_USE_MAC)
|
||||
mbedtls_md_free( &transform->md_ctx_enc );
|
||||
mbedtls_md_free( &transform->md_ctx_dec );
|
||||
#endif
|
||||
|
||||
@@ -806,14 +806,14 @@ typedef int ssl_tls_prf_t(const unsigned char *, size_t, const char *,
|
||||
static int ssl_populate_transform( mbedtls_ssl_transform *transform,
|
||||
int ciphersuite,
|
||||
const unsigned char master[48],
|
||||
#if defined(MBEDTLS_SSL_SOME_MODES_USE_MAC)
|
||||
#if defined(MBEDTLS_SSL_SOME_SUITES_USE_MAC)
|
||||
#if defined(MBEDTLS_SSL_ENCRYPT_THEN_MAC)
|
||||
int encrypt_then_mac,
|
||||
#endif /* MBEDTLS_SSL_ENCRYPT_THEN_MAC */
|
||||
#if defined(MBEDTLS_SSL_TRUNCATED_HMAC)
|
||||
int trunc_hmac,
|
||||
#endif /* MBEDTLS_SSL_TRUNCATED_HMAC */
|
||||
#endif /* MBEDTLS_SSL_SOME_MODES_USE_MAC */
|
||||
#endif /* MBEDTLS_SSL_SOME_SUITES_USE_MAC */
|
||||
ssl_tls_prf_t tls_prf,
|
||||
const unsigned char randbytes[64],
|
||||
int minor_ver,
|
||||
@@ -846,7 +846,7 @@ static int ssl_populate_transform( mbedtls_ssl_transform *transform,
|
||||
* Some data just needs copying into the structure
|
||||
*/
|
||||
#if defined(MBEDTLS_SSL_ENCRYPT_THEN_MAC) && \
|
||||
defined(MBEDTLS_SSL_SOME_MODES_USE_MAC)
|
||||
defined(MBEDTLS_SSL_SOME_SUITES_USE_MAC)
|
||||
transform->encrypt_then_mac = encrypt_then_mac;
|
||||
#endif
|
||||
transform->minor_ver = minor_ver;
|
||||
@@ -967,7 +967,7 @@ static int ssl_populate_transform( mbedtls_ssl_transform *transform,
|
||||
}
|
||||
else
|
||||
#endif /* MBEDTLS_GCM_C || MBEDTLS_CCM_C || MBEDTLS_CHACHAPOLY_C */
|
||||
#if defined(MBEDTLS_SSL_SOME_MODES_USE_MAC)
|
||||
#if defined(MBEDTLS_SSL_SOME_SUITES_USE_MAC)
|
||||
if( cipher_info->mode == MBEDTLS_MODE_STREAM ||
|
||||
cipher_info->mode == MBEDTLS_MODE_CBC )
|
||||
{
|
||||
@@ -1044,7 +1044,7 @@ static int ssl_populate_transform( mbedtls_ssl_transform *transform,
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif /* MBEDTLS_SSL_SOME_MODES_USE_MAC */
|
||||
#endif /* MBEDTLS_SSL_SOME_SUITES_USE_MAC */
|
||||
{
|
||||
MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) );
|
||||
return( MBEDTLS_ERR_SSL_INTERNAL_ERROR );
|
||||
@@ -1105,7 +1105,7 @@ static int ssl_populate_transform( mbedtls_ssl_transform *transform,
|
||||
goto end;
|
||||
}
|
||||
|
||||
#if defined(MBEDTLS_SSL_SOME_MODES_USE_MAC)
|
||||
#if defined(MBEDTLS_SSL_SOME_SUITES_USE_MAC)
|
||||
#if defined(MBEDTLS_SSL_PROTO_TLS1) || defined(MBEDTLS_SSL_PROTO_TLS1_1) || \
|
||||
defined(MBEDTLS_SSL_PROTO_TLS1_2)
|
||||
if( minor_ver >= MBEDTLS_SSL_MINOR_VERSION_1 )
|
||||
@@ -1125,7 +1125,7 @@ static int ssl_populate_transform( mbedtls_ssl_transform *transform,
|
||||
ret = MBEDTLS_ERR_SSL_INTERNAL_ERROR;
|
||||
goto end;
|
||||
}
|
||||
#endif /* MBEDTLS_SSL_SOME_MODES_USE_MAC */
|
||||
#endif /* MBEDTLS_SSL_SOME_SUITES_USE_MAC */
|
||||
|
||||
((void) mac_dec);
|
||||
((void) mac_enc);
|
||||
@@ -1518,14 +1518,14 @@ int mbedtls_ssl_derive_keys( mbedtls_ssl_context *ssl )
|
||||
ret = ssl_populate_transform( ssl->transform_negotiate,
|
||||
ssl->session_negotiate->ciphersuite,
|
||||
ssl->session_negotiate->master,
|
||||
#if defined(MBEDTLS_SSL_SOME_MODES_USE_MAC)
|
||||
#if defined(MBEDTLS_SSL_SOME_SUITES_USE_MAC)
|
||||
#if defined(MBEDTLS_SSL_ENCRYPT_THEN_MAC)
|
||||
ssl->session_negotiate->encrypt_then_mac,
|
||||
#endif /* MBEDTLS_SSL_ENCRYPT_THEN_MAC */
|
||||
#if defined(MBEDTLS_SSL_TRUNCATED_HMAC)
|
||||
ssl->session_negotiate->trunc_hmac,
|
||||
#endif /* MBEDTLS_SSL_TRUNCATED_HMAC */
|
||||
#endif /* MBEDTLS_SSL_SOME_MODES_USE_MAC */
|
||||
#endif /* MBEDTLS_SSL_SOME_SUITES_USE_MAC */
|
||||
ssl->handshake->tls_prf,
|
||||
ssl->handshake->randbytes,
|
||||
ssl->minor_ver,
|
||||
@@ -1936,8 +1936,9 @@ int mbedtls_ssl_write_certificate( mbedtls_ssl_context *ssl )
|
||||
{
|
||||
if( mbedtls_ssl_own_cert( ssl ) == NULL )
|
||||
{
|
||||
MBEDTLS_SSL_DEBUG_MSG( 1, ( "got no certificate to send" ) );
|
||||
return( MBEDTLS_ERR_SSL_CERTIFICATE_REQUIRED );
|
||||
/* Should never happen because we shouldn't have picked the
|
||||
* ciphersuite if we don't have a certificate. */
|
||||
return( MBEDTLS_ERR_SSL_INTERNAL_ERROR );
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1964,7 +1965,7 @@ int mbedtls_ssl_write_certificate( mbedtls_ssl_context *ssl )
|
||||
MBEDTLS_SSL_DEBUG_MSG( 1, ( "certificate too large, %" MBEDTLS_PRINTF_SIZET
|
||||
" > %" MBEDTLS_PRINTF_SIZET,
|
||||
i + 3 + n, (size_t) MBEDTLS_SSL_OUT_CONTENT_LEN ) );
|
||||
return( MBEDTLS_ERR_SSL_CERTIFICATE_TOO_LARGE );
|
||||
return( MBEDTLS_ERR_SSL_BUFFER_TOO_SMALL );
|
||||
}
|
||||
|
||||
ssl->out_msg[i ] = (unsigned char)( n >> 16 );
|
||||
@@ -2897,8 +2898,6 @@ static void ssl_calc_finished_tls_sha256(
|
||||
|
||||
#if defined(MBEDTLS_SHA384_C)
|
||||
|
||||
typedef int (*finish_sha384_t)(mbedtls_sha512_context*, unsigned char*);
|
||||
|
||||
static void ssl_calc_finished_tls_sha384(
|
||||
mbedtls_ssl_context *ssl, unsigned char *buf, int from )
|
||||
{
|
||||
@@ -2957,13 +2956,7 @@ static void ssl_calc_finished_tls_sha384(
|
||||
MBEDTLS_SSL_DEBUG_BUF( 4, "finished sha512 state", (unsigned char *)
|
||||
sha512.state, sizeof( sha512.state ) );
|
||||
#endif
|
||||
/*
|
||||
* For SHA-384, we can save 16 bytes by keeping padbuf 48 bytes long.
|
||||
* However, to avoid stringop-overflow warning in gcc, we have to cast
|
||||
* mbedtls_sha512_finish_ret().
|
||||
*/
|
||||
finish_sha384_t finish = (finish_sha384_t)mbedtls_sha512_finish_ret;
|
||||
finish( &sha512, padbuf );
|
||||
mbedtls_sha512_finish_ret( &sha512, padbuf );
|
||||
|
||||
mbedtls_sha512_free( &sha512 );
|
||||
#endif
|
||||
@@ -3322,7 +3315,7 @@ void mbedtls_ssl_transform_init( mbedtls_ssl_transform *transform )
|
||||
mbedtls_cipher_init( &transform->cipher_ctx_enc );
|
||||
mbedtls_cipher_init( &transform->cipher_ctx_dec );
|
||||
|
||||
#if defined(MBEDTLS_SSL_SOME_MODES_USE_MAC)
|
||||
#if defined(MBEDTLS_SSL_SOME_SUITES_USE_MAC)
|
||||
mbedtls_md_init( &transform->md_ctx_enc );
|
||||
mbedtls_md_init( &transform->md_ctx_dec );
|
||||
#endif
|
||||
@@ -4646,7 +4639,7 @@ const char *mbedtls_ssl_get_version( const mbedtls_ssl_context *ssl )
|
||||
#if defined(MBEDTLS_SSL_MAX_FRAGMENT_LENGTH)
|
||||
size_t mbedtls_ssl_get_input_max_frag_len( const mbedtls_ssl_context *ssl )
|
||||
{
|
||||
size_t max_len = MBEDTLS_SSL_MAX_CONTENT_LEN;
|
||||
size_t max_len = MBEDTLS_SSL_IN_CONTENT_LEN;
|
||||
size_t read_mfl;
|
||||
|
||||
/* Use the configured MFL for the client if we're past SERVER_HELLO_DONE */
|
||||
@@ -6161,14 +6154,14 @@ static int ssl_context_load( mbedtls_ssl_context *ssl,
|
||||
ret = ssl_populate_transform( ssl->transform,
|
||||
ssl->session->ciphersuite,
|
||||
ssl->session->master,
|
||||
#if defined(MBEDTLS_SSL_SOME_MODES_USE_MAC)
|
||||
#if defined(MBEDTLS_SSL_SOME_SUITES_USE_MAC)
|
||||
#if defined(MBEDTLS_SSL_ENCRYPT_THEN_MAC)
|
||||
ssl->session->encrypt_then_mac,
|
||||
#endif
|
||||
#if defined(MBEDTLS_SSL_TRUNCATED_HMAC)
|
||||
ssl->session->trunc_hmac,
|
||||
#endif
|
||||
#endif /* MBEDTLS_SSL_SOME_MODES_USE_MAC */
|
||||
#endif /* MBEDTLS_SSL_SOME_SUITES_USE_MAC */
|
||||
ssl_tls12prf_from_cs( ssl->session->ciphersuite ),
|
||||
p, /* currently pointing to randbytes */
|
||||
MBEDTLS_SSL_MINOR_VERSION_3, /* (D)TLS 1.2 is forced */
|
||||
@@ -6985,14 +6978,14 @@ int mbedtls_ssl_set_calc_verify_md( mbedtls_ssl_context *ssl, int md )
|
||||
{
|
||||
#if defined(MBEDTLS_SSL_PROTO_TLS1_2)
|
||||
if( ssl->minor_ver != MBEDTLS_SSL_MINOR_VERSION_3 )
|
||||
return MBEDTLS_ERR_SSL_INVALID_VERIFY_HASH;
|
||||
return( -1 );
|
||||
|
||||
switch( md )
|
||||
{
|
||||
#if defined(MBEDTLS_SSL_PROTO_TLS1) || defined(MBEDTLS_SSL_PROTO_TLS1_1)
|
||||
#if defined(MBEDTLS_MD5_C)
|
||||
case MBEDTLS_SSL_HASH_MD5:
|
||||
return MBEDTLS_ERR_SSL_INVALID_VERIFY_HASH;
|
||||
return( -1 );
|
||||
#endif
|
||||
#if defined(MBEDTLS_SHA1_C)
|
||||
case MBEDTLS_SSL_HASH_SHA1:
|
||||
@@ -7011,7 +7004,7 @@ int mbedtls_ssl_set_calc_verify_md( mbedtls_ssl_context *ssl, int md )
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
return MBEDTLS_ERR_SSL_INVALID_VERIFY_HASH;
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -7019,7 +7012,7 @@ int mbedtls_ssl_set_calc_verify_md( mbedtls_ssl_context *ssl, int md )
|
||||
(void) ssl;
|
||||
(void) md;
|
||||
|
||||
return MBEDTLS_ERR_SSL_INVALID_VERIFY_HASH;
|
||||
return( -1 );
|
||||
#endif /* MBEDTLS_SSL_PROTO_TLS1_2 */
|
||||
}
|
||||
|
||||
|
||||
@@ -1,845 +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)
|
||||
"MBEDTLS_HAVE_ASM",
|
||||
#endif /* MBEDTLS_HAVE_ASM */
|
||||
#if defined(MBEDTLS_NO_UDBL_DIVISION)
|
||||
"MBEDTLS_NO_UDBL_DIVISION",
|
||||
#endif /* MBEDTLS_NO_UDBL_DIVISION */
|
||||
#if defined(MBEDTLS_NO_64BIT_MULTIPLICATION)
|
||||
"MBEDTLS_NO_64BIT_MULTIPLICATION",
|
||||
#endif /* MBEDTLS_NO_64BIT_MULTIPLICATION */
|
||||
#if defined(MBEDTLS_HAVE_SSE2)
|
||||
"MBEDTLS_HAVE_SSE2",
|
||||
#endif /* MBEDTLS_HAVE_SSE2 */
|
||||
#if defined(MBEDTLS_HAVE_TIME)
|
||||
"MBEDTLS_HAVE_TIME",
|
||||
#endif /* MBEDTLS_HAVE_TIME */
|
||||
#if defined(MBEDTLS_HAVE_TIME_DATE)
|
||||
"MBEDTLS_HAVE_TIME_DATE",
|
||||
#endif /* MBEDTLS_HAVE_TIME_DATE */
|
||||
#if defined(MBEDTLS_PLATFORM_MEMORY)
|
||||
"MBEDTLS_PLATFORM_MEMORY",
|
||||
#endif /* MBEDTLS_PLATFORM_MEMORY */
|
||||
#if defined(MBEDTLS_PLATFORM_NO_STD_FUNCTIONS)
|
||||
"MBEDTLS_PLATFORM_NO_STD_FUNCTIONS",
|
||||
#endif /* MBEDTLS_PLATFORM_NO_STD_FUNCTIONS */
|
||||
#if defined(MBEDTLS_PLATFORM_EXIT_ALT)
|
||||
"MBEDTLS_PLATFORM_EXIT_ALT",
|
||||
#endif /* MBEDTLS_PLATFORM_EXIT_ALT */
|
||||
#if defined(MBEDTLS_PLATFORM_TIME_ALT)
|
||||
"MBEDTLS_PLATFORM_TIME_ALT",
|
||||
#endif /* MBEDTLS_PLATFORM_TIME_ALT */
|
||||
#if defined(MBEDTLS_PLATFORM_FPRINTF_ALT)
|
||||
"MBEDTLS_PLATFORM_FPRINTF_ALT",
|
||||
#endif /* MBEDTLS_PLATFORM_FPRINTF_ALT */
|
||||
#if defined(MBEDTLS_PLATFORM_PRINTF_ALT)
|
||||
"MBEDTLS_PLATFORM_PRINTF_ALT",
|
||||
#endif /* MBEDTLS_PLATFORM_PRINTF_ALT */
|
||||
#if defined(MBEDTLS_PLATFORM_SNPRINTF_ALT)
|
||||
"MBEDTLS_PLATFORM_SNPRINTF_ALT",
|
||||
#endif /* MBEDTLS_PLATFORM_SNPRINTF_ALT */
|
||||
#if defined(MBEDTLS_PLATFORM_VSNPRINTF_ALT)
|
||||
"MBEDTLS_PLATFORM_VSNPRINTF_ALT",
|
||||
#endif /* MBEDTLS_PLATFORM_VSNPRINTF_ALT */
|
||||
#if defined(MBEDTLS_PLATFORM_NV_SEED_ALT)
|
||||
"MBEDTLS_PLATFORM_NV_SEED_ALT",
|
||||
#endif /* MBEDTLS_PLATFORM_NV_SEED_ALT */
|
||||
#if defined(MBEDTLS_PLATFORM_SETUP_TEARDOWN_ALT)
|
||||
"MBEDTLS_PLATFORM_SETUP_TEARDOWN_ALT",
|
||||
#endif /* MBEDTLS_PLATFORM_SETUP_TEARDOWN_ALT */
|
||||
#if defined(MBEDTLS_DEPRECATED_WARNING)
|
||||
"MBEDTLS_DEPRECATED_WARNING",
|
||||
#endif /* MBEDTLS_DEPRECATED_WARNING */
|
||||
#if defined(MBEDTLS_DEPRECATED_REMOVED)
|
||||
"MBEDTLS_DEPRECATED_REMOVED",
|
||||
#endif /* MBEDTLS_DEPRECATED_REMOVED */
|
||||
#if defined(MBEDTLS_CHECK_PARAMS)
|
||||
"MBEDTLS_CHECK_PARAMS",
|
||||
#endif /* MBEDTLS_CHECK_PARAMS */
|
||||
#if defined(MBEDTLS_CHECK_PARAMS_ASSERT)
|
||||
"MBEDTLS_CHECK_PARAMS_ASSERT",
|
||||
#endif /* MBEDTLS_CHECK_PARAMS_ASSERT */
|
||||
#if defined(MBEDTLS_TIMING_ALT)
|
||||
"MBEDTLS_TIMING_ALT",
|
||||
#endif /* MBEDTLS_TIMING_ALT */
|
||||
#if defined(MBEDTLS_AES_ALT)
|
||||
"MBEDTLS_AES_ALT",
|
||||
#endif /* MBEDTLS_AES_ALT */
|
||||
#if defined(MBEDTLS_ARC4_ALT)
|
||||
"MBEDTLS_ARC4_ALT",
|
||||
#endif /* MBEDTLS_ARC4_ALT */
|
||||
#if defined(MBEDTLS_ARIA_ALT)
|
||||
"MBEDTLS_ARIA_ALT",
|
||||
#endif /* MBEDTLS_ARIA_ALT */
|
||||
#if defined(MBEDTLS_BLOWFISH_ALT)
|
||||
"MBEDTLS_BLOWFISH_ALT",
|
||||
#endif /* MBEDTLS_BLOWFISH_ALT */
|
||||
#if defined(MBEDTLS_CAMELLIA_ALT)
|
||||
"MBEDTLS_CAMELLIA_ALT",
|
||||
#endif /* MBEDTLS_CAMELLIA_ALT */
|
||||
#if defined(MBEDTLS_CCM_ALT)
|
||||
"MBEDTLS_CCM_ALT",
|
||||
#endif /* MBEDTLS_CCM_ALT */
|
||||
#if defined(MBEDTLS_CHACHA20_ALT)
|
||||
"MBEDTLS_CHACHA20_ALT",
|
||||
#endif /* MBEDTLS_CHACHA20_ALT */
|
||||
#if defined(MBEDTLS_CHACHAPOLY_ALT)
|
||||
"MBEDTLS_CHACHAPOLY_ALT",
|
||||
#endif /* MBEDTLS_CHACHAPOLY_ALT */
|
||||
#if defined(MBEDTLS_CMAC_ALT)
|
||||
"MBEDTLS_CMAC_ALT",
|
||||
#endif /* MBEDTLS_CMAC_ALT */
|
||||
#if defined(MBEDTLS_DES_ALT)
|
||||
"MBEDTLS_DES_ALT",
|
||||
#endif /* MBEDTLS_DES_ALT */
|
||||
#if defined(MBEDTLS_DHM_ALT)
|
||||
"MBEDTLS_DHM_ALT",
|
||||
#endif /* MBEDTLS_DHM_ALT */
|
||||
#if defined(MBEDTLS_ECJPAKE_ALT)
|
||||
"MBEDTLS_ECJPAKE_ALT",
|
||||
#endif /* MBEDTLS_ECJPAKE_ALT */
|
||||
#if defined(MBEDTLS_GCM_ALT)
|
||||
"MBEDTLS_GCM_ALT",
|
||||
#endif /* MBEDTLS_GCM_ALT */
|
||||
#if defined(MBEDTLS_NIST_KW_ALT)
|
||||
"MBEDTLS_NIST_KW_ALT",
|
||||
#endif /* MBEDTLS_NIST_KW_ALT */
|
||||
#if defined(MBEDTLS_MD2_ALT)
|
||||
"MBEDTLS_MD2_ALT",
|
||||
#endif /* MBEDTLS_MD2_ALT */
|
||||
#if defined(MBEDTLS_MD4_ALT)
|
||||
"MBEDTLS_MD4_ALT",
|
||||
#endif /* MBEDTLS_MD4_ALT */
|
||||
#if defined(MBEDTLS_MD5_ALT)
|
||||
"MBEDTLS_MD5_ALT",
|
||||
#endif /* MBEDTLS_MD5_ALT */
|
||||
#if defined(MBEDTLS_POLY1305_ALT)
|
||||
"MBEDTLS_POLY1305_ALT",
|
||||
#endif /* MBEDTLS_POLY1305_ALT */
|
||||
#if defined(MBEDTLS_RIPEMD160_ALT)
|
||||
"MBEDTLS_RIPEMD160_ALT",
|
||||
#endif /* MBEDTLS_RIPEMD160_ALT */
|
||||
#if defined(MBEDTLS_RSA_ALT)
|
||||
"MBEDTLS_RSA_ALT",
|
||||
#endif /* MBEDTLS_RSA_ALT */
|
||||
#if defined(MBEDTLS_SHA1_ALT)
|
||||
"MBEDTLS_SHA1_ALT",
|
||||
#endif /* MBEDTLS_SHA1_ALT */
|
||||
#if defined(MBEDTLS_SHA256_ALT)
|
||||
"MBEDTLS_SHA256_ALT",
|
||||
#endif /* MBEDTLS_SHA256_ALT */
|
||||
#if defined(MBEDTLS_SHA512_ALT)
|
||||
"MBEDTLS_SHA512_ALT",
|
||||
#endif /* MBEDTLS_SHA512_ALT */
|
||||
#if defined(MBEDTLS_XTEA_ALT)
|
||||
"MBEDTLS_XTEA_ALT",
|
||||
#endif /* MBEDTLS_XTEA_ALT */
|
||||
#if defined(MBEDTLS_ECP_ALT)
|
||||
"MBEDTLS_ECP_ALT",
|
||||
#endif /* MBEDTLS_ECP_ALT */
|
||||
#if defined(MBEDTLS_MD2_PROCESS_ALT)
|
||||
"MBEDTLS_MD2_PROCESS_ALT",
|
||||
#endif /* MBEDTLS_MD2_PROCESS_ALT */
|
||||
#if defined(MBEDTLS_MD4_PROCESS_ALT)
|
||||
"MBEDTLS_MD4_PROCESS_ALT",
|
||||
#endif /* MBEDTLS_MD4_PROCESS_ALT */
|
||||
#if defined(MBEDTLS_MD5_PROCESS_ALT)
|
||||
"MBEDTLS_MD5_PROCESS_ALT",
|
||||
#endif /* MBEDTLS_MD5_PROCESS_ALT */
|
||||
#if defined(MBEDTLS_RIPEMD160_PROCESS_ALT)
|
||||
"MBEDTLS_RIPEMD160_PROCESS_ALT",
|
||||
#endif /* MBEDTLS_RIPEMD160_PROCESS_ALT */
|
||||
#if defined(MBEDTLS_SHA1_PROCESS_ALT)
|
||||
"MBEDTLS_SHA1_PROCESS_ALT",
|
||||
#endif /* MBEDTLS_SHA1_PROCESS_ALT */
|
||||
#if defined(MBEDTLS_SHA256_PROCESS_ALT)
|
||||
"MBEDTLS_SHA256_PROCESS_ALT",
|
||||
#endif /* MBEDTLS_SHA256_PROCESS_ALT */
|
||||
#if defined(MBEDTLS_SHA512_PROCESS_ALT)
|
||||
"MBEDTLS_SHA512_PROCESS_ALT",
|
||||
#endif /* MBEDTLS_SHA512_PROCESS_ALT */
|
||||
#if defined(MBEDTLS_DES_SETKEY_ALT)
|
||||
"MBEDTLS_DES_SETKEY_ALT",
|
||||
#endif /* MBEDTLS_DES_SETKEY_ALT */
|
||||
#if defined(MBEDTLS_DES_CRYPT_ECB_ALT)
|
||||
"MBEDTLS_DES_CRYPT_ECB_ALT",
|
||||
#endif /* MBEDTLS_DES_CRYPT_ECB_ALT */
|
||||
#if defined(MBEDTLS_DES3_CRYPT_ECB_ALT)
|
||||
"MBEDTLS_DES3_CRYPT_ECB_ALT",
|
||||
#endif /* MBEDTLS_DES3_CRYPT_ECB_ALT */
|
||||
#if defined(MBEDTLS_AES_SETKEY_ENC_ALT)
|
||||
"MBEDTLS_AES_SETKEY_ENC_ALT",
|
||||
#endif /* MBEDTLS_AES_SETKEY_ENC_ALT */
|
||||
#if defined(MBEDTLS_AES_SETKEY_DEC_ALT)
|
||||
"MBEDTLS_AES_SETKEY_DEC_ALT",
|
||||
#endif /* MBEDTLS_AES_SETKEY_DEC_ALT */
|
||||
#if defined(MBEDTLS_AES_ENCRYPT_ALT)
|
||||
"MBEDTLS_AES_ENCRYPT_ALT",
|
||||
#endif /* MBEDTLS_AES_ENCRYPT_ALT */
|
||||
#if defined(MBEDTLS_AES_DECRYPT_ALT)
|
||||
"MBEDTLS_AES_DECRYPT_ALT",
|
||||
#endif /* MBEDTLS_AES_DECRYPT_ALT */
|
||||
#if defined(MBEDTLS_ECDH_GEN_PUBLIC_ALT)
|
||||
"MBEDTLS_ECDH_GEN_PUBLIC_ALT",
|
||||
#endif /* MBEDTLS_ECDH_GEN_PUBLIC_ALT */
|
||||
#if defined(MBEDTLS_ECDH_COMPUTE_SHARED_ALT)
|
||||
"MBEDTLS_ECDH_COMPUTE_SHARED_ALT",
|
||||
#endif /* MBEDTLS_ECDH_COMPUTE_SHARED_ALT */
|
||||
#if defined(MBEDTLS_ECDSA_VERIFY_ALT)
|
||||
"MBEDTLS_ECDSA_VERIFY_ALT",
|
||||
#endif /* MBEDTLS_ECDSA_VERIFY_ALT */
|
||||
#if defined(MBEDTLS_ECDSA_SIGN_ALT)
|
||||
"MBEDTLS_ECDSA_SIGN_ALT",
|
||||
#endif /* MBEDTLS_ECDSA_SIGN_ALT */
|
||||
#if defined(MBEDTLS_ECDSA_GENKEY_ALT)
|
||||
"MBEDTLS_ECDSA_GENKEY_ALT",
|
||||
#endif /* MBEDTLS_ECDSA_GENKEY_ALT */
|
||||
#if defined(MBEDTLS_ECP_INTERNAL_ALT)
|
||||
"MBEDTLS_ECP_INTERNAL_ALT",
|
||||
#endif /* MBEDTLS_ECP_INTERNAL_ALT */
|
||||
#if defined(MBEDTLS_ECP_NO_FALLBACK)
|
||||
"MBEDTLS_ECP_NO_FALLBACK",
|
||||
#endif /* MBEDTLS_ECP_NO_FALLBACK */
|
||||
#if defined(MBEDTLS_ECP_RANDOMIZE_JAC_ALT)
|
||||
"MBEDTLS_ECP_RANDOMIZE_JAC_ALT",
|
||||
#endif /* MBEDTLS_ECP_RANDOMIZE_JAC_ALT */
|
||||
#if defined(MBEDTLS_ECP_ADD_MIXED_ALT)
|
||||
"MBEDTLS_ECP_ADD_MIXED_ALT",
|
||||
#endif /* MBEDTLS_ECP_ADD_MIXED_ALT */
|
||||
#if defined(MBEDTLS_ECP_DOUBLE_JAC_ALT)
|
||||
"MBEDTLS_ECP_DOUBLE_JAC_ALT",
|
||||
#endif /* MBEDTLS_ECP_DOUBLE_JAC_ALT */
|
||||
#if defined(MBEDTLS_ECP_NORMALIZE_JAC_MANY_ALT)
|
||||
"MBEDTLS_ECP_NORMALIZE_JAC_MANY_ALT",
|
||||
#endif /* MBEDTLS_ECP_NORMALIZE_JAC_MANY_ALT */
|
||||
#if defined(MBEDTLS_ECP_NORMALIZE_JAC_ALT)
|
||||
"MBEDTLS_ECP_NORMALIZE_JAC_ALT",
|
||||
#endif /* MBEDTLS_ECP_NORMALIZE_JAC_ALT */
|
||||
#if defined(MBEDTLS_ECP_DOUBLE_ADD_MXZ_ALT)
|
||||
"MBEDTLS_ECP_DOUBLE_ADD_MXZ_ALT",
|
||||
#endif /* MBEDTLS_ECP_DOUBLE_ADD_MXZ_ALT */
|
||||
#if defined(MBEDTLS_ECP_RANDOMIZE_MXZ_ALT)
|
||||
"MBEDTLS_ECP_RANDOMIZE_MXZ_ALT",
|
||||
#endif /* MBEDTLS_ECP_RANDOMIZE_MXZ_ALT */
|
||||
#if defined(MBEDTLS_ECP_NORMALIZE_MXZ_ALT)
|
||||
"MBEDTLS_ECP_NORMALIZE_MXZ_ALT",
|
||||
#endif /* MBEDTLS_ECP_NORMALIZE_MXZ_ALT */
|
||||
#if defined(MBEDTLS_TEST_NULL_ENTROPY)
|
||||
"MBEDTLS_TEST_NULL_ENTROPY",
|
||||
#endif /* MBEDTLS_TEST_NULL_ENTROPY */
|
||||
#if defined(MBEDTLS_ENTROPY_HARDWARE_ALT)
|
||||
"MBEDTLS_ENTROPY_HARDWARE_ALT",
|
||||
#endif /* MBEDTLS_ENTROPY_HARDWARE_ALT */
|
||||
#if defined(MBEDTLS_AES_ROM_TABLES)
|
||||
"MBEDTLS_AES_ROM_TABLES",
|
||||
#endif /* MBEDTLS_AES_ROM_TABLES */
|
||||
#if defined(MBEDTLS_AES_FEWER_TABLES)
|
||||
"MBEDTLS_AES_FEWER_TABLES",
|
||||
#endif /* MBEDTLS_AES_FEWER_TABLES */
|
||||
#if defined(MBEDTLS_CAMELLIA_SMALL_MEMORY)
|
||||
"MBEDTLS_CAMELLIA_SMALL_MEMORY",
|
||||
#endif /* MBEDTLS_CAMELLIA_SMALL_MEMORY */
|
||||
#if defined(MBEDTLS_CIPHER_MODE_CBC)
|
||||
"MBEDTLS_CIPHER_MODE_CBC",
|
||||
#endif /* MBEDTLS_CIPHER_MODE_CBC */
|
||||
#if defined(MBEDTLS_CIPHER_MODE_CFB)
|
||||
"MBEDTLS_CIPHER_MODE_CFB",
|
||||
#endif /* MBEDTLS_CIPHER_MODE_CFB */
|
||||
#if defined(MBEDTLS_CIPHER_MODE_CTR)
|
||||
"MBEDTLS_CIPHER_MODE_CTR",
|
||||
#endif /* MBEDTLS_CIPHER_MODE_CTR */
|
||||
#if defined(MBEDTLS_CIPHER_MODE_OFB)
|
||||
"MBEDTLS_CIPHER_MODE_OFB",
|
||||
#endif /* MBEDTLS_CIPHER_MODE_OFB */
|
||||
#if defined(MBEDTLS_CIPHER_MODE_XTS)
|
||||
"MBEDTLS_CIPHER_MODE_XTS",
|
||||
#endif /* MBEDTLS_CIPHER_MODE_XTS */
|
||||
#if defined(MBEDTLS_CIPHER_NULL_CIPHER)
|
||||
"MBEDTLS_CIPHER_NULL_CIPHER",
|
||||
#endif /* MBEDTLS_CIPHER_NULL_CIPHER */
|
||||
#if defined(MBEDTLS_CIPHER_PADDING_PKCS7)
|
||||
"MBEDTLS_CIPHER_PADDING_PKCS7",
|
||||
#endif /* MBEDTLS_CIPHER_PADDING_PKCS7 */
|
||||
#if defined(MBEDTLS_CIPHER_PADDING_ONE_AND_ZEROS)
|
||||
"MBEDTLS_CIPHER_PADDING_ONE_AND_ZEROS",
|
||||
#endif /* MBEDTLS_CIPHER_PADDING_ONE_AND_ZEROS */
|
||||
#if defined(MBEDTLS_CIPHER_PADDING_ZEROS_AND_LEN)
|
||||
"MBEDTLS_CIPHER_PADDING_ZEROS_AND_LEN",
|
||||
#endif /* MBEDTLS_CIPHER_PADDING_ZEROS_AND_LEN */
|
||||
#if defined(MBEDTLS_CIPHER_PADDING_ZEROS)
|
||||
"MBEDTLS_CIPHER_PADDING_ZEROS",
|
||||
#endif /* MBEDTLS_CIPHER_PADDING_ZEROS */
|
||||
#if defined(MBEDTLS_CTR_DRBG_USE_128_BIT_KEY)
|
||||
"MBEDTLS_CTR_DRBG_USE_128_BIT_KEY",
|
||||
#endif /* MBEDTLS_CTR_DRBG_USE_128_BIT_KEY */
|
||||
#if defined(MBEDTLS_REMOVE_3DES_CIPHERSUITES)
|
||||
"MBEDTLS_REMOVE_3DES_CIPHERSUITES",
|
||||
#endif /* MBEDTLS_REMOVE_3DES_CIPHERSUITES */
|
||||
#if defined(MBEDTLS_ECP_DP_SECP192R1_ENABLED)
|
||||
"MBEDTLS_ECP_DP_SECP192R1_ENABLED",
|
||||
#endif /* MBEDTLS_ECP_DP_SECP192R1_ENABLED */
|
||||
#if defined(MBEDTLS_ECP_DP_SECP224R1_ENABLED)
|
||||
"MBEDTLS_ECP_DP_SECP224R1_ENABLED",
|
||||
#endif /* MBEDTLS_ECP_DP_SECP224R1_ENABLED */
|
||||
#if defined(MBEDTLS_ECP_DP_SECP256R1_ENABLED)
|
||||
"MBEDTLS_ECP_DP_SECP256R1_ENABLED",
|
||||
#endif /* MBEDTLS_ECP_DP_SECP256R1_ENABLED */
|
||||
#if defined(MBEDTLS_ECP_DP_SECP384R1_ENABLED)
|
||||
"MBEDTLS_ECP_DP_SECP384R1_ENABLED",
|
||||
#endif /* MBEDTLS_ECP_DP_SECP384R1_ENABLED */
|
||||
#if defined(MBEDTLS_ECP_DP_SECP521R1_ENABLED)
|
||||
"MBEDTLS_ECP_DP_SECP521R1_ENABLED",
|
||||
#endif /* MBEDTLS_ECP_DP_SECP521R1_ENABLED */
|
||||
#if defined(MBEDTLS_ECP_DP_SECP192K1_ENABLED)
|
||||
"MBEDTLS_ECP_DP_SECP192K1_ENABLED",
|
||||
#endif /* MBEDTLS_ECP_DP_SECP192K1_ENABLED */
|
||||
#if defined(MBEDTLS_ECP_DP_SECP224K1_ENABLED)
|
||||
"MBEDTLS_ECP_DP_SECP224K1_ENABLED",
|
||||
#endif /* MBEDTLS_ECP_DP_SECP224K1_ENABLED */
|
||||
#if defined(MBEDTLS_ECP_DP_SECP256K1_ENABLED)
|
||||
"MBEDTLS_ECP_DP_SECP256K1_ENABLED",
|
||||
#endif /* MBEDTLS_ECP_DP_SECP256K1_ENABLED */
|
||||
#if defined(MBEDTLS_ECP_DP_BP256R1_ENABLED)
|
||||
"MBEDTLS_ECP_DP_BP256R1_ENABLED",
|
||||
#endif /* MBEDTLS_ECP_DP_BP256R1_ENABLED */
|
||||
#if defined(MBEDTLS_ECP_DP_BP384R1_ENABLED)
|
||||
"MBEDTLS_ECP_DP_BP384R1_ENABLED",
|
||||
#endif /* MBEDTLS_ECP_DP_BP384R1_ENABLED */
|
||||
#if defined(MBEDTLS_ECP_DP_BP512R1_ENABLED)
|
||||
"MBEDTLS_ECP_DP_BP512R1_ENABLED",
|
||||
#endif /* MBEDTLS_ECP_DP_BP512R1_ENABLED */
|
||||
#if defined(MBEDTLS_ECP_DP_CURVE25519_ENABLED)
|
||||
"MBEDTLS_ECP_DP_CURVE25519_ENABLED",
|
||||
#endif /* MBEDTLS_ECP_DP_CURVE25519_ENABLED */
|
||||
#if defined(MBEDTLS_ECP_DP_CURVE448_ENABLED)
|
||||
"MBEDTLS_ECP_DP_CURVE448_ENABLED",
|
||||
#endif /* MBEDTLS_ECP_DP_CURVE448_ENABLED */
|
||||
#if defined(MBEDTLS_ECP_NIST_OPTIM)
|
||||
"MBEDTLS_ECP_NIST_OPTIM",
|
||||
#endif /* MBEDTLS_ECP_NIST_OPTIM */
|
||||
#if defined(MBEDTLS_ECP_NO_INTERNAL_RNG)
|
||||
"MBEDTLS_ECP_NO_INTERNAL_RNG",
|
||||
#endif /* MBEDTLS_ECP_NO_INTERNAL_RNG */
|
||||
#if defined(MBEDTLS_ECP_RESTARTABLE)
|
||||
"MBEDTLS_ECP_RESTARTABLE",
|
||||
#endif /* MBEDTLS_ECP_RESTARTABLE */
|
||||
#if defined(MBEDTLS_ECDH_LEGACY_CONTEXT)
|
||||
"MBEDTLS_ECDH_LEGACY_CONTEXT",
|
||||
#endif /* MBEDTLS_ECDH_LEGACY_CONTEXT */
|
||||
#if defined(MBEDTLS_ECDSA_DETERMINISTIC)
|
||||
"MBEDTLS_ECDSA_DETERMINISTIC",
|
||||
#endif /* MBEDTLS_ECDSA_DETERMINISTIC */
|
||||
#if defined(MBEDTLS_KEY_EXCHANGE_PSK_ENABLED)
|
||||
"MBEDTLS_KEY_EXCHANGE_PSK_ENABLED",
|
||||
#endif /* MBEDTLS_KEY_EXCHANGE_PSK_ENABLED */
|
||||
#if defined(MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED)
|
||||
"MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED",
|
||||
#endif /* MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED */
|
||||
#if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED)
|
||||
"MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED",
|
||||
#endif /* MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED */
|
||||
#if defined(MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED)
|
||||
"MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED",
|
||||
#endif /* MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED */
|
||||
#if defined(MBEDTLS_KEY_EXCHANGE_RSA_ENABLED)
|
||||
"MBEDTLS_KEY_EXCHANGE_RSA_ENABLED",
|
||||
#endif /* MBEDTLS_KEY_EXCHANGE_RSA_ENABLED */
|
||||
#if defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED)
|
||||
"MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED",
|
||||
#endif /* MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED */
|
||||
#if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED)
|
||||
"MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED",
|
||||
#endif /* MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED */
|
||||
#if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED)
|
||||
"MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED",
|
||||
#endif /* MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED */
|
||||
#if defined(MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED)
|
||||
"MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED",
|
||||
#endif /* MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED */
|
||||
#if defined(MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED)
|
||||
"MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED",
|
||||
#endif /* MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED */
|
||||
#if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED)
|
||||
"MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED",
|
||||
#endif /* MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED */
|
||||
#if defined(MBEDTLS_PK_PARSE_EC_EXTENDED)
|
||||
"MBEDTLS_PK_PARSE_EC_EXTENDED",
|
||||
#endif /* MBEDTLS_PK_PARSE_EC_EXTENDED */
|
||||
#if defined(MBEDTLS_ERROR_STRERROR_DUMMY)
|
||||
"MBEDTLS_ERROR_STRERROR_DUMMY",
|
||||
#endif /* MBEDTLS_ERROR_STRERROR_DUMMY */
|
||||
#if defined(MBEDTLS_GENPRIME)
|
||||
"MBEDTLS_GENPRIME",
|
||||
#endif /* MBEDTLS_GENPRIME */
|
||||
#if defined(MBEDTLS_FS_IO)
|
||||
"MBEDTLS_FS_IO",
|
||||
#endif /* MBEDTLS_FS_IO */
|
||||
#if defined(MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES)
|
||||
"MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES",
|
||||
#endif /* MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES */
|
||||
#if defined(MBEDTLS_NO_PLATFORM_ENTROPY)
|
||||
"MBEDTLS_NO_PLATFORM_ENTROPY",
|
||||
#endif /* MBEDTLS_NO_PLATFORM_ENTROPY */
|
||||
#if defined(MBEDTLS_ENTROPY_FORCE_SHA256)
|
||||
"MBEDTLS_ENTROPY_FORCE_SHA256",
|
||||
#endif /* MBEDTLS_ENTROPY_FORCE_SHA256 */
|
||||
#if defined(MBEDTLS_ENTROPY_NV_SEED)
|
||||
"MBEDTLS_ENTROPY_NV_SEED",
|
||||
#endif /* MBEDTLS_ENTROPY_NV_SEED */
|
||||
#if defined(MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER)
|
||||
"MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER",
|
||||
#endif /* MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER */
|
||||
#if defined(MBEDTLS_MEMORY_DEBUG)
|
||||
"MBEDTLS_MEMORY_DEBUG",
|
||||
#endif /* MBEDTLS_MEMORY_DEBUG */
|
||||
#if defined(MBEDTLS_MEMORY_BACKTRACE)
|
||||
"MBEDTLS_MEMORY_BACKTRACE",
|
||||
#endif /* MBEDTLS_MEMORY_BACKTRACE */
|
||||
#if defined(MBEDTLS_PK_RSA_ALT_SUPPORT)
|
||||
"MBEDTLS_PK_RSA_ALT_SUPPORT",
|
||||
#endif /* MBEDTLS_PK_RSA_ALT_SUPPORT */
|
||||
#if defined(MBEDTLS_PKCS1_V15)
|
||||
"MBEDTLS_PKCS1_V15",
|
||||
#endif /* MBEDTLS_PKCS1_V15 */
|
||||
#if defined(MBEDTLS_PKCS1_V21)
|
||||
"MBEDTLS_PKCS1_V21",
|
||||
#endif /* MBEDTLS_PKCS1_V21 */
|
||||
#if defined(MBEDTLS_PSA_CRYPTO_BUILTIN_KEYS)
|
||||
"MBEDTLS_PSA_CRYPTO_BUILTIN_KEYS",
|
||||
#endif /* MBEDTLS_PSA_CRYPTO_BUILTIN_KEYS */
|
||||
#if defined(MBEDTLS_PSA_CRYPTO_CLIENT)
|
||||
"MBEDTLS_PSA_CRYPTO_CLIENT",
|
||||
#endif /* MBEDTLS_PSA_CRYPTO_CLIENT */
|
||||
#if defined(MBEDTLS_PSA_CRYPTO_DRIVERS)
|
||||
"MBEDTLS_PSA_CRYPTO_DRIVERS",
|
||||
#endif /* MBEDTLS_PSA_CRYPTO_DRIVERS */
|
||||
#if defined(MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG)
|
||||
"MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG",
|
||||
#endif /* MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG */
|
||||
#if defined(MBEDTLS_PSA_CRYPTO_SPM)
|
||||
"MBEDTLS_PSA_CRYPTO_SPM",
|
||||
#endif /* MBEDTLS_PSA_CRYPTO_SPM */
|
||||
#if defined(MBEDTLS_PSA_INJECT_ENTROPY)
|
||||
"MBEDTLS_PSA_INJECT_ENTROPY",
|
||||
#endif /* MBEDTLS_PSA_INJECT_ENTROPY */
|
||||
#if defined(MBEDTLS_RSA_NO_CRT)
|
||||
"MBEDTLS_RSA_NO_CRT",
|
||||
#endif /* MBEDTLS_RSA_NO_CRT */
|
||||
#if defined(MBEDTLS_SELF_TEST)
|
||||
"MBEDTLS_SELF_TEST",
|
||||
#endif /* MBEDTLS_SELF_TEST */
|
||||
#if defined(MBEDTLS_SHA256_SMALLER)
|
||||
"MBEDTLS_SHA256_SMALLER",
|
||||
#endif /* MBEDTLS_SHA256_SMALLER */
|
||||
#if defined(MBEDTLS_SHA512_SMALLER)
|
||||
"MBEDTLS_SHA512_SMALLER",
|
||||
#endif /* MBEDTLS_SHA512_SMALLER */
|
||||
#if defined(MBEDTLS_SSL_ALL_ALERT_MESSAGES)
|
||||
"MBEDTLS_SSL_ALL_ALERT_MESSAGES",
|
||||
#endif /* MBEDTLS_SSL_ALL_ALERT_MESSAGES */
|
||||
#if defined(MBEDTLS_SSL_RECORD_CHECKING)
|
||||
"MBEDTLS_SSL_RECORD_CHECKING",
|
||||
#endif /* MBEDTLS_SSL_RECORD_CHECKING */
|
||||
#if defined(MBEDTLS_SSL_DTLS_CONNECTION_ID)
|
||||
"MBEDTLS_SSL_DTLS_CONNECTION_ID",
|
||||
#endif /* MBEDTLS_SSL_DTLS_CONNECTION_ID */
|
||||
#if defined(MBEDTLS_SSL_ASYNC_PRIVATE)
|
||||
"MBEDTLS_SSL_ASYNC_PRIVATE",
|
||||
#endif /* MBEDTLS_SSL_ASYNC_PRIVATE */
|
||||
#if defined(MBEDTLS_SSL_CONTEXT_SERIALIZATION)
|
||||
"MBEDTLS_SSL_CONTEXT_SERIALIZATION",
|
||||
#endif /* MBEDTLS_SSL_CONTEXT_SERIALIZATION */
|
||||
#if defined(MBEDTLS_SSL_DEBUG_ALL)
|
||||
"MBEDTLS_SSL_DEBUG_ALL",
|
||||
#endif /* MBEDTLS_SSL_DEBUG_ALL */
|
||||
#if defined(MBEDTLS_SSL_ENCRYPT_THEN_MAC)
|
||||
"MBEDTLS_SSL_ENCRYPT_THEN_MAC",
|
||||
#endif /* MBEDTLS_SSL_ENCRYPT_THEN_MAC */
|
||||
#if defined(MBEDTLS_SSL_EXTENDED_MASTER_SECRET)
|
||||
"MBEDTLS_SSL_EXTENDED_MASTER_SECRET",
|
||||
#endif /* MBEDTLS_SSL_EXTENDED_MASTER_SECRET */
|
||||
#if defined(MBEDTLS_SSL_FALLBACK_SCSV)
|
||||
"MBEDTLS_SSL_FALLBACK_SCSV",
|
||||
#endif /* MBEDTLS_SSL_FALLBACK_SCSV */
|
||||
#if defined(MBEDTLS_SSL_KEEP_PEER_CERTIFICATE)
|
||||
"MBEDTLS_SSL_KEEP_PEER_CERTIFICATE",
|
||||
#endif /* MBEDTLS_SSL_KEEP_PEER_CERTIFICATE */
|
||||
#if defined(MBEDTLS_SSL_CBC_RECORD_SPLITTING)
|
||||
"MBEDTLS_SSL_CBC_RECORD_SPLITTING",
|
||||
#endif /* MBEDTLS_SSL_CBC_RECORD_SPLITTING */
|
||||
#if defined(MBEDTLS_SSL_RENEGOTIATION)
|
||||
"MBEDTLS_SSL_RENEGOTIATION",
|
||||
#endif /* MBEDTLS_SSL_RENEGOTIATION */
|
||||
#if defined(MBEDTLS_SSL_SRV_RESPECT_CLIENT_PREFERENCE)
|
||||
"MBEDTLS_SSL_SRV_RESPECT_CLIENT_PREFERENCE",
|
||||
#endif /* MBEDTLS_SSL_SRV_RESPECT_CLIENT_PREFERENCE */
|
||||
#if defined(MBEDTLS_SSL_MAX_FRAGMENT_LENGTH)
|
||||
"MBEDTLS_SSL_MAX_FRAGMENT_LENGTH",
|
||||
#endif /* MBEDTLS_SSL_MAX_FRAGMENT_LENGTH */
|
||||
#if defined(MBEDTLS_SSL_PROTO_TLS1)
|
||||
"MBEDTLS_SSL_PROTO_TLS1",
|
||||
#endif /* MBEDTLS_SSL_PROTO_TLS1 */
|
||||
#if defined(MBEDTLS_SSL_PROTO_TLS1_1)
|
||||
"MBEDTLS_SSL_PROTO_TLS1_1",
|
||||
#endif /* MBEDTLS_SSL_PROTO_TLS1_1 */
|
||||
#if defined(MBEDTLS_SSL_PROTO_TLS1_2)
|
||||
"MBEDTLS_SSL_PROTO_TLS1_2",
|
||||
#endif /* MBEDTLS_SSL_PROTO_TLS1_2 */
|
||||
#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL)
|
||||
"MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL",
|
||||
#endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */
|
||||
#if defined(MBEDTLS_SSL_PROTO_DTLS)
|
||||
"MBEDTLS_SSL_PROTO_DTLS",
|
||||
#endif /* MBEDTLS_SSL_PROTO_DTLS */
|
||||
#if defined(MBEDTLS_SSL_ALPN)
|
||||
"MBEDTLS_SSL_ALPN",
|
||||
#endif /* MBEDTLS_SSL_ALPN */
|
||||
#if defined(MBEDTLS_SSL_DTLS_ANTI_REPLAY)
|
||||
"MBEDTLS_SSL_DTLS_ANTI_REPLAY",
|
||||
#endif /* MBEDTLS_SSL_DTLS_ANTI_REPLAY */
|
||||
#if defined(MBEDTLS_SSL_DTLS_HELLO_VERIFY)
|
||||
"MBEDTLS_SSL_DTLS_HELLO_VERIFY",
|
||||
#endif /* MBEDTLS_SSL_DTLS_HELLO_VERIFY */
|
||||
#if defined(MBEDTLS_SSL_DTLS_SRTP)
|
||||
"MBEDTLS_SSL_DTLS_SRTP",
|
||||
#endif /* MBEDTLS_SSL_DTLS_SRTP */
|
||||
#if defined(MBEDTLS_SSL_DTLS_CLIENT_PORT_REUSE)
|
||||
"MBEDTLS_SSL_DTLS_CLIENT_PORT_REUSE",
|
||||
#endif /* MBEDTLS_SSL_DTLS_CLIENT_PORT_REUSE */
|
||||
#if defined(MBEDTLS_SSL_DTLS_BADMAC_LIMIT)
|
||||
"MBEDTLS_SSL_DTLS_BADMAC_LIMIT",
|
||||
#endif /* MBEDTLS_SSL_DTLS_BADMAC_LIMIT */
|
||||
#if defined(MBEDTLS_SSL_SESSION_TICKETS)
|
||||
"MBEDTLS_SSL_SESSION_TICKETS",
|
||||
#endif /* MBEDTLS_SSL_SESSION_TICKETS */
|
||||
#if defined(MBEDTLS_SSL_EXPORT_KEYS)
|
||||
"MBEDTLS_SSL_EXPORT_KEYS",
|
||||
#endif /* MBEDTLS_SSL_EXPORT_KEYS */
|
||||
#if defined(MBEDTLS_SSL_SERVER_NAME_INDICATION)
|
||||
"MBEDTLS_SSL_SERVER_NAME_INDICATION",
|
||||
#endif /* MBEDTLS_SSL_SERVER_NAME_INDICATION */
|
||||
#if defined(MBEDTLS_SSL_TRUNCATED_HMAC)
|
||||
"MBEDTLS_SSL_TRUNCATED_HMAC",
|
||||
#endif /* MBEDTLS_SSL_TRUNCATED_HMAC */
|
||||
#if defined(MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH)
|
||||
"MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH",
|
||||
#endif /* MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH */
|
||||
#if defined(MBEDTLS_TEST_CONSTANT_FLOW_MEMSAN)
|
||||
"MBEDTLS_TEST_CONSTANT_FLOW_MEMSAN",
|
||||
#endif /* MBEDTLS_TEST_CONSTANT_FLOW_MEMSAN */
|
||||
#if defined(MBEDTLS_TEST_CONSTANT_FLOW_VALGRIND)
|
||||
"MBEDTLS_TEST_CONSTANT_FLOW_VALGRIND",
|
||||
#endif /* MBEDTLS_TEST_CONSTANT_FLOW_VALGRIND */
|
||||
#if defined(MBEDTLS_TEST_HOOKS)
|
||||
"MBEDTLS_TEST_HOOKS",
|
||||
#endif /* MBEDTLS_TEST_HOOKS */
|
||||
#if defined(MBEDTLS_THREADING_ALT)
|
||||
"MBEDTLS_THREADING_ALT",
|
||||
#endif /* MBEDTLS_THREADING_ALT */
|
||||
#if defined(MBEDTLS_THREADING_PTHREAD)
|
||||
"MBEDTLS_THREADING_PTHREAD",
|
||||
#endif /* MBEDTLS_THREADING_PTHREAD */
|
||||
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||
"MBEDTLS_USE_PSA_CRYPTO",
|
||||
#endif /* MBEDTLS_USE_PSA_CRYPTO */
|
||||
#if defined(MBEDTLS_PSA_CRYPTO_CONFIG)
|
||||
"MBEDTLS_PSA_CRYPTO_CONFIG",
|
||||
#endif /* MBEDTLS_PSA_CRYPTO_CONFIG */
|
||||
#if defined(MBEDTLS_VERSION_FEATURES)
|
||||
"MBEDTLS_VERSION_FEATURES",
|
||||
#endif /* MBEDTLS_VERSION_FEATURES */
|
||||
#if defined(MBEDTLS_X509_ALLOW_EXTENSIONS_NON_V3)
|
||||
"MBEDTLS_X509_ALLOW_EXTENSIONS_NON_V3",
|
||||
#endif /* MBEDTLS_X509_ALLOW_EXTENSIONS_NON_V3 */
|
||||
#if defined(MBEDTLS_X509_ALLOW_UNSUPPORTED_CRITICAL_EXTENSION)
|
||||
"MBEDTLS_X509_ALLOW_UNSUPPORTED_CRITICAL_EXTENSION",
|
||||
#endif /* MBEDTLS_X509_ALLOW_UNSUPPORTED_CRITICAL_EXTENSION */
|
||||
#if defined(MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK)
|
||||
"MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK",
|
||||
#endif /* MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK */
|
||||
#if defined(MBEDTLS_X509_CHECK_KEY_USAGE)
|
||||
"MBEDTLS_X509_CHECK_KEY_USAGE",
|
||||
#endif /* MBEDTLS_X509_CHECK_KEY_USAGE */
|
||||
#if defined(MBEDTLS_X509_CHECK_EXTENDED_KEY_USAGE)
|
||||
"MBEDTLS_X509_CHECK_EXTENDED_KEY_USAGE",
|
||||
#endif /* MBEDTLS_X509_CHECK_EXTENDED_KEY_USAGE */
|
||||
#if defined(MBEDTLS_X509_REMOVE_INFO)
|
||||
"MBEDTLS_X509_REMOVE_INFO",
|
||||
#endif /* MBEDTLS_X509_REMOVE_INFO */
|
||||
#if defined(MBEDTLS_X509_RSASSA_PSS_SUPPORT)
|
||||
"MBEDTLS_X509_RSASSA_PSS_SUPPORT",
|
||||
#endif /* MBEDTLS_X509_RSASSA_PSS_SUPPORT */
|
||||
#if defined(MBEDTLS_AESNI_C)
|
||||
"MBEDTLS_AESNI_C",
|
||||
#endif /* MBEDTLS_AESNI_C */
|
||||
#if defined(MBEDTLS_AES_C)
|
||||
"MBEDTLS_AES_C",
|
||||
#endif /* MBEDTLS_AES_C */
|
||||
#if defined(MBEDTLS_ARC4_C)
|
||||
"MBEDTLS_ARC4_C",
|
||||
#endif /* MBEDTLS_ARC4_C */
|
||||
#if defined(MBEDTLS_ASN1_PARSE_C)
|
||||
"MBEDTLS_ASN1_PARSE_C",
|
||||
#endif /* MBEDTLS_ASN1_PARSE_C */
|
||||
#if defined(MBEDTLS_ASN1_WRITE_C)
|
||||
"MBEDTLS_ASN1_WRITE_C",
|
||||
#endif /* MBEDTLS_ASN1_WRITE_C */
|
||||
#if defined(MBEDTLS_BASE64_C)
|
||||
"MBEDTLS_BASE64_C",
|
||||
#endif /* MBEDTLS_BASE64_C */
|
||||
#if defined(MBEDTLS_BIGNUM_C)
|
||||
"MBEDTLS_BIGNUM_C",
|
||||
#endif /* MBEDTLS_BIGNUM_C */
|
||||
#if defined(MBEDTLS_BLOWFISH_C)
|
||||
"MBEDTLS_BLOWFISH_C",
|
||||
#endif /* MBEDTLS_BLOWFISH_C */
|
||||
#if defined(MBEDTLS_CAMELLIA_C)
|
||||
"MBEDTLS_CAMELLIA_C",
|
||||
#endif /* MBEDTLS_CAMELLIA_C */
|
||||
#if defined(MBEDTLS_ARIA_C)
|
||||
"MBEDTLS_ARIA_C",
|
||||
#endif /* MBEDTLS_ARIA_C */
|
||||
#if defined(MBEDTLS_CCM_C)
|
||||
"MBEDTLS_CCM_C",
|
||||
#endif /* MBEDTLS_CCM_C */
|
||||
#if defined(MBEDTLS_CHACHA20_C)
|
||||
"MBEDTLS_CHACHA20_C",
|
||||
#endif /* MBEDTLS_CHACHA20_C */
|
||||
#if defined(MBEDTLS_CHACHAPOLY_C)
|
||||
"MBEDTLS_CHACHAPOLY_C",
|
||||
#endif /* MBEDTLS_CHACHAPOLY_C */
|
||||
#if defined(MBEDTLS_CIPHER_C)
|
||||
"MBEDTLS_CIPHER_C",
|
||||
#endif /* MBEDTLS_CIPHER_C */
|
||||
#if defined(MBEDTLS_CMAC_C)
|
||||
"MBEDTLS_CMAC_C",
|
||||
#endif /* MBEDTLS_CMAC_C */
|
||||
#if defined(MBEDTLS_CTR_DRBG_C)
|
||||
"MBEDTLS_CTR_DRBG_C",
|
||||
#endif /* MBEDTLS_CTR_DRBG_C */
|
||||
#if defined(MBEDTLS_DEBUG_C)
|
||||
"MBEDTLS_DEBUG_C",
|
||||
#endif /* MBEDTLS_DEBUG_C */
|
||||
#if defined(MBEDTLS_DES_C)
|
||||
"MBEDTLS_DES_C",
|
||||
#endif /* MBEDTLS_DES_C */
|
||||
#if defined(MBEDTLS_DHM_C)
|
||||
"MBEDTLS_DHM_C",
|
||||
#endif /* MBEDTLS_DHM_C */
|
||||
#if defined(MBEDTLS_ECDH_C)
|
||||
"MBEDTLS_ECDH_C",
|
||||
#endif /* MBEDTLS_ECDH_C */
|
||||
#if defined(MBEDTLS_ECDSA_C)
|
||||
"MBEDTLS_ECDSA_C",
|
||||
#endif /* MBEDTLS_ECDSA_C */
|
||||
#if defined(MBEDTLS_ECJPAKE_C)
|
||||
"MBEDTLS_ECJPAKE_C",
|
||||
#endif /* MBEDTLS_ECJPAKE_C */
|
||||
#if defined(MBEDTLS_ECP_C)
|
||||
"MBEDTLS_ECP_C",
|
||||
#endif /* MBEDTLS_ECP_C */
|
||||
#if defined(MBEDTLS_ENTROPY_C)
|
||||
"MBEDTLS_ENTROPY_C",
|
||||
#endif /* MBEDTLS_ENTROPY_C */
|
||||
#if defined(MBEDTLS_ERROR_C)
|
||||
"MBEDTLS_ERROR_C",
|
||||
#endif /* MBEDTLS_ERROR_C */
|
||||
#if defined(MBEDTLS_GCM_C)
|
||||
"MBEDTLS_GCM_C",
|
||||
#endif /* MBEDTLS_GCM_C */
|
||||
#if defined(MBEDTLS_HKDF_C)
|
||||
"MBEDTLS_HKDF_C",
|
||||
#endif /* MBEDTLS_HKDF_C */
|
||||
#if defined(MBEDTLS_HMAC_DRBG_C)
|
||||
"MBEDTLS_HMAC_DRBG_C",
|
||||
#endif /* MBEDTLS_HMAC_DRBG_C */
|
||||
#if defined(MBEDTLS_NIST_KW_C)
|
||||
"MBEDTLS_NIST_KW_C",
|
||||
#endif /* MBEDTLS_NIST_KW_C */
|
||||
#if defined(MBEDTLS_MD_C)
|
||||
"MBEDTLS_MD_C",
|
||||
#endif /* MBEDTLS_MD_C */
|
||||
#if defined(MBEDTLS_MD2_C)
|
||||
"MBEDTLS_MD2_C",
|
||||
#endif /* MBEDTLS_MD2_C */
|
||||
#if defined(MBEDTLS_MD4_C)
|
||||
"MBEDTLS_MD4_C",
|
||||
#endif /* MBEDTLS_MD4_C */
|
||||
#if defined(MBEDTLS_MD5_C)
|
||||
"MBEDTLS_MD5_C",
|
||||
#endif /* MBEDTLS_MD5_C */
|
||||
#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C)
|
||||
"MBEDTLS_MEMORY_BUFFER_ALLOC_C",
|
||||
#endif /* MBEDTLS_MEMORY_BUFFER_ALLOC_C */
|
||||
#if defined(MBEDTLS_NET_C)
|
||||
"MBEDTLS_NET_C",
|
||||
#endif /* MBEDTLS_NET_C */
|
||||
#if defined(MBEDTLS_OID_C)
|
||||
"MBEDTLS_OID_C",
|
||||
#endif /* MBEDTLS_OID_C */
|
||||
#if defined(MBEDTLS_PADLOCK_C)
|
||||
"MBEDTLS_PADLOCK_C",
|
||||
#endif /* MBEDTLS_PADLOCK_C */
|
||||
#if defined(MBEDTLS_PEM_PARSE_C)
|
||||
"MBEDTLS_PEM_PARSE_C",
|
||||
#endif /* MBEDTLS_PEM_PARSE_C */
|
||||
#if defined(MBEDTLS_PEM_WRITE_C)
|
||||
"MBEDTLS_PEM_WRITE_C",
|
||||
#endif /* MBEDTLS_PEM_WRITE_C */
|
||||
#if defined(MBEDTLS_PK_C)
|
||||
"MBEDTLS_PK_C",
|
||||
#endif /* MBEDTLS_PK_C */
|
||||
#if defined(MBEDTLS_PK_PARSE_C)
|
||||
"MBEDTLS_PK_PARSE_C",
|
||||
#endif /* MBEDTLS_PK_PARSE_C */
|
||||
#if defined(MBEDTLS_PK_WRITE_C)
|
||||
"MBEDTLS_PK_WRITE_C",
|
||||
#endif /* MBEDTLS_PK_WRITE_C */
|
||||
#if defined(MBEDTLS_PKCS5_C)
|
||||
"MBEDTLS_PKCS5_C",
|
||||
#endif /* MBEDTLS_PKCS5_C */
|
||||
#if defined(MBEDTLS_PKCS12_C)
|
||||
"MBEDTLS_PKCS12_C",
|
||||
#endif /* MBEDTLS_PKCS12_C */
|
||||
#if defined(MBEDTLS_PLATFORM_C)
|
||||
"MBEDTLS_PLATFORM_C",
|
||||
#endif /* MBEDTLS_PLATFORM_C */
|
||||
#if defined(MBEDTLS_POLY1305_C)
|
||||
"MBEDTLS_POLY1305_C",
|
||||
#endif /* MBEDTLS_POLY1305_C */
|
||||
#if defined(MBEDTLS_PSA_CRYPTO_C)
|
||||
"MBEDTLS_PSA_CRYPTO_C",
|
||||
#endif /* MBEDTLS_PSA_CRYPTO_C */
|
||||
#if defined(MBEDTLS_PSA_CRYPTO_SE_C)
|
||||
"MBEDTLS_PSA_CRYPTO_SE_C",
|
||||
#endif /* MBEDTLS_PSA_CRYPTO_SE_C */
|
||||
#if defined(MBEDTLS_PSA_CRYPTO_STORAGE_C)
|
||||
"MBEDTLS_PSA_CRYPTO_STORAGE_C",
|
||||
#endif /* MBEDTLS_PSA_CRYPTO_STORAGE_C */
|
||||
#if defined(MBEDTLS_PSA_ITS_FILE_C)
|
||||
"MBEDTLS_PSA_ITS_FILE_C",
|
||||
#endif /* MBEDTLS_PSA_ITS_FILE_C */
|
||||
#if defined(MBEDTLS_RIPEMD160_C)
|
||||
"MBEDTLS_RIPEMD160_C",
|
||||
#endif /* MBEDTLS_RIPEMD160_C */
|
||||
#if defined(MBEDTLS_RSA_C)
|
||||
"MBEDTLS_RSA_C",
|
||||
#endif /* MBEDTLS_RSA_C */
|
||||
#if defined(MBEDTLS_SHA1_C)
|
||||
"MBEDTLS_SHA1_C",
|
||||
#endif /* MBEDTLS_SHA1_C */
|
||||
#if defined(MBEDTLS_SHA224_C)
|
||||
"MBEDTLS_SHA224_C",
|
||||
#endif /* MBEDTLS_SHA224_C */
|
||||
#if defined(MBEDTLS_SHA256_C)
|
||||
"MBEDTLS_SHA256_C",
|
||||
#endif /* MBEDTLS_SHA256_C */
|
||||
#if defined(MBEDTLS_SHA384_C)
|
||||
"MBEDTLS_SHA384_C",
|
||||
#endif /* MBEDTLS_SHA384_C */
|
||||
#if defined(MBEDTLS_SHA512_C)
|
||||
"MBEDTLS_SHA512_C",
|
||||
#endif /* MBEDTLS_SHA512_C */
|
||||
#if defined(MBEDTLS_SSL_CACHE_C)
|
||||
"MBEDTLS_SSL_CACHE_C",
|
||||
#endif /* MBEDTLS_SSL_CACHE_C */
|
||||
#if defined(MBEDTLS_SSL_COOKIE_C)
|
||||
"MBEDTLS_SSL_COOKIE_C",
|
||||
#endif /* MBEDTLS_SSL_COOKIE_C */
|
||||
#if defined(MBEDTLS_SSL_TICKET_C)
|
||||
"MBEDTLS_SSL_TICKET_C",
|
||||
#endif /* MBEDTLS_SSL_TICKET_C */
|
||||
#if defined(MBEDTLS_SSL_CLI_C)
|
||||
"MBEDTLS_SSL_CLI_C",
|
||||
#endif /* MBEDTLS_SSL_CLI_C */
|
||||
#if defined(MBEDTLS_SSL_SRV_C)
|
||||
"MBEDTLS_SSL_SRV_C",
|
||||
#endif /* MBEDTLS_SSL_SRV_C */
|
||||
#if defined(MBEDTLS_SSL_TLS_C)
|
||||
"MBEDTLS_SSL_TLS_C",
|
||||
#endif /* MBEDTLS_SSL_TLS_C */
|
||||
#if defined(MBEDTLS_THREADING_C)
|
||||
"MBEDTLS_THREADING_C",
|
||||
#endif /* MBEDTLS_THREADING_C */
|
||||
#if defined(MBEDTLS_TIMING_C)
|
||||
"MBEDTLS_TIMING_C",
|
||||
#endif /* MBEDTLS_TIMING_C */
|
||||
#if defined(MBEDTLS_VERSION_C)
|
||||
"MBEDTLS_VERSION_C",
|
||||
#endif /* MBEDTLS_VERSION_C */
|
||||
#if defined(MBEDTLS_X509_USE_C)
|
||||
"MBEDTLS_X509_USE_C",
|
||||
#endif /* MBEDTLS_X509_USE_C */
|
||||
#if defined(MBEDTLS_X509_CRT_PARSE_C)
|
||||
"MBEDTLS_X509_CRT_PARSE_C",
|
||||
#endif /* MBEDTLS_X509_CRT_PARSE_C */
|
||||
#if defined(MBEDTLS_X509_CRL_PARSE_C)
|
||||
"MBEDTLS_X509_CRL_PARSE_C",
|
||||
#endif /* MBEDTLS_X509_CRL_PARSE_C */
|
||||
#if defined(MBEDTLS_X509_CSR_PARSE_C)
|
||||
"MBEDTLS_X509_CSR_PARSE_C",
|
||||
#endif /* MBEDTLS_X509_CSR_PARSE_C */
|
||||
#if defined(MBEDTLS_X509_CREATE_C)
|
||||
"MBEDTLS_X509_CREATE_C",
|
||||
#endif /* MBEDTLS_X509_CREATE_C */
|
||||
#if defined(MBEDTLS_X509_CRT_WRITE_C)
|
||||
"MBEDTLS_X509_CRT_WRITE_C",
|
||||
#endif /* MBEDTLS_X509_CRT_WRITE_C */
|
||||
#if defined(MBEDTLS_X509_CSR_WRITE_C)
|
||||
"MBEDTLS_X509_CSR_WRITE_C",
|
||||
#endif /* MBEDTLS_X509_CSR_WRITE_C */
|
||||
#if defined(MBEDTLS_XTEA_C)
|
||||
"MBEDTLS_XTEA_C",
|
||||
#endif /* MBEDTLS_XTEA_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 );
|
||||
|
||||
while( *idx != NULL )
|
||||
{
|
||||
if( !strcmp( *idx, feature ) )
|
||||
return( 0 );
|
||||
idx++;
|
||||
}
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
#endif /* MBEDTLS_VERSION_C */
|
||||
Reference in New Issue
Block a user