Bouncy Castle Cryptography Library 1.87

org.bouncycastle.asn1
Class ASN1TimeFormatTest

java.lang.Object
  extended byjunit.framework.Assert
      extended byjunit.framework.TestCase
          extended byorg.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 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 . The validator must reject all of them while still accepting the legal lenient forms BC is expected to read.


Constructor Summary
ASN1TimeFormatTest()
           
 
Method Summary
 void testDayAgainstMonthLength()
          A day the month does not have is not a date: the lenient Calendar behind getDate() rolls it into the next month, so the value read back is not the one the encoding names, and some other encoding already denotes it.
 void testDayAgainstMonthLengthCanBeSwitchedOff()
           
 void testInvalidGeneralizedTimeFieldRanges()
           
 void testInvalidGeneralizedTimeStructure()
           
 void testInvalidUTCTimeFieldRanges()
           
 void testInvalidUTCTimeStructure()
           
 void testRejectsReportedCorpusContent()
           
 void testValidGeneralizedTime()
           
 void testValidUTCTime()
           
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runBare, runTest, setName, setUp, tearDown, toString
 
Methods inherited from class junit.framework.Assert
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, fail, fail
 
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()

testDayAgainstMonthLength

public void testDayAgainstMonthLength()
A day the month does not have is not a date: the lenient Calendar behind getDate() rolls it into the next month, so the value read back is not the one the encoding names, and some other encoding already denotes it. OpenSSL refuses these; the JDK's CertificateFactory rolls them silently, which is what Properties.ASN1_ALLOW_NON_DER_TIME is there to let a caller follow.


testDayAgainstMonthLengthCanBeSwitchedOff

public void testDayAgainstMonthLengthCanBeSwitchedOff()

testRejectsReportedCorpusContent

public void testRejectsReportedCorpusContent()

Bouncy Castle Cryptography Library 1.87