]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
asn1_time_test.c: More asn1 to utc testcases
authorBob Beck <beck@openssl.org>
Wed, 8 Oct 2025 13:46:33 +0000 (07:46 -0600)
committerTomas Mraz <tomas@openssl.org>
Tue, 14 Oct 2025 15:48:33 +0000 (17:48 +0200)
Test out of bounds month, day of month, hour, minute and seconds.
Ensure we check the leap year boundaries.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/28789)

test/asn1_time_test.c

index 7b1b3700bc875d5ee56b4c19c593f3292c7957f9..f39f690231b12a7d00514eb1c3dae036307dd49b 100644 (file)
@@ -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