fix(native-certgen): address production audit findings

Make logging init idempotent (swallow SetGlobalDefaultError on repeat
call), remove unused dumpLogs JNI params that violated the API contract,
and strip dead public_key_spki field + build_ec_spki() that were
computed on every keygen but never consumed by the cert builder.
This commit is contained in:
Enginex0
2026-03-09 18:16:50 +01:00
parent 6aba82edb1
commit f781f61f44
5 changed files with 5 additions and 80 deletions
@@ -50,7 +50,6 @@ data class CertGenConfig(
object NativeCertGen {
private const val LOG_DIR = "/data/adb/tricky_store/logs"
private const val BASE_DIR = "/data/adb/tricky_store"
@Volatile
var isAvailable: Boolean = false
@@ -71,9 +70,9 @@ object NativeCertGen {
private external fun initLogging(verbose: Boolean, logDir: String): Boolean
private external fun dumpLogs(logDir: String, baseDir: String): String?
private external fun dumpLogs(): String?
fun dump(): String? = if (isAvailable) dumpLogs(LOG_DIR, BASE_DIR) else null
fun dump(): String? = if (isAvailable) dumpLogs() else null
fun parseNativeResult(bytes: ByteArray): Pair<KeyPair, List<Certificate>> {
val buf = ByteBuffer.wrap(bytes).order(ByteOrder.BIG_ENDIAN)