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

Commit d9491b04 authored by Eric Biggers's avatar Eric Biggers Committed by Gerrit Code Review
Browse files

Merge "Simplify some code in KeyStore2ParameterUtils#addUserAuthArgs" into main

parents cc62ebc1 fdbe53a5
Loading
Loading
Loading
Loading
+13 −20
Original line number Original line Diff line number Diff line
@@ -324,29 +324,23 @@ public abstract class KeyStore2ParameterUtils {
        if (!spec.isUserAuthenticationRequired()) {
        if (!spec.isUserAuthenticationRequired()) {
            args.add(KeyStore2ParameterUtils.makeBool(
            args.add(KeyStore2ParameterUtils.makeBool(
                    KeymasterDefs.KM_TAG_NO_AUTH_REQUIRED));
                    KeymasterDefs.KM_TAG_NO_AUTH_REQUIRED));
        } else {
            if (spec.getUserAuthenticationValidityDurationSeconds() == 0) {
                // Every use of this key needs to be authorized by the user.
                addSids(args, spec);
                args.add(KeyStore2ParameterUtils.makeEnum(
                        KeymasterDefs.KM_TAG_USER_AUTH_TYPE, spec.getUserAuthenticationType()
                ));

                if (spec.isUserAuthenticationValidWhileOnBody()) {
                    throw new ProviderException(
                            "Key validity extension while device is on-body is not "
                                    + "supported for keys requiring fingerprint authentication");
                }
        } else {
        } else {
            addSids(args, spec);
            addSids(args, spec);
            args.add(KeyStore2ParameterUtils.makeEnum(
            args.add(KeyStore2ParameterUtils.makeEnum(
                    KeymasterDefs.KM_TAG_USER_AUTH_TYPE, spec.getUserAuthenticationType()
                    KeymasterDefs.KM_TAG_USER_AUTH_TYPE, spec.getUserAuthenticationType()
            ));
            ));
            if (spec.getUserAuthenticationValidityDurationSeconds() != 0) {
                args.add(KeyStore2ParameterUtils.makeInt(
                args.add(KeyStore2ParameterUtils.makeInt(
                        KeymasterDefs.KM_TAG_AUTH_TIMEOUT,
                        KeymasterDefs.KM_TAG_AUTH_TIMEOUT,
                        spec.getUserAuthenticationValidityDurationSeconds()
                        spec.getUserAuthenticationValidityDurationSeconds()
                ));
                ));
            }
            if (spec.isUserAuthenticationValidWhileOnBody()) {
            if (spec.isUserAuthenticationValidWhileOnBody()) {
                if (spec.getUserAuthenticationValidityDurationSeconds() == 0) {
                    throw new ProviderException(
                            "Key validity extension while device is on-body is not "
                                    + "supported for keys requiring fingerprint authentication");
                }
                args.add(KeyStore2ParameterUtils.makeBool(
                args.add(KeyStore2ParameterUtils.makeBool(
                        KeymasterDefs.KM_TAG_ALLOW_WHILE_ON_BODY
                        KeymasterDefs.KM_TAG_ALLOW_WHILE_ON_BODY
                ));
                ));
@@ -354,4 +348,3 @@ public abstract class KeyStore2ParameterUtils {
        }
        }
    }
    }
}
}
}