Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit f7bb9128 authored by Marvin W.'s avatar Marvin W. 🐿️
Browse files

Fido: Do not send default values to the security key

parent f4c9ecf1
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@
package com.google.android.gms.fido.fido2.api.common;

import org.microg.gms.common.PublicApi;
import org.microg.gms.utils.ToStringHelper;
import org.microg.safeparcel.AutoSafeParcelable;

import java.util.Arrays;
@@ -58,11 +59,11 @@ public class AuthenticationExtensions extends AutoSafeParcelable {

    @Override
    public String toString() {
        return "AuthenticationExtensions{" +
                "fidoAppIdExtension=" + fidoAppIdExtension +
                ", cableAuthenticationExtension=" + cableAuthenticationExtension +
                ", userVerificationMethodExtension=" + userVerificationMethodExtension +
                '}';
        return ToStringHelper.name("AuthenticationExtensions")
                .field("fidoAppIdExtension", fidoAppIdExtension != null ? fidoAppIdExtension.getAppId() : null)
                .field("cableAuthenticationExtension", cableAuthenticationExtension)
                .field("userVerificationMethodExtension", userVerificationMethodExtension != null ? userVerificationMethodExtension.getUvm() : null)
                .end();
    }

    /**
+5 −4
Original line number Diff line number Diff line
@@ -45,12 +45,13 @@ class AuthenticatorGetAssertionRequest(

    companion object {
        class Options(
            val userPresence: Boolean? = true,
            val userVerification: Boolean? = false
            val userPresence: Boolean = true,
            val userVerification: Boolean = false
        ) {
            fun encodeAsCbor(): CBORObject = CBORObject.NewMap().apply {
                if (userPresence != null) set("up", userPresence.encodeAsCbor())
                if (userVerification != null) set("uv", userVerification.encodeAsCbor())
                // Only encode non-default values
                if (!userPresence) set("up", userPresence.encodeAsCbor())
                if (userVerification) set("uv", userVerification.encodeAsCbor())
            }
        }
    }
+5 −4
Original line number Diff line number Diff line
@@ -49,12 +49,13 @@ class AuthenticatorMakeCredentialRequest(

    companion object {
        class Options(
            val residentKey: Boolean? = false,
            val userVerification: Boolean? = false
            val residentKey: Boolean = false,
            val userVerification: Boolean = false
        ) {
            fun encodeAsCbor() = CBORObject.NewMap().apply {
                if (residentKey != null) set("rk", residentKey.encodeAsCbor())
                if (userVerification != null) set("uv", userVerification.encodeAsCbor())
                // Only encode non-default values
                if (residentKey) set("rk", residentKey.encodeAsCbor())
                if (userVerification) set("uv", userVerification.encodeAsCbor())
            }
        }
    }
+4 −3
Original line number Diff line number Diff line
@@ -49,8 +49,9 @@ abstract class TransportHandler(val transport: Transport, val callback: Transpor
        clientDataHash: ByteArray
    ): Pair<AuthenticatorMakeCredentialResponse, ByteArray?> {
        val reqOptions = AuthenticatorMakeCredentialRequest.Companion.Options(
            options.registerOptions.authenticatorSelection?.requireResidentKey,
            options.registerOptions.authenticatorSelection?.requireUserVerification?.let { it == UserVerificationRequirement.REQUIRED })
            options.registerOptions.authenticatorSelection?.requireResidentKey == true,
            options.registerOptions.authenticatorSelection?.requireUserVerification == UserVerificationRequirement.REQUIRED
        )
        val extensions = mutableMapOf<String, CBORObject>()
        if (options.authenticationExtensions?.fidoAppIdExtension?.appId != null) {
            extensions["appidExclude"] =
@@ -163,7 +164,7 @@ abstract class TransportHandler(val transport: Transport, val callback: Transpor
        clientDataHash: ByteArray
    ): Pair<AuthenticatorGetAssertionResponse, ByteArray?> {
        val reqOptions = AuthenticatorGetAssertionRequest.Companion.Options(
            userVerification = options.signOptions.requireUserVerification?.let { it == UserVerificationRequirement.REQUIRED }
            userVerification = options.signOptions.requireUserVerification == UserVerificationRequirement.REQUIRED
        )
        val extensions = mutableMapOf<String, CBORObject>()
        if (options.authenticationExtensions?.fidoAppIdExtension?.appId != null) {