public int processBlock(byte[] in, int inOff, byte[] out, int outOff)
        throws DataLengthException, IllegalStateException {
        
        int blockLenByte = stateSize / 8;
        int blockLenLong = stateSize / 64;
        
        if (cipher.expanedKey == null)
        {
            throw new IllegalStateException("Threefish: engine not initialised");
        }

        if ((inOff + blockLenByte) > in.length)
        {
            throw new DataLengthException("Threefish: input buffer too short");
        }

        if ((outOff + blockLenByte) > out.length)
        {
            throw new DataLengthException("Threefish: output buffer too short");
        }
        for (int i = 0; i < blockLenLong; i++)
            cipherIn[i] = ByteLong.GetUInt64(in, inOff + i * 8);

        if (forEncryption)
        {
            cipher.encrypt(cipherIn, cipherOut);
        }
        else
        {
            cipher.decrypt(cipherIn, cipherOut);
        }
        ByteLong.PutBytes(cipherOut, out, outOff, blockLenByte);

        return stateSize / 8;
    }