Package io.grpc.alts.internal
Interface AeadCrypter
- All Known Implementing Classes:
AesGcmAeadCrypter
,AesGcmHkdfAeadCrypter
interface AeadCrypter
AeadCrypter
performs authenticated encryption and decryption for a fixed key given unique
nonces. Authenticated additional data is supported.-
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.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.
-
Method Details
-
encrypt
void encrypt(ByteBuffer ciphertext, ByteBuffer plaintext, byte[] nonce) throws GeneralSecurityException Encrypt plaintext into ciphertext buffer using the given nonce.- 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
void encrypt(ByteBuffer ciphertext, ByteBuffer plaintext, ByteBuffer aad, byte[] nonce) throws GeneralSecurityException Encrypt plaintext into ciphertext buffer using the given nonce with authenticated data.- 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
void decrypt(ByteBuffer plaintext, ByteBuffer ciphertext, byte[] nonce) throws GeneralSecurityException Decrypt ciphertext into plaintext buffer using the given nonce.- 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
void decrypt(ByteBuffer plaintext, ByteBuffer ciphertext, ByteBuffer aad, byte[] nonce) throws GeneralSecurityException Decrypt ciphertext into plaintext buffer using the given nonce.- 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.
-