SharpDevelop Community

Get your problems solved!
Welcome to SharpDevelop Community Sign in | Join | Help
in Search

encryption

Last post 01-27-2010 3:08 AM by DavidPierson. 7 replies.
Page 1 of 1 (8 items)
Sort Posts: Previous Next
  • 01-21-2010 10:53 PM

    • hbaker
    • Not Ranked
    • Joined on 01-21-2010
    • Posts 3

    encryption

     Can someone give me a specific answer as to what type of encryption is used for creating zip files via ZipOutputStream?  The version number I see is 0.85.0.0.

    I have a client that requires us to use 256 bit AES, but it seems it was not supported, but now is?!  Could not find a definitive answer.

    Thanks in advance.

  • 01-22-2010 3:01 AM In reply to

    Re: encryption

    Hi,

    128 and 256 bit AES is supported in the latest version, which is not yet been officially released, but will be soon.
    Please download the dll from
    http://blissfloral.com.au/ref/ICSharpCode.SharpZipLib.zip

    I'm delighted to see more interest in this feature. It was the reason I joined the forum originally and my first post was asking if anyone had made any progress. I ended up adding it myself :-)

    It works for creation and extraction, except that for extraction, you must use the ZipFile class and not ZipInputStream as I have not yet updated that. For creation, both ZipFile and ZipOutputStream are fully functional.

    Here is sample code to create a 256 bit AES zip file.

    using System;
    using System.Collections.Generic;
    using System.IO;
    using ICSharpCode.SharpZipLib.Core;
    using ICSharpCode.SharpZipLib.Zip;

    public void CreateSample(string outPathname, string password, List<String> contents) {

        FileStream fsOut = File.Create(outPathname);
        ZipOutputStream zipStream = new ZipOutputStream(fsOut);

        zipStream.SetLevel(3); //0-9, 9 being the highest level of compression

        zipStream.Password = password;

        foreach (string filename in contents) {

            string entryName = StrippedFilename(filename);
            ZipEntry newEntry = new ZipEntry(entryName);
            newEntry.DateTime = DateTime.Now;

            // Specifying the AESKeySize triggers AES encryption. Allowable values are 0 (off), 128 or 256.
            newEntry.AESKeySize = 256;

            // Use Off to permit the zip to be unpacked by XP's built-in extractor and other older
            // code. Use On or Dynamic if the file will be bigger than 4GB.
            zipStream.UseZip64 = UseZip64.Off;

            zipStream.PutNextEntry(newEntry);

            // zip file in buffered chunks
            // the "using" will close the stream even if an exception occurs
            byte[ ] buffer = new byte[4096];
            using (FileStream streamReader = File.OpenRead(filename)) {
                StreamUtils.Copy(streamReader, zipStream, buffer);
            }
            zipStream.CloseEntry();
        }
        zipStream.IsStreamOwner = true;    // Makes the Close also Close the underlying stream
        zipStream.Close();
    }

    // Remove drive from name eg "C:\temp\file.txt" -> "temp\file.txt"
    // Many utilities object to presence of disk in path.
    private string StrippedFilename(string filename) {
        string pathroot = Path.GetPathRoot(filename);
        return filename.Substring(pathroot.Length);
    }

    public static void TestBuild() {
        List<String> contents = new List <String>();
        // some test files to encrypt
        contents.Add(@"c:\temp\test1.txt");
        contents.Add(@"c:\temp\test2.txt");
        CreateSample(@"c:\temp\AES-test.zip", "whatever", contents);
    }

    The dll matches the current source code checked into the repository. There are more code changes for other features/bugs to be done before I do an official new release.

    Hope this helps,
    David
    Edit: a gremlin removed the password line

  • 01-22-2010 3:16 AM In reply to

    • hbaker
    • Not Ranked
    • Joined on 01-21-2010
    • Posts 3

    Re: encryption

     Thanks for the AES info - what does the previous version use though?

  • 01-22-2010 5:19 AM In reply to

    Re: encryption

    Sorry, not sure I understand your question ?

  • 01-22-2010 6:32 PM In reply to

    • hbaker
    • Not Ranked
    • Joined on 01-21-2010
    • Posts 3

    Re: encryption

     What type of encryption does SharpZipLib current use?  I see some reference to "classic PKZip encryption" - is that what is used?

  • 01-22-2010 11:49 PM In reply to

    Re: encryption

    Yes that's right. Winzip refers to as Zip 2.0 compatible encryption. From the Winzip help ...

     

    • Standard Zip 2.0 encryption: this older encryption technique provides a measure of protection against casual users who do not have the password and are trying to determine the contents of the files. However, the Zip 2.0 encryption format is known to be relatively weak, and cannot be expected to provide protection from individuals with access to specialized password recovery tools.

      You should not rely on Zip 2.0 encryption to provide strong security for your data. If you have important security requirements for your data, you should use WinZip's AES encryption, described above.

      The only advantage of Zip 2.0 encryption over the more secure AES encryption is that it is supported by most Zip file utilities, including earlier versions of WinZip. Files that you encrypt using this technique can be extracted by anyone who knows the correct password and has access to almost any Zip file utility. Additionally, Zip 2.0 encryption is supported by WinZip Self-Extractor 2.2 and by WinZip Self-Extractor Personal Edition (included in WinZip 9.0); the AES encryption method described above is not supported by either self-extractor program.


  • 01-25-2010 4:44 PM In reply to

    Re: encryption

    Hello David

    I wish to use AES in my Silverlight application so I need the source code of this version.

    Can you post a link for the source of the version which includes the AES encryption?

    Thanks

    Ran.

  • 01-27-2010 3:08 AM In reply to

    Re: encryption

    Certainly.

    http://blissfloral.com.au/ref/SharpZipLib-source.zip

    This includes only the src/ folder. For the other folders (doc, samples, tests) please download the standard package from the front page (http://www.icsharpcode.net/OpenSource/SharpZipLib/Download.aspx). These haven't been updated yet.

    I'd be interested to know what you'll be doing with it, as we have little exposure to Silverlight where I work.

    Thanks,

    David

     

Page 1 of 1 (8 items)
Powered by Community Server (Commercial Edition), by Telligent Systems
Don't contact us via this (fleischfalle@alphasierrapapa.com) email address.