summary refs log tree commit diff
diff options
context:
space:
mode:
authorAlexander Scheel <alexander.scheel@keyfactor.com>2024-02-07 08:55:36 -0500
committerAlexander Scheel <alexander.scheel@keyfactor.com>2024-02-07 08:55:36 -0500
commitccc26e01498df5f05c173e66e562557b1f4e899b (patch)
tree14362ccb41b478b864a98e16a6c996b823205b0e
parentMerge branch 'release/v2.3' (diff)
downloadBouncyCastle.NET-ed25519-ccc26e01498df5f05c173e66e562557b1f4e899b.tar.xz
Test invalid DerGeneralizedTime with explicit zone
Signed-off-by: Alexander Scheel <alexander.scheel@keyfactor.com>
-rw-r--r--crypto/test/src/asn1/test/GeneralizedTimeTest.cs13
1 files changed, 12 insertions, 1 deletions
diff --git a/crypto/test/src/asn1/test/GeneralizedTimeTest.cs b/crypto/test/src/asn1/test/GeneralizedTimeTest.cs
index c1d6b27ca..9d051051e 100644
--- a/crypto/test/src/asn1/test/GeneralizedTimeTest.cs
+++ b/crypto/test/src/asn1/test/GeneralizedTimeTest.cs
@@ -155,6 +155,7 @@ namespace Org.BouncyCastle.Asn1.Tests
                 IsTrue(Arrays.AreEqual(Hex.Decode("180f32303232303830393132313530305a"), der.GetEncoded(Asn1Encodable.DL)));
                 IsTrue(Arrays.AreEqual(Hex.Decode("180f32303232303830393132313530305a"), der.GetEncoded(Asn1Encodable.Ber)));
                 IsTrue(Arrays.AreEqual(Hex.Decode("180f32303232303830393132313530305a"), der.GetEncoded(Asn1Encodable.Der)));
+
             }
 
             try
@@ -187,6 +188,16 @@ namespace Org.BouncyCastle.Asn1.Tests
                     Fail("failed UTC conversion test");
                 }
             }
+
+            try
+            {
+                // Ensure no stack overflow, only parse format.
+                DerGeneralizedTime shouldFail = new DerGeneralizedTime("20160601140601GMT-04:00");
+            }
+            catch (ArgumentException e)
+            {
+                IsTrue(e.Message.Contains("invalid format"));
+            }
         }
 
         [Test]
@@ -194,7 +205,7 @@ namespace Org.BouncyCastle.Asn1.Tests
         {
             string resultText = Perform().ToString();
 
-            Assert.AreEqual(Name + ": Okay", resultText);
+            Assert.AreEqual(Name + ": Okay", resultText, resultText);
         }
     }
 }