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