android updates

This commit is contained in:
Adam Velebil 2024-08-13 15:54:03 +02:00
parent ba85a257d4
commit cf6a57be2e
No known key found for this signature in database
GPG Key ID: C9B1E4A3CBBD2E10
3 changed files with 40 additions and 38 deletions

View File

@ -27,7 +27,7 @@ enum class FidoActionDescription(private val value: Int) {
RenameFingerprint(5),
RegisterFingerprint(6),
EnableEnterpriseAttestation(7),
ActionFailure(7);
ActionFailure(8);
val id: Int
get() = value + dialogDescriptionFidoIndex

View File

@ -252,11 +252,6 @@ class FidoManager(
ClientPin.PIN_PERMISSION_BE else 0
}
private fun getPinPermissionsACFG(fidoSession: YubiKitFidoSession): Int {
return if(Config.isSupported(fidoSession.cachedInfo))
ClientPin.PIN_PERMISSION_ACFG else 0
}
private fun unlockSession(
fidoSession: YubiKitFidoSession,
clientPin: ClientPin,
@ -613,41 +608,44 @@ class FidoManager(
private suspend fun enableEnterpriseAttestation(): String =
connectionHelper.useSession(FidoActionDescription.EnableEnterpriseAttestation) { fidoSession ->
val uvAuthProtocol = getPreferredPinUvAuthProtocol(fidoSession.cachedInfo)
val clientPin = ClientPin(fidoSession, uvAuthProtocol)
val token = if (pinStore.hasPin()) {
clientPin.getPinToken(
pinStore.getPin(),
getPinPermissionsACFG(fidoSession),
null
)
} else null
val config = Config(fidoSession, uvAuthProtocol, token)
try {
config.enableEnterpriseAttestation()
fidoViewModel.setSessionState(
Session(
fidoSession.info,
pinStore.hasPin(),
pinRetries
if (Config.isSupported(fidoSession.cachedInfo)) {
val uvAuthProtocol = getPreferredPinUvAuthProtocol(fidoSession.cachedInfo)
val clientPin = ClientPin(fidoSession, uvAuthProtocol)
val token = if (pinStore.hasPin()) {
clientPin.getPinToken(
pinStore.getPin(),
ClientPin.PIN_PERMISSION_ACFG,
null
)
)
return@useSession JSONObject(
mapOf(
"success" to true,
)
).toString()
} else null
val config = Config(fidoSession, uvAuthProtocol, token)
} catch (e: Exception) {
logger.error("Failed to enable enterprise attestation. ", e)
return@useSession JSONObject(
mapOf(
"success" to false,
try {
config.enableEnterpriseAttestation()
fidoViewModel.setSessionState(
Session(
fidoSession.info,
pinStore.hasPin(),
pinRetries
)
)
).toString()
} catch (e: Exception) {
logger.error("Failed to enable enterprise attestation. ", e)
return@useSession JSONObject(
mapOf(
"success" to false,
)
).toString()
}
} else {
logger.debug("authenticatorConfig not supported, ignoring call to enableEnterpriseAttestation")
}
return@useSession JSONObject(
mapOf(
"success" to true,
)
).toString()
}
override fun onDisconnected() {

View File

@ -80,6 +80,8 @@ enum _DDesc {
fidoDeleteCredential,
fidoDeleteFingerprint,
fidoRenameFingerprint,
fidoRegisterFingerprint,
fidoEnableEnterpriseAttestation,
fidoActionFailure,
// Others
invalid;
@ -105,7 +107,9 @@ enum _DDesc {
dialogDescriptionFidoIndex + 3: fidoDeleteCredential,
dialogDescriptionFidoIndex + 4: fidoDeleteFingerprint,
dialogDescriptionFidoIndex + 5: fidoRenameFingerprint,
dialogDescriptionFidoIndex + 6: fidoActionFailure,
dialogDescriptionFidoIndex + 6: fidoRegisterFingerprint,
dialogDescriptionFidoIndex + 7: fidoEnableEnterpriseAttestation,
dialogDescriptionFidoIndex + 8: fidoActionFailure,
}[id] ??
_DDesc.invalid;
}