I'm trying to decode with pidCrypt some data which has been encrypted with openssl, and I have a few problems. Here is what I'm doing server-side:
# Generate encrypted private key.
openssl genrsa -aes256 -out private.key
# Extract public key from private key.
openssl rsa -in private.key -pubout > public.key
# Encrypt with public key, and encode in Base64
echo 'Hello Trac!' | openssl rsautl -encrypt -pubin -inkey public.key | base64 > encrypted_with_public_key
My goal is to decrypt the content of file "encrypted_with_public_key" with pidCrypt, the private key, and the password chosen to encrypt the private key.
I was able to decode my rsa encrypted string by using a hack I still don't understand, after noticing a bunch of "f" at the end of the cipher, just before decryption.
I tried all combinations of openssl paddings, but none seems to work. In particular, here are the openssl options I have tried:
-pkcs: (the default) works with my hack, doesn't work without.
-oaep: doesn't work at all, with or without hack.
-ssl: works with my hack, doesn't work without.
-raw: doesn't work at all, with or without hack.
Using OpenSSL 1.0.1e 11 Feb 2013, on Debian SID.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Sorry, this was my fault from the beginning: I'm reading the encoded password through jquery, and I didn't take care of a few empty characters in the HTML file, which used to look like:
Hi,
I'm trying to decode with pidCrypt some data which has been encrypted with openssl, and I have a few problems. Here is what I'm doing server-side:
My goal is to decrypt the content of file "encrypted_with_public_key" with pidCrypt, the private key, and the password chosen to encrypt the private key.
Here is the javascript code I'm using:
Plaintext return is always empty. But key decoding seems to work. Do you see any reason why this shouldn't work?
Thanks!
I was able to decode my rsa encrypted string by using a hack I still don't understand, after noticing a bunch of "f" at the end of the cipher, just before decryption.
I might have unneeded trailing characters in my encoded string.
It might be a padding issue. Please try using PKCS#1 v1.5 (see https://www.openssl.org/docs/apps/rsautl.html).
We demonstrate a working example in this thread. Please let us know if this does not solve your issue.
Best,
Jonah
Hi,
I tried all combinations of openssl paddings, but none seems to work. In particular, here are the openssl options I have tried:
Using OpenSSL 1.0.1e 11 Feb 2013, on Debian SID.
Sorry, this was my fault from the beginning: I'm reading the encoded password through jquery, and I didn't take care of a few empty characters in the HTML file, which used to look like:
Works fine like so:
Sorry for that! :)
No problem and we're glad you have figured it out!