Skip to content

Commit b16b1db

Browse files
committed
[M487] Fix return error code when ECC H/W acceleratioin is failed
1 parent 3b138fb commit b16b1db

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480/ecp/ecp_internal_alt.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
* would be defined in mbedtls/ecp.h from ecp.c for our inclusion */
5454
#define ECP_SHORTWEIERSTRASS
5555

56+
#include "mbedtls/platform.h"
5657
#include "mbedtls/ecp_internal.h"
5758
#include "mbed_toolchain.h"
5859
#include "mbed_assert.h"
@@ -632,10 +633,9 @@ NU_STATIC int internal_run_eccop(const mbedtls_ecp_group *grp,
632633
crypto_ecc_prestart();
633634
CRPT->ECC_CTL = (grp->pbits << CRPT_ECC_CTL_CURVEM_Pos) | eccop | CRPT_ECC_CTL_FSEL_Msk | CRPT_ECC_CTL_START_Msk;
634635
ecc_done = crypto_ecc_wait();
635-
636-
/* FIXME: Better error code for ECC accelerator error */
637-
MBEDTLS_MPI_CHK(ecc_done ? 0 : -1);
638-
636+
637+
MBEDTLS_MPI_CHK(ecc_done ? 0 : MBEDTLS_ERR_PLATFORM_HW_ACCEL_FAILED);
638+
639639
/* (X1, Y1) hold the normalized result. */
640640
MBEDTLS_MPI_CHK(internal_mpi_read_eccreg(&R->X, (uint32_t *) CRPT->ECC_X1, NU_ECC_BIGNUM_MAXWORD));
641641
MBEDTLS_MPI_CHK(internal_mpi_read_eccreg(&R->Y, (uint32_t *) CRPT->ECC_Y1, NU_ECC_BIGNUM_MAXWORD));
@@ -726,10 +726,9 @@ NU_STATIC int internal_run_modop(mbedtls_mpi *r,
726726
crypto_ecc_prestart();
727727
CRPT->ECC_CTL = (pbits << CRPT_ECC_CTL_CURVEM_Pos) | (ECCOP_MODULE | modop) | CRPT_ECC_CTL_FSEL_Msk | CRPT_ECC_CTL_START_Msk;
728728
ecc_done = crypto_ecc_wait();
729-
730-
/* FIXME: Better error code for ECC accelerator error */
731-
MBEDTLS_MPI_CHK(ecc_done ? 0 : -1);
732-
729+
730+
MBEDTLS_MPI_CHK(ecc_done ? 0 : MBEDTLS_ERR_PLATFORM_HW_ACCEL_FAILED);
731+
733732
/* X1 holds the result. */
734733
MBEDTLS_MPI_CHK(internal_mpi_read_eccreg(r, (uint32_t *) CRPT->ECC_X1, NU_ECC_BIGNUM_MAXWORD));
735734

0 commit comments

Comments
 (0)