Package org.apache.hadoop.crypto
Class OpensslCtrCryptoCodec.OpensslCtrCipher
java.lang.Object
org.apache.hadoop.crypto.OpensslCtrCryptoCodec.OpensslCtrCipher
- Enclosing class:
- OpensslCtrCryptoCodec
-
Constructor Summary
ConstructorsConstructorDescriptionOpensslCtrCipher(int mode, CipherSuite suite) OpensslCtrCipher(int mode, CipherSuite suite, String engineId) -
Method Summary
Modifier and TypeMethodDescriptionvoiddecrypt(ByteBuffer inBuffer, ByteBuffer outBuffer) AES-CTR will consume all of the input data.voidencrypt(ByteBuffer inBuffer, ByteBuffer outBuffer) AES-CTR will consume all of the input data.voidinit(byte[] key, byte[] iv) Initialize the encryptor and the internal encryption context.booleanIndicate whether the encryption context is reset.
-
Constructor Details
-
OpensslCtrCipher
public OpensslCtrCipher(int mode, CipherSuite suite, String engineId) throws GeneralSecurityException - Throws:
GeneralSecurityException
-
OpensslCtrCipher
- Throws:
GeneralSecurityException
-
-
Method Details
-
init
Description copied from interface:EncryptorInitialize the encryptor and the internal encryption context.- Specified by:
initin interfaceDecryptor- Specified by:
initin interfaceEncryptor- Parameters:
key- encryption key.iv- encryption initialization vector- Throws:
IOException- if initialization fails
-
encrypt
AES-CTR will consume all of the input data. It requires enough space in the destination buffer to encrypt entire input buffer.- Specified by:
encryptin interfaceEncryptor- Parameters:
inBuffer- a directByteBufferto read from. inBuffer may not be null and inBuffer.remaining() must be > 0outBuffer- a directByteBufferto write to. outBuffer may not be null and outBuffer.remaining() must be > 0- Throws:
IOException- if encryption fails
-
decrypt
AES-CTR will consume all of the input data. It requires enough space in the destination buffer to decrypt entire input buffer.- Specified by:
decryptin interfaceDecryptor- Parameters:
inBuffer- a directByteBufferto read from. inBuffer may not be null and inBuffer.remaining() must be > 0outBuffer- a directByteBufferto write to. outBuffer may not be null and outBuffer.remaining() must be > 0- Throws:
IOException- if decryption fails
-
isContextReset
public boolean isContextReset()Description copied from interface:EncryptorIndicate whether the encryption context is reset.Certain modes, like CTR, require a different IV depending on the position in the stream. Generally, the encryptor maintains any necessary context for calculating the IV and counter so that no reinit is necessary during the encryption. Reinit before each operation is inefficient.
- Specified by:
isContextResetin interfaceDecryptor- Specified by:
isContextResetin interfaceEncryptor- Returns:
- boolean whether context is reset.
-