<div dir="ltr"><div dir="ltr"><div dir="ltr"><font face="monospace">Isn't it obvious to use PEM_read_PrivateKey() or variants to load the private key as EVP_PKEY </font></div><div dir="ltr"><font face="monospace">and use EVP_PKEY_decrypt* as specified in <a href="https://www.openssl.org/docs/man1.0.2/man3/EVP_PKEY_decrypt.html">https://www.openssl.org/docs/man1.0.2/man3/EVP_PKEY_decrypt.html</a> ?</font></div><div dir="ltr"><font face="monospace"><br></font></div><div><font face="monospace">Thanks,</font></div><div><font face="monospace">Thulasi.</font></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, 29 Jan 2021 at 16:59, 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_-3850105345524427869WordSection1">
<p class="MsoNormal"><span>Hi Thulasi,<u></u><u></u></span></p>
<p class="MsoNormal"><span><u></u> <u></u></span></p>
<p class="MsoNormal"><span>Currently in (1.0.1) we are following the following sequence, which now need to replace with EVP.<u></u><u></u></span></p>
<p class="MsoNormal"><span><u></u> <u></u></span></p>
<p class="MsoNormal"><u><span>Current sequence<u></u><u></u></span></u></p>
<p class="MsoNormal"><u><span><u></u><span style="text-decoration:none"> </span><u></u></span></u></p>
<p class="MsoNormal"><span>//to create RSA pubkey<u></u><u></u></span></p>
<p class="MsoNormal"><span>rsa = PEM_read_bio_RSA_PUBKEY(keybio, NULL, NULL, NULL);  // !!!
<u></u><u></u></span></p>
<p class="MsoNormal"><span><u></u> <u></u></span></p>
<p class="MsoNormal"><span>//to decrypt using RSA utility<u></u><u></u></span></p>
<p class="MsoNormal"><span>RSA_public_decrypt(len, (unsigned char*)buffer,decrypted,rsa, RSA_PKCS1_PADDING) ;<u></u><u></u></span></p>
<p class="MsoNormal"><span><u></u> <u></u></span></p>
<p class="MsoNormal"><span>As you mentioned , if we use
</span><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://www.openssl.org/docs/manmaster/man3/EVP_PKEY_decrypt_init.html" target="_blank">
https://www.openssl.org/docs/manmaster/man3/EVP_PKEY_decrypt_init.html</a></span><span style="font-family:"Courier New";background-color:rgb(248,248,248);background-position:initial initial;background-repeat:initial initial"><u></u><u></u></span></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><span style="font-family:"Courier New";background-color:rgb(248,248,248);background-position:initial initial;background-repeat:initial initial"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New";background-color:rgb(248,248,248);background-position:initial initial;background-repeat:initial initial"><u></u> <u></u></span></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><span style="font-family:"Courier New";background-color:rgb(248,248,248);background-position:initial initial;background-repeat:initial initial"><u></u><u></u></span></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><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>
<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><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>
<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/C67CC73AG3hQlMmXs8mmvp?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-left:4.8pt;margin-right:0cm">
<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,<u></u><u></u></span></p>
<p class="MsoNormal" style="background-color:white;background-position:initial initial;background-repeat:initial initial"><span style="color:rgb(33,33,33)"><u></u> <u></u></span></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>
<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>