<div dir="ltr"><div dir="ltr">Thanks for the Reply!!.<div>I have a doubt , is it necessary to create a duplicate method ?? , Actually in my case this custom "set" function would be called only once during system initialization &  we need to use those hardware accelerator functions for all the crypto operations to be done later. So here's what i did : </div><div>--</div><div>new code :</div><div>    static DH_METHOD *Intoto_DH_Method;<br>    static RSA_METHOD *Intoto_RSA_Method;<br>    static DSA_METHOD *Intoto_DSA_Method;<br><br>    void updatePublicKeyMethods()<br>    {    <br>        Intoto_DH_Method = (DH_METHOD *)DH_get_default_method();<br>        DH_meth_set_bn_mod_exp(Intoto_DH_Method, Intoto_DH_mod_exp);<br>        DH_set_default_method(Intoto_DH_Method);         

 << I guess, there's no need to set the same as default again ??

<br><br>        Intoto_RSA_Method = (RSA_METHOD *)RSA_get_default_method();<br>        RSA_meth_set_bn_mod_exp(Intoto_RSA_Method, Intoto_RSA_mod_exp);<br>        RSA_set_default_method(Intoto_RSA_Method);<br><br>        Intoto_DSA_Method = (DSA_METHOD *)DSA_get_default_method();<br>        DSA_meth_set_bn_mod_exp(Intoto_DSA_Method, Intoto_DSA_mod_exp);<br>        DSA_set_default_method(Intoto_DSA_Method);   <br>        return;<br>    } <br></div><div>--</div><div>old code :</div><div>    static DH_METHOD Intoto_DH_Method;<br>    static RSA_METHOD Intoto_RSA_Method;<br>    static DSA_METHOD Intoto_DSA_Method;<br><br>    void updatePublicKeyMethods()<br>    {    <br>        Intoto_DH_Method = *(DH_get_default_method());<br>        Intoto_DH_Method.bn_mod_exp = Intoto_DH_mod_exp;<br>        DH_set_default_method(&Intoto_DH_Method);<br><br>        Intoto_RSA_Method = *(RSA_get_default_method());<br>        Intoto_RSA_Method.bn_mod_exp = Intoto_RSA_mod_exp;<br>        RSA_set_default_method(&Intoto_RSA_Method);<br><br>        Intoto_DSA_Method = *(DSA_get_default_method());<br>        Intoto_DSA_Method.bn_mod_exp = Intoto_DSA_mod_exp;<br>        DSA_set_default_method(&Intoto_DSA_Method);<br><br>        return;<br>    } <br></div><div>--</div><div>Do you suggest any modifications, If any ??</div><div><br></div><div>Thanks,</div><div>Prudvi.</div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Dec 17, 2020 at 4:07 PM Tomas Mraz <<a href="mailto:tmraz@redhat.com">tmraz@redhat.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Thu, 2020-12-17 at 15:16 +0530, prudvi raj wrote:<br>
> Hi,<br>
> <br>
> I need to set custom accelerated functions for bn_mod_exp methods in<br>
> openssl 1.1.1, while upgrading for openssl 1.0.2. Here's the code<br>
> snippet () :<br>
> --<br>
>     static DH_METHOD Intoto_DH_Method;<br>
>     static RSA_METHOD Intoto_RSA_Method;<br>
>     static DSA_METHOD Intoto_DSA_Method;<br>
> <br>
>     void updatePublicKeyMethods()<br>
>     {    <br>
>         Intoto_DH_Method = *(DH_get_default_method());<br>
>         Intoto_DH_Method.bn_mod_exp = Intoto_DH_mod_exp;<br>
>         DH_set_default_method(&Intoto_DH_Method);<br>
> <br>
>         Intoto_RSA_Method = *(RSA_get_default_method());<br>
>         Intoto_RSA_Method.bn_mod_exp = Intoto_RSA_mod_exp;<br>
>         RSA_set_default_method(&Intoto_RSA_Method);<br>
> <br>
>         Intoto_DSA_Method = *(DSA_get_default_method());<br>
>         Intoto_DSA_Method.bn_mod_exp = Intoto_DSA_mod_exp;<br>
>         DSA_set_default_method(&Intoto_DSA_Method);<br>
> <br>
>         return;<br>
>     } <br>
> --<br>
> As RSA_METHOD,DSA_METHOD & DH_METHOD objects are Opaque now , Can<br>
> anyone help me with what would be the replacement for above code ??<br>
<br>
There is RSA_meth_set_bn_mod_exp() function and the respective<br>
equivalents for DH and DSA. Of course you'll also have to use<br>
RSA_meth_dup() to duplicate the default method before you can<br>
manipulate it. And you'll need to free it once you stop using the<br>
OpenSSL functions.<br>
<br>
-- <br>
Tomáš Mráz<br>
No matter how far down the wrong road you've gone, turn back.<br>
                                              Turkish proverb<br>
[You'll know whether the road is wrong if you carefully listen to your<br>
conscience.]<br>
<br>
<br>
</blockquote></div></div>