After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 121579 - RFE: implement loading crypto engine as plugins
RFE: implement loading crypto engine as plugins
Status: RESOLVED FIXED
Product: xmlsec
Classification: Other
Component: general
1.1.1
Other Linux
: Normal normal
: ---
Assigned To: Aleksey Sanin
Aleksey Sanin
Depends on:
Blocks:
 
 
Reported: 2003-09-06 02:54 UTC by Aleksey Sanin
Modified: 2004-12-22 21:47 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
the first patch for MSCRYPTO branch: plugins are implemented with ltdl library, no windows code yet (407.89 KB, patch)
2003-09-09 19:41 UTC, Aleksey Sanin
none Details | Review
the first patch for CVS trunk: no windows support again (391.19 KB, patch)
2003-09-09 19:57 UTC, Aleksey Sanin
none Details | Review
cleanup in Windows makefile (mscrypto branch) (19.81 KB, patch)
2003-09-09 23:16 UTC, Aleksey Sanin
none Details | Review
cleanup in Windows makefile (trunk) (17.32 KB, patch)
2003-09-09 23:16 UTC, Aleksey Sanin
none Details | Review
DL implementation for Windows (native,not ltdl based; patch for both trunk and branch) (5.03 KB, patch)
2003-09-10 19:42 UTC, Aleksey Sanin
none Details | Review
link xmlsec core library with dl libraries (440 bytes, patch)
2003-09-16 09:31 UTC, Aleksey Sanin
none Details | Review

Description Aleksey Sanin 2003-09-06 02:54:15 UTC
Aleksey wrote:

> I can do it in a couple days but first I would like to ask a question:
> does anyone have a need in such an improvement? Any use cases for it?


One case is the xmlsec tool.  Instead of having xmlsec1-nss, etc., have
only xmlsec1 and select the engine at the command line.  The xmlsec tool is
a model application for the xmlsec library-- things we can surmise from
this tool likely apply to any binary application using the library.

Another case is any new library that will depend on libxmlsec. Currently,
the author of such software might be tempted to propagate the compile-time
xmlsec option and make libfoo-openssl, libfoo-nss, etc., versions of his
library.  (Now if his library had it's own compile time options, then you
can see how things get ugly.  We get libfoo-a-openssl, libfoo-b-nss, etc. 
An then another new library depends on libfoo... and so on.)  It would be
better if he could just distribute one version of his library and let the
xmlsec crypto enigne be selected by the user of the library or on-site.

I don't know anything about the complexity of dlopen or security issues of
using plugins.  I'm only commenting on the benefits of deferring crypto
engine selection.

Regards,
-John
Comment 1 Roumen Petrov 2003-09-09 07:47:17 UTC
I hope that libltdl from libtool can hide "complexity of dlopen".

I think when we use lt_dlopen("/usr/libexec/xmlsec-nss.so") we
shouldn't care about security. My /usr/libexec is full with apache
modules ;-).

We can have security problems with shared libs without dlopen.
As example see for AIX and gcc "Portable OpenSSH: Dangerous AIX linker
behavior (aixgcc.adv)" at
http://marc.theaimsgroup.com/?l=openssh-unix-dev&m=105167884027821 

For ms-windows os-es I think that we might have security problem what
cannot be fixed - I't not recommended to use fixed paths to load dlls
and might cannot fix dll search path.


Comment 2 Aleksey Sanin 2003-09-09 19:41:14 UTC
Created attachment 19829 [details] [review]
the first patch for MSCRYPTO branch: plugins are implemented with ltdl library, no windows code yet
Comment 3 Aleksey Sanin 2003-09-09 19:57:55 UTC
Created attachment 19830 [details] [review]
the first patch for CVS trunk: no windows support again
Comment 4 Aleksey Sanin 2003-09-09 23:16:21 UTC
Created attachment 19834 [details] [review]
cleanup in Windows makefile (mscrypto branch)
Comment 5 Aleksey Sanin 2003-09-09 23:16:45 UTC
Created attachment 19836 [details] [review]
cleanup in Windows makefile (trunk)
Comment 6 Roumen Petrov 2003-09-10 08:12:29 UTC
about attachment with id 19830
1.) ===
Patch contain (on one line !)
#if !defined(XMLSEC_NO_CRYPTO_DYNAMIC_LOADING) &&
defined(XMLSEC_CRYPTO_DYNAMIC_LOADING)

Why ?
Both definition are mutually exclusive. 
What about config.h.in to contain:
#ifdef XMLSEC_CRYPTO_DYNAMIC_LOADING
#  ifdef XMLSEC_NO_CRYPTO_DYNAMIC_LOADING
#    undef XMLSEC_NO_CRYPTO_DYNAMIC_LOADING
#  endif
#endif

2.) ===
Now I see one problem. One crypto can have aes/des/etc. support, other
without aes/des/etc. .
Might we should have configure.ac for every crypto engine and in main
configure.in to put macro AC_CONFIG_SUBDIRS() for allowed crypto engines.

3.) ===
I think that every crypto should init own struct
xmlSecCryptoDLFunctions as usualy in C, i.e.

static xmlSecCryptoDLFunctions functions = {
  ...
  xmlSecXXXInit,
  xmlSecXXXShutdown,
  xmlSecXXXKeysMngrInit,
  ... 
};

When definition of structure xmlSecCryptoDLFunctions is changed, on
compile time we can detect this. On run time as in proposed patch we
can miss some initialization.

4.) ===
Why patch contain ltdl.{h|c} and xmlsec-ltdl.{h|c|c.patch} ?
Where/What is problem in original ltdl ? 

 
Comment 7 Aleksey Sanin 2003-09-10 08:24:57 UTC
1)
You are right, it;s not necessary :) But just in case :)

2) and 3)
Yes, it's possible that one crypto engine implements, say, AES and
another one does not. But application can detect it (corresponding
klass would be NULL) or we would fail as soon as application would try
to use it (thanks to xmlSecAsserts).
It's perfectly legal to have NULLs in the functions table. Again, not
all crypto engines are the same. Some have the functionality that is
not implemented by others. There is no need to worry about that.
The purpose of XMLSEC_NO_AES (and friends) is to disable the
particular feature all together. For example, in embedded case you
might have limited memory size. Thus you might want to disable some
features to reduce xmlsec library size.

4) 
Suppose you have another library XYZ that also embeds ltdl.c file. Now
you want to link library XYZ and xmlsec in one application. Guess
what? You'll have a symbols conflict because for example lt_open is
defined and implemented in both libraries. 








Comment 8 Aleksey Sanin 2003-09-10 19:42:17 UTC
Created attachment 19848 [details] [review]
DL implementation for Windows (native,not ltdl based; patch for both trunk and branch)
Comment 9 Roumen Petrov 2003-09-16 08:18:18 UTC
undefined symbols:

In version xmlsec-20030916(CVS) libxmssec1.so has undefined symbols.
Use on linux "ldd -r ../src/.libs/libxmlsec1.so" to see.
LTDL_PARSE or xmlsec-ltdl.patch should change these symbols too.
Result is that I cannot link my test samples.
Note: xmlsec1 examples are not tested, but they should fail too.
Comment 10 Aleksey Sanin 2003-09-16 09:31:47 UTC
Created attachment 19976 [details] [review]
link xmlsec core library with dl libraries
Comment 11 Aleksey Sanin 2003-09-16 09:34:42 UTC
No, the xmlsec tests do not fail because I use "pkg-config" that
provides correct linker flags (i.e. it includes the required "-ldl").
Anyway, good catch! The trivial fix is attached and checked into both
trunk and branch.
Comment 12 Aleksey Sanin 2003-09-16 09:37:21 UTC
I feel that we can declare this bug closed. Any new problems with
dynamic loading should be reported as separate bugs.