ASN1TimeFormatTest (Bouncy Castle Library 1.85 API Specification)
Date: 2026-07-12

org.bouncycastle.asn1

## Class ASN1TimeFormatTest

- java.lang.Object
- - junit.framework.Assert
  - - junit.framework.TestCase
    - - org.bouncycastle.asn1.ASN1TimeFormatTest

- All Implemented Interfaces:
    junit.framework.Test

      public class ASN1TimeFormatTest
      extends junit.framework.TestCase

  White-box tests for `ASN1TimeFormat`, the strict structural validator for UTCTime / GeneralizedTime content. Lives in `org.bouncycastle.asn1` to reach the package-private helper.

  The "currently accepted but bogus" cases use the exact content bytes from the fuzzing report (github ASN.1 TIME parsing): values BC parses today and either turns into a nonsensical Date or fails on `getDate()`. The validator must reject all of them while still accepting the legal lenient forms BC is expected to read.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ASN1TimeFormatTest()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `testInvalidGeneralizedTimeFieldRanges()`
    `void` | `testInvalidGeneralizedTimeStructure()`
    `void` | `testInvalidUTCTimeFieldRanges()`
    `void` | `testInvalidUTCTimeStructure()`
    `void` | `testRejectsReportedCorpusContent()` Exact content octets (tag/length stripped) of inputs from the fuzzing report that BC parses today; every one must now be rejected.
    `void` | `testValidGeneralizedTime()`
    `void` | `testValidUTCTime()`

    - ### Methods inherited from class junit.framework.TestCase

      `assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, countTestCases, createResult, fail, fail, failNotEquals, failNotSame, failSame, format, getName, run, run, runBare, runTest, setName, setUp, tearDown, toString`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### ASN1TimeFormatTest

          public ASN1TimeFormatTest()

  - ### Method Detail

    - #### testValidUTCTime

          public void testValidUTCTime()

    - #### testInvalidUTCTimeFieldRanges

          public void testInvalidUTCTimeFieldRanges()

    - #### testInvalidUTCTimeStructure

          public void testInvalidUTCTimeStructure()

    - #### testValidGeneralizedTime

          public void testValidGeneralizedTime()

    - #### testInvalidGeneralizedTimeFieldRanges

          public void testInvalidGeneralizedTimeFieldRanges()

    - #### testInvalidGeneralizedTimeStructure

          public void testInvalidGeneralizedTimeStructure()

    - #### testRejectsReportedCorpusContent

          public void testRejectsReportedCorpusContent()

      Exact content octets (tag/length stripped) of inputs from the fuzzing report that BC parses today; every one must now be rejected.