mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-12-23 18:35:44 +00:00
TinyCrypt Test: Adapt 'PK utils: ECKEY' test in PK test suite
This commit is contained in:
parent
da77971ec8
commit
251d7523fe
|
@ -12,10 +12,14 @@ PK utils: RSA
|
|||
depends_on:MBEDTLS_RSA_C:MBEDTLS_GENPRIME
|
||||
pk_utils:MBEDTLS_PK_RSA:512:64:"RSA"
|
||||
|
||||
PK utils: ECKEY
|
||||
depends_on:MBEDTLS_ECP_C:MBEDTLS_ECP_DP_SECP192R1_ENABLED
|
||||
PK utils: ECKEY (legacy)
|
||||
depends_on:MBEDTLS_ECP_C:MBEDTLS_ECP_DP_SECP192R1_ENABLED:!MBEDTLS_USE_TINYCRYPT
|
||||
pk_utils:MBEDTLS_PK_ECKEY:192:24:"EC"
|
||||
|
||||
PK utils: ECKEY (TinyCrypt)
|
||||
depends_on:MBEDTLS_USE_TINYCRYPT
|
||||
pk_utils:MBEDTLS_PK_ECKEY:256:32:"EC"
|
||||
|
||||
PK utils: ECKEY_DH
|
||||
depends_on:MBEDTLS_ECP_C:MBEDTLS_ECP_DP_SECP192R1_ENABLED
|
||||
pk_utils:MBEDTLS_PK_ECKEY_DH:192:24:"EC_DH"
|
||||
|
|
|
@ -7,6 +7,10 @@
|
|||
#include "mbedtls/ecp.h"
|
||||
#include "mbedtls/rsa.h"
|
||||
|
||||
#if defined(MBEDTLS_USE_TINYCRYPT)
|
||||
#include "tinycrypt/ecc_dh.h"
|
||||
#endif /* MBEDTLS_USE_TINYCRYPT */
|
||||
|
||||
#include <limits.h>
|
||||
#include <stdint.h>
|
||||
|
||||
|
@ -21,8 +25,24 @@ static int pk_genkey( mbedtls_pk_context *pk )
|
|||
|
||||
#if defined(MBEDTLS_RSA_C) && defined(MBEDTLS_GENPRIME)
|
||||
if( mbedtls_pk_get_type( pk ) == MBEDTLS_PK_RSA )
|
||||
{
|
||||
return mbedtls_rsa_gen_key( mbedtls_pk_rsa( *pk ), rnd_std_rand, NULL, RSA_KEY_SIZE, 3 );
|
||||
} else
|
||||
#endif
|
||||
#if defined(MBEDTLS_USE_TINYCRYPT)
|
||||
if( mbedtls_pk_get_type( pk ) == MBEDTLS_PK_ECKEY )
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = uECC_make_key( mbedtls_pk_uecc( *pk )->public_key,
|
||||
mbedtls_pk_uecc( *pk )->private_key,
|
||||
uECC_secp256r1() );
|
||||
if( ret == 0 )
|
||||
return( -1 );
|
||||
|
||||
return( 0 );
|
||||
} else
|
||||
#endif /* MBEDTLS_USE_TINYCRYPT */
|
||||
#if defined(MBEDTLS_ECP_C)
|
||||
if( mbedtls_pk_get_type( pk ) == MBEDTLS_PK_ECKEY ||
|
||||
mbedtls_pk_get_type( pk ) == MBEDTLS_PK_ECKEY_DH ||
|
||||
|
@ -35,9 +55,9 @@ static int pk_genkey( mbedtls_pk_context *pk )
|
|||
|
||||
return mbedtls_ecp_gen_keypair( &mbedtls_pk_ec( *pk )->grp, &mbedtls_pk_ec( *pk )->d,
|
||||
&mbedtls_pk_ec( *pk )->Q, rnd_std_rand, NULL );
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
return( -1 );
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
#if defined(MBEDTLS_RSA_C)
|
||||
|
|
Loading…
Reference in a new issue