<div dir="ltr"><font face="monospace">I am not sure why the code you have shared is trying to decrypt the signature. </font><div><font face="monospace">If it is done as part of signature verification, don't do this. Use the actual EVP_PKEY_verify API with corresponding public key.</font><div><font face="monospace"><br></font></div><div><font face="monospace">If you certainly need the decrypted signature, you should do public encryption with NONE padding.<br></font><div><font face="monospace">A Private key is not necessary.</font></div><div><font face="monospace"><br></font></div><div><font face="monospace">Thanks,</font></div><div><font face="monospace">Thulasi</font></div></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, 29 Jan 2021 at 17:47, Narayana, Sunil Kumar <<a href="mailto:sanarayana@rbbn.com">sanarayana@rbbn.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">





<div lang="EN-IN" style="word-wrap:break-word">
<div class="gmail-m_-7424277747695029927WordSection1">
<p class="MsoNormal"><span>Yeah, it sounds correct. But since it’s an old application code & we are not sure why was it done so, we are little worried to change.<u></u><u></u></span></p>
<p class="MsoNormal"><span>Can you please take a look the attachment which has the complete flow, and provide your views which helps us to change it to  </span><span style="font-family:"Courier New"">PEM_read_PrivateKey()
 or variants as you suggested</span><span> <u></u>
