mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-07-30 22:43:08 +03:00
ecp_curves: Added unit-tests for secp256k1
This patch introduces basic unit-testing for the `ecp_mod_p256k1()`. The method is exposed through the ecp_invasive interface, and the standard testing data is being provided by the python framework. Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
This commit is contained in:
@ -4617,7 +4617,8 @@ MBEDTLS_STATIC_TESTABLE
|
||||
int mbedtls_ecp_mod_p224k1(mbedtls_mpi *);
|
||||
#endif
|
||||
#if defined(MBEDTLS_ECP_DP_SECP256K1_ENABLED)
|
||||
static int ecp_mod_p256k1(mbedtls_mpi *);
|
||||
MBEDTLS_STATIC_TESTABLE
|
||||
int ecp_mod_p256k1(mbedtls_mpi *);
|
||||
#endif
|
||||
|
||||
#if defined(ECP_LOAD_GROUP)
|
||||
@ -5659,7 +5660,8 @@ int mbedtls_ecp_mod_p224k1(mbedtls_mpi *N)
|
||||
* Fast quasi-reduction modulo p256k1 = 2^256 - R,
|
||||
* with R = 2^32 + 2^9 + 2^8 + 2^7 + 2^6 + 2^4 + 1 = 0x01000003D1
|
||||
*/
|
||||
static int ecp_mod_p256k1(mbedtls_mpi *N)
|
||||
MBEDTLS_STATIC_TESTABLE
|
||||
int ecp_mod_p256k1(mbedtls_mpi *N)
|
||||
{
|
||||
static mbedtls_mpi_uint Rp[] = {
|
||||
MBEDTLS_BYTES_TO_T_UINT_8(0xD1, 0x03, 0x00, 0x00, 0x01, 0x00, 0x00,
|
||||
|
@ -186,6 +186,13 @@ int mbedtls_ecp_mod_p224k1(mbedtls_mpi *N);
|
||||
|
||||
#endif /* MBEDTLS_ECP_DP_SECP224K1_ENABLED */
|
||||
|
||||
#if defined(MBEDTLS_ECP_DP_SECP256K1_ENABLED)
|
||||
|
||||
MBEDTLS_STATIC_TESTABLE
|
||||
int ecp_mod_p256k1(mbedtls_mpi *N);
|
||||
|
||||
#endif /* MBEDTLS_ECP_DP_SECP256K1_ENABLED */
|
||||
|
||||
/** Initialise a modulus with hard-coded const curve data.
|
||||
*
|
||||
* \note The caller is responsible for the \p N modulus' memory.
|
||||
|
Reference in New Issue
Block a user