<div dir="auto"><div>Do you mean RSA OAEP decryption done by HSM fails?</div><div dir="auto"><br></div><div dir="auto">Possible tests:</div><div dir="auto">1. Try RSA OAEP encryption/decryption with HSM. - basic test.</div><div dir="auto">2. Encrypt with HSM and decrypt using openssl crypto library. - To make sure RSA OAEP encryption of the HSM works fine.</div><div dir="auto">3. If test 2 fails, check if all the parameters (hash, mgf, salt length) used for OAEP are same on both sides. If they match and decryption still fails, check with your HSM vendor. If they don't, try fixing the parameters and repeat test 2.</div><div dir="auto"><br></div><div dir="auto">RSA_NO_PADDING always works as all it does is modular exponentiation.</div><div dir="auto"><br></div><div dir="auto">Thanks,</div><div dir="auto">Thulasi.<br><br><div class="gmail_quote" dir="auto"><div dir="ltr" class="gmail_attr">On Mon, 17 Feb, 2020, 19:22 RudyAC, <<a href="mailto:rpo@compumatica.com">rpo@compumatica.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
I have the requirement to decrypt e-mails where RSA-OAEP padding is used. I<br>
use the library openssl-1.0.2k and decrypt with CMS container (CMS_decrypt).<br>
This works very well unless the private key is stored in a Hardware security<br>
module and the cryptographic operation is performed via the PKCS11 engine<br>
from openssl.<br>
<br>
When decrypting an email which uses OAEP I got the error message:<br>
<br>
47235129370352:error:06065064:digital envelope<br>
routines:EVP_DecryptFinal_ex:bad decrypt:evp_enc.c:529:<br>
<br>
To analyze the problem I encrypted an clear text using OAEP padding and<br>
setup a decryption function using <br>
RSA_private_decrypt(). Here I use padding mode "RSA_NO_PADDING" and the<br>
decryption also works with the PKCS11 engine. Unfortunately CMS does not<br>
support setting the padding mode.<br>
<br>
For any comments I would be very grateful <br>
<br>
Regards Rudy <br>
<br>
<br>
<br>
--<br>
Sent from: <a href="http://openssl.6102.n7.nabble.com/OpenSSL-User-f3.html" rel="noreferrer noreferrer" target="_blank">http://openssl.6102.n7.nabble.com/OpenSSL-User-f3.html</a><br>
</blockquote></div></div></div>