I am trying to create a encrypted Derby
Db using com.ibm.j9.jce.provider.J9JCEProvider. This JCE provider
comes with IBM's J9 JRE. I am using J9 JCL Max and this J9 comes with j9jceprov.jar
which is a JCEProvider.
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
public int encrypt(byte cleartext,
int offset, int length, byte ciphertext, int outputOffset) method
is throwing this 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. Now after this
change if you check the Debug statements printed in attached OutPut.txt
then you will find that length of ciphertext array and out put of
cipher.getOutputSize(length) is always same and its still throwing ShortBufferException.
And in that case it should not throw this exception.
For your reference I am also attaching
my test class which is JDBCTest.java. Please also note that I am using
J9 as my JRE.
If I run the same test program with
IBM 1.4.2 JRE and use either IBMJCE provider (which comes with IBM JRE
1.4.2) or BouncyCastleProvider its working fine and I can successfully
create the encrypted database.
Can anyone please help me with this
strange problem? Is it the problem with com.ibm.j9.jce.provider.J9JCEProvider
I am using ?
Thanks and Regards,