mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-12-23 10:35:35 +00:00
Add unit tests for X509 certificate date parsing
This commit is contained in:
parent
f3ebf909c9
commit
ea7054a00c
|
@ -1574,3 +1574,64 @@ x509_get_time:MBEDTLS_ASN1_UTC_TIME:"001130236012Z":MBEDTLS_ERR_X509_INVALID_DAT
|
||||||
X509 Get time (UTC invalid sec)
|
X509 Get time (UTC invalid sec)
|
||||||
depends_on:MBEDTLS_X509_USE_C
|
depends_on:MBEDTLS_X509_USE_C
|
||||||
x509_get_time:MBEDTLS_ASN1_UTC_TIME:"001130235960Z":MBEDTLS_ERR_X509_INVALID_DATE:0:0:0:0:0:0
|
x509_get_time:MBEDTLS_ASN1_UTC_TIME:"001130235960Z":MBEDTLS_ERR_X509_INVALID_DATE:0:0:0:0:0:0
|
||||||
|
|
||||||
|
X509 Get time (UTC without time zone)
|
||||||
|
depends_on:MBEDTLS_X509_USE_C
|
||||||
|
x509_get_time:MBEDTLS_ASN1_UTC_TIME:"000229121212":0:2000:2:29:12:12:12
|
||||||
|
|
||||||
|
X509 Get time (UTC with invalid time zone #1)
|
||||||
|
depends_on:MBEDTLS_X509_USE_C
|
||||||
|
x509_get_time:MBEDTLS_ASN1_UTC_TIME:"000229121212J":MBEDTLS_ERR_X509_INVALID_DATE:0:0:0:0:0:0
|
||||||
|
|
||||||
|
X509 Get time (UTC with invalid time zone #2)
|
||||||
|
depends_on:MBEDTLS_X509_USE_C
|
||||||
|
x509_get_time:MBEDTLS_ASN1_UTC_TIME:"000229121212+0300":MBEDTLS_ERR_X509_INVALID_DATE:0:0:0:0:0:0
|
||||||
|
|
||||||
|
X509 Get time (Date with invalid tag)
|
||||||
|
depends_on:MBEDTLS_X509_USE_C
|
||||||
|
x509_get_time:MBEDTLS_ASN1_CONTEXT_SPECIFIC:"000229121212":MBEDTLS_ERR_X509_INVALID_DATE+MBEDTLS_ERR_ASN1_UNEXPECTED_TAG:0:0:0:0:0:0
|
||||||
|
|
||||||
|
X509 Get time (UTC, truncated)
|
||||||
|
depends_on:MBEDTLS_X509_USE_C
|
||||||
|
x509_get_time:MBEDTLS_ASN1_UTC_TIME:"000229121":MBEDTLS_ERR_X509_INVALID_DATE:0:0:0:0:0:0
|
||||||
|
|
||||||
|
X509 Get time (Generalized Time, truncated)
|
||||||
|
depends_on:MBEDTLS_X509_USE_C
|
||||||
|
x509_get_time:MBEDTLS_ASN1_GENERALIZED_TIME:"20000229121":MBEDTLS_ERR_X509_INVALID_DATE:0:0:0:0:0:0
|
||||||
|
|
||||||
|
X509 Get time (UTC without seconds)
|
||||||
|
depends_on:MBEDTLS_X509_USE_C
|
||||||
|
x509_get_time:MBEDTLS_ASN1_UTC_TIME:"0002291212":MBEDTLS_ERR_X509_INVALID_DATE:2000:2:29:12:12:0
|
||||||
|
|
||||||
|
X509 Get time (UTC without seconds and with invalid time zone #1)
|
||||||
|
depends_on:MBEDTLS_X509_USE_C
|
||||||
|
x509_get_time:MBEDTLS_ASN1_UTC_TIME:"0002291212J":MBEDTLS_ERR_X509_INVALID_DATE:0:0:0:0:0:0
|
||||||
|
|
||||||
|
X509 Get time (UTC without second and with invalid time zone #2)
|
||||||
|
depends_on:MBEDTLS_X509_USE_C
|
||||||
|
x509_get_time:MBEDTLS_ASN1_UTC_TIME:"0002291212+0300":MBEDTLS_ERR_X509_INVALID_DATE:0:0:0:0:0:0
|
||||||
|
|
||||||
|
X509 Get time (UTC invalid character in year)
|
||||||
|
depends_on:MBEDTLS_X509_USE_C
|
||||||
|
x509_get_time:MBEDTLS_ASN1_UTC_TIME:"0\1130231212Z":MBEDTLS_ERR_X509_INVALID_DATE:0:0:0:0:0:0
|
||||||
|
|
||||||
|
X509 Get time (UTC invalid character in month)
|
||||||
|
depends_on:MBEDTLS_X509_USE_C
|
||||||
|
x509_get_time:MBEDTLS_ASN1_UTC_TIME:"001%30231212Z":MBEDTLS_ERR_X509_INVALID_DATE:0:0:0:0:0:0
|
||||||
|
|
||||||
|
X509 Get time (UTC invalid character in day)
|
||||||
|
depends_on:MBEDTLS_X509_USE_C
|
||||||
|
x509_get_time:MBEDTLS_ASN1_UTC_TIME:"0011`0231212Z":MBEDTLS_ERR_X509_INVALID_DATE:0:0:0:0:0:0
|
||||||
|
|
||||||
|
X509 Get time (UTC invalid character in hour)
|
||||||
|
depends_on:MBEDTLS_X509_USE_C
|
||||||
|
x509_get_time:MBEDTLS_ASN1_UTC_TIME:"0011302h1212Z":MBEDTLS_ERR_X509_INVALID_DATE:0:0:0:0:0:0
|
||||||
|
|
||||||
|
X509 Get time (UTC invalid character in min)
|
||||||
|
depends_on:MBEDTLS_X509_USE_C
|
||||||
|
x509_get_time:MBEDTLS_ASN1_UTC_TIME:"00113023u012Z":MBEDTLS_ERR_X509_INVALID_DATE:0:0:0:0:0:0
|
||||||
|
|
||||||
|
X509 Get time (UTC invalid character in sec)
|
||||||
|
depends_on:MBEDTLS_X509_USE_C
|
||||||
|
x509_get_time:MBEDTLS_ASN1_UTC_TIME:"0011302359n0Z":MBEDTLS_ERR_X509_INVALID_DATE:0:0:0:0:0:0
|
||||||
|
|
||||||
|
|
|
@ -613,16 +613,14 @@ void x509_get_time( int tag, char *time_str, int ret,
|
||||||
int hour, int min, int sec )
|
int hour, int min, int sec )
|
||||||
{
|
{
|
||||||
mbedtls_x509_time time;
|
mbedtls_x509_time time;
|
||||||
unsigned char buf[17];
|
unsigned char buf[21];
|
||||||
unsigned char* start = buf;
|
unsigned char* start = buf;
|
||||||
unsigned char* end = buf;
|
unsigned char* end = buf;
|
||||||
|
|
||||||
memset( &time, 0x00, sizeof( time ) );
|
memset( &time, 0x00, sizeof( time ) );
|
||||||
*end = (unsigned char)tag; end++;
|
*end = (unsigned char)tag; end++;
|
||||||
if( tag == MBEDTLS_ASN1_UTC_TIME )
|
*end = strlen( time_str );
|
||||||
*end = 13;
|
TEST_ASSERT( *end < 20 );
|
||||||
else
|
|
||||||
*end = 15;
|
|
||||||
end++;
|
end++;
|
||||||
memcpy( end, time_str, (size_t)*(end - 1) );
|
memcpy( end, time_str, (size_t)*(end - 1) );
|
||||||
end += *(end - 1);
|
end += *(end - 1);
|
||||||
|
|
Loading…
Reference in a new issue