mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-22 15:55:37 +01:00
cert_req: discover hash algorithms automatically
Discover hash algorithms automatically rather than hard-coding a list, as was previously done in cert_write. Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
parent
db1e7a8f7b
commit
c3d0a7f1ec
@ -127,9 +127,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"
|
||||
|
||||
|
||||
@ -244,58 +243,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 )
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user