Package com.github.ambry.router
Interface CryptoService<T>
-
public interface CryptoService<T>
Crypto Service to assist in encrypting and decrypting bytes and keys T refers to the key type that thisCryptoService
accepts. Ensure thatCryptoService
implementation is compatible with the key type thatKeyManagementService
generates
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default io.netty.buffer.ByteBuf
decrypt(io.netty.buffer.ByteBuf toDecrypt, T key)
Decrypts thetoDecrypt
with the given key.java.nio.ByteBuffer
decrypt(java.nio.ByteBuffer toDecrypt, T key)
Decrypts thetoDecrypt
with the given key.T
decryptKey(java.nio.ByteBuffer toDecrypt, T key)
Decrypts the key using the givenkey
default io.netty.buffer.ByteBuf
encrypt(io.netty.buffer.ByteBuf toEncrypt, T key)
Encrypts thetoEncrypt
with the given key.java.nio.ByteBuffer
encrypt(java.nio.ByteBuffer toEncrypt, T key)
Encrypts thetoEncrypt
with the given key.java.nio.ByteBuffer
encryptKey(T toEncrypt, T key)
Returns the encrypted form of the key in bytes.
-
-
-
Method Detail
-
encrypt
java.nio.ByteBuffer encrypt(java.nio.ByteBuffer toEncrypt, T key) throws java.security.GeneralSecurityException
Encrypts thetoEncrypt
with the given key. This is used for encrypting data chunks.- Parameters:
toEncrypt
-ByteBuffer
that needs to be encryptedkey
- the secret key (of type T) to use to encrypt- Returns:
- the
ByteBuffer
containing the encrypted content. Ensure the result has all the information like the IV along with the encrypted content, in order to decrypt the content with a given key - Throws:
java.security.GeneralSecurityException
-
encrypt
default io.netty.buffer.ByteBuf encrypt(io.netty.buffer.ByteBuf toEncrypt, T key) throws java.security.GeneralSecurityException
Encrypts thetoEncrypt
with the given key. ThetoEncrypt
is a nettyByteBuf
. This is used for encrypting data chunks.- Parameters:
toEncrypt
-ByteBuf
that needs to be encryptedkey
- the secret key (of type T) to use to encrypt- Returns:
- the
ByteBuf
containing the encrypted content. Ensure the result has all the information lik the IV along with the encrypted content, in order to decrypt the content with a given key - Throws:
java.security.GeneralSecurityException
-
decrypt
java.nio.ByteBuffer decrypt(java.nio.ByteBuffer toDecrypt, T key) throws java.security.GeneralSecurityException
Decrypts thetoDecrypt
with the given key. This is used for decrypting data chunks.- Parameters:
toDecrypt
-ByteBuffer
that needs to be decryptedkey
- the secret key (of type T) to use to decrypt- Returns:
- the
ByteBuffer
containing the decrypted content - Throws:
java.security.GeneralSecurityException
-
decrypt
default io.netty.buffer.ByteBuf decrypt(io.netty.buffer.ByteBuf toDecrypt, T key) throws java.security.GeneralSecurityException
Decrypts thetoDecrypt
with the given key. ThetoDecrypt
is a nettyByteBuf
. This is used for decrypting data chunks.- Parameters:
toDecrypt
-ByteBuf
that needs to be decryptedkey
- the secret key (of type T) to use to decrypt- Returns:
- the
ByteBuffer
containing the decrypted content - Throws:
java.security.GeneralSecurityException
-
encryptKey
java.nio.ByteBuffer encryptKey(T toEncrypt, T key) throws java.security.GeneralSecurityException
Returns the encrypted form of the key in bytes.- Parameters:
toEncrypt
- the secret key (of type T) that needs to be encryptedkey
- the secret key (of type T) to use to encrypt- Returns:
- the
ByteBuffer
representing the encrypted key - Throws:
java.security.GeneralSecurityException
-
decryptKey
T decryptKey(java.nio.ByteBuffer toDecrypt, T key) throws java.security.GeneralSecurityException
Decrypts the key using the givenkey
- Parameters:
toDecrypt
- theByteBuffer
from which key needs to be decryptedkey
- the secret key (of type T) to use to decrypt- Returns:
- the key thus decrypted
- Throws:
java.security.GeneralSecurityException
-
-