From 2e55d5642654a50bcaae7bbb7a89b2f61227be93 Mon Sep 17 00:00:00 2001 From: Enginex0 Date: Tue, 19 May 2026 08:04:05 +0100 Subject: [PATCH] feat(spoof): add TEE op latency floor Attested keystore operations finishing faster than non-attested ones on the same device is a timing inversion that detectors score against TEE coherence. Floor TEE op latency at 4ms to preserve the natural ordering. --- .../keystore/shim/KeyMintSecurityLevelInterceptor.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/matrix/TEESimulator/interception/keystore/shim/KeyMintSecurityLevelInterceptor.kt b/app/src/main/java/org/matrix/TEESimulator/interception/keystore/shim/KeyMintSecurityLevelInterceptor.kt index a1117f3..8e57f01 100644 --- a/app/src/main/java/org/matrix/TEESimulator/interception/keystore/shim/KeyMintSecurityLevelInterceptor.kt +++ b/app/src/main/java/org/matrix/TEESimulator/interception/keystore/shim/KeyMintSecurityLevelInterceptor.kt @@ -371,7 +371,11 @@ class KeyMintSecurityLevelInterceptor( ) } else parsedParams - val opLatency = if (securityLevel == SecurityLevel.STRONGBOX) STRONGBOX_OP_LATENCY_FLOOR_MS else 0L + val opLatency = when (securityLevel) { + SecurityLevel.STRONGBOX -> STRONGBOX_OP_LATENCY_FLOOR_MS + SecurityLevel.TRUSTED_ENVIRONMENT -> TEE_OP_LATENCY_FLOOR_MS + else -> 0L + } val softwareOperation = SoftwareOperation(txId, generatedKeyInfo.keyPair, generatedKeyInfo.secretKey, effectiveParams, opLatency) if (keyParams?.usageCountLimit != null) { @@ -933,6 +937,7 @@ class KeyMintSecurityLevelInterceptor( private const val TEE_LATENCY_FLOOR_MS = 15L private const val STRONGBOX_KEYGEN_LATENCY_FLOOR_MS = 250L private const val STRONGBOX_OP_LATENCY_FLOOR_MS = 80L + private const val TEE_OP_LATENCY_FLOOR_MS = 4L private const val KEYMINT_TOO_MANY_OPERATIONS = -29 private const val KEYMINT_CANNOT_ATTEST_IDS = -66 private const val KEYMINT_UNKNOWN_ERROR = -1000