fix(pki): log keybox serial on every fetch
The serial log added previously lived in parseKeysFromXml, which getAttestationKey runs only on a cache miss -- so it emitted at most once per boot and scrolled off the buffer before it could be read. Move it into getAttestationKey so the keybox attestation cert serials are logged on every fetch, on the live native cert-gen path. Verified on device: "Using RSA keybox keybox.xml; attestation cert serials (hex): ..." now prints on each forge.
This commit is contained in:
@@ -54,10 +54,21 @@ object KeyBoxManager {
|
|||||||
// If it's not in the cache, the `getOrPut` block is executed to parse and store it.
|
// If it's not in the cache, the `getOrPut` block is executed to parse and store it.
|
||||||
val keyMap =
|
val keyMap =
|
||||||
keyStoreCache.getOrPut(keyStoreFileName) { parseKeyStoreFile(keyStoreFileName) }
|
keyStoreCache.getOrPut(keyStoreFileName) { parseKeyStoreFile(keyStoreFileName) }
|
||||||
SystemLogger.verbose(
|
val keyBox = keyMap[algorithm]
|
||||||
"Fetching attestation key in $keyStoreFileName with $algorithm algorithm."
|
if (keyBox != null) {
|
||||||
)
|
// Surface attestation cert serials on every fetch so a revoked/leaked keybox is
|
||||||
return keyMap[algorithm]
|
// obvious from logcat alone -- Google's CRL and Duck's "mass abuse" check both match
|
||||||
|
// by certificate serial (lowercase hex). Logged here rather than at parse time because
|
||||||
|
// the parse is cached and would emit at most once per boot.
|
||||||
|
val serials =
|
||||||
|
keyBox.certificates.joinToString(", ") { cert ->
|
||||||
|
(cert as? X509Certificate)?.serialNumber?.toString(16) ?: "?"
|
||||||
|
}
|
||||||
|
SystemLogger.info(
|
||||||
|
"Using $algorithm keybox $keyStoreFileName; attestation cert serials (hex): $serials"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
return keyBox
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -233,15 +244,6 @@ 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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user