diff options
author | Alex Klyubin <klyubin@google.com> | 2015-04-13 17:31:40 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2015-04-13 17:31:40 +0000 |
commit | a978a3d6e9586af8cc7191cde83dcf2742ea5269 (patch) | |
tree | 174ba1879cc96cc8fa3ae58353af5b5fe85e59d0 /core | |
parent | 110919d9952a60eb9a2ff1696f3e13818428ee6a (diff) | |
parent | f265bdbfc70411c08b4aa7d17125cf1b5e9b14e8 (diff) | |
download | frameworks_base-a978a3d6e9586af8cc7191cde83dcf2742ea5269.zip frameworks_base-a978a3d6e9586af8cc7191cde83dcf2742ea5269.tar.gz frameworks_base-a978a3d6e9586af8cc7191cde83dcf2742ea5269.tar.bz2 |
am f265bdbf: am d1af38a4: Merge "Use JCA names for block modes, paddings, and digests."
* commit 'f265bdbfc70411c08b4aa7d17125cf1b5e9b14e8':
Use JCA names for block modes, paddings, and digests.
Diffstat (limited to 'core')
-rw-r--r-- | core/java/android/security/keymaster/KeyCharacteristics.java | 53 | ||||
-rw-r--r-- | core/java/android/security/keymaster/KeymasterArguments.java | 9 |
2 files changed, 62 insertions, 0 deletions
diff --git a/core/java/android/security/keymaster/KeyCharacteristics.java b/core/java/android/security/keymaster/KeyCharacteristics.java index b803a1b..b3a3aad 100644 --- a/core/java/android/security/keymaster/KeyCharacteristics.java +++ b/core/java/android/security/keymaster/KeyCharacteristics.java @@ -19,6 +19,8 @@ package android.security.keymaster; import android.os.Parcel; import android.os.Parcelable; +import java.util.ArrayList; +import java.util.Date; import java.util.List; /** @@ -30,10 +32,12 @@ public class KeyCharacteristics implements Parcelable { public static final Parcelable.Creator<KeyCharacteristics> CREATOR = new Parcelable.Creator<KeyCharacteristics>() { + @Override public KeyCharacteristics createFromParcel(Parcel in) { return new KeyCharacteristics(in); } + @Override public KeyCharacteristics[] newArray(int length) { return new KeyCharacteristics[length]; } @@ -50,6 +54,7 @@ public class KeyCharacteristics implements Parcelable { return 0; } + @Override public void writeToParcel(Parcel out, int flags) { swEnforced.writeToParcel(out, flags); hwEnforced.writeToParcel(out, flags); @@ -59,5 +64,53 @@ public class KeyCharacteristics implements Parcelable { swEnforced = KeymasterArguments.CREATOR.createFromParcel(in); hwEnforced = KeymasterArguments.CREATOR.createFromParcel(in); } + + public Integer getInteger(int tag) { + if (hwEnforced.containsTag(tag)) { + return hwEnforced.getInt(tag, -1); + } else if (swEnforced.containsTag(tag)) { + return swEnforced.getInt(tag, -1); + } else { + return null; + } + } + + public int getInt(int tag, int defaultValue) { + Integer result = getInteger(tag); + return (result != null) ? result : defaultValue; + } + + public List<Integer> getInts(int tag) { + List<Integer> result = new ArrayList<Integer>(); + result.addAll(hwEnforced.getInts(tag)); + result.addAll(swEnforced.getInts(tag)); + return result; + } + + public Date getDate(int tag) { + Date result = hwEnforced.getDate(tag, null); + if (result == null) { + result = swEnforced.getDate(tag, null); + } + return result; + } + + public Date getDate(int tag, Date defaultValue) { + if (hwEnforced.containsTag(tag)) { + return hwEnforced.getDate(tag, null); + } else if (hwEnforced.containsTag(tag)) { + return swEnforced.getDate(tag, null); + } else { + return defaultValue; + } + } + + public boolean getBoolean(KeyCharacteristics keyCharacteristics, int tag) { + if (keyCharacteristics.hwEnforced.containsTag(tag)) { + return keyCharacteristics.hwEnforced.getBoolean(tag, false); + } else { + return keyCharacteristics.swEnforced.getBoolean(tag, false); + } + } } diff --git a/core/java/android/security/keymaster/KeymasterArguments.java b/core/java/android/security/keymaster/KeymasterArguments.java index b5fd4bd..8ed288c 100644 --- a/core/java/android/security/keymaster/KeymasterArguments.java +++ b/core/java/android/security/keymaster/KeymasterArguments.java @@ -34,9 +34,12 @@ public class KeymasterArguments implements Parcelable { public static final Parcelable.Creator<KeymasterArguments> CREATOR = new Parcelable.Creator<KeymasterArguments>() { + @Override public KeymasterArguments createFromParcel(Parcel in) { return new KeymasterArguments(in); } + + @Override public KeymasterArguments[] newArray(int size) { return new KeymasterArguments[size]; } @@ -54,6 +57,12 @@ public class KeymasterArguments implements Parcelable { mArguments.add(new KeymasterIntArgument(tag, value)); } + public void addInts(int tag, int... values) { + for (int value : values) { + addInt(tag, value); + } + } + public void addBoolean(int tag) { mArguments.add(new KeymasterBooleanArgument(tag)); } |