summaryrefslogtreecommitdiffstats
path: root/keystore/java/android/security/AndroidKeyStore.java
diff options
context:
space:
mode:
authorAlex Klyubin <klyubin@google.com>2015-03-30 21:01:39 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2015-03-30 21:01:39 +0000
commit8a78286915a8f71eb09b5ae29a3bd8fb977180e6 (patch)
tree07dcf960329d6680697a96aa9094ab0174387687 /keystore/java/android/security/AndroidKeyStore.java
parentdc0078b7947e0b035dce6c61108a48a276b11034 (diff)
parent7ca65f09013e807b6df61b2ba3e650a09ceff432 (diff)
downloadframeworks_base-8a78286915a8f71eb09b5ae29a3bd8fb977180e6.zip
frameworks_base-8a78286915a8f71eb09b5ae29a3bd8fb977180e6.tar.gz
frameworks_base-8a78286915a8f71eb09b5ae29a3bd8fb977180e6.tar.bz2
am 7ca65f09: am b000d129: am 6a6f0c7d: Merge "Add HmacSHA256 backed by AndroidKeyStore."
* commit '7ca65f09013e807b6df61b2ba3e650a09ceff432': Add HmacSHA256 backed by AndroidKeyStore.
Diffstat (limited to 'keystore/java/android/security/AndroidKeyStore.java')
-rw-r--r--keystore/java/android/security/AndroidKeyStore.java13
1 files changed, 13 insertions, 0 deletions
diff --git a/keystore/java/android/security/AndroidKeyStore.java b/keystore/java/android/security/AndroidKeyStore.java
index f3eb317..1d16ca1 100644
--- a/keystore/java/android/security/AndroidKeyStore.java
+++ b/keystore/java/android/security/AndroidKeyStore.java
@@ -494,6 +494,19 @@ public class AndroidKeyStore extends KeyStoreSpi {
args.addInt(KeymasterDefs.KM_TAG_DIGEST,
KeyStoreKeyConstraints.Digest.toKeymaster(digest));
}
+ if (keyAlgorithm == KeyStoreKeyConstraints.Algorithm.HMAC) {
+ if (digest == null) {
+ throw new IllegalStateException("Digest algorithm must be specified for key"
+ + " algorithm " + keyAlgorithmString);
+ }
+ Integer digestOutputSizeBytes =
+ KeyStoreKeyConstraints.Digest.getOutputSizeBytes(digest);
+ if (digestOutputSizeBytes != null) {
+ // TODO: Remove MAC length constraint once Keymaster API no longer requires it.
+ // TODO: Switch to bits instead of bytes, once this is fixed in Keymaster
+ args.addInt(KeymasterDefs.KM_TAG_MAC_LENGTH, digestOutputSizeBytes);
+ }
+ }
@KeyStoreKeyConstraints.PurposeEnum int purposes = (params.getPurposes() != null)
? params.getPurposes()