Closed koolsys closed 6 years ago
@koolsys The problem fixed in latest release. Also please use a correct latest example code - seems you are using old one, or probably adopted somehow code from live example on pkijs.org.
BTW - please notice that at the moment there is a problem with binary encoding in emailjs-mime-parser
package. And that is why your S/MIME data must contain Content-Type: charset=binary
. Without it you would see a strange side bugs
like unable to decode
or other weird messages.
@koolsys I have updated this example - now you could set any RSA-OAEP hashing algorithm, it is not limited to SHA-512
only anymore.
Moreover, this example was also updated with RSA-OAEP hashing algorithm choice.
That was some very fast turn-around, I'm impressed. Also I can confirm bi-directional encryption and decryption between OpenSSL and PKI.js example for S/MIME encoding.
Using the example in SMIMEEncryptionExample I'm able to decode the message with OpenSSL using:
openssl cms -decrypt -aes-128-cbc -inkey cmskey.pem
However, when I try to decode a message generated by openssl in the PKIjs example I receive an error:
I replaced all instances of "innerHTML" with "value" in the "bundle.js" file so the example would accept user input for keys and encrypted messages.
The OpenSSL command used to make the message is this:
openssl cms -encrypt -in text2.txt -from sender@example.com -to recipient@example.com -subject Testing -aes-128-cbc -recip cmscert.pem -keyopt rsa_padding_mode:oeap
I used the following command to look at the message structures:
openssl cms -decrypt -aes-128-cbc -inkey cmskey.pem -noout -cmsout -print
I noticed the PKIjs example seems to use RSA-OEAP-512 without any obvious way to switch the behavior in the example code. OpenSSL documentation states it uses SHA1 for RSA-OAEP, and I've seen some other areas stating this is the standard. Specifically there's this forum post stating it's hard coded, and it seems to still be hard coded.
I also noticed the PKIjs example marks d.envelopedData.version as 2, and openssl leaves it unassigned.
Here's the parsed cms structure outputs of the messages:
PKIjs:
OpenSSL: