mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-21 13:53:55 -07:00
Add: 'hf mfu info' - now does orinality check against ECC. (@pwpivi)
Adapted to prefered codestyle and added references.
This commit is contained in:
parent
283060f962
commit
f433e26e3b
13 changed files with 264 additions and 131 deletions
|
@ -115,6 +115,7 @@
|
|||
#endif
|
||||
|
||||
#if defined(MBEDTLS_ECP_C) && ( !defined(MBEDTLS_BIGNUM_C) || ( \
|
||||
!defined(MBEDTLS_ECP_DP_SECP128R1_ENABLED) && \
|
||||
!defined(MBEDTLS_ECP_DP_SECP192R1_ENABLED) && \
|
||||
!defined(MBEDTLS_ECP_DP_SECP224R1_ENABLED) && \
|
||||
!defined(MBEDTLS_ECP_DP_SECP256R1_ENABLED) && \
|
||||
|
|
|
@ -645,6 +645,7 @@
|
|||
*
|
||||
* Comment macros to disable the curve and functions for it
|
||||
*/
|
||||
#define MBEDTLS_ECP_DP_SECP128R1_ENABLED
|
||||
#define MBEDTLS_ECP_DP_SECP192R1_ENABLED
|
||||
#define MBEDTLS_ECP_DP_SECP224R1_ENABLED
|
||||
#define MBEDTLS_ECP_DP_SECP256R1_ENABLED
|
||||
|
|
|
@ -286,7 +286,7 @@ cleanup:
|
|||
/*
|
||||
* Convert a signature (given by context) to ASN.1
|
||||
*/
|
||||
static int ecdsa_signature_to_asn1(const mbedtls_mpi *r, const mbedtls_mpi *s,
|
||||
int ecdsa_signature_to_asn1(const mbedtls_mpi *r, const mbedtls_mpi *s,
|
||||
unsigned char *sig, size_t *slen) {
|
||||
int ret;
|
||||
unsigned char buf[MBEDTLS_ECDSA_MAX_LEN];
|
||||
|
|
|
@ -334,6 +334,8 @@ void mbedtls_ecdsa_init(mbedtls_ecdsa_context *ctx);
|
|||
*/
|
||||
void mbedtls_ecdsa_free(mbedtls_ecdsa_context *ctx);
|
||||
|
||||
int ecdsa_signature_to_asn1( const mbedtls_mpi *r, const mbedtls_mpi *s, unsigned char *sig, size_t *slen );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -84,7 +84,8 @@
|
|||
static unsigned long add_count, dbl_count, mul_count;
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_ECP_DP_SECP192R1_ENABLED) || \
|
||||
#if defined(MBEDTLS_ECP_DP_SECP128R1_ENABLED) || \
|
||||
defined(MBEDTLS_ECP_DP_SECP192R1_ENABLED) || \
|
||||
defined(MBEDTLS_ECP_DP_SECP224R1_ENABLED) || \
|
||||
defined(MBEDTLS_ECP_DP_SECP256R1_ENABLED) || \
|
||||
defined(MBEDTLS_ECP_DP_SECP384R1_ENABLED) || \
|
||||
|
@ -157,6 +158,9 @@ static const mbedtls_ecp_curve_info ecp_supported_curves[] = {
|
|||
#endif
|
||||
#if defined(MBEDTLS_ECP_DP_SECP192K1_ENABLED)
|
||||
{ MBEDTLS_ECP_DP_SECP192K1, 18, 192, "secp192k1" },
|
||||
#endif
|
||||
#if defined(MBEDTLS_ECP_DP_SECP128R1_ENABLED)
|
||||
{ MBEDTLS_ECP_DP_SECP128R1, 0xFE00, 128, "secp128r1" },
|
||||
#endif
|
||||
{ MBEDTLS_ECP_DP_NONE, 0, 0, NULL },
|
||||
};
|
||||
|
|
|
@ -81,6 +81,7 @@ typedef enum {
|
|||
MBEDTLS_ECP_DP_SECP224K1, /*!< Domain parameters for 224-bit "Koblitz" curve. */
|
||||
MBEDTLS_ECP_DP_SECP256K1, /*!< Domain parameters for 256-bit "Koblitz" curve. */
|
||||
MBEDTLS_ECP_DP_CURVE448, /*!< Domain parameters for Curve448. */
|
||||
MBEDTLS_ECP_DP_SECP128R1, /*!< Domain parameters for the 128-bit curve used for NXP originality check. */
|
||||
} mbedtls_ecp_group_id;
|
||||
|
||||
/**
|
||||
|
|
|
@ -84,6 +84,42 @@
|
|||
* to be directly usable in MPIs
|
||||
*/
|
||||
|
||||
/*
|
||||
* Domain parameters for secp128r1
|
||||
*/
|
||||
#if defined(MBEDTLS_ECP_DP_SECP128R1_ENABLED)
|
||||
static const mbedtls_mpi_uint secp128r1_p[] = {
|
||||
// 2^128 - 2^97 - 1 // TODO
|
||||
BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ),
|
||||
BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFD, 0xFF, 0xFF, 0xFF ),
|
||||
};
|
||||
static const mbedtls_mpi_uint secp128r1_a[] = {
|
||||
// FFFFFFFDFFFFFFFF FFFFFFFFFFFFFFFC
|
||||
BYTES_TO_T_UINT_8( 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ),
|
||||
BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFD, 0xFF, 0xFF, 0xFF ),
|
||||
};
|
||||
static const mbedtls_mpi_uint secp128r1_b[] = {
|
||||
// E87579C11079F43D D824993C2CEE5ED3
|
||||
BYTES_TO_T_UINT_8( 0xD3, 0x5E, 0xEE, 0x2C, 0x3C, 0x99, 0x24, 0xD8 ),
|
||||
BYTES_TO_T_UINT_8( 0x3D, 0xF4, 0x79, 0x10, 0xC1, 0x79, 0x75, 0xE8 ),
|
||||
};
|
||||
static const mbedtls_mpi_uint secp128r1_gx[] = {
|
||||
// 161FF7528B899B2D 0C28607CA52C5B86
|
||||
BYTES_TO_T_UINT_8( 0x86, 0x5B, 0x2C, 0xA5, 0x7C, 0x60, 0x28, 0x0C ),
|
||||
BYTES_TO_T_UINT_8( 0x2D, 0x9B, 0x89, 0x8B, 0x52, 0xF7, 0x1F, 0x16 ),
|
||||
};
|
||||
static const mbedtls_mpi_uint secp128r1_gy[] = {
|
||||
// CF5AC8395BAFEB13 C02DA292DDED7A83
|
||||
BYTES_TO_T_UINT_8( 0x83, 0x7A, 0xED, 0xDD, 0x92, 0xA2, 0x2D, 0xC0 ),
|
||||
BYTES_TO_T_UINT_8( 0x13, 0xEB, 0xAF, 0x5B, 0x39, 0xC8, 0x5A, 0xCF ),
|
||||
};
|
||||
static const mbedtls_mpi_uint secp128r1_n[] = {
|
||||
// FFFFFFFE00000000 75A30D1B9038A115
|
||||
BYTES_TO_T_UINT_8( 0x15, 0xA1, 0x38, 0x90, 0x1B, 0x0D, 0xA3, 0x75 ),
|
||||
BYTES_TO_T_UINT_8( 0x00, 0x00, 0x00, 0x00, 0xFE, 0xFF, 0xFF, 0xFF ),
|
||||
};
|
||||
#endif /* MBEDTLS_ECP_DP_SECP128R1_ENABLED */
|
||||
|
||||
/*
|
||||
* Domain parameters for secp192r1
|
||||
*/
|
||||
|
@ -747,6 +783,11 @@ int mbedtls_ecp_group_load(mbedtls_ecp_group *grp, mbedtls_ecp_group_id id) {
|
|||
grp->id = id;
|
||||
|
||||
switch (id) {
|
||||
#if defined(MBEDTLS_ECP_DP_SECP128R1_ENABLED)
|
||||
case MBEDTLS_ECP_DP_SECP128R1:
|
||||
grp->modp = NULL;
|
||||
return( LOAD_GROUP_A( secp128r1 ) );
|
||||
#endif /* MBEDTLS_ECP_DP_SECP128R1_ENABLED */
|
||||
#if defined(MBEDTLS_ECP_DP_SECP192R1_ENABLED)
|
||||
case MBEDTLS_ECP_DP_SECP192R1:
|
||||
NIST_MODP(p192);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue