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
6 changes: 0 additions & 6 deletions renovate.json

This file was deleted.

6 changes: 1 addition & 5 deletions src/main/kotlin/Verifier.kt
Original file line number Diff line number Diff line change
Expand Up @@ -225,11 +225,7 @@ open class Verifier(
log: VerifyRequestLog? = null,
): VerificationResult {
log?.logInputChain(certPath.certificatesWithAnchor.map { it.getEncoded().toByteString() })
log?.logCertSerialNumbers(
certPath.certificatesWithAnchor.subList(1, certPath.certificatesWithAnchor.size).map {
it.serialNumber.toString(16)
}
)
log?.logCertSerialNumbers(certPath.serialNumbers())
val certPathValidator = CertPathValidator.getInstance("KeyAttestation")
val certPathParameters =
PKIXParameters(trustAnchorsSource()).apply {
Expand Down
9 changes: 9 additions & 0 deletions src/main/kotlin/provider/KeyAttestationCertPath.kt
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,15 @@ class KeyAttestationCertPath(certs: List<X509Certificate>) : CertPath("X.509") {

override fun getCertificates(): List<X509Certificate> = certificatesWithAnchor.dropLast(1)

/**
* Returns the serial numbers of the certificates in the certificate chain.
*
* The format is unpadded hex strings.
*
* @return the serial numbers of the certificates in the certificate chain.
*/
fun serialNumbers() = certificatesWithAnchor.map { it.serialNumber.toString(16) }

fun provisioningMethod() =
when {
isFactoryProvisioned() -> ProvisioningMethod.FACTORY_PROVISIONED
Expand Down
7 changes: 7 additions & 0 deletions src/test/kotlin/provider/KeyAttestationCertPathTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,13 @@ class KeyAttestationCertPathTest {
.isEqualTo(CertLists.validFactoryProvisioned.first())
}

@Test
fun getSerialNumbers_returnsExpectedSerialNumbers() {
assertThat(KeyAttestationCertPath(CertLists.validFactoryProvisioned).serialNumbers())
.containsExactly("1", "cafbad", "1234567890", "ca11cafe")
.inOrder()
}

@Test
fun provisioningMethod_returnsExpectedType(@TestParameter testCase: ProvisioningMethodTestCase) {
val certPath = readCertPath("${testCase.path}.pem")
Expand Down