Add unit tests for X509 certificate date parsing

This commit is contained in:
Janos Follath
2017-02-08 14:13:02 +00:00
committed by Simon Butcher
parent f3ebf909c9
commit ea7054a00c
2 changed files with 64 additions and 5 deletions

View File

@@ -613,16 +613,14 @@ void x509_get_time( int tag, char *time_str, int ret,
int hour, int min, int sec )
{
mbedtls_x509_time time;
unsigned char buf[17];
unsigned char buf[21];
unsigned char* start = buf;
unsigned char* end = buf;
memset( &time, 0x00, sizeof( time ) );
*end = (unsigned char)tag; end++;
if( tag == MBEDTLS_ASN1_UTC_TIME )
*end = 13;
else
*end = 15;
*end = strlen( time_str );
TEST_ASSERT( *end < 20 );
end++;
memcpy( end, time_str, (size_t)*(end - 1) );
end += *(end - 1);