mirror of
https://github.com/espressif/openthread.git
synced 2026-08-03 17:37:46 +00:00
[crypto] PSA API: introduce support for simulation and test platform
This commit adds support for Crypto PSA library for simulation and test platform and introduces initial CI check. Signed-off-by: Łukasz Duda <[email protected]>
This commit is contained in:
@@ -74,7 +74,6 @@ set(OT_PLATFORM_DEFINES ${OT_PLATFORM_DEFINES} PARENT_SCOPE)
|
||||
add_library(openthread-simulation
|
||||
alarm.c
|
||||
ble.c
|
||||
crypto.c
|
||||
diag.c
|
||||
dns.c
|
||||
dnssd.c
|
||||
@@ -106,6 +105,7 @@ target_link_libraries(openthread-simulation PRIVATE
|
||||
openthread-platform
|
||||
ot-simulation-config
|
||||
ot-config
|
||||
mbedtls
|
||||
)
|
||||
|
||||
target_compile_options(openthread-simulation PRIVATE
|
||||
|
||||
@@ -1,121 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2021, The OpenThread Authors.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the copyright holder nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "platform-simulation.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <openthread/config.h>
|
||||
#include <openthread/platform/crypto.h>
|
||||
|
||||
#if OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE
|
||||
|
||||
// crypto key storage stubs
|
||||
|
||||
otError otPlatCryptoImportKey(otCryptoKeyRef *aKeyRef,
|
||||
otCryptoKeyType aKeyType,
|
||||
otCryptoKeyAlgorithm aKeyAlgorithm,
|
||||
int aKeyUsage,
|
||||
otCryptoKeyStorage aKeyPersistence,
|
||||
const uint8_t *aKey,
|
||||
size_t aKeyLen)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aKeyRef);
|
||||
OT_UNUSED_VARIABLE(aKeyType);
|
||||
OT_UNUSED_VARIABLE(aKeyAlgorithm);
|
||||
OT_UNUSED_VARIABLE(aKeyUsage);
|
||||
OT_UNUSED_VARIABLE(aKeyPersistence);
|
||||
OT_UNUSED_VARIABLE(aKey);
|
||||
OT_UNUSED_VARIABLE(aKeyLen);
|
||||
|
||||
return OT_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
otError otPlatCryptoExportKey(otCryptoKeyRef aKeyRef, uint8_t *aBuffer, size_t aBufferLen, size_t *aKeyLen)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aKeyRef);
|
||||
OT_UNUSED_VARIABLE(aBuffer);
|
||||
OT_UNUSED_VARIABLE(aBufferLen);
|
||||
OT_UNUSED_VARIABLE(aKeyLen);
|
||||
|
||||
return OT_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
otError otPlatCryptoDestroyKey(otCryptoKeyRef aKeyRef)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aKeyRef);
|
||||
|
||||
return OT_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
bool otPlatCryptoHasKey(otCryptoKeyRef aKeyRef)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aKeyRef);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
otError otPlatCryptoEcdsaGenerateAndImportKey(otCryptoKeyRef aKeyRef)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aKeyRef);
|
||||
|
||||
return OT_ERROR_NONE;
|
||||
}
|
||||
|
||||
otError otPlatCryptoEcdsaExportPublicKey(otCryptoKeyRef aKeyRef, otPlatCryptoEcdsaPublicKey *aPublicKey)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aKeyRef);
|
||||
OT_UNUSED_VARIABLE(aPublicKey);
|
||||
|
||||
return OT_ERROR_NONE;
|
||||
}
|
||||
|
||||
otError otPlatCryptoEcdsaSignUsingKeyRef(otCryptoKeyRef aKeyRef,
|
||||
const otPlatCryptoSha256Hash *aHash,
|
||||
otPlatCryptoEcdsaSignature *aSignature)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aKeyRef);
|
||||
OT_UNUSED_VARIABLE(aHash);
|
||||
OT_UNUSED_VARIABLE(aSignature);
|
||||
|
||||
return OT_ERROR_NONE;
|
||||
}
|
||||
|
||||
otError otPlatCryptoEcdsaVerifyUsingKeyRef(otCryptoKeyRef aKeyRef,
|
||||
const otPlatCryptoSha256Hash *aHash,
|
||||
const otPlatCryptoEcdsaSignature *aSignature)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aKeyRef);
|
||||
OT_UNUSED_VARIABLE(aHash);
|
||||
OT_UNUSED_VARIABLE(aSignature);
|
||||
|
||||
return OT_ERROR_NONE;
|
||||
}
|
||||
|
||||
#endif // OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE
|
||||
@@ -38,6 +38,10 @@
|
||||
|
||||
#include <openthread/platform/entropy.h>
|
||||
|
||||
#if (OPENTHREAD_CONFIG_CRYPTO_LIB == OPENTHREAD_CONFIG_CRYPTO_LIB_PSA)
|
||||
#include <psa/crypto.h>
|
||||
#endif
|
||||
|
||||
#include "utils/code_utils.h"
|
||||
|
||||
#ifndef __SANITIZE_ADDRESS__
|
||||
@@ -133,3 +137,33 @@ exit:
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
#if (OPENTHREAD_CONFIG_CRYPTO_LIB == OPENTHREAD_CONFIG_CRYPTO_LIB_PSA) && defined(MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG)
|
||||
/**
|
||||
* When OpenThread is compiled with the PSA Crypto backend using Mbed TLS 3.x, there is no
|
||||
* API to configure a dedicated non-default entropy source. It is documented that a future version of
|
||||
* Mbed TLS (likely 4.x) will include a PSA interface for configuring entropy sources.
|
||||
*
|
||||
* For now, we need to define the external RNG. Since the implementation of `otPlatEntropyGet` already
|
||||
* uses CSPRNG, we will call it here as well.
|
||||
*/
|
||||
psa_status_t mbedtls_psa_external_get_random(mbedtls_psa_external_random_context_t *context,
|
||||
uint8_t *output,
|
||||
size_t output_size,
|
||||
size_t *output_length)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(context);
|
||||
|
||||
otError error;
|
||||
psa_status_t status = PSA_ERROR_GENERIC_ERROR;
|
||||
|
||||
error = otPlatEntropyGet(output, (uint16_t)output_size);
|
||||
if (error == OT_ERROR_NONE)
|
||||
{
|
||||
*output_length = output_size;
|
||||
status = PSA_SUCCESS;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -101,6 +101,7 @@ endif()
|
||||
target_link_libraries(ot-test-platform-ftd
|
||||
PRIVATE
|
||||
ot-config
|
||||
mbedtls
|
||||
${OT_MBEDTLS}
|
||||
)
|
||||
|
||||
|
||||
@@ -38,6 +38,10 @@
|
||||
#include <openthread/platform/ble.h>
|
||||
#endif
|
||||
|
||||
#if (OPENTHREAD_CONFIG_CRYPTO_LIB == OPENTHREAD_CONFIG_CRYPTO_LIB_PSA)
|
||||
#include <psa/crypto.h>
|
||||
#endif
|
||||
|
||||
enum
|
||||
{
|
||||
FLASH_SWAP_SIZE = 2048,
|
||||
@@ -226,6 +230,36 @@ exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
#if (OPENTHREAD_CONFIG_CRYPTO_LIB == OPENTHREAD_CONFIG_CRYPTO_LIB_PSA) && defined(MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG)
|
||||
/**
|
||||
* When OpenThread is compiled with the PSA Crypto backend using Mbed TLS 3.x, there is no
|
||||
* API to configure a dedicated non-default entropy source. It is documented that a future version of
|
||||
* Mbed TLS (likely 4.x) will include a PSA interface for configuring entropy sources.
|
||||
*
|
||||
* For now, we need to define the external RNG. Since the implementation of `otPlatEntropyGet` already
|
||||
* uses CSPRNG, we will call it here as well.
|
||||
*/
|
||||
extern "C" psa_status_t mbedtls_psa_external_get_random(mbedtls_psa_external_random_context_t *context,
|
||||
uint8_t *output,
|
||||
size_t output_size,
|
||||
size_t *output_length)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(context);
|
||||
|
||||
otError error;
|
||||
psa_status_t status = PSA_ERROR_GENERIC_ERROR;
|
||||
|
||||
error = otPlatEntropyGet(output, (uint16_t)output_size);
|
||||
if (error == OT_ERROR_NONE)
|
||||
{
|
||||
*output_length = output_size;
|
||||
status = PSA_SUCCESS;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void DiagOutput(const char *aFormat, ...)
|
||||
{
|
||||
va_list args;
|
||||
@@ -512,91 +546,6 @@ OT_TOOL_WEAK void otPlatInfraIfDhcp6PdClientSend(otInstance *aInstance,
|
||||
#endif // OPENTHREAD_CONFIG_BORDER_ROUTING_DHCP6_PD_ENABLE && OPENTHREAD_CONFIG_BORDER_ROUTING_DHCP6_PD_CLIENT_ENABLE
|
||||
#endif // OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE
|
||||
|
||||
#if OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE
|
||||
|
||||
otError otPlatCryptoImportKey(otCryptoKeyRef *aKeyRef,
|
||||
otCryptoKeyType aKeyType,
|
||||
otCryptoKeyAlgorithm aKeyAlgorithm,
|
||||
int aKeyUsage,
|
||||
otCryptoKeyStorage aKeyPersistence,
|
||||
const uint8_t *aKey,
|
||||
size_t aKeyLen)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aKeyRef);
|
||||
OT_UNUSED_VARIABLE(aKeyType);
|
||||
OT_UNUSED_VARIABLE(aKeyAlgorithm);
|
||||
OT_UNUSED_VARIABLE(aKeyUsage);
|
||||
OT_UNUSED_VARIABLE(aKeyPersistence);
|
||||
OT_UNUSED_VARIABLE(aKey);
|
||||
OT_UNUSED_VARIABLE(aKeyLen);
|
||||
|
||||
return OT_ERROR_NONE;
|
||||
}
|
||||
|
||||
otError otPlatCryptoExportKey(otCryptoKeyRef aKeyRef, uint8_t *aBuffer, size_t aBufferLen, size_t *aKeyLen)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aKeyRef);
|
||||
OT_UNUSED_VARIABLE(aBuffer);
|
||||
OT_UNUSED_VARIABLE(aBufferLen);
|
||||
|
||||
*aKeyLen = 0;
|
||||
|
||||
return OT_ERROR_NONE;
|
||||
}
|
||||
|
||||
otError otPlatCryptoDestroyKey(otCryptoKeyRef aKeyRef)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aKeyRef);
|
||||
|
||||
return OT_ERROR_NONE;
|
||||
}
|
||||
|
||||
bool otPlatCryptoHasKey(otCryptoKeyRef aKeyRef)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aKeyRef);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
otError otPlatCryptoEcdsaGenerateAndImportKey(otCryptoKeyRef aKeyRef)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aKeyRef);
|
||||
|
||||
return OT_ERROR_NONE;
|
||||
}
|
||||
|
||||
otError otPlatCryptoEcdsaExportPublicKey(otCryptoKeyRef aKeyRef, otPlatCryptoEcdsaPublicKey *aPublicKey)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aKeyRef);
|
||||
OT_UNUSED_VARIABLE(aPublicKey);
|
||||
|
||||
return OT_ERROR_NONE;
|
||||
}
|
||||
|
||||
otError otPlatCryptoEcdsaSignUsingKeyRef(otCryptoKeyRef aKeyRef,
|
||||
const otPlatCryptoSha256Hash *aHash,
|
||||
otPlatCryptoEcdsaSignature *aSignature)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aKeyRef);
|
||||
OT_UNUSED_VARIABLE(aHash);
|
||||
OT_UNUSED_VARIABLE(aSignature);
|
||||
|
||||
return OT_ERROR_NONE;
|
||||
}
|
||||
|
||||
otError otPlatCryptoEcdsaVerifyUsingKeyRef(otCryptoKeyRef aKeyRef,
|
||||
const otPlatCryptoSha256Hash *aHash,
|
||||
const otPlatCryptoEcdsaSignature *aSignature)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aKeyRef);
|
||||
OT_UNUSED_VARIABLE(aHash);
|
||||
OT_UNUSED_VARIABLE(aSignature);
|
||||
|
||||
return OT_ERROR_NONE;
|
||||
}
|
||||
|
||||
#endif // OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE
|
||||
|
||||
otError otPlatRadioSetCcaEnergyDetectThreshold(otInstance *aInstance, int8_t aThreshold)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aInstance);
|
||||
|
||||
Vendored
+27
-6
@@ -27,8 +27,10 @@
|
||||
#
|
||||
|
||||
set(OT_MBEDTLS_DEFAULT_CONFIG_FILE \"openthread-mbedtls-config.h\")
|
||||
set(OT_PSA_CRYPTO_DEFAULT_CONFIG_FILE \"openthread-psa-crypto-config.h\")
|
||||
|
||||
set(OT_MBEDTLS_CONFIG_FILE "" CACHE STRING "The mbedTLS config file")
|
||||
set(OT_PSA_CRYPTO_CONFIG_FILE "" CACHE STRING "The PSA Crypto config file")
|
||||
|
||||
set(ENABLE_TESTING OFF CACHE BOOL "Disable mbedtls test" FORCE)
|
||||
set(ENABLE_PROGRAMS OFF CACHE BOOL "Disable mbetls program" FORCE)
|
||||
@@ -42,6 +44,8 @@ if(UNIFDEF_EXE)
|
||||
endif()
|
||||
find_program(SED_EXE sed)
|
||||
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-but-set-variable")
|
||||
|
||||
string(REPLACE "-Wconversion" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
|
||||
string(REPLACE "-Wconversion" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
|
||||
@@ -63,15 +67,29 @@ if(UNIFDEFALL_EXE AND SED_EXE AND UNIFDEF_VERSION VERSION_GREATER_EQUAL 2.10)
|
||||
COMMAND_EXPAND_LISTS
|
||||
)
|
||||
|
||||
add_custom_target(openthread-mbedtls-config
|
||||
DEPENDS openthread-mbedtls-config.h)
|
||||
add_custom_command(OUTPUT openthread-psa-crypto-config.h
|
||||
COMMAND ${UNIFDEFALL_EXE}
|
||||
"'-D$<JOIN:$<TARGET_PROPERTY:ot-config,INTERFACE_COMPILE_DEFINITIONS>,';'-D>'"
|
||||
"-I$<JOIN:$<TARGET_PROPERTY:ot-config,INTERFACE_INCLUDE_DIRECTORIES>,;-I>"
|
||||
"-I$<JOIN:${OT_PUBLIC_INCLUDES},;-I>"
|
||||
"-I${CMAKE_CURRENT_SOURCE_DIR}/repo/include"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/psa-crypto-config.h" |
|
||||
${SED_EXE} '/openthread-core-config\.h/d' >
|
||||
openthread-psa-crypto-config.h
|
||||
MAIN_DEPENDENCY psa-crypto-config.h
|
||||
COMMAND_EXPAND_LISTS
|
||||
)
|
||||
|
||||
add_dependencies(ot-config openthread-mbedtls-config)
|
||||
add_dependencies(mbedtls openthread-mbedtls-config)
|
||||
add_dependencies(mbedx509 openthread-mbedtls-config)
|
||||
add_dependencies(mbedcrypto openthread-mbedtls-config)
|
||||
add_custom_target(openthread-mbedtls-config
|
||||
DEPENDS openthread-mbedtls-config.h openthread-psa-crypto-config.h)
|
||||
|
||||
add_dependencies(ot-config openthread-mbedtls-config openthread-psa-crypto-config)
|
||||
add_dependencies(mbedtls openthread-mbedtls-config openthread-psa-crypto-config)
|
||||
add_dependencies(mbedx509 openthread-mbedtls-config openthread-psa-crypto-config)
|
||||
add_dependencies(mbedcrypto openthread-mbedtls-config openthread-psa-crypto-config)
|
||||
else()
|
||||
configure_file(mbedtls-config.h openthread-mbedtls-config.h COPYONLY)
|
||||
configure_file(psa-crypto-config.h openthread-psa-crypto-config.h COPYONLY)
|
||||
endif()
|
||||
|
||||
target_include_directories(ot-config SYSTEM
|
||||
@@ -82,6 +100,7 @@ target_include_directories(ot-config SYSTEM
|
||||
target_compile_definitions(mbedtls
|
||||
PUBLIC
|
||||
"MBEDTLS_CONFIG_FILE=$<IF:$<BOOL:${OT_MBEDTLS_CONFIG_FILE}>,${OT_MBEDTLS_CONFIG_FILE},${OT_MBEDTLS_DEFAULT_CONFIG_FILE}>"
|
||||
"MBEDTLS_PSA_CRYPTO_CONFIG_FILE=$<IF:$<BOOL:${OT_PSA_CRYPTO_CONFIG_FILE}>,${OT_PSA_CRYPTO_CONFIG_FILE},${OT_PSA_CRYPTO_DEFAULT_CONFIG_FILE}>"
|
||||
PRIVATE
|
||||
$<TARGET_PROPERTY:ot-config,INTERFACE_COMPILE_DEFINITIONS>
|
||||
)
|
||||
@@ -96,6 +115,7 @@ target_include_directories(mbedtls
|
||||
target_compile_definitions(mbedx509
|
||||
PUBLIC
|
||||
"MBEDTLS_CONFIG_FILE=$<IF:$<BOOL:${OT_MBEDTLS_CONFIG_FILE}>,${OT_MBEDTLS_CONFIG_FILE},${OT_MBEDTLS_DEFAULT_CONFIG_FILE}>"
|
||||
"MBEDTLS_PSA_CRYPTO_CONFIG_FILE=$<IF:$<BOOL:${OT_PSA_CRYPTO_CONFIG_FILE}>,${OT_PSA_CRYPTO_CONFIG_FILE},${OT_PSA_CRYPTO_DEFAULT_CONFIG_FILE}>"
|
||||
PRIVATE
|
||||
$<TARGET_PROPERTY:ot-config,INTERFACE_COMPILE_DEFINITIONS>
|
||||
)
|
||||
@@ -110,6 +130,7 @@ target_include_directories(mbedx509
|
||||
target_compile_definitions(mbedcrypto
|
||||
PUBLIC
|
||||
"MBEDTLS_CONFIG_FILE=$<IF:$<BOOL:${OT_MBEDTLS_CONFIG_FILE}>,${OT_MBEDTLS_CONFIG_FILE},${OT_MBEDTLS_DEFAULT_CONFIG_FILE}>"
|
||||
"MBEDTLS_PSA_CRYPTO_CONFIG_FILE=$<IF:$<BOOL:${OT_PSA_CRYPTO_CONFIG_FILE}>,${OT_PSA_CRYPTO_CONFIG_FILE},${OT_PSA_CRYPTO_DEFAULT_CONFIG_FILE}>"
|
||||
PRIVATE
|
||||
$<TARGET_PROPERTY:ot-config,INTERFACE_COMPILE_DEFINITIONS>
|
||||
)
|
||||
|
||||
Vendored
+104
-49
@@ -40,7 +40,11 @@
|
||||
#include <openthread/platform/logging.h>
|
||||
#include <openthread/platform/memory.h>
|
||||
|
||||
#define MBEDTLS_PLATFORM_SNPRINTF_MACRO snprintf
|
||||
// ==============================================================================
|
||||
// mbedTLS legacy/PSA configuration
|
||||
// ==============================================================================
|
||||
|
||||
#if OPENTHREAD_CONFIG_CRYPTO_LIB == OPENTHREAD_CONFIG_CRYPTO_LIB_MBEDTLS
|
||||
|
||||
#define MBEDTLS_AES_C
|
||||
#if (MBEDTLS_VERSION_NUMBER >= 0x03050000)
|
||||
@@ -66,19 +70,46 @@
|
||||
#define MBEDTLS_ENTROPY_C
|
||||
#define MBEDTLS_HAVE_ASM
|
||||
#define MBEDTLS_HMAC_DRBG_C
|
||||
#define MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED
|
||||
#define MBEDTLS_MD_C
|
||||
#define MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES
|
||||
#define MBEDTLS_NO_PLATFORM_ENTROPY
|
||||
#define MBEDTLS_OID_C
|
||||
#define MBEDTLS_PK_C
|
||||
#define MBEDTLS_PK_PARSE_C
|
||||
#define MBEDTLS_PLATFORM_C
|
||||
#define MBEDTLS_PLATFORM_MEMORY
|
||||
#define MBEDTLS_PLATFORM_NO_STD_FUNCTIONS
|
||||
#define MBEDTLS_SHA224_C
|
||||
#define MBEDTLS_SHA256_C
|
||||
#define MBEDTLS_SHA256_SMALLER
|
||||
|
||||
#if OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE || OPENTHREAD_CONFIG_TLS_ENABLE
|
||||
#define MBEDTLS_BASE64_C
|
||||
#define MBEDTLS_ECDH_C
|
||||
#define MBEDTLS_ECDSA_C
|
||||
#endif
|
||||
|
||||
#if OPENTHREAD_CONFIG_BLE_TCAT_ENABLE
|
||||
#define MBEDTLS_GCM_C
|
||||
#endif
|
||||
|
||||
#if OPENTHREAD_CONFIG_ECDSA_ENABLE
|
||||
#define MBEDTLS_BASE64_C
|
||||
#define MBEDTLS_ECDH_C
|
||||
#define MBEDTLS_ECDSA_C
|
||||
#if OPENTHREAD_CONFIG_DETERMINISTIC_ECDSA_ENABLE
|
||||
#define MBEDTLS_ECDSA_DETERMINISTIC
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#elif OPENTHREAD_CONFIG_CRYPTO_LIB == OPENTHREAD_CONFIG_CRYPTO_LIB_PSA
|
||||
|
||||
#define MBEDTLS_USE_PSA_CRYPTO
|
||||
|
||||
#define MBEDTLS_PSA_CRYPTO_C
|
||||
#define MBEDTLS_PSA_CRYPTO_CLIENT
|
||||
#define MBEDTLS_PSA_CRYPTO_STORAGE_C
|
||||
#define MBEDTLS_PSA_CRYPTO_CONFIG
|
||||
#define MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG
|
||||
|
||||
#endif
|
||||
|
||||
// ==============================================================================
|
||||
// SSL configuration
|
||||
// ==============================================================================
|
||||
|
||||
#define MBEDTLS_SSL_CLI_C
|
||||
#define MBEDTLS_SSL_DTLS_ANTI_REPLAY
|
||||
#define MBEDTLS_SSL_DTLS_HELLO_VERIFY
|
||||
@@ -93,6 +124,12 @@
|
||||
#define MBEDTLS_SSL_SRV_C
|
||||
#endif
|
||||
|
||||
#if OPENTHREAD_CONFIG_BLE_TCAT_ENABLE
|
||||
#define MBEDTLS_SSL_KEEP_PEER_CERTIFICATE
|
||||
#endif
|
||||
|
||||
#define MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED
|
||||
|
||||
#if OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE
|
||||
#define MBEDTLS_KEY_EXCHANGE_PSK_ENABLED
|
||||
#endif
|
||||
@@ -101,45 +138,6 @@
|
||||
#define MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
|
||||
#endif
|
||||
|
||||
#if OPENTHREAD_CONFIG_BLE_TCAT_ENABLE
|
||||
#define MBEDTLS_SSL_KEEP_PEER_CERTIFICATE
|
||||
#define MBEDTLS_GCM_C
|
||||
#endif
|
||||
|
||||
#ifdef MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
|
||||
#define MBEDTLS_BASE64_C
|
||||
#define MBEDTLS_ECDH_C
|
||||
#define MBEDTLS_ECDSA_C
|
||||
#define MBEDTLS_PEM_PARSE_C
|
||||
#define MBEDTLS_X509_USE_C
|
||||
#define MBEDTLS_X509_CRT_PARSE_C
|
||||
#endif
|
||||
|
||||
#if OPENTHREAD_CONFIG_ECDSA_ENABLE
|
||||
#define MBEDTLS_BASE64_C
|
||||
#define MBEDTLS_ECDH_C
|
||||
#define MBEDTLS_ECDSA_C
|
||||
#if OPENTHREAD_CONFIG_DETERMINISTIC_ECDSA_ENABLE
|
||||
#define MBEDTLS_ECDSA_DETERMINISTIC
|
||||
#endif
|
||||
#define MBEDTLS_PEM_PARSE_C
|
||||
#define MBEDTLS_PK_WRITE_C
|
||||
#endif
|
||||
|
||||
#define MBEDTLS_MPI_WINDOW_SIZE 1 /**< Maximum windows size used. */
|
||||
#define MBEDTLS_MPI_MAX_SIZE 32 /**< Maximum number of bytes for usable MPIs. */
|
||||
#define MBEDTLS_ECP_MAX_BITS 256 /**< Maximum bit size of groups */
|
||||
#define MBEDTLS_ECP_WINDOW_SIZE 2 /**< Maximum window size used */
|
||||
#define MBEDTLS_ECP_FIXED_POINT_OPTIM 0 /**< Enable fixed-point speed-up */
|
||||
#define MBEDTLS_ENTROPY_MAX_SOURCES 1 /**< Maximum number of sources supported */
|
||||
|
||||
#if OPENTHREAD_CONFIG_HEAP_EXTERNAL_ENABLE
|
||||
#define MBEDTLS_PLATFORM_STD_CALLOC otPlatCAlloc /**< Default allocator to use, can be undefined */
|
||||
#define MBEDTLS_PLATFORM_STD_FREE otPlatFree /**< Default free to use, can be undefined */
|
||||
#else
|
||||
#define MBEDTLS_MEMORY_BUFFER_ALLOC_C
|
||||
#endif
|
||||
|
||||
#if OPENTHREAD_CONFIG_BLE_TCAT_ENABLE
|
||||
#define MBEDTLS_SSL_MAX_CONTENT_LEN 2000 /**< Maxium fragment length in bytes */
|
||||
#elif OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE
|
||||
@@ -152,6 +150,63 @@
|
||||
#define MBEDTLS_SSL_OUT_CONTENT_LEN MBEDTLS_SSL_MAX_CONTENT_LEN
|
||||
#define MBEDTLS_SSL_CIPHERSUITES MBEDTLS_TLS_ECJPAKE_WITH_AES_128_CCM_8
|
||||
|
||||
// ==============================================================================
|
||||
// x509 & PK configuration
|
||||
// ==============================================================================
|
||||
|
||||
#define MBEDTLS_OID_C
|
||||
#define MBEDTLS_PK_C
|
||||
#define MBEDTLS_PK_PARSE_C
|
||||
|
||||
#if OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE || OPENTHREAD_CONFIG_TLS_ENABLE
|
||||
#define MBEDTLS_BASE64_C
|
||||
#define MBEDTLS_PEM_PARSE_C
|
||||
#define MBEDTLS_X509_USE_C
|
||||
#define MBEDTLS_X509_CRT_PARSE_C
|
||||
#endif
|
||||
|
||||
#if OPENTHREAD_CONFIG_ECDSA_ENABLE
|
||||
#define MBEDTLS_PEM_PARSE_C
|
||||
#define MBEDTLS_PK_WRITE_C
|
||||
#endif
|
||||
|
||||
// ==============================================================================
|
||||
// MPI configuration
|
||||
// ==============================================================================
|
||||
|
||||
#define MBEDTLS_MPI_WINDOW_SIZE 1 /**< Maximum windows size used. */
|
||||
#define MBEDTLS_MPI_MAX_SIZE 32 /**< Maximum number of bytes for usable MPIs. */
|
||||
|
||||
// ==============================================================================
|
||||
// ECP configuration
|
||||
// ==============================================================================
|
||||
|
||||
#if (MBEDTLS_VERSION_NUMBER < 0x03000000)
|
||||
#define MBEDTLS_ECP_MAX_BITS 256 /**< Maximum bit size of groups */
|
||||
#endif
|
||||
#define MBEDTLS_ECP_WINDOW_SIZE 2 /**< Maximum window size used */
|
||||
#define MBEDTLS_ECP_FIXED_POINT_OPTIM 0 /**< Enable fixed-point speed-up */
|
||||
|
||||
// ==============================================================================
|
||||
// Platform configuration
|
||||
// ==============================================================================
|
||||
|
||||
#define MBEDTLS_PLATFORM_SNPRINTF_MACRO snprintf
|
||||
|
||||
#if OPENTHREAD_CONFIG_HEAP_EXTERNAL_ENABLE
|
||||
#define MBEDTLS_PLATFORM_STD_CALLOC otPlatCAlloc /**< Default allocator to use, can be undefined */
|
||||
#define MBEDTLS_PLATFORM_STD_FREE otPlatFree /**< Default free to use, can be undefined */
|
||||
#else
|
||||
#define MBEDTLS_MEMORY_BUFFER_ALLOC_C
|
||||
#endif
|
||||
|
||||
#define MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES
|
||||
#define MBEDTLS_NO_PLATFORM_ENTROPY
|
||||
#define MBEDTLS_PLATFORM_C
|
||||
#define MBEDTLS_PLATFORM_MEMORY
|
||||
#define MBEDTLS_PLATFORM_NO_STD_FUNCTIONS
|
||||
#define MBEDTLS_ENTROPY_MAX_SOURCES 1
|
||||
|
||||
// Spans multiple lines to avoid being processed by unifdef
|
||||
#if defined(\
|
||||
MBEDTLS_USER_CONFIG_FILE)
|
||||
|
||||
+82
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* Copyright (c) 2025, The OpenThread Authors.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the copyright holder nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
// Spans multiple lines to avoid being processed by unifdef
|
||||
#ifndef \
|
||||
PSA_CRYPTO_CONFIG_H
|
||||
#define PSA_CRYPTO_CONFIG_H
|
||||
|
||||
#include "openthread-core-config.h"
|
||||
|
||||
#include <openthread/config.h>
|
||||
|
||||
#define PSA_WANT_ALG_CBC_NO_PADDING 1
|
||||
#define PSA_WANT_ALG_CBC_PKCS7 1
|
||||
#define PSA_WANT_ALG_CCM 1
|
||||
#define PSA_WANT_ALG_CCM_STAR_NO_TAG 1
|
||||
#define PSA_WANT_ALG_CMAC 1
|
||||
#define PSA_WANT_ALG_CFB 1
|
||||
#define PSA_WANT_ALG_CTR 1
|
||||
#define PSA_WANT_ALG_DETERMINISTIC_ECDSA 1
|
||||
#define PSA_WANT_ALG_ECB_NO_PADDING 1
|
||||
#define PSA_WANT_ALG_ECDH 1
|
||||
#define PSA_WANT_ALG_ECDSA 1
|
||||
#define PSA_WANT_ALG_JPAKE 1
|
||||
#define PSA_WANT_ALG_GCM 1
|
||||
#define PSA_WANT_ALG_HKDF 1
|
||||
#define PSA_WANT_ALG_HKDF_EXTRACT 1
|
||||
#define PSA_WANT_ALG_HKDF_EXPAND 1
|
||||
#define PSA_WANT_ALG_HMAC 1
|
||||
#define PSA_WANT_ALG_PBKDF2_HMAC 1
|
||||
#define PSA_WANT_ALG_PBKDF2_AES_CMAC_PRF_128 1
|
||||
#define PSA_WANT_ALG_RIPEMD160 1
|
||||
#define PSA_WANT_ALG_SHA_1 1
|
||||
#define PSA_WANT_ALG_SHA_224 1
|
||||
#define PSA_WANT_ALG_SHA_256 1
|
||||
#define PSA_WANT_ALG_TLS12_PRF 1
|
||||
#define PSA_WANT_ALG_TLS12_PSK_TO_MS 1
|
||||
#define PSA_WANT_ALG_TLS12_ECJPAKE_TO_PMS 1
|
||||
|
||||
#define PSA_WANT_ECC_SECP_K1_256 1
|
||||
#define PSA_WANT_ECC_SECP_R1_256 1
|
||||
|
||||
#define PSA_WANT_KEY_TYPE_DERIVE 1
|
||||
#define PSA_WANT_KEY_TYPE_PASSWORD 1
|
||||
#define PSA_WANT_KEY_TYPE_PASSWORD_HASH 1
|
||||
#define PSA_WANT_KEY_TYPE_HMAC 1
|
||||
#define PSA_WANT_KEY_TYPE_AES 1
|
||||
#define PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY 1
|
||||
#define PSA_WANT_KEY_TYPE_RAW_DATA 1
|
||||
|
||||
#define PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_BASIC 1
|
||||
#define PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_IMPORT 1
|
||||
#define PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_EXPORT 1
|
||||
#define PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_GENERATE 1
|
||||
#define PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_DERIVE 1
|
||||
|
||||
#endif /* PSA_CRYPTO_CONFIG_H */
|
||||
Reference in New Issue
Block a user