Example usage for javax.crypto IllegalBlockSizeException IllegalBlockSizeException

List of usage examples for javax.crypto IllegalBlockSizeException IllegalBlockSizeException

Introduction

In this page you can find the example usage for javax.crypto IllegalBlockSizeException IllegalBlockSizeException.

Prototype

public IllegalBlockSizeException(String msg) 

Source Link

Document

Constructs an IllegalBlockSizeException with the specified detail message.

Usage

From source file:org.opensc.pkcs11.spi.PKCS11CipherSpi.java

@Override
protected byte[] engineDoFinal(byte[] input, int off, int len)
        throws IllegalBlockSizeException, BadPaddingException {
    byte[] ret;//w  ww  . j  a  v  a  2 s .c  o  m

    try {
        if (this.mode == Cipher.DECRYPT_MODE)
            if (this.count == 0)
                ret = doDecryptNative(this.worker.getPvh(), this.worker.getSlotHandle(),
                        this.worker.getSessionHandle(), this.worker.getHandle(), input, off, len);
            else
                ret = doFinalDecryptNative(this.worker.getPvh(), this.worker.getSlotHandle(),
                        this.worker.getSessionHandle(), this.worker.getHandle(), input, off, len);
        else if (this.count == 0)
            ret = doEncryptNative(this.worker.getPvh(), this.worker.getSlotHandle(),
                    this.worker.getSessionHandle(), this.worker.getHandle(), input, off, len);
        else
            ret = doFinalEncryptNative(this.worker.getPvh(), this.worker.getSlotHandle(),
                    this.worker.getSessionHandle(), this.worker.getHandle(), input, off, len);

    } catch (PKCS11Exception e) {
        log.error("PKCS11Exception caught:", e);
        throw new IllegalBlockSizeException("PKCS11Exception caught:" + e);
    }
    this.count = 0;
    return ret;
}