paragonie / EasyRSA

Simple and Secure Wrapper for phpseclib
https://paragonie.com
MIT License
198 stars 34 forks source link

[ISSUE] Decryption failed with Message encrypted by Public Key generated by Mailvelope #15

Closed vzool closed 6 years ago

vzool commented 6 years ago

Hi,

I tried to encrypt content with RSA/4096 key generated by Mailvelope, then the web server send the encrypted message to my email, in order to use Mailvelope to decrypt and read server message from my mail box directly without copy and paste everytime. But, it fails to be decypted by Mailvelope look here:

Error message:

screenshot from 2018-07-02 11-56-05

I even tried to add a header and footer for the encrypted message like this:

-----BEGIN PGP MESSAGE-----
EzR2$$3vUCAOMixWpGR7SRCF8w6WF3I4EwmFTmy4tytt+dmakTHeMadtkuJnWSEMeq5uM6hGy/dUEyZY/3oqcGC+ZqYFNlSjumeXDamrpZWgCiBrj1j2mCLIJ5Y3p7iA0ad1c=$d7a8998ed2d71e1d
-----END PGP MESSAGE-----

And error message changed to something else, look here:

screenshot from 2018-07-02 11-54-51

I add a new line after header line, like this:

-----BEGIN PGP MESSAGE-----

EzR2$$3vUCAOMixWpGR7SRCF8w6WF3I4EwmFTmy4tytt+dmakTHeMadtkuJnWSEMeq5uM6hGy/dUEyZY/3oqcGC+ZqYFNlSjumeXDamrpZWgCiBrj1j2mCLIJ5Y3p7iA0ad1c=$d7a8998ed2d71e1d
-----END PGP MESSAGE-----

And error message changed again, look here:

screenshot from 2018-07-02 12-08-28

Snippet to generate encrypted message:

$message = "Hello World";
$public = new ParagonIE\EasyRSA\PublicKey(file_get_contents("keys/Debugging_pub.asc"));
$cipher_message = ParagonIE\EasyRSA\EasyRSA::encrypt($message, $public);

keys/Debugging_pub.asc

-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: Mailvelope v2.2.2
Comment: https://www.mailvelope.com

xsFNBFs533ABEACzNdFO7J5VDmrCz8XP9j2CmCasBCM8rOU+OcXIn/zkch9f
5dE/wy0dC7antytGax6lc6dQTdiu7u0vqIz5iML6LHtpV61kUSdyM3QpU+DZ
xRtA8+p6w6AzDk4DapQaybvT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FVkZ0qWJl8grXkzjLjn5knBV/Alblk16pb/MvX/uw6yCHdsB+h
rUjXEi+n7GD0Jv/3Aia1E2/zWeU0NCqvtlvb8i8Mm0Kw72OPoeZZDAPldvKR
Zxsdth69xLuLSqiOd1RSuQ+7d+ZL9kQZq6nZU/p4aBLBYdNHz7u27aRn3GLe
UimZImPByZTaoUaSn8nxXCmsT4OKpymYU8ZmaDI2e9aLJ+oHVwurDyHVwmfX
4T/XJEMrXktp3IPdST87qf/2TPcMR1z2qyr7h/a5jbN8ojFQFv9t7+IgF3BZ
EdT4HPok/OFZFQ1N7vyzMoJgP3UC6MYTx9gX3msF1j4Do19gSxYgki7rKyyT
4PAyHqc/Y1TgpV7uI4NdfatL0t8UBOFfA9KKchA8XxTvDmS8PVV37bUtRJhN
TV0jgHhjjNFGcwyffl7z08qfucWK82/Qm+QMBHYyavvYYDAj7WIOggrEtoje
OgqdwCEyNMLa3j8Sb6mArj69+C/qjanrc1mPtJK/KaKc1xga3UoN3r0eB3Sw
ybaMcqIMXd1tJrizYciDjEfyeSl/Ba7qx80nmwLpJBEr3TWC0iOmJwcmdBAl
ncE0gDOANoSewIZJvovi1xmixWmTyDCR4QgdpLVrq1XtLrY+h8OTtmVk8LJ4
kIh7Gdrpglua
=mpfx
-----END PGP PUBLIC KEY BLOCK-----

As I think the library itself didn't complaint about the public key and the encryption process just done fine.

What I missed here, could anyone help me out?

Thanks

paragonie-scott commented 6 years ago

I tried to encrypt content with RSA/4096 key generated by Mailvelope

I don't think OpenGPG is compatible with our encryption format.

paragonie-scott commented 6 years ago

Instead of EasyRSA (which is only compatible with itself), consider switching to https://github.com/paragonie/gpg-mailer instead.

paragonie-scott commented 6 years ago

I've updated the readme to make this clearer. https://github.com/paragonie/EasyRSA#compatibility

vzool commented 6 years ago

Oh, great ... This is so fantastic. Thanks you very much <3