public final class AndroidKeystoreKmsClient extends Object implements KmsClient
KmsClient for Android Keystore.
This class requires Android M (API level 23) or newer.
| Modifier and Type | Class and Description |
|---|---|
static class |
AndroidKeystoreKmsClient.Builder
Builder for AndroidKeystoreKmsClient
|
| Modifier and Type | Field and Description |
|---|---|
static String |
PREFIX
The prefix of all keys stored in Android Keystore.
|
| Constructor and Description |
|---|
AndroidKeystoreKmsClient() |
AndroidKeystoreKmsClient(String uri)
Deprecated.
|
| Modifier and Type | Method and Description |
|---|---|
void |
deleteKey(String keyUri)
Deletes a key in Android Keystore.
|
boolean |
doesSupport(String uri) |
static void |
generateNewAeadKey(String keyUri)
Generates a new key in Android Keystore.
|
Aead |
getAead(String uri)
Returns an
Aead backed by a key in Android Keystore specified by uri. |
static Aead |
getOrGenerateNewAeadKey(String keyUri)
Generates a new key in Android Keystore, if it doesn't exist.
|
KmsClient |
withCredentials(String unused)
Initializes a
KmsClient for Android Keystore. |
KmsClient |
withDefaultCredentials()
Initializes a
KmsClient for Android Keystore. |
public static final String PREFIX
@RequiresApi(value=23)
public AndroidKeystoreKmsClient()
throws GeneralSecurityException
GeneralSecurityException@Deprecated @RequiresApi(value=23) public AndroidKeystoreKmsClient(String uri)
AndroidKeystoreKmsClient.Builder.AndroidKeystoreKmsClient that is bound to a single key identified by
uri.@RequiresApi(value=23) public boolean doesSupport(String uri)
doesSupport in interface KmsClientkeyUri is not null and equal to uri, or keyUri is null and uri starts with PREFIX.@RequiresApi(value=23) public KmsClient withCredentials(String unused) throws GeneralSecurityException
KmsClient for Android Keystore.
Note that Android Keystore doesn't need credentials, thus the credential path is unused.
withCredentials in interface KmsClientGeneralSecurityException@RequiresApi(value=23) public KmsClient withDefaultCredentials() throws GeneralSecurityException
KmsClient for Android Keystore.
Note that Android Keystore does not use credentials.
withDefaultCredentials in interface KmsClientGeneralSecurityExceptionpublic Aead getAead(String uri) throws GeneralSecurityException
Aead backed by a key in Android Keystore specified by uri.
Since Android Keystore is somewhat unreliable, a self-test is done against the key. This will incur a small performance penalty.
getAead in interface KmsClientGeneralSecurityException - if the URI is not supported or invalidpublic void deleteKey(String keyUri) throws GeneralSecurityException
GeneralSecurityException@RequiresApi(value=23) public static Aead getOrGenerateNewAeadKey(String keyUri) throws GeneralSecurityException, IOException
Generates AES256-GCM keys.
GeneralSecurityExceptionIOException@RequiresApi(value=23) public static void generateNewAeadKey(String keyUri) throws GeneralSecurityException
Generates AES256-GCM keys.
GeneralSecurityException