java.io.Closeable, java.lang.AutoCloseable, ConfigurableJceCtrCryptoCodec, OpensslCtrCryptoCodec@Private @Evolving public abstract class CryptoCodec extends java.lang.Object implements Configurable, java.io.Closeable
| Modifier and Type | Field | Description |
|---|---|---|
static org.slf4j.Logger |
LOG |
| Constructor | Description |
|---|---|
CryptoCodec() |
| Modifier and Type | Method | Description |
|---|---|---|
abstract void |
calculateIV(byte[] initIV,
long counter,
byte[] IV) |
This interface is only for Counter (CTR) mode.
|
abstract Decryptor |
createDecryptor() |
Create a
Decryptor. |
abstract Encryptor |
createEncryptor() |
Create a
Encryptor. |
abstract void |
generateSecureRandom(byte[] bytes) |
Generate a number of secure, random bytes suitable for cryptographic use.
|
abstract CipherSuite |
getCipherSuite() |
|
static CryptoCodec |
getInstance(Configuration conf) |
Get crypto codec for algorithm/mode/padding in config value
hadoop.security.crypto.cipher.suite
|
static CryptoCodec |
getInstance(Configuration conf,
CipherSuite cipherSuite) |
Get crypto codec for specified algorithm/mode/padding.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetConf, setConfpublic static CryptoCodec getInstance(Configuration conf, CipherSuite cipherSuite)
conf - the configurationcipherSuite - algorithm/mode/paddingpublic static CryptoCodec getInstance(Configuration conf)
conf - the configurationpublic abstract CipherSuite getCipherSuite()
public abstract Encryptor createEncryptor() throws java.security.GeneralSecurityException
Encryptor.java.security.GeneralSecurityException - thrown if create encryptor error.public abstract Decryptor createDecryptor() throws java.security.GeneralSecurityException
Decryptor.java.security.GeneralSecurityException - thrown if create decryptor error.public abstract void calculateIV(byte[] initIV,
long counter,
byte[] IV)
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
initIV - initial IVcounter - counter for input stream positionIV - the IV for input stream positionpublic abstract void generateSecureRandom(byte[] bytes)
bytes - byte array to populate with random dataCopyright © 2008–2025 Apache Software Foundation. All rights reserved.