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 this CryptoService accepts. Ensure that CryptoService implementation is compatible with the key type that KeyManagementService 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 the toDecrypt with the given key.
      java.nio.ByteBuffer decrypt​(java.nio.ByteBuffer toDecrypt, T key)
      Decrypts the toDecrypt with the given key.
      T decryptKey​(java.nio.ByteBuffer toDecrypt, T key)
      Decrypts the key using the given key
      default io.netty.buffer.ByteBuf encrypt​(io.netty.buffer.ByteBuf toEncrypt, T key)
      Encrypts the toEncrypt with the given key.
      java.nio.ByteBuffer encrypt​(java.nio.ByteBuffer toEncrypt, T key)
      Encrypts the toEncrypt 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 the toEncrypt with the given key. This is used for encrypting data chunks.
        Parameters:
        toEncrypt - ByteBuffer that needs to be encrypted
        key - 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 the toEncrypt with the given key. The toEncrypt is a netty ByteBuf. This is used for encrypting data chunks.
        Parameters:
        toEncrypt - ByteBuf that needs to be encrypted
        key - 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 the toDecrypt with the given key. This is used for decrypting data chunks.
        Parameters:
        toDecrypt - ByteBuffer that needs to be decrypted
        key - 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 the toDecrypt with the given key. The toDecrypt is a netty ByteBuf. This is used for decrypting data chunks.
        Parameters:
        toDecrypt - ByteBuf that needs to be decrypted
        key - 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 encrypted
        key - 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 given key
        Parameters:
        toDecrypt - the ByteBuffer from which key needs to be decrypted
        key - the secret key (of type T) to use to decrypt
        Returns:
        the key thus decrypted
        Throws:
        java.security.GeneralSecurityException