mirror of https://github.com/ARMmbed/mbed-os.git
Updated mbedTLS CRYPTO target to be more flexibly configured for supported boards
parent
2cd10fc786
commit
9fc299a1cc
|
@ -44,14 +44,14 @@
|
||||||
#include "mbedtls/platform.h"
|
#include "mbedtls/platform.h"
|
||||||
#include "mbedtls/platform_util.h"
|
#include "mbedtls/platform_util.h"
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_AES_ALT)
|
||||||
|
|
||||||
/* Parameter validation macros based on platform_util.h */
|
/* Parameter validation macros based on platform_util.h */
|
||||||
#define AES_VALIDATE_RET( cond ) \
|
#define AES_VALIDATE_RET( cond ) \
|
||||||
MBEDTLS_INTERNAL_VALIDATE_RET( cond, MBEDTLS_ERR_AES_BAD_INPUT_DATA )
|
MBEDTLS_INTERNAL_VALIDATE_RET( cond, MBEDTLS_ERR_AES_BAD_INPUT_DATA )
|
||||||
#define AES_VALIDATE( cond ) \
|
#define AES_VALIDATE( cond ) \
|
||||||
MBEDTLS_INTERNAL_VALIDATE( cond )
|
MBEDTLS_INTERNAL_VALIDATE( cond )
|
||||||
|
|
||||||
#if defined(MBEDTLS_AES_ALT)
|
|
||||||
|
|
||||||
#include "crypto_common.h"
|
#include "crypto_common.h"
|
||||||
#include "cy_crypto_core.h"
|
#include "cy_crypto_core.h"
|
||||||
|
|
||||||
|
@ -107,7 +107,9 @@ static int aes_set_keys( mbedtls_aes_context *ctx, const unsigned char *key,
|
||||||
cy_en_crypto_aes_key_length_t key_length;
|
cy_en_crypto_aes_key_length_t key_length;
|
||||||
cy_en_crypto_status_t status;
|
cy_en_crypto_status_t status;
|
||||||
|
|
||||||
AES_VALIDATE( ctx != NULL );
|
AES_VALIDATE_RET( ctx != NULL );
|
||||||
|
AES_VALIDATE_RET( key != NULL );
|
||||||
|
|
||||||
|
|
||||||
switch( keybits )
|
switch( keybits )
|
||||||
{
|
{
|
|
@ -168,5 +168,5 @@ void cy_hw_sha_clone( void *ctxDst, const void *ctxSrc, uint32_t ctxSize,
|
||||||
CY_CRYPTO_CHECK_PARAM( shaBuffersDst != NULL );
|
CY_CRYPTO_CHECK_PARAM( shaBuffersDst != NULL );
|
||||||
|
|
||||||
Cy_Crypto_Core_MemCpy(((cy_hw_crypto_t *)ctxSrc)->base, ctxDst, ctxSrc, (uint16_t)ctxSize);
|
Cy_Crypto_Core_MemCpy(((cy_hw_crypto_t *)ctxSrc)->base, ctxDst, ctxSrc, (uint16_t)ctxSize);
|
||||||
Cy_Crypto_Core_Sha_Init(((cy_hw_crypto_t *)ctxSrc)->base, hashStateDst, hashStateDst->mode, shaBuffersDst);
|
Cy_Crypto_Core_Sha_Init(((cy_hw_crypto_t *)ctxSrc)->base, hashStateDst, (cy_en_crypto_sha_mode_t)hashStateDst->mode, shaBuffersDst);
|
||||||
}
|
}
|
|
@ -2669,21 +2669,31 @@ cy_en_crypto_ecc_curve_id_t cy_get_dp_idx(mbedtls_ecp_group_id gid)
|
||||||
|
|
||||||
switch( gid )
|
switch( gid )
|
||||||
{
|
{
|
||||||
|
#if defined(MBEDTLS_ECP_DP_SECP192R1_ENABLED)
|
||||||
case MBEDTLS_ECP_DP_SECP192R1:
|
case MBEDTLS_ECP_DP_SECP192R1:
|
||||||
dp_idx = CY_CRYPTO_ECC_ECP_SECP192R1;
|
dp_idx = CY_CRYPTO_ECC_ECP_SECP192R1;
|
||||||
break;
|
break;
|
||||||
|
#endif /* defined(MBEDTLS_ECP_DP_SECP192R1_ENABLED) */
|
||||||
|
#if defined(MBEDTLS_ECP_DP_SECP224R1_ENABLED)
|
||||||
case MBEDTLS_ECP_DP_SECP224R1:
|
case MBEDTLS_ECP_DP_SECP224R1:
|
||||||
dp_idx = CY_CRYPTO_ECC_ECP_SECP224R1;
|
dp_idx = CY_CRYPTO_ECC_ECP_SECP224R1;
|
||||||
break;
|
break;
|
||||||
|
#endif /* defined(MBEDTLS_ECP_DP_SECP224R1_ENABLED) */
|
||||||
|
#if defined(MBEDTLS_ECP_DP_SECP256R1_ENABLED)
|
||||||
case MBEDTLS_ECP_DP_SECP256R1:
|
case MBEDTLS_ECP_DP_SECP256R1:
|
||||||
dp_idx = CY_CRYPTO_ECC_ECP_SECP256R1;
|
dp_idx = CY_CRYPTO_ECC_ECP_SECP256R1;
|
||||||
break;
|
break;
|
||||||
|
#endif /* defined(MBEDTLS_ECP_DP_SECP256R1_ENABLED) */
|
||||||
|
#if defined(MBEDTLS_ECP_DP_SECP384R1_ENABLED)
|
||||||
case MBEDTLS_ECP_DP_SECP384R1:
|
case MBEDTLS_ECP_DP_SECP384R1:
|
||||||
dp_idx = CY_CRYPTO_ECC_ECP_SECP384R1;
|
dp_idx = CY_CRYPTO_ECC_ECP_SECP384R1;
|
||||||
break;
|
break;
|
||||||
|
#endif /* defined(MBEDTLS_ECP_DP_SECP384R1_ENABLED) */
|
||||||
|
#if defined(MBEDTLS_ECP_DP_SECP521R1_ENABLED)
|
||||||
case MBEDTLS_ECP_DP_SECP521R1:
|
case MBEDTLS_ECP_DP_SECP521R1:
|
||||||
dp_idx = CY_CRYPTO_ECC_ECP_SECP521R1;
|
dp_idx = CY_CRYPTO_ECC_ECP_SECP521R1;
|
||||||
break;
|
break;
|
||||||
|
#endif /* defined(MBEDTLS_ECP_DP_SECP521R1_ENABLED) */
|
||||||
|
|
||||||
default:
|
default:
|
||||||
dp_idx = CY_CRYPTO_ECC_ECP_NONE;
|
dp_idx = CY_CRYPTO_ECC_ECP_NONE;
|
|
@ -39,13 +39,13 @@
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_SHA1_ALT)
|
||||||
|
|
||||||
/* Parameter validation macros based on platform_util.h */
|
/* Parameter validation macros based on platform_util.h */
|
||||||
#define SHA1_VALIDATE_RET(cond) \
|
#define SHA1_VALIDATE_RET(cond) \
|
||||||
MBEDTLS_INTERNAL_VALIDATE_RET( cond, MBEDTLS_ERR_SHA1_BAD_INPUT_DATA )
|
MBEDTLS_INTERNAL_VALIDATE_RET( cond, MBEDTLS_ERR_SHA1_BAD_INPUT_DATA )
|
||||||
#define SHA1_VALIDATE(cond) MBEDTLS_INTERNAL_VALIDATE( cond )
|
#define SHA1_VALIDATE(cond) MBEDTLS_INTERNAL_VALIDATE( cond )
|
||||||
|
|
||||||
#if defined(MBEDTLS_SHA1_ALT)
|
|
||||||
|
|
||||||
void mbedtls_sha1_init( mbedtls_sha1_context *ctx )
|
void mbedtls_sha1_init( mbedtls_sha1_context *ctx )
|
||||||
{
|
{
|
||||||
SHA1_VALIDATE( ctx != NULL );
|
SHA1_VALIDATE( ctx != NULL );
|
|
@ -38,13 +38,13 @@
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_SHA256_ALT)
|
||||||
|
|
||||||
/* Parameter validation macros based on platform_util.h */
|
/* Parameter validation macros based on platform_util.h */
|
||||||
#define SHA256_VALIDATE_RET(cond) \
|
#define SHA256_VALIDATE_RET(cond) \
|
||||||
MBEDTLS_INTERNAL_VALIDATE_RET( cond, MBEDTLS_ERR_SHA256_BAD_INPUT_DATA )
|
MBEDTLS_INTERNAL_VALIDATE_RET( cond, MBEDTLS_ERR_SHA256_BAD_INPUT_DATA )
|
||||||
#define SHA256_VALIDATE(cond) MBEDTLS_INTERNAL_VALIDATE( cond )
|
#define SHA256_VALIDATE(cond) MBEDTLS_INTERNAL_VALIDATE( cond )
|
||||||
|
|
||||||
#if defined(MBEDTLS_SHA256_ALT)
|
|
||||||
|
|
||||||
void mbedtls_sha256_init( mbedtls_sha256_context *ctx )
|
void mbedtls_sha256_init( mbedtls_sha256_context *ctx )
|
||||||
{
|
{
|
||||||
SHA256_VALIDATE( ctx != NULL );
|
SHA256_VALIDATE( ctx != NULL );
|
|
@ -38,13 +38,13 @@
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_SHA512_ALT)
|
||||||
|
|
||||||
/* Parameter validation macros based on platform_util.h */
|
/* Parameter validation macros based on platform_util.h */
|
||||||
#define SHA512_VALIDATE_RET(cond) \
|
#define SHA512_VALIDATE_RET(cond) \
|
||||||
MBEDTLS_INTERNAL_VALIDATE_RET( cond, MBEDTLS_ERR_SHA512_BAD_INPUT_DATA )
|
MBEDTLS_INTERNAL_VALIDATE_RET( cond, MBEDTLS_ERR_SHA512_BAD_INPUT_DATA )
|
||||||
#define SHA512_VALIDATE(cond) MBEDTLS_INTERNAL_VALIDATE( cond )
|
#define SHA512_VALIDATE(cond) MBEDTLS_INTERNAL_VALIDATE( cond )
|
||||||
|
|
||||||
#if defined(MBEDTLS_SHA512_ALT)
|
|
||||||
|
|
||||||
void mbedtls_sha512_init( mbedtls_sha512_context *ctx )
|
void mbedtls_sha512_init( mbedtls_sha512_context *ctx )
|
||||||
{
|
{
|
||||||
SHA512_VALIDATE( ctx != NULL );
|
SHA512_VALIDATE( ctx != NULL );
|
|
@ -8844,7 +8844,7 @@
|
||||||
"WATCHDOG"
|
"WATCHDOG"
|
||||||
],
|
],
|
||||||
"release_versions": ["5"],
|
"release_versions": ["5"],
|
||||||
"extra_labels": ["Cypress", "PSOC6"],
|
"extra_labels": ["Cypress", "PSOC6", "MXCRYPTO"],
|
||||||
"components_add": ["SOFTFP", "RTX"],
|
"components_add": ["SOFTFP", "RTX"],
|
||||||
"public": false,
|
"public": false,
|
||||||
"overrides" : {
|
"overrides" : {
|
||||||
|
@ -8869,6 +8869,7 @@
|
||||||
"device_has_remove": ["ANALOGOUT"],
|
"device_has_remove": ["ANALOGOUT"],
|
||||||
"extra_labels_add": [
|
"extra_labels_add": [
|
||||||
"PSOC6_02",
|
"PSOC6_02",
|
||||||
|
"MXCRYPTO_02",
|
||||||
"CM0P_SLEEP",
|
"CM0P_SLEEP",
|
||||||
"WHD",
|
"WHD",
|
||||||
"4343W",
|
"4343W",
|
||||||
|
@ -8887,6 +8888,7 @@
|
||||||
"device_has_remove": ["ANALOGOUT"],
|
"device_has_remove": ["ANALOGOUT"],
|
||||||
"extra_labels_add": [
|
"extra_labels_add": [
|
||||||
"PSOC6_02",
|
"PSOC6_02",
|
||||||
|
"MXCRYPTO_02",
|
||||||
"CM0P_SLEEP",
|
"CM0P_SLEEP",
|
||||||
"WHD",
|
"WHD",
|
||||||
"43012",
|
"43012",
|
||||||
|
@ -8905,6 +8907,7 @@
|
||||||
"supported_form_factors": ["ARDUINO"],
|
"supported_form_factors": ["ARDUINO"],
|
||||||
"extra_labels_add": [
|
"extra_labels_add": [
|
||||||
"PSOC6_01",
|
"PSOC6_01",
|
||||||
|
"MXCRYPTO_01",
|
||||||
"CM0P_SLEEP",
|
"CM0P_SLEEP",
|
||||||
"WHD",
|
"WHD",
|
||||||
"4343W",
|
"4343W",
|
||||||
|
@ -8946,6 +8949,7 @@
|
||||||
"supported_form_factors": ["ARDUINO"],
|
"supported_form_factors": ["ARDUINO"],
|
||||||
"extra_labels_add": [
|
"extra_labels_add": [
|
||||||
"PSOC6_01",
|
"PSOC6_01",
|
||||||
|
"MXCRYPTO_01",
|
||||||
"CM0P_SLEEP"
|
"CM0P_SLEEP"
|
||||||
],
|
],
|
||||||
"macros_add": ["CY8C6347BZI_BLD53"],
|
"macros_add": ["CY8C6347BZI_BLD53"],
|
||||||
|
@ -8961,7 +8965,7 @@
|
||||||
"components_remove": ["QSPIF"],
|
"components_remove": ["QSPIF"],
|
||||||
"device_has_remove": ["QSPI"],
|
"device_has_remove": ["QSPI"],
|
||||||
"supported_form_factors": ["ARDUINO"],
|
"supported_form_factors": ["ARDUINO"],
|
||||||
"extra_labels_add": ["PSOC6_01"],
|
"extra_labels_add": ["PSOC6_01", "MXCRYPTO_01"],
|
||||||
"macros_add": ["CYB06447BZI_D54",
|
"macros_add": ["CYB06447BZI_D54",
|
||||||
"PSOC6_DYNSRM_DISABLE=1",
|
"PSOC6_DYNSRM_DISABLE=1",
|
||||||
"CY_CFG_SYSCLK_WCO_ENABLED=1",
|
"CY_CFG_SYSCLK_WCO_ENABLED=1",
|
||||||
|
@ -8978,6 +8982,7 @@
|
||||||
"features": ["BLE"],
|
"features": ["BLE"],
|
||||||
"extra_labels_add": [
|
"extra_labels_add": [
|
||||||
"PSOC6_01",
|
"PSOC6_01",
|
||||||
|
"MXCRYPTO_01",
|
||||||
"CM0P_SLEEP",
|
"CM0P_SLEEP",
|
||||||
"WHD",
|
"WHD",
|
||||||
"43012",
|
"43012",
|
||||||
|
@ -8997,7 +9002,7 @@
|
||||||
"inherits": ["MCU_PSOC6_M0"],
|
"inherits": ["MCU_PSOC6_M0"],
|
||||||
"supported_form_factors": ["ARDUINO"],
|
"supported_form_factors": ["ARDUINO"],
|
||||||
"extra_labels_add": ["PSOC6_FUTURE", "CY8C63XX", "FUTURE_SEQUANA"],
|
"extra_labels_add": ["PSOC6_FUTURE", "CY8C63XX", "FUTURE_SEQUANA"],
|
||||||
"extra_labels_remove": ["PSOC6"],
|
"extra_labels_remove": ["PSOC6", "MXCRYPTO"],
|
||||||
"device_has_remove": ["TRNG", "CRC", "I2CSLAVE", "USBDEVICE", "QSPI", "WATCHDOG"],
|
"device_has_remove": ["TRNG", "CRC", "I2CSLAVE", "USBDEVICE", "QSPI", "WATCHDOG"],
|
||||||
"macros_add": ["CY8C6347BZI_BLD53"],
|
"macros_add": ["CY8C6347BZI_BLD53"],
|
||||||
"macros_remove": ["MBEDTLS_CONFIG_HW_SUPPORT"],
|
"macros_remove": ["MBEDTLS_CONFIG_HW_SUPPORT"],
|
||||||
|
@ -9031,7 +9036,7 @@
|
||||||
"supported_form_factors": ["ARDUINO"],
|
"supported_form_factors": ["ARDUINO"],
|
||||||
"components_remove": ["QSPIF"],
|
"components_remove": ["QSPIF"],
|
||||||
"extra_labels_add": ["PSOC6_FUTURE", "CY8C63XX", "CORDIO"],
|
"extra_labels_add": ["PSOC6_FUTURE", "CY8C63XX", "CORDIO"],
|
||||||
"extra_labels_remove": ["PSOC6"],
|
"extra_labels_remove": ["PSOC6", "MXCRYPTO"],
|
||||||
"device_has_remove": ["TRNG", "CRC", "I2CSLAVE", "USBDEVICE", "QSPI", "WATCHDOG"],
|
"device_has_remove": ["TRNG", "CRC", "I2CSLAVE", "USBDEVICE", "QSPI", "WATCHDOG"],
|
||||||
"macros_add": ["CY8C6347BZI_BLD53"],
|
"macros_add": ["CY8C6347BZI_BLD53"],
|
||||||
"macros_remove": ["MBEDTLS_CONFIG_HW_SUPPORT"],
|
"macros_remove": ["MBEDTLS_CONFIG_HW_SUPPORT"],
|
||||||
|
|
Loading…
Reference in New Issue