[openssl-dev] openssl.cnf causes Segmentation fault

2016-05-31 Thread danigrosu
Hi everyone. 

My intention is to modify the openssl.cnf file in order to add a new RSA
ENGINE, dynamicaly. 
I have found the /etc/ssl/openssl.cnf file and after my modifications it
looks like this: 

#openssl.cnf ### 
# 
# OpenSSL example configuration file. 
# This is mostly being used for generation of certificate requests. 
# 


openssl_conf = openssl_def 


# This definition stops the following lines choking if HOME isn't 
# defined. 
HOME= . 
RANDFILE= $ENV::HOME/.rnd 


## other lines 
#--unmodified-
 
## end of other lines 


ess_cert_id_chain   = no# Must the ESS cert id chain be included? 
# (optional, default: no) 

[openssl_def] 
engines = engine_section 

[engine_section] 

foo = gpu_section 

[gpu_section] 
dynamic_path =
/usr/lib/x86_64-linux-gnu/openssl-1.0.0/engines/librsax_gpu.so 
engine_id = rsax_gpu 
default_algorithms = ALL 
init = 1 
end of file 


The problem is that if i try the command 
"openssl engine", it results in a "Segmentation fault (core dumped)" 

I am struggling with this for a while. 
OpenSSL 1.0.1f 6 Jan 2014, Ubuntu 14.04 

Best regards, 
Dani Grosu



--
View this message in context: 
http://openssl.6102.n7.nabble.com/openssl-cnf-causes-Segmentation-fault-tp66453.html
Sent from the OpenSSL - Dev mailing list archive at Nabble.com.
-- 
openssl-dev mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-dev


Re: [openssl-dev] Errors when loading an OpenSSL RSA Engine

2016-03-10 Thread danigrosu
Richard Levitte - VMS Whacker-2 wrote
> The issue is easily fixed by adding a parameter in the problematic
> call, like this:
> 
>   if(!bind_helper(ret, engine_e_rsax_id))

Yes, indeed it was simple, I totally missed that.

And now something really weird...
Remember my first post in this topic when I said I encountered this:

/Then, when I'm trying to test the engine by using the command:
openssl engine -t -c `pwd`/eng_rsax.so
... I receive the following errors:
140470207960736:error:25066067:DSO support routines:DLFCN_LOAD:could not
load the shared library:dso_dlfcn.c:185:filename(/some_path/eng_rsax.so):
/some_path/eng_rsax.so: *undefined symbol: mod_exp_512*
140470207960736:error:25070067:DSO support routines:DSO_load:could not load
the shared library:dso_lib.c:244:
140470207960736:error:260B6084:engine routines:DYNAMIC_LOAD:dso not
found:eng_dyn.c:450: 
140470207960736:error:2606A074:engine routines:ENGINE_by_id:no such
engine:eng_list.c:417:id=/some_path/eng_rsax.so/

I simply implemented the body of the "mod_exp_512" function, and the magic
happend:

/root@dani-pc:~/Desktop/CUDA/RSA-engine# openssl genrsa -out priv.pem
-engine `pwd`/eng_rsax.so 1024
/home/dani/Desktop/CUDA/RSA-engine/eng_rsax.so
engine "rsax_dani" set.
Generating RSA private key, 1024 bit long modulus
.++
..++
e is 65537 (0x10001)/

It seems that the solution was right in front of my eyes.
Now let's put some CUDA code in this engine  and increase the speedup.
Thank you for support!

Best wishes,
Dani Grosu




--
View this message in context: 
http://openssl.6102.n7.nabble.com/Errors-when-loading-an-OpenSSL-RSA-Engine-tp64385p64547.html
Sent from the OpenSSL - Dev mailing list archive at Nabble.com.
-- 
openssl-dev mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-dev


Re: [openssl-dev] Errors when loading an OpenSSL RSA Engine

2016-03-10 Thread danigrosu
Ok Richard, I figured it out how the md5 engine works, and, I also
realized that it is a bit different from the RSA engine:
---different structure (EVP_MD vs RSA_METHOD)
---missing the dynamic bind part, and I have no idea how to do it (see the
above post)

Maybe I should try something else in order to build a RSA engine. I think it
is very
hard to start it from scratch and that's why I choose to use the RSA-X.

Dani Grosu



--
View this message in context: 
http://openssl.6102.n7.nabble.com/Errors-when-loading-an-OpenSSL-RSA-Engine-tp64385p64536.html
Sent from the OpenSSL - Dev mailing list archive at Nabble.com.
-- 
openssl-dev mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-dev


Re: [openssl-dev] Errors when loading an OpenSSL RSA Engine

2016-03-10 Thread danigrosu
Blumenthal, Uri - 0553 - MITLL wrote
> But autotools setup did not work (see my
> previous post in this thread). Perhaps Richard could shed some light on
> that.

I just did what that guy said and it worked. Basically I created a "m4"
directory
and I copied the "ax_check_openssl.m4" file to the "m4" directory, then I
used
the "autoreconf -fi -I m4" command, then ./configure, then make.
-- "ax_check_openssl.m4" can be found here 
autoconf-archive-2015.09.25.tar.xz
  


Blumenthal, Uri - 0553 - MITLL wrote
> Regarding RSA-X engine, it lacks the dynamic binding code necessary for
> being loaded, etc. That’s why it fails to load. Check the contents of
> e_md5.c and eng_rsax.c for differences.
> 
> $ OPENSSL_ENGINES=. openssl engine -t -c rsax
> (rsax) RSAX engine support
>  [RSA]
>  [ available ]
> $ 

Be aware that the name "rsax" is the name of the engine that OpenSSL
already knows. Try to change it's name to something else, e.g. "rsax_smth".
I get the same error after I change it's name to "rsax_dani":

/140334964717216:error:25066067:DSO support routines:DLFCN_LOAD:could not
load the shared library:dso_dlfcn.c:185:filename(./librsax_dani.so):
./librsax_dani.so: cannot open shared object file: No such file or directory
140334964717216:error:25070067:DSO support routines:DSO_load:could not load
the shared library:dso_lib.c:244:
140334964717216:error:260B6084:engine routines:DYNAMIC_LOAD:dso not
found:eng_dyn.c:450:
140334964717216:error:2606A074:engine routines:ENGINE_by_id:no such
engine:eng_list.c:417:id=rsax_dani/

Then I tryed to use the following macros in order to dynamically bind
the engine (as I saw in the md5 engine):

/IMPLEMENT_DYNAMIC_BIND_FN(bind_helper)
IMPLEMENT_DYNAMIC_CHECK_FN()/

I changed the "bind_helper" function to be exactly like "bind" function
from the md5 engine => /static int bind_helper(ENGINE *e, const char *id)/
and I get this error message:

/eng_rsax.c: In function ‘ENGINE_rsax’:
eng_rsax.c:178:2: error: too few arguments to function ‘bind_helper’
  if(!bind_helper(ret))
  ^
eng_rsax.c:142:12: note: declared here
 static int bind_helper(ENGINE *e, const char *id)
^
140334964717216:error:25066067:DSO support routines:DLFCN_LOAD:could not
load the shared library:dso_dlfcn.c:185:filename(./librsax_dani.so):
./librsax_dani.so: cannot open shared object file: No such file or directory
140334964717216:error:25070067:DSO support routines:DSO_load:could not load
the shared library:dso_lib.c:244:
140334964717216:error:260B6084:engine routines:DYNAMIC_LOAD:dso not
found:eng_dyn.c:450:
140334964717216:error:2606A074:engine routines:ENGINE_by_id:no such
engine:eng_list.c:417:id=rsax_dani/

Dani Grosu




--
View this message in context: 
http://openssl.6102.n7.nabble.com/Errors-when-loading-an-OpenSSL-RSA-Engine-tp64385p64535.html
Sent from the OpenSSL - Dev mailing list archive at Nabble.com.
-- 
openssl-dev mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-dev


Re: [openssl-dev] Errors when loading an OpenSSL RSA Engine

2016-03-09 Thread danigrosu
In git version, if I comment the block

/ if (id && strcmp(id, engine_id)) {
fprintf(stderr, "MD5 engine called with the unexpected id %s\n", id);
fprintf(stderr, "The expected id is %s\n", engine_id);
goto end;
  }/

... then I type

/$ gcc -fPIC -o rfc1321/md5c.o -c rfc1321/md5c.c 
$ gcc -fPIC -o md5-engine.o -c e_md5.c 
$ gcc -shared -o md5-engine.so -lcrypto md5-engine.o rfc1321/md5c.o

$ echo whatever | openssl dgst -engine `pwd`/md5-engine.so -md5
engine "emd5" set.
(stdin)= d8d77109f4a24efc3bd53d7cabb7ee35/

... everithing goes well

Dani Grosu



--
View this message in context: 
http://openssl.6102.n7.nabble.com/Errors-when-loading-an-OpenSSL-RSA-Engine-tp64385p64501.html
Sent from the OpenSSL - Dev mailing list archive at Nabble.com.
-- 
openssl-dev mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-dev


Re: [openssl-dev] Errors when loading an OpenSSL RSA Engine

2016-03-09 Thread danigrosu
Blumenthal, Uri - 0553 - MITLL wrote
> You probably want to post (a) the modifications you made to
> autotools-whatever, and (b) the resulting compile and link commands.

The answer of  this question

  
(asked by me) helped me to solve the problem.


Richard Levitte - VMS wrote
> Exactly how did it fail?  It's a bit hard to diagnose unless you show 
> us what you were told...  I assume there were some error messages? 

This is what I get if I use the the git version:
 
... and if I use the blog code for the e_md5.c file (called md5-engine.c on
the blog) 
it simply works with the same commands. As I said above, I had to make some 
modifications in order to build the engine using autotools.

Dani Grosu






--
View this message in context: 
http://openssl.6102.n7.nabble.com/Errors-when-loading-an-OpenSSL-RSA-Engine-tp64385p64500.html
Sent from the OpenSSL - Dev mailing list archive at Nabble.com.
-- 
openssl-dev mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-dev


Re: [openssl-dev] Errors when loading an OpenSSL RSA Engine

2016-03-09 Thread danigrosu
danigrosu wrote
> I'm just trying to implement an RSA engine and I thought that this would
> be a good start.
> I tryed successfully the 
> MD5 Engine
> <https://www.openssl.org/blog/blog/2015/11/23/engine-building-lesson-2-an-example-md5-engine/>
>   
>  written by Richard Levitte and my next step is to build an RSA engine
>  which I will use in my application.
> 
> I think my problem is simple and it's just something that I miss.

Relating to the MD5 Engine, I tryed to build the  git version
<https://github.com/engine-corner/Lesson-2-A-digest>   manually with these
commands:
$ gcc -fPIC -o rfc1321/md5c.o -c rfc1321/md5c.c
$ gcc -fPIC -o md5-engine.o -c e_md5.c
$ gcc -shared -o md5-engine.so -lcrypto md5-engine.o rfc1321/md5c.o
... and it failed when I tried to load the engine, but using the autotools
and a few modifications it worked.

So, maybe, the same problem is here, with the RSA-X engine.
Maybe Mr. Levitte could clarify this.

Dani Grosu



--
View this message in context: 
http://openssl.6102.n7.nabble.com/Errors-when-loading-an-OpenSSL-RSA-Engine-tp64385p64483.html
Sent from the OpenSSL - Dev mailing list archive at Nabble.com.-- 
openssl-dev mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-dev


Re: [openssl-dev] Errors when loading an OpenSSL RSA Engine

2016-03-09 Thread danigrosu
So we are stuck with this error? Since we are using OpenSSL 1.0.1, I think
we can handle it.

Dani Grosu

On 8 March 2016 at 17:03, danigrosu [via OpenSSL] <
ml-node+s6102n64449...@n7.nabble.com> wrote:

> Blumenthal, Uri - 0553 - MITLL wrote
> Could you please confirm that you’re doing this on OpenSSL-1.0.2?
>
> # openssl version
> OpenSSL 1.0.1f 6 Jan 2014
> So it appears I'm working with 1.0.1.
>
> Dani Grosu
>
> --
> If you reply to this email, your message will be added to the discussion
> below:
>
> http://openssl.6102.n7.nabble.com/Errors-when-loading-an-OpenSSL-RSA-Engine-tp64385p64449.html
> To unsubscribe from Errors when loading an OpenSSL RSA Engine, click here
> <http://openssl.6102.n7.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code=64385=ZG5pLmdyb3N1QGdtYWlsLmNvbXw2NDM4NXwtMTk3MTUwMDcxNg==>
> .
> NAML
> <http://openssl.6102.n7.nabble.com/template/NamlServlet.jtp?macro=macro_viewer=instant_html%21nabble%3Aemail.naml=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>




--
View this message in context: 
http://openssl.6102.n7.nabble.com/Errors-when-loading-an-OpenSSL-RSA-Engine-tp64385p64473.html
Sent from the OpenSSL - Dev mailing list archive at Nabble.com.-- 
openssl-dev mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-dev


Re: [openssl-dev] Errors when loading an OpenSSL RSA Engine

2016-03-08 Thread danigrosu
Blumenthal, Uri - 0553 - MITLL wrote
> Could you please confirm that you’re doing this on OpenSSL-1.0.2?

# openssl version
OpenSSL 1.0.1f 6 Jan 2014
So it appears I'm working with 1.0.1. 

Dani Grosu



--
View this message in context: 
http://openssl.6102.n7.nabble.com/Errors-when-loading-an-OpenSSL-RSA-Engine-tp64385p64449.html
Sent from the OpenSSL - Dev mailing list archive at Nabble.com.-- 
openssl-dev mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-dev


Re: [openssl-dev] Errors when loading an OpenSSL RSA Engine

2016-03-08 Thread danigrosu
I'm just trying to implement an RSA engine and I thought that this would be a
good start.
I tryed successfully the  MD5 Engine

  
written by Richard Levitte and my next step is to build an RSA engine
 which I will use in my application.

I think my problem is simple and it's just something that I miss.

Dani Grosu



--
View this message in context: 
http://openssl.6102.n7.nabble.com/Errors-when-loading-an-OpenSSL-RSA-Engine-tp64385p64445.html
Sent from the OpenSSL - Dev mailing list archive at Nabble.com.-- 
openssl-dev mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-dev


Re: [openssl-dev] Errors when loading an OpenSSL RSA Engine

2016-03-08 Thread danigrosu
I tried your suggestion, but the error still appears.
Richard Levitte - VMS Whacker-2 wrote
> You might want to try this:
> 

> gcc -shared -o eng_rsax.so eng_rsax.o -lcrypto

> 
> When linking, order is important.

Dani Grosu



--
View this message in context: 
http://openssl.6102.n7.nabble.com/Errors-when-loading-an-OpenSSL-RSA-Engine-tp64385p64438.html
Sent from the OpenSSL - Dev mailing list archive at Nabble.com.-- 
openssl-dev mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-dev


[openssl-dev] Errors when loading an OpenSSL RSA Engine

2016-03-07 Thread danigrosu
I want to build an OpenSSL RSA engine, starting from  this existing source
code file    
which is a faster method implemented by Intel. First of all I want to build
this code so I'm using these commands:

gcc -fPIC -m64 -o eng_rsax.o -c eng_rsax.c 
gcc -shared -o eng_rsax.so -lcrypto eng_rsax.o

... and no error shows up. Then, when I'm trying to test the engine by using
the command:
openssl engine -t -c `pwd`/eng_rsax.so
... I receive the following errors:
140470207960736:error:25066067:DSO support routines:DLFCN_LOAD:could not
load the shared library:dso_dlfcn.c:185:filename(/some_path/eng_rsax.so):
/some_path/eng_rsax.so: undefined symbol: mod_exp_512
140470207960736:error:25070067:DSO support routines:DSO_load:could not
load the shared library:dso_lib.c:244:
140470207960736:error:260B6084:engine routines:DYNAMIC_LOAD:dso not
found:eng_dyn.c:450:
140470207960736:error:2606A074:engine routines:ENGINE_by_id:no such
engine:eng_list.c:417:id=/some_path/eng_rsax.so

At this point I guess I'm not using the right flags and maybe the commands
for building the engine are incomplete.  
What do I need to do in order to make this work?



--
View this message in context: 
http://openssl.6102.n7.nabble.com/Errors-when-loading-an-OpenSSL-RSA-Engine-tp64385.html
Sent from the OpenSSL - Dev mailing list archive at Nabble.com.-- 
openssl-dev mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-dev