[prev in list] [next in list] [prev in thread] [next in thread] 

List:       bouncycastle-crypto-dev
Subject:    Errors decrypting on MID
From:       "Darryl L. Pierce" <mcpierce () telocity ! com>
Date:       2002-10-21 16:25:17
[Download RAW message or body]

I'm using the BC code to do encryption between a PC client and a 
MIDlet. When I perform encryption using a simple key, it always works. 
However, I'm generating a secret key on the PC and passing it back to 
the MIDlet to use for further communications. When the MID uses that 
key to decrypt data, it _always_ blows up with a "pad block corrupted" 
exception. The exact same data, encrypted with the simple key, works 
every time.

The decryption code is:

---8<[snip]---

     private static byte[] decrypt(byte[] encrypted,byte[] key)
	throws InvalidCipherTextException
     {
	byte[] result = null;

	cipher.init(false,new KeyParameter(key));

	int length = cipher.getOutputSize(encrypted.length);
	result = new byte[length];

	int olen = 
cipher.processBytes(encrypted,0,encrypted.length,result,0);

	// the code blows up on this call when using the generated key
	cipher.doFinal(result,olen);

	return result;
     }
---8<[snip]---

I don't think it's a memory issue. The encrypted data is 22,485 bytes 
and the output size reported by the cipher is 22,475 bytes, which is 
the size of the data that was encrypted originally.

Any ideas on why this would fail? 
-- 
Darryl L. Pierce <mcpierce@telocity.com>
Visit the Infobahn Offramp - <http://welcome.to/mcpierce>
"What do you care what other people think, Mr. Feynman?"

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic