2003-10-26 Sebastien Pouliot <spouliot@videotron.ca>
[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 external 
18                   tools.
19
20                 * MACTripleDES is compatible with the implementation shipped in
21                   framework 1.0. Version 1.1 gives different results when the
22                   MACed data is a multiple of BlockSize (8 bytes).
23         </ul>
24
25 **** TODO
26         <ul>
27                 * RNGCryptoServiceProvider is currently only working on Linux.
28                   The current implementation reside in Mono's runtime and use 
29                   the <code>/dev/[u]random</code> device (which do not exists 
30                   under Windows). A Windows specific alternative is available 
31                   using the Mono.Security.Win32 assembly.
32
33                 * Keypair persistance for RSA and DSA. This persistance must
34                   somehow be linked with X509 certificate stores (in planning).
35
36                 * <code>PasswordDeriveBytes.CryptDeriveKey</code> is included 
37                   in MS BCL to provide compatibility with existing Windows 
38                   applications. The main problem is that the key derivation 
39                   algorithm can be different for every CSP (Crypto Service 
40                   Provider). However for compatibility we should provide an
41                   implementation compatible with the MS CSP (most likely used).
42         </ul>
43
44 **** Notes
45         <ul>
46                 * All cryptographic algorithms are entirely managed, including 
47                   classes named <code>*CryptoServiceProvider</code>, with the 
48                   exception of <code>RNGCryptoServiceProvider</code> (which 
49                   implementation resides in the runtime).
50
51                 * There is a bug in the <code>PKCS1MaskGenerationMethod</code>
52                   class (in both framework 1.0 and 1.1). This means our 
53                   implementation isn't compatible with MS (but is compatible with
54                   PKCS#1 v.2.1). However we get OAEP padding for every platform!
55
56                 * Look at assembly Mono.Security.Win32 if you require more
57                   compatiblity with the Microsoft implementation (like accessing
58                   a particuliar keypair container inside a specific CSP).
59         </ul>
60
61
62 *** Namespace: <b>System.Security.Cryptography.X509Certificates</b>
63
64 **** Status
65         <ul>
66                 * X.509 certificates are parsed using 100% managed code 
67                   (using the Mono.Security.ASN1 class). 
68
69                 * Software Publisher Certificates (SPC) used by Authenticode
70                   (tm) to sign assemblies are supported and <b>minimally</b>
71                   validated.
72
73                 * Unit tests are generated from a set of existing certificates
74                   (about a dozen) each having different properties. Another
75                   set of certificates (more than 700) are used for a more 
76                   complete test (but isn't part of the standard test suite for 
77                   size and time consideration, i.e. a 7.5Mb C# source file).
78         </ul>
79
80 **** Notes
81         <ul>
82                 * Except for their structure <b>there are no validation of the
83                   certificates</b> done by this class (this is by design and 
84                   isn't a restriction of Mono!). This means that certificate 
85                   signatures and validity dates are <b>never</b> checked 
86                   (except when used for Authenticode, i.e. 
87                   <code>CreateFromSignedFile</code>).
88
89                 * The newer X509Certificate class included in Microsoft's Web 
90                   Service Enhancement (WSE) is a little better (as it includes 
91                   CryptoAPI's validation) when <code>IsCurrent</code> is called.
92                   See assembly <b>Microsoft.Web.Services</b> for more details.
93
94                 * The class Mono.Security.X509.X509Certificate (in Mono.Security 
95                   assembly) is becoming a much better alternative - and will 
96                   continue to evolve to support the security tools.
97
98                 * Microsoft implementation of <code>X509Certificate</code> is 
99                   done by using CryptoAPI (unmanaged code). Based on the 
100                   exceptions thrown, Authenticode(tm) support is done via COM.
101         </ul>
102
103 <hr>
104 ** Assembly: System.Security
105
106 *** Namespace: <b>System.Security.Cryptography.Xml</b>
107
108         This namespace implements the <a href="http://www.w3.org/TR/xmldsig-core/">
109         XML Digital Signature</a> specification from 
110         <a href="http://www.w3.org/">W3C</a>.
111
112 **** Status
113         <ul>
114                 * All classes are present but some Transforms are only stubbed. 
115
116                 * We now have a fully managed C14N implementation.
117
118                 * Most classes have their unit tests.
119         </ul>
120
121 **** TODO
122         <ul>
123                 * Complete all Transform derived classes.
124         </ul>
125
126 <hr>
127 ** Assembly: Mono.Security
128
129         <b>Rational: </b>
130         This assembly provides the missing pieces to .NET security. On Windows
131         CryptoAPI is often used to provide much needed functionalities (like
132         some cryptographic algorithms, code signing, X.509 certificates). Mono,
133         for platform independance, implements these functionalities in 100% 
134         managed code.
135
136 *** Namespace: Mono.Security
137         <ul>
138                 * Structures (ASN1, PKCS7) and primitives (PKCS1).
139         </ul>
140 *** Namespace: Mono.Security.Authenticode
141         <ul>
142                 * Code signing and verification.
143                 * Support for SPC (Software Publisher Certificate) files and 
144                   PVK (Private Key) files.
145         </ul>
146 *** Namespace: Mono.Security.Cryptography
147         <ul>
148                 * Additional algorithms: MD2, ARCFOUR (required for SSL)
149                 * Convertion helpers
150         </ul>
151 *** Namespace: Mono.Security.Protocol.Tls
152         <ul>
153                 * An 100% managed TLS implementation from Carlos Guzman Alvarez.
154         </ul>
155 *** Namespace: Mono.Security.X509
156         <ul>
157                 * X.509 structures (certificate, CRL...) building and decoding.
158         </ul>
159 *** Namespace: Mono.Security.X509.Extensions
160         <ul>
161                 * X.509 extensions (from public X.509 to private PKIX, Netsapce, 
162                   Microsoft, Entrust...).
163         </ul>
164
165 **** Status
166         <ul>
167                 * A big part of this assembly is also included inside Mono's
168                   corlib. The classes are duplicated in this assembly so the 
169                   functionalities can be used without a dependency on Mono's 
170                   corlib (which depends on Mono's runtime).
171
172                 * Unit test coverage isn't (yet) complete.
173         </ul>
174
175 <hr>
176 ** Assembly: Mono.Security.Win32
177
178         <b>Rational: </b>
179         This assembly goal is to provide maximum compatibility with CryptoAPI
180         to application running with Mono's runtime on the Windows operating 
181         system.
182
183         <b>This assembly should NEVER be used directly by any application</b>
184         (e.g. referecing the assembly from a project).
185         The classes should only be used by modifying the <code>machine.config
186         </code> configuration file (and then only if this increased 
187         compatibility is required by an application).
188
189         See the file <code><a href="http://cvs.hispalinux.es/cgi-bin/cvsweb/~checkout~/mcs/class/Mono.Security.Win32/README?rev=1.1&content-type=text/plain&cvsroot=mono">/mcs/class/Mono.Security.Win32/README</a></code>
190         for complete instructions.
191
192 *** Namespace: Mono.Security.Cryptography
193
194 **** Status
195         <ul>
196                 * A RNGCryptoServiceProvider built on top of CryptoAPI. This
197                   allows Windows users to get around the limitation of the 
198                   runtime RNG (which requires <code>/dev/[u]random/</code>).
199
200                 * Wrapper classes for unmanaged versions of hash algorithms:
201                   MD2, MD4, MD5 and SHA1 are supported. <b>note</b>: some 
202                   algorithms shouldn't be used in new design (MD4 is broken, 
203                   MD2 and MD5 aren't considered safe for some usage). They are 
204                   included to preserve interoperability with older applications
205                   (e.g. some old, but still valid, X.509 certificates use MD2,
206                   MD4 is required for NTLM authentication ...).
207         </ul>
208
209 **** TODO
210         <ul>
211                 * Wrapper classes for unmanaged versions of symmetric 
212                   encryption algorithms (like DES, TripleDES, RC2 and others 
213                   present in default CSP).
214
215                 * Wrapper classes for unmanaged versions of asymmetric 
216                   algorithms (like DSA and RSA) which persist their keypair 
217                   into the specified CSP.
218         </ul>
219
220 **** Ideas
221         <ul>
222                 * Similar assemblies (e.g. <code>Mono.Security.XXX</code>) 
223                   could be created for <a href="http://www.openssl.org">OpenSSL</a>,
224                   <a href="http://www.mozilla.org/projects/security/pki/nss/">NSS</a>,
225                   <a href="http://www.eskimo.com/~weidai/cryptlib.html">crypto++</a>,
226                   <a href="http://www.cryptlib.orion.co.nz/">cryptlib</a> ... for 
227                   improved performance and/or HSM (Hardware Security Module) support 
228                   under Linux and/or Windows.
229         </ul>
230 <hr>
231 ** Assembly: Microsoft.Web.Services
232
233         Microsoft Web Service Enhancement (WSE), known as Web Service 
234         Development Kit (WSDK) in it's beta days, is an add-on the .NET
235         framework that implements WS-Security (and other WS-* specifications).
236         It also includes improved support for XML Signature (replacing and/or
237         extending <code>System.Security.Cryptography.Xml</code>) and X.509
238         certificates classes.
239
240         Note: WSE is distributed as an add-on because some specifications,
241         like WS-Security, aren't yet completed by 
242         <a href="http://www.oasis-open.org/committees/wss/">OASIS</a> or
243         other committees.
244
245 *** Namespace: Microsoft.Web.Services.Security
246
247 **** Status
248         <ul>
249                 * Most WSE 1.0 classes are implemented.
250         </ul>
251
252 **** TODO
253         <ul>
254                 * Some classes from System.Security assembly need to be 
255                 duplicated (and somewhat fixed) in WSE for XMLDSIG.
256
257                 * There are still missing classes and <b>many</b> missing
258                 unit tests.
259         </ul>
260
261
262 *** Namespace: Microsoft.Web.Services.Timestamp
263
264 **** Status
265         <ul>
266                 * This seems complete for WSE 1.0 but some new classes were 
267                 introduced in WSE 2.0.
268         </ul>
269
270 *** Namespace: Microsoft.Web.Services.Security.X509
271
272 **** Status
273         <ul>
274                 * X509Certificate support is complete for both WSE 1.0 and 2.0.
275         </ul>
276
277 **** TODO
278         <ul>
279                 * We need to define certificate stores (for both users and
280                   machines). These sames stores must be linked with asymmetric
281                   keypairs. This could also be used to store the SPC roots.
282         </ul>
283
284 *** Notes
285         <ul>
286                 * Microsoft has <a href="http://microsoft.com/downloads/details.aspx?FamilyId=21FB9B9A-C5F6-4C95-87B7-FC7AB49B3EDD&displaylang=en">released</a>
287                 a technical preview of WSE 2. <b>Note that WSDK (the technical 
288                 preview of WSE) had A LOT of changes before it's initial 
289                 release!</b>
290         </ul>
291
292 <hr>
293 ** Tools
294
295         There are many tools in the .NET framework that indirectly interacts 
296         with some cryptographic classes. Mono will eventually need these tools.
297         Unless noted the tools should work on any CLR (tested with both Mono 
298         and Microsoft).
299
300 **** Status
301
302         The following tools are complete (or mostly complete):
303         <ul>
304                 * <code>secutil</code> is a tool to extract certificates and 
305                   strongnames from assemblies in a format that can be easily 
306                   re-used in source code (C# or VB.NET syntax).
307
308                 * <code>cert2spc</code> is a tool to transform multiple X.509 
309                    certificates and CRLs into a Software Publisher Certificate
310                   (SPC) file - which is a long name for a simple PKCS#7 file.
311
312                 * <code>makecert</code> to create X.509 test certificates that 
313                   can be used (once transformed in SPC) to sign assemblies. It's
314                   now possible to generate SSL certificates for web servers.
315
316                 * <code>sn</code> is a clone of the <code>sn</code> to manage
317                   strongnames. Current version can create, convert, sign and
318                   verify strongnames signatures. Some configuration options 
319                   are still missing.
320
321                 * <code>signcode</code> and <code>chktrust</code> for signing 
322                   and validating Authenticode(tm) signatures on assemblies (or 
323                   any PE file) are now working (signature and timestamps) but 
324                   some options aren't yet supported.
325         </ul>
326
327         Somewhat usable, somewhat incomplete:
328         <ul>
329                 * <code>certview</code> is a certificate viewer for 
330                   <code>System.Windows.Forms</code> (right now only working on 
331                   Windows), while <code>gcertview</code> is the same viewer 
332                   implemented for GTK# (working on both Windows and Linux).
333
334                 * <code>monosn</code> is a clone of the <code>sn</code> to manage
335                   strongnames. This tools is part of the runtime (not the class
336                   library) and as such is written in C and won't run without Mono.
337         </ul>
338
339
340 **** TODO
341         The following tools are still missing or largely incomplete:
342         <ul>
343                 * Other tools like a, GUI-based, certificate manager...
344         </ul>
345
346         Note that many of the tools requires the class library and/or the
347         runtime to be ready for them. E.g. StrongName and Authenticode signatures
348         tools are of limited use until supported by the runtime.
349
350 <hr>
351 ** References
352
353         <ul>
354                 * RSA Laboratories' <a href="http://www.rsasecurity.com/rsalabs/faq/index.html">
355                 Frequently Asked Questions</a> About Today's Cryptography, Version 4.1
356
357                 * Public-Key Cryptography Standards (<a href="http://www.rsasecurity.com/rsalabs/pkcs/index.html">
358                 PKCS</a>)
359
360                 * National Institute of Standards and Technology - Federal 
361                 Information Processing Standards <a href="http://csrc.nist.gov/publications/fips/index.html">
362                 NIST FIPS</a>
363         </ul>
364
365 <hr>
366 ** How to Help
367
368         <ul>
369                 * Complete any of the TODO (and feel good about it ;-).
370
371                 * Analyse the current coverage of the unit tests on the 
372                   cryptographic classes and complete the unit tests. <b><code>
373                   monocov</code> does a great job at this! Now we just need to
374                   complete the missing unit tests.</b>
375
376                 * Optimization can also be done on most algorithms as crypto 
377                   is never fast enough. Some have been done using the 
378                   Community Edition of BoundChecker (a free VisualStudio 
379                   addon) - recommanded! Just be sure to test every optimization
380                   (using the unit tests) carefully - it's so fast to break an
381                   algorithm ;-).
382
383                 * Write some documentation on the cryptographic classes for 
384                   <b>monodoc</b> as I'm not a very good writer (at least in English).
385         </ul>
386
387         Contact Sebastien Pouliot (<a href="mailto:spouliot@videotron.ca">home</a>
388         , <a href="mailto:spouliot@motus.com">work</a>) if you need additional
389         informations about the status of the cryptographic classes.
390
391 <hr>
392 Last reviewed: October 26, 2003 (post mono 0.28)