Package org.conscrypt
Class OpenSSLCipherChaCha20
- java.lang.Object
-
- javax.crypto.CipherSpi
-
- org.conscrypt.OpenSSLCipher
-
- org.conscrypt.OpenSSLCipherChaCha20
-
@Internal public class OpenSSLCipherChaCha20 extends OpenSSLCipher
Implementation of the ChaCha20 stream cipher.
-
-
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 static intBLOCK_SIZE_BYTESprivate intblockCounterprivate intcurrentBlockConsumedBytesprivate static intNONCE_SIZE_BYTES-
Fields inherited from class org.conscrypt.OpenSSLCipher
encodedKey, iv, mode
-
-
Constructor Summary
Constructors Constructor Description OpenSSLCipherChaCha20()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) voidcheckSupportedKeySize(int keySize)Checks whether the cipher supports this particularkeySize(in bytes) and throwsInvalidKeyExceptionif it doesn't.(package private) voidcheckSupportedMode(OpenSSLCipher.Mode mode)Checks whether the cipher supports this particular ciphermodeand throwsNoSuchAlgorithmExceptionif it doesn't.(package private) voidcheckSupportedPadding(OpenSSLCipher.Padding padding)Checks whether the cipher supports this particular cipherpaddingand throwsNoSuchPaddingExceptionif it doesn't.(package private) intdoFinalInternal(byte[] output, int outputOffset, int maximumLen)API-specific implementation of the final block.(package private) voidengineInitInternal(byte[] encodedKey, java.security.spec.AlgorithmParameterSpec params, java.security.SecureRandom random)API-specific implementation of initializing the cipher.(package private) java.lang.StringgetBaseCipherName()Returns the standard name for the particular algorithm.(package private) intgetCipherBlockSize()(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()(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
engineDoFinal, engineDoFinal, engineGetBlockSize, engineGetIV, engineGetKeySize, engineGetOutputSize, engineGetParameters, engineInit, engineInit, engineInit, engineSetMode, engineSetPadding, engineUnwrap, engineUpdate, engineUpdate, engineWrap, getPadding, getParameterSpec, isEncrypting, supportsVariableSizeIv, supportsVariableSizeKey
-
-
-
-
Field Detail
-
BLOCK_SIZE_BYTES
private static final int BLOCK_SIZE_BYTES
- See Also:
- Constant Field Values
-
NONCE_SIZE_BYTES
private static final int NONCE_SIZE_BYTES
- See Also:
- Constant Field Values
-
currentBlockConsumedBytes
private int currentBlockConsumedBytes
-
blockCounter
private int blockCounter
-
-
Method Detail
-
engineInitInternal
void engineInitInternal(byte[] encodedKey, java.security.spec.AlgorithmParameterSpec params, java.security.SecureRandom random) throws java.security.InvalidKeyException, java.security.InvalidAlgorithmParameterExceptionDescription 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:
java.security.InvalidKeyExceptionjava.security.InvalidAlgorithmParameterException
-
updateInternal
int updateInternal(byte[] input, int inputOffset, int inputLen, byte[] output, int outputOffset, int maximumLen) throws javax.crypto.ShortBufferExceptionDescription 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:
javax.crypto.ShortBufferException
-
doFinalInternal
int doFinalInternal(byte[] output, int outputOffset, int maximumLen) throws javax.crypto.IllegalBlockSizeException, javax.crypto.BadPaddingException, javax.crypto.ShortBufferExceptionDescription 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:
javax.crypto.IllegalBlockSizeExceptionjavax.crypto.BadPaddingExceptionjavax.crypto.ShortBufferException
-
reset
private void reset()
-
getBaseCipherName
java.lang.String getBaseCipherName()
Description copied from class:OpenSSLCipherReturns the standard name for the particular algorithm.- Specified by:
getBaseCipherNamein classOpenSSLCipher
-
checkSupportedKeySize
void checkSupportedKeySize(int keySize) throws java.security.InvalidKeyExceptionDescription copied from class:OpenSSLCipherChecks whether the cipher supports this particularkeySize(in bytes) and throwsInvalidKeyExceptionif it doesn't.- Specified by:
checkSupportedKeySizein classOpenSSLCipher- Throws:
java.security.InvalidKeyException
-
checkSupportedMode
void checkSupportedMode(OpenSSLCipher.Mode mode) throws java.security.NoSuchAlgorithmException
Description copied from class:OpenSSLCipherChecks whether the cipher supports this particular ciphermodeand throwsNoSuchAlgorithmExceptionif it doesn't.- Specified by:
checkSupportedModein classOpenSSLCipher- Throws:
java.security.NoSuchAlgorithmException
-
checkSupportedPadding
void checkSupportedPadding(OpenSSLCipher.Padding padding) throws javax.crypto.NoSuchPaddingException
Description copied from class:OpenSSLCipherChecks whether the cipher supports this particular cipherpaddingand throwsNoSuchPaddingExceptionif it doesn't.- Specified by:
checkSupportedPaddingin classOpenSSLCipher- Throws:
javax.crypto.NoSuchPaddingException
-
getCipherBlockSize
int getCipherBlockSize()
- Specified by:
getCipherBlockSizein classOpenSSLCipher
-
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
-
-