mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2025-01-24 06:00:59 +00:00
Merge pull request #3597 from gilles-peskine-arm/cert-gen-cleanup-202008-2.7
Backport 2.7: Minor cleanups in certificate generation
This commit is contained in:
commit
c10e6022ee
|
@ -125,9 +125,8 @@ int main( void )
|
|||
" Add NsCertType even if it is empty\n" \
|
||||
" md=%%s default: SHA256\n" \
|
||||
" possible values:\n" \
|
||||
" MD2, MD4, MD5, SHA1\n" \
|
||||
" SHA224, SHA256\n" \
|
||||
" SHA384, SHA512\n" \
|
||||
" MD2, MD4, MD5, RIPEMD160, SHA1,\n" \
|
||||
" SHA224, SHA256, SHA384, SHA512\n" \
|
||||
"\n"
|
||||
|
||||
/*
|
||||
|
@ -237,58 +236,14 @@ int main( int argc, char *argv[] )
|
|||
}
|
||||
else if( strcmp( p, "md" ) == 0 )
|
||||
{
|
||||
if( strcmp( q, "SHA256" ) == 0 )
|
||||
{
|
||||
opt.md_alg = MBEDTLS_MD_SHA256;
|
||||
}
|
||||
else if( strcmp( q, "SHA224" ) == 0 )
|
||||
{
|
||||
opt.md_alg = MBEDTLS_MD_SHA224;
|
||||
}
|
||||
else
|
||||
#if defined(MBEDTLS_MD5_C)
|
||||
if( strcmp( q, "MD5" ) == 0 )
|
||||
{
|
||||
opt.md_alg = MBEDTLS_MD_MD5;
|
||||
}
|
||||
else
|
||||
#endif /* MBEDTLS_MD5_C */
|
||||
#if defined(MBEDTLS_MD4_C)
|
||||
if( strcmp( q, "MD4" ) == 0 )
|
||||
{
|
||||
opt.md_alg = MBEDTLS_MD_MD4;
|
||||
}
|
||||
else
|
||||
#endif /* MBEDTLS_MD5_C */
|
||||
#if defined(MBEDTLS_MD2_C)
|
||||
if( strcmp( q, "MD2" ) == 0 )
|
||||
{
|
||||
opt.md_alg = MBEDTLS_MD_MD2;
|
||||
}
|
||||
else
|
||||
#endif /* MBEDTLS_MD2_C */
|
||||
#if defined(MBEDTLS_SHA1_C)
|
||||
if( strcmp( q, "SHA1" ) == 0 )
|
||||
{
|
||||
opt.md_alg = MBEDTLS_MD_SHA1;
|
||||
}
|
||||
else
|
||||
#endif /* MBEDTLS_SHA1_C */
|
||||
#if defined(MBEDTLS_SHA512_C)
|
||||
if( strcmp( q, "SHA384" ) == 0 )
|
||||
{
|
||||
opt.md_alg = MBEDTLS_MD_SHA384;
|
||||
}
|
||||
else
|
||||
if( strcmp( q, "SHA512" ) == 0 )
|
||||
{
|
||||
opt.md_alg = MBEDTLS_MD_SHA512;
|
||||
}
|
||||
else
|
||||
#endif /* MBEDTLS_SHA512_C */
|
||||
const mbedtls_md_info_t *md_info =
|
||||
mbedtls_md_info_from_string( q );
|
||||
if( md_info == NULL )
|
||||
{
|
||||
mbedtls_printf( "Invalid argument for option %s\n", p );
|
||||
goto usage;
|
||||
}
|
||||
opt.md_alg = mbedtls_md_get_type( md_info );
|
||||
}
|
||||
else if( strcmp( p, "key_usage" ) == 0 )
|
||||
{
|
||||
|
|
|
@ -13,8 +13,10 @@
|
|||
## Tools
|
||||
OPENSSL ?= openssl
|
||||
FAKETIME ?= faketime
|
||||
MBEDTLS_CERT_WRITE ?= $(PWD)/../../programs/x509/cert_write
|
||||
MBEDTLS_CERT_REQ ?= $(PWD)/../../programs/x509/cert_req
|
||||
|
||||
TOP_DIR = ../..
|
||||
MBEDTLS_CERT_WRITE ?= $(TOP_DIR)/programs/x509/cert_write
|
||||
MBEDTLS_CERT_REQ ?= $(TOP_DIR)/programs/x509/cert_req
|
||||
|
||||
## Build the generated test data. Note that since the final outputs
|
||||
## are committed to the repository, this target should do nothing on a
|
||||
|
@ -833,10 +835,6 @@ server1_ca.crt: server1.crt $(test_ca_crt)
|
|||
cat server1.crt $(test_ca_crt) > $@
|
||||
all_final += server1_ca.crt
|
||||
|
||||
cert_md5.crt: server1.key
|
||||
$(MBEDTLS_CERT_WRITE) subject_key=server1.key subject_name="C=NL, O=PolarSSL, CN=PolarSSL Cert MD5" serial=6 issuer_crt=$(test_ca_crt) issuer_key=$(test_ca_key_file_rsa) issuer_pwd=$(test_ca_pwd_rsa) not_before=20190210144406 not_after=20290210144406 md=MD5 version=3 output_file=$@
|
||||
all_final += cert_md5.crt
|
||||
|
||||
cert_sha1.crt: server1.key
|
||||
$(MBEDTLS_CERT_WRITE) subject_key=server1.key subject_name="C=NL, O=PolarSSL, CN=PolarSSL Cert SHA1" serial=7 issuer_crt=$(test_ca_crt) issuer_key=$(test_ca_key_file_rsa) issuer_pwd=$(test_ca_pwd_rsa) not_before=20190210144406 not_after=20290210144406 md=SHA1 version=3 output_file=$@
|
||||
all_final += cert_sha1.crt
|
||||
|
|
16
tests/data_files/cert_md2.csr
Normal file
16
tests/data_files/cert_md2.csr
Normal file
|
@ -0,0 +1,16 @@
|
|||
-----BEGIN CERTIFICATE REQUEST-----
|
||||
MIICgTCCAWkCAQAwPDELMAkGA1UEBhMCTkwxETAPBgNVBAoTCFBvbGFyU1NMMRow
|
||||
GAYDVQQDExFQb2xhclNTTCBDZXJ0IE1EMjCCASIwDQYJKoZIhvcNAQEBBQADggEP
|
||||
ADCCAQoCggEBAMh0xMy5+bV56UXZFGCwfbuT8msenzOtDY+KPFZl5dxE2cxmhQfV
|
||||
+CewSjXQY54Kbhu32vB+q+4MEJOGSRg086gq0lf1LtQvdymEYU2CUI+nlUhw9W5N
|
||||
stUTw9Ia7eZD6kIU63TqwO0f1FdOqfOo7dLgwTBxMDIw1dP2CNBWT0aO8l/5PWeR
|
||||
iDAuQrLfffvlDHf/7DHAeI+/wn/KrWwh1o3Zi2qOb+Cb+BBWzLOOExXmNARmx+75
|
||||
Ng5qlfYJmgZn9GVx+MqksSXg/jyLNQRnuuBPdoX8f/w2a7XpzS0DYk6zPQDPr3ag
|
||||
aVaDatKo1OdQcea1NgV3BW17yOTE/UzVIV8CAwEAAaAAMA0GCSqGSIb3DQEBAgUA
|
||||
A4IBAQA4VJ08+OCG8ZJw6U4+n0D3zZO/tW2xEKi7CnOPgWainiDIhv2v7JzLEzmA
|
||||
Zm/z/RmbAxKjpnbh3ooMuw4SL3eai/rEAi/PMbmGk434womFashGSBvwGMHXmWxv
|
||||
0IY+cPAgct3LWG9sWwZeZmIYMgKOUCjdYlBZBXJhvVI7iq/Xw0gpGuOLhps3Ambh
|
||||
j5IWK07X5Fd1ubk0OPqfRPU9PU0YNBD1sno4HBWWYsAxxb/NCas6K/R9WHstNDq6
|
||||
TDdUIwIfGGlqFFUUdifGDqTsTODvrJTokMU8JiqpZ9Lx+mx4wfbPmhg39/V3XBpM
|
||||
pGDLCUTwlctbNFM5y32Fb6XJk/+3
|
||||
-----END CERTIFICATE REQUEST-----
|
16
tests/data_files/cert_md4.csr
Normal file
16
tests/data_files/cert_md4.csr
Normal file
|
@ -0,0 +1,16 @@
|
|||
-----BEGIN CERTIFICATE REQUEST-----
|
||||
MIICgTCCAWkCAQAwPDELMAkGA1UEBhMCTkwxETAPBgNVBAoTCFBvbGFyU1NMMRow
|
||||
GAYDVQQDExFQb2xhclNTTCBDZXJ0IE1ENDCCASIwDQYJKoZIhvcNAQEBBQADggEP
|
||||
ADCCAQoCggEBAMh0xMy5+bV56UXZFGCwfbuT8msenzOtDY+KPFZl5dxE2cxmhQfV
|
||||
+CewSjXQY54Kbhu32vB+q+4MEJOGSRg086gq0lf1LtQvdymEYU2CUI+nlUhw9W5N
|
||||
stUTw9Ia7eZD6kIU63TqwO0f1FdOqfOo7dLgwTBxMDIw1dP2CNBWT0aO8l/5PWeR
|
||||
iDAuQrLfffvlDHf/7DHAeI+/wn/KrWwh1o3Zi2qOb+Cb+BBWzLOOExXmNARmx+75
|
||||
Ng5qlfYJmgZn9GVx+MqksSXg/jyLNQRnuuBPdoX8f/w2a7XpzS0DYk6zPQDPr3ag
|
||||
aVaDatKo1OdQcea1NgV3BW17yOTE/UzVIV8CAwEAAaAAMA0GCSqGSIb3DQEBAwUA
|
||||
A4IBAQCvIMDLo4HBjZsSFm+oIrUlBd3Yl+Ac4Gyu6xDSW7I0dDa02NFZv1Q/RagW
|
||||
4wJEQXegiTw5zHj0eUCdwL7o3NVCPRl9Jx7+0z4jVcfi7qyPGcoFHO/HA9v/fOgr
|
||||
rTPwVA3YgIqEyBUpgQcta/b0oYHJYLFM5M2S0nu7BzDvL0j+CfSIymyi20woSda3
|
||||
0TieyqHCEX8xLAT05KKG8NiSEhToDgOuj0HNPi+84JHvuhcRi6LU7Q8i/1wM49+7
|
||||
TQhe8jgCyz3y8UetGwBr1Xlqy8e2I5zUSiaJH7glWV6dmLTquev/Vat9SXvLUsRb
|
||||
lNc8nFK+4tGsr+vG8JU9bYXjAx4h
|
||||
-----END CERTIFICATE REQUEST-----
|
16
tests/data_files/cert_md5.csr
Normal file
16
tests/data_files/cert_md5.csr
Normal file
|
@ -0,0 +1,16 @@
|
|||
-----BEGIN CERTIFICATE REQUEST-----
|
||||
MIICgTCCAWkCAQAwPDELMAkGA1UEBhMCTkwxETAPBgNVBAoTCFBvbGFyU1NMMRow
|
||||
GAYDVQQDExFQb2xhclNTTCBDZXJ0IE1ENTCCASIwDQYJKoZIhvcNAQEBBQADggEP
|
||||
ADCCAQoCggEBAMh0xMy5+bV56UXZFGCwfbuT8msenzOtDY+KPFZl5dxE2cxmhQfV
|
||||
+CewSjXQY54Kbhu32vB+q+4MEJOGSRg086gq0lf1LtQvdymEYU2CUI+nlUhw9W5N
|
||||
stUTw9Ia7eZD6kIU63TqwO0f1FdOqfOo7dLgwTBxMDIw1dP2CNBWT0aO8l/5PWeR
|
||||
iDAuQrLfffvlDHf/7DHAeI+/wn/KrWwh1o3Zi2qOb+Cb+BBWzLOOExXmNARmx+75
|
||||
Ng5qlfYJmgZn9GVx+MqksSXg/jyLNQRnuuBPdoX8f/w2a7XpzS0DYk6zPQDPr3ag
|
||||
aVaDatKo1OdQcea1NgV3BW17yOTE/UzVIV8CAwEAAaAAMA0GCSqGSIb3DQEBBAUA
|
||||
A4IBAQB9WFAzCUYXl5pnYIdSizvMkVewMkAdkS5MJoabr5+lTMq0kvK6xFBGvQ5k
|
||||
4raIIV6RSa6aCFtOJNz/rQ3A/AuEeC5CckIAs/qmiJ/DOKFn3+FUbc04kA7Lkkeb
|
||||
HUpWaVCZQwOiCdgCennSdCnC+PtgN05405qyKdS9zj1BH2sUPbf+2rctMlLJr3ks
|
||||
FA/StcWprrrFq6DouddnlAZabRmHOuQbNVjZ642XFTgO07wva9/FfVxiHElJlj27
|
||||
Vqprqwz+Bth4dGnQN8SR7acM1PsgpE4Otg/OS9VoS+vG8vZpcgjzrJ7HvIKaIz9m
|
||||
Z0sgokL2cnxY79GldoMKOb47x09T
|
||||
-----END CERTIFICATE REQUEST-----
|
Loading…
Reference in a new issue