Package org.conscrypt
Class OpenSSLEvpCipher
java.lang.Object
javax.crypto.CipherSpi
org.conscrypt.OpenSSLCipher
org.conscrypt.OpenSSLEvpCipher
- Direct Known Subclasses:
OpenSSLEvpCipherAES,OpenSSLEvpCipherARC4,OpenSSLEvpCipherDESEDE
-
Nested Class Summary
Nested classes/interfaces inherited from class org.conscrypt.OpenSSLCipher
OpenSSLCipher.Mode, OpenSSLCipher.Padding -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanWhether the cipher has processed any data yet.private final NativeRef.EVP_CIPHER_CTXNative pointer for the OpenSSL EVP_CIPHER context.private intThe block size of the current mode.Fields inherited from class org.conscrypt.OpenSSLCipher
encodedKey, iv, mode -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) intdoFinalInternal(byte[] output, int outputOffset, int maximumLen) API-specific implementation of the final block.(package private) voidengineInitInternal(byte[] encodedKey, AlgorithmParameterSpec params, SecureRandom random) API-specific implementation of initializing the cipher.(package private) abstract StringgetCipherName(int keySize, OpenSSLCipher.Mode mode) Returns the OpenSSL cipher name for the particularkeySizeand ciphermode.(package private) intgetOutputSizeForFinal(int inputLen) The size of output ifdoFinal()is called with thisinputLen.(package private) intgetOutputSizeForUpdate(int inputLen) The size of output ifupdate()is called with thisinputLen.private voidreset()Reset this Cipher instance state to process a new chunk of data.(package private) intupdateInternal(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, supportsVariableSizeKeyMethods inherited from class javax.crypto.CipherSpi
engineDoFinal, engineUpdate, engineUpdateAAD, engineUpdateAAD
-
Field Details
-
cipherCtx
Native pointer for the OpenSSL EVP_CIPHER context. -
calledUpdate
private boolean calledUpdateWhether the cipher has processed any data yet. EVP_CIPHER doesn't like calling "doFinal()" in decryption mode without processing any updates. -
modeBlockSize
private int modeBlockSizeThe block size of the current mode.
-
-
Constructor Details
-
OpenSSLEvpCipher
-
-
Method Details
-
engineInitInternal
void engineInitInternal(byte[] encodedKey, AlgorithmParameterSpec params, SecureRandom random) throws InvalidKeyException, InvalidAlgorithmParameterException Description copied from class:OpenSSLCipherAPI-specific implementation of initializing the cipher. TheOpenSSLCipher.isEncrypting()function will tell whether it should be initialized for encryption or decryption. TheencodedKeywill be the bytes of a supported key size.- Specified by:
engineInitInternalin classOpenSSLCipher- Throws:
InvalidKeyExceptionInvalidAlgorithmParameterException
-
updateInternal
int updateInternal(byte[] input, int inputOffset, int inputLen, byte[] output, int outputOffset, int maximumLen) throws ShortBufferException Description copied from class:OpenSSLCipherAPI-specific implementation of updating the cipher. ThemaximumLenwill 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:
updateInternalin classOpenSSLCipher- Throws:
ShortBufferException
-
doFinalInternal
int doFinalInternal(byte[] output, int outputOffset, int maximumLen) throws IllegalBlockSizeException, BadPaddingException, ShortBufferException Description copied from class:OpenSSLCipherAPI-specific implementation of the final block. ThemaximumLenwill 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:
doFinalInternalin classOpenSSLCipher- Throws:
IllegalBlockSizeExceptionBadPaddingExceptionShortBufferException
-
getOutputSizeForFinal
int getOutputSizeForFinal(int inputLen) Description copied from class:OpenSSLCipherThe 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:
getOutputSizeForFinalin classOpenSSLCipher
-
getOutputSizeForUpdate
int getOutputSizeForUpdate(int inputLen) Description copied from class:OpenSSLCipherThe 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:
getOutputSizeForUpdatein classOpenSSLCipher
-
getCipherName
Returns the OpenSSL cipher name for the particularkeySizeand ciphermode. -
reset
private void reset()Reset this Cipher instance state to process a new chunk of data.
-