Add suppport for MD2 to CSR and CRT writing example programs
The example programs programs/x509/cert_req and programs/x509/cert_write
(demonstrating the use of X.509 CSR and CRT writing functionality)
previously didn't support MD2 signatures.
For testing purposes, this commit adds support for MD2 to cert_req,
and support for MD2 and MD4 to cert_write.
diff --git a/programs/x509/cert_req.c b/programs/x509/cert_req.c
index d25ad4c..b2052ec 100644
--- a/programs/x509/cert_req.c
+++ b/programs/x509/cert_req.c
@@ -102,7 +102,7 @@
" Add NsCertType even if it is empty\n" \
" md=%%s default: SHA256\n" \
" possible values:\n" \
- " MD4, MD5, SHA1\n" \
+ " MD2, MD4, MD5, SHA1\n" \
" SHA224, SHA256\n" \
" SHA384, SHA512\n" \
"\n"
@@ -252,6 +252,13 @@
}
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 )
{