Git init
[external/xmlsec1.git] / docs / api / xmlsec-notes-new-crypto-skeleton.html
1 <html>
2 <head>
3 <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
4 <title>Creating a framework from the skeleton.</title>
5 <meta name="GENERATOR" content="Modular DocBook HTML Stylesheet Version 1.79">
6 <link rel="HOME" title="XML Security Library Reference Manual" href="index.html">
7 <link rel="UP" title="Adding support for new cryptographic library." href="xmlsec-notes-new-crypto.html">
8 <link rel="PREVIOUS" title="Adding support for new cryptographic library." href="xmlsec-notes-new-crypto.html">
9 <link rel="NEXT" title="xmlSecCryptoApp* functions." href="xmlsec-notes-new-crypto-functions.html">
10 <style type="text/css">.synopsis, .classsynopsis {
11     background: #eeeeee;
12     border: solid 1px #aaaaaa;
13     padding: 0.5em;
14 }
15 .programlisting {
16     background: #eeeeff;
17     border: solid 1px #aaaaff;
18     padding: 0.5em;
19 }
20 .variablelist {
21     padding: 4px;
22     margin-left: 3em;
23 }
24 .navigation {
25     background: #ffeeee;
26     border: solid 1px #ffaaaa;
27     margin-top: 0.5em;
28     margin-bottom: 0.5em;
29 }
30 .navigation a {
31     color: #770000;
32 }
33 .navigation a:visited {
34     color: #550000;
35 }
36 .navigation .title {
37     font-size: 200%;
38 }</style>
39 </head>
40 <body><table witdh="100%" valign="top"><tr valign="top">
41 <td valign="top" align="left" width="210">
42 <img src="../images/logo.gif" alt="XML Security Library" border="0"><p></p>
43 <ul>
44 <li><a href="../index.html">Home</a></li>
45 <li><a href="../download.html">Download</a></li>
46 <li><a href="../news.html">News</a></li>
47 <li><a href="../documentation.html">Documentation</a></li>
48 <ul>
49 <li><a href="../faq.html">FAQ</a></li>
50 <li><a href="../api/xmlsec-notes.html">Tutorial</a></li>
51 <li><a href="../api/xmlsec-reference.html">API reference</a></li>
52 <li><a href="../api/xmlsec-examples.html">Examples</a></li>
53 </ul>
54 <li><a href="../xmldsig.html">XML Digital Signature</a></li>
55 <ul><li><a href="http://www.aleksey.com/xmlsec/xmldsig-verifier.html">Online Verifier</a></li></ul>
56 <li><a href="../xmlenc.html">XML Encryption</a></li>
57 <li><a href="../c14n.html">XML Canonicalization</a></li>
58 <li><a href="../bugs.html">Reporting Bugs</a></li>
59 <li><a href="http://www.aleksey.com/pipermail/xmlsec">Mailing list</a></li>
60 <li><a href="../related.html">Related</a></li>
61 <li><a href="../authors.html">Authors</a></li>
62 </ul>
63 <table width="100%">
64 <tr>
65 <td width="15"></td>
66 <td><a href="http://xmlsoft.org/"><img src="../images/libxml2-logo.png" alt="LibXML2" border="0"></a></td>
67 </tr>
68 <tr>
69 <td width="15"></td>
70 <td><a href="http://xmlsoft.org/XSLT"><img src="../images/libxslt-logo.png" alt="LibXSLT" border="0"></a></td>
71 </tr>
72 <tr>
73 <td width="15"></td>
74 <td><a href="http://www.openssl.org/"><img src="../images/openssl-logo.png" alt="OpenSSL" border="0"></a></td>
75 </tr>
76 <!--Links - start--><!--Links - end-->
77 </table>
78 </td>
79 <td valign="top"><table width="100%" valign="top"><tr><td valign="top" align="left" id="xmlsecContent">
80 <table width="100%" class="navigation" summary="Navigation header" cellpadding="2" cellspacing="2"><tr valign="middle">
81 <td><a accesskey="p" href="xmlsec-notes-new-crypto.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
82 <td><a accesskey="u" href="xmlsec-notes-new-crypto.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
83 <td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
84 <th width="100%" align="center">XML Security Library Reference Manual</th>
85 <td><a accesskey="n" href="xmlsec-notes-new-crypto-functions.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
86 </tr></table>
87 <br clear="all"><div class="SECT1">
88 <h1 class="SECT1"><a name="XMLSEC-NOTES-NEW-CRYPTO-SKELETON">Creating a framework from the skeleton.</a></h1>
89 <p>     The XML Security Library contains a "skeleton" for creating new
90         "xmlsec-&lt;crypto&gt;" libraries. In order to create "xmlsec-mycrypto"
91         library framework, do the following (this example assumes that you 
92         are using *nix system, adjust the commands if you are using something else):
93         </p>
94 <p></p>
95 <ul>
96 <li>
97 <p>     Copy src/skeleton and include/xmlsec/skeleton folders to src/mycrypto and
98         include/xmlsec/mycrypto folders and remove CVS folders from the result:
99         </p>
100 <div class="EXAMPLE">
101 <a name="AEN512"></a><p><b>Example 1. Coping skeleton folders.</b></p>
102 <pre class="PROGRAMLISTING">cd src
103 cp -r skeleton mycrypto
104 cd mycrypto
105 rm -rf CVS
106 cd ../..
107 cd include/xmlsec
108 cp -r skeleton mycrypto
109 cd mycrypto
110 rm -rf CVS
111 cd ../../..
112             </pre>
113 </div>  
114         </li>
115 <li>
116 <p>     Replace "skeleton" with "mycrypto" in the copied files (note that there
117         are different possible cases here):
118         </p>
119 <div class="EXAMPLE">
120 <a name="AEN517"></a><p><b>Example 2. Replacing "skeleton" with "mycrypto".</b></p>
121 <pre class="PROGRAMLISTING">for i in `ls include/xmlsec/mycrypto/* src/mycrypto/*`;  do 
122     echo Processing $i ..;
123     sed 's/skeleton/mycrypto/g' $i | \
124     sed 's/SKELETON/MYCRYPTO/g' | \
125     sed 's/Skeleton/MyCrypto/g' &gt; $i.tmp;
126     mv $i.tmp $i;
127 done
128             </pre>
129 </div>
130         </li>
131 <li>
132 <p>     Add "xmlsec-mycrypto" library to the "include/xmlsec/crypto.h" file:
133         </p>
134 <div class="EXAMPLE">
135 <a name="AEN522"></a><p><b>Example 3. Modifying include/xmlsec/crypto.h file.</b></p>
136 <pre class="PROGRAMLISTING">...     
137 #ifdef XMLSEC_CRYPTO_MYCRYPTO
138 #include &lt;xmlsec/mycrypto/app.h&gt;
139 #include &lt;xmlsec/mycrypto/crypto.h&gt;
140 #include &lt;xmlsec/mycrypto/symbols.h&gt;
141 #else /* XMLSEC_CRYPTO_MYCRYPTO */
142 ...
143 #endif /* XMLSEC_CRYPTO_MYCRYPTO */
144 ...
145             </pre>
146 </div>
147         </li>
148 <li>
149 <p>     Add "xmlsec-crypto" library to the configure.in file (for *nix systems;
150         for Windows you need to modify win32/confgure.js and win32/Makefile.msvc
151         files, see win32/README.txt for details):
152         </p>
153 <div class="EXAMPLE">
154 <a name="AEN527"></a><p><b>Example 4. Modifying configure.in file.</b></p>
155 <pre class="PROGRAMLISTING">dnl ==========================================================================
156 dnl See if we can find MyCrypto
157 dnl ==========================================================================
158 XMLSEC_MYCRYPTO_DEFINES=""
159 MYCRYPTO_CONFIG="mycrypto-config" # TODO
160 XMLSEC_NO_MYCRYPTO="1"
161 MYCRYPTO_MIN_VERSION="0.0.0" # TODO 
162 MYCRYPTO_VERSION=""
163 MYCRYPTO_PREFIX=""
164 MYCRYPTO_CFLAGS=""
165 MYCRYPTO_LIBS=""
166 MYCRYPTO_LDADDS=""
167 AC_MSG_CHECKING(for mycrypto libraries &gt;= $MYCRYPTO_MIN_VERSION) 
168 AC_ARG_WITH(mycrypto, [  --with-mycrypto=[PFX]    mycrypto location])
169 if test "$with_mycrypto" = "no" ; then
170     XMLSEC_CRYPTO_DISABLED_LIST="$XMLSEC_CRYPTO_DISABLED_LIST mycrypto"
171     AC_MSG_RESULT(no)
172 else
173     if test "$with_mycrypto" != "" ; then
174         MYCRYPTO_PREFIX=$with_mycrypto
175         MYCRYPTO_CONFIG=$MYCRYPTO_PREFIX/bin/$MYCRYPTO_CONFIG
176     fi
177     if ! $MYCRYPTO_CONFIG --version &gt; /dev/null 2&gt;&amp;1 ; then
178         if test "$with_mycrypto" != "" ; then
179             AC_MSG_ERROR(Unable to find mycrypto at '$with_mycrypto')
180         fi
181     else
182         vers=`$MYCRYPTO_CONFIG --version | awk -F. '{ printf "%d", ($1 * 1000 + $2) * 1000 + $3;}'`
183         minvers=`echo $MYCRYPTO_MIN_VERSION | awk -F. '{ printf "%d", ($1 * 1000 + $2) * 1000 + $3;}'`
184         if test "$vers" -ge "$minvers" ; then
185             MYCRYPTO_LIBS="`$MYCRYPTO_CONFIG --libs`"
186             MYCRYPTO_CFLAGS="`$MYCRYPTO_CONFIG --cflags`"
187             MYCRYPTO_VERSION="`$MYCRYPTO_CONFIG --version`"
188             XMLSEC_NO_MYCRYPTO="0"
189         else
190             AC_MSG_ERROR(You need at least mycrypto $MYCRYPTO_MIN_VERSION for this version of $PACKAGE)
191         fi      
192     fi
193
194     dnl update crypt libraries list
195     if test "z$XMLSEC_NO_MYCRYPTO" = "z0" ; then
196         dnl first crypto library is default one
197         if test "z$XMLSEC_CRYPTO" = "z" ; then
198             XMLSEC_CRYPTO="mycrypto"
199             XMLSEC_CRYPTO_LIB="xmlsec1-mycrypto"
200             XMLSEC_CRYPTO_CFLAGS="$MYCRYPTO_CFLAGS -DXMLSEC_CRYPTO_MYCRYPTO=1"
201             XMLSEC_CRYPTO_LIBS="$MYCRYPTO_LIBS"
202             XMLSEC_CRYPTO_LDADDS="$MYCRYPTO_LDADDS"
203         fi      
204         XMLSEC_CRYPTO_LIST="$XMLSEC_CRYPTO_LIST mycrypto"
205         AC_MSG_RESULT(yes ('$MYCRYPTO_VERSION'))
206     else
207         XMLSEC_CRYPTO_DISABLED_LIST="$XMLSEC_CRYPTO_DISABLED_LIST mycrypto"
208         AC_MSG_RESULT(no)
209     fi
210 fi
211 AC_SUBST(XMLSEC_NO_MYCRYPTO)
212 AC_SUBST(MYCRYPTO_MIN_VERSION)
213 AC_SUBST(MYCRYPTO_VERSION)
214 AC_SUBST(MYCRYPTO_CONFIG)       
215 AC_SUBST(MYCRYPTO_PREFIX)
216 AC_SUBST(MYCRYPTO_CFLAGS)
217 AC_SUBST(MYCRYPTO_LIBS)
218 AC_SUBST(MYCRYPTO_LDADDS)
219 AC_SUBST(XMLSEC_MYCRYPTO_DEFINES)
220
221 ...
222 AC_OUTPUT([
223 ...
224 include/xmlsec/mycrypto/Makefile
225 src/mycrypto/Makefile
226 ...
227 ])
228             </pre>
229 </div>
230         </li>
231 <li><p>Modify "xmlsec.spec.in" file to create "xmlsec-mycrypto"
232         RPM (if necessary).
233         </p></li>
234 </ul>
235         
236         By now you should be able to sucessfuly compile XML Security Library
237         with MyCrypto library (we disable all other libraries to make sure
238         that xmlsec command line utility is linked against xmlsec-mycrypto
239         library):
240         <div class="EXAMPLE">
241 <a name="AEN532"></a><p><b>Example 5. Compiling the results.</b></p>
242 <pre class="PROGRAMLISTING">./autogen.sh --without-openssl --without-nss --without-gnutls \
243              --with-mycrypto=$HOME --disable-tmpl-tests
244 make    
245             </pre>
246 </div>
247         </div>
248 <table class="navigation" width="100%" summary="Navigation footer" cellpadding="2" cellspacing="2"><tr valign="middle">
249 <td align="left"><a accesskey="p" href="xmlsec-notes-new-crypto.html"><b>&lt;&lt;&lt; Adding support for new cryptographic library.</b></a></td>
250 <td align="right"><a accesskey="n" href="xmlsec-notes-new-crypto-functions.html"><b>xmlSecCryptoApp* functions. &gt;&gt;&gt;</b></a></td>
251 </tr></table>
252 </td></tr></table></td>
253 </tr></table></body>
254 </html>