Class AndroidKeystoreKmsClient
- java.lang.Object
-
- com.google.crypto.tink.integration.android.AndroidKeystoreKmsClient
-
- All Implemented Interfaces:
KmsClient
public final class AndroidKeystoreKmsClient extends java.lang.Object implements KmsClient
An implementation ofKmsClientfor Android Keystore.We don't recommend using this class. Instead, directly use
AndroidKeystore.This class requires Android M (API level 23) or newer.
- Since:
- 1.0.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAndroidKeystoreKmsClient.BuilderBuilder for AndroidKeystoreKmsClient
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringPREFIXThe prefix of all keys stored in Android Keystore.
-
Constructor Summary
Constructors Constructor Description AndroidKeystoreKmsClient()AndroidKeystoreKmsClient(java.lang.String uri)Deprecated.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddeleteKey(java.lang.String keyUri)Deletes a key in Android Keystore.booleandoesSupport(java.lang.String uri)static voidgenerateNewAeadKey(java.lang.String keyUri)Generates a new key in Android Keystore.AeadgetAead(java.lang.String uri)Returns anAeadbacked by a key in Android Keystore specified byuri.static AeadgetOrGenerateNewAeadKey(java.lang.String keyUri)Generates a new key in Android Keystore, if it doesn't exist.KmsClientwithCredentials(java.lang.String unused)Initializes aKmsClientfor Android Keystore.KmsClientwithDefaultCredentials()Initializes aKmsClientfor Android Keystore.
-
-
-
Field Detail
-
PREFIX
public static final java.lang.String PREFIX
The prefix of all keys stored in Android Keystore.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
AndroidKeystoreKmsClient
@RequiresApi(23) public AndroidKeystoreKmsClient() throws java.security.GeneralSecurityException- Throws:
java.security.GeneralSecurityException
-
AndroidKeystoreKmsClient
@RequiresApi(23) @Deprecated public AndroidKeystoreKmsClient(java.lang.String uri)
Deprecated.Constructs anAndroidKeystoreKmsClientthat is bound to a single key identified byuri.
-
-
Method Detail
-
doesSupport
@RequiresApi(23) public boolean doesSupport(java.lang.String uri)
- Specified by:
doesSupportin interfaceKmsClient- Returns:
- true either if
keyUriis not null and equal touri, orkeyUriis null anduristarts withPREFIX.
-
withCredentials
@RequiresApi(23) public KmsClient withCredentials(java.lang.String unused) throws java.security.GeneralSecurityException
Initializes aKmsClientfor Android Keystore.Note that Android Keystore doesn't need credentials, thus the credential path is unused.
- Specified by:
withCredentialsin interfaceKmsClient- Throws:
java.security.GeneralSecurityException
-
withDefaultCredentials
@RequiresApi(23) public KmsClient withDefaultCredentials() throws java.security.GeneralSecurityException
Initializes aKmsClientfor Android Keystore.Note that Android Keystore does not use credentials.
- Specified by:
withDefaultCredentialsin interfaceKmsClient- Throws:
java.security.GeneralSecurityException
-
getAead
public Aead getAead(java.lang.String uri) throws java.security.GeneralSecurityException
Returns anAeadbacked by a key in Android Keystore specified byuri.Since Android Keystore is somewhat unreliable, a self-test is done against the key. This will incur a small performance penalty.
-
deleteKey
public void deleteKey(java.lang.String keyUri) throws java.security.GeneralSecurityExceptionDeletes a key in Android Keystore.- Throws:
java.security.GeneralSecurityException
-
getOrGenerateNewAeadKey
@RequiresApi(23) public static Aead getOrGenerateNewAeadKey(java.lang.String keyUri) throws java.security.GeneralSecurityException, java.io.IOException
Generates a new key in Android Keystore, if it doesn't exist.Generates AES256-GCM keys.
- Throws:
java.security.GeneralSecurityExceptionjava.io.IOException
-
generateNewAeadKey
@RequiresApi(23) public static void generateNewAeadKey(java.lang.String keyUri) throws java.security.GeneralSecurityExceptionGenerates a new key in Android Keystore.Generates AES256-GCM keys.
- Throws:
java.security.GeneralSecurityException
-
-