crypto 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  1. * Cryptography
  2. In the .NET framework cryptography can be found under a number of
  3. namespaces in several assemblies. Mono also has it's own assemblies
  4. to provide missing security functionalities from the .NET framework.
  5. ** Assembly: corlib
  6. *** Namespace: <b>System.Security.Cryptography</b>
  7. Thanks to the work of many people this namespace is almost complete.
  8. **** Status
  9. <ul>
  10. * All classes are present. Most of them have (minimal)
  11. documentation in <b>monodoc</b>.
  12. * Most classes have their unit tests. Some tests like <code>
  13. SymmetricAlgorithmTest</code> are generated by external
  14. tools.
  15. </ul>
  16. *** Namespace: <b>System.Security.Cryptography.X509Certificates</b>
  17. **** Status
  18. <ul>
  19. * X.509 certificates are parsed using 100% managed code
  20. (using the Mono.Security.ASN1 class).
  21. * Software Publisher Certificates (SPC) used by Authenticode
  22. (tm) to sign assemblies are supported and <b>minimally</b>
  23. validated.
  24. * Unit tests are generated from a set of existing certificates
  25. (about a dozen) each having different properties. Another
  26. set of certificates (more than 700) are used for a more
  27. complete test (but isn't part of the standard test suite for
  28. size and time consideration, i.e. a 7.5Mb C# source file).
  29. </ul>
  30. **** Notes
  31. <ul>
  32. * The class Mono.Security.X509.X509Certificate (in Mono.Security
  33. assembly) is becoming a much better alternative - and will
  34. continue to evolve to support the security tools.
  35. </ul>
  36. <hr>
  37. ** Assembly: System.Security
  38. *** Namespace: <b>System.Security.Cryptography.Xml</b>
  39. This namespace implements the <a href="http://www.w3.org/TR/xmldsig-core/">
  40. XML Digital Signature</a> specification from
  41. <a href="http://www.w3.org/">W3C</a>.
  42. **** Status
  43. <ul>
  44. * We pass the fifteen tests from Merlin's xmldsig suite with
  45. success. Which is funny because Microsoft fails in one case
  46. where both a X509Certificate and an X509CRL are present in
  47. an X509Data. We also pass most Phaos tests.
  48. * Most classes have their unit tests. Some standalone tests
  49. are also in CVS to test C14N and both Merlin and Phaos test
  50. suites.
  51. </ul>
  52. <hr>
  53. ** Assembly: Mono.Security
  54. <b>Rational: </b>
  55. This assembly provides the missing pieces to .NET security. On Windows
  56. CryptoAPI is often used to provide much needed functionalities (like
  57. some cryptographic algorithms, code signing, X.509 certificates). Mono,
  58. for platform independance, implements these functionalities in 100%
  59. managed code.
  60. *** Namespace: Mono.Security
  61. <ul>
  62. * Structures (ASN1, PKCS7) and primitives (PKCS1).
  63. </ul>
  64. *** Namespace: Mono.Security.Authenticode
  65. <ul>
  66. * Code signing and verification.
  67. * Support for SPC (Software Publisher Certificate) files and
  68. PVK (Private Key) files.
  69. </ul>
  70. *** Namespace: Mono.Security.Cryptography
  71. <ul>
  72. * Additional algorithms: MD2, MD4, ARCFOUR (required for SSL)
  73. * Convertion helpers
  74. </ul>
  75. *** Namespace: Mono.Security.Protocol.*
  76. <ul>
  77. * Tls: An 100% managed SSLv3 and TLSv1 implementation from
  78. Carlos Guzman Alvarez.
  79. * Ntlm: NTLM authentication (used for HTTP and SQL Server).
  80. </ul>
  81. *** Namespace: Mono.Security.X509.*
  82. <ul>
  83. * X.509 structures (certificate, CRL...) building and decoding.
  84. * PKCS#12 decoding and encoding.
  85. * X.509 extensions (from public X.509 to private PKIX, Netsapce,
  86. Microsoft, Entrust...).
  87. </ul>
  88. **** Status
  89. <ul>
  90. * A big part of this assembly is also included inside Mono's
  91. corlib. The classes are duplicated in this assembly so the
  92. functionalities can be used without a dependency on Mono's
  93. corlib (which depends on Mono's runtime).
  94. * Unit test coverage isn't (yet) complete.
  95. * Most classes have minimal documentation available in
  96. <b>monodoc</b>.
  97. </ul>
  98. <hr>
  99. ** Assembly: Mono.Security.Win32
  100. <b>Rational: </b>
  101. This assembly goal is to provide maximum compatibility with CryptoAPI
  102. to application running with Mono's runtime on the Windows operating
  103. system.
  104. <b>This assembly should NEVER be used directly by any application</b>
  105. (e.g. referecing the assembly from a project).
  106. The classes should only be used by modifying the <code>machine.config
  107. </code> configuration file (and then only if this increased
  108. compatibility is required by an application).
  109. 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>
  110. for complete instructions.
  111. *** Namespace: Mono.Security.Cryptography
  112. **** Status
  113. <ul>
  114. * A RNGCryptoServiceProvider built on top of CryptoAPI.
  115. * Wrapper classes for unmanaged versions of hash algorithms:
  116. MD2, MD4, MD5 and SHA1 are supported. <b>note</b>: some
  117. algorithms shouldn't be used in new design (MD4 is broken,
  118. MD2 and MD5 aren't considered safe for some usage). They are
  119. included to preserve interoperability with older applications
  120. (e.g. some old, but still valid, X.509 certificates use MD2,
  121. MD4 is required for NTLM authentication ...).
  122. * Classes have minimal documentation available in
  123. <b>monodoc</b>.
  124. </ul>
  125. **** TODO
  126. <ul>
  127. * Wrapper classes for unmanaged versions of symmetric
  128. encryption algorithms (like DES, TripleDES, RC2 and others
  129. present in default CSP).
  130. * Wrapper classes for unmanaged versions of asymmetric
  131. algorithms (like DSA and RSA) which persist their keypair
  132. into the specified CSP.
  133. </ul>
  134. **** Ideas
  135. <ul>
  136. * Similar assemblies (e.g. <code>Mono.Security.XXX</code>)
  137. could be created for <a href="http://www.openssl.org">OpenSSL</a>,
  138. <a href="http://www.mozilla.org/projects/security/pki/nss/">NSS</a>,
  139. <a href="http://www.eskimo.com/~weidai/cryptlib.html">crypto++</a>,
  140. <a href="http://www.cryptlib.orion.co.nz/">cryptlib</a> ... for
  141. improved performance and/or HSM (Hardware Security Module) support
  142. under Linux and/or Windows.
  143. </ul>
  144. <hr>
  145. ** Assembly: Microsoft.Web.Services
  146. Microsoft Web Service Enhancement (WSE), known as Web Service
  147. Development Kit (WSDK) in it's beta days, is an add-on the .NET
  148. framework that implements WS-Security (and other WS-* specifications).
  149. It also includes improved support for XML Signature (replacing and/or
  150. extending <code>System.Security.Cryptography.Xml</code>) and X.509
  151. certificates classes.
  152. Note: WSE is distributed as an add-on because some specifications,
  153. like WS-Security, aren't yet completed by
  154. <a href="http://www.oasis-open.org/committees/wss/">OASIS</a> or
  155. other committees.
  156. *** Namespace: Microsoft.Web.Services.Security
  157. **** Status
  158. <ul>
  159. * Most WSE 1.0 classes are implemented.
  160. </ul>
  161. **** TODO
  162. <ul>
  163. * Some classes from System.Security assembly need to be
  164. duplicated (and somewhat fixed) in WSE for XMLDSIG.
  165. * There are still missing classes and <b>many</b> missing
  166. unit tests.
  167. </ul>
  168. *** Namespace: Microsoft.Web.Services.Timestamp
  169. **** Status
  170. <ul>
  171. * This seems complete for WSE 1.0 but some new classes were
  172. introduced in WSE 2.0.
  173. </ul>
  174. *** Namespace: Microsoft.Web.Services.Security.X509
  175. **** Status
  176. <ul>
  177. * X509Certificate support is complete for both WSE 1.0 and 2.0.
  178. </ul>
  179. **** TODO
  180. <ul>
  181. * We need to define certificate stores (for both users and
  182. machines). These sames stores must be linked with asymmetric
  183. keypairs. This could also be used to store the SPC roots.
  184. </ul>
  185. *** Notes
  186. <ul>
  187. * Microsoft has released WSE 2.
  188. </ul>
  189. <hr>
  190. ** Tools
  191. There are many tools in the .NET framework that indirectly interacts
  192. with some cryptographic classes. Unless noted the tools should work on
  193. any CLR (tested with both Mono and Microsoft).
  194. **** Status
  195. The following tools are complete (or mostly complete):
  196. <ul>
  197. * <code>secutil</code> is a tool to extract certificates and
  198. strongnames from assemblies in a format that can be easily
  199. re-used in source code (C# or VB.NET syntax).
  200. * <code>cert2spc</code> is a tool to transform multiple X.509
  201. certificates and CRLs into a Software Publisher Certificate
  202. (SPC) file - which is a long name for a simple PKCS#7 file.
  203. * <code>makecert</code> to create X.509 test certificates that
  204. can be used (once transformed in SPC) to sign assemblies. It's
  205. now possible to generate SSL certificates for web servers.
  206. * <code>sn</code> is a clone of the <code>sn</code> to manage
  207. strongnames. Current version can create, convert, sign and
  208. verify strongnames signatures. Some configuration options
  209. are still missing, some will only works with Mono.
  210. * <code>signcode</code> and <code>chktrust</code> for signing
  211. and validating Authenticode(tm) signatures on assemblies (or
  212. any PE file) are now working (signature and timestamps) but
  213. some options aren't yet supported.
  214. * <code>setreg</code> can change some cryptographic parameters
  215. of the runtime. Currently it can add or remove two root test
  216. certificates (the one used by Mono's <code>makecert</code>,
  217. the other used by Microsoft's <code>makecert</code>).
  218. * <code>certmgr</code> can add and remove certificates from
  219. the stores. Most common use is to add new trusted certificates
  220. or remove them.
  221. </ul>
  222. Somewhat usable, somewhat incomplete:
  223. <ul>
  224. * <code>certview</code> is a certificate viewer for
  225. <code>System.Windows.Forms</code> (right now only working on
  226. Windows), while <code>gcertview</code> is the same viewer
  227. implemented for GTK# (working on both Windows and Linux).
  228. </ul>
  229. **** TODO
  230. The following tools are still missing or largely incomplete:
  231. <ul>
  232. * Other tools like a, GUI-based, certificate manager...
  233. </ul>
  234. Note that many of the tools requires the class library and/or the
  235. runtime to be ready for them. E.g. StrongName and Authenticode signatures
  236. tools are of limited use until supported by the runtime.
  237. <hr>
  238. ** References
  239. <ul>
  240. * RSA Laboratories' <a href="http://www.rsasecurity.com/rsalabs/faq/index.html">
  241. Frequently Asked Questions</a> About Today's Cryptography, Version 4.1
  242. * Public-Key Cryptography Standards (<a href="http://www.rsasecurity.com/rsalabs/pkcs/index.html">
  243. PKCS</a>)
  244. * National Institute of Standards and Technology - Federal
  245. Information Processing Standards <a href="http://csrc.nist.gov/publications/fips/index.html">
  246. NIST FIPS</a>
  247. </ul>
  248. <hr>
  249. ** How to Help
  250. <ul>
  251. * Complete any of the TODO (and feel good about it ;-).
  252. * Analyse the current coverage of the unit tests on the
  253. cryptographic classes and complete the unit tests. <b><code>
  254. monocov</code> does a great job at this! Now we just need to
  255. complete the missing unit tests.</b>
  256. * Optimization can also be done on most algorithms as crypto
  257. is never fast enough. Some have been done using the
  258. Community Edition of BoundChecker (a free VisualStudio
  259. addon) - recommanded! Just be sure to test every optimization
  260. (using the unit tests) carefully - it's so fast to break an
  261. algorithm ;-).
  262. * Write some documentation or add some sample code for the
  263. cryptographic classes in <b>monodoc</b>.
  264. </ul>
  265. <hr>
  266. Last reviewed: June 26, 2004 (mono release candidate 1)