From b2f9b144a62e0ef40eff6baf0ec64c3286f0a8dc Mon Sep 17 00:00:00 2001 From: Bob Beck Date: Wed, 8 Oct 2025 07:46:33 -0600 Subject: [PATCH] asn1_time_test.c: More asn1 to utc testcases Test out of bounds month, day of month, hour, minute and seconds. Ensure we check the leap year boundaries. Reviewed-by: Matt Caswell Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/28789) --- test/asn1_time_test.c | 50 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/test/asn1_time_test.c b/test/asn1_time_test.c index 7b1b3700bc8..f39f690231b 100644 --- a/test/asn1_time_test.c +++ b/test/asn1_time_test.c @@ -68,6 +68,56 @@ static const struct TESTDATA_asn1_to_utc asn1_to_utc[] = { "20210328030000+0200", 1616893200, }, + { + /* test seconds out of bound */ + "210328005960Z", + -1, + }, + { + /* test minutes out of bound */ + "210328006059Z", + -1, + }, + { + /* test hours out of bound */ + "210328255959Z", + -1, + }, + { + /* test days out of bound */ + "210332005959Z", + -1, + }, + { + /* test days out of bound */ + "210230005959Z", + -1, + }, + { + /* test days out of bound (non leap year)*/ + "210229005959Z", + -1, + }, + { + /* test days not out of bound (non leap year) */ + "210228005959Z", + 1614473999, + }, + { + /* test days not out of bound (leap year)*/ + "200229005959Z", + 1582937999, + }, + { + /* test days out of bound (leap year)*/ + "200230005959Z", + -1 + }, + { + /* test month out of bound */ + "211328005960Z", + -1, + }, { /* * Invalid strings should get -1 as a result -- 2.47.3