crypto 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. * Cryptography
  2. In the .NET framework cryptography can be found under a number of
  3. namespaces in several assemblies.
  4. ** Assembly: corlib
  5. *** Namespace: <b>System.Security.Cryptography</b>
  6. Thanks to the work of many people this namespace is almost complete.
  7. **** Status
  8. <ul>
  9. * Every classes are present.
  10. * Most classes have their unit tests.
  11. </ul>
  12. **** TODO
  13. <ul>
  14. * Support for adding/modifying algorithms and OID using the
  15. <code>machine.config</code> configuration file (in progress).
  16. * RNGCryptoServiceProvider is currently only working on Linux.
  17. The current implementation reside in Mono's runtime and use
  18. the <code>/dev/[u]random</code> device (which do not exists
  19. under Windows). A Windows alternative is in the work...
  20. * Keypair persistance for RSA and DSA. This persistance must
  21. somehow be linked with X509 certificate stores (in planning).
  22. * <code>MACTripleDES</code> is not functionnal. There are many
  23. differents and conflicting standards about how to do MAC
  24. (NIST has two, ANSI has one, maybe the framework is using
  25. yet another). We just have to figure out which one it is.
  26. * <code>PasswordDeriveBytes</code> is currently limited to
  27. generating keys with the maximum length equals to the hash
  28. output (as specified in PKCS #5). However the framework
  29. implementation allows for longer keys to be generated. Also
  30. the algorithms used by CryptDeriveKey (used by Windows
  31. applications) are unknown.
  32. * Analyse the current coverage of the unit tests on the
  33. cryptographic classes and complete the unit tests.
  34. * Optimizations (performance) on most class are possible. Some
  35. have been done using the Community Edition of BoundChecker
  36. (a free VisualStudio addon) - recommanded!
  37. </ul>
  38. **** Notes
  39. <ul>
  40. * All cryptographic algorithms are entirely managed, including
  41. classes named <code>*CryptoServiceProvider</code>, with the
  42. exception of <code>RNGCryptoServiceProvider</code> (which
  43. resides in the runtime).
  44. </ul>
  45. *** Namespace: <b>System.Security.Cryptography.X509Certificates</b>
  46. **** Status
  47. <ul>
  48. * X.509 certificates are parsed using 100% managed code.
  49. * Software Publisher Certificates (SPC) used by Authenticode
  50. (tm) to sign assemblies are supported (extraction from PE
  51. files) but <b>not</b> validated.
  52. * Tests are generated from a set of existing certificates
  53. (about a dozen) each having different properties. Another
  54. set of certificates (more than 300) are used for a more
  55. complete test (but isn't part of the test suite for size
  56. and time consideration).
  57. </ul>
  58. **** TODO
  59. <ul>
  60. * Authenticode(tm) support is incomplete. We can extract the
  61. certificates from PE files but cannot validate the signature
  62. nor the certificate chain (and we're still missing some trust
  63. anchors).
  64. * Integration with CryptoAPI isn't possible as long as the
  65. <code>X509Certificate(IntPtr)</code> constructor isn't
  66. completed.
  67. </ul>
  68. **** Notes
  69. <ul>
  70. * <b>There's no validation of the certificates</b> done in this
  71. class (this isn't a restriction of Mono!). This means that
  72. certificate signatures and validity dates are never checked!
  73. * The newer X509Certificate class included in Microsoft's Web
  74. Service Enhancement (WSE) is a little better (as it includes
  75. validation).
  76. * Microsoft implementation of <code>X509Certificate</code> is
  77. done by using CryptoAPI. From the exceptions thrown
  78. Authenticode(tm) support is done via COM.
  79. </ul>
  80. <hr>
  81. ** Assembly: System.Security
  82. *** Namespace: <b>System.Security.Cryptography.Xml</b>
  83. This namespace implements the XML Digital Signature specification from
  84. W3C.
  85. **** Status
  86. <ul>
  87. * All classes are present but some are only stubbed.
  88. * Most classes have their unit tests.
  89. * This assembly is present in CVS but isn't (yet) part of the
  90. build.
  91. </ul>
  92. **** TODO
  93. <ul>
  94. * All the transforms needs to be done. But this requires far
  95. more XML knowledge than crypto.
  96. * Fix the tests (see notes) then include the assembly into the
  97. build process.
  98. </ul>
  99. **** Notes
  100. <ul>
  101. * Many current tests fails because the XML generated by Mono
  102. isn't exactly the same as the one produced by the Microsoft
  103. implementation (but 100% equivalent). We'll either have to
  104. change the XML code or the tests.
  105. * Testing is difficult because the classes use CryptoConfig
  106. to create the required cryptographic objects. When running
  107. the unit tests the CryptoConfig executing is the one in
  108. mscorlib (not Mono's one) so it doesn't return the expected
  109. objects. This results in InvalidCastException.
  110. </ul>
  111. <hr>
  112. ** Assembly: Mono.Security.Win32
  113. This assembly is to provide maximum compatibility with CryptoAPI to
  114. application running with Mono's runtime on the Windows operating
  115. system.
  116. <b>This assembly should NEVER be used directly by any application</b>.
  117. The classes should only be used by modifying the <code>machine.config
  118. </code> configuration file (and then only if this increased
  119. compatibility is required by an application).
  120. *** Namespace: Mono.Security.Cryptography
  121. **** Status
  122. <ul>
  123. * A RNGCryptoServiceProvider built on top of CryptoAPI.
  124. * Not (yet) commited in CVS.
  125. </ul>
  126. **** TODO
  127. <ul>
  128. * Unmanaged versions of hash algorithms (SHA1 and MD5).
  129. * Unmanaged versions of symmetric encryption algorithms
  130. (like DES, TripleDES, RC2 and others present in CryptoAPI).
  131. * Unmanaged versions of asymmetric algorithms (like DSA and
  132. RSA) which persist their keypair into the specified CSP.
  133. </ul>
  134. <hr>
  135. ** Assembly: Microsoft.Web.Services
  136. Microsoft Web Service Enhancement (WSE), known as Web Service
  137. Development Kit (WSDK) in it's beta days, is an add-on the .NET
  138. framework that implements WS-Security (and other WS-* specifications).
  139. It also includes improved support for XML Signature (replacing and/or
  140. extending <code>System.Security.Cryptography.Xml</code>) and X509
  141. certificates.
  142. Note: WSE is distributed as an add-on because the WS-Security
  143. specification isn't yet completed by OASIS.
  144. <b>There are some licensing issues to consider before stating to
  145. implement WS-Security. All contributors must sign an agreement with
  146. Microsoft before commiting anything related to WS-Security into CVS.
  147. </b>
  148. *** Namespace: Microsoft.Web.Services.Security
  149. **** Status
  150. <ul>
  151. * Nothing (yet) commited in CVS.
  152. </ul>
  153. *** Namespace: Microsoft.Web.Services.Security.X509
  154. **** Status
  155. <ul>
  156. * Nothing (yet) commited in CVS.
  157. </ul>
  158. **** TODO
  159. <ul>
  160. * We need to define certificate stores (for both users and
  161. machines). These sames stores must be linked with asymmetric
  162. keypairs. This could also be used to store the SPC roots.
  163. </ul>
  164. <hr>
  165. ** Other stuff
  166. There are other, not so visible, uses of cryptography both inside and
  167. outside the class library - such as:
  168. <ul>
  169. * SSL/TLS for secure communication (investigation under way).
  170. * Assembly signing (and verification) using StrongNames.
  171. * Assembly signing (and verification) using Authenticode(tm).
  172. </ul>
  173. *** Tools
  174. There are many tools in the .NET framework that indirectly interacts
  175. with some cryptographic classes. Mono will eventually need these tools.
  176. **** Status
  177. The following tools are complete:
  178. <ul>
  179. * <code>secutil</code> is a tool to extract certificates and
  180. strongnames from assemblies in a format that can be easily
  181. re-used in source code (C# or VB.NET syntax).
  182. * <code>cert2spc</code> is a tool to transform multiple X.509
  183. certificates (a chain) into a Software Publisher Certificate
  184. (SPC) - which is a long name for a simple PKCS#7 file.
  185. </ul>
  186. **** TODO
  187. The following tools are still missing or incomplete:
  188. <ul>
  189. * <code>monosn</code> is a clone of the <code>sn</code> to manage
  190. strongnames. This tools is part of the runtime (not the class
  191. library) and as such is written in C.
  192. * <code>signcode</code> and <code>chktrust</code> for signing
  193. and validating Authenticode(tm) signatures on assemblies.
  194. * <code>makecert</code> to create X.509 test certificates that
  195. can be used (once transformed in SPC) to sign assemblies.
  196. * Other tools like a, GUI-based, certificate manager...
  197. </ul>
  198. Note that many of the tools requires the class library and/or the
  199. runtime to be ready for them.
  200. <hr>
  201. ** How to Help
  202. Complete any of the TODO (and feel good about it ;-).
  203. Add missing unit tests to classes or methods.
  204. Write some documentation on the cryptographic classes for MonkeyGuide
  205. (as I'm not a good writer - but you must be a good reader if you got to
  206. this part).
  207. Optimization can also be done on algorithms as crypto is never fast
  208. enough. Just be sure to test every optimization (using the unit test)
  209. carefully - it's so fast to break an algorithm ;-).
  210. Contact Sebastien Pouliot (<a href="mailto:[email protected]">home</a>
  211. , <a href="mailto:[email protected]">work</a>) if you need additional
  212. informations about the status of the cryptographic classes.