mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-23 03:45:39 +01:00
pk tests: USE_PSA_CRYPTO: test several curves
This commit is contained in:
parent
85f47c9d69
commit
33b1c69908
@ -271,5 +271,39 @@ ECDSA restartable sign/verify: ECKEY, max_ops=250
|
||||
depends_on:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_SHA256_C
|
||||
pk_sign_verify_restart:MBEDTLS_PK_ECKEY:MBEDTLS_ECP_DP_SECP256R1:"C9AFA9D845BA75166B5C215767B1D6934E50C3DB36E89B127B8A622B120F6721":"60FED4BA255A9D31C961EB74C6356D68C049B8923B61FA6CE669622E60F29FB6":"7903FE1008B8BC99A41AE9E95628BC64F2F1B20C2D7E9F5177A3C294D4462299":MBEDTLS_MD_SHA256:"test":"3045022100f1abb023518351cd71d881567b1ea663ed3efcf6c5132b354f28d3b0b7d383670220019f4113742a2b14bd25926b49c649155f267e60d3814b4c0cc84250e46f0083":250:2:64
|
||||
|
||||
PSA wrapped sign
|
||||
pk_psa_sign:
|
||||
PSA wrapped sign: SECP256R1
|
||||
depends_on:MBEDTLS_ECP_DP_SECP256R1_ENABLED
|
||||
pk_psa_sign:MBEDTLS_ECP_DP_SECP256R1:PSA_ECC_CURVE_SECP256R1:256
|
||||
|
||||
PSA wrapped sign: SECP384R1
|
||||
depends_on:MBEDTLS_ECP_DP_SECP384R1_ENABLED
|
||||
pk_psa_sign:MBEDTLS_ECP_DP_SECP384R1:PSA_ECC_CURVE_SECP384R1:384
|
||||
|
||||
PSA wrapped sign: SECP521R1
|
||||
depends_on:MBEDTLS_ECP_DP_SECP521R1_ENABLED
|
||||
pk_psa_sign:MBEDTLS_ECP_DP_SECP521R1:PSA_ECC_CURVE_SECP521R1:521
|
||||
|
||||
PSA wrapped sign: SECP192K1
|
||||
depends_on:MBEDTLS_ECP_DP_SECP192K1_ENABLED
|
||||
pk_psa_sign:MBEDTLS_ECP_DP_SECP192K1:PSA_ECC_CURVE_SECP192K1:192
|
||||
|
||||
## Currently buggy: https://github.com/ARMmbed/mbed-crypto/issues/336
|
||||
# PSA wrapped sign: SECP224K1
|
||||
# depends_on:MBEDTLS_ECP_DP_SECP224K1_ENABLED
|
||||
# pk_psa_sign:MBEDTLS_ECP_DP_SECP224K1:PSA_ECC_CURVE_SECP224K1:224
|
||||
|
||||
PSA wrapped sign: SECP256K1
|
||||
depends_on:MBEDTLS_ECP_DP_SECP256K1_ENABLED
|
||||
pk_psa_sign:MBEDTLS_ECP_DP_SECP256K1:PSA_ECC_CURVE_SECP256K1:256
|
||||
|
||||
PSA wrapped sign: BP256R1
|
||||
depends_on:MBEDTLS_ECP_DP_BP256R1_ENABLED
|
||||
pk_psa_sign:MBEDTLS_ECP_DP_BP256R1:PSA_ECC_CURVE_BRAINPOOL_P256R1:256
|
||||
|
||||
PSA wrapped sign: BP384R1
|
||||
depends_on:MBEDTLS_ECP_DP_BP384R1_ENABLED
|
||||
pk_psa_sign:MBEDTLS_ECP_DP_BP384R1:PSA_ECC_CURVE_BRAINPOOL_P384R1:384
|
||||
|
||||
PSA wrapped sign: BP512R1
|
||||
depends_on:MBEDTLS_ECP_DP_BP512R1_ENABLED
|
||||
pk_psa_sign:MBEDTLS_ECP_DP_BP512R1:PSA_ECC_CURVE_BRAINPOOL_P512R1:512
|
||||
|
@ -10,6 +10,11 @@
|
||||
#include <limits.h>
|
||||
#include <stdint.h>
|
||||
|
||||
/* Needed only for test case data under #if defined(MBEDTLS_USE_PSA_CRYPTO),
|
||||
* but the test code generator requires test case data to be valid C code
|
||||
* unconditionally (https://github.com/ARMmbed/mbedtls/issues/2023). */
|
||||
#include "psa/crypto.h"
|
||||
|
||||
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||
#include "mbedtls/psa_util.h"
|
||||
#include "psa_crypto_helpers.h"
|
||||
@ -1230,18 +1235,23 @@ exit:
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE depends_on:MBEDTLS_SHA256_C:MBEDTLS_USE_PSA_CRYPTO:MBEDTLS_ECDSA_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED */
|
||||
void pk_psa_sign( )
|
||||
/* BEGIN_CASE depends_on:MBEDTLS_SHA256_C:MBEDTLS_USE_PSA_CRYPTO:MBEDTLS_ECDSA_C */
|
||||
void pk_psa_sign( int grpid_arg,
|
||||
int psa_curve_arg, int expected_bits_arg )
|
||||
{
|
||||
mbedtls_ecp_group_id grpid = MBEDTLS_ECP_DP_SECP256R1;
|
||||
mbedtls_ecp_group_id grpid = grpid_arg;
|
||||
mbedtls_pk_context pk;
|
||||
unsigned char hash[50], sig[100], pkey_legacy[100], pkey_psa[100];
|
||||
unsigned char hash[32];
|
||||
unsigned char sig[MBEDTLS_ECDSA_MAX_LEN];
|
||||
unsigned char pkey_legacy[200];
|
||||
unsigned char pkey_psa[200];
|
||||
unsigned char *pkey_legacy_start, *pkey_psa_start;
|
||||
size_t sig_len, klen_legacy, klen_psa;
|
||||
int ret;
|
||||
psa_key_handle_t handle;
|
||||
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
|
||||
size_t expected_bits;
|
||||
psa_key_type_t expected_type = PSA_KEY_TYPE_ECC_KEY_PAIR( psa_curve_arg );
|
||||
size_t expected_bits = expected_bits_arg;
|
||||
|
||||
/*
|
||||
* This tests making signatures with a wrapped PSA key:
|
||||
@ -1274,9 +1284,7 @@ void pk_psa_sign( )
|
||||
PSA_ALG_SHA_256 ) == 0 );
|
||||
|
||||
PSA_ASSERT( psa_get_key_attributes( handle, &attributes ) );
|
||||
TEST_EQUAL( psa_get_key_type( &attributes ),
|
||||
PSA_KEY_TYPE_ECC_KEY_PAIR(
|
||||
mbedtls_ecc_group_to_psa( grpid, &expected_bits ) ) );
|
||||
TEST_EQUAL( psa_get_key_type( &attributes ), expected_type );
|
||||
TEST_EQUAL( psa_get_key_bits( &attributes ), expected_bits );
|
||||
TEST_EQUAL( psa_get_key_lifetime( &attributes ),
|
||||
PSA_KEY_LIFETIME_VOLATILE );
|
||||
|
Loading…
Reference in New Issue
Block a user