db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sunitha Kambhampati <ksunitha...@gmail.com>
Subject Re: Getting : javax.crypto.ShortBufferException while creating a encrypted database
Date Thu, 13 Jul 2006 17:03:22 GMT
Supal J Patel wrote:

> To debug the problem I downloaded Derby source and successfully set up 
> a local development environment. While looking at the source code I 
> found that  in org.apache.derby.impl.services.jce.JCECipherProvider 
> class'
> public int encrypt(byte[] cleartext, int offset, int length,  byte[] 
> ciphertext, int outputOffset) method is throwing this exception. 

It might be helpful if you can post the derby.log and stack traces for 
the original exception.

> I understand that this exception is thrown when  the given output 
> buffer is too small to hold the result . Thats why I updated this 
> method as attached in Updated_Encrypt_Method.txt to make sure that 
> outbuffer is always sufficient. 
In this case, I'd expect the caller of the encrypt method to pass the 
ciphertext with correct size.  doFinal is taking the outputOffset, so 
ciphertext size should take of the outputOffset also.

Since you have the development environment already setup, maybe you can 
run this with sane mode. (ant clobber; ant sane; ant all)

 There are actually some assert statements in the encrypt method that 
would throw errors if the ciphertext array was of insufficient size.  
Another thing to try is to print out the parameter values that are 
passed in this method and to print out the stack traces in encrypt when 
the exception is hit.  
      System.out.println("encrypt method called : cleartext = " + 
cleartext.length + " ciphertext = " + ciphertext.length + " offset : " + 
offset + " length : " + length + " outputOffset: "+ outputOffset ); 
When this exception is hit, what is the value of arguments to encrypt 
method ?

 I dont have the j9 jce provider, so cannot try it out to see what could 
be happening.  But maybe someone else on the list can try it out. So 
please post your findings on the list.


View raw message