EncryptionAlgorithm.cs 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. // EncryptionAlgorithm.cs
  2. // ------------------------------------------------------------------
  3. //
  4. // Copyright (c) 2009 Dino Chiesa
  5. // All rights reserved.
  6. //
  7. // This code module is part of DotNetZip, a zipfile class library.
  8. //
  9. // ------------------------------------------------------------------
  10. //
  11. // This code is licensed under the Microsoft Public License.
  12. // See the file License.txt for the license details.
  13. // More info on: http://dotnetzip.codeplex.com
  14. //
  15. // ------------------------------------------------------------------
  16. //
  17. // last saved (in emacs):
  18. // Time-stamp: <2009-October-21 17:24:45>
  19. //
  20. // ------------------------------------------------------------------
  21. //
  22. // This module defines the EncryptionAgorithm enum
  23. //
  24. //
  25. // ------------------------------------------------------------------
  26. namespace Ionic.Zip
  27. {
  28. /// <summary>
  29. /// An enum that provides the various encryption algorithms supported by this
  30. /// library.
  31. /// </summary>
  32. ///
  33. /// <remarks>
  34. ///
  35. /// <para>
  36. /// <c>PkzipWeak</c> implies the use of Zip 2.0 encryption, which is known to be
  37. /// weak and subvertible.
  38. /// </para>
  39. ///
  40. /// <para>
  41. /// A note on interoperability: Values of <c>PkzipWeak</c> and <c>None</c> are
  42. /// specified in <see
  43. /// href="http://www.pkware.com/documents/casestudies/APPNOTE.TXT">PKWARE's zip
  44. /// specification</see>, and are considered to be "standard". Zip archives
  45. /// produced using these options will be interoperable with many other zip tools
  46. /// and libraries, including Windows Explorer.
  47. /// </para>
  48. ///
  49. /// <para>
  50. /// Values of <c>WinZipAes128</c> and <c>WinZipAes256</c> are not part of the Zip
  51. /// specification, but rather imply the use of a vendor-specific extension from
  52. /// WinZip. If you want to produce interoperable Zip archives, do not use these
  53. /// values. For example, if you produce a zip archive using WinZipAes256, you
  54. /// will be able to open it in Windows Explorer on Windows XP and Vista, but you
  55. /// will not be able to extract entries; trying this will lead to an "unspecified
  56. /// error". For this reason, some people have said that a zip archive that uses
  57. /// WinZip's AES encryption is not actually a zip archive at all. A zip archive
  58. /// produced this way will be readable with the WinZip tool (Version 11 and
  59. /// beyond).
  60. /// </para>
  61. ///
  62. /// <para>
  63. /// There are other third-party tools and libraries, both commercial and
  64. /// otherwise, that support WinZip's AES encryption. These will be able to read
  65. /// AES-encrypted zip archives produced by DotNetZip, and conversely applications
  66. /// that use DotNetZip to read zip archives will be able to read AES-encrypted
  67. /// archives produced by those tools or libraries. Consult the documentation for
  68. /// those other tools and libraries to find out if WinZip's AES encryption is
  69. /// supported.
  70. /// </para>
  71. ///
  72. /// <para>
  73. /// In case you care: According to <see
  74. /// href="http://www.winzip.com/aes_info.htm">the WinZip specification</see>, the
  75. /// actual AES key used is derived from the <see cref="ZipEntry.Password"/> via an
  76. /// algorithm that complies with <see
  77. /// href="http://www.ietf.org/rfc/rfc2898.txt">RFC 2898</see>, using an iteration
  78. /// count of 1000. The algorithm is sometimes referred to as PBKDF2, which stands
  79. /// for "Password Based Key Derivation Function #2".
  80. /// </para>
  81. ///
  82. /// <para>
  83. /// A word about password strength and length: The AES encryption technology is
  84. /// very good, but any system is only as secure as the weakest link. If you want
  85. /// to secure your data, be sure to use a password that is hard to guess. To make
  86. /// it harder to guess (increase its "entropy"), you should make it longer. If
  87. /// you use normal characters from an ASCII keyboard, a password of length 20 will
  88. /// be strong enough that it will be impossible to guess. For more information on
  89. /// that, I'd encourage you to read <see
  90. /// href="http://www.redkestrel.co.uk/Articles/RandomPasswordStrength.html">this
  91. /// article.</see>
  92. /// </para>
  93. ///
  94. /// <para>
  95. /// The WinZip AES algorithms are not supported with the version of DotNetZip that
  96. /// runs on the .NET Compact Framework. This is because .NET CF lacks the
  97. /// HMACSHA1 class that is required for producing the archive.
  98. /// </para>
  99. /// </remarks>
  100. public enum EncryptionAlgorithm
  101. {
  102. /// <summary>
  103. /// No encryption at all.
  104. /// </summary>
  105. None = 0,
  106. /// <summary>
  107. /// Traditional or Classic pkzip encryption.
  108. /// </summary>
  109. PkzipWeak,
  110. #if AESCRYPTO
  111. /// <summary>
  112. /// WinZip AES encryption (128 key bits).
  113. /// </summary>
  114. WinZipAes128,
  115. /// <summary>
  116. /// WinZip AES encryption (256 key bits).
  117. /// </summary>
  118. WinZipAes256,
  119. #endif
  120. /// <summary>
  121. /// An encryption algorithm that is not supported by DotNetZip.
  122. /// </summary>
  123. Unsupported = 4,
  124. // others... not implemented (yet?)
  125. }
  126. }