Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,17 @@

#include "cyhal_crypto_common.h"

/* Compatibility checks for Mbed TLS 3. */
#if !defined(MBEDTLS_INTERNAL_VALIDATE_RET)
#define MBEDTLS_INTERNAL_VALIDATE_RET(cond, ret) \
do { if (!(cond)) { return (ret); } } while (0)
#endif

#if !defined(MBEDTLS_INTERNAL_VALIDATE)
#define MBEDTLS_INTERNAL_VALIDATE(cond) \
do { if (!(cond)) { return; } } while (0)
#endif

/** CRYPTO object */
typedef struct {
#if defined(CY_IP_MXCRYPTO_INSTANCES) || defined(CPUSS_CRYPTO_PRESENT)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

#include "mbedtls/ecdsa.h"
#include "mbedtls/asn1write.h"
#include "mbedtls/error.h"
#include "mbedtls/platform_util.h"

#if defined(MBEDTLS_ECDSA_SIGN_ALT)
Expand Down Expand Up @@ -130,10 +131,10 @@ int mbedtls_ecdsa_sign( mbedtls_ecp_group *grp, mbedtls_mpi *r, mbedtls_mpi *s,
MBEDTLS_MPI_CHK((tmp_k == NULL) ? MBEDTLS_ERR_ECP_ALLOC_FAILED : 0);

ecdsa_status = Cy_Crypto_Core_ECC_MakePrivateKey(crypto_obj.base, key.curveID, tmp_k, f_rng, p_rng);
MBEDTLS_MPI_CHK((ecdsa_status == CY_CRYPTO_SUCCESS) ? 0 : MBEDTLS_ERR_ECP_HW_ACCEL_FAILED);
MBEDTLS_MPI_CHK((ecdsa_status == CY_CRYPTO_SUCCESS) ? 0 : MBEDTLS_ERR_PLATFORM_HW_ACCEL_FAILED);

ecdsa_status = Cy_Crypto_Core_ECC_SignHash(crypto_obj.base, buf, blen, sig, &key, tmp_k);
MBEDTLS_MPI_CHK((ecdsa_status == CY_CRYPTO_SUCCESS) ? 0 : MBEDTLS_ERR_ECP_HW_ACCEL_FAILED);
MBEDTLS_MPI_CHK((ecdsa_status == CY_CRYPTO_SUCCESS) ? 0 : MBEDTLS_ERR_PLATFORM_HW_ACCEL_FAILED);

/* Prepare a signature to load into an mpi format */
Cy_Crypto_Core_InvertEndianness(sig, bytesize);
Expand Down Expand Up @@ -226,7 +227,7 @@ int mbedtls_ecdsa_verify( mbedtls_ecp_group *grp,
Cy_Crypto_Core_InvertEndianness(key.pubkey.y, bytesize);

ecdsa_ver_status = Cy_Crypto_Core_ECC_VerifyHash(crypto_obj.base, sig, buf, blen, &stat, &key);
MBEDTLS_MPI_CHK((ecdsa_ver_status != CY_CRYPTO_SUCCESS) ? MBEDTLS_ERR_ECP_HW_ACCEL_FAILED : 0);
MBEDTLS_MPI_CHK((ecdsa_ver_status != CY_CRYPTO_SUCCESS) ? MBEDTLS_ERR_PLATFORM_HW_ACCEL_FAILED : 0);

MBEDTLS_MPI_CHK((stat == 1) ? 0 : MBEDTLS_ERR_ECP_VERIFY_FAILED);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

#include "mbedtls/ecp.h"
#include "mbedtls/platform_util.h"
#include "crypto_common.h"

#include <string.h>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@

#include "mbedtls/sha1.h"
#include "mbedtls/platform_util.h"
#include "crypto_common.h"

#include <string.h>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

#include "mbedtls/sha256.h"
#include "mbedtls/platform_util.h"
#include "crypto_common.h"

#include <string.h>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

#include "mbedtls/sha512.h"
#include "mbedtls/platform_util.h"
#include "crypto_common.h"

#include <string.h>

Expand Down
53 changes: 41 additions & 12 deletions connectivity/mbedtls/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,29 +22,32 @@ target_include_directories(mbed-mbedtls

target_sources(mbed-mbedtls
PRIVATE
platform/src/hash_wrappers.c
platform/src/mbed_trng.cpp
platform/src/platform_alt.cpp
platform/src/platform_time_mbed.cpp
platform/src/shared_rng.cpp
platform/src/timing_mbed.cpp

source/aes.c
source/aesce.c
source/aesni.c
source/arc4.c
source/aria.c
source/asn1parse.c
source/asn1write.c
source/base64.c
source/bignum.c
source/blowfish.c
source/bignum_core.c
source/bignum_mod.c
source/bignum_mod_raw.c
source/block_cipher.c
source/camellia.c
source/ccm.c
source/certs.c
source/chacha20.c
source/chachapoly.c
source/cipher.c
source/cipher_wrap.c
source/cmac.c
source/constant_time.c
source/ctr_drbg.c
source/debug.c
source/des.c
Expand All @@ -54,48 +57,74 @@ target_sources(mbed-mbedtls
source/ecjpake.c
source/ecp.c
source/ecp_curves.c
source/ecp_curves_new.c
source/entropy.c
source/entropy_poll.c
source/error.c
source/gcm.c
source/havege.c
source/hkdf.c
source/hmac_drbg.c
source/lmots.c
source/lms.c
source/md.c
source/md2.c
source/md4.c
source/md5.c
source/memory_buffer_alloc.c
source/mps_reader.c
source/mps_trace.c
source/net_sockets.c
source/nist_kw.c
source/oid.c
source/padlock.c
source/pem.c
source/pk.c
source/pk_ecc.c
source/pk_wrap.c
source/pkcs11.c
source/pkcs12.c
source/pkcs5.c
source/pkcs7.c
source/pkparse.c
source/pkwrite.c
source/platform.c
source/platform_util.c
source/poly1305.c
source/psa_crypto.c
source/psa_crypto_aead.c
source/psa_crypto_cipher.c
source/psa_crypto_client.c
source/psa_crypto_driver_wrappers_no_static.c
source/psa_crypto_ecp.c
source/psa_crypto_ffdh.c
source/psa_crypto_hash.c
source/psa_crypto_mac.c
source/psa_crypto_pake.c
source/psa_crypto_random.c
source/psa_crypto_rsa.c
source/psa_crypto_se.c
source/psa_crypto_slot_management.c
source/psa_crypto_storage.c
source/psa_its_file.c
source/psa_util.c
source/ripemd160.c
source/rsa.c
source/rsa_internal.c
source/rsa_alt_helpers.c
source/sha1.c
source/sha256.c
source/sha3.c
source/sha512.c
source/ssl_cache.c
source/ssl_ciphersuites.c
source/ssl_cli.c
source/ssl_client.c
source/ssl_cookie.c
source/ssl_debug_helpers_generated.c
source/ssl_msg.c
source/ssl_srv.c
source/ssl_ticket.c
source/ssl_tls.c
source/ssl_tls12_client.c
source/ssl_tls12_server.c
source/ssl_tls13_client.c
source/ssl_tls13_generic.c
source/ssl_tls13_keys.c
source/ssl_tls13_server.c
source/threading.c
source/timing.c
source/version.c
Expand All @@ -105,9 +134,9 @@ target_sources(mbed-mbedtls
source/x509_crl.c
source/x509_crt.c
source/x509_csr.c
source/x509write.c
source/x509write_crt.c
source/x509write_csr.c
source/xtea.c
)

target_compile_definitions(mbed-mbedtls
Expand Down
Loading
Loading