Creating a framework from the skeleton.

Home Download News Documentation FAQ Tutorial API reference Examples XML Digital Signature Online Verifier XML Encryption XML Canonicalization Reporting Bugs Mailing list Related Authors
- # Creating a framework from the skeleton. The XML Security Library contains a "skeleton" for creating new "xmlsec-<crypto>" libraries. In order to create "xmlsec-mycrypto" library framework, do the following (this example assumes that you are using *nix system, adjust the commands if you are using something else): Copy src/skeleton and include/xmlsec/skeleton folders to src/mycrypto and include/xmlsec/mycrypto folders and remove CVS folders from the result: Example 1. Coping skeleton folders.
      cd src
      cp -r skeleton mycrypto
      cd mycrypto
      rm -rf CVS
      cd ../..
      cd include/xmlsec
      cp -r skeleton mycrypto
      cd mycrypto
      rm -rf CVS
      cd ../../..
- Replace "skeleton" with "mycrypto" in the copied files (note that there are different possible cases here): Example 2. Replacing "skeleton" with "mycrypto".
      for i in `ls include/xmlsec/mycrypto/* src/mycrypto/*`;  do
          echo Processing $i ..;
          sed 's/skeleton/mycrypto/g' $i | \
          sed 's/SKELETON/MYCRYPTO/g' | \
          sed 's/Skeleton/MyCrypto/g' > $i.tmp;
          mv $i.tmp $i;
      done
- Add "xmlsec-mycrypto" library to the "include/xmlsec/crypto.h" file: Example 3. Modifying include/xmlsec/crypto.h file.
      ...
      #ifdef XMLSEC_CRYPTO_MYCRYPTO
      #include <xmlsec/mycrypto/app.h>
      #include <xmlsec/mycrypto/crypto.h>
      #include <xmlsec/mycrypto/symbols.h>
      #else /* XMLSEC_CRYPTO_MYCRYPTO */
      ...
      #endif /* XMLSEC_CRYPTO_MYCRYPTO */
      ...
- Add "xmlsec-crypto" library to the configure.in file (for *nix systems; for Windows you need to modify win32/confgure.js and win32/Makefile.msvc files, see win32/README.txt for details): Example 4. Modifying configure.in file.
      dnl ==========================================================================
      dnl See if we can find MyCrypto
      dnl ==========================================================================
      XMLSEC_MYCRYPTO_DEFINES=""
      MYCRYPTO_CONFIG="mycrypto-config" # TODO
      XMLSEC_NO_MYCRYPTO="1"
      MYCRYPTO_MIN_VERSION="0.0.0" # TODO
      MYCRYPTO_VERSION=""
      MYCRYPTO_PREFIX=""
      MYCRYPTO_CFLAGS=""
      MYCRYPTO_LIBS=""
      MYCRYPTO_LDADDS=""
      AC_MSG_CHECKING(for mycrypto libraries >= $MYCRYPTO_MIN_VERSION)
      AC_ARG_WITH(mycrypto, [  --with-mycrypto=[PFX]    mycrypto location])
      if test "$with_mycrypto" = "no" ; then
          XMLSEC_CRYPTO_DISABLED_LIST="$XMLSEC_CRYPTO_DISABLED_LIST mycrypto"
          AC_MSG_RESULT(no)
      else
          if test "$with_mycrypto" != "" ; then
      	MYCRYPTO_PREFIX=$with_mycrypto
      	MYCRYPTO_CONFIG=$MYCRYPTO_PREFIX/bin/$MYCRYPTO_CONFIG
          fi
          if ! $MYCRYPTO_CONFIG --version > /dev/null 2>&1 ; then
      	if test "$with_mycrypto" != "" ; then
      	    AC_MSG_ERROR(Unable to find mycrypto at '$with_mycrypto')
      	fi
          else
              vers=`$MYCRYPTO_CONFIG --version | awk -F. '{ printf "%d", ($1 * 1000 + $2) * 1000 + $3;}'`
      	minvers=`echo $MYCRYPTO_MIN_VERSION | awk -F. '{ printf "%d", ($1 * 1000 + $2) * 1000 + $3;}'`
      	if test "$vers" -ge "$minvers" ; then
          	    MYCRYPTO_LIBS="`$MYCRYPTO_CONFIG --libs`"
      	    MYCRYPTO_CFLAGS="`$MYCRYPTO_CONFIG --cflags`"
      	    MYCRYPTO_VERSION="`$MYCRYPTO_CONFIG --version`"
      	    XMLSEC_NO_MYCRYPTO="0"
      	else
          	    AC_MSG_ERROR(You need at least mycrypto $MYCRYPTO_MIN_VERSION for this version of $PACKAGE)
      	fi
          fi

          dnl update crypt libraries list
          if test "z$XMLSEC_NO_MYCRYPTO" = "z0" ; then
      	dnl first crypto library is default one
      	if test "z$XMLSEC_CRYPTO" = "z" ; then
      	    XMLSEC_CRYPTO="mycrypto"
          	    XMLSEC_CRYPTO_LIB="xmlsec1-mycrypto"
      	    XMLSEC_CRYPTO_CFLAGS="$MYCRYPTO_CFLAGS -DXMLSEC_CRYPTO_MYCRYPTO=1"
      	    XMLSEC_CRYPTO_LIBS="$MYCRYPTO_LIBS"
      	    XMLSEC_CRYPTO_LDADDS="$MYCRYPTO_LDADDS"
      	fi
      	XMLSEC_CRYPTO_LIST="$XMLSEC_CRYPTO_LIST mycrypto"
          	AC_MSG_RESULT(yes ('$MYCRYPTO_VERSION'))
          else
      	XMLSEC_CRYPTO_DISABLED_LIST="$XMLSEC_CRYPTO_DISABLED_LIST mycrypto"
      	AC_MSG_RESULT(no)
          fi
      fi
      AC_SUBST(XMLSEC_NO_MYCRYPTO)
      AC_SUBST(MYCRYPTO_MIN_VERSION)
      AC_SUBST(MYCRYPTO_VERSION)
      AC_SUBST(MYCRYPTO_CONFIG)
      AC_SUBST(MYCRYPTO_PREFIX)
      AC_SUBST(MYCRYPTO_CFLAGS)
      AC_SUBST(MYCRYPTO_LIBS)
      AC_SUBST(MYCRYPTO_LDADDS)
      AC_SUBST(XMLSEC_MYCRYPTO_DEFINES)

      ...
      AC_OUTPUT([
      ...
      include/xmlsec/mycrypto/Makefile
      src/mycrypto/Makefile
      ...
      ])
Modify "xmlsec.spec.in" file to create "xmlsec-mycrypto" RPM (if necessary). By now you should be able to sucessfuly compile XML Security Library with MyCrypto library (we disable all other libraries to make sure that xmlsec command line utility is linked against xmlsec-mycrypto library): Example 5. Compiling the results.
    ./autogen.sh --without-openssl --without-nss --without-gnutls --without-gcrypt \
        	     --with-mycrypto=$HOME --disable-tmpl-tests
    make