From c9cc3577347b5df6d35c30c352da7f91363a877e Mon Sep 17 00:00:00 2001 From: ccli8 Date: Tue, 6 Feb 2018 09:30:57 +0800 Subject: [PATCH] [M487] Check divisor is not zero in MODOP_DIV operation in ECP alter. --- .../TARGET_NUVOTON/TARGET_M480/ecp/ecp_internal_alt.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480/ecp/ecp_internal_alt.c b/features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480/ecp/ecp_internal_alt.c index 2a0a0c8e60..5dc5d1e80e 100644 --- a/features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480/ecp/ecp_internal_alt.c +++ b/features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480/ecp/ecp_internal_alt.c @@ -719,6 +719,11 @@ int mbedtls_internal_run_modop(mbedtls_mpi *r, return MBEDTLS_ERR_ECP_BAD_INPUT_DATA; } + /* Check divisor is not zero in MODOP_DIV operation */ + if (modop == MODOP_DIV && mbedtls_mpi_cmp_int(o2, 0) == 0) { + return MBEDTLS_ERR_ECP_BAD_INPUT_DATA; + } + int ret; bool ecc_done;