public final class AeadKeyTemplates extends Object
KeyTemplate for Aead keys.
We recommend to avoid this class to keep dependencies small.
Instead, we recommend to use KeysetHandle.generateEntryFromParametersName or KeysetHandle.generateEntryFromParameters.
One can use these templates to generate new Keyset with
KeysetHandle.generateNew(com.google.crypto.tink.Parameters). To generate a new keyset that contains a
single AesGcmKey, one can do:
AeadConfig.register();
KeysetHandle handle = KeysetHandle.generateNew(AeadKeyTemplates.AES128_GCM);
Aead aead = handle.getPrimitive(RegistryConfiguration.get(), Aead.class);
| Modifier and Type | Field and Description |
|---|---|
static KeyTemplate |
AES128_CTR_HMAC_SHA256
A
KeyTemplate that generates new instances of AesCtrHmacAeadKey with the following parameters:
AES key size: 16 bytes
AES CTR IV size: 16 byte
HMAC key size: 32 bytes
HMAC tag size: 16 bytes
HMAC hash function: SHA256
|
static KeyTemplate |
AES128_EAX
A
KeyTemplate that generates new instances of com.google.crypto.tink.proto.AesEaxKey with the following parameters:
Key size: 16 bytes
IV size: 16 bytes
|
static KeyTemplate |
AES128_GCM
A
KeyTemplate that generates new instances of AesGcmKey with the following parameters:
Key size: 16 bytes
|
static KeyTemplate |
AES256_CTR_HMAC_SHA256
A
KeyTemplate that generates new instances of AesCtrHmacAeadKey with the following parameters:
AES key size: 32 bytes
AES CTR IV size: 16 byte
HMAC key size: 32 bytes
HMAC tag size: 32 bytes
HMAC hash function: SHA256
|
static KeyTemplate |
AES256_EAX
A
KeyTemplate that generates new instances of AesEaxKey with the following parameters:
Key size: 32 bytes
IV size: 16 bytes
|
static KeyTemplate |
AES256_GCM
A
KeyTemplate that generates new instances of AesGcmKey with the following parameters:
Key size: 32 bytes
|
static KeyTemplate |
CHACHA20_POLY1305
A
KeyTemplate that generates new instances of ChaCha20Poly1305Key. |
static KeyTemplate |
XCHACHA20_POLY1305
A
KeyTemplate that generates new instances of XChaCha20Poly1305Key. |
| Modifier and Type | Method and Description |
|---|---|
static KeyTemplate |
createAesCtrHmacAeadKeyTemplate(int aesKeySize,
int ivSize,
int hmacKeySize,
int tagSize,
HashType hashType) |
static KeyTemplate |
createAesEaxKeyTemplate(int keySize,
int ivSize) |
static KeyTemplate |
createAesGcmKeyTemplate(int keySize) |
static KeyTemplate |
createKmsEnvelopeAeadKeyTemplate(String kekUri,
KeyTemplate dekTemplate)
Returns a new
KeyTemplate that can generate a KmsEnvelopeAeadKey whose key encrypting key (KEK) is pointing to
kekUri and DEK template is dekTemplate. |
public static final KeyTemplate AES128_GCM
KeyTemplate that generates new instances of AesGcmKey with the following parameters:
On Android KitKat (API level 19), the Aead instance generated
by this key template does not support associated data. It might not work at all in older
versions.
public static final KeyTemplate AES256_GCM
KeyTemplate that generates new instances of AesGcmKey with the following parameters:
On Android KitKat (API level 19), the Aead instance generated
by this key template does not support associated data. It might not work at all in older
versions.
public static final KeyTemplate AES128_EAX
KeyTemplate that generates new instances of com.google.crypto.tink.proto.AesEaxKey with the following parameters:
public static final KeyTemplate AES256_EAX
KeyTemplate that generates new instances of AesEaxKey with the following parameters:
public static final KeyTemplate AES128_CTR_HMAC_SHA256
KeyTemplate that generates new instances of AesCtrHmacAeadKey with the following parameters:
public static final KeyTemplate AES256_CTR_HMAC_SHA256
KeyTemplate that generates new instances of AesCtrHmacAeadKey with the following parameters:
public static final KeyTemplate CHACHA20_POLY1305
KeyTemplate that generates new instances of ChaCha20Poly1305Key.public static final KeyTemplate XCHACHA20_POLY1305
KeyTemplate that generates new instances of XChaCha20Poly1305Key.public static KeyTemplate createAesGcmKeyTemplate(int keySize)
KeyTemplate containing a AesGcmKeyFormat with some specified
parameters.public static KeyTemplate createAesEaxKeyTemplate(int keySize, int ivSize)
KeyTemplate containing a AesEaxKeyFormat with some specified
parameters.public static KeyTemplate createAesCtrHmacAeadKeyTemplate(int aesKeySize, int ivSize, int hmacKeySize, int tagSize, HashType hashType)
KeyTemplate containing a AesCtrHmacAeadKeyFormat with some specific
parameters.public static KeyTemplate createKmsEnvelopeAeadKeyTemplate(String kekUri, KeyTemplate dekTemplate)
KeyTemplate that can generate a KmsEnvelopeAeadKey whose key encrypting key (KEK) is pointing to
kekUri and DEK template is dekTemplate. Keys generated by this key template
uses RAW output prefix to make them compatible with the remote KMS' encrypt/decrypt operations.
Unlike other templates, when you generate new keys with this template, Tink does not generate
new key material, but only creates a reference to the remote KEK.