gnu-crypto-discuss
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNU Crypto] Odd behavior from PKCS7


From: Ryan Senior
Subject: [GNU Crypto] Odd behavior from PKCS7
Date: 25 Nov 2003 13:05:39 -0600

Hello,

I'm using GNU-Crypto 1.1.0 on a project that I am working on and I'm
getting some weird things from PKCS7.  I'm encrypting data using the
Blowfish algorithm (with CBC) and padding the remaining data with PKCS7.

My problem comes about when I attempt to pad remaining bytes in a
block.  For whatever reason, PKCS7 is returning a byte array of length
252 instead of 5.  I am thinking there is probably something I am
overlooking in my code, but I can't figure out what it is.  I have tried
varying lengths of information to see maybe if there was just a problem
with return 5 bytes of padding, but I received the same errors with
similarly large returned arrays from PKCS7.


Attached is the class that's having problems.  It's specifically the
encryptStream() class.  

The output it gives is:

Current Block Size 8
Bytes available 3
leftOver length is 3
paddedTemp length is 252
inData length is 8
java.lang.ArrayIndexOutOfBoundsException
        at java.lang.System.arraycopy(Native Method)
        at GCISS_BE.encryptStream(GCISS_BE.java:99)


Everything looked normal until the paddedTemp length is 252.

Also, another question I have is that when I don't call pad.reset(), I
get a java.lang.IllegalStateException however the pad has NOT been
initialized yet.  I didn't think calling pad.reset() would hurt
anything, so I went ahead and did that and it fixed my problem, however
I was still wondering why I would get that if I just instantiated the
PKCS7 class.

Thanks for the help,

Ryan

Attachment: GCISS_BE.java
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]