<u></u></span></p>
<p class="MsoNormal"><span><u></u> <u></u></span></p>
<p class="MsoNormal"><span>Regards,<u></u><u></u></span></p>
<p class="MsoNormal"><span>Sunil  <u></u><u></u></span></p>
<p class="MsoNormal"><span><u></u> <u></u></span></p>
<div>
<div style="border-style:solid none none;border-top-width:1pt;border-top-color:rgb(225,225,225);padding:3pt 0cm 0cm">
<p class="MsoNormal"><b><span lang="EN-US">From:</span></b><span lang="EN-US"> Thulasi Goriparthi <<a href="mailto:thulasi.goriparthi@gmail.com" target="_blank">thulasi.goriparthi@gmail.com</a>>
<br>
<b>Sent:</b> 29 January 2021 17:24<br>
<b>To:</b> Narayana, Sunil Kumar <<a href="mailto:sanarayana@rbbn.com" target="_blank">sanarayana@rbbn.com</a>><br>
<b>Cc:</b> <a href="mailto:openssl-users@openssl.org" target="_blank">openssl-users@openssl.org</a><br>
<b>Subject:</b> Re: <Replacement for RSA_public_decrypt><u></u><u></u></span></p>
</div>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
<div class="MsoNormal" align="center" style="text-align:center">
<hr size="2" width="100%" align="center">
</div>
<p class="MsoNormal">NOTICE: This email was received from an EXTERNAL sender<u></u><u></u></p>
<div class="MsoNormal" align="center" style="text-align:center">
<hr size="2" width="100%" align="center">
</div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New"">Isn't it obvious to use PEM_read_PrivateKey() or variants to load the private key as EVP_PKEY </span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New"">and use EVP_PKEY_decrypt* as specified in
<a href="https://protect-us.mimecast.com/s/pIHaCqx23xSzZMNwiZOok8?domain=openssl.org" target="_blank">
https://www.openssl.org/docs/man1.0.2/man3/EVP_PKEY_decrypt.html</a> ?</span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New"">Thanks,</span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New"">Thulasi.</span><u></u><u></u></p>
</div>
</div>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<div>
<p class="MsoNormal">On Fri, 29 Jan 2021 at 16:59, Narayana, Sunil Kumar <<a href="mailto:sanarayana@rbbn.com" target="_blank">sanarayana@rbbn.com</a>> wrote:<u></u><u></u></p>
</div>
<blockquote style="border-style:none none none solid;border-left-width:1pt;border-left-color:rgb(204,204,204);padding:0cm 0cm 0cm 6pt;margin-left:4.8pt;margin-right:0cm">
<div>
<div>
<p class="MsoNormal">Hi Thulasi,<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal">Currently in (1.0.1) we are following the following sequence, which now need to replace with EVP.<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal"><u>Current sequence</u><u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal">//to create RSA pubkey<u></u><u></u></p>
<p class="MsoNormal">rsa = PEM_read_bio_RSA_PUBKEY(keybio, NULL, NULL, NULL);  // !!!
<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal">//to decrypt using RSA utility<u></u><u></u></p>
<p class="MsoNormal">RSA_public_decrypt(len, (unsigned char*)buffer,decrypted,rsa, RSA_PKCS1_PADDING) ;<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal">As you mentioned , if we use
<span style="font-family:"Courier New";color:black;background-color:rgb(248,248,248);background-position:initial initial;background-repeat:initial initial">PEM_read_bio_PUBKEY to get EVP_PKEY, it will be a pubkey right ? but in order to decrypt as per the example in
<a href="https://protect-us.mimecast.com/s/iJORCrkY3ki1EBZJTzdO87?domain=openssl.org" target="_blank">
https://www.openssl.org/docs/manmaster/man3/EVP_PKEY_decrypt_init.html</a></span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-family:"Courier New";color:black;background-color:rgb(248,248,248);background-position:initial initial;background-repeat:initial initial">We need to use an RSA private key</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-family:"Courier New";color:black;background-color:rgb(248,248,248);background-position:initial initial;background-repeat:initial initial"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-family:"Courier New";color:black;background-color:rgb(248,248,248);background-position:initial initial;background-repeat:initial initial">Please suggest.</span><u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal">Regards,<u></u><u></u></p>
<p class="MsoNormal">Sunil<u></u><u></u></p>
<div>
<div style="border-style:solid none none;border-top-width:1pt;border-top-color:rgb(225,225,225);padding:3pt 0cm 0cm">
<p class="MsoNormal"><b><span lang="EN-US">From:</span></b><span lang="EN-US"> Thulasi Goriparthi <<a href="mailto:thulasi.goriparthi@gmail.com" target="_blank">thulasi.goriparthi@gmail.com</a>>
<br>
<b>Sent:</b> 29 January 2021 13:07<br>
<b>To:</b> Narayana, Sunil Kumar <<a href="mailto:sanarayana@rbbn.com" target="_blank">sanarayana@rbbn.com</a>><br>
<b>Cc:</b> <a href="mailto:openssl-users@openssl.org" target="_blank">openssl-users@openssl.org</a><br>
<b>Subject:</b> Re: <Replacement for RSA_public_decrypt></span><u></u><u></u></p>
</div>
</div>
<p class="MsoNormal"> <u></u><u></u></p>
<div class="MsoNormal" align="center" style="text-align:center">
<hr size="2" width="100%" align="center">
</div>
<p class="MsoNormal">NOTICE: This email was received from an EXTERNAL sender<u></u><u></u></p>
<div class="MsoNormal" align="center" style="text-align:center">
<hr size="2" width="100%" align="center">
</div>
<p class="MsoNormal"> <u></u><u></u></p>
<div>
<div>
<div>
<div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New";color:black;background-color:rgb(248,248,248);background-position:initial initial;background-repeat:initial initial">Hope, you are referring to </span><span style="font-family:"Courier New";color:black"><a href="https://protect-us.mimecast.com/s/v2osCv2j32i2xk8Vtz2d4K?domain=openssl.org" target="_blank">https://www.openssl.org/docs/man1.0.2/man3/EVP_PKEY_encrypt.html</a></span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New"">Use <span style="color:black;background-color:rgb(248,248,248);background-position:initial initial;background-repeat:initial initial">PEM_read_bio_PUBKEY to get EVP_PKEY.</span></span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New";color:black;background-color:rgb(248,248,248);background-position:initial initial;background-repeat:initial initial">eng is for engine reference. If you have no engine, it can be NULL.</span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New"">Thanks,</span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New"">Thulasi.</span><u></u><u></u></p>
</div>
</div>
</div>
</div>
</div>
<p class="MsoNormal"> <u></u><u></u></p>
<div>
<div>
<p class="MsoNormal">On Fri, 29 Jan 2021 at 10:13, Narayana, Sunil Kumar <<a href="mailto:sanarayana@rbbn.com" target="_blank">sanarayana@rbbn.com</a>> wrote:<u></u><u></u></p>
</div>
<blockquote style="border-style:none none none solid;border-left-width:1pt;border-left-color:rgb(204,204,204);padding:0cm 0cm 0cm 6pt;margin:5pt 0cm 5pt 4.8pt">
<div>
<p class="MsoNormal" style="background-color:white;background-position:initial initial;background-repeat:initial initial">
<span style="color:rgb(33,33,33)">Dear Openssl team,</span><u></u><u></u></p>
<p class="MsoNormal" style="background-color:white;background-position:initial initial;background-repeat:initial initial">
<span style="color:rgb(33,33,33)"> </span><u></u><u></u></p>
<div>
<p class="MsoNormal">                While migrating from 1.0.2 to 3.0 we observe that RSA_public_decrypt() API been deprecated in 3.0.<u></u><u></u></p>
<p class="MsoNormal">We referred the example provided in man page but we are not clear in generating the initial ‘key’ required to create CTX.
<u></u><u></u></p>
<p class="MsoNormal">Please suggest on (key , eng) params to proceed
<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal">Also currently we are using PEM_read_bio_RSA_PUBKEY() to generate RSA, I think this might not require in case of EVP, please suggest.<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal">/*<u></u><u></u></p>
<p class="MsoNormal">  * NB: assumes key, eng, in, inlen are already set up<u></u><u></u></p>
<p class="MsoNormal">  * and that key is an RSA private key<u></u><u></u></p>
<p class="MsoNormal">  */<u></u><u></u></p>
<p class="MsoNormal">ctx = EVP_PKEY_CTX_new(key, eng);<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal">Regards,<u></u><u></u></p>
<p class="MsoNormal">Sunil<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal"><br>
Notice: This e-mail together with any attachments may contain information of Ribbon Communications Inc. and its Affiliates that is confidential and/or proprietary for the sole use of the intended recipient. Any review, disclosure, reliance or distribution by
 others or forwarding without express permission is strictly prohibited. If you are not the intended recipient, please notify the sender immediately and then delete all copies, including any attachments.<u></u><u></u></p>
</div>
</blockquote>
</div>
</div>
<p class="MsoNormal"><br>
Notice: This e-mail together with any attachments may contain information of Ribbon Communications Inc. and its Affiliates that is confidential and/or proprietary for the sole use of the intended recipient. Any review, disclosure, reliance or distribution by
 others or forwarding without express permission is strictly prohibited. If you are not the intended recipient, please notify the sender immediately and then delete all copies, including any attachments.<u></u><u></u></p>
</div>
</blockquote>
</div>
</div>
<br clear="both">
Notice: This e-mail together with any attachments may contain information of Ribbon Communications Inc. and its Affiliates that is confidential and/or proprietary for the sole use of the intended recipient. Any review, disclosure, reliance or distribution by others or forwarding without express permission is strictly prohibited. If you are not the intended recipient, please notify the sender immediately and then delete all copies, including any attachments.<br>
</div>


</blockquote></div>