Class AesGcmAeadCrypter
java.lang.Object
io.grpc.alts.internal.AesGcmAeadCrypter
- All Implemented Interfaces:
AeadCrypter
AES128-GCM implementation of
AeadCrypter that uses default JCE provider.-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddecrypt(ByteBuffer plaintext, ByteBuffer ciphertext, byte[] nonce) Decrypt ciphertext into plaintext buffer using the given nonce.voiddecrypt(ByteBuffer plaintext, ByteBuffer ciphertext, ByteBuffer aad, byte[] nonce) Decrypt ciphertext into plaintext buffer using the given nonce.private voiddecryptAad(ByteBuffer plaintext, ByteBuffer ciphertext, ByteBuffer aad, byte[] nonce) voidencrypt(ByteBuffer ciphertext, ByteBuffer plaintext, byte[] nonce) Encrypt plaintext into ciphertext buffer using the given nonce.voidencrypt(ByteBuffer ciphertext, ByteBuffer plaintext, ByteBuffer aad, byte[] nonce) Encrypt plaintext into ciphertext buffer using the given nonce with authenticated data.private intencryptAad(ByteBuffer ciphertext, ByteBuffer plaintext, ByteBuffer aad, byte[] nonce) (package private) static Provider(package private) static int
-
Field Details
-
logger
-
KEY_LENGTH
private static final int KEY_LENGTH- See Also:
-
TAG_LENGTH
private static final int TAG_LENGTH- See Also:
-
NONCE_LENGTH
static final int NONCE_LENGTH- See Also:
-
AES
- See Also:
-
AES_GCM
- See Also:
-
CONSCRYPT
-
key
private final byte[] key -
cipher
-
-
Constructor Details
-
AesGcmAeadCrypter
AesGcmAeadCrypter(byte[] key) throws GeneralSecurityException - Throws:
GeneralSecurityException
-
-
Method Details
-
encryptAad
private int encryptAad(ByteBuffer ciphertext, ByteBuffer plaintext, @Nullable ByteBuffer aad, byte[] nonce) throws GeneralSecurityException - Throws:
GeneralSecurityException
-
decryptAad
private void decryptAad(ByteBuffer plaintext, ByteBuffer ciphertext, @Nullable ByteBuffer aad, byte[] nonce) throws GeneralSecurityException - Throws:
GeneralSecurityException
-
encrypt
public void encrypt(ByteBuffer ciphertext, ByteBuffer plaintext, byte[] nonce) throws GeneralSecurityException Description copied from interface:AeadCrypterEncrypt plaintext into ciphertext buffer using the given nonce.- Specified by:
encryptin interfaceAeadCrypter- Parameters:
ciphertext- the encrypted plaintext and the tag will be written into this buffer.plaintext- the input that should be encrypted.nonce- the unique nonce used for the encryption.- Throws:
GeneralSecurityException- if ciphertext buffer is short or the nonce does not have the expected size.
-
encrypt
public void encrypt(ByteBuffer ciphertext, ByteBuffer plaintext, ByteBuffer aad, byte[] nonce) throws GeneralSecurityException Description copied from interface:AeadCrypterEncrypt plaintext into ciphertext buffer using the given nonce with authenticated data.- Specified by:
encryptin interfaceAeadCrypter- Parameters:
ciphertext- the encrypted plaintext and the tag will be written into this buffer.plaintext- the input that should be encrypted.aad- additional data that should be authenticated, but not encrypted.nonce- the unique nonce used for the encryption.- Throws:
GeneralSecurityException- if ciphertext buffer is short or the nonce does not have the expected size.
-
decrypt
public void decrypt(ByteBuffer plaintext, ByteBuffer ciphertext, byte[] nonce) throws GeneralSecurityException Description copied from interface:AeadCrypterDecrypt ciphertext into plaintext buffer using the given nonce.- Specified by:
decryptin interfaceAeadCrypter- Parameters:
plaintext- the decrypted plaintext will be written into this buffer.ciphertext- the ciphertext and tag that should be decrypted.nonce- the nonce that was used for the encryption.- Throws:
GeneralSecurityException- if the tag is invalid or any of the inputs do not have the expected size.
-
decrypt
public void decrypt(ByteBuffer plaintext, ByteBuffer ciphertext, ByteBuffer aad, byte[] nonce) throws GeneralSecurityException Description copied from interface:AeadCrypterDecrypt ciphertext into plaintext buffer using the given nonce.- Specified by:
decryptin interfaceAeadCrypter- Parameters:
plaintext- the decrypted plaintext will be written into this buffer.ciphertext- the ciphertext and tag that should be decrypted.aad- additional data that is checked for authenticity.nonce- the nonce that was used for the encryption.- Throws:
GeneralSecurityException- if the tag is invalid or any of the inputs do not have the expected size.
-
getKeyLength
static int getKeyLength() -
getConscrypt
-