mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-12-22 20:25:34 +00:00
Add tests for x509parse_key_ec()
Test files were generated as follows: openssl ecparam -name prime192v1 -genkey > key.pem openssl ec -in key.pem -pubout -outform PEM > pub.pem openssl ec -in key.pem -pubout -outform DER > pub.der openssl ec -in key.pem -outform pem > prv.sec1.pem openssl ec -in key.pem -outform der > prv.sec1.der openssl ec -in key.pem -des -passout pass:polar -outform pem > prv.sec1.pw.pem openssl pkcs8 -topk8 -in key.pem -nocrypt -outform pem > prv.pk8.pem openssl pkcs8 -topk8 -in key.pem -nocrypt -outform der > prv.pk8.der openssl pkcs8 -topk8 -in key.pem -passout pass:polar -outform der \ > prv.pk8.pw.der openssl pkcs8 -topk8 -in key.pem -passout pass:polar -outform pem \ > prv.pk8.pw.pem
This commit is contained in:
parent
15e8b82724
commit
2b9252cd8f
BIN
tests/data_files/ec_prv.pk8.der
Normal file
BIN
tests/data_files/ec_prv.pk8.der
Normal file
Binary file not shown.
5
tests/data_files/ec_prv.pk8.pem
Normal file
5
tests/data_files/ec_prv.pk8.pem
Normal file
|
@ -0,0 +1,5 @@
|
|||
-----BEGIN PRIVATE KEY-----
|
||||
MG8CAQAwEwYHKoZIzj0CAQYIKoZIzj0DAQEEVTBTAgEBBBgzjoaogeI49Um9bwVT
|
||||
SUtz49YRMP3GyW2hNAMyAARRdbzfMKNw851Tk+YScojYAWe19LS3dsZ098bzVLfS
|
||||
JAYsH2hUtaevD+V46vJY8Cc=
|
||||
-----END PRIVATE KEY-----
|
BIN
tests/data_files/ec_prv.pk8.pw.der
Normal file
BIN
tests/data_files/ec_prv.pk8.pw.der
Normal file
Binary file not shown.
6
tests/data_files/ec_prv.pk8.pw.pem
Normal file
6
tests/data_files/ec_prv.pk8.pw.pem
Normal file
|
@ -0,0 +1,6 @@
|
|||
-----BEGIN ENCRYPTED PRIVATE KEY-----
|
||||
MIGXMBsGCSqGSIb3DQEFAzAOBAiO5a+OuKjOdwICCAAEeGEBv8oxHZy3GvR28QHJ
|
||||
Xq1Fq/UZrWklH6RI8VTx4WS6UK88PzJSmLMxO3pl4L/CUNfJ4RI9+YHFRZyf8Tcr
|
||||
5di4xMQaEqh08PXwyErqOerBGc9DsFpcpFAsn6Sa9KLG5aritGrSkPyDACloHyKR
|
||||
lJyTE6fTVwG5xQ==
|
||||
-----END ENCRYPTED PRIVATE KEY-----
|
BIN
tests/data_files/ec_prv.sec1.der
Normal file
BIN
tests/data_files/ec_prv.sec1.der
Normal file
Binary file not shown.
5
tests/data_files/ec_prv.sec1.pem
Normal file
5
tests/data_files/ec_prv.sec1.pem
Normal file
|
@ -0,0 +1,5 @@
|
|||
-----BEGIN EC PRIVATE KEY-----
|
||||
MF8CAQEEGDOOhqiB4jj1Sb1vBVNJS3Pj1hEw/cbJbaAKBggqhkjOPQMBAaE0AzIA
|
||||
BFF1vN8wo3DznVOT5hJyiNgBZ7X0tLd2xnT3xvNUt9IkBiwfaFS1p68P5Xjq8ljw
|
||||
Jw==
|
||||
-----END EC PRIVATE KEY-----
|
8
tests/data_files/ec_prv.sec1.pw.pem
Normal file
8
tests/data_files/ec_prv.sec1.pw.pem
Normal file
|
@ -0,0 +1,8 @@
|
|||
-----BEGIN EC PRIVATE KEY-----
|
||||
Proc-Type: 4,ENCRYPTED
|
||||
DEK-Info: DES-CBC,AA94892A169FA426
|
||||
|
||||
gSkFuUENNke5MvkWHc11/w1NQWBxaIxGT+d5oRcqs44D3tltVOwtdnYexoD9uSIL
|
||||
wMFFRLL6I5ii1Naa38nPOMaa7kLU2J3jY8SeIH1rQ43X6tlpv9WFGqDn/m6X7oKo
|
||||
RMMfGdicPZg=
|
||||
-----END EC PRIVATE KEY-----
|
|
@ -194,6 +194,34 @@ X509 Parse Public EC Key #2 (RFC 5480, PEM)
|
|||
depends_on:POLARSSL_PEM_C:POLARSSL_ECP_C:POLARSSL_FS_IO
|
||||
x509parse_public_keyfile_ec:"data_files/ec_pub.pem":0
|
||||
|
||||
X509 Parse EC Key #1 (SEC1 DER)
|
||||
depends_on:POLARSSL_FS_IO:POLARSSL_ECP_C
|
||||
x509parse_keyfile_ec:"data_files/ec_prv.sec1.der":NULL:0
|
||||
|
||||
X509 Parse EC Key #2 (SEC1 PEM)
|
||||
depends_on:POLARSSL_PEM_C:POLARSSL_FS_IO:POLARSSL_ECP_C
|
||||
x509parse_keyfile_ec:"data_files/ec_prv.sec1.pem":NULL:0
|
||||
|
||||
X509 Parse EC Key #3 (SEC1 PEM encrypted)
|
||||
depends_on:POLARSSL_DES_C:POLARSSL_PEM_C:POLARSSL_FS_IO:POLARSSL_ECP_C
|
||||
x509parse_keyfile_ec:"data_files/ec_prv.sec1.pw.pem":"polar":0
|
||||
|
||||
X509 Parse EC Key #4 (PKCS8 DER)
|
||||
depends_on:POLARSSL_FS_IO:POLARSSL_ECP_C
|
||||
x509parse_keyfile_ec:"data_files/ec_prv.pk8.der":NULL:0
|
||||
|
||||
X509 Parse EC Key #5 (PKCS8 PEM)
|
||||
depends_on:POLARSSL_PEM_C:POLARSSL_FS_IO:POLARSSL_ECP_C
|
||||
x509parse_keyfile_ec:"data_files/ec_prv.pk8.pem":NULL:0
|
||||
|
||||
X509 Parse EC Key #6 (PKCS8 encrypted DER)
|
||||
depends_on:POLARSSL_DES_C:POLARSSL_FS_IO:POLARSSL_ECP_C
|
||||
x509parse_keyfile_ec:"data_files/ec_prv.pk8.pw.der":"polar":0
|
||||
|
||||
X509 Parse EC Key #7 (PKCS8 encrypted PEM)
|
||||
depends_on:POLARSSL_DES_C:POLARSSL_PEM_C:POLARSSL_FS_IO:POLARSSL_ECP_C
|
||||
x509parse_keyfile_ec:"data_files/ec_prv.pk8.pw.pem":"polar":0
|
||||
|
||||
X509 Get Distinguished Name #1
|
||||
depends_on:POLARSSL_PEM_C:POLARSSL_FS_IO
|
||||
x509_dn_gets:"data_files/server1.crt":subject:"C=NL, O=PolarSSL, CN=PolarSSL Server 1"
|
||||
|
|
|
@ -200,6 +200,27 @@ x509parse_public_keyfile_ec:key_file:result
|
|||
}
|
||||
END_CASE
|
||||
|
||||
BEGIN_CASE
|
||||
x509parse_keyfile_ec:key_file:password:result
|
||||
{
|
||||
ecp_keypair eckey;
|
||||
int res;
|
||||
|
||||
ecp_keypair_init( &eckey );
|
||||
|
||||
res = x509parse_keyfile_ec( &eckey, {key_file}, {password} );
|
||||
|
||||
TEST_ASSERT( res == {result} );
|
||||
|
||||
if( res == 0 )
|
||||
{
|
||||
TEST_ASSERT( ecp_check_prvkey( &eckey.grp, &eckey.d ) == 0 );
|
||||
}
|
||||
|
||||
ecp_keypair_free( &eckey );
|
||||
}
|
||||
END_CASE
|
||||
|
||||
BEGIN_CASE
|
||||
x509parse_crt:crt_data:result_str:result
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue