<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=koi8-r">
<style type="text/css" id="owaParaStyle">P {margin-top:0;margin-bottom:0;}</style>
</head>
<body fpstyle="1" ocsi="0">
<div style="direction: ltr;font-family: Tahoma;color: #000000;font-size: 10pt;">
<div>Hi Dimitry,</div>
<div><br>
</div>
<div>thanks, yes, that's why I'm doing inside the engine as well.</div>
<div><br>
</div>
<div>The question was regarding the library that my engine links against that in turn uses libcrypto again.</div>
<div><br>
</div>
<div>That linked library uses the EVP methods with the "default"-engine, which is however set from the surrounding application.</div>
<div><br>
</div>
<div>I guess it's a similar question to when an application links against liba.so and libb.so and both use openssl internally but set different default engines. How can you prevent them from interfering with each other ?</div>
<div><br>
</div>
<div>Thanks,</div>
<div>Andreas<br>
</div>
<div><br>
</div>
<div style="font-family: Times New Roman; color: #000000; font-size: 16px">
<hr tabindex="-1">
<div id="divRpF829557" style="direction: ltr;"><font size="2" face="Tahoma" color="#000000"><b>From:</b> openssl-users [openssl-users-bounces@openssl.org] on behalf of Dmitry Belyavsky [beldmit@gmail.com]<br>
<b>Sent:</b> Tuesday, March 19, 2019 21:09<br>
<b>To:</b> openssl-users@openssl.org<br>
<b>Subject:</b> Re: Howto prevent cycles in engine invocation ?<br>
</font><br>
</div>
<div></div>
<div>
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div dir="auto">
<div dir="auto">
<div>Hello Andreas,</div>
<div><br>
</div>
<div>I used smth like<br>
=======</div>
<div dir="auto">RSA_METHOD my_rsa_method = {</div>
<div dir="auto">    "My RSA method",</div>
<div dir="auto">    0,                          /* pub_enc */</div>
<div dir="auto">    0,                          /* pub_dec */</div>
<div dir="auto">    0,          /* priv_enc */</div>
<div dir="auto">    my_priv_dec,          /* priv_dec */</div>
<div dir="auto">    0,                          /* rsa_mod_exp */</div>
<div dir="auto">    0,                          /* bn_mod_exp */</div>
<div dir="auto">    0,                          /* init */</div>
<div dir="auto">    0,              /* finish */</div>
<div dir="auto">    RSA_METHOD_FLAG_NO_CHECK|RSA_FLAG_SIGN_VER,          /* flags */</div>
<div dir="auto">    NULL,                       /* app_data */</div>
<div dir="auto">    my_rsa_sign,              /* rsa_sign */</div>
<div dir="auto">    0                           /* rsa_verify */</div>
<div dir="auto">};</div>
<div dir="auto"><br>
</div>
<div dir="auto">static int my_priv_dec (int flen, const unsigned char *from,</div>
<div dir="auto">    unsigned char *to, RSA *rsa, int padding)</div>
<div dir="auto">{</div>
<div dir="auto">  const RSA_METHOD *def_meth = RSA_PKCS1_SSLeay();</div>
<div dir="auto">  if ((rsa->meth == &my_rsa_method) && RSA_get_ex_data(rsa, my_key_pos))</div>
<div dir="auto">  {</div>
<div dir="auto">    return my_op_rsa_decrypt(flen, from, to, rsa, padding);</div>
<div dir="auto">  }</div>
<div dir="auto"><br>
</div>
<div dir="auto">  return def_meth->rsa_priv_dec(flen, from, to, rsa, padding);</div>
<div dir="auto">}</div>
<div>==============</div>
<div>But this code worked for 1.0.* branch</div>
</div>
<br>
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">вт, 19 марта 2019 г., 19:52 Fuchs, Andreas <<a href="mailto:andreas.fuchs@sit.fraunhofer.de" rel="noreferrer" target="_blank">andreas.fuchs@sit.fraunhofer.de</a>>:<br>
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex; border-left:1px solid rgb(204,204,204); padding-left:1ex">
Following scenario:<br>
<br>
I have an engine that implements e.g. RSA decryption.<br>
That engine links against a library that links against libcrypto to perform RSA decryption.<br>
<br>
Now if I have an application that sets the default library to be my engine, won't I end up in an infinite loop ?<br>
<br>
Or the other way around:<br>
- Is there a way to change the default engine from within my engine before calling out to the library ?<br>
- Can the library itself select "software-only" as an engine ?<br>
<br>
I guess I don't have a concrete problem in my specific case, since I have app_data attached to any key and<br>
if my engine receives a key without app_data, it will just call SSLeay() functions.<br>
<br>
But what if that was not the case ?<br>
<br>
Thanks a lot for any help,<br>
Andreas</blockquote>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>