B4J Question B4XEncryption and jB4XEncryption interoperability

yo3ggx

Active Member
Licensed User
Longtime User
Hello,

I'm using B4XEncryption library on Android for encryption and jB4XEncryption in B4J for decryption.
I get the following error when trying to decrypt in B4J:
org.bouncycastle.crypto.InvalidCipherTextException: pad block corrupted:

If I encrypt/decrypt in B4A and in B4J separately, everything is working as expected.
Tried different bouncycastle jars in B4J, from 15 to 18 with the same result.
Both B4A (13.10) and B4J (10.20) use OpenJDK 19.

I decided to migrate from the old Encryption library (used successfully at both ends) to the newer B4XEncryption after the old one stopped to work after upgrading OpenJDK in B4J from 11 to 19.
Any hints?

Thank you.
Dan
 
Last edited:

yo3ggx

Active Member
Licensed User
Longtime User
As stated in my email, that test works perfectly on both B4A and B4J, the problem is when I encrypt on Android and try to decrypt on Java.
With the old Encrypt library is working, with the B4X library don't. I'm transferring encrypted data over the network as a byte array.
 
Upvote 0

yo3ggx

Active Member
Licensed User
Longtime User
Tested on Android 13. The problem is that the byte array (encoded data) is checked on both sides and is the same. If I decode it locally it works, remotely not. What bouncycastle jar version are you using for jB4XEncryption?
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
The problem is that the byte array (encoded data) is checked on both sides and is the same. If I decode it locally it works, remotely not.
This is exactly what I did in the example project. Take the base64 string (=encoded bytes) from B4J and put it in B4A code. Or vice versa.

bouncycastle jar version are you using for jB4XEncryption?
#AdditionalJar: bcprov-jdk15on-154
 
Upvote 0

yo3ggx

Active Member
Licensed User
Longtime User
This is exactly what I did in the example project. Take the base64 string (=encoded bytes) from B4J and put it in B4A code. Or vice versa.


#AdditionalJar: bcprov-jdk15on-154
I'm using bcprov-jdk15to18-1.80, but tried with bcmail-jdk18on-180 and bcmail-lts8on-2.73.7 with the same result (with just some changes in the reported errors).
I will check with bcprov-jdk15on-154, as for the moment I returned to the old Encryption library.

Thank you.
 
Upvote 0
Top