Class CryptoSuite


  • public class CryptoSuite
    extends Object
    Defines cipher transformation and hash algorithm for cryptographic related operations.
    • Constructor Detail

      • CryptoSuite

        public CryptoSuite​(CryptoManager cryptoManager,
                           String cipherTransformation,
                           int cipherKeyLength,
                           boolean encrypt)
        Declares a new CryptoSuite with provided parameters.
        Parameters:
        cryptoManager - the CryptoManager to use for cryptographic operations
        cipherTransformation - the initial cipher transformation
        cipherKeyLength - the initial key length for the cipher
        encrypt - if the user of the crypto suite needs encryption
    • Method Detail

      • newParameters

        public void newParameters​(String cipherTransformation,
                                  int cipherKeyLength,
                                  boolean enabled)
        Set new cipher and enable parameters for the crypto suite.
        Parameters:
        cipherTransformation - the new cipher transformation
        cipherKeyLength - the new key length
        enabled - true if the user of the crypto suite needs encryption
      • encrypt

        public byte[] encrypt​(byte[] data)
                       throws GeneralSecurityException,
                              CryptoManagerException
        Encrypts data with the configured cipher transformation and key length.
        Parameters:
        data - the clear-text data to encrypt
        Returns:
        a byte array with a prologue containing the key identifier followed by cipher-text
        Throws:
        GeneralSecurityException - if a problem occurs while encrypting the data
        CryptoManagerException - if a problem occurs during cipher initialization
      • hash48

        public ByteString hash48​(ByteSequence data)
                          throws DecodeException
        Returns a ByteString of 6 bytes hash of the data.
        Parameters:
        data - a ByteSequence containing the input data to be hashed
        Returns:
        a ByteString of 6 bytes hash of the data.
        Throws:
        DecodeException - if digest of the data cannot be computed
      • isEncrypted

        public boolean isEncrypted()
        Returns whether the user of the crypto suite needs encryption.
        Returns:
        true if the user of the crypto suite needs encryption