-
Notifications
You must be signed in to change notification settings - Fork 310
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to decrypt in Java after having encrypted via defuse/php-encryption #331
Comments
I think the Java code in the stackoverflow post is wrong, because it tries to interpret a SHA256 hash as a UTF-8 string in the line |
Maybe but we tried to implement in Java without doing this UTF-8 interpretation of the prehash you mentioned and it didn't give the expected result, meaning we can't decrypt the chain. |
Googling around a bit, you might be able to get by parsing the hash as ISO-8859-1 instead of UTF-8, or even simply just create a Since this library doesn't aim to be compatible with other implementation languages (libsodium is a good replacement for that use case), I'm going to close this ticket as "wontfix, it's Java's fault if its abstractions prevent you from computing the function on inputs that are valid according to the RFC." |
Alright, I understand your point. Thank you for your answers, I will try to parse using the ISO-8859-1 charset. Regards, |
Thanks! Please let us know if it works :-) |
Will do!
Le 25 mars 2017 6:24 PM, "Taylor Hornby" <[email protected]> a
écrit :
… Thanks! Please let us know if it works :-)
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#331 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AG63FbHeqlFUKd_dSlgs35w3SoUhDJeyks5rpU3MgaJpZM4MoXoW>
.
|
Unfortunately, this doesn't solve the problem ; the char array given to PBEKeySpec Java class is now identical to what we can find in php. Like you suggest, we first have ensured that the low 8 bits of the chars are the same as the 8 bits of the bytes doing this : |
Hi,
As explained in this stackoverflow post ; we stumbled upon the same issue while trying to decrypt a chain using built-in cryptographic functions in Java after having encrypted this chain at first using defuse/php-encryption.
The update of this post gave us a workaround which is to by-pass the prehash in sha256 step and thus directly pass secret to Core::pbkdf2 function.
As mentioned into inline comments, this prehash step appears to prevent a DoS attack documented in the GitHub issue #230 but somehow, this makes the decryption in a Java implementation impossible.
Many thanks though, cheers.
The text was updated successfully, but these errors were encountered: