*** empty log message ***
[mono.git] / web / crypto
1 * Cryptography
2
3         In the .NET framework cryptography can be found under a number of
4         namespaces in several assemblies.
5
6 ** Assembly: corlib
7
8 *** Namespace: <b>System.Security.Cryptography</b>
9
10         Thanks to the work of many people this namespace is almost complete.
11
12 **** Status
13         <ul>
14                 * Every classes are present.
15
16                 * Most classes have their unit tests. Some tests like <code>
17                   SymmetricAlgorithmTest</code> are generated by an external 
18                   tool.
19         </ul>
20
21 **** TODO
22         <ul>
23                 * The current implementation of <code>CryptoStream</code> is
24                   very limited and contain known bugs (<a 
25                   href="http://bugzilla.ximian.com/show_bug.cgi?id=40689">
26                   40689</a>). The class need to be re-designed.
27
28                 * Support for adding/modifying OID using the 
29                   <code>machine.config</code> configuration file (algorithms 
30                   are done).
31
32                 * RNGCryptoServiceProvider is currently only working on Linux.
33                   The current implementation reside in Mono's runtime and use 
34                   the <code>/dev/[u]random</code> device (which do not exists 
35                   under Windows). A Windows specific alternative is available 
36                   using the Mono.Security.Win32 assembly.
37
38                 * Keypair persistance for RSA and DSA. This persistance must
39                   somehow be linked with X509 certificate stores (in planning).
40
41                 * <code>PasswordDeriveBytes.CryptDeriveKey</code> is included 
42                   in MS BCL to provide compatibility with existing Windows 
43                   applications. The main problem is that the key derivation 
44                   algorithm can be different for every CSP (Crypto Service 
45                   Provider). However for compatibility we should provide an
46                   implementation compatible with the MS CSP (most likely used).
47
48                 * Analyse the current coverage of the unit tests on the 
49                   cryptographic classes and complete the unit tests.
50
51                 * Optimizations (performance) on most class are possible. Some
52                   have been done using the Community Edition of BoundChecker 
53                   (a free VisualStudio addon) - recommanded!
54         </ul>
55
56 **** Notes
57         <ul>
58                 * All cryptographic algorithms are entirely managed, including 
59                   classes named <code>*CryptoServiceProvider</code>, with the 
60                   exception of <code>RNGCryptoServiceProvider</code> (which 
61                   resides in the runtime).
62
63                 * Look at assembly Mono.Security.Win32 if you require more
64                   compatiblity with the Microsoft implementation (like accessing
65                   a particuliar keypair container inside a specific CSP).
66         </ul>
67
68
69 *** Namespace: <b>System.Security.Cryptography.X509Certificates</b>
70
71 **** Status
72         <ul>
73                 * X.509 certificates are parsed using 100% managed code 
74                   (using the Mono.Security.ASN1 class). 
75
76                 * Software Publisher Certificates (SPC) used by Authenticode
77                   (tm) to sign assemblies are supported (extraction from PE 
78                   files) but <b>not yet</b> validated.
79
80                 * Unit tests are generated from a set of existing certificates
81                   (about a dozen) each having different properties. Another
82                   set of certificates (more than 300) are used for a more 
83                   complete test (but isn't part of the standard test suite for 
84                   size and time consideration, i.e. a 3.5Mb C# source file).
85         </ul>
86
87 **** TODO
88         <ul>
89                 * Authenticode(tm) support is incomplete. We can extract the
90                   certificates from PE files but cannot validate the signature
91                   nor the certificate chain (and we're still missing some trust
92                   anchors). See Tools section for more information.
93
94                 * Integration with CryptoAPI (on Windows) isn't possible as 
95                   long as the <code>X509Certificate(IntPtr)</code> constructor 
96                   isn't completed.
97         </ul>
98
99 **** Notes
100         <ul>
101                 * Except for their structure <b>there are no validation of the
102                   certificates</b> done by this class (this is by design and 
103                   isn't a restriction of Mono!). This means that certificate 
104                   signatures and validity dates are <b>never</b> checked 
105                   (except when used for Authenticode, i.e. 
106                   <code>CreateFromSignedFile</code>).
107
108                 * The newer X509Certificate class included in Microsoft's Web 
109                   Service Enhancement (WSE) is a little better (as it includes 
110                   CryptoAPI's validation) when <code>IsCurrent</code> is called.
111                   See assembly <b>Microsoft.Web.Services</b> for more details.
112
113                 * The class Mono.Security.X509.X509Certificate (in Mono.Security 
114                   assembly) is becoming a much better alternative - and will 
115                   continue to evolve to support the security tools.
116
117                 * Microsoft implementation of <code>X509Certificate</code> is 
118                   done by using CryptoAPI (unmanaged code). From the exceptions 
119                   thrown Authenticode(tm) support is done via COM.
120         </ul>
121
122 <hr>
123 ** Assembly: System.Security
124
125 *** Namespace: <b>System.Security.Cryptography.Xml</b>
126
127         This namespace implements the <a href="http://www.w3.org/TR/xmldsig-core/">
128         XML Digital Signature</a> specification from 
129         <a href="http://www.w3.org/">W3C</a>.
130
131 **** Status
132         <ul>
133                 * All classes are present but some (most Transforms) are only 
134                   stubbed.
135
136                 * Most classes have their unit tests.
137         </ul>
138
139 **** TODO
140         <ul>
141                 * All the transforms needs to be done. But this requires far 
142                   more XML knowledge than crypto. Note: Most tests runs because
143                   the feeded XML is pre-c14n (by hand in the code) before 
144                   signing (not because the transforms works). In the short
145                   term <code>libxml2</code> could be used to provide C14N, but 
146                   in the long term a fully managed class would be much better.
147         </ul>
148
149 <hr>
150 ** Assembly: Mono.Security
151
152         <b>Rational</b>
153         This assembly provides the missing pieces to .NET security. On Windows
154         CryptoAPI is often used to provide much needed functionalities (like
155         some cryptographic algorithms, code signing, X.509 certificates).
156
157 *** Namespace: Mono.Security
158         <ul>
159                 * Structures (ASN1, PKCS7) and primitives (PKCS1).
160         </ul>
161 *** Namespace: Mono.Security.Authenticode
162         <ul>
163                 * Code signing and verification.
164                 * Support for SPC files and PVK files.
165         </ul>
166 *** Namespace: Mono.Security.Cryptography
167         <ul>
168                 * Additional algorithms: MD2, ARCFOUR (required for SSL)
169                 * Convertion helpers
170         </ul>
171 *** Namespace: Mono.Security.X509
172         <ul>
173                 * X.509 certificate building and decoding.
174         </ul>
175 *** Namespace: Mono.Security.X509.Extensions
176         <ul>
177                 * X.509 extensions (from X.509, PKIX, Netsapce, Microsoft,
178                   Entrust...).
179         </ul>
180
181 **** Status
182         <ul>
183                 * Some part of the work has not yet been commited (cleaning up).
184
185                 * A big part of this assembly is also included inside Mono's
186                   corlib. The class are duplicated in this assembly so the 
187                   functionalities can be used without a dependency on Mono's 
188                   corlib (which depends on Mono's runtime).
189
190                 * Unit test coverage isn't (yet) complete.
191         </ul>
192
193 <hr>
194 ** Assembly: Mono.Security.Win32
195
196         <b>Rational</b>
197         This assembly goal is to provide maximum compatibility with CryptoAPI
198         to application running with Mono's runtime on the Windows operating 
199         system.
200
201         <b>This assembly should NEVER be used directly by any application</b>.
202         The classes should only be used by modifying the <code>machine.config
203         </code> configuration file (and then only if this increased 
204         compatibility is required by an application).
205
206         See the file <code>/mcs/class/Mono.Security.Win32/README</code> for 
207         complete instructions.
208
209 *** Namespace: Mono.Security.Cryptography
210
211 **** Status
212         <ul>
213                 * A RNGCryptoServiceProvider built on top of CryptoAPI. This
214                   allows Windows users to get around the limitation of the 
215                   runtime RNG (which requires <code>/dev/[u]random/</code>).
216
217                 * Wrapper classes for unmanaged versions of hash algorithms:
218                   MD2, MD4, MD5 and SHA1 are supported. <b>note</b>: some 
219                   algorithms shouldn't be used in new design (MD4 is broken and
220                   MD2 isn't considered safe). They are included to preserve
221                   interoperability with older applications (e.g. some old, but 
222                   still valid, X.509 certificates use MD2).
223         </ul>
224
225 **** TODO
226         <ul>
227                 * Wrapper classes for unmanaged versions of symmetric 
228                   encryption algorithms (like DES, TripleDES, RC2 and others 
229                   present in default CSP).
230
231                 * Wrapper classes for unmanaged versions of asymmetric 
232                   algorithms (like DSA and RSA) which persist their keypair 
233                   into the specified CSP.
234         </ul>
235
236 **** Ideas
237         <ul>
238                 * Similar assembly could be created for <a href="http://www.openssl.org">
239                   OpenSSL</a>, NSS, crypto++, cryptlib ... for improved 
240                   performance and/or HSM support under Linux.
241         </ul>
242 <hr>
243 ** Assembly: Microsoft.Web.Services
244
245         Microsoft Web Service Enhancement (WSE), known as Web Service 
246         Development Kit (WSDK) in it's beta days, is an add-on the .NET
247         framework that implements WS-Security (and other WS-* specifications).
248         It also includes improved support for XML Signature (replacing and/or
249         extending <code>System.Security.Cryptography.Xml</code>) and X.509
250         certificates classes.
251
252         Note: WSE is distributed as an add-on because some specifications,
253         like WS-Security, aren't yet completed by 
254         <a href="http://www.oasis-open.org/committees/wss/">OASIS</a> or
255         other committees.
256
257         <b>[*] There are some licensing issues to consider before stating to 
258         implement WS-Security. All contributors must sign an agreement with 
259         Microsoft before commiting anything related to WS-Security into CVS.
260         </b>
261
262 *** Namespace: Microsoft.Web.Services.Security [*]
263 *** Namespace: Microsoft.Web.Services.Timestamp [*]
264
265 **** Status
266         <ul>
267                 * Nothing (yet) commited in CVS <b>[*]</b>.
268         </ul>
269
270 *** Namespace: Microsoft.Web.Services.Security.X509
271
272 **** Status
273         <ul>
274                 * Nothing (yet) commited in CVS. However the classes in this 
275                   namespace are outside WS-Security scope. So development, for 
276                   those, could be done without signing any agreements.
277         </ul>
278
279 **** TODO
280         <ul>
281                 * We need to define certificate stores (for both users and
282                   machines). These sames stores must be linked with asymmetric
283                   keypairs. This could also be used to store the SPC roots.
284         </ul>
285
286 <hr>
287 ** Tools
288
289         There are many tools in the .NET framework that indirectly interacts 
290         with some cryptographic classes. Mono will eventually need these tools.
291         Unless noted the tools should work on any CLR (tested with both Mono 
292         and Microsoft).
293
294 **** Status
295
296         The following tools are complete:
297         <ul>
298                 * <code>secutil</code> is a tool to extract certificates and 
299                   strongnames from assemblies in a format that can be easily 
300                   re-used in source code (C# or VB.NET syntax).
301
302                 * <code>cert2spc</code> is a tool to transform multiple X.509 
303                    certificates and CRLs into a Software Publisher Certificate
304                   (SPC) file - which is a long name for a simple PKCS#7 file.
305
306                 * <code>makecert</code> to create X.509 test certificates that 
307                   can be used (once transformed in SPC) to sign assemblies.
308         </ul>
309
310 **** TODO
311         The following tools are still missing or incomplete:
312         <ul>
313                 * <code>monosn</code> is a clone of the <code>sn</code> to manage
314                   strongnames. This tools is part of the runtime (not the class
315                   library) and as such is written in C and won't run without Mono.
316
317                 * <code>signcode</code> and <code>chktrust</code> (in progress)
318                   for signing and validating Authenticode(tm) signatures on 
319                   assemblies (or any PE file).
320
321                 * Other tools like a, GUI-based, certificate manager...
322         </ul>
323
324         Note that many of the tools requires the class library and/or the
325         runtime to be ready for them. E.g. StrongName and Authenticode signatures
326         tools are of limited use until supported by the runtime.
327
328 <hr>
329 ** Other stuff
330
331         <ul>
332                 * SSL/TLS for secure communication (a prototype is under way).
333                   Some work is already visible in Mono.Security assembly (e.g. 
334                   RC4).
335         </ul>
336
337
338 <hr>    
339 ** How to Help
340
341         Complete any of the TODO (and feel good about it ;-).
342
343         Add missing unit tests to classes or methods.
344
345         Write some documentation on the cryptographic classes for the 
346         <a href="http://go-mono.com/tutorial/html/en/index.html">Mono 
347         Handbook</a> as I'm not a very good writer (at least in English).
348
349         Optimization can also be done on algorithms as crypto is never fast 
350         enough. Just be sure to test every optimization (using the unit test)
351         carefully - it's so fast to break an algorithm ;-).
352
353         Contact Sebastien Pouliot (<a href="mailto:spouliot@videotron.ca">home</a>
354         , <a href="mailto:spouliot@motus.com">work</a>) if you need additional
355         informations about the status of the cryptographic classes.
356
357 <hr>
358 Last reviewed: April 7, 2003 (post mono 0.23)