diff options
author | Justin Klaassen <justinklaassen@google.com> | 2017-11-30 18:18:21 -0500 |
---|---|---|
committer | Justin Klaassen <justinklaassen@google.com> | 2017-11-30 18:18:21 -0500 |
commit | 4217cf85c20565a3446a662a7f07f26137b26b7f (patch) | |
tree | a0417b47a8cc802f6642f369fd2371165bec7b5c /android/security | |
parent | 6a65f2da209bff03cb0eb6da309710ac6ee5026d (diff) | |
download | android-28-4217cf85c20565a3446a662a7f07f26137b26b7f.tar.gz |
Import Android SDK Platform P [4477446]
/google/data/ro/projects/android/fetch_artifact \
--bid 4477446 \
--target sdk_phone_armv7-win_sdk \
sdk-repo-linux-sources-4477446.zip
AndroidVersion.ApiLevel has been modified to appear as 28
Change-Id: If0559643d7c328e36aafca98f0c114641d33642c
Diffstat (limited to 'android/security')
-rw-r--r-- | android/security/KeyChain.java | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/android/security/KeyChain.java b/android/security/KeyChain.java index 3fe730fd..2daf733d 100644 --- a/android/security/KeyChain.java +++ b/android/security/KeyChain.java @@ -40,6 +40,7 @@ import android.security.keystore.KeyProperties; import java.io.ByteArrayInputStream; import java.io.Closeable; +import java.security.KeyPair; import java.security.Principal; import java.security.PrivateKey; import java.security.UnrecoverableKeyException; @@ -418,6 +419,18 @@ public final class KeyChain { @Nullable @WorkerThread public static PrivateKey getPrivateKey(@NonNull Context context, @NonNull String alias) throws KeyChainException, InterruptedException { + KeyPair keyPair = getKeyPair(context, alias); + if (keyPair != null) { + return keyPair.getPrivate(); + } + + return null; + } + + /** @hide */ + @Nullable @WorkerThread + public static KeyPair getKeyPair(@NonNull Context context, @NonNull String alias) + throws KeyChainException, InterruptedException { if (alias == null) { throw new NullPointerException("alias == null"); } @@ -439,7 +452,7 @@ public final class KeyChain { return null; } else { try { - return AndroidKeyStoreProvider.loadAndroidKeyStorePrivateKeyFromKeystore( + return AndroidKeyStoreProvider.loadAndroidKeyStoreKeyPairFromKeystore( KeyStore.getInstance(), keyId, KeyStore.UID_SELF); } catch (RuntimeException | UnrecoverableKeyException e) { throw new KeyChainException(e); |