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

Commit 45d27836 authored by Alex Klyubin's avatar Alex Klyubin
Browse files

Add Keymaster KM_ORIGIN_UNKNOWN constant.

This tracks d359b044830b292f492f8a8df5471f869e358399 from
hardware/libhardware.

Bug: 18088752
Change-Id: I9a7bd8bdee51c18ae0427eff4efe036213d2b175
parent 8704ae46
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -118,9 +118,9 @@ public final class KeymasterDefs {
    public static final int KM_DIGEST_SHA_2_512 = 6;
    public static final int KM_DIGEST_SHA_2_512 = 6;


    // Key origins.
    // Key origins.
    public static final int KM_ORIGIN_HARDWARE = 0;
    public static final int KM_ORIGIN_GENERATED = 0;
    public static final int KM_ORIGIN_SOFTWARE = 1;
    public static final int KM_ORIGIN_IMPORTED = 2;
    public static final int KM_ORIGIN_IMPORTED = 2;
    public static final int KM_ORIGIN_UNKNOWN = 3;


    // Key usability requirements.
    // Key usability requirements.
    public static final int KM_BLOB_STANDALONE = 0;
    public static final int KM_BLOB_STANDALONE = 0;
+11 −1
Original line number Original line Diff line number Diff line
@@ -225,15 +225,25 @@ public abstract class KeyStoreKeyProperties {
        /** Key was imported into AndroidKeyStore. */
        /** Key was imported into AndroidKeyStore. */
        public static final int IMPORTED = 1 << 1;
        public static final int IMPORTED = 1 << 1;


        /**
         * Origin of the key is unknown. This can occur only for keys backed by an old TEE
         * implementation which does not record origin information.
         *
         * @hide
         */
        public static final int UNKNOWN = 1 << 2;

        /**
        /**
         * @hide
         * @hide
         */
         */
        public static @OriginEnum int fromKeymaster(int origin) {
        public static @OriginEnum int fromKeymaster(int origin) {
            switch (origin) {
            switch (origin) {
                case KeymasterDefs.KM_ORIGIN_HARDWARE:
                case KeymasterDefs.KM_ORIGIN_GENERATED:
                    return GENERATED;
                    return GENERATED;
                case KeymasterDefs.KM_ORIGIN_IMPORTED:
                case KeymasterDefs.KM_ORIGIN_IMPORTED:
                    return IMPORTED;
                    return IMPORTED;
                case KeymasterDefs.KM_ORIGIN_UNKNOWN:
                    return UNKNOWN;
                default:
                default:
                    throw new IllegalArgumentException("Unknown origin: " + origin);
                    throw new IllegalArgumentException("Unknown origin: " + origin);
            }
            }