Package org.conscrypt

Class OpenSSLCipherChaCha20


  • @Internal
    public class OpenSSLCipherChaCha20
    extends OpenSSLCipher
    Implementation of the ChaCha20 stream cipher.
    • Field Detail

      • currentBlockConsumedBytes

        private int currentBlockConsumedBytes
      • blockCounter

        private int blockCounter
    • Constructor Detail

      • OpenSSLCipherChaCha20

        public OpenSSLCipherChaCha20()
    • 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. The OpenSSLCipher.isEncrypting() function will tell whether it should be initialized for encryption or decryption. The encodedKey will be the bytes of a supported key size.
        Specified by:
        engineInitInternal in class OpenSSLCipher
        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. The maximumLen will be the maximum length of the output as returned by OpenSSLCipher.getOutputSizeForUpdate(int). The return value must be the number of bytes processed and placed into output. On error, an exception must be thrown.
        Specified by:
        updateInternal in class OpenSSLCipher
        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. The maximumLen will be the maximum length of the possible output as returned by OpenSSLCipher.getOutputSizeForFinal(int). The return value must be the number of bytes processed and placed into output. On error, an exception must be thrown.
        Specified by:
        doFinalInternal in class OpenSSLCipher
        Throws:
        javax.crypto.IllegalBlockSizeException
        javax.crypto.BadPaddingException
        javax.crypto.ShortBufferException
      • reset

        private void reset()
      • getBaseCipherName

        java.lang.String getBaseCipherName()
        Description copied from class: OpenSSLCipher
        Returns the standard name for the particular algorithm.
        Specified by:
        getBaseCipherName in class OpenSSLCipher
      • checkSupportedKeySize

        void checkSupportedKeySize​(int keySize)
                            throws java.security.InvalidKeyException
        Description copied from class: OpenSSLCipher
        Checks whether the cipher supports this particular keySize (in bytes) and throws InvalidKeyException if it doesn't.
        Specified by:
        checkSupportedKeySize in class OpenSSLCipher
        Throws:
        java.security.InvalidKeyException
      • checkSupportedMode

        void checkSupportedMode​(OpenSSLCipher.Mode mode)
                         throws java.security.NoSuchAlgorithmException
        Description copied from class: OpenSSLCipher
        Checks whether the cipher supports this particular cipher mode and throws NoSuchAlgorithmException if it doesn't.
        Specified by:
        checkSupportedMode in class OpenSSLCipher
        Throws:
        java.security.NoSuchAlgorithmException
      • checkSupportedPadding

        void checkSupportedPadding​(OpenSSLCipher.Padding padding)
                            throws javax.crypto.NoSuchPaddingException
        Description copied from class: OpenSSLCipher
        Checks whether the cipher supports this particular cipher padding and throws NoSuchPaddingException if it doesn't.
        Specified by:
        checkSupportedPadding in class OpenSSLCipher
        Throws:
        javax.crypto.NoSuchPaddingException
      • getOutputSizeForFinal

        int getOutputSizeForFinal​(int inputLen)
        Description copied from class: OpenSSLCipher
        The size of output if doFinal() is called with this inputLen. 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 class OpenSSLCipher
      • getOutputSizeForUpdate

        int getOutputSizeForUpdate​(int inputLen)
        Description copied from class: OpenSSLCipher
        The size of output if update() is called with this inputLen. 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 class OpenSSLCipher