Package org.apache.hadoop.crypto
Class JceSm4CtrCryptoCodec
java.lang.Object
org.apache.hadoop.crypto.CryptoCodec
org.apache.hadoop.crypto.JceCtrCryptoCodec
org.apache.hadoop.crypto.JceSm4CtrCryptoCodec
- All Implemented Interfaces:
Closeable,AutoCloseable,Configurable
Implement the SM4-CTR crypto codec using JCE provider.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.hadoop.crypto.JceCtrCryptoCodec
JceCtrCryptoCodec.JceCtrCipher -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcalculateIV(byte[] initIV, long counter, byte[] iv) This interface is only for Counter (CTR) mode.Create aDecryptor.Create aEncryptor.org.slf4j.LoggerMethods inherited from class org.apache.hadoop.crypto.JceCtrCryptoCodec
calculateIV, close, generateSecureRandom, getConf, getProvider, setConfMethods inherited from class org.apache.hadoop.crypto.CryptoCodec
getInstance, getInstance
-
Constructor Details
-
JceSm4CtrCryptoCodec
public JceSm4CtrCryptoCodec()
-
-
Method Details
-
getLogger
public org.slf4j.Logger getLogger()- Specified by:
getLoggerin classJceCtrCryptoCodec
-
getCipherSuite
- Specified by:
getCipherSuitein classCryptoCodec- Returns:
- the CipherSuite for this codec.
-
calculateIV
public void calculateIV(byte[] initIV, long counter, byte[] iv) Description copied from class:CryptoCodecThis interface is only for Counter (CTR) mode. Generally the Encryptor or Decryptor calculates the IV and maintain encryption context internally. For example aCipherwill 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:
calculateIVin classCryptoCodec- Parameters:
initIV- initial IVcounter- counter for input stream positioniv- the IV for input stream position
-
createEncryptor
Description copied from class:CryptoCodecCreate aEncryptor.- Specified by:
createEncryptorin classCryptoCodec- Returns:
- Encryptor the encryptor.
- Throws:
GeneralSecurityException- thrown if create encryptor error.
-
createDecryptor
Description copied from class:CryptoCodecCreate aDecryptor.- Specified by:
createDecryptorin classCryptoCodec- Returns:
- Decryptor the decryptor
- Throws:
GeneralSecurityException- thrown if create decryptor error.
-