<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;" dir="ltr">
<p style="margin-top:0;margin-bottom:0">Hi,</p>
<p style="margin-top:0;margin-bottom:0">fine you got it working.</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">Then for your question: <br>
</p>
<p style="margin-top:0;margin-bottom:0"><font face="monospace,monospace">crypto:engine_list()
<span style="font-family: Calibri, Helvetica, sans-serif;">shows which engines are loaded and not which are available to the system.
<br>
</span></font></p>
<p style="margin-top:0;margin-bottom:0"><font face="monospace,monospace"><span style="font-family: Calibri, Helvetica, sans-serif;"></span></font><font face="arial,helvetica,sans-serif"></font>So in your case it shows you
<span style="font-family: Arial, Helvetica, sans-serif;">dstu</span> which you load and
<span style="font-family: Arial, Helvetica, sans-serif;">dynamic</span> which the system loads to be able to load other engines dynamically.<br>
</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">BR Lars<br>
</p>
</div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Eugene Pirogov <iamexile@gmail.com><br>
<b>Sent:</b> Sunday, January 21, 2018 4:01:24 PM<br>
<b>To:</b> Lars Thorsen<br>
<b>Cc:</b> erlang-questions@erlang.org<br>
<b>Subject:</b> Re: [erlang-questions] crypto:engine_list() returns empty list</font>
<div> </div>
</div>
<div>
<div dir="ltr">Hi Lars,
<div><br>
</div>
<div>I figured it out.</div>
<div><br>
</div>
<div>I mistakingly ended up with two different openssl (and libssl1.0.0) in the system:</div>
<div>
<ul>
<li>one that was installed from Ubuntu sources, e.g. <a href="https://launchpad.net/ubuntu/+source/openssl/1.0.1f-1ubuntu2.23">
https://launchpad.net/ubuntu/+source/openssl/1.0.1f-1ubuntu2.23</a>,</li><li>another one was the one I built & installed manually (via <font face="monospace, monospace">
make install</font>).</li></ul>
<div>My custom-built & installed openssl command somehow successfully saw custom-built libssl1.0.0, which contained dstu engine. However erlang was unable to see custom-built libssl1.0.0. Instead, it remained to refer to libssl1.0.0 that existed somewhere else
 in the system. Hence Erlang was unable to load "dstu".</div>
