Class JceSm4CtrCryptoCodec

All Implemented Interfaces:
Closeable, AutoCloseable, Configurable

@Private public class JceSm4CtrCryptoCodec extends JceCtrCryptoCodec
Implement the SM4-CTR crypto codec using JCE provider.
  • Constructor Details

    • JceSm4CtrCryptoCodec

      public JceSm4CtrCryptoCodec()
  • Method Details

    • getLogger

      public org.slf4j.Logger getLogger()
      Specified by:
      getLogger in class JceCtrCryptoCodec
    • getCipherSuite

      public CipherSuite getCipherSuite()
      Specified by:
      getCipherSuite in class CryptoCodec
      Returns:
      the CipherSuite for this codec.
    • calculateIV

      public void calculateIV(byte[] initIV, long counter, byte[] iv)
      Description copied from class: CryptoCodec
      This interface is only for Counter (CTR) mode. Generally the Encryptor or Decryptor calculates the IV and maintain encryption context internally. For example a Cipher will maintain its encryption context internally when we do encryption/decryption using the Cipher#update interface.

      Encryption/Decryption is not always on the entire file. For example, in Hadoop, a node may only decrypt a portion of a file (i.e. a split). In these situations, the counter is derived from the file position.

      The IV can be calculated by combining the initial IV and the counter with a lossless operation (concatenation, addition, or XOR). See http://en.wikipedia.org/wiki/Block_cipher_mode_of_operation#Counter_ .28CTR.29

      Specified by:
      calculateIV in class CryptoCodec
      Parameters:
      initIV - initial IV
      counter - counter for input stream position
      iv - the IV for input stream position
    • createEncryptor

      public Encryptor createEncryptor() throws GeneralSecurityException
      Description copied from class: CryptoCodec
      Create a Encryptor.
      Specified by:
      createEncryptor in class CryptoCodec
      Returns:
      Encryptor the encryptor.
      Throws:
      GeneralSecurityException - thrown if create encryptor error.
    • createDecryptor

      public Decryptor createDecryptor() throws GeneralSecurityException
      Description copied from class: CryptoCodec
      Create a Decryptor.
      Specified by:
      createDecryptor in class CryptoCodec
      Returns:
      Decryptor the decryptor
      Throws:
      GeneralSecurityException - thrown if create decryptor error.