feat(pki): log keybox attestation cert serials

Emit each loaded keybox's certificate-chain serials (lowercase hex) at
parse time. A revoked or leaked keybox is then visible from logcat
alone, since Google's CRL and Duck Detector's "mass abuse" check both
match by certificate serial.

Diagnostic aid for the revoked-keybox danger in #28; the actual fix is
rotating to a non-revoked keybox.
This commit is contained in:
Enginex0
2026-06-04 13:00:38 +01:00
parent 5c300ff47b
commit 37e9d007de
@@ -3,6 +3,7 @@ package org.matrix.TEESimulator.pki
import android.security.keystore.KeyProperties import android.security.keystore.KeyProperties
import java.io.File import java.io.File
import java.io.StringReader import java.io.StringReader
import java.security.cert.X509Certificate
import java.security.interfaces.ECPrivateKey import java.security.interfaces.ECPrivateKey
import java.security.interfaces.RSAPrivateKey import java.security.interfaces.RSAPrivateKey
import java.util.concurrent.ConcurrentHashMap import java.util.concurrent.ConcurrentHashMap
@@ -232,6 +233,15 @@ object KeyBoxManager {
eventType = parser.next() eventType = parser.next()
} }
SystemLogger.info("Finished parsing, found ${foundKeys.size} valid keys.") SystemLogger.info("Finished parsing, found ${foundKeys.size} valid keys.")
// Surface attestation cert serials so a revoked/leaked keybox is obvious from
// logcat alone -- Google's CRL and Duck's "mass abuse" check both match by serial.
foundKeys.forEach { (alg, keyBox) ->
val serials =
keyBox.certificates.joinToString(", ") { cert ->
(cert as? X509Certificate)?.serialNumber?.toString(16) ?: "?"
}
SystemLogger.info("$alg keybox attestation cert serials (hex): $serials")
}
return foundKeys return foundKeys
} }
} }