</div>
<div><br>
</div>
<div>I packed my custom-built openssl as a .deb package and properly installed it (overriding/upgrading existing system one). Erlang now sees correct libssl1.0.0 with no problem, and is able to load the engine in question:</div>
<div><br>
</div>
<div>
<blockquote style="margin:0px 0px 0px 40px; border:none; padding:0px">
<div>
<div><font face="monospace, monospace">crypto:engine_load(<<"dstu">>, [], []).</font></div>
<div><font face="monospace, monospace">{ok,#Ref<0.3776855326.4257087491.172227>}</font></div>
</div>
<div><font face="monospace, monospace"><br>
</font></div>
</blockquote>
<font face="arial, helvetica, sans-serif">Just as an observation, interestingly, </font><font face="monospace, monospace">crypto:engine_list()</font><font face="arial, helvetica, sans-serif"> still will not show a list of available engines... until I load at
 least some engine:</font></div>
<blockquote style="margin:0px 0px 0px 40px; border:none; padding:0px">
<div><font face="monospace, monospace"><br>
</font></div>
<div>
<div><font face="monospace, monospace"># erl</font></div>
</div>
<div>
<div><font face="monospace, monospace">Erlang/OTP 20 [erts-9.2] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:10] [hipe] [kernel-poll:false]</font></div>
</div>
<div>
<div><font face="monospace, monospace"><br>
</font></div>
</div>
<div>
<div><font face="monospace, monospace">Eshell V9.2  (abort with ^G)</font></div>
</div>
<div>
<div><font face="monospace, monospace">1> crypto:engine_list().</font></div>
</div>
<div>
<div><font face="monospace, monospace">[]</font></div>
</div>
<div>
<div><font face="monospace, monospace">2> crypto:engine_load(<<"dstu">>, [], []).</font></div>
</div>
<div>
<div><font face="monospace, monospace">{ok,#Ref<0.3447474459.3988914180.174416>}</font></div>
</div>
<div>
<div><font face="monospace, monospace">3> crypto:engine_list().</font></div>
</div>
<div>
<div><font face="monospace, monospace">[<<"dynamic">>,<<"dstu">>]</font></div>
</div>
<div>
<div><font face="monospace, monospace">4></font></div>
</div>
<div><font face="monospace, monospace"><br>
</font></div>
</blockquote>
<font face="arial, helvetica, sans-serif">It's not an issue, just a question: why won't </font><font face="monospace, monospace">crypto:engine_list()</font><font face="arial, helvetica, sans-serif"> tell me what engines exist in the system, upfront?</font></div>
<div class="x_gmail_extra"><br>
<div class="x_gmail_quote">On Fri, Jan 19, 2018 at 11:11 AM, Lars Thorsen <span dir="ltr">
<<a href="mailto:lars.thorsen@ericsson.com" target="_blank">lars.thorsen@ericsson.com</a>></span> wrote:<br>
<blockquote class="x_gmail_quote" style="margin:0 0 0 .8ex; border-left:1px #ccc solid; padding-left:1ex">
<div dir="ltr">
<div id="x_m_8491899949032205698divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:#000000; font-family:Calibri,Helvetica,sans-serif">
<div id="x_m_8491899949032205698divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:rgb(0,0,0); font-family:Calibri,Helvetica,sans-serif,"EmojiFont","Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols">
<p>Hi,</p>
<p><font face="monospace, monospace"><b>crypto:engine_list()</b></font> returns what engine is loaded for OTP ssl (<span>OTP just uses crypto lib and not openssl</span> ) and not what is available
<br>
</p>
<p>(it loops too get all engines by using <span>ENGINE_get_first()</span> and <span>
ENGINE_get_next(</span>) from crypto lib). OTP just uses crypto lib and not openssl.</p>
<p><br>
</p>
<p>So after you executed <font face="monospace, monospace">{ok, Engine} = crypto:engine_load(<<"gost">>, [], []).</font> you should see gost in the list.</p>
<p><br>
</p>
<p>Interesting with dstu, where is that engine located. Same place as gost ?</p>
<p>Normally if you just use the id, the engine must be located in the OpenSSL/LibreSSL installation
<span class="x_m_8491899949032205698code">"engines</span>" directory for crypto lib to find it.
<br>
</p>
<p>See crypto users guide for loading from other directory.</p>
<p>Perhaps openssl has some other config where to find engines that not affects cryptolib.</p>
<p><br>
</p>
<p>BR Lars Thorsén</p>
<p>OTP Team<br>
</p>
<div><br>
</div>
<p></p>
<p><br>
</p>
<p><br>
</p>
</div>
<hr style="display:inline-block; width:98%">
<div id="x_m_8491899949032205698divRplyFwdMsg" dir="ltr"><font color="#000000" face="Calibri, sans-serif" style="font-size:11pt"><b>From:</b>
<a href="mailto:erlang-questions-bounces@erlang.org" target="_blank">erlang-questions-bounces@<wbr>erlang.org</a> <<a href="mailto:erlang-questions-bounces@erlang.org" target="_blank">erlang-questions-bounces@<wbr>erlang.org</a>> on behalf of Eugene Pirogov
 <<a href="mailto:iamexile@gmail.com" target="_blank">iamexile@gmail.com</a>><br>
<b>Sent:</b> Thursday, January 18, 2018 5:43:05 PM<br>
<b>To:</b> <a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a><br>
<b>Subject:</b> [erlang-questions] crypto:engine_list() returns empty list</font>
<div> </div>
</div>
<div>
<div class="x_h5">
<div>
<div dir="ltr">Hi,
<div><br>
</div>
<div>I'm running <font face="monospace, monospace"><b>crypto:engine_list()</b></font>, but it won't list any OpenSSL engines I have installed. What can be the reason?</div>
<div><br>
</div>
<div>I can see the engine in the system by running the following:</div>
<div><br>
</div>
<blockquote style="margin:0px 0px 0px 40px; border:none; padding:0px">
<div>
<div><font face="monospace, monospace"># openssl engine -t gost</font></div>
</div>
<div>
<div><font face="monospace, monospace">(gost) Reference implementation of GOST engine</font></div>
</div>
<div>
<div><font face="monospace, monospace">     [ available ]</font></div>
</div>
<div><font face="monospace, monospace"><br>
</font></div>
<div>
<div><font face="monospace, monospace"># openssl engine -t dstu</font></div>
</div>
<div>
<div><font face="monospace, monospace">(dstu) Reference implementation of DSTU engine</font></div>
</div>
<div>
<div><font face="monospace, monospace">     [ available ]</font></div>
</div>
</blockquote>
<div><br>
</div>
<div>However when running from erl repl, I get this:</div>
<div><br>
</div>
<blockquote style="margin:0px 0px 0px 40px; border:none; padding:0px">
<div>
<div><font face="monospace, monospace"># erl</font></div>
</div>
<div>
<div><font face="monospace, monospace">Erlang/OTP 20 [erts-9.2] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:10] [hipe] [kernel-poll:false]</font></div>
</div>
<div>
<div><font face="monospace, monospace"><br>
</font></div>
</div>
<div>
<div><font face="monospace, monospace">Eshell V9.2  (abort with ^G)</font></div>
</div>
<div>
<div><font face="monospace, monospace">1> crypto:engine_list().</font></div>
</div>
<div>
<div><font face="monospace, monospace">[]</font></div>
</div>
</blockquote>
<div>
<div><br>
</div>
<div>What's weird is that if I try to forcefully load the engine, it <i>works sometimes.</i></div>
<div>
<ul>
<li>it works with gost engine:<br>
<br>
<div><font face="monospace, monospace"># erl</font></div>
<div><font face="monospace, monospace">Erlang/OTP 20 [erts-9.2] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:10] [hipe] [kernel-poll:false]</font></div>
<div><font face="monospace, monospace"><br>
</font></div>
<div><font face="monospace, monospace">Eshell V9.2  (abort with ^G)</font></div>
<div><font face="monospace, monospace">1> {ok, Engine} = crypto:engine_load(<<"gost">>, [], []).</font></div>
<div><font face="monospace, monospace">{ok,#Ref<0.950608548.198482329<wbr>8.71941>}<br>
<br>
</font></div>
</li><li>it does not work with dstu engine:<br>
<div>
<div><br class="x_m_8491899949032205698x_m_-6293851380270026687gmail-Apple-interchange-newline">
<font face="monospace, monospace"># erl</font></div>
<div><font face="monospace, monospace">Erlang/OTP 20 [erts-9.2] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:10] [hipe] [kernel-poll:false]</font></div>
<div><font face="monospace, monospace"><br>
</font></div>
<div><font face="monospace, monospace">Eshell V9.2  (abort with ^G)</font></div>
<div><font face="monospace, monospace">1> {ok, Engine} = crypto:engine_load(<<"dstu">>, [], []).</font></div>
<div><font face="monospace, monospace">** exception error: no match of right hand side value {error,bad_engine_id}</font></div>
</div>
</li></ul>
</div>
</div>
<div>
<div>What am I missing? How can I get to load <a href="https://github.com/dstucrypt/openssl-dstu/commits/dstu-1_0_1h" target="_blank">
dstu engine</a> in my case?</div>
<div><br>
</div>
-- <br>
<div class="x_m_8491899949032205698x_m_-6293851380270026687gmail-m_8885458731413169712gmail_signature">
<div dir="ltr"><a href="http://www.gmile.me" target="_blank">http://www.gmile.me</a><br>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
<br>
<br clear="all">
<div><br>
</div>
-- <br>
<div class="x_gmail_signature">
<div dir="ltr"><a href="http://www.gmile.me" target="_blank">http://www.gmile.me</a><br>
</div>
</div>
</div>
</div>
</body>
</html>