Package io.grpc.alts.internal
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 TypeMethodDescriptionvoid
decrypt
(ByteBuffer plaintext, ByteBuffer ciphertext, byte[] nonce) Decrypt ciphertext into plaintext buffer using the given nonce.void
decrypt
(ByteBuffer plaintext, ByteBuffer ciphertext, ByteBuffer aad, byte[] nonce) Decrypt ciphertext into plaintext buffer using the given nonce.private void
decryptAad
(ByteBuffer plaintext, ByteBuffer ciphertext, ByteBuffer aad, byte[] nonce) void
encrypt
(ByteBuffer ciphertext, ByteBuffer plaintext, byte[] nonce) Encrypt plaintext into ciphertext buffer using the given nonce.void
encrypt
(ByteBuffer ciphertext, ByteBuffer plaintext, ByteBuffer aad, byte[] nonce) Encrypt plaintext into ciphertext buffer using the given nonce with authenticated data.private int
encryptAad
(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:AeadCrypter
Encrypt plaintext into ciphertext buffer using the given nonce.- Specified by:
encrypt
in 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:AeadCrypter
Encrypt plaintext into ciphertext buffer using the given nonce with authenticated data.- Specified by:
encrypt
in 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:AeadCrypter
Decrypt ciphertext into plaintext buffer using the given nonce.- Specified by:
decrypt
in 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:AeadCrypter
Decrypt ciphertext into plaintext buffer using the given nonce.- Specified by:
decrypt
in 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
-