Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/main/kotlin/testing/FakeCalendar.kt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ class FakeCalendar(val today: LocalDate = LocalDate.of(2024, 10, 20)) {

fun nextWeek(): Date = today.plusDays(7).toDate()

internal fun longAgo(): Date = today.minusYears(5).toDate()

internal fun farInTheFuture(): Date = today.plusYears(5).toDate()

private fun Instant.toDate() = Date.from(this)

private fun LocalDate.toDate() = this.atStartOfDay(ZoneId.of("UTC")).toInstant().toDate()
Expand Down
7 changes: 4 additions & 3 deletions src/main/kotlin/testing/KeyAttestationCertFactory.kt
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,16 @@ internal class KeyAttestationCertFactory(val fakeCalendar: FakeCalendar = FakeCa

internal fun generateRootCertificate(
keyPair: KeyPair = rootKey,
subject: X500Name = X500Name("SERIALNUMBER=badc0de"),
subject: X500Name = RKP_ROOT_SUBJECT,
) =
generateCertificate(
keyPair.public,
keyPair.private,
subject = subject,
issuer = subject,
serialNumber = BigInteger.valueOf(0xca11cafe),
notBefore = fakeCalendar.lastWeek(),
notAfter = fakeCalendar.nextWeek(),
notBefore = fakeCalendar.longAgo(),
notAfter = fakeCalendar.farInTheFuture(),
extensions = listOf(BASIC_CONSTRAINTS_EXT),
)

Expand Down Expand Up @@ -258,6 +258,7 @@ internal class KeyAttestationCertFactory(val fakeCalendar: FakeCalendar = FakeCa
)
val RKP_INTERMEDIATE_SUBJECT = X500Name("O=Google LLC, CN=Droid CA3")
val REMOTE_INTERMEDIATE_SUBJECT = X500Name("CN=Droid CA2, O=Google LLC")
val RKP_ROOT_SUBJECT = X500Name("CN=Test Key Attestation CA1, OU=Android, O=Google LLC, C=US")
}
}

Expand Down
Loading