Package org.conscrypt
Class OpenSSLEvpCipher
- java.lang.Object
-
- javax.crypto.CipherSpi
-
- org.conscrypt.OpenSSLCipher
-
- org.conscrypt.OpenSSLEvpCipher
-
- Direct Known Subclasses:
OpenSSLEvpCipherAES
,OpenSSLEvpCipherARC4
,OpenSSLEvpCipherDESEDE
@Internal public abstract class OpenSSLEvpCipher extends OpenSSLCipher
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.conscrypt.OpenSSLCipher
OpenSSLCipher.Mode, OpenSSLCipher.Padding
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
calledUpdate
Whether the cipher has processed any data yet.private NativeRef.EVP_CIPHER_CTX
cipherCtx
Native pointer for the OpenSSL EVP_CIPHER context.private int
modeBlockSize
The block size of the current mode.-
Fields inherited from class org.conscrypt.OpenSSLCipher
encodedKey, iv, mode
-
-
Constructor Summary
Constructors Constructor Description OpenSSLEvpCipher(OpenSSLCipher.Mode mode, OpenSSLCipher.Padding padding)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description (package private) int
doFinalInternal(byte[] output, int outputOffset, int maximumLen)
API-specific implementation of the final block.(package private) void
engineInitInternal(byte[] encodedKey, java.security.spec.AlgorithmParameterSpec params, java.security.SecureRandom random)
API-specific implementation of initializing the cipher.(package private) abstract java.lang.String
getCipherName(int keySize, OpenSSLCipher.Mode mode)
Returns the OpenSSL cipher name for the particularkeySize
and ciphermode
.(package private) int
getOutputSizeForFinal(int inputLen)
The size of output ifdoFinal()
is called with thisinputLen
.(package private) int
getOutputSizeForUpdate(int inputLen)
The size of output ifupdate()
is called with thisinputLen
.private void
reset()
Reset this Cipher instance state to process a new chunk of data.(package private) int
updateInternal(byte[] input, int inputOffset, int inputLen, byte[] output, int outputOffset, int maximumLen)
API-specific implementation of updating the cipher.-
Methods inherited from class org.conscrypt.OpenSSLCipher
checkSupportedKeySize, checkSupportedMode, checkSupportedPadding, engineDoFinal, engineDoFinal, engineGetBlockSize, engineGetIV, engineGetKeySize, engineGetOutputSize, engineGetParameters, engineInit, engineInit, engineInit, engineSetMode, engineSetPadding, engineUnwrap, engineUpdate, engineUpdate, engineWrap, getBaseCipherName, getCipherBlockSize, getPadding, getParameterSpec, isEncrypting, supportsVariableSizeIv, supportsVariableSizeKey
-
-
-
-
Field Detail
-
cipherCtx
private final NativeRef.EVP_CIPHER_CTX cipherCtx
Native pointer for the OpenSSL EVP_CIPHER context.
-
calledUpdate
private boolean calledUpdate
Whether the cipher has processed any data yet. EVP_CIPHER doesn't like calling "doFinal()" in decryption mode without processing any updates.
-
modeBlockSize
private int modeBlockSize
The block size of the current mode.
-
-
Constructor Detail
-
OpenSSLEvpCipher
public OpenSSLEvpCipher(OpenSSLCipher.Mode mode, OpenSSLCipher.Padding padding)
-
-
Method Detail
-
engineInitInternal
void engineInitInternal(byte[] encodedKey, java.security.spec.AlgorithmParameterSpec params, java.security.SecureRandom random) throws java.security.InvalidKeyException, java.security.InvalidAlgorithmParameterException
Description copied from class:OpenSSLCipher
API-specific implementation of initializing the cipher. TheOpenSSLCipher.isEncrypting()
function will tell whether it should be initialized for encryption or decryption. TheencodedKey
will be the bytes of a supported key size.- Specified by:
engineInitInternal
in classOpenSSLCipher
- Throws:
java.security.InvalidKeyException
java.security.InvalidAlgorithmParameterException
-
updateInternal
int updateInternal(byte[] input, int inputOffset, int inputLen, byte[] output, int outputOffset, int maximumLen) throws javax.crypto.ShortBufferException
Description copied from class:OpenSSLCipher
API-specific implementation of updating the cipher. ThemaximumLen
will be the maximum length of the output as returned byOpenSSLCipher.getOutputSizeForUpdate(int)
. The return value must be the number of bytes processed and placed intooutput
. On error, an exception must be thrown.- Specified by:
updateInternal
in classOpenSSLCipher
- Throws:
javax.crypto.ShortBufferException
-
doFinalInternal
int doFinalInternal(byte[] output, int outputOffset, int maximumLen) throws javax.crypto.IllegalBlockSizeException, javax.crypto.BadPaddingException, javax.crypto.ShortBufferException
Description copied from class:OpenSSLCipher
API-specific implementation of the final block. ThemaximumLen
will be the maximum length of the possible output as returned byOpenSSLCipher.getOutputSizeForFinal(int)
. The return value must be the number of bytes processed and placed intooutput
. On error, an exception must be thrown.- Specified by:
doFinalInternal
in classOpenSSLCipher
- Throws:
javax.crypto.IllegalBlockSizeException
javax.crypto.BadPaddingException
javax.crypto.ShortBufferException
-
getOutputSizeForFinal
int getOutputSizeForFinal(int inputLen)
Description copied from class:OpenSSLCipher
The size of output ifdoFinal()
is called with thisinputLen
. If padding is enabled and the size of the input puts it right at the block size, it will add another block for the padding.- Specified by:
getOutputSizeForFinal
in classOpenSSLCipher
-
getOutputSizeForUpdate
int getOutputSizeForUpdate(int inputLen)
Description copied from class:OpenSSLCipher
The size of output ifupdate()
is called with thisinputLen
. If padding is enabled and the size of the input puts it right at the block size, it will add another block for the padding.- Specified by:
getOutputSizeForUpdate
in classOpenSSLCipher
-
getCipherName
abstract java.lang.String getCipherName(int keySize, OpenSSLCipher.Mode mode)
Returns the OpenSSL cipher name for the particularkeySize
and ciphermode
.
-
reset
private void reset()
Reset this Cipher instance state to process a new chunk of data.
-
-