Merge "Add BlockMode.GCM constant to AndroidKeyStore API."

This commit is contained in:
Alex Klyubin
2015-04-08 17:51:12 +00:00
committed by Gerrit Code Review

View File

@@ -471,7 +471,7 @@ public abstract class KeyStoreKeyConstraints {
@Retention(RetentionPolicy.SOURCE) @Retention(RetentionPolicy.SOURCE)
@IntDef(flag = true, @IntDef(flag = true,
value = {BlockMode.ECB, BlockMode.CBC, BlockMode.CTR}) value = {BlockMode.ECB, BlockMode.CBC, BlockMode.CTR, BlockMode.GCM})
public @interface BlockModeEnum {} public @interface BlockModeEnum {}
/** /**
@@ -489,6 +489,9 @@ public abstract class KeyStoreKeyConstraints {
/** Counter (CTR) block mode. */ /** Counter (CTR) block mode. */
public static final int CTR = 1 << 2; public static final int CTR = 1 << 2;
/** Galois/Counter Mode (GCM) block mode. */
public static final int GCM = 1 << 3;
/** /**
* @hide * @hide
*/ */
@@ -500,6 +503,8 @@ public abstract class KeyStoreKeyConstraints {
return KeymasterDefs.KM_MODE_CBC; return KeymasterDefs.KM_MODE_CBC;
case CTR: case CTR:
return KeymasterDefs.KM_MODE_CTR; return KeymasterDefs.KM_MODE_CTR;
case GCM:
return KeymasterDefs.KM_MODE_GCM;
default: default:
throw new IllegalArgumentException("Unknown block mode: " + mode); throw new IllegalArgumentException("Unknown block mode: " + mode);
} }
@@ -516,6 +521,8 @@ public abstract class KeyStoreKeyConstraints {
return CBC; return CBC;
case KeymasterDefs.KM_MODE_CTR: case KeymasterDefs.KM_MODE_CTR:
return CTR; return CTR;
case KeymasterDefs.KM_MODE_GCM:
return GCM;
default: default:
throw new IllegalArgumentException("Unknown block mode: " + mode); throw new IllegalArgumentException("Unknown block mode: " + mode);
} }
@@ -554,6 +561,8 @@ public abstract class KeyStoreKeyConstraints {
return "CBC"; return "CBC";
case CTR: case CTR:
return "CTR"; return "CTR";
case GCM:
return "GCM";
default: default:
throw new IllegalArgumentException("Unknown block mode: " + mode); throw new IllegalArgumentException("Unknown block mode: " + mode);
} }
@@ -570,6 +579,8 @@ public abstract class KeyStoreKeyConstraints {
return CBC; return CBC;
} else if ("ctr".equals(modeLower)) { } else if ("ctr".equals(modeLower)) {
return CTR; return CTR;
} else if ("gcm".equals(modeLower)) {
return CTR;
} else { } else {
throw new IllegalArgumentException("Unknown block mode: " + mode); throw new IllegalArgumentException("Unknown block mode: " + mode);
} }