Package org.conscrypt

Class OpenSSLEvpCipher

    • Field Detail

      • 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.
    • 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
      • 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
      • getCipherName

        abstract java.lang.String getCipherName​(int keySize,
                                                OpenSSLCipher.Mode mode)
        Returns the OpenSSL cipher name for the particular keySize and cipher mode.
      • reset

        private void reset()
        Reset this Cipher instance state to process a new chunk of data.