From 991a05b4110dbb761e82cc018b6e1e5336535b3d Mon Sep 17 00:00:00 2001 From: Ron Eldor Date: Tue, 12 Feb 2019 15:05:53 +0200 Subject: [PATCH] Add support for all SHA modes in cert_write Add support for `MBEDTLS_SHA_224` and `MBEDTLS_SHA_384` in `cert_write`, to support generating such certificates in `tests/data_files/Makefile`. --- library/certs.c | 2 +- programs/x509/cert_write.c | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/library/certs.c b/library/certs.c index 3c18d3cd9..f152c283a 100644 --- a/library/certs.c +++ b/library/certs.c @@ -725,7 +725,7 @@ "iEM9wW7hEMkwmk0h/sqZsrJsGH5YsF/VThSq/JVO1e2mZH2vruyZKJVBq+8tDNYp\r\n" \ "HkK6tSyVYQhzIt3StMJWKMl/o5k2AYz6tSC164+1oG+ML3LWg8XrGKa91H4UOKap\r\n" \ "Awgk0+4m0T25cNs=\r\n" \ -"-----END CERTIFICATE-----\r\n"; +"-----END CERTIFICATE-----\r\n" /* END FILE */ /* This is taken from tests/data_files/server2.crt.der. */ diff --git a/programs/x509/cert_write.c b/programs/x509/cert_write.c index c3e89bef5..d36d73c0d 100644 --- a/programs/x509/cert_write.c +++ b/programs/x509/cert_write.c @@ -357,8 +357,12 @@ int main( int argc, char *argv[] ) { if( strcmp( q, "SHA1" ) == 0 ) opt.md = MBEDTLS_MD_SHA1; + else if( strcmp( q, "SHA224" ) == 0 ) + opt.md = MBEDTLS_MD_SHA224; else if( strcmp( q, "SHA256" ) == 0 ) opt.md = MBEDTLS_MD_SHA256; + else if( strcmp( q, "SHA384" ) == 0 ) + opt.md = MBEDTLS_MD_SHA384; else if( strcmp( q, "SHA512" ) == 0 ) opt.md = MBEDTLS_MD_SHA512; else if( strcmp( q, "MD2" ) == 0 )