Compare commits

...

44 Commits

Author SHA1 Message Date
Adam Hathcock
65090b0fb0 Force tests to run single threaded 2013-07-27 12:20:32 +01:00
Adam Hathcock
3bbb407bdb Fixed line endings 2013-07-27 12:20:17 +01:00
Adam Hathcock
404fa8c62d AES zip decryption works 2013-07-27 12:06:54 +01:00
Adam Hathcock
9cf8c1a747 Moved classes into own files 2013-07-27 08:30:20 +01:00
Adam Hathcock
0937c63a9e Added extra encryption test. 2013-07-27 08:27:31 +01:00
Adam Hathcock
f367f489eb Adding bouncy castle crypto for portable (and metro) 2013-07-20 11:46:37 +01:00
Adam Hathcock
d78677186b Refactor crypto out of MarkingBinaryReader into RarCrypto specific class. Remove functionality from portable build to make it work. 2013-07-16 16:53:00 +01:00
Adam Hathcock
9447c1ed71 Add resharper shared config 2013-07-16 16:52:01 +01:00
Adam Hathcock
a16219763b Merge pull request #1 from hrasyid/master
Added support for decryption of RAR files
2013-07-16 07:27:31 -07:00
Hamdanil Rasyid
430263b672 More style adjustment 2013-07-16 22:19:41 +08:00
Hamdanil Rasyid
cc902bcb2d Style issue and access modifiers 2013-07-16 22:17:15 +08:00
Hamdanil Rasyid
a29f7d4500 Revert "Remove requirement for signature"
This reverts commit 1d10ea29da.
2013-07-16 22:00:13 +08:00
Hamdanil Rasyid
f9194b645d Merge branch 'master' of https://github.com/hrasyid/sharpcompress 2013-07-16 00:18:36 +08:00
Hamdanil Rasyid
c7f6b506b5 Use faster implementation of SHA1 2013-07-16 00:17:24 +08:00
Hamdanil Rasyid
1ab89ba59c Cleanup 2013-07-16 00:04:54 +08:00
Hamdanil Rasyid
3370fadbd1 Refactor all cryptography codes to RarRijndael 2013-07-15 23:43:26 +08:00
Hamdanil Rasyid
a73c831647 Refactor initialization codes into one class 2013-07-15 23:29:24 +08:00
hrasyid
203a7beef7 Merge pull request #1 from hrasyid/dev_rardecryption
Dev rardecryption
2013-07-14 09:56:39 -07:00
Hamdanil Rasyid
6c2b447530 Fix filename 2013-07-15 00:44:07 +08:00
Hamdanil Rasyid
1e7d6dc4f5 Test both Rar with header+ file encrypted and only file encrypted 2013-07-15 00:42:48 +08:00
Hamdanil Rasyid
37c4665630 Make password a parameter 2013-07-15 00:35:35 +08:00
Hamdanil Rasyid
d15c8785ac Use more meaningful error message 2013-07-14 23:22:08 +08:00
Hamdanil Rasyid
ab19dedf1f Fix bug when ignoring offset 2013-07-14 23:20:43 +08:00
Hamdanil Rasyid
34190f6576 Code tidyness 2013-07-14 19:09:33 +08:00
Hamdanil Rasyid
78cecda03a Update to reflect folder structure 2013-07-14 19:08:54 +08:00
Hamdanil Rasyid
13de04ddd2 Fix bug when no rijndael is used 2013-07-14 19:08:20 +08:00
Hamdanil Rasyid
e1511bf3ba Decrypt stream (in addition to header) 2013-07-14 19:04:22 +08:00
Hamdanil Rasyid
e78ead7bc3 Temporarily do not treat warning as error 2013-07-13 21:49:35 +08:00
Hamdanil Rasyid
bb2dcce57a Remove comments from reference code 2013-07-13 21:49:04 +08:00
Hamdanil Rasyid
c0b630c795 Decrypt rar - first attempt, test still fails 2013-07-13 20:12:35 +08:00
Hamdanil Rasyid
22d181e637 recognize encrypted flag in archive header 2013-07-13 10:45:25 +08:00
Hamdanil Rasyid
af8e4f9da8 Add test case for encrypted Rar 2013-07-12 23:26:30 +08:00
Hamdanil Rasyid
ad421936dc Modify test base to follow my folder structure 2013-07-12 23:23:56 +08:00
Hamdanil Rasyid
1d10ea29da Remove requirement for signature 2013-07-12 21:43:38 +08:00
Adam Hathcock
31f8c18bc5 Added codeplex discussion link 2013-05-28 19:40:13 +01:00
Adam Hathcock
692bebf658 Better message for supported types
Changed exception message in Reader/Archive Factory to list the
supported types.
2013-05-28 19:34:41 +01:00
Adam Hathcock
0ab103e1b1 Made streams Dispose resilient
Made streams resilient to dispose being called multiple times.  Removed
unused stream.
2013-05-28 19:29:54 +01:00
Adam Hathcock
483f2e564a Fixing ArchiveFactory.Open IsRarFile: https://sharpcompress.codeplex.com/workitem/35 2013-05-07 14:31:30 +01:00
Adam Hathcock
ea6661ee8e Changing some nuget metadata 2013-05-04 17:15:46 +01:00
Adam Hathcock
9ff2369744 Version 0.9 2013-05-04 17:05:09 +01:00
Adam Hathcock
dc192601f3 Removed comment 2013-04-28 13:09:34 +01:00
Adam Hathcock
455f93f294 Windows Store version compiles 2013-04-28 13:01:29 +01:00
Adam Hathcock
0a69c584b4 Removed Silverlight project and renamed WP7 project to Portable 2013-04-28 12:45:44 +01:00
Adam Hathcock
257e85d8bf Removed 3.5 project. Added WinRT project 2013-04-28 12:41:29 +01:00
107 changed files with 7390 additions and 1968 deletions

2
.gitignore vendored
View File

@@ -6,3 +6,5 @@ bin/
*.user
TestArchives/Scratch/
TestArchives/Scratch2/
TestResults/
*.nupkg

View File

@@ -1,23 +1,22 @@
<?xml version="1.0"?>
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<version>0.8.2</version>
<authors>Adam Hathcock</authors>
<owners>Adam Hathcock</owners>
<licenseUrl>http://sharpcompress.codeplex.com/license</licenseUrl>
<projectUrl>http://sharpcompress.codeplex.com/</projectUrl>
<id>sharpcompress</id>
<title>SharpCompress - Pure C# Decompression/Compression</title>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>SharpCompress is a compression library for .NET/Mono/Silverlight/WP7 that can unrar, decompress 7zip, zip/unzip, tar/untar bzip2/unbzip2 and gzip/ungzip with forward-only reading and file random access APIs. Write support for zip/tar/bzip2/gzip is implemented.</description>
<releaseNotes />
<language>en-US</language>
<tags>rar unrar zip unzip bzip2 gzip tar 7zip .net40 .net35 sl4</tags>
</metadata>
<files>
<file src="..\bin\SharpCompress.3.5.dll" target="lib\net35\SharpCompress.3.5.dll" />
<file src="..\bin\SharpCompress.dll" target="lib\net40\SharpCompress.dll" />
<file src="..\bin\SharpCompress.WP7.dll" target="lib\sl3-wp\SharpCompress.WP7.dll" />
<file src="..\bin\SharpCompress.Silverlight.dll" target="lib\sl50\SharpCompress.Silverlight.dll" />
</files>
<metadata>
<id>sharpcompress</id>
<version>0.9</version>
<title>SharpCompress - Pure C# Decompression/Compression</title>
<authors>Adam Hathcock</authors>
<owners>Adam Hathcock</owners>
<licenseUrl>http://sharpcompress.codeplex.com/license</licenseUrl>
<projectUrl>https://github.com/adamhathcock/sharpcompress</projectUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>SharpCompress is a compression library for .NET/Mono/Silverlight/WP7/WindowsStore that can unrar, decompress 7zip, zip/unzip, tar/untar bzip2/unbzip2 and gzip/ungzip with forward-only reading and file random access APIs. Write support for zip/tar/bzip2/gzip is implemented.</description>
<releaseNotes />
<language>en-US</language>
<tags>rar unrar zip unzip bzip2 gzip tar 7zip .net40 .net35 sl4</tags>
</metadata>
<files>
<file src="..\bin\SharpCompress.dll" target="lib\net40\SharpCompress.dll" />
<file src="..\bin\SharpCompress.WindowsStore.dll" target="lib\netcore45\SharpCompress.WindowsStore.dll" />
<file src="..\bin\SharpCompress.Portable.dll" target="lib\portable-net4+sl4+wp7+win8\SharpCompress.Portable.dll" />
</files>
</package>

View File

@@ -21,4 +21,16 @@ TODOs (always lots):
* Zip64
* Multi-volume Zip support.
7Zip implementation based on: https://code.google.com/p/managed-lzma/
Some Help/Discussion:
https://sharpcompress.codeplex.com/discussions
7Zip implementation based on: https://code.google.com/p/managed-lzma/
LICENSE
Copyright (c) 2000 - 2011 The Legion Of The Bouncy Castle (http://www.bouncycastle.org)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@@ -0,0 +1,60 @@
using System.IO;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using SharpCompress.Common;
using SharpCompress.Common.Rar.Headers;
using SharpCompress.IO;
namespace SharpCompress.Test.Rar
{
/// <summary>
/// Summary description for RarFactoryReaderTest
/// </summary>
[TestClass]
public class RarHeaderFactoryTest : TestBase
{
private RarHeaderFactory rarHeaderFactory;
[TestInitialize]
public void Initialize()
{
ResetScratch();
rarHeaderFactory = new RarHeaderFactory(StreamingMode.Seekable, Options.KeepStreamsOpen);
}
[TestMethod]
public void ReadHeaders_RecognizeEncryptedFlag()
{
ReadEncryptedFlag("Rar.Encrypted_filesAndHeader.rar", true);
}
private void ReadEncryptedFlag(string testArchive, bool isEncrypted)
{
using (var stream = GetReaderStream(testArchive))
foreach (var header in rarHeaderFactory.ReadHeaders(stream))
{
if (header.HeaderType == HeaderType.ArchiveHeader)
{
Assert.AreEqual(isEncrypted, rarHeaderFactory.IsEncrypted);
break;
}
}
}
[TestMethod]
public void ReadHeaders_RecognizeNoEncryptedFlag()
{
ReadEncryptedFlag("Rar.rar", false);
}
private FileStream GetReaderStream(string testArchive)
{
return new FileStream(Path.Combine(TEST_ARCHIVES_PATH, testArchive),
FileMode.Open);
}
}
}

View File

@@ -36,7 +36,7 @@ namespace SharpCompress.Test
[TestMethod]
public void Rar_Multi_Reader_Delete_Files()
{
var testArchives = new string[] { "Rar.multi.part01.rar",
var testArchives = new string[] { "Rar.multi.part01.rar",
"Rar.multi.part02.rar",
"Rar.multi.part03.rar",
"Rar.multi.part04.rar",
@@ -44,27 +44,27 @@ namespace SharpCompress.Test
"Rar.multi.part06.rar"};
ResetScratch();
ResetScratch();
foreach (var file in testArchives)
{
File.Copy(Path.Combine(TEST_ARCHIVES_PATH, file), Path.Combine(SCRATCH2_FILES_PATH, file));
}
foreach (var file in testArchives)
{
File.Copy(Path.Combine(TEST_ARCHIVES_PATH, file), Path.Combine(SCRATCH2_FILES_PATH, file));
}
using (var reader = RarReader.Open(testArchives.Select(s => Path.Combine(SCRATCH2_FILES_PATH, s))
.Select(p => File.OpenRead(p)), Options.None))
{
while (reader.MoveToNextEntry())
{
reader.WriteEntryToDirectory(SCRATCH_FILES_PATH, ExtractOptions.ExtractFullPath | ExtractOptions.Overwrite);
}
}
VerifyFiles();
using (var reader = RarReader.Open(testArchives.Select(s => Path.Combine(SCRATCH2_FILES_PATH, s))
.Select(p => File.OpenRead(p)), Options.None))
{
while (reader.MoveToNextEntry())
{
reader.WriteEntryToDirectory(SCRATCH_FILES_PATH, ExtractOptions.ExtractFullPath | ExtractOptions.Overwrite);
}
}
VerifyFiles();
foreach (var file in testArchives.Select(s => Path.Combine(SCRATCH2_FILES_PATH, s)))
{
File.Delete(file);
}
foreach (var file in testArchives.Select(s => Path.Combine(SCRATCH2_FILES_PATH, s)))
{
File.Delete(file);
}
}
[TestMethod]
@@ -79,6 +79,45 @@ namespace SharpCompress.Test
Read("Rar.rar", CompressionType.Rar);
}
[TestMethod]
public void Rar_EncryptedFileAndHeader_Reader()
{
ReadRar("Rar.encrypted_filesAndHeader.rar", "test");
}
[TestMethod]
public void Rar_EncryptedFileOnly_Reader()
{
ReadRar("Rar.encrypted_filesOnly.rar", "test");
}
[TestMethod]
public void Rar_Encrypted_Reader()
{
ReadRar("Encrypted.rar", "test");
}
private void ReadRar(string testArchive, string password)
{
ResetScratch();
using (Stream stream = File.OpenRead(Path.Combine(TEST_ARCHIVES_PATH, testArchive)))
using (var reader = RarReader.Open(stream, password))
{
while (reader.MoveToNextEntry())
{
if (!reader.Entry.IsDirectory)
{
Assert.AreEqual(reader.Entry.CompressionType, CompressionType.Rar);
reader.WriteEntryToDirectory(SCRATCH_FILES_PATH, ExtractOptions.ExtractFullPath | ExtractOptions.Overwrite);
}
}
}
VerifyFiles();
}
[TestMethod]
public void Rar_Entry_Stream()
{

View File

@@ -0,0 +1,113 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{E9C3C94B-FB27-4B4F-B225-57513C254D37}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SharpCompress.Test</RootNamespace>
<AssemblyName>SharpCompress.Test.Portable</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>
</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\sharpcompress\</SolutionDir>
<RestorePackages>true</RestorePackages>
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\DebugPortable\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<StartupObject>
</StartupObject>
</PropertyGroup>
<PropertyGroup>
<SignAssembly>true</SignAssembly>
</PropertyGroup>
<PropertyGroup>
<AssemblyOriginatorKeyFile>..\SharpCompress\SharpCompress.pfx</AssemblyOriginatorKeyFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
<Reference Include="System" />
<Reference Include="System.Core" />
</ItemGroup>
<ItemGroup>
<Compile Include="ArchiveTests.cs" />
<Compile Include="GZip\GZipWriterTests.cs" />
<Compile Include="GZip\GZipArchiveTests.cs" />
<Compile Include="Rar\RarHeaderFactoryTest.cs" />
<Compile Include="SevenZip\SevenZipArchiveTests.cs" />
<Compile Include="Streams\StreamTests.cs" />
<Compile Include="Tar\TarWriterTests.cs" />
<Compile Include="Tar\TarReaderTests.cs" />
<Compile Include="Zip\ZipWriterTests.cs" />
<Compile Include="WriterTests.cs" />
<Compile Include="Rar\RarReaderTests.cs" />
<Compile Include="ReaderTests.cs" />
<Compile Include="Tar\TarArchiveTests.cs" />
<Compile Include="Zip\ZipArchiveTests.cs" />
<Compile Include="Rar\RarArchiveTests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="RewindableStreamTest.cs" />
<Compile Include="TestBase.cs" />
<Compile Include="TestStream.cs" />
<Compile Include="Zip\ZipReaderTests.cs" />
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<None Include="..\SharpCompress\SharpCompress.pfx">
<Link>SharpCompress.pfx</Link>
</None>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SharpCompress\SharpCompress.PortableTest.csproj">
<Project>{efdcaf57-fd4d-4e5d-a3d5-f26b875817ed}</Project>
<Name>SharpCompress.PortableTest</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@@ -56,6 +56,7 @@
<Compile Include="ArchiveTests.cs" />
<Compile Include="GZip\GZipWriterTests.cs" />
<Compile Include="GZip\GZipArchiveTests.cs" />
<Compile Include="Rar\RarHeaderFactoryTest.cs" />
<Compile Include="SevenZip\SevenZipArchiveTests.cs" />
<Compile Include="Streams\StreamTests.cs" />
<Compile Include="Tar\TarWriterTests.cs" />

View File

@@ -1,6 +1,7 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using SharpCompress.Common;
using SharpCompress.Reader;
@@ -122,14 +123,15 @@ namespace SharpCompress.Test
using (var file2Stream = File.OpenRead(file2))
{
Assert.AreEqual(file1Stream.Length, file2Stream.Length);
int byte1 = 0;
int byte2 = 0;
while (byte1 != -1)
for (int counter = 0; byte1 != -1; counter++)
{
byte1 = file1Stream.ReadByte();
byte2 = file2Stream.ReadByte();
Assert.AreEqual(byte1, byte2);
if (byte1 != byte2)
Assert.AreEqual(byte1, byte2, string.Format("Byte {0} differ between {1} and {2}",
counter, file1, file2));
}
}
}
@@ -147,5 +149,19 @@ namespace SharpCompress.Test
Assert.IsFalse(archive2.MoveToNextEntry());
}
}
private static readonly object testLock = new object();
[TestInitialize]
public void TestSetup()
{
Monitor.Enter(testLock);
}
[TestCleanup]
public void TestCleanup()
{
Monitor.Exit(testLock);
}
}
}

View File

@@ -1,78 +1,105 @@
Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpCompress", "SharpCompress\SharpCompress.csproj", "{10A689CF-76A2-4A4F-96E4-553C33398438}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpCompress.Test", "SharpCompress.Test\SharpCompress.Test.csproj", "{15679D7A-F22C-4943-87FF-BF5C76C4A6FD}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpCompress.3.5", "SharpCompress\SharpCompress.3.5.csproj", "{43F219EC-21D3-4EA8-8379-151AF9580CB8}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpCompress.Portable", "SharpCompress\SharpCompress.Portable.csproj", "{7FA7D133-1417-4F85-9998-4C618AC8FEDA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpCompress.Silverlight", "SharpCompress\SharpCompress.Silverlight.csproj", "{185ED218-A74F-4F57-85A5-30647495E615}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpCompress.WindowsStore", "SharpCompress\SharpCompress.WindowsStore.csproj", "{1DF6D83C-31FF-47B6-82FE-C4603BE916B5}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpCompress.WP7", "SharpCompress\SharpCompress.WP7.csproj", "{7FA7D133-1417-4F85-9998-4C618AC8FEDA}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpCompress.PortableTest", "SharpCompress\SharpCompress.PortableTest.csproj", "{EFDCAF57-FD4D-4E5D-A3D5-F26B875817ED}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpCompress.Test.Portable", "SharpCompress.Test\SharpCompress.Test.Portable.csproj", "{E9C3C94B-FB27-4B4F-B225-57513C254D37}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Testing", "Testing", "{932BBFCC-76E3-45FF-90CA-6BE4FBF4A097}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|Mixed Platforms = Debug|Mixed Platforms
Debug|ARM = Debug|ARM
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|Mixed Platforms = Release|Mixed Platforms
Release|ARM = Release|ARM
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{10A689CF-76A2-4A4F-96E4-553C33398438}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{10A689CF-76A2-4A4F-96E4-553C33398438}.Debug|Any CPU.Build.0 = Debug|Any CPU
{10A689CF-76A2-4A4F-96E4-553C33398438}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{10A689CF-76A2-4A4F-96E4-553C33398438}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{10A689CF-76A2-4A4F-96E4-553C33398438}.Debug|ARM.ActiveCfg = Debug|Any CPU
{10A689CF-76A2-4A4F-96E4-553C33398438}.Debug|x64.ActiveCfg = Debug|Any CPU
{10A689CF-76A2-4A4F-96E4-553C33398438}.Debug|x86.ActiveCfg = Debug|Any CPU
{10A689CF-76A2-4A4F-96E4-553C33398438}.Release|Any CPU.ActiveCfg = Release|Any CPU
{10A689CF-76A2-4A4F-96E4-553C33398438}.Release|Any CPU.Build.0 = Release|Any CPU
{10A689CF-76A2-4A4F-96E4-553C33398438}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{10A689CF-76A2-4A4F-96E4-553C33398438}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{10A689CF-76A2-4A4F-96E4-553C33398438}.Release|ARM.ActiveCfg = Release|Any CPU
{10A689CF-76A2-4A4F-96E4-553C33398438}.Release|x64.ActiveCfg = Release|Any CPU
{10A689CF-76A2-4A4F-96E4-553C33398438}.Release|x86.ActiveCfg = Release|Any CPU
{15679D7A-F22C-4943-87FF-BF5C76C4A6FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{15679D7A-F22C-4943-87FF-BF5C76C4A6FD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{15679D7A-F22C-4943-87FF-BF5C76C4A6FD}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{15679D7A-F22C-4943-87FF-BF5C76C4A6FD}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{15679D7A-F22C-4943-87FF-BF5C76C4A6FD}.Debug|ARM.ActiveCfg = Debug|Any CPU
{15679D7A-F22C-4943-87FF-BF5C76C4A6FD}.Debug|x64.ActiveCfg = Debug|Any CPU
{15679D7A-F22C-4943-87FF-BF5C76C4A6FD}.Debug|x86.ActiveCfg = Debug|Any CPU
{15679D7A-F22C-4943-87FF-BF5C76C4A6FD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{15679D7A-F22C-4943-87FF-BF5C76C4A6FD}.Release|Any CPU.Build.0 = Release|Any CPU
{15679D7A-F22C-4943-87FF-BF5C76C4A6FD}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{15679D7A-F22C-4943-87FF-BF5C76C4A6FD}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{15679D7A-F22C-4943-87FF-BF5C76C4A6FD}.Release|ARM.ActiveCfg = Release|Any CPU
{15679D7A-F22C-4943-87FF-BF5C76C4A6FD}.Release|x64.ActiveCfg = Release|Any CPU
{15679D7A-F22C-4943-87FF-BF5C76C4A6FD}.Release|x86.ActiveCfg = Release|Any CPU
{43F219EC-21D3-4EA8-8379-151AF9580CB8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{43F219EC-21D3-4EA8-8379-151AF9580CB8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{43F219EC-21D3-4EA8-8379-151AF9580CB8}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{43F219EC-21D3-4EA8-8379-151AF9580CB8}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{43F219EC-21D3-4EA8-8379-151AF9580CB8}.Debug|x86.ActiveCfg = Debug|Any CPU
{43F219EC-21D3-4EA8-8379-151AF9580CB8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{43F219EC-21D3-4EA8-8379-151AF9580CB8}.Release|Any CPU.Build.0 = Release|Any CPU
{43F219EC-21D3-4EA8-8379-151AF9580CB8}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{43F219EC-21D3-4EA8-8379-151AF9580CB8}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{43F219EC-21D3-4EA8-8379-151AF9580CB8}.Release|x86.ActiveCfg = Release|Any CPU
{185ED218-A74F-4F57-85A5-30647495E615}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{185ED218-A74F-4F57-85A5-30647495E615}.Debug|Any CPU.Build.0 = Debug|Any CPU
{185ED218-A74F-4F57-85A5-30647495E615}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{185ED218-A74F-4F57-85A5-30647495E615}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{185ED218-A74F-4F57-85A5-30647495E615}.Debug|x86.ActiveCfg = Debug|Any CPU
{185ED218-A74F-4F57-85A5-30647495E615}.Release|Any CPU.ActiveCfg = Release|Any CPU
{185ED218-A74F-4F57-85A5-30647495E615}.Release|Any CPU.Build.0 = Release|Any CPU
{185ED218-A74F-4F57-85A5-30647495E615}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{185ED218-A74F-4F57-85A5-30647495E615}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{185ED218-A74F-4F57-85A5-30647495E615}.Release|x86.ActiveCfg = Release|Any CPU
{7FA7D133-1417-4F85-9998-4C618AC8FEDA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7FA7D133-1417-4F85-9998-4C618AC8FEDA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7FA7D133-1417-4F85-9998-4C618AC8FEDA}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{7FA7D133-1417-4F85-9998-4C618AC8FEDA}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{7FA7D133-1417-4F85-9998-4C618AC8FEDA}.Debug|ARM.ActiveCfg = Debug|Any CPU
{7FA7D133-1417-4F85-9998-4C618AC8FEDA}.Debug|x64.ActiveCfg = Debug|Any CPU
{7FA7D133-1417-4F85-9998-4C618AC8FEDA}.Debug|x86.ActiveCfg = Debug|Any CPU
{7FA7D133-1417-4F85-9998-4C618AC8FEDA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7FA7D133-1417-4F85-9998-4C618AC8FEDA}.Release|Any CPU.Build.0 = Release|Any CPU
{7FA7D133-1417-4F85-9998-4C618AC8FEDA}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{7FA7D133-1417-4F85-9998-4C618AC8FEDA}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{7FA7D133-1417-4F85-9998-4C618AC8FEDA}.Release|ARM.ActiveCfg = Release|Any CPU
{7FA7D133-1417-4F85-9998-4C618AC8FEDA}.Release|x64.ActiveCfg = Release|Any CPU
{7FA7D133-1417-4F85-9998-4C618AC8FEDA}.Release|x86.ActiveCfg = Release|Any CPU
{1DF6D83C-31FF-47B6-82FE-C4603BE916B5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1DF6D83C-31FF-47B6-82FE-C4603BE916B5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1DF6D83C-31FF-47B6-82FE-C4603BE916B5}.Debug|ARM.ActiveCfg = Debug|ARM
{1DF6D83C-31FF-47B6-82FE-C4603BE916B5}.Debug|ARM.Build.0 = Debug|ARM
{1DF6D83C-31FF-47B6-82FE-C4603BE916B5}.Debug|x64.ActiveCfg = Debug|x64
{1DF6D83C-31FF-47B6-82FE-C4603BE916B5}.Debug|x64.Build.0 = Debug|x64
{1DF6D83C-31FF-47B6-82FE-C4603BE916B5}.Debug|x86.ActiveCfg = Debug|x86
{1DF6D83C-31FF-47B6-82FE-C4603BE916B5}.Debug|x86.Build.0 = Debug|x86
{1DF6D83C-31FF-47B6-82FE-C4603BE916B5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1DF6D83C-31FF-47B6-82FE-C4603BE916B5}.Release|Any CPU.Build.0 = Release|Any CPU
{1DF6D83C-31FF-47B6-82FE-C4603BE916B5}.Release|ARM.ActiveCfg = Release|ARM
{1DF6D83C-31FF-47B6-82FE-C4603BE916B5}.Release|ARM.Build.0 = Release|ARM
{1DF6D83C-31FF-47B6-82FE-C4603BE916B5}.Release|x64.ActiveCfg = Release|x64
{1DF6D83C-31FF-47B6-82FE-C4603BE916B5}.Release|x64.Build.0 = Release|x64
{1DF6D83C-31FF-47B6-82FE-C4603BE916B5}.Release|x86.ActiveCfg = Release|x86
{1DF6D83C-31FF-47B6-82FE-C4603BE916B5}.Release|x86.Build.0 = Release|x86
{EFDCAF57-FD4D-4E5D-A3D5-F26B875817ED}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EFDCAF57-FD4D-4E5D-A3D5-F26B875817ED}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EFDCAF57-FD4D-4E5D-A3D5-F26B875817ED}.Debug|ARM.ActiveCfg = Debug|Any CPU
{EFDCAF57-FD4D-4E5D-A3D5-F26B875817ED}.Debug|x64.ActiveCfg = Debug|Any CPU
{EFDCAF57-FD4D-4E5D-A3D5-F26B875817ED}.Debug|x86.ActiveCfg = Debug|Any CPU
{EFDCAF57-FD4D-4E5D-A3D5-F26B875817ED}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EFDCAF57-FD4D-4E5D-A3D5-F26B875817ED}.Release|Any CPU.Build.0 = Release|Any CPU
{EFDCAF57-FD4D-4E5D-A3D5-F26B875817ED}.Release|ARM.ActiveCfg = Release|Any CPU
{EFDCAF57-FD4D-4E5D-A3D5-F26B875817ED}.Release|x64.ActiveCfg = Release|Any CPU
{EFDCAF57-FD4D-4E5D-A3D5-F26B875817ED}.Release|x86.ActiveCfg = Release|Any CPU
{E9C3C94B-FB27-4B4F-B225-57513C254D37}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E9C3C94B-FB27-4B4F-B225-57513C254D37}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E9C3C94B-FB27-4B4F-B225-57513C254D37}.Debug|ARM.ActiveCfg = Debug|Any CPU
{E9C3C94B-FB27-4B4F-B225-57513C254D37}.Debug|x64.ActiveCfg = Debug|Any CPU
{E9C3C94B-FB27-4B4F-B225-57513C254D37}.Debug|x86.ActiveCfg = Debug|Any CPU
{E9C3C94B-FB27-4B4F-B225-57513C254D37}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E9C3C94B-FB27-4B4F-B225-57513C254D37}.Release|Any CPU.Build.0 = Release|Any CPU
{E9C3C94B-FB27-4B4F-B225-57513C254D37}.Release|ARM.ActiveCfg = Release|Any CPU
{E9C3C94B-FB27-4B4F-B225-57513C254D37}.Release|x64.ActiveCfg = Release|Any CPU
{E9C3C94B-FB27-4B4F-B225-57513C254D37}.Release|x86.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{EFDCAF57-FD4D-4E5D-A3D5-F26B875817ED} = {932BBFCC-76E3-45FF-90CA-6BE4FBF4A097}
{15679D7A-F22C-4943-87FF-BF5C76C4A6FD} = {932BBFCC-76E3-45FF-90CA-6BE4FBF4A097}
{E9C3C94B-FB27-4B4F-B225-57513C254D37} = {932BBFCC-76E3-45FF-90CA-6BE4FBF4A097}
EndGlobalSection
EndGlobal

View File

@@ -0,0 +1,6 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:String x:Key="/Default/Environment/InjectedLayers/FileInjectedLayer/=181069325DAB1C4287CD564D6CDDEDB3/AbsolutePath/@EntryValue">D:\Git\sharpcompress\SharpCompress\sharpcompress.DotSettings</s:String>
<s:String x:Key="/Default/Environment/InjectedLayers/FileInjectedLayer/=181069325DAB1C4287CD564D6CDDEDB3/RelativePath/@EntryValue">..\SharpCompress\sharpcompress.DotSettings</s:String>
<s:Boolean x:Key="/Default/Environment/InjectedLayers/FileInjectedLayer/=181069325DAB1C4287CD564D6CDDEDB3/@KeyIndexDefined">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/InjectedLayers/InjectedLayerCustomization/=File181069325DAB1C4287CD564D6CDDEDB3/@KeyIndexDefined">True</s:Boolean>
<s:Double x:Key="/Default/Environment/InjectedLayers/InjectedLayerCustomization/=File181069325DAB1C4287CD564D6CDDEDB3/RelativePriority/@EntryValue">1</s:Double></wpf:ResourceDictionary>

View File

@@ -20,7 +20,7 @@ namespace SharpCompress.Archive
public event EventHandler<CompressedBytesReadEventArgs> CompressedBytesRead;
public event EventHandler<FilePartExtractionBeginEventArgs> FilePartExtractionBegin;
#if !PORTABLE
#if !PORTABLE && !NETFX_CORE
internal AbstractArchive(ArchiveType type, FileInfo fileInfo, Options options)
{
this.Type = type;

View File

@@ -13,7 +13,7 @@ namespace SharpCompress.Archive
writableArchive.SaveTo(stream, new CompressionInfo {Type = compressionType});
}
#if !PORTABLE
#if !PORTABLE && !NETFX_CORE
public static void AddEntry<TEntry, TVolume>(this AbstractWritableArchive<TEntry, TVolume> writableArchive,
string entryPath, string filePath)
@@ -73,12 +73,7 @@ namespace SharpCompress.Archive
where TEntry : IArchiveEntry
where TVolume : IVolume
{
#if THREEFIVE
foreach (var path in Directory.GetFiles(filePath, searchPattern, searchOption))
#else
foreach (var path in Directory.EnumerateFiles(filePath, searchPattern, searchOption))
#endif
{
var fileInfo = new FileInfo(path);
writableArchive.AddEntry(path.Substring(filePath.Length), fileInfo.OpenRead(), true, fileInfo.Length,

View File

@@ -31,7 +31,7 @@ namespace SharpCompress.Archive
}
}
#if !PORTABLE
#if !PORTABLE && !NETFX_CORE
internal AbstractWritableArchive(ArchiveType type, FileInfo fileInfo, Options options)
: base(type, fileInfo, options)
{
@@ -96,7 +96,7 @@ namespace SharpCompress.Archive
RebuildModifiedCollection();
}
#if !PORTABLE
#if !PORTABLE && !NETFX_CORE
public void AddEntry(string filePath, FileInfo fileInfo)
{
if (!fileInfo.Exists)

View File

@@ -31,7 +31,7 @@ namespace SharpCompress.Archive
return ZipArchive.Open(stream, options, null);
}
stream.Seek(0, SeekOrigin.Begin);
if (RarArchive.IsRarFile(stream))
if (RarArchive.IsRarFile(stream, Options.LookForHeader | Options.KeepStreamsOpen))
{
stream.Seek(0, SeekOrigin.Begin);
return RarArchive.Open(stream, options);
@@ -54,7 +54,7 @@ namespace SharpCompress.Archive
stream.Seek(0, SeekOrigin.Begin);
return GZipArchive.Open(stream, options);
}
throw new InvalidOperationException("Cannot determine compressed stream type.");
throw new InvalidOperationException("Cannot determine compressed stream type. Supported Archive Formats: Zip, GZip, Tar, Rar, 7Zip");
}
public static IArchive Create(ArchiveType type)
@@ -76,7 +76,7 @@ namespace SharpCompress.Archive
}
}
#if !PORTABLE
#if !PORTABLE && !NETFX_CORE
/// <summary>
/// Constructor expects a filepath to an existing file.
/// </summary>

View File

@@ -12,7 +12,7 @@ namespace SharpCompress.Archive.GZip
{
public class GZipArchive : AbstractWritableArchive<GZipArchiveEntry, GZipVolume>
{
#if !PORTABLE
#if !PORTABLE && !NETFX_CORE
/// <summary>
/// Constructor expects a filepath to an existing file.
/// </summary>
@@ -75,7 +75,7 @@ namespace SharpCompress.Archive.GZip
return new GZipArchive(stream, options);
}
#if !PORTABLE
#if !PORTABLE && !NETFX_CORE
/// <summary>
/// Constructor with a FileInfo object to an existing file.
/// </summary>

View File

@@ -5,7 +5,7 @@ namespace SharpCompress.Archive
{
public static class IArchiveExtensions
{
#if !PORTABLE
#if !PORTABLE && !NETFX_CORE
/// <summary>
/// Extract to specific directory, retaining filename
/// </summary>

View File

@@ -1,15 +1,11 @@
using System.IO;
using SharpCompress.Common;
#if THREEFIVE
using SharpCompress.Common.Rar.Headers;
#endif
namespace SharpCompress.Archive
{
public static class IArchiveEntryExtensions
{
#if !PORTABLE
#if !PORTABLE && !NETFX_CORE
/// <summary>
/// Extract to specific directory, retaining filename
/// </summary>

View File

@@ -21,7 +21,7 @@ namespace SharpCompress.Archive.Rar
get { return unpack; }
}
#if !PORTABLE
#if !PORTABLE && !NETFX_CORE
/// <summary>
/// Constructor with a FileInfo object to an existing file.
/// </summary>
@@ -72,7 +72,7 @@ namespace SharpCompress.Archive.Rar
#region Creation
#if !PORTABLE
#if !PORTABLE && !NETFX_CORE
/// <summary>
/// Constructor expects a filepath to an existing file.
/// </summary>
@@ -156,7 +156,7 @@ namespace SharpCompress.Archive.Rar
return new RarArchive(streams, options);
}
#if !PORTABLE
#if !PORTABLE && !NETFX_CORE
public static bool IsRarFile(string filePath)
{
return IsRarFile(new FileInfo(filePath));

View File

@@ -26,7 +26,7 @@ namespace SharpCompress.Archive.Rar
}
}
#if !PORTABLE
#if !PORTABLE && !NETFX_CORE
internal static IEnumerable<RarVolume> GetParts(FileInfo fileInfo, Options options)
{
FileInfoRarArchiveVolume part = new FileInfoRarArchiveVolume(fileInfo, options);

View File

@@ -14,7 +14,7 @@ namespace SharpCompress.Archive.Rar
{
}
#if !PORTABLE
#if !PORTABLE && !NETFX_CORE
public override FileInfo VolumeFile
{
get { return null; }

View File

@@ -12,7 +12,7 @@ namespace SharpCompress.Archive.SevenZip
public class SevenZipArchive : AbstractArchive<SevenZipArchiveEntry, SevenZipVolume>
{
private ArchiveDatabase database;
#if !PORTABLE
#if !PORTABLE && !NETFX_CORE
/// <summary>
/// Constructor expects a filepath to an existing file.
/// </summary>
@@ -75,7 +75,7 @@ namespace SharpCompress.Archive.SevenZip
return new SevenZipArchive(stream, options);
}
#if !PORTABLE
#if !PORTABLE && !NETFX_CORE
internal SevenZipArchive(FileInfo fileInfo, Options options)
: base(ArchiveType.SevenZip, fileInfo, options)
{

View File

@@ -14,7 +14,7 @@ namespace SharpCompress.Archive.Tar
{
public class TarArchive : AbstractWritableArchive<TarArchiveEntry, TarVolume>
{
#if !PORTABLE
#if !PORTABLE && !NETFX_CORE
/// <summary>
/// Constructor expects a filepath to an existing file.
/// </summary>
@@ -77,7 +77,7 @@ namespace SharpCompress.Archive.Tar
return new TarArchive(stream, options);
}
#if !PORTABLE
#if !PORTABLE && !NETFX_CORE
public static bool IsTarFile(string filePath)
{
return IsTarFile(new FileInfo(filePath));
@@ -110,7 +110,7 @@ namespace SharpCompress.Archive.Tar
return false;
}
#if !PORTABLE
#if !PORTABLE && !NETFX_CORE
/// <summary>
/// Constructor with a FileInfo object to an existing file.
/// </summary>

View File

@@ -22,7 +22,7 @@ namespace SharpCompress.Archive.Zip
/// </summary>
public CompressionLevel DeflateCompressionLevel { get; set; }
#if !PORTABLE
#if !PORTABLE && !NETFX_CORE
/// <summary>
/// Constructor expects a filepath to an existing file.
/// </summary>
@@ -91,7 +91,7 @@ namespace SharpCompress.Archive.Zip
return new ZipArchive(stream, options, password);
}
#if !PORTABLE
#if !PORTABLE && !NETFX_CORE
public static bool IsZipFile(string filePath, string password = null)
{
return IsZipFile(new FileInfo(filePath), password);
@@ -133,7 +133,7 @@ namespace SharpCompress.Archive.Zip
}
}
#if !PORTABLE
#if !PORTABLE && !NETFX_CORE
/// <summary>
/// Constructor with a FileInfo object to an existing file.
/// </summary>

View File

@@ -1,17 +1,9 @@
using System.Reflection;
using System.Runtime.CompilerServices;
#if SILVERLIGHT
[assembly: AssemblyTitle("SharpCompress.Silverlight")]
[assembly: AssemblyProduct("SharpCompress.Silverlight")]
#else
#if PORTABLE
[assembly: AssemblyTitle("SharpCompress.Silverlight")]
[assembly: AssemblyProduct("SharpCompress.Silverlight")]
#else
#if THREEFIVE
[assembly: AssemblyTitle("SharpCompress.3.5")]
[assembly: AssemblyProduct("SharpCompress.3.5")]
[assembly: AssemblyTitle("SharpCompress.Portable")]
[assembly: AssemblyProduct("SharpCompress.Portable")]
#else
[assembly: AssemblyTitle("SharpCompress")]
@@ -20,6 +12,8 @@ using System.Runtime.CompilerServices;
InternalsVisibleTo(
"SharpCompress.Test, PublicKey=002400000480000094000000060200000024000052534131000400000100010005d6ae1b0f6875393da83c920a5b9408f5191aaf4e8b3c2c476ad2a11f5041ecae84ce9298bc4c203637e2fd3a80ad5378a9fa8da1363e98cea45c73969198a4b64510927c910001491cebbadf597b22448ad103b0a4007e339faf8fe8665dcdb70d65b27ac05b1977c0655fad06b372b820ecbdccf10a0f214fee0986dfeded"
)]
#endif
#endif
[assembly:
InternalsVisibleTo(
"SharpCompress.Test.Portable, PublicKey=002400000480000094000000060200000024000052534131000400000100010005d6ae1b0f6875393da83c920a5b9408f5191aaf4e8b3c2c476ad2a11f5041ecae84ce9298bc4c203637e2fd3a80ad5378a9fa8da1363e98cea45c73969198a4b64510927c910001491cebbadf597b22448ad103b0a4007e339faf8fe8665dcdb70d65b27ac05b1977c0655fad06b372b820ecbdccf10a0f214fee0986dfeded"
)]
#endif

View File

@@ -17,7 +17,7 @@ namespace SharpCompress.Common
static ArchiveEncoding()
{
#if SILVERLIGHT || PORTABLE
#if PORTABLE || NETFX_CORE
Default = Encoding.UTF8;
Password = Encoding.UTF8;
#else

View File

@@ -7,6 +7,7 @@ namespace SharpCompress.Common
{
private Stream stream;
private bool completed;
private bool isDisposed;
internal EntryStream(Stream stream)
{
@@ -32,6 +33,11 @@ namespace SharpCompress.Common
throw new InvalidOperationException(
"EntryStream has not been fully consumed. Read the entire stream or use SkipEntry.");
}
if (isDisposed)
{
return;
}
isDisposed = true;
base.Dispose(disposing);
stream.Dispose();
}

View File

@@ -13,9 +13,9 @@ namespace SharpCompress.Common
/// <param name="flag">Flag to test</param>
/// <returns></returns>
public static bool HasFlag<T>(long bitField, T flag)
where T : struct, IConvertible
where T : struct
{
return HasFlag(bitField, flag.ToInt64(null));
return HasFlag(bitField, flag);
}
/// <summary>
@@ -27,9 +27,9 @@ namespace SharpCompress.Common
/// <param name="flag">Flag to test</param>
/// <returns></returns>
public static bool HasFlag<T>(ulong bitField, T flag)
where T : struct, IConvertible
where T : struct
{
return HasFlag(bitField, flag.ToUInt64(null));
return HasFlag(bitField, flag);
}
/// <summary>
@@ -70,19 +70,6 @@ namespace SharpCompress.Common
}
#endif
#if THREEFIVE
/// <summary>
/// Generically checks enums in a .NET 3.5
/// </summary>
/// <param name="enumVal"></param>
/// <param name="flag"></param>
/// <returns></returns>
public static bool HasFlag(this Enum enumVal, Enum flag)
{
return (Convert.ToInt32(enumVal) & Convert.ToInt32(flag)) == Convert.ToInt32(flag);
}
#endif
/// <summary>
/// Returns true if the flag is set on the specified bit field.
/// Currently only works with 32-bit bitfields.
@@ -113,22 +100,17 @@ namespace SharpCompress.Common
/// <summary>
/// Sets a bit-field to either on or off for the specified flag.
/// </summary>
/// <typeparam name="T">Enumeration with Flags attribute</typeparam>
/// <param name="bitField">Flagged variable</param>
/// <param name="flag">Flag to change</param>
/// <param name="on">bool</param>
/// <returns>The flagged variable with the flag changed</returns>
public static long SetFlag<T>(long bitField, T flag, bool @on)
where T : struct, IConvertible
public static long SetFlag(long bitField, long flag, bool @on)
{
if (@on)
{
return bitField | flag.ToInt64(null);
}
else
{
return bitField & (~flag.ToInt64(null));
return bitField | flag;
}
return bitField & (~flag);
}
/// <summary>
@@ -140,9 +122,9 @@ namespace SharpCompress.Common
/// <param name="on">bool</param>
/// <returns>The flagged variable with the flag changed</returns>
public static long SetFlag<T>(T bitField, T flag, bool @on)
where T : struct, IConvertible
where T : struct
{
return SetFlag(bitField.ToInt64(null), flag, @on);
return SetFlag(Convert.ToInt64(bitField), Convert.ToInt64(flag), @on);
}
}
}

View File

@@ -4,7 +4,7 @@ namespace SharpCompress.Common.GZip
{
public class GZipVolume : Volume
{
#if !PORTABLE
#if !PORTABLE && !NETFX_CORE
private readonly FileInfo fileInfo;
#endif
@@ -13,7 +13,7 @@ namespace SharpCompress.Common.GZip
{
}
#if !PORTABLE
#if !PORTABLE && !NETFX_CORE
public GZipVolume(FileInfo fileInfo, Options options)
: base(fileInfo.OpenRead(), options)
{
@@ -21,7 +21,7 @@ namespace SharpCompress.Common.GZip
}
#endif
#if !PORTABLE
#if !PORTABLE && !NETFX_CORE
/// <summary>
/// File that backs this volume, if it not stream based
/// </summary>

View File

@@ -4,7 +4,7 @@ namespace SharpCompress.Common
{
public class GenericVolume : Volume
{
#if !PORTABLE
#if !PORTABLE && !NETFX_CORE
private FileInfo fileInfo;
#endif
@@ -13,7 +13,7 @@ namespace SharpCompress.Common
{
}
#if !PORTABLE
#if !PORTABLE && !NETFX_CORE
public GenericVolume(FileInfo fileInfo, Options options)
: base(fileInfo.OpenRead(), options)
{
@@ -21,7 +21,7 @@ namespace SharpCompress.Common
}
#endif
#if !PORTABLE
#if !PORTABLE && !NETFX_CORE
/// <summary>
/// File that backs this volume, if it not stream based
/// </summary>

View File

@@ -1,14 +1,13 @@
using System;
#if !PORTABLE
#if !PORTABLE && !NETFX_CORE
using System.IO;
#endif
namespace SharpCompress.Common
{
public interface IVolume : IDisposable
{
#if !PORTABLE
#if !PORTABLE && !NETFX_CORE
/// <summary>
/// File that backs this volume, if it not stream based
/// </summary>

View File

@@ -27,5 +27,10 @@ namespace SharpCompress.Common.Rar.Headers
internal int PosAv { get; private set; }
internal byte EncryptionVersion { get; private set; }
public bool HasPassword
{
get { return ArchiveHeaderFlags.HasFlag(ArchiveFlags.PASSWORD); }
}
}
}

View File

@@ -157,7 +157,7 @@ namespace SharpCompress.Common.Rar.Headers
private static string ConvertPath(string path, HostOS os)
{
#if PORTABLE
#if PORTABLE || NETFX_CORE
return path.Replace('\\', '/');
#else
switch (os)

View File

@@ -35,11 +35,10 @@ namespace SharpCompress.Common.Rar.Headers
return null;
}
}
protected virtual void ReadFromReader(MarkingBinaryReader reader)
{
HeadCRC = reader.ReadInt16();
HeaderType = (HeaderType) (int) (reader.ReadByte() & 0xff);
HeaderType = (HeaderType)(int)(reader.ReadByte() & 0xff);
Flags = reader.ReadInt16();
HeaderSize = reader.ReadInt16();
if (FlagUtility.HasFlag(Flags, LONG_BLOCK))
@@ -58,7 +57,7 @@ namespace SharpCompress.Common.Rar.Headers
header.ReadFromReader(reader);
header.ReadBytes += reader.CurrentReadByteCount;
int headerSizeDiff = header.HeaderSize - (int) header.ReadBytes;
int headerSizeDiff = header.HeaderSize - (int)header.ReadBytes;
if (headerSizeDiff > 0)
{

View File

@@ -7,24 +7,27 @@ namespace SharpCompress.Common.Rar.Headers
{
internal class RarHeaderFactory
{
private int MAX_SFX_SIZE = 0x80000 - 16; //archive.cpp line 136
private const int MAX_SFX_SIZE = 0x80000 - 16; //archive.cpp line 136
internal RarHeaderFactory(StreamingMode mode, Options options)
internal RarHeaderFactory(StreamingMode mode, Options options, string password = null)
{
StreamingMode = mode;
Options = options;
Password = password;
}
private Options Options { get; set; }
public string Password { get; private set; }
internal StreamingMode StreamingMode { get; private set; }
internal bool IsEncrypted { get; private set; }
internal IEnumerable<RarHeader> ReadHeaders(Stream stream)
{
if (Options.HasFlag(Options.LookForHeader))
{
stream = CheckSFX(stream);
}
RarHeader header;
while ((header = ReadNextHeader(stream)) != null)
{
@@ -90,11 +93,7 @@ namespace SharpCompress.Common.Rar.Headers
{
if (!Options.HasFlag(Options.KeepStreamsOpen))
{
#if THREEFIVE
reader.Close();
#else
reader.Dispose();
#endif
}
throw new InvalidFormatException("Error trying to read rar signature.", e);
}
@@ -111,9 +110,22 @@ namespace SharpCompress.Common.Rar.Headers
return rewindableStream;
}
private RarHeader ReadNextHeader(Stream stream)
{
MarkingBinaryReader reader = new MarkingBinaryReader(stream);
#if PORTABLE
var reader = new MarkingBinaryReader(stream);
#else
var reader = new RarCryptoBinaryReader(stream, Password);
if (IsEncrypted)
{
reader.SkipQueue();
byte[] salt = reader.ReadBytes(8);
reader.InitializeAes(salt);
}
#endif
RarHeader header = RarHeader.Create(reader);
if (header == null)
{
@@ -123,7 +135,9 @@ namespace SharpCompress.Common.Rar.Headers
{
case HeaderType.ArchiveHeader:
{
return header.PromoteHeader<ArchiveHeader>(reader);
var ah = header.PromoteHeader<ArchiveHeader>(reader);
IsEncrypted = ah.HasPassword;
return ah;
}
case HeaderType.MarkHeader:
{
@@ -166,9 +180,19 @@ namespace SharpCompress.Common.Rar.Headers
break;
case StreamingMode.Streaming:
{
ReadOnlySubStream ms
= new ReadOnlySubStream(reader.BaseStream, fh.CompressedSize);
fh.PackedStream = ms;
var ms = new ReadOnlySubStream(reader.BaseStream, fh.CompressedSize);
if (fh.Salt == null)
{
fh.PackedStream = ms;
}
else
{
#if PORTABLE
throw new NotSupportedException("Encrypted Rar files aren't supported in portable distro.");
#else
fh.PackedStream = new RarCryptoWrapper(ms, Password, fh.Salt);
#endif
}
}
break;
default:

View File

@@ -0,0 +1,82 @@
using System.Collections.Generic;
using System.IO;
using SharpCompress.IO;
namespace SharpCompress.Common.Rar
{
internal class RarCryptoBinaryReader : MarkingBinaryReader
{
private RarRijndael rijndael;
private byte[] salt;
private readonly string password;
private readonly Queue<byte> data = new Queue<byte>();
public RarCryptoBinaryReader(Stream stream, string password )
: base(stream)
{
this.password = password;
}
protected bool UseEncryption
{
get { return salt != null; }
}
internal void InitializeAes(byte[] salt)
{
this.salt = salt;
rijndael = RarRijndael.InitializeFrom(password, salt);
}
public override byte[] ReadBytes(int count)
{
CurrentReadByteCount += count;
if (UseEncryption)
{
return ReadAndDecryptBytes(count);
}
return base.ReadBytes(count);
}
private byte[] ReadAndDecryptBytes(int count)
{
int queueSize = data.Count;
int sizeToRead = count - queueSize;
if (sizeToRead > 0)
{
int alignedSize = sizeToRead + ((~sizeToRead + 1) & 0xf);
for (int i = 0; i < alignedSize / 16; i++)
{
//long ax = System.currentTimeMillis();
byte[] cipherText = base.ReadBytes(16);
var readBytes = rijndael.ProcessBlock(cipherText);
foreach (var readByte in readBytes)
data.Enqueue(readByte);
}
}
var decryptedBytes = new byte[count];
for (int i = 0; i < count; i++)
{
decryptedBytes[i] = data.Dequeue();
}
return decryptedBytes;
}
public void ClearQueue()
{
data.Clear();
}
public void SkipQueue()
{
var position = BaseStream.Position;
BaseStream.Position = position + data.Count;
ClearQueue();
}
}
}

View File

@@ -0,0 +1,108 @@
using System;
using System.Collections.Generic;
using System.IO;
namespace SharpCompress.Common.Rar
{
internal class RarCryptoWrapper : Stream
{
private readonly Stream actualStream;
private readonly byte[] salt;
private RarRijndael rijndael;
private readonly Queue<byte> data = new Queue<byte>();
public RarCryptoWrapper(Stream actualStream, string password, byte[] salt)
{
this.actualStream = actualStream;
this.salt = salt;
rijndael = RarRijndael.InitializeFrom(password, salt);
}
public override void Flush()
{
throw new NotImplementedException();
}
public override long Seek(long offset, SeekOrigin origin)
{
throw new NotImplementedException();
}
public override void SetLength(long value)
{
throw new NotImplementedException();
}
public override int Read(byte[] buffer, int offset, int count)
{
if (salt == null)
{
return actualStream.Read(buffer, offset, count);
}
return ReadAndDecrypt(buffer, offset, count);
}
public int ReadAndDecrypt(byte[] buffer, int offset, int count)
{
int queueSize = data.Count;
int sizeToRead = count - queueSize;
if (sizeToRead > 0)
{
int alignedSize = sizeToRead + ((~sizeToRead + 1) & 0xf);
for (int i = 0; i < alignedSize / 16; i++)
{
//long ax = System.currentTimeMillis();
byte[] cipherText = new byte[RarRijndael.CRYPTO_BLOCK_SIZE];
actualStream.Read(cipherText, 0, RarRijndael.CRYPTO_BLOCK_SIZE);
var readBytes = rijndael.ProcessBlock(cipherText);
foreach (var readByte in readBytes)
data.Enqueue(readByte);
}
for (int i = 0; i < count; i++)
buffer[offset + i] = data.Dequeue();
}
return count;
}
public override void Write(byte[] buffer, int offset, int count)
{
throw new NotImplementedException();
}
public override bool CanRead
{
get { throw new NotImplementedException(); }
}
public override bool CanSeek
{
get { throw new NotImplementedException(); }
}
public override bool CanWrite
{
get { throw new NotImplementedException(); }
}
public override long Length
{
get { throw new NotImplementedException(); }
}
public override long Position { get; set; }
protected override void Dispose(bool disposing)
{
if (rijndael != null)
{
rijndael.Dispose();
rijndael = null;
}
base.Dispose(disposing);
}
}
}

View File

@@ -0,0 +1,113 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Org.BouncyCastle.Crypto.Digests;
using Org.BouncyCastle.Crypto.Engines;
using Org.BouncyCastle.Crypto.Parameters;
namespace SharpCompress.Common.Rar
{
internal class RarRijndael : IDisposable
{
internal const int CRYPTO_BLOCK_SIZE = 16;
private readonly string password;
private readonly byte[] salt;
private byte[] aesInitializationVector;
private RijndaelEngine rijndael;
private RarRijndael(string password, byte[] salt)
{
this.password = password;
this.salt = salt;
}
private byte[] ComputeHash(byte[] input)
{
var sha = new Sha1Digest();
sha.BlockUpdate(input, 0, input.Length);
byte[] result = new byte[sha.GetDigestSize()];
sha.DoFinal(result, 0);
return result;
}
private void Initialize()
{
rijndael = new RijndaelEngine();
aesInitializationVector = new byte[CRYPTO_BLOCK_SIZE];
int rawLength = 2 * password.Length;
byte[] rawPassword = new byte[rawLength + 8];
byte[] passwordBytes = Encoding.UTF8.GetBytes(password);
for (int i = 0; i < password.Length; i++)
{
rawPassword[i * 2] = passwordBytes[i];
rawPassword[i * 2 + 1] = 0;
}
for (int i = 0; i < salt.Length; i++)
{
rawPassword[i + rawLength] = salt[i];
}
const int noOfRounds = (1 << 18);
IList<byte> bytes = new List<byte>();
byte[] digest;
//TODO slow code below, find ways to optimize
for (int i = 0; i < noOfRounds; i++)
{
bytes.AddRange(rawPassword);
bytes.AddRange(new[] { (byte)i, (byte)(i >> 8), (byte)(i >> CRYPTO_BLOCK_SIZE) });
if (i % (noOfRounds / CRYPTO_BLOCK_SIZE) == 0)
{
digest = ComputeHash(bytes.ToArray());
aesInitializationVector[i / (noOfRounds / CRYPTO_BLOCK_SIZE)] = digest[19];
}
}
digest = ComputeHash(bytes.ToArray());
//slow code ends
byte[] aesKey = new byte[CRYPTO_BLOCK_SIZE];
for (int i = 0; i < 4; i++)
for (int j = 0; j < 4; j++)
aesKey[i * 4 + j] = (byte)
(((digest[i * 4] * 0x1000000) & 0xff000000 |
(uint)((digest[i * 4 + 1] * 0x10000) & 0xff0000) |
(uint)((digest[i * 4 + 2] * 0x100) & 0xff00) |
(uint)(digest[i * 4 + 3] & 0xff)) >> (j * 8));
rijndael.Init(false, new KeyParameter(aesKey));
}
public static RarRijndael InitializeFrom(string password, byte[] salt)
{
var rijndael = new RarRijndael(password, salt);
rijndael.Initialize();
return rijndael;
}
public byte[] ProcessBlock(byte[] cipherText)
{
var plainText = new byte[CRYPTO_BLOCK_SIZE];
var decryptedBytes = new List<byte>();
rijndael.ProcessBlock(cipherText, 0, plainText, 0);
for (int j = 0; j < plainText.Length; j++)
decryptedBytes.Add((byte)(plainText[j] ^ aesInitializationVector[j % 16])); //32:114, 33:101
for (int j = 0; j < aesInitializationVector.Length; j++)
aesInitializationVector[j] = cipherText[j];
return decryptedBytes.ToArray();
}
public void Dispose()
{
}
}
}

View File

@@ -0,0 +1,112 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
namespace SharpCompress.Common.Rar
{
internal class RarRijndael : IDisposable
{
internal const int CRYPTO_BLOCK_SIZE = 16;
private readonly string password;
private readonly byte[] salt;
private byte[] aesInitializationVector;
private Rijndael rijndael;
private RarRijndael(string password, byte[] salt)
{
this.password = password;
this.salt = salt;
}
private void Initialize()
{
rijndael = new RijndaelManaged() { Padding = PaddingMode.None };
aesInitializationVector = new byte[CRYPTO_BLOCK_SIZE];
int rawLength = 2 * password.Length;
byte[] rawPassword = new byte[rawLength + 8];
byte[] passwordBytes = Encoding.UTF8.GetBytes(password);
for (int i = 0; i < password.Length; i++)
{
rawPassword[i * 2] = passwordBytes[i];
rawPassword[i * 2 + 1] = 0;
}
for (int i = 0; i < salt.Length; i++)
{
rawPassword[i + rawLength] = salt[i];
}
SHA1 sha = new SHA1CryptoServiceProvider();
const int noOfRounds = (1 << 18);
IList<byte> bytes = new List<byte>();
byte[] digest;
//TODO slow code below, find ways to optimize
for (int i = 0; i < noOfRounds; i++)
{
bytes.AddRange(rawPassword);
bytes.AddRange(new[] { (byte)i, (byte)(i >> 8), (byte)(i >> CRYPTO_BLOCK_SIZE) });
if (i % (noOfRounds / CRYPTO_BLOCK_SIZE) == 0)
{
digest = sha.ComputeHash(bytes.ToArray());
aesInitializationVector[i / (noOfRounds / CRYPTO_BLOCK_SIZE)] = digest[19];
}
}
digest = sha.ComputeHash(bytes.ToArray());
//slow code ends
byte[] aesKey = new byte[CRYPTO_BLOCK_SIZE];
for (int i = 0; i < 4; i++)
for (int j = 0; j < 4; j++)
aesKey[i * 4 + j] = (byte)
(((digest[i * 4] * 0x1000000) & 0xff000000 |
(uint)((digest[i * 4 + 1] * 0x10000) & 0xff0000) |
(uint)((digest[i * 4 + 2] * 0x100) & 0xff00) |
(uint)(digest[i * 4 + 3] & 0xff)) >> (j * 8));
rijndael.IV = new byte[CRYPTO_BLOCK_SIZE];
rijndael.Key = aesKey;
rijndael.BlockSize = CRYPTO_BLOCK_SIZE * 8;
}
public static RarRijndael InitializeFrom(string password, byte[] salt)
{
var rijndael = new RarRijndael(password, salt);
rijndael.Initialize();
return rijndael;
}
public byte[] ProcessBlock(byte[] cipherText)
{
var plainText = new byte[CRYPTO_BLOCK_SIZE];
var decryptedBytes = new List<byte>();
var decryptor = rijndael.CreateDecryptor();
using (var msDecrypt = new MemoryStream(cipherText))
{
using (var csDecrypt = new CryptoStream(msDecrypt, decryptor, CryptoStreamMode.Read))
{
csDecrypt.ReadFully(plainText);
}
}
for (int j = 0; j < plainText.Length; j++)
decryptedBytes.Add((byte)(plainText[j] ^ aesInitializationVector[j % 16])); //32:114, 33:101
for (int j = 0; j < aesInitializationVector.Length; j++)
aesInitializationVector[j] = cipherText[j];
return decryptedBytes.ToArray();
}
public void Dispose()
{
rijndael.Dispose();
}
}
}

View File

@@ -13,11 +13,18 @@ namespace SharpCompress.Common.Rar
public abstract class RarVolume : Volume
{
private readonly RarHeaderFactory headerFactory;
public string Password { get; set; }
internal RarVolume(StreamingMode mode, Stream stream, Options options)
internal RarVolume(StreamingMode mode, Stream stream, Options options)
: this(mode, stream, null, options)
{
}
internal RarVolume(StreamingMode mode, Stream stream, string password, Options options)
: base(stream, options)
{
headerFactory = new RarHeaderFactory(mode, options);
headerFactory = new RarHeaderFactory(mode, options, password);
}
internal StreamingMode Mode

View File

@@ -9,7 +9,7 @@ namespace SharpCompress.Common.SevenZip
{
}
#if !PORTABLE
#if !PORTABLE && !NETFX_CORE
public SevenZipVolume(FileInfo fileInfo, Options options)
: base(fileInfo, options)
{

View File

@@ -69,7 +69,7 @@ namespace SharpCompress.Common.Tar.Headers
}
if (Size >= 0x1FFFFFFFF)
{
#if PORTABLE
#if PORTABLE || NETFX_CORE
byte[] bytes = BitConverter.GetBytes(Utility.HostToNetworkOrder(Size));
#else
byte[] bytes = BitConverter.GetBytes(IPAddress.HostToNetworkOrder(Size));
@@ -104,7 +104,7 @@ namespace SharpCompress.Common.Tar.Headers
if ((buffer[124] & 0x80) == 0x80) // if size in binary
{
long sizeBigEndian = BitConverter.ToInt64(buffer, 0x80);
#if PORTABLE
#if PORTABLE || NETFX_CORE
Size = Utility.NetworkToHostOrder(sizeBigEndian);
#else
Size = IPAddress.NetworkToHostOrder(sizeBigEndian);

View File

@@ -4,19 +4,25 @@ namespace SharpCompress.Common.Tar
{
internal class TarReadOnlySubStream : Stream
{
private bool isDisposed;
private int amountRead;
public TarReadOnlySubStream(Stream stream, long bytesToRead)
{
this.Stream = stream;
this.BytesLeftToRead = bytesToRead;
Stream = stream;
BytesLeftToRead = bytesToRead;
}
protected override void Dispose(bool disposing)
{
if (isDisposed)
{
return;
}
isDisposed = true;
if (disposing)
{
int skipBytes = this.amountRead%512;
int skipBytes = this.amountRead % 512;
if (skipBytes == 0)
{
return;
@@ -70,7 +76,7 @@ namespace SharpCompress.Common.Tar
{
if (this.BytesLeftToRead < count)
{
count = (int) this.BytesLeftToRead;
count = (int)this.BytesLeftToRead;
}
int read = this.Stream.Read(buffer, offset, count);
if (read > 0)

View File

@@ -9,7 +9,7 @@ namespace SharpCompress.Common.Tar
{
}
#if !PORTABLE
#if !PORTABLE && !NETFX_CORE
public TarVolume(FileInfo fileInfo, Options options)
: base(fileInfo, options)
{

View File

@@ -31,7 +31,7 @@ namespace SharpCompress.Common
/// </summary>
public abstract bool IsMultiVolume { get; }
#if !PORTABLE
#if !PORTABLE && !NETFX_CORE
public abstract FileInfo VolumeFile { get; }
#endif

View File

@@ -54,7 +54,7 @@ namespace SharpCompress.Common.Zip.Headers
internal List<ExtraData> Extra { get; set; }
internal PkwareTraditionalEncryptionData PkwareTraditionalEncryptionData { get; set; }
#if !PORTABLE
#if !PORTABLE && !NETFX_CORE
internal WinzipAesEncryptionData WinzipAesEncryptionData { get; set; }
#endif

View File

@@ -15,6 +15,7 @@ namespace SharpCompress.Common.Zip
private readonly PkwareTraditionalEncryptionData encryptor;
private readonly CryptoMode mode;
private readonly Stream stream;
private bool isDisposed;
public PkwareTraditionalCryptoStream(Stream stream, PkwareTraditionalEncryptionData encryptor, CryptoMode mode)
{
@@ -104,5 +105,16 @@ namespace SharpCompress.Common.Zip
{
throw new NotSupportedException();
}
protected override void Dispose(bool disposing)
{
if (isDisposed)
{
return;
}
isDisposed = true;
base.Dispose(disposing);
stream.Dispose();
}
}
}

View File

@@ -0,0 +1,170 @@
using System;
using System.IO;
using Org.BouncyCastle.Crypto;
using Org.BouncyCastle.Crypto.Engines;
using Org.BouncyCastle.Crypto.Parameters;
namespace SharpCompress.Common.Zip
{
internal class WinzipAesCryptoStream : Stream
{
private const int BLOCK_SIZE_IN_BYTES = 16;
private readonly IBufferedCipher rijndael;
private readonly byte[] counter = new byte[BLOCK_SIZE_IN_BYTES];
private readonly Stream stream;
private int nonce = 1;
private byte[] counterOut = new byte[BLOCK_SIZE_IN_BYTES];
private bool isFinalBlock;
private long totalBytesLeftToRead;
private bool isDisposed;
internal WinzipAesCryptoStream(Stream stream, WinzipAesEncryptionData winzipAesEncryptionData, long length)
{
this.stream = stream;
totalBytesLeftToRead = length;
rijndael = CreateRijndael(winzipAesEncryptionData);
}
private IBufferedCipher CreateRijndael(WinzipAesEncryptionData winzipAesEncryptionData)
{
var blockCipher = new BufferedBlockCipher(new RijndaelEngine());
var param = new KeyParameter(winzipAesEncryptionData.KeyBytes);
blockCipher.Init(true, param);
return blockCipher;
}
public override bool CanRead
{
get { return true; }
}
public override bool CanSeek
{
get { return false; }
}
public override bool CanWrite
{
get { return false; }
}
public override long Length
{
get { throw new NotImplementedException(); }
}
public override long Position
{
get { throw new NotImplementedException(); }
set { throw new NotImplementedException(); }
}
protected override void Dispose(bool disposing)
{
if (isDisposed)
{
return;
}
isDisposed = true;
if (disposing)
{
//read out last 10 auth bytes
var ten = new byte[10];
stream.Read(ten, 0, 10);
stream.Dispose();
}
}
public override void Flush()
{
throw new NotImplementedException();
}
public override int Read(byte[] buffer, int offset, int count)
{
if (totalBytesLeftToRead == 0)
{
return 0;
}
int bytesToRead = count;
if (count > totalBytesLeftToRead)
{
bytesToRead = (int)totalBytesLeftToRead;
}
int read = stream.Read(buffer, offset, bytesToRead);
totalBytesLeftToRead -= read;
ReadTransformBlocks(buffer, offset, read);
return read;
}
private int ReadTransformOneBlock(byte[] buffer, int offset, int last)
{
if (isFinalBlock)
{
throw new InvalidOperationException();
}
int bytesRemaining = last - offset;
int bytesToRead = (bytesRemaining > BLOCK_SIZE_IN_BYTES)
? BLOCK_SIZE_IN_BYTES
: bytesRemaining;
// update the counter
Array.Copy(BitConverter.GetBytes(nonce++), 0, counter, 0, 4);
// Determine if this is the final block
if ((bytesToRead == bytesRemaining) && (totalBytesLeftToRead == 0))
{
counterOut = rijndael.DoFinal(counter, 0, BLOCK_SIZE_IN_BYTES);
isFinalBlock = true;
}
else
{
rijndael.ProcessBytes(counter, 0, BLOCK_SIZE_IN_BYTES, counterOut, 0);
}
XorInPlace(buffer, offset, bytesToRead);
return bytesToRead;
}
private void XorInPlace(byte[] buffer, int offset, int count)
{
for (int i = 0; i < count; i++)
{
buffer[offset + i] = (byte)(counterOut[i] ^ buffer[offset + i]);
}
}
private void ReadTransformBlocks(byte[] buffer, int offset, int count)
{
int posn = offset;
int last = count + offset;
while (posn < buffer.Length && posn < last)
{
int n = ReadTransformOneBlock(buffer, posn, last);
posn += n;
}
}
public override long Seek(long offset, SeekOrigin origin)
{
throw new NotImplementedException();
}
public override void SetLength(long value)
{
throw new NotImplementedException();
}
public override void Write(byte[] buffer, int offset, int count)
{
throw new NotImplementedException();
}
}
}

View File

@@ -9,48 +9,33 @@ namespace SharpCompress.Common.Zip
private const int BLOCK_SIZE_IN_BYTES = 16;
private readonly SymmetricAlgorithm cipher;
private readonly byte[] counter = new byte[BLOCK_SIZE_IN_BYTES];
private readonly HMACSHA1 hmac;
private readonly Stream stream;
private readonly ICryptoTransform transform;
private int _nonce = 1;
private int nonce = 1;
private byte[] counterOut = new byte[BLOCK_SIZE_IN_BYTES];
private bool isFinalBlock;
private CryptoMode mode;
private long totalBytesLeftToRead;
private bool isDisposed;
internal WinzipAesCryptoStream(Stream stream, WinzipAesEncryptionData winzipAesEncryptionData, long length,
CryptoMode mode)
internal WinzipAesCryptoStream(Stream stream, WinzipAesEncryptionData winzipAesEncryptionData, long length)
{
this.mode = mode;
this.stream = stream;
totalBytesLeftToRead = length;
hmac = new HMACSHA1(winzipAesEncryptionData.IvBytes);
cipher = CreateCipher(winzipAesEncryptionData);
var iv = new byte[BLOCK_SIZE_IN_BYTES];
transform = cipher.CreateEncryptor(winzipAesEncryptionData.KeyBytes, iv);
//if (_mode == CryptoMode.Encrypt)
//{
// _iobuf = new byte[2048];
// _PendingWriteBlock = new byte[BLOCK_SIZE_IN_BYTES];
//}
}
private SymmetricAlgorithm CreateCipher(WinzipAesEncryptionData winzipAesEncryptionData)
{
#if !SILVERLIGHT && !PORTABLE
RijndaelManaged cipher = new RijndaelManaged();
cipher.BlockSize = BLOCK_SIZE_IN_BYTES*8;
cipher.KeySize = winzipAesEncryptionData.KeyBytes.Length*8;
cipher.BlockSize = BLOCK_SIZE_IN_BYTES * 8;
cipher.KeySize = winzipAesEncryptionData.KeyBytes.Length * 8;
cipher.Mode = CipherMode.ECB;
cipher.Padding = PaddingMode.None;
return cipher;
#else
throw new NotSupportedException("Cannot decrypt Winzip AES with Silverlight or WP7.");
#endif
}
public override bool CanRead
@@ -81,6 +66,11 @@ namespace SharpCompress.Common.Zip
protected override void Dispose(bool disposing)
{
if (isDisposed)
{
return;
}
isDisposed = true;
if (disposing)
{
//read out last 10 auth bytes
@@ -104,7 +94,7 @@ namespace SharpCompress.Common.Zip
int bytesToRead = count;
if (count > totalBytesLeftToRead)
{
bytesToRead = (int) totalBytesLeftToRead;
bytesToRead = (int)totalBytesLeftToRead;
}
int read = stream.Read(buffer, offset, bytesToRead);
totalBytesLeftToRead -= read;
@@ -127,12 +117,11 @@ namespace SharpCompress.Common.Zip
: bytesRemaining;
// update the counter
Array.Copy(BitConverter.GetBytes(_nonce++), 0, counter, 0, 4);
Array.Copy(BitConverter.GetBytes(nonce++), 0, counter, 0, 4);
// Determine if this is the final block
if ((bytesToRead == bytesRemaining) && (totalBytesLeftToRead == 0))
{
hmac.TransformFinalBlock(buffer, offset, bytesToRead);
counterOut = transform.TransformFinalBlock(counter,
0,
BLOCK_SIZE_IN_BYTES);
@@ -140,7 +129,6 @@ namespace SharpCompress.Common.Zip
}
else
{
hmac.TransformBlock(buffer, offset, bytesToRead, null, 0);
transform.TransformBlock(counter,
0, // offset
BLOCK_SIZE_IN_BYTES,
@@ -157,7 +145,7 @@ namespace SharpCompress.Common.Zip
{
for (int i = 0; i < count; i++)
{
buffer[offset + i] = (byte) (counterOut[i] ^ buffer[offset + i]);
buffer[offset + i] = (byte)(counterOut[i] ^ buffer[offset + i]);
}
}

View File

@@ -0,0 +1,68 @@
using System;
using System.Text;
using SharpCompress.Crypto;
namespace SharpCompress.Common.Zip
{
internal class WinzipAesEncryptionData
{
private const int RFC2898_ITERATIONS = 1000;
private byte[] salt;
private WinzipAesKeySize keySize;
private byte[] passwordVerifyValue;
private string password;
private byte[] generatedVerifyValue;
internal WinzipAesEncryptionData(WinzipAesKeySize keySize, byte[] salt, byte[] passwordVerifyValue,
string password)
{
this.keySize = keySize;
this.salt = salt;
this.passwordVerifyValue = passwordVerifyValue;
this.password = password;
Initialize();
}
internal byte[] IvBytes { get; set; }
internal byte[] KeyBytes { get; set; }
private int KeySizeInBytes
{
get { return KeyLengthInBytes(keySize); }
}
internal static int KeyLengthInBytes(WinzipAesKeySize keySize)
{
switch (keySize)
{
case WinzipAesKeySize.KeySize128:
return 16;
case WinzipAesKeySize.KeySize192:
return 24;
case WinzipAesKeySize.KeySize256:
return 32;
}
throw new InvalidOperationException();
}
private void Initialize()
{
var utf8 = new UTF8Encoding(false);
var paramz = new PBKDF2(utf8.GetBytes(password), salt, RFC2898_ITERATIONS);
KeyBytes = paramz.GetBytes(KeySizeInBytes);
IvBytes = paramz.GetBytes(KeySizeInBytes);
generatedVerifyValue = paramz.GetBytes(2);
short verify = BitConverter.ToInt16(passwordVerifyValue, 0);
if (password != null)
{
short generated = BitConverter.ToInt16(generatedVerifyValue, 0);
if (verify != generated)
throw new InvalidFormatException("bad password");
}
}
}
}

View File

@@ -89,7 +89,7 @@ namespace SharpCompress.Common.Zip
Header.CompressedSize > 0 ? Header.CompressedSize - 4 - props.Length : -1,
FlagUtility.HasFlag(Header.Flags, HeaderFlags.Bit1)
? -1
: (long) Header.UncompressedSize);
: (long)Header.UncompressedSize);
}
case ZipCompressionMethod.PPMd:
{
@@ -120,7 +120,7 @@ namespace SharpCompress.Common.Zip
{
throw new InvalidFormatException("Unexpected vendor ID for WinZip AES metadata");
}
Header.CompressionMethod = (ZipCompressionMethod) BitConverter.ToUInt16(data.DataBytes, 5);
Header.CompressionMethod = (ZipCompressionMethod)BitConverter.ToUInt16(data.DataBytes, 5);
return CreateDecompressionStream(stream);
}
default:
@@ -133,8 +133,8 @@ namespace SharpCompress.Common.Zip
protected Stream GetCryptoStream(Stream plainStream)
{
if ((Header.CompressedSize == 0)
#if !PORTABLE
&& ((Header.PkwareTraditionalEncryptionData != null)
#if !PORTABLE && !NETFX_CORE
&& ((Header.PkwareTraditionalEncryptionData != null)
|| (Header.WinzipAesEncryptionData != null)))
#else
&& (Header.PkwareTraditionalEncryptionData != null))
@@ -156,12 +156,11 @@ namespace SharpCompress.Common.Zip
return new PkwareTraditionalCryptoStream(plainStream, Header.PkwareTraditionalEncryptionData,
CryptoMode.Decrypt);
}
#if !PORTABLE
#if !PORTABLE && !NETFX_CORE
if (Header.WinzipAesEncryptionData != null)
{
//only read 10 less because the last ten are auth bytes
return new WinzipAesCryptoStream(plainStream, Header.WinzipAesEncryptionData,
Header.CompressedSize - 10, CryptoMode.Decrypt);
return new WinzipAesCryptoStream(plainStream, Header.WinzipAesEncryptionData, Header.CompressedSize - 10);
}
#endif
return plainStream;

View File

@@ -2,7 +2,7 @@
using System.IO;
using SharpCompress.Common.Zip.Headers;
using SharpCompress.IO;
#if !SILVERLIGHT && !PORTABLE
#if !PORTABLE
using System.Linq;
#endif
@@ -135,7 +135,7 @@ namespace SharpCompress.Common.Zip
}
else
{
#if SILVERLIGHT || PORTABLE
#if PORTABLE || NETFX_CORE
throw new NotSupportedException("Cannot decrypt Winzip AES with Silverlight or WP7.");
#else

View File

@@ -9,7 +9,7 @@ namespace SharpCompress.Common.Zip
{
}
#if !PORTABLE
#if !PORTABLE && !NETFX_CORE
public ZipVolume(FileInfo fileInfo, Options options)
: base(fileInfo, options)
{

View File

@@ -5,6 +5,7 @@ namespace SharpCompress.Compressor.BZip2
public class BZip2Stream : Stream
{
private readonly Stream stream;
private bool isDisposed;
/// <summary>
/// Create a BZip2Stream
@@ -29,6 +30,11 @@ namespace SharpCompress.Compressor.BZip2
protected override void Dispose(bool disposing)
{
if (isDisposed)
{
return;
}
isDisposed = true;
if (disposing)
{
stream.Dispose();

View File

@@ -65,8 +65,8 @@ namespace SharpCompress.Compressor.BZip2
{
if (inUse[i])
{
seqToUnseq[nInUse] = (char) i;
unseqToSeq[i] = (char) nInUse;
seqToUnseq[nInUse] = (char)i;
unseqToSeq[i] = (char)nInUse;
nInUse++;
}
}
@@ -145,6 +145,7 @@ namespace SharpCompress.Compressor.BZip2
private int rTPos = 0;
private int j2;
private char z;
private bool isDisposed;
public CBZip2InputStream(Stream zStream, bool decompressConcatenated, bool leaveOpen)
{
@@ -157,6 +158,20 @@ namespace SharpCompress.Compressor.BZip2
SetupBlock();
}
protected override void Dispose(bool disposing)
{
if (isDisposed)
{
return;
}
isDisposed = true;
base.Dispose(disposing);
if (bsStream != null)
{
bsStream.Dispose();
}
}
internal static int[][] InitIntArray(int n1, int n2)
{
int[][] a = new int[n1][];
@@ -299,7 +314,7 @@ namespace SharpCompress.Compressor.BZip2
}
computedCombinedCRC = (computedCombinedCRC << 1)
| (int) (((uint) computedCombinedCRC) >> 31);
| (int)(((uint)computedCombinedCRC) >> 31);
computedCombinedCRC ^= computedBlockCRC;
}
@@ -372,7 +387,7 @@ namespace SharpCompress.Compressor.BZip2
int thech = '\0';
try
{
thech = (char) bsStream.ReadByte();
thech = (char)bsStream.ReadByte();
}
catch (IOException)
{
@@ -394,7 +409,7 @@ namespace SharpCompress.Compressor.BZip2
private char BsGetUChar()
{
return (char) BsR(8);
return (char)BsR(8);
}
private int BsGetint()
@@ -409,12 +424,12 @@ namespace SharpCompress.Compressor.BZip2
private int BsGetIntVS(int numBits)
{
return (int) BsR(numBits);
return (int)BsR(numBits);
}
private int BsGetInt32()
{
return (int) BsGetint();
return (int)BsGetint();
}
private void HbCreateDecodeTables(int[] limit, int[] basev,
@@ -501,7 +516,7 @@ namespace SharpCompress.Compressor.BZip2
{
if (BsR(1) == 1)
{
inUse[i*16 + j] = true;
inUse[i * 16 + j] = true;
}
}
}
@@ -520,7 +535,7 @@ namespace SharpCompress.Compressor.BZip2
{
j++;
}
selectorMtf[i] = (char) j;
selectorMtf[i] = (char)j;
}
/* Undo the MTF values for the selectors. */
@@ -563,7 +578,7 @@ namespace SharpCompress.Compressor.BZip2
curr--;
}
}
len[t][i] = (char) curr;
len[t][i] = (char)curr;
}
}
@@ -595,7 +610,7 @@ namespace SharpCompress.Compressor.BZip2
int i, j, nextSym, limitLast;
int EOB, groupNo, groupPos;
limitLast = BZip2Constants.baseBlockSize*blockSize100k;
limitLast = BZip2Constants.baseBlockSize * blockSize100k;
origPtr = BsGetIntVS(24);
RecvDecodingTables();
@@ -616,7 +631,7 @@ namespace SharpCompress.Compressor.BZip2
for (i = 0; i <= 255; i++)
{
yy[i] = (char) i;
yy[i] = (char)i;
}
last = -1;
@@ -643,7 +658,7 @@ namespace SharpCompress.Compressor.BZip2
char thech = '\0';
try
{
thech = (char) bsStream.ReadByte();
thech = (char)bsStream.ReadByte();
}
catch (IOException)
{
@@ -682,13 +697,13 @@ namespace SharpCompress.Compressor.BZip2
{
if (nextSym == BZip2Constants.RUNA)
{
s = s + (0 + 1)*N;
s = s + (0 + 1) * N;
}
else if (nextSym == BZip2Constants.RUNB)
{
s = s + (1 + 1)*N;
s = s + (1 + 1) * N;
}
N = N*2;
N = N * 2;
{
int zt, zn, zvec, zj;
if (groupPos == 0)
@@ -711,7 +726,7 @@ namespace SharpCompress.Compressor.BZip2
char thech = '\0';
try
{
thech = (char) bsStream.ReadByte();
thech = (char)bsStream.ReadByte();
}
catch (IOException)
{
@@ -808,7 +823,7 @@ namespace SharpCompress.Compressor.BZip2
char thech = '\0';
try
{
thech = (char) bsStream.ReadByte();
thech = (char)bsStream.ReadByte();
}
catch (IOException)
{
@@ -848,7 +863,7 @@ namespace SharpCompress.Compressor.BZip2
for (i = 0; i <= last; i++)
{
ch = (char) ll8[i];
ch = (char)ll8[i];
tt[cftab[ch]] = i;
cftab[ch]++;
}
@@ -889,7 +904,7 @@ namespace SharpCompress.Compressor.BZip2
}
}
rNToGo--;
ch2 ^= (int) ((rNToGo == 1) ? 1 : 0);
ch2 ^= (int)((rNToGo == 1) ? 1 : 0);
i2++;
currentChar = ch2;
@@ -950,7 +965,7 @@ namespace SharpCompress.Compressor.BZip2
}
}
rNToGo--;
z ^= (char) ((rNToGo == 1) ? 1 : 0);
z ^= (char)((rNToGo == 1) ? 1 : 0);
j2 = 0;
currentState = RAND_PART_C_STATE;
SetupRandPartC();
@@ -965,7 +980,7 @@ namespace SharpCompress.Compressor.BZip2
private void SetupRandPartC()
{
if (j2 < (int) z)
if (j2 < (int)z)
{
currentChar = ch2;
mCrc.UpdateCRC(ch2);
@@ -1009,7 +1024,7 @@ namespace SharpCompress.Compressor.BZip2
private void SetupNoRandPartC()
{
if (j2 < (int) z)
if (j2 < (int)z)
{
currentChar = ch2;
mCrc.UpdateCRC(ch2);
@@ -1039,7 +1054,7 @@ namespace SharpCompress.Compressor.BZip2
return;
}
int n = BZip2Constants.baseBlockSize*newSize100k;
int n = BZip2Constants.baseBlockSize * newSize100k;
ll8 = new char[n];
tt = new int[n];
}
@@ -1057,7 +1072,7 @@ namespace SharpCompress.Compressor.BZip2
c = ReadByte();
if (c == -1)
break;
buffer[k + offset] = (byte) c;
buffer[k + offset] = (byte)c;
}
return k;
}

View File

@@ -36,13 +36,6 @@ namespace SharpCompress.Compressor.Deflate
public class GZipStream : Stream
{
internal static readonly DateTime UnixEpoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
/*
#if SILVERLIGHT || PORTABLE || MONO
internal static readonly Encoding Iso8859Dash1 = Encoding.UTF8;
#else
internal static readonly Encoding Iso8859Dash1 = Encoding.GetEncoding("iso-8859-1");
#endif
*/
public DateTime? LastModified { get; set; }

File diff suppressed because it is too large Load Diff

View File

@@ -25,8 +25,8 @@
// ------------------------------------------------------------------
using System;
using SharpCompress.Common.Tar.Headers;
using SharpCompress.Common;
using SharpCompress.Common.Tar.Headers;
namespace SharpCompress.Compressor.Deflate
{
@@ -65,7 +65,8 @@ namespace SharpCompress.Compressor.Deflate
{
get
{
if (crc == null) return 0;
if (crc == null)
return 0;
return crc.Crc32Result;
}
}
@@ -176,7 +177,8 @@ namespace SharpCompress.Compressor.Deflate
private void finish()
{
if (_z == null) return;
if (_z == null)
return;
if (_streamMode == StreamMode.Writer)
{
@@ -220,7 +222,7 @@ namespace SharpCompress.Compressor.Deflate
// Emit the GZIP trailer: CRC32 and size mod 2^32
int c1 = crc.Crc32Result;
_stream.Write(BitConverter.GetBytes(c1), 0, 4);
int c2 = (Int32) (crc.TotalBytesRead & 0x00000000FFFFFFFF);
int c2 = (Int32)(crc.TotalBytesRead & 0x00000000FFFFFFFF);
_stream.Write(BitConverter.GetBytes(c2), 0, 4);
}
else
@@ -229,7 +231,7 @@ namespace SharpCompress.Compressor.Deflate
}
}
}
// workitem 7159
// workitem 7159
else if (_streamMode == StreamMode.Reader)
{
if (_flavor == ZlibStreamFlavor.GZIP)
@@ -268,7 +270,7 @@ namespace SharpCompress.Compressor.Deflate
Int32 crc32_expected = BitConverter.ToInt32(trailer, 0);
Int32 crc32_actual = crc.Crc32Result;
Int32 isize_expected = BitConverter.ToInt32(trailer, 4);
Int32 isize_actual = (Int32) (_z.TotalBytesOut & 0x00000000FFFFFFFF);
Int32 isize_actual = (Int32)(_z.TotalBytesOut & 0x00000000FFFFFFFF);
if (crc32_actual != crc32_expected)
throw new ZlibException(
@@ -306,6 +308,11 @@ namespace SharpCompress.Compressor.Deflate
protected override void Dispose(bool disposing)
{
if (isDisposed)
{
return;
}
isDisposed = true;
base.Dispose(disposing);
if (disposing)
{
@@ -355,6 +362,7 @@ namespace SharpCompress.Compressor.Deflate
#endif
private bool nomoreinput = false;
private bool isDisposed;
private string ReadZeroTerminatedString()
@@ -406,7 +414,7 @@ namespace SharpCompress.Compressor.Deflate
n = _stream.Read(header, 0, 2); // 2-byte length field
totalBytesRead += n;
Int16 extraLength = (Int16) (header[0] + header[1]*256);
Int16 extraLength = (Int16)(header[0] + header[1] * 256);
byte[] extra = new byte[extraLength];
n = _stream.Read(extra, 0, extra.Length);
if (n != extraLength)
@@ -434,7 +442,8 @@ namespace SharpCompress.Compressor.Deflate
if (_streamMode == StreamMode.Undefined)
{
if (!this._stream.CanRead) throw new ZlibException("The stream is not readable.");
if (!this._stream.CanRead)
throw new ZlibException("The stream is not readable.");
// for the first read, set up some controls.
_streamMode = StreamMode.Reader;
// (The first reference to _z goes through the private accessor which
@@ -452,12 +461,18 @@ namespace SharpCompress.Compressor.Deflate
if (_streamMode != StreamMode.Reader)
throw new ZlibException("Cannot Read after Writing.");
if (count == 0) return 0;
if (nomoreinput && _wantCompress) return 0; // workitem 8557
if (buffer == null) throw new ArgumentNullException("buffer");
if (count < 0) throw new ArgumentOutOfRangeException("count");
if (offset < buffer.GetLowerBound(0)) throw new ArgumentOutOfRangeException("offset");
if ((offset + count) > buffer.GetLength(0)) throw new ArgumentOutOfRangeException("count");
if (count == 0)
return 0;
if (nomoreinput && _wantCompress)
return 0; // workitem 8557
if (buffer == null)
throw new ArgumentNullException("buffer");
if (count < 0)
throw new ArgumentOutOfRangeException("count");
if (offset < buffer.GetLowerBound(0))
throw new ArgumentOutOfRangeException("offset");
if ((offset + count) > buffer.GetLength(0))
throw new ArgumentOutOfRangeException("count");
int rc = 0;

View File

@@ -27,6 +27,7 @@ namespace SharpCompress.Compressor.Filters
private ushort[] p = new ushort[256 + 2];
private uint range, code;
private byte prevByte = 0;
private bool isDisposed;
private const int kNumTopBits = 24;
private const int kTopValue = 1 << kNumTopBits;
@@ -62,6 +63,17 @@ namespace SharpCompress.Compressor.Filters
code = (code << 8) | control[controlPos++];
}
protected override void Dispose(bool disposing)
{
if (isDisposed)
{
return;
}
isDisposed = true;
base.Dispose(disposing);
baseStream.Dispose();
}
public override bool CanRead
{
get { return true; }

View File

@@ -13,6 +13,7 @@ namespace SharpCompress.Compressor.Filters
private int transformed = 0;
private int read = 0;
private bool endReached = false;
private bool isDisposed;
protected Filter(bool isEncoder, Stream baseStream, int lookahead)
{
@@ -22,6 +23,17 @@ namespace SharpCompress.Compressor.Filters
window = new byte[tail.Length * 2];
}
protected override void Dispose(bool disposing)
{
if (isDisposed)
{
return;
}
isDisposed = true;
base.Dispose(disposing);
baseStream.Dispose();
}
public override bool CanRead
{
get { return !isEncoder; }

View File

@@ -18,6 +18,7 @@ namespace SharpCompress.Compressor.LZMA
private int mOffset;
private int mEnding;
private int mUnderflow;
private bool isDisposed;
#endregion
@@ -28,7 +29,7 @@ namespace SharpCompress.Compressor.LZMA
mStream = input;
mLimit = limit;
if (((uint) input.Length & 15) != 0)
if (((uint)input.Length & 15) != 0)
throw new NotSupportedException("AES decoder does not support padding.");
int numCyclesPower;
@@ -52,6 +53,11 @@ namespace SharpCompress.Compressor.LZMA
{
try
{
if (isDisposed)
{
return;
}
isDisposed = true;
if (disposing)
{
mStream.Dispose();
@@ -106,7 +112,7 @@ namespace SharpCompress.Compressor.LZMA
// Currently this is handled by forcing an underflow if
// the stream length is not a multiple of the block size.
if (count > mLimit - mWritten)
count = (int) (mLimit - mWritten);
count = (int)(mLimit - mWritten);
// We cannot transform less than 16 bytes into the target buffer,
// but we also cannot return zero, so we need to handle this.

View File

@@ -29,7 +29,7 @@ namespace SharpCompress.Compressor.LZMA
if (bt < 0)
throw new EndOfStreamException();
return (byte) bt;
return (byte)bt;
}
public void Dispose()
@@ -49,7 +49,7 @@ namespace SharpCompress.Compressor.LZMA
public StatusDecoder()
{
Prob = kBitModelTotal/2;
Prob = kBitModelTotal / 2;
}
private void UpdateModel(uint symbol)
@@ -66,7 +66,7 @@ namespace SharpCompress.Compressor.LZMA
public uint Decode(RangeDecoder decoder)
{
uint newBound = (decoder.Range >> kNumBitModelTotalBits)*Prob;
uint newBound = (decoder.Range >> kNumBitModelTotalBits) * Prob;
if (decoder.Code < newBound)
{
decoder.Range = newBound;
@@ -102,6 +102,7 @@ namespace SharpCompress.Compressor.LZMA
private long mLimit;
private IEnumerator<byte> mIter;
private bool mFinished;
private bool isDisposed;
public Bcj2DecoderStream(Stream[] streams, byte[] info, long limit)
{
@@ -124,6 +125,19 @@ namespace SharpCompress.Compressor.LZMA
mIter = Run().GetEnumerator();
}
protected override void Dispose(bool disposing)
{
if (isDisposed)
{
return;
}
isDisposed = true;
base.Dispose(disposing);
mMainStream.Dispose();
mCallStream.Dispose();
mJumpStream.Dispose();
}
private static bool IsJcc(byte b0, byte b1)
{
return b0 == 0x0F
@@ -171,7 +185,7 @@ namespace SharpCompress.Compressor.LZMA
byte prevByte = 0;
uint processedBytes = 0;
for (;;)
for (; ; )
{
byte b = 0;
uint i;
@@ -181,7 +195,7 @@ namespace SharpCompress.Compressor.LZMA
if (tmp < 0)
yield break;
b = (byte) tmp;
b = (byte)tmp;
mWritten++;
yield return b;
if (IsJ(prevByte, b))
@@ -206,19 +220,19 @@ namespace SharpCompress.Compressor.LZMA
throw new EndOfStreamException();
src <<= 8;
src |= (uint) b0;
src |= (uint)b0;
}
uint dest = src - (uint) (mWritten + 4);
uint dest = src - (uint)(mWritten + 4);
mWritten++;
yield return (byte) dest;
yield return (byte)dest;
mWritten++;
yield return (byte) (dest >> 8);
yield return (byte)(dest >> 8);
mWritten++;
yield return (byte) (dest >> 16);
yield return (byte)(dest >> 16);
mWritten++;
yield return (byte) (dest >> 24);
prevByte = (byte) (dest >> 24);
yield return (byte)(dest >> 24);
prevByte = (byte)(dest >> 24);
processedBytes += 4;
}
else

View File

@@ -6,7 +6,7 @@ namespace SharpCompress.Compressor.LZMA
internal static class CRC
{
public const uint kInitCRC = 0xFFFFFFFF;
private static uint[] kTable = new uint[4*256];
private static uint[] kTable = new uint[4 * 256];
static CRC()
{
@@ -34,7 +34,7 @@ namespace SharpCompress.Compressor.LZMA
byte[] buffer = new byte[Math.Min(length, 4 << 10)];
while (length > 0)
{
int delta = stream.Read(buffer, 0, (int) Math.Min(length, buffer.Length));
int delta = stream.Read(buffer, 0, (int)Math.Min(length, buffer.Length));
if (delta == 0)
throw new EndOfStreamException();
crc = Update(crc, buffer, 0, delta);
@@ -64,12 +64,12 @@ namespace SharpCompress.Compressor.LZMA
public static uint Update(uint crc, ulong value)
{
return Update(Update(crc, (uint) value), (uint) (value >> 32));
return Update(Update(crc, (uint)value), (uint)(value >> 32));
}
public static uint Update(uint crc, long value)
{
return Update(crc, (ulong) value);
return Update(crc, (ulong)value);
}
public static uint Update(uint crc, byte[] buffer, int offset, int length)
@@ -80,7 +80,7 @@ namespace SharpCompress.Compressor.LZMA
return crc;
}
#if !SILVERLIGHT && !PORTABLE
#if !PORTABLE && !NETFX_CORE
public static unsafe uint Update(uint crc, byte* buffer, int length)
{
while (length > 0 && ((int) buffer & 3) != 0)

View File

@@ -31,7 +31,7 @@ namespace SharpCompress.Compressor.LZMA
if (_needsIndent)
{
_needsIndent = false;
#if !SILVERLIGHT && !PORTABLE
#if !PORTABLE && !NETFX_CORE
System.Diagnostics.Debug.Write(_indent.Peek());
#endif
}
@@ -40,7 +40,7 @@ namespace SharpCompress.Compressor.LZMA
public static void Write(object value)
{
EnsureIndent();
#if !SILVERLIGHT && !PORTABLE
#if !PORTABLE && !NETFX_CORE
System.Diagnostics.Debug.Write(value);
#endif
}
@@ -48,7 +48,7 @@ namespace SharpCompress.Compressor.LZMA
public static void Write(string text)
{
EnsureIndent();
#if !SILVERLIGHT && !PORTABLE
#if !PORTABLE && !NETFX_CORE
System.Diagnostics.Debug.Write(text);
#endif
}
@@ -56,7 +56,7 @@ namespace SharpCompress.Compressor.LZMA
public static void Write(string format, params object[] args)
{
EnsureIndent();
#if !SILVERLIGHT && !PORTABLE
#if !PORTABLE && !NETFX_CORE
System.Diagnostics.Debug.Write(string.Format(format, args));
#endif
}

View File

@@ -29,6 +29,7 @@ namespace SharpCompress.Compressor.LZMA
private byte[] props = new byte[5];
private Encoder encoder;
private bool isDisposed;
public LzmaStream(byte[] properties, Stream inputStream)
: this(properties, inputStream, -1, -1, null, properties.Length < 5)
@@ -132,10 +133,21 @@ namespace SharpCompress.Compressor.LZMA
protected override void Dispose(bool disposing)
{
if (isDisposed)
{
return;
}
isDisposed = true;
if (disposing)
{
if (encoder != null)
{
position = encoder.Code(null, true);
}
if (inputStream != null)
{
inputStream.Dispose();
}
}
base.Dispose(disposing);
}

View File

@@ -33,7 +33,7 @@ namespace SharpCompress.Compressor.LZMA
case k_LZMA:
case k_LZMA2:
return new LzmaStream(info, inStreams.Single(), -1, limit);
#if !SILVERLIGHT && !PORTABLE
#if !PORTABLE && !NETFX_CORE
case CMethodId.kAESId:
return new AesDecoderStream(inStreams.Single(), info, pass, limit);
#endif

View File

@@ -9,6 +9,7 @@ namespace SharpCompress.Compressor.LZMA.Utilites
private Stream mTarget;
private uint mCRC;
private bool mFinished;
private bool isDisposed;
public CrcBuilderStream(Stream target)
{
@@ -16,6 +17,17 @@ namespace SharpCompress.Compressor.LZMA.Utilites
mCRC = CRC.kInitCRC;
}
protected override void Dispose(bool disposing)
{
if (isDisposed)
{
return;
}
isDisposed = true;
mTarget.Dispose();
base.Dispose(disposing);
}
public long Processed
{
get { return mProcessed; }

View File

@@ -13,6 +13,7 @@ namespace SharpCompress.Compressor.LZMA.Utilites
private long mOrigin;
private long mEnding;
private long mOffset;
private bool isDisposed;
public SyncStreamView(object sync, Stream stream, long origin, long length)
{
@@ -23,6 +24,17 @@ namespace SharpCompress.Compressor.LZMA.Utilites
mOffset = 0;
}
protected override void Dispose(bool disposing)
{
if (isDisposed)
{
return;
}
isDisposed = true;
base.Dispose(disposing);
mStream.Dispose();
}
public override bool CanRead
{
get { return true; }
@@ -64,7 +76,7 @@ namespace SharpCompress.Compressor.LZMA.Utilites
{
long remaining = mEnding - mOrigin - mOffset;
if (count > remaining)
count = (int) remaining;
count = (int)remaining;
if (count == 0)
return 0;

View File

@@ -13,6 +13,7 @@ namespace SharpCompress.Compressor.PPMd
private H.ModelPPM modelH;
private LZMA.RangeCoder.Decoder decoder;
private long position = 0;
private bool isDisposed;
public PpmdStream(PpmdProperties properties, Stream stream, bool compress)
{
@@ -69,6 +70,11 @@ namespace SharpCompress.Compressor.PPMd
protected override void Dispose(bool isDisposing)
{
if (isDisposed)
{
return;
}
isDisposed = true;
if (isDisposing)
{
if (compress)

View File

@@ -20,6 +20,7 @@ namespace SharpCompress.Compressor.Rar
private int outOffset;
private int outCount = 0;
private int outTotal;
private bool isDisposed;
public RarStream(Unpack unpack, FileHeader fileHeader, Stream readStream)
{
@@ -31,6 +32,17 @@ namespace SharpCompress.Compressor.Rar
fetch = false;
}
protected override void Dispose(bool disposing)
{
if (isDisposed)
{
return;
}
isDisposed = true;
base.Dispose(disposing);
readStream.Dispose();
}
public override bool CanRead
{
get { throw new NotImplementedException(); }
@@ -116,7 +128,7 @@ namespace SharpCompress.Compressor.Rar
if (tmpBuffer.Length < tmpCount + count)
{
byte[] newBuffer =
new byte[tmpBuffer.Length*2 > tmpCount + count ? tmpBuffer.Length*2 : tmpCount + count];
new byte[tmpBuffer.Length * 2 > tmpCount + count ? tmpBuffer.Length * 2 : tmpCount + count];
Buffer.BlockCopy(tmpBuffer, 0, newBuffer, 0, tmpCount);
tmpBuffer = newBuffer;
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,376 @@
using System;
namespace Org.BouncyCastle.Crypto
{
/**
* A wrapper class that allows block ciphers to be used to process data in
* a piecemeal fashion. The BufferedBlockCipher outputs a block only when the
* buffer is full and more data is being added, or on a doFinal.
* <p>
* Note: in the case where the underlying cipher is either a CFB cipher or an
* OFB one the last block may not be a multiple of the block size.
* </p>
*/
public class BufferedBlockCipher
: BufferedCipherBase
{
internal byte[] buf;
internal int bufOff;
internal bool forEncryption;
internal IBlockCipher cipher;
/**
* constructor for subclasses
*/
protected BufferedBlockCipher()
{
}
/**
* Create a buffered block cipher without padding.
*
* @param cipher the underlying block cipher this buffering object wraps.
* false otherwise.
*/
public BufferedBlockCipher(
IBlockCipher cipher)
{
if (cipher == null)
throw new ArgumentNullException("cipher");
this.cipher = cipher;
buf = new byte[cipher.GetBlockSize()];
bufOff = 0;
}
public override string AlgorithmName
{
get { return cipher.AlgorithmName; }
}
/**
* initialise the cipher.
*
* @param forEncryption if true the cipher is initialised for
* encryption, if false for decryption.
* @param param the key and other data required by the cipher.
* @exception ArgumentException if the parameters argument is
* inappropriate.
*/
// Note: This doubles as the Init in the event that this cipher is being used as an IWrapper
public override void Init(
bool forEncryption,
ICipherParameters parameters)
{
this.forEncryption = forEncryption;
//if (parameters is ParametersWithRandom)
//{
// parameters = ((ParametersWithRandom) parameters).Parameters;
//}
Reset();
cipher.Init(forEncryption, parameters);
}
/**
* return the blocksize for the underlying cipher.
*
* @return the blocksize for the underlying cipher.
*/
public override int GetBlockSize()
{
return cipher.GetBlockSize();
}
/**
* return the size of the output buffer required for an update
* an input of len bytes.
*
* @param len the length of the input.
* @return the space required to accommodate a call to update
* with len bytes of input.
*/
public override int GetUpdateOutputSize(
int length)
{
int total = length + bufOff;
int leftOver = total % buf.Length;
return total - leftOver;
}
/**
* return the size of the output buffer required for an update plus a
* doFinal with an input of len bytes.
*
* @param len the length of the input.
* @return the space required to accommodate a call to update and doFinal
* with len bytes of input.
*/
public override int GetOutputSize(
int length)
{
// Note: Can assume IsPartialBlockOkay is true for purposes of this calculation
return length + bufOff;
}
/**
* process a single byte, producing an output block if neccessary.
*
* @param in the input byte.
* @param out the space for any output that might be produced.
* @param outOff the offset from which the output will be copied.
* @return the number of output bytes copied to out.
* @exception DataLengthException if there isn't enough space in out.
* @exception InvalidOperationException if the cipher isn't initialised.
*/
public override int ProcessByte(
byte input,
byte[] output,
int outOff)
{
buf[bufOff++] = input;
if (bufOff == buf.Length)
{
if ((outOff + buf.Length) > output.Length)
throw new DataLengthException("output buffer too short");
bufOff = 0;
return cipher.ProcessBlock(buf, 0, output, outOff);
}
return 0;
}
public override byte[] ProcessByte(
byte input)
{
int outLength = GetUpdateOutputSize(1);
byte[] outBytes = outLength > 0 ? new byte[outLength] : null;
int pos = ProcessByte(input, outBytes, 0);
if (outLength > 0 && pos < outLength)
{
byte[] tmp = new byte[pos];
Array.Copy(outBytes, 0, tmp, 0, pos);
outBytes = tmp;
}
return outBytes;
}
public override byte[] ProcessBytes(
byte[] input,
int inOff,
int length)
{
if (input == null)
throw new ArgumentNullException("input");
if (length < 1)
return null;
int outLength = GetUpdateOutputSize(length);
byte[] outBytes = outLength > 0 ? new byte[outLength] : null;
int pos = ProcessBytes(input, inOff, length, outBytes, 0);
if (outLength > 0 && pos < outLength)
{
byte[] tmp = new byte[pos];
Array.Copy(outBytes, 0, tmp, 0, pos);
outBytes = tmp;
}
return outBytes;
}
/**
* process an array of bytes, producing output if necessary.
*
* @param in the input byte array.
* @param inOff the offset at which the input data starts.
* @param len the number of bytes to be copied out of the input array.
* @param out the space for any output that might be produced.
* @param outOff the offset from which the output will be copied.
* @return the number of output bytes copied to out.
* @exception DataLengthException if there isn't enough space in out.
* @exception InvalidOperationException if the cipher isn't initialised.
*/
public override int ProcessBytes(
byte[] input,
int inOff,
int length,
byte[] output,
int outOff)
{
if (length < 1)
{
if (length < 0)
throw new ArgumentException("Can't have a negative input length!");
return 0;
}
int blockSize = GetBlockSize();
int outLength = GetUpdateOutputSize(length);
if (outLength > 0)
{
if ((outOff + outLength) > output.Length)
{
throw new DataLengthException("output buffer too short");
}
}
int resultLen = 0;
int gapLen = buf.Length - bufOff;
if (length > gapLen)
{
Array.Copy(input, inOff, buf, bufOff, gapLen);
resultLen += cipher.ProcessBlock(buf, 0, output, outOff);
bufOff = 0;
length -= gapLen;
inOff += gapLen;
while (length > buf.Length)
{
resultLen += cipher.ProcessBlock(input, inOff, output, outOff + resultLen);
length -= blockSize;
inOff += blockSize;
}
}
Array.Copy(input, inOff, buf, bufOff, length);
bufOff += length;
if (bufOff == buf.Length)
{
resultLen += cipher.ProcessBlock(buf, 0, output, outOff + resultLen);
bufOff = 0;
}
return resultLen;
}
public override byte[] DoFinal()
{
byte[] outBytes = EmptyBuffer;
int length = GetOutputSize(0);
if (length > 0)
{
outBytes = new byte[length];
int pos = DoFinal(outBytes, 0);
if (pos < outBytes.Length)
{
byte[] tmp = new byte[pos];
Array.Copy(outBytes, 0, tmp, 0, pos);
outBytes = tmp;
}
}
else
{
Reset();
}
return outBytes;
}
public override byte[] DoFinal(
byte[] input,
int inOff,
int inLen)
{
if (input == null)
throw new ArgumentNullException("input");
int length = GetOutputSize(inLen);
byte[] outBytes = EmptyBuffer;
if (length > 0)
{
outBytes = new byte[length];
int pos = (inLen > 0)
? ProcessBytes(input, inOff, inLen, outBytes, 0)
: 0;
pos += DoFinal(outBytes, pos);
if (pos < outBytes.Length)
{
byte[] tmp = new byte[pos];
Array.Copy(outBytes, 0, tmp, 0, pos);
outBytes = tmp;
}
}
else
{
Reset();
}
return outBytes;
}
/**
* Process the last block in the buffer.
*
* @param out the array the block currently being held is copied into.
* @param outOff the offset at which the copying starts.
* @return the number of output bytes copied to out.
* @exception DataLengthException if there is insufficient space in out for
* the output, or the input is not block size aligned and should be.
* @exception InvalidOperationException if the underlying cipher is not
* initialised.
* @exception InvalidCipherTextException if padding is expected and not found.
* @exception DataLengthException if the input is not block size
* aligned.
*/
public override int DoFinal(
byte[] output,
int outOff)
{
try
{
if (bufOff != 0)
{
if (!cipher.IsPartialBlockOkay)
{
throw new DataLengthException("data not block size aligned");
}
if (outOff + bufOff > output.Length)
{
throw new DataLengthException("output buffer too short for DoFinal()");
}
// NB: Can't copy directly, or we may write too much output
cipher.ProcessBlock(buf, 0, buf, 0);
Array.Copy(buf, 0, output, outOff, bufOff);
}
return bufOff;
}
finally
{
Reset();
}
}
/**
* Reset the buffer and cipher. After resetting the object is in the same
* state as it was after the last init (if there was one).
*/
public override void Reset()
{
Array.Clear(buf, 0, buf.Length);
bufOff = 0;
cipher.Reset();
}
}
}

View File

@@ -0,0 +1,113 @@
using System;
namespace Org.BouncyCastle.Crypto
{
public abstract class BufferedCipherBase
: IBufferedCipher
{
protected static readonly byte[] EmptyBuffer = new byte[0];
public abstract string AlgorithmName { get; }
public abstract void Init(bool forEncryption, ICipherParameters parameters);
public abstract int GetBlockSize();
public abstract int GetOutputSize(int inputLen);
public abstract int GetUpdateOutputSize(int inputLen);
public abstract byte[] ProcessByte(byte input);
public virtual int ProcessByte(
byte input,
byte[] output,
int outOff)
{
byte[] outBytes = ProcessByte(input);
if (outBytes == null)
return 0;
if (outOff + outBytes.Length > output.Length)
throw new DataLengthException("output buffer too short");
outBytes.CopyTo(output, outOff);
return outBytes.Length;
}
public virtual byte[] ProcessBytes(
byte[] input)
{
return ProcessBytes(input, 0, input.Length);
}
public abstract byte[] ProcessBytes(byte[] input, int inOff, int length);
public virtual int ProcessBytes(
byte[] input,
byte[] output,
int outOff)
{
return ProcessBytes(input, 0, input.Length, output, outOff);
}
public virtual int ProcessBytes(
byte[] input,
int inOff,
int length,
byte[] output,
int outOff)
{
byte[] outBytes = ProcessBytes(input, inOff, length);
if (outBytes == null)
return 0;
if (outOff + outBytes.Length > output.Length)
throw new DataLengthException("output buffer too short");
outBytes.CopyTo(output, outOff);
return outBytes.Length;
}
public abstract byte[] DoFinal();
public virtual byte[] DoFinal(
byte[] input)
{
return DoFinal(input, 0, input.Length);
}
public abstract byte[] DoFinal(
byte[] input,
int inOff,
int length);
public virtual int DoFinal(
byte[] output,
int outOff)
{
byte[] outBytes = DoFinal();
if (outOff + outBytes.Length > output.Length)
throw new DataLengthException("output buffer too short");
outBytes.CopyTo(output, outOff);
return outBytes.Length;
}
public virtual int DoFinal(
byte[] input,
byte[] output,
int outOff)
{
return DoFinal(input, 0, input.Length, output, outOff);
}
public virtual int DoFinal(
byte[] input,
int inOff,
int length,
byte[] output,
int outOff)
{
int len = ProcessBytes(input, inOff, length, output, outOff);
len += DoFinal(output, outOff + len);
return len;
}
public abstract void Reset();
}
}

View File

@@ -0,0 +1,25 @@
using System;
namespace Org.BouncyCastle.Crypto
{
public class CryptoException
: Exception
{
public CryptoException()
{
}
public CryptoException(
string message)
: base(message)
{
}
public CryptoException(
string message,
Exception exception)
: base(message, exception)
{
}
}
}

View File

@@ -0,0 +1,33 @@
using System;
namespace Org.BouncyCastle.Crypto
{
public class DataLengthException
: CryptoException
{
/**
* base constructor.
*/
public DataLengthException()
{
}
/**
* create a DataLengthException with the given message.
*
* @param message the message to be carried with the exception.
*/
public DataLengthException(
string message)
: base(message)
{
}
public DataLengthException(
string message,
Exception exception)
: base(message, exception)
{
}
}
}

View File

@@ -0,0 +1,115 @@
using System;
namespace Org.BouncyCastle.Crypto.Digests
{
public abstract class GeneralDigest
: IDigest
{
private const int BYTE_LENGTH = 64;
private byte[] xBuf;
private int xBufOff;
private long byteCount;
internal GeneralDigest()
{
xBuf = new byte[4];
}
internal GeneralDigest(GeneralDigest t)
{
xBuf = new byte[t.xBuf.Length];
Array.Copy(t.xBuf, 0, xBuf, 0, t.xBuf.Length);
xBufOff = t.xBufOff;
byteCount = t.byteCount;
}
public void Update(byte input)
{
xBuf[xBufOff++] = input;
if (xBufOff == xBuf.Length)
{
ProcessWord(xBuf, 0);
xBufOff = 0;
}
byteCount++;
}
public void BlockUpdate(
byte[] input,
int inOff,
int length)
{
//
// fill the current word
//
while ((xBufOff != 0) && (length > 0))
{
Update(input[inOff]);
inOff++;
length--;
}
//
// process whole words.
//
while (length > xBuf.Length)
{
ProcessWord(input, inOff);
inOff += xBuf.Length;
length -= xBuf.Length;
byteCount += xBuf.Length;
}
//
// load in the remainder.
//
while (length > 0)
{
Update(input[inOff]);
inOff++;
length--;
}
}
public void Finish()
{
long bitLength = (byteCount << 3);
//
// add the pad bytes.
//
Update((byte)128);
while (xBufOff != 0)
Update((byte)0);
ProcessLength(bitLength);
ProcessBlock();
}
public virtual void Reset()
{
byteCount = 0;
xBufOff = 0;
Array.Clear(xBuf, 0, xBuf.Length);
}
public int GetByteLength()
{
return BYTE_LENGTH;
}
internal abstract void ProcessWord(byte[] input, int inOff);
internal abstract void ProcessLength(long bitLength);
internal abstract void ProcessBlock();
public abstract string AlgorithmName { get; }
public abstract int GetDigestSize();
public abstract int DoFinal(byte[] output, int outOff);
}
}

View File

@@ -0,0 +1,134 @@
using System;
using System.Collections;
using Org.BouncyCastle.Crypto;
using Org.BouncyCastle.Crypto.Parameters;
namespace Org.BouncyCastle.Crypto.Macs
{
/**
* HMAC implementation based on RFC2104
*
* H(K XOR opad, H(K XOR ipad, text))
*/
public class HMac
: IMac
{
private const byte IPAD = (byte)0x36;
private const byte OPAD = (byte)0x5C;
private readonly IDigest digest;
private readonly int digestSize;
private readonly int blockLength;
private readonly byte[] inputPad;
private readonly byte[] outputPad;
public HMac(
IDigest digest)
{
this.digest = digest;
this.digestSize = digest.GetDigestSize();
this.blockLength = digest.GetByteLength();
this.inputPad = new byte[blockLength];
this.outputPad = new byte[blockLength];
}
public string AlgorithmName
{
get { return digest.AlgorithmName + "/HMAC"; }
}
public IDigest GetUnderlyingDigest()
{
return digest;
}
public void Init(
ICipherParameters parameters)
{
digest.Reset();
byte[] key = ((KeyParameter)parameters).GetKey();
int keyLength = key.Length;
if (keyLength > blockLength)
{
digest.BlockUpdate(key, 0, key.Length);
digest.DoFinal(inputPad, 0);
keyLength = digestSize;
}
else
{
Array.Copy(key, 0, inputPad, 0, keyLength);
}
Array.Clear(inputPad, keyLength, blockLength - keyLength);
Array.Copy(inputPad, 0, outputPad, 0, blockLength);
xor(inputPad, IPAD);
xor(outputPad, OPAD);
// Initialise the digest
digest.BlockUpdate(inputPad, 0, inputPad.Length);
}
public int GetMacSize()
{
return digestSize;
}
public void Update(
byte input)
{
digest.Update(input);
}
public void BlockUpdate(
byte[] input,
int inOff,
int len)
{
digest.BlockUpdate(input, inOff, len);
}
public int DoFinal(
byte[] output,
int outOff)
{
byte[] tmp = new byte[digestSize];
digest.DoFinal(tmp, 0);
digest.BlockUpdate(outputPad, 0, outputPad.Length);
digest.BlockUpdate(tmp, 0, tmp.Length);
int len = digest.DoFinal(output, outOff);
// Initialise the digest
digest.BlockUpdate(inputPad, 0, inputPad.Length);
return len;
}
/**
* Reset the mac generator.
*/
public void Reset()
{
// Reset underlying digest
digest.Reset();
// Initialise the digest
digest.BlockUpdate(inputPad, 0, inputPad.Length);
}
private static void xor(byte[] a, byte n)
{
for (int i = 0; i < a.Length; ++i)
{
a[i] ^= n;
}
}
}
}

View File

@@ -0,0 +1,35 @@
namespace Org.BouncyCastle.Crypto
{
/// <remarks>Base interface for a symmetric key block cipher.</remarks>
public interface IBlockCipher
{
/// <summary>The name of the algorithm this cipher implements.</summary>
string AlgorithmName { get; }
/// <summary>Initialise the cipher.</summary>
/// <param name="forEncryption">Initialise for encryption if true, for decryption if false.</param>
/// <param name="parameters">The key or other data required by the cipher.</param>
void Init(bool forEncryption, ICipherParameters parameters);
/// <returns>The block size for this cipher, in bytes.</returns>
int GetBlockSize();
/// <summary>Indicates whether this cipher can handle partial blocks.</summary>
bool IsPartialBlockOkay { get; }
/// <summary>Process a block.</summary>
/// <param name="inBuf">The input buffer.</param>
/// <param name="inOff">The offset into <paramref>inBuf</paramref> that the input block begins.</param>
/// <param name="outBuf">The output buffer.</param>
/// <param name="outOff">The offset into <paramref>outBuf</paramref> to write the output block.</param>
/// <exception cref="DataLengthException">If input block is wrong size, or outBuf too small.</exception>
/// <returns>The number of bytes processed and produced.</returns>
int ProcessBlock(byte[] inBuf, int inOff, byte[] outBuf, int outOff);
/// <summary>
/// Reset the cipher to the same state as it was after the last init (if there was one).
/// </summary>
void Reset();
}
}

View File

@@ -0,0 +1,44 @@
using System;
namespace Org.BouncyCastle.Crypto
{
/// <remarks>Block cipher engines are expected to conform to this interface.</remarks>
public interface IBufferedCipher
{
/// <summary>The name of the algorithm this cipher implements.</summary>
string AlgorithmName { get; }
/// <summary>Initialise the cipher.</summary>
/// <param name="forEncryption">If true the cipher is initialised for encryption,
/// if false for decryption.</param>
/// <param name="parameters">The key and other data required by the cipher.</param>
void Init(bool forEncryption, ICipherParameters parameters);
int GetBlockSize();
int GetOutputSize(int inputLen);
int GetUpdateOutputSize(int inputLen);
byte[] ProcessByte(byte input);
int ProcessByte(byte input, byte[] output, int outOff);
byte[] ProcessBytes(byte[] input);
byte[] ProcessBytes(byte[] input, int inOff, int length);
int ProcessBytes(byte[] input, byte[] output, int outOff);
int ProcessBytes(byte[] input, int inOff, int length, byte[] output, int outOff);
byte[] DoFinal();
byte[] DoFinal(byte[] input);
byte[] DoFinal(byte[] input, int inOff, int length);
int DoFinal(byte[] output, int outOff);
int DoFinal(byte[] input, byte[] output, int outOff);
int DoFinal(byte[] input, int inOff, int length, byte[] output, int outOff);
/// <summary>
/// Reset the cipher. After resetting the cipher is in the same state
/// as it was after the last init (if there was one).
/// </summary>
void Reset();
}
}

View File

@@ -0,0 +1,7 @@
namespace Org.BouncyCastle.Crypto
{
public interface ICipherParameters
{
}
}

View File

@@ -0,0 +1,56 @@
namespace Org.BouncyCastle.Crypto
{
public interface IDigest
{
/**
* return the algorithm name
*
* @return the algorithm name
*/
string AlgorithmName { get; }
/**
* return the size, in bytes, of the digest produced by this message digest.
*
* @return the size, in bytes, of the digest produced by this message digest.
*/
int GetDigestSize();
/**
* return the size, in bytes, of the internal buffer used by this digest.
*
* @return the size, in bytes, of the internal buffer used by this digest.
*/
int GetByteLength();
/**
* update the message digest with a single byte.
*
* @param inByte the input byte to be entered.
*/
void Update(byte input);
/**
* update the message digest with a block of bytes.
*
* @param input the byte array containing the data.
* @param inOff the offset into the byte array where the data starts.
* @param len the length of the data.
*/
void BlockUpdate(byte[] input, int inOff, int length);
/**
* Close the digest, producing the final digest value. The doFinal
* call leaves the digest reset.
*
* @param output the array the digest is to be copied into.
* @param outOff the offset into the out array the digest is to start at.
*/
int DoFinal(byte[] output, int outOff);
/**
* reset the digest back to it's initial state.
*/
void Reset();
}
}

View File

@@ -0,0 +1,64 @@
namespace Org.BouncyCastle.Crypto
{
public interface IMac
{
/**
* Initialise the MAC.
*
* @param param the key and other data required by the MAC.
* @exception ArgumentException if the parameters argument is
* inappropriate.
*/
void Init(ICipherParameters parameters);
/**
* Return the name of the algorithm the MAC implements.
*
* @return the name of the algorithm the MAC implements.
*/
string AlgorithmName { get; }
/**
* Return the block size for this MAC (in bytes).
*
* @return the block size for this MAC in bytes.
*/
int GetMacSize();
/**
* add a single byte to the mac for processing.
*
* @param in the byte to be processed.
* @exception InvalidOperationException if the MAC is not initialised.
*/
void Update(byte input);
/**
* @param in the array containing the input.
* @param inOff the index in the array the data begins at.
* @param len the length of the input starting at inOff.
* @exception InvalidOperationException if the MAC is not initialised.
* @exception DataLengthException if there isn't enough data in in.
*/
void BlockUpdate(byte[] input, int inOff, int len);
/**
* Compute the final stage of the MAC writing the output to the out
* parameter.
* <p>
* doFinal leaves the MAC in the same state it was after the last init.
* </p>
* @param out the array the MAC is to be output to.
* @param outOff the offset into the out buffer the output is to start at.
* @exception DataLengthException if there isn't enough space in out.
* @exception InvalidOperationException if the MAC is not initialised.
*/
int DoFinal(byte[] output, int outOff);
/**
* Reset the MAC. At the end of resetting the MAC should be in the
* in the same state it was after the last init (if there was one).
*/
void Reset();
}
}

View File

@@ -0,0 +1,40 @@
using System;
namespace Org.BouncyCastle.Crypto.Parameters
{
public class KeyParameter
: ICipherParameters
{
private readonly byte[] key;
public KeyParameter(
byte[] key)
{
if (key == null)
throw new ArgumentNullException("key");
this.key = (byte[])key.Clone();
}
public KeyParameter(
byte[] key,
int keyOff,
int keyLen)
{
if (key == null)
throw new ArgumentNullException("key");
if (keyOff < 0 || keyOff > key.Length)
throw new ArgumentOutOfRangeException("keyOff");
if (keyLen < 0 || (keyOff + keyLen) > key.Length)
throw new ArgumentOutOfRangeException("keyLen");
this.key = new byte[keyLen];
Array.Copy(key, keyOff, this.key, 0, keyLen);
}
public byte[] GetKey()
{
return (byte[])key.Clone();
}
}
}

View File

@@ -0,0 +1,119 @@
using System;
using Org.BouncyCastle.Crypto;
using Org.BouncyCastle.Crypto.Digests;
using Org.BouncyCastle.Crypto.Macs;
using Org.BouncyCastle.Crypto.Parameters;
namespace SharpCompress.Crypto
{
//Gathered from:
//http://stackoverflow.com/questions/3210795/pbkdf2-in-bouncy-castle-c-sharp and Rfc2898DeriveBytes
internal class PBKDF2
{
private readonly IMac hMac = new HMac(new Sha1Digest());
private readonly byte[] state = new byte[20];
private int endIndex;
private int startIndex;
private uint block = 1u;
private readonly byte[] password;
private readonly byte[] salt;
private readonly int iterations;
public PBKDF2(byte[] password, byte[] salt, int iterations)
{
this.password = password;
this.salt = salt;
this.iterations = iterations;
}
public byte[] GetBytes(int cb)
{
if (cb <= 0)
{
throw new ArgumentOutOfRangeException("cb");
}
byte[] array = new byte[cb];
int i = 0;
int num = endIndex - startIndex;
if (num > 0)
{
if (cb < num)
{
Buffer.BlockCopy(state, startIndex, array, 0, cb);
startIndex += cb;
return array;
}
Buffer.BlockCopy(state, startIndex, array, 0, num);
startIndex = (endIndex = 0);
i += num;
}
while (i < cb)
{
byte[] src = Hash();
int num2 = cb - i;
if (num2 <= 20)
{
Buffer.BlockCopy(src, 0, array, i, num2);
i += num2;
Buffer.BlockCopy(src, num2, state, startIndex, 20 - num2);
endIndex += 20 - num2;
return array;
}
Buffer.BlockCopy(src, 0, array, i, 20);
i += 20;
}
return array;
}
private byte[] Hash()
{
byte[] array = UIntToOctet(block);
ICipherParameters param = new KeyParameter(password);
hMac.Init(param);
hMac.BlockUpdate(salt, 0, salt.Length);
hMac.BlockUpdate(array, 0, array.Length);
byte[] array2 = new byte[20];
hMac.DoFinal(array2, 0);
hMac.Init(param);
byte[] array3 = new byte[20];
Buffer.BlockCopy(array2, 0, array3, 0, 20);
int num = 2;
while (num <= (long)((ulong)iterations))
{
hMac.BlockUpdate(array2, 0, array2.Length);
hMac.DoFinal(array2, 0);
for (int i = 0; i < 20; i++)
{
array3[i] ^= array2[i];
}
num++;
}
block += 1u;
return array3;
}
internal static byte[] UIntToOctet(uint i)
{
byte[] bytes = BitConverter.GetBytes(i);
byte[] result = new[]
{
bytes[3],
bytes[2],
bytes[1],
bytes[0]
};
if (!BitConverter.IsLittleEndian)
{
return bytes;
}
return result;
}
}
}

View File

@@ -0,0 +1,129 @@
namespace Org.BouncyCastle.Crypto.Utilities
{
internal sealed class Pack
{
private Pack()
{
}
internal static void UInt32_To_BE(uint n, byte[] bs)
{
bs[0] = (byte)(n >> 24);
bs[1] = (byte)(n >> 16);
bs[2] = (byte)(n >> 8);
bs[3] = (byte)(n);
}
internal static void UInt32_To_BE(uint n, byte[] bs, int off)
{
bs[off] = (byte)(n >> 24);
bs[++off] = (byte)(n >> 16);
bs[++off] = (byte)(n >> 8);
bs[++off] = (byte)(n);
}
internal static uint BE_To_UInt32(byte[] bs)
{
uint n = (uint)bs[0] << 24;
n |= (uint)bs[1] << 16;
n |= (uint)bs[2] << 8;
n |= (uint)bs[3];
return n;
}
internal static uint BE_To_UInt32(byte[] bs, int off)
{
uint n = (uint)bs[off] << 24;
n |= (uint)bs[++off] << 16;
n |= (uint)bs[++off] << 8;
n |= (uint)bs[++off];
return n;
}
internal static ulong BE_To_UInt64(byte[] bs)
{
uint hi = BE_To_UInt32(bs);
uint lo = BE_To_UInt32(bs, 4);
return ((ulong)hi << 32) | (ulong)lo;
}
internal static ulong BE_To_UInt64(byte[] bs, int off)
{
uint hi = BE_To_UInt32(bs, off);
uint lo = BE_To_UInt32(bs, off + 4);
return ((ulong)hi << 32) | (ulong)lo;
}
internal static void UInt64_To_BE(ulong n, byte[] bs)
{
UInt32_To_BE((uint)(n >> 32), bs);
UInt32_To_BE((uint)(n), bs, 4);
}
internal static void UInt64_To_BE(ulong n, byte[] bs, int off)
{
UInt32_To_BE((uint)(n >> 32), bs, off);
UInt32_To_BE((uint)(n), bs, off + 4);
}
internal static void UInt32_To_LE(uint n, byte[] bs)
{
bs[0] = (byte)(n);
bs[1] = (byte)(n >> 8);
bs[2] = (byte)(n >> 16);
bs[3] = (byte)(n >> 24);
}
internal static void UInt32_To_LE(uint n, byte[] bs, int off)
{
bs[off] = (byte)(n);
bs[++off] = (byte)(n >> 8);
bs[++off] = (byte)(n >> 16);
bs[++off] = (byte)(n >> 24);
}
internal static uint LE_To_UInt32(byte[] bs)
{
uint n = (uint)bs[0];
n |= (uint)bs[1] << 8;
n |= (uint)bs[2] << 16;
n |= (uint)bs[3] << 24;
return n;
}
internal static uint LE_To_UInt32(byte[] bs, int off)
{
uint n = (uint)bs[off];
n |= (uint)bs[++off] << 8;
n |= (uint)bs[++off] << 16;
n |= (uint)bs[++off] << 24;
return n;
}
internal static ulong LE_To_UInt64(byte[] bs)
{
uint lo = LE_To_UInt32(bs);
uint hi = LE_To_UInt32(bs, 4);
return ((ulong)hi << 32) | (ulong)lo;
}
internal static ulong LE_To_UInt64(byte[] bs, int off)
{
uint lo = LE_To_UInt32(bs, off);
uint hi = LE_To_UInt32(bs, off + 4);
return ((ulong)hi << 32) | (ulong)lo;
}
internal static void UInt64_To_LE(ulong n, byte[] bs)
{
UInt32_To_LE((uint)(n), bs);
UInt32_To_LE((uint)(n >> 32), bs, 4);
}
internal static void UInt64_To_LE(ulong n, byte[] bs, int off)
{
UInt32_To_LE((uint)(n), bs, off);
UInt32_To_LE((uint)(n >> 32), bs, off + 4);
}
}
}

View File

@@ -0,0 +1,740 @@
using System;
using Org.BouncyCastle.Crypto.Parameters;
namespace Org.BouncyCastle.Crypto.Engines
{
public class RijndaelEngine
: IBlockCipher
{
private static readonly int MAXROUNDS = 14;
private static readonly int MAXKC = (256 / 4);
private static readonly byte[] Logtable =
{
0, 0, 25, 1, 50, 2, 26, 198,
75, 199, 27, 104, 51, 238, 223, 3,
100, 4, 224, 14, 52, 141, 129, 239,
76, 113, 8, 200, 248, 105, 28, 193,
125, 194, 29, 181, 249, 185, 39, 106,
77, 228, 166, 114, 154, 201, 9, 120,
101, 47, 138, 5, 33, 15, 225, 36,
18, 240, 130, 69, 53, 147, 218, 142,
150, 143, 219, 189, 54, 208, 206, 148,
19, 92, 210, 241, 64, 70, 131, 56,
102, 221, 253, 48, 191, 6, 139, 98,
179, 37, 226, 152, 34, 136, 145, 16,
126, 110, 72, 195, 163, 182, 30, 66,
58, 107, 40, 84, 250, 133, 61, 186,
43, 121, 10, 21, 155, 159, 94, 202,
78, 212, 172, 229, 243, 115, 167, 87,
175, 88, 168, 80, 244, 234, 214, 116,
79, 174, 233, 213, 231, 230, 173, 232,
44, 215, 117, 122, 235, 22, 11, 245,
89, 203, 95, 176, 156, 169, 81, 160,
127, 12, 246, 111, 23, 196, 73, 236,
216, 67, 31, 45, 164, 118, 123, 183,
204, 187, 62, 90, 251, 96, 177, 134,
59, 82, 161, 108, 170, 85, 41, 157,
151, 178, 135, 144, 97, 190, 220, 252,
188, 149, 207, 205, 55, 63, 91, 209,
83, 57, 132, 60, 65, 162, 109, 71,
20, 42, 158, 93, 86, 242, 211, 171,
68, 17, 146, 217, 35, 32, 46, 137,
180, 124, 184, 38, 119, 153, 227, 165,
103, 74, 237, 222, 197, 49, 254, 24,
13, 99, 140, 128, 192, 247, 112, 7
};
private static readonly byte[] Alogtable =
{
0, 3, 5, 15, 17, 51, 85, 255, 26, 46, 114, 150, 161, 248, 19, 53,
95, 225, 56, 72, 216, 115, 149, 164, 247, 2, 6, 10, 30, 34, 102, 170,
229, 52, 92, 228, 55, 89, 235, 38, 106, 190, 217, 112, 144, 171, 230, 49,
83, 245, 4, 12, 20, 60, 68, 204, 79, 209, 104, 184, 211, 110, 178, 205,
76, 212, 103, 169, 224, 59, 77, 215, 98, 166, 241, 8, 24, 40, 120, 136,
131, 158, 185, 208, 107, 189, 220, 127, 129, 152, 179, 206, 73, 219, 118, 154,
181, 196, 87, 249, 16, 48, 80, 240, 11, 29, 39, 105, 187, 214, 97, 163,
254, 25, 43, 125, 135, 146, 173, 236, 47, 113, 147, 174, 233, 32, 96, 160,
251, 22, 58, 78, 210, 109, 183, 194, 93, 231, 50, 86, 250, 21, 63, 65,
195, 94, 226, 61, 71, 201, 64, 192, 91, 237, 44, 116, 156, 191, 218, 117,
159, 186, 213, 100, 172, 239, 42, 126, 130, 157, 188, 223, 122, 142, 137, 128,
155, 182, 193, 88, 232, 35, 101, 175, 234, 37, 111, 177, 200, 67, 197, 84,
252, 31, 33, 99, 165, 244, 7, 9, 27, 45, 119, 153, 176, 203, 70, 202,
69, 207, 74, 222, 121, 139, 134, 145, 168, 227, 62, 66, 198, 81, 243, 14,
18, 54, 90, 238, 41, 123, 141, 140, 143, 138, 133, 148, 167, 242, 13, 23,
57, 75, 221, 124, 132, 151, 162, 253, 28, 36, 108, 180, 199, 82, 246, 1,
3, 5, 15, 17, 51, 85, 255, 26, 46, 114, 150, 161, 248, 19, 53,
95, 225, 56, 72, 216, 115, 149, 164, 247, 2, 6, 10, 30, 34, 102, 170,
229, 52, 92, 228, 55, 89, 235, 38, 106, 190, 217, 112, 144, 171, 230, 49,
83, 245, 4, 12, 20, 60, 68, 204, 79, 209, 104, 184, 211, 110, 178, 205,
76, 212, 103, 169, 224, 59, 77, 215, 98, 166, 241, 8, 24, 40, 120, 136,
131, 158, 185, 208, 107, 189, 220, 127, 129, 152, 179, 206, 73, 219, 118, 154,
181, 196, 87, 249, 16, 48, 80, 240, 11, 29, 39, 105, 187, 214, 97, 163,
254, 25, 43, 125, 135, 146, 173, 236, 47, 113, 147, 174, 233, 32, 96, 160,
251, 22, 58, 78, 210, 109, 183, 194, 93, 231, 50, 86, 250, 21, 63, 65,
195, 94, 226, 61, 71, 201, 64, 192, 91, 237, 44, 116, 156, 191, 218, 117,
159, 186, 213, 100, 172, 239, 42, 126, 130, 157, 188, 223, 122, 142, 137, 128,
155, 182, 193, 88, 232, 35, 101, 175, 234, 37, 111, 177, 200, 67, 197, 84,
252, 31, 33, 99, 165, 244, 7, 9, 27, 45, 119, 153, 176, 203, 70, 202,
69, 207, 74, 222, 121, 139, 134, 145, 168, 227, 62, 66, 198, 81, 243, 14,
18, 54, 90, 238, 41, 123, 141, 140, 143, 138, 133, 148, 167, 242, 13, 23,
57, 75, 221, 124, 132, 151, 162, 253, 28, 36, 108, 180, 199, 82, 246, 1,
};
private static readonly byte[] S =
{
99, 124, 119, 123, 242, 107, 111, 197, 48, 1, 103, 43, 254, 215, 171, 118,
202, 130, 201, 125, 250, 89, 71, 240, 173, 212, 162, 175, 156, 164, 114, 192,
183, 253, 147, 38, 54, 63, 247, 204, 52, 165, 229, 241, 113, 216, 49, 21,
4, 199, 35, 195, 24, 150, 5, 154, 7, 18, 128, 226, 235, 39, 178, 117,
9, 131, 44, 26, 27, 110, 90, 160, 82, 59, 214, 179, 41, 227, 47, 132,
83, 209, 0, 237, 32, 252, 177, 91, 106, 203, 190, 57, 74, 76, 88, 207,
208, 239, 170, 251, 67, 77, 51, 133, 69, 249, 2, 127, 80, 60, 159, 168,
81, 163, 64, 143, 146, 157, 56, 245, 188, 182, 218, 33, 16, 255, 243, 210,
205, 12, 19, 236, 95, 151, 68, 23, 196, 167, 126, 61, 100, 93, 25, 115,
96, 129, 79, 220, 34, 42, 144, 136, 70, 238, 184, 20, 222, 94, 11, 219,
224, 50, 58, 10, 73, 6, 36, 92, 194, 211, 172, 98, 145, 149, 228, 121,
231, 200, 55, 109, 141, 213, 78, 169, 108, 86, 244, 234, 101, 122, 174, 8,
186, 120, 37, 46, 28, 166, 180, 198, 232, 221, 116, 31, 75, 189, 139, 138,
112, 62, 181, 102, 72, 3, 246, 14, 97, 53, 87, 185, 134, 193, 29, 158,
225, 248, 152, 17, 105, 217, 142, 148, 155, 30, 135, 233, 206, 85, 40, 223,
140, 161, 137, 13, 191, 230, 66, 104, 65, 153, 45, 15, 176, 84, 187, 22,
};
private static readonly byte[] Si =
{
82, 9, 106, 213, 48, 54, 165, 56, 191, 64, 163, 158, 129, 243, 215, 251,
124, 227, 57, 130, 155, 47, 255, 135, 52, 142, 67, 68, 196, 222, 233, 203,
84, 123, 148, 50, 166, 194, 35, 61, 238, 76, 149, 11, 66, 250, 195, 78,
8, 46, 161, 102, 40, 217, 36, 178, 118, 91, 162, 73, 109, 139, 209, 37,
114, 248, 246, 100, 134, 104, 152, 22, 212, 164, 92, 204, 93, 101, 182, 146,
108, 112, 72, 80, 253, 237, 185, 218, 94, 21, 70, 87, 167, 141, 157, 132,
144, 216, 171, 0, 140, 188, 211, 10, 247, 228, 88, 5, 184, 179, 69, 6,
208, 44, 30, 143, 202, 63, 15, 2, 193, 175, 189, 3, 1, 19, 138, 107,
58, 145, 17, 65, 79, 103, 220, 234, 151, 242, 207, 206, 240, 180, 230, 115,
150, 172, 116, 34, 231, 173, 53, 133, 226, 249, 55, 232, 28, 117, 223, 110,
71, 241, 26, 113, 29, 41, 197, 137, 111, 183, 98, 14, 170, 24, 190, 27,
252, 86, 62, 75, 198, 210, 121, 32, 154, 219, 192, 254, 120, 205, 90, 244,
31, 221, 168, 51, 136, 7, 199, 49, 177, 18, 16, 89, 39, 128, 236, 95,
96, 81, 127, 169, 25, 181, 74, 13, 45, 229, 122, 159, 147, 201, 156, 239,
160, 224, 59, 77, 174, 42, 245, 176, 200, 235, 187, 60, 131, 83, 153, 97,
23, 43, 4, 126, 186, 119, 214, 38, 225, 105, 20, 99, 85, 33, 12, 125,
};
private static readonly byte[] rcon =
{
0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a,
0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91
};
static readonly byte[][] shifts0 = new byte[][]
{
new byte[]{ 0, 8, 16, 24 },
new byte[]{ 0, 8, 16, 24 },
new byte[]{ 0, 8, 16, 24 },
new byte[]{ 0, 8, 16, 32 },
new byte[]{ 0, 8, 24, 32 }
};
static readonly byte[][] shifts1 =
{
new byte[]{ 0, 24, 16, 8 },
new byte[]{ 0, 32, 24, 16 },
new byte[]{ 0, 40, 32, 24 },
new byte[]{ 0, 48, 40, 24 },
new byte[]{ 0, 56, 40, 32 }
};
/**
* multiply two elements of GF(2^m)
* needed for MixColumn and InvMixColumn
*/
private byte Mul0x2(
int b)
{
if (b != 0)
{
return Alogtable[25 + (Logtable[b] & 0xff)];
}
else
{
return 0;
}
}
private byte Mul0x3(
int b)
{
if (b != 0)
{
return Alogtable[1 + (Logtable[b] & 0xff)];
}
else
{
return 0;
}
}
private byte Mul0x9(
int b)
{
if (b >= 0)
{
return Alogtable[199 + b];
}
else
{
return 0;
}
}
private byte Mul0xb(
int b)
{
if (b >= 0)
{
return Alogtable[104 + b];
}
else
{
return 0;
}
}
private byte Mul0xd(
int b)
{
if (b >= 0)
{
return Alogtable[238 + b];
}
else
{
return 0;
}
}
private byte Mul0xe(
int b)
{
if (b >= 0)
{
return Alogtable[223 + b];
}
else
{
return 0;
}
}
/**
* xor corresponding text input and round key input bytes
*/
private void KeyAddition(
long[] rk)
{
A0 ^= rk[0];
A1 ^= rk[1];
A2 ^= rk[2];
A3 ^= rk[3];
}
private long Shift(
long r,
int shift)
{
//return (((long)((ulong) r >> shift) | (r << (BC - shift)))) & BC_MASK;
ulong temp = (ulong)r >> shift;
// NB: This corrects for Mono Bug #79087 (fixed in 1.1.17)
if (shift > 31)
{
temp &= 0xFFFFFFFFUL;
}
return ((long)temp | (r << (BC - shift))) & BC_MASK;
}
/**
* Row 0 remains unchanged
* The other three rows are shifted a variable amount
*/
private void ShiftRow(
byte[] shiftsSC)
{
A1 = Shift(A1, shiftsSC[1]);
A2 = Shift(A2, shiftsSC[2]);
A3 = Shift(A3, shiftsSC[3]);
}
private long ApplyS(
long r,
byte[] box)
{
long res = 0;
for (int j = 0; j < BC; j += 8)
{
res |= (long)(box[(int)((r >> j) & 0xff)] & 0xff) << j;
}
return res;
}
/**
* Replace every byte of the input by the byte at that place
* in the nonlinear S-box
*/
private void Substitution(
byte[] box)
{
A0 = ApplyS(A0, box);
A1 = ApplyS(A1, box);
A2 = ApplyS(A2, box);
A3 = ApplyS(A3, box);
}
/**
* Mix the bytes of every column in a linear way
*/
private void MixColumn()
{
long r0, r1, r2, r3;
r0 = r1 = r2 = r3 = 0;
for (int j = 0; j < BC; j += 8)
{
int a0 = (int)((A0 >> j) & 0xff);
int a1 = (int)((A1 >> j) & 0xff);
int a2 = (int)((A2 >> j) & 0xff);
int a3 = (int)((A3 >> j) & 0xff);
r0 |= (long)((Mul0x2(a0) ^ Mul0x3(a1) ^ a2 ^ a3) & 0xff) << j;
r1 |= (long)((Mul0x2(a1) ^ Mul0x3(a2) ^ a3 ^ a0) & 0xff) << j;
r2 |= (long)((Mul0x2(a2) ^ Mul0x3(a3) ^ a0 ^ a1) & 0xff) << j;
r3 |= (long)((Mul0x2(a3) ^ Mul0x3(a0) ^ a1 ^ a2) & 0xff) << j;
}
A0 = r0;
A1 = r1;
A2 = r2;
A3 = r3;
}
/**
* Mix the bytes of every column in a linear way
* This is the opposite operation of Mixcolumn
*/
private void InvMixColumn()
{
long r0, r1, r2, r3;
r0 = r1 = r2 = r3 = 0;
for (int j = 0; j < BC; j += 8)
{
int a0 = (int)((A0 >> j) & 0xff);
int a1 = (int)((A1 >> j) & 0xff);
int a2 = (int)((A2 >> j) & 0xff);
int a3 = (int)((A3 >> j) & 0xff);
//
// pre-lookup the log table
//
a0 = (a0 != 0) ? (Logtable[a0 & 0xff] & 0xff) : -1;
a1 = (a1 != 0) ? (Logtable[a1 & 0xff] & 0xff) : -1;
a2 = (a2 != 0) ? (Logtable[a2 & 0xff] & 0xff) : -1;
a3 = (a3 != 0) ? (Logtable[a3 & 0xff] & 0xff) : -1;
r0 |= (long)((Mul0xe(a0) ^ Mul0xb(a1) ^ Mul0xd(a2) ^ Mul0x9(a3)) & 0xff) << j;
r1 |= (long)((Mul0xe(a1) ^ Mul0xb(a2) ^ Mul0xd(a3) ^ Mul0x9(a0)) & 0xff) << j;
r2 |= (long)((Mul0xe(a2) ^ Mul0xb(a3) ^ Mul0xd(a0) ^ Mul0x9(a1)) & 0xff) << j;
r3 |= (long)((Mul0xe(a3) ^ Mul0xb(a0) ^ Mul0xd(a1) ^ Mul0x9(a2)) & 0xff) << j;
}
A0 = r0;
A1 = r1;
A2 = r2;
A3 = r3;
}
/**
* Calculate the necessary round keys
* The number of calculations depends on keyBits and blockBits
*/
private long[][] GenerateWorkingKey(
byte[] key)
{
int KC;
int t, rconpointer = 0;
int keyBits = key.Length * 8;
byte[,] tk = new byte[4, MAXKC];
//long[,] W = new long[MAXROUNDS+1,4];
long[][] W = new long[MAXROUNDS + 1][];
for (int i = 0; i < MAXROUNDS + 1; i++)
W[i] = new long[4];
switch (keyBits)
{
case 128:
KC = 4;
break;
case 160:
KC = 5;
break;
case 192:
KC = 6;
break;
case 224:
KC = 7;
break;
case 256:
KC = 8;
break;
default:
throw new ArgumentException("Key length not 128/160/192/224/256 bits.");
}
if (keyBits >= blockBits)
{
ROUNDS = KC + 6;
}
else
{
ROUNDS = (BC / 8) + 6;
}
//
// copy the key into the processing area
//
int index = 0;
for (int i = 0; i < key.Length; i++)
{
tk[i % 4, i / 4] = key[index++];
}
t = 0;
//
// copy values into round key array
//
for (int j = 0; (j < KC) && (t < (ROUNDS + 1) * (BC / 8)); j++, t++)
{
for (int i = 0; i < 4; i++)
{
W[t / (BC / 8)][i] |= (long)(tk[i, j] & 0xff) << ((t * 8) % BC);
}
}
//
// while not enough round key material calculated
// calculate new values
//
while (t < (ROUNDS + 1) * (BC / 8))
{
for (int i = 0; i < 4; i++)
{
tk[i, 0] ^= S[tk[(i + 1) % 4, KC - 1] & 0xff];
}
tk[0, 0] ^= (byte)rcon[rconpointer++];
if (KC <= 6)
{
for (int j = 1; j < KC; j++)
{
for (int i = 0; i < 4; i++)
{
tk[i, j] ^= tk[i, j - 1];
}
}
}
else
{
for (int j = 1; j < 4; j++)
{
for (int i = 0; i < 4; i++)
{
tk[i, j] ^= tk[i, j - 1];
}
}
for (int i = 0; i < 4; i++)
{
tk[i, 4] ^= S[tk[i, 3] & 0xff];
}
for (int j = 5; j < KC; j++)
{
for (int i = 0; i < 4; i++)
{
tk[i, j] ^= tk[i, j - 1];
}
}
}
//
// copy values into round key array
//
for (int j = 0; (j < KC) && (t < (ROUNDS + 1) * (BC / 8)); j++, t++)
{
for (int i = 0; i < 4; i++)
{
W[t / (BC / 8)][i] |= (long)(tk[i, j] & 0xff) << ((t * 8) % (BC));
}
}
}
return W;
}
private int BC;
private long BC_MASK;
private int ROUNDS;
private int blockBits;
private long[][] workingKey;
private long A0, A1, A2, A3;
private bool forEncryption;
private byte[] shifts0SC;
private byte[] shifts1SC;
/**
* default constructor - 128 bit block size.
*/
public RijndaelEngine() : this(128) { }
/**
* basic constructor - set the cipher up for a given blocksize
*
* @param blocksize the blocksize in bits, must be 128, 192, or 256.
*/
public RijndaelEngine(
int blockBits)
{
switch (blockBits)
{
case 128:
BC = 32;
BC_MASK = 0xffffffffL;
shifts0SC = shifts0[0];
shifts1SC = shifts1[0];
break;
case 160:
BC = 40;
BC_MASK = 0xffffffffffL;
shifts0SC = shifts0[1];
shifts1SC = shifts1[1];
break;
case 192:
BC = 48;
BC_MASK = 0xffffffffffffL;
shifts0SC = shifts0[2];
shifts1SC = shifts1[2];
break;
case 224:
BC = 56;
BC_MASK = 0xffffffffffffffL;
shifts0SC = shifts0[3];
shifts1SC = shifts1[3];
break;
case 256:
BC = 64;
BC_MASK = unchecked((long)0xffffffffffffffffL);
shifts0SC = shifts0[4];
shifts1SC = shifts1[4];
break;
default:
throw new ArgumentException("unknown blocksize to Rijndael");
}
this.blockBits = blockBits;
}
/**
* initialise a Rijndael cipher.
*
* @param forEncryption whether or not we are for encryption.
* @param parameters the parameters required to set up the cipher.
* @exception ArgumentException if the parameters argument is
* inappropriate.
*/
public void Init(
bool forEncryption,
ICipherParameters parameters)
{
var parameter = parameters as KeyParameter;
if (parameter != null)
{
workingKey = GenerateWorkingKey(parameter.GetKey());
this.forEncryption = forEncryption;
return;
}
throw new ArgumentException("invalid parameter passed to Rijndael init - " + parameters.GetType().ToString());
}
public string AlgorithmName
{
get { return "Rijndael"; }
}
public bool IsPartialBlockOkay
{
get { return false; }
}
public int GetBlockSize()
{
return BC / 2;
}
public int ProcessBlock(
byte[] input,
int inOff,
byte[] output,
int outOff)
{
if (workingKey == null)
{
throw new InvalidOperationException("Rijndael engine not initialised");
}
if ((inOff + (BC / 2)) > input.Length)
{
throw new DataLengthException("input buffer too short");
}
if ((outOff + (BC / 2)) > output.Length)
{
throw new DataLengthException("output buffer too short");
}
UnPackBlock(input, inOff);
if (forEncryption)
{
EncryptBlock(workingKey);
}
else
{
DecryptBlock(workingKey);
}
PackBlock(output, outOff);
return BC / 2;
}
public void Reset()
{
}
private void UnPackBlock(
byte[] bytes,
int off)
{
int index = off;
A0 = (long)(bytes[index++] & 0xff);
A1 = (long)(bytes[index++] & 0xff);
A2 = (long)(bytes[index++] & 0xff);
A3 = (long)(bytes[index++] & 0xff);
for (int j = 8; j != BC; j += 8)
{
A0 |= (long)(bytes[index++] & 0xff) << j;
A1 |= (long)(bytes[index++] & 0xff) << j;
A2 |= (long)(bytes[index++] & 0xff) << j;
A3 |= (long)(bytes[index++] & 0xff) << j;
}
}
private void PackBlock(
byte[] bytes,
int off)
{
int index = off;
for (int j = 0; j != BC; j += 8)
{
bytes[index++] = (byte)(A0 >> j);
bytes[index++] = (byte)(A1 >> j);
bytes[index++] = (byte)(A2 >> j);
bytes[index++] = (byte)(A3 >> j);
}
}
private void EncryptBlock(
long[][] rk)
{
int r;
//
// begin with a key addition
//
KeyAddition(rk[0]);
//
// ROUNDS-1 ordinary rounds
//
for (r = 1; r < ROUNDS; r++)
{
Substitution(S);
ShiftRow(shifts0SC);
MixColumn();
KeyAddition(rk[r]);
}
//
// Last round is special: there is no MixColumn
//
Substitution(S);
ShiftRow(shifts0SC);
KeyAddition(rk[ROUNDS]);
}
private void DecryptBlock(
long[][] rk)
{
int r;
// To decrypt: apply the inverse operations of the encrypt routine,
// in opposite order
//
// (KeyAddition is an involution: it 's equal to its inverse)
// (the inverse of Substitution with table S is Substitution with the inverse table of S)
// (the inverse of Shiftrow is Shiftrow over a suitable distance)
//
// First the special round:
// without InvMixColumn
// with extra KeyAddition
//
KeyAddition(rk[ROUNDS]);
Substitution(Si);
ShiftRow(shifts1SC);
//
// ROUNDS-1 ordinary rounds
//
for (r = ROUNDS - 1; r > 0; r--)
{
KeyAddition(rk[r]);
InvMixColumn();
Substitution(Si);
ShiftRow(shifts1SC);
}
//
// End with the extra key addition
//
KeyAddition(rk[0]);
}
}
}

View File

@@ -0,0 +1,255 @@
using System;
using Org.BouncyCastle.Crypto.Utilities;
namespace Org.BouncyCastle.Crypto.Digests
{
public class Sha1Digest
: GeneralDigest
{
private const int DigestLength = 20;
private uint H1, H2, H3, H4, H5;
private uint[] X = new uint[80];
private int xOff;
public Sha1Digest()
{
Reset();
}
/**
* Copy constructor. This will copy the state of the provided
* message digest.
*/
public Sha1Digest(Sha1Digest t)
: base(t)
{
H1 = t.H1;
H2 = t.H2;
H3 = t.H3;
H4 = t.H4;
H5 = t.H5;
Array.Copy(t.X, 0, X, 0, t.X.Length);
xOff = t.xOff;
}
public override string AlgorithmName
{
get { return "SHA-1"; }
}
public override int GetDigestSize()
{
return DigestLength;
}
internal override void ProcessWord(
byte[] input,
int inOff)
{
X[xOff] = Pack.BE_To_UInt32(input, inOff);
if (++xOff == 16)
{
ProcessBlock();
}
}
internal override void ProcessLength(long bitLength)
{
if (xOff > 14)
{
ProcessBlock();
}
X[14] = (uint)((ulong)bitLength >> 32);
X[15] = (uint)((ulong)bitLength);
}
public override int DoFinal(
byte[] output,
int outOff)
{
Finish();
Pack.UInt32_To_BE(H1, output, outOff);
Pack.UInt32_To_BE(H2, output, outOff + 4);
Pack.UInt32_To_BE(H3, output, outOff + 8);
Pack.UInt32_To_BE(H4, output, outOff + 12);
Pack.UInt32_To_BE(H5, output, outOff + 16);
Reset();
return DigestLength;
}
/**
* reset the chaining variables
*/
public override void Reset()
{
base.Reset();
H1 = 0x67452301;
H2 = 0xefcdab89;
H3 = 0x98badcfe;
H4 = 0x10325476;
H5 = 0xc3d2e1f0;
xOff = 0;
Array.Clear(X, 0, X.Length);
}
//
// Additive constants
//
private const uint Y1 = 0x5a827999;
private const uint Y2 = 0x6ed9eba1;
private const uint Y3 = 0x8f1bbcdc;
private const uint Y4 = 0xca62c1d6;
private static uint F(uint u, uint v, uint w)
{
return (u & v) | (~u & w);
}
private static uint H(uint u, uint v, uint w)
{
return u ^ v ^ w;
}
private static uint G(uint u, uint v, uint w)
{
return (u & v) | (u & w) | (v & w);
}
internal override void ProcessBlock()
{
//
// expand 16 word block into 80 word block.
//
for (int i = 16; i < 80; i++)
{
uint t = X[i - 3] ^ X[i - 8] ^ X[i - 14] ^ X[i - 16];
X[i] = t << 1 | t >> 31;
}
//
// set up working variables.
//
uint A = H1;
uint B = H2;
uint C = H3;
uint D = H4;
uint E = H5;
//
// round 1
//
int idx = 0;
for (int j = 0; j < 4; j++)
{
// E = rotateLeft(A, 5) + F(B, C, D) + E + X[idx++] + Y1
// B = rotateLeft(B, 30)
E += (A << 5 | (A >> 27)) + F(B, C, D) + X[idx++] + Y1;
B = B << 30 | (B >> 2);
D += (E << 5 | (E >> 27)) + F(A, B, C) + X[idx++] + Y1;
A = A << 30 | (A >> 2);
C += (D << 5 | (D >> 27)) + F(E, A, B) + X[idx++] + Y1;
E = E << 30 | (E >> 2);
B += (C << 5 | (C >> 27)) + F(D, E, A) + X[idx++] + Y1;
D = D << 30 | (D >> 2);
A += (B << 5 | (B >> 27)) + F(C, D, E) + X[idx++] + Y1;
C = C << 30 | (C >> 2);
}
//
// round 2
//
for (int j = 0; j < 4; j++)
{
// E = rotateLeft(A, 5) + H(B, C, D) + E + X[idx++] + Y2
// B = rotateLeft(B, 30)
E += (A << 5 | (A >> 27)) + H(B, C, D) + X[idx++] + Y2;
B = B << 30 | (B >> 2);
D += (E << 5 | (E >> 27)) + H(A, B, C) + X[idx++] + Y2;
A = A << 30 | (A >> 2);
C += (D << 5 | (D >> 27)) + H(E, A, B) + X[idx++] + Y2;
E = E << 30 | (E >> 2);
B += (C << 5 | (C >> 27)) + H(D, E, A) + X[idx++] + Y2;
D = D << 30 | (D >> 2);
A += (B << 5 | (B >> 27)) + H(C, D, E) + X[idx++] + Y2;
C = C << 30 | (C >> 2);
}
//
// round 3
//
for (int j = 0; j < 4; j++)
{
// E = rotateLeft(A, 5) + G(B, C, D) + E + X[idx++] + Y3
// B = rotateLeft(B, 30)
E += (A << 5 | (A >> 27)) + G(B, C, D) + X[idx++] + Y3;
B = B << 30 | (B >> 2);
D += (E << 5 | (E >> 27)) + G(A, B, C) + X[idx++] + Y3;
A = A << 30 | (A >> 2);
C += (D << 5 | (D >> 27)) + G(E, A, B) + X[idx++] + Y3;
E = E << 30 | (E >> 2);
B += (C << 5 | (C >> 27)) + G(D, E, A) + X[idx++] + Y3;
D = D << 30 | (D >> 2);
A += (B << 5 | (B >> 27)) + G(C, D, E) + X[idx++] + Y3;
C = C << 30 | (C >> 2);
}
//
// round 4
//
for (int j = 0; j < 4; j++)
{
// E = rotateLeft(A, 5) + H(B, C, D) + E + X[idx++] + Y4
// B = rotateLeft(B, 30)
E += (A << 5 | (A >> 27)) + H(B, C, D) + X[idx++] + Y4;
B = B << 30 | (B >> 2);
D += (E << 5 | (E >> 27)) + H(A, B, C) + X[idx++] + Y4;
A = A << 30 | (A >> 2);
C += (D << 5 | (D >> 27)) + H(E, A, B) + X[idx++] + Y4;
E = E << 30 | (E >> 2);
B += (C << 5 | (C >> 27)) + H(D, E, A) + X[idx++] + Y4;
D = D << 30 | (D >> 2);
A += (B << 5 | (B >> 27)) + H(C, D, E) + X[idx++] + Y4;
C = C << 30 | (C >> 2);
}
H1 += A;
H2 += B;
H3 += C;
H4 += D;
H5 += E;
//
// reset start of the buffer.
//
xOff = 0;
Array.Clear(X, 0, 16);
}
}
}

View File

@@ -1,16 +1,18 @@
using System;
using System.IO;
using System.Linq;
namespace SharpCompress.IO
{
internal class MarkingBinaryReader : BinaryReader
{
public MarkingBinaryReader(Stream stream)
: base(stream)
{
}
public long CurrentReadByteCount { get; private set; }
public long CurrentReadByteCount { get; protected set; }
public void Mark()
{
@@ -42,8 +44,7 @@ namespace SharpCompress.IO
public override byte ReadByte()
{
CurrentReadByteCount++;
return base.ReadByte();
return ReadBytes(1).Single();
}
public override byte[] ReadBytes(int count)
@@ -62,48 +63,52 @@ namespace SharpCompress.IO
throw new NotImplementedException();
}
#if !SILVERLIGHT && !PORTABLE
#if !PORTABLE
public override decimal ReadDecimal()
{
CurrentReadByteCount += 16;
return base.ReadDecimal();
return ByteArrayToDecimal(ReadBytes(16), 0);
}
private decimal ByteArrayToDecimal(byte[] src, int offset)
{
//http://stackoverflow.com/a/16984356/385387
var i1 = BitConverter.ToInt32(src, offset);
var i2 = BitConverter.ToInt32(src, offset + 4);
var i3 = BitConverter.ToInt32(src, offset + 8);
var i4 = BitConverter.ToInt32(src, offset + 12);
return new decimal(new[] { i1, i2, i3, i4 });
}
#endif
public override double ReadDouble()
{
CurrentReadByteCount += 8;
return base.ReadDouble();
return BitConverter.ToDouble(ReadBytes(8), 0);
}
public override short ReadInt16()
{
CurrentReadByteCount += 2;
return base.ReadInt16();
return BitConverter.ToInt16(ReadBytes(2), 0);
}
public override int ReadInt32()
{
CurrentReadByteCount += 4;
return base.ReadInt32();
return BitConverter.ToInt32(ReadBytes(4), 0);
}
public override long ReadInt64()
{
CurrentReadByteCount += 8;
return base.ReadInt64();
return BitConverter.ToInt64(ReadBytes(8), 0);
}
public override sbyte ReadSByte()
{
CurrentReadByteCount++;
return base.ReadSByte();
return (sbyte)ReadByte();
}
public override float ReadSingle()
{
CurrentReadByteCount += 4;
return base.ReadSingle();
return BitConverter.ToSingle(ReadBytes(4), 0);
}
public override string ReadString()
@@ -113,20 +118,17 @@ namespace SharpCompress.IO
public override ushort ReadUInt16()
{
CurrentReadByteCount += 2;
return base.ReadUInt16();
return BitConverter.ToUInt16(ReadBytes(2), 0);
}
public override uint ReadUInt32()
{
CurrentReadByteCount += 4;
return base.ReadUInt32();
return BitConverter.ToUInt32(ReadBytes(4), 0);
}
public override ulong ReadUInt64()
{
CurrentReadByteCount += 8;
return base.ReadUInt64();
return BitConverter.ToUInt64(ReadBytes(8), 0);
}
}
}

View File

@@ -11,10 +11,7 @@ namespace SharpCompress.IO
protected override void Dispose(bool disposing)
{
if (disposing)
{
//Stream.Dispose();
}
//don't dispose anything
}
public Stream Stream { get; private set; }

View File

@@ -7,6 +7,7 @@ namespace SharpCompress.IO
private readonly Stream stream;
private MemoryStream bufferStream = new MemoryStream();
private bool isRewound;
private bool isDisposed;
public RewindableStream(Stream stream)
{
@@ -17,6 +18,11 @@ namespace SharpCompress.IO
protected override void Dispose(bool disposing)
{
if (isDisposed)
{
return;
}
isDisposed = true;
base.Dispose(disposing);
if (disposing)
{
@@ -55,7 +61,7 @@ namespace SharpCompress.IO
byte[] data = bufferStream.ToArray();
long position = bufferStream.Position;
bufferStream.SetLength(0);
bufferStream.Write(data, (int) position, data.Length - (int) position);
bufferStream.Write(data, (int)position, data.Length - (int)position);
bufferStream.Position = 0;
}
IsRecording = true;

View File

@@ -5,7 +5,7 @@ using System.Linq;
using SharpCompress.Common;
#if THREEFIVE || PORTABLE
#if PORTABLE
using SharpCompress.Common.Rar.Headers;
#endif
@@ -137,11 +137,11 @@ namespace SharpCompress.Reader
if (rawStream != null)
{
var bytesToAdvance = Entry.CompressedSize;
for (var i = 0; i < bytesToAdvance/skipBuffer.Length; i++)
for (var i = 0; i < bytesToAdvance / skipBuffer.Length; i++)
{
rawStream.Read(skipBuffer, 0, skipBuffer.Length);
}
rawStream.Read(skipBuffer, 0, (int) (bytesToAdvance%skipBuffer.Length));
rawStream.Read(skipBuffer, 0, (int)(bytesToAdvance % skipBuffer.Length));
return;
}
}

View File

@@ -1,15 +1,11 @@
using System.IO;
using SharpCompress.Common;
#if THREEFIVE
using SharpCompress.Common.Rar.Headers;
#endif
namespace SharpCompress.Reader
{
public static class IReaderExtensions
{
#if !PORTABLE
#if !PORTABLE && !NETFX_CORE
public static void WriteEntryTo(this IReader reader, string filePath)
{
using (Stream stream = File.Open(filePath, FileMode.Create, FileAccess.Write))

View File

@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using SharpCompress.Common;
@@ -12,6 +13,7 @@ namespace SharpCompress.Reader.Rar
/// </summary>
public abstract class RarReader : AbstractReader<RarReaderEntry, RarVolume>
{
public string Password { get; set; }
private RarVolume volume;
private readonly Unpack pack = new Unpack();
@@ -37,8 +39,7 @@ namespace SharpCompress.Reader.Rar
/// <returns></returns>
public static RarReader Open(Stream stream, Options options = Options.KeepStreamsOpen)
{
stream.CheckNotNull("stream");
return new SingleVolumeRarReader(stream, options);
return Open(stream, null, options);
}
/// <summary>
@@ -57,7 +58,7 @@ namespace SharpCompress.Reader.Rar
internal override IEnumerable<RarReaderEntry> GetEntries(Stream stream)
{
volume = new RarReaderVolume(stream, Options);
volume = new RarReaderVolume(stream, Password, Options);
foreach (RarFilePart fp in volume.ReadFileParts())
{
ValidateArchive(volume);
@@ -76,5 +77,11 @@ namespace SharpCompress.Reader.Rar
new MultiVolumeReadOnlyStream(
CreateFilePartEnumerableForCurrentEntry().Cast<RarFilePart>(), this)));
}
public static RarReader Open(Stream stream, string password, Options options = Options.KeepStreamsOpen)
{
stream.CheckNotNull("stream");
return new SingleVolumeRarReader(stream, password, options);
}
}
}

View File

@@ -9,8 +9,10 @@ namespace SharpCompress.Reader.Rar
{
public class RarReaderVolume : RarVolume
{
internal RarReaderVolume(Stream stream, Options options)
: base(StreamingMode.Streaming, stream, options)
internal RarReaderVolume(Stream stream, string password, Options options)
: base(StreamingMode.Streaming, stream, password, options)
{
}
@@ -25,7 +27,7 @@ namespace SharpCompress.Reader.Rar
}
#if !PORTABLE
#if !PORTABLE && !NETFX_CORE
public override FileInfo VolumeFile
{
get { return null; }

View File

@@ -7,11 +7,13 @@ namespace SharpCompress.Reader.Rar
{
internal class SingleVolumeRarReader : RarReader
{
private readonly Stream stream;
internal SingleVolumeRarReader(Stream stream, Options options)
internal SingleVolumeRarReader(Stream stream, string password, Options options)
: base(options)
{
Password = password;
this.stream = stream;
}

View File

@@ -74,7 +74,7 @@ namespace SharpCompress.Reader
return RarReader.Open(rewindableStream, options);
}
throw new InvalidOperationException("Cannot determine compressed stream type.");
throw new InvalidOperationException("Cannot determine compressed stream type. Supported Reader Formats: Zip, GZip, BZip2, Tar, Rar");
}
}
}

View File

@@ -1,230 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{51F02DE5-3A3D-4545-A309-7F4514B88A9E}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SharpCompress</RootNamespace>
<AssemblyName>SharpCompress.Mono</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<SccProjectName>
</SccProjectName>
<SccLocalPath>
</SccLocalPath>
<SccAuxPath>
</SccAuxPath>
<SccProvider>
</SccProvider>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\bin\</OutputPath>
<DefineConstants>TRACE;DEBUG;MONO</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\bin\</OutputPath>
<DefineConstants>TRACE;MONO</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
<ItemGroup>
<Compile Include="Archive\Rar\FileInfoRarArchiveVolume.cs" />
<Compile Include="Archive\Rar\FileInfoRarFilePart.cs" />
<Compile Include="Archive\Rar\RarArchive.cs" />
<Compile Include="Archive\Rar\RarArchive.Extensions.cs" />
<Compile Include="Archive\Rar\RarArchiveEntry.cs" />
<Compile Include="Archive\Rar\RarArchiveEntryFactory.cs" />
<Compile Include="Archive\Rar\RarArchiveVolume.cs" />
<Compile Include="Archive\Rar\RarArchiveVolumeFactory.cs" />
<Compile Include="Archive\Rar\SeekableStreamFilePart.cs" />
<Compile Include="Archive\Rar\StreamRarArchiveVolume.cs" />
<Compile Include="Archive\Tar\TarArchive.cs" />
<Compile Include="Archive\Tar\TarArchiveEntry.cs" />
<Compile Include="Archive\Zip\ZipArchive.cs" />
<Compile Include="Archive\Zip\ZipArchiveEntry.cs" />
<Compile Include="Archive\AbstractArchive.cs" />
<Compile Include="Archive\ArchiveFactory.cs" />
<Compile Include="Archive\IArchive.cs" />
<Compile Include="Archive\IArchiveEntry.cs" />
<Compile Include="Archive\IArchiveEntry.Extensions.cs" />
<Compile Include="Common\BZip2\BZip2Entry.cs" />
<Compile Include="Common\BZip2\BZip2FilePart.cs" />
<Compile Include="Common\BZip2\BZip2Volume.cs" />
<Compile Include="Common\GZip\GZipEntry.cs" />
<Compile Include="Common\GZip\GZipFilePart.cs" />
<Compile Include="Common\GZip\GZipVolume.cs" />
<Compile Include="Common\Rar\Headers\ArchiveHeader.cs" />
<Compile Include="Common\Rar\Headers\AVHeader.cs" />
<Compile Include="Common\Rar\Headers\CommentHeader.cs" />
<Compile Include="Common\Rar\Headers\EndArchiveHeader.cs" />
<Compile Include="Common\Rar\Headers\FileHeader.cs" />
<Compile Include="Common\Rar\Headers\FileNameDecoder.cs" />
<Compile Include="Common\Rar\Headers\Flags.cs" />
<Compile Include="Common\Rar\Headers\MarkHeader.cs" />
<Compile Include="Common\Rar\Headers\NewSubHeader.cs" />
<Compile Include="Common\Rar\Headers\RarHeader.cs" />
<Compile Include="Common\Rar\Headers\RarHeaderFactory.cs" />
<Compile Include="Common\Rar\Headers\SignHeader.cs" />
<Compile Include="Common\Rar\RarEntry.cs" />
<Compile Include="Common\Rar\RarFilePart.cs" />
<Compile Include="Common\Rar\RarVolume.cs" />
<Compile Include="Common\Tar\Headers\TarHeader.cs" />
<Compile Include="Common\Tar\TarEntry.cs" />
<Compile Include="Common\Tar\TarFilePart.cs" />
<Compile Include="Common\Tar\TarHeaderFactory.cs" />
<Compile Include="Common\Tar\TarReadOnlySubStream.cs" />
<Compile Include="Common\Tar\TarVolume.cs" />
<Compile Include="Common\Zip\Headers\DirectoryEndHeader.cs" />
<Compile Include="Common\Zip\Headers\DirectoryEntryHeader.cs" />
<Compile Include="Common\Zip\Headers\LocalEntryHeader.cs" />
<Compile Include="Common\Zip\Headers\ZipHeader.cs" />
<Compile Include="Common\Zip\CompressionMethod.cs" />
<Compile Include="Common\Zip\ZipEntry.cs" />
<Compile Include="Common\Zip\ZipFilePart.cs" />
<Compile Include="Common\Zip\ZipHeaderFactory.cs" />
<Compile Include="Common\Zip\ZipVolume.cs" />
<Compile Include="Common\Entry.cs" />
<Compile Include="Common\ExtractOptions.cs" />
<Compile Include="Common\FilePart.cs" />
<Compile Include="Common\FlagUtility.cs" />
<Compile Include="Common\IEntry.cs" />
<Compile Include="Common\IExtractionListener.cs" />
<Compile Include="Common\IVolume.cs" />
<Compile Include="Common\Options.cs" />
<Compile Include="Common\ReaderType.cs" />
<Compile Include="Common\Volume.cs" />
<Compile Include="Compressor\BZip2\BZip2Constants.cs" />
<Compile Include="Compressor\BZip2\CBZip2InputStream.cs" />
<Compile Include="Compressor\BZip2\CBZip2OutputStream.cs" />
<Compile Include="Compressor\BZip2\CRC.cs" />
<Compile Include="Compressor\Deflate\CRC32.cs" />
<Compile Include="Compressor\Deflate\DeflateManager.cs" />
<Compile Include="Compressor\Deflate\DeflateStream.cs" />
<Compile Include="Compressor\Deflate\FlushType.cs" />
<Compile Include="Compressor\Deflate\GZipStream.cs" />
<Compile Include="Compressor\Deflate\Inflate.cs" />
<Compile Include="Compressor\Deflate\InfTree.cs" />
<Compile Include="Compressor\Deflate\ParallelDeflateOutputStream.cs" />
<Compile Include="Compressor\Deflate\Tree.cs" />
<Compile Include="Compressor\Deflate\Zlib.cs" />
<Compile Include="Compressor\Deflate\ZlibBaseStream.cs" />
<Compile Include="Compressor\Deflate\ZlibCodec.cs" />
<Compile Include="Compressor\Deflate\ZlibConstants.cs" />
<Compile Include="Compressor\Deflate\ZlibStream.cs" />
<Compile Include="Compressor\LZMA\CRC.cs" />
<Compile Include="Compressor\LZMA\ICoder.cs" />
<Compile Include="Compressor\LZMA\LZ\LzBinTree.cs" />
<Compile Include="Compressor\LZMA\LZ\LzInWindow.cs" />
<Compile Include="Compressor\LZMA\LzmaBase.cs" />
<Compile Include="Compressor\LZMA\LzmaDecoder.cs" />
<Compile Include="Compressor\LZMA\LzmaEncoder.cs" />
<Compile Include="Compressor\LZMA\LzmaStream.cs" />
<Compile Include="Compressor\LZMA\LZ\LzOutWindow.cs" />
<Compile Include="Compressor\LZMA\RangeCoder\RangeCoder.cs" />
<Compile Include="Compressor\LZMA\RangeCoder\RangeCoderBit.cs" />
<Compile Include="Compressor\LZMA\RangeCoder\RangeCoderBitTree.cs" />
<Compile Include="Compressor\Rar\Decode\AudioVariables.cs" />
<Compile Include="Compressor\Rar\Decode\BitDecode.cs" />
<Compile Include="Compressor\Rar\Decode\CodeType.cs" />
<Compile Include="Compressor\Rar\Decode\Compress.cs" />
<Compile Include="Compressor\Rar\Decode\Decode.cs" />
<Compile Include="Compressor\Rar\Decode\DistDecode.cs" />
<Compile Include="Compressor\Rar\Decode\FilterType.cs" />
<Compile Include="Compressor\Rar\Decode\LitDecode.cs" />
<Compile Include="Compressor\Rar\Decode\LowDistDecode.cs" />
<Compile Include="Compressor\Rar\Decode\MultDecode.cs" />
<Compile Include="Compressor\Rar\Decode\RepDecode.cs" />
<Compile Include="Compressor\Rar\PPM\BlockTypes.cs" />
<Compile Include="Compressor\Rar\PPM\FreqData.cs" />
<Compile Include="Compressor\Rar\PPM\ModelPPM.cs" />
<Compile Include="Compressor\Rar\PPM\Pointer.cs" />
<Compile Include="Compressor\Rar\PPM\PPMContext.cs" />
<Compile Include="Compressor\Rar\PPM\RangeCoder.cs" />
<Compile Include="Compressor\Rar\PPM\RarMemBlock.cs" />
<Compile Include="Compressor\Rar\PPM\RarNode.cs" />
<Compile Include="Compressor\Rar\PPM\SEE2Context.cs" />
<Compile Include="Compressor\Rar\PPM\State.cs" />
<Compile Include="Compressor\Rar\PPM\StateRef.cs" />
<Compile Include="Compressor\Rar\PPM\SubAllocator.cs" />
<Compile Include="Compressor\Rar\VM\BitInput.cs" />
<Compile Include="Compressor\Rar\VM\RarVM.cs" />
<Compile Include="Compressor\Rar\VM\VMCmdFlags.cs" />
<Compile Include="Compressor\Rar\VM\VMCommands.cs" />
<Compile Include="Compressor\Rar\VM\VMFlags.cs" />
<Compile Include="Compressor\Rar\VM\VMOpType.cs" />
<Compile Include="Compressor\Rar\VM\VMPreparedCommand.cs" />
<Compile Include="Compressor\Rar\VM\VMPreparedOperand.cs" />
<Compile Include="Compressor\Rar\VM\VMPreparedProgram.cs" />
<Compile Include="Compressor\Rar\VM\VMStandardFilters.cs" />
<Compile Include="Compressor\Rar\VM\VMStandardFilterSignature.cs" />
<Compile Include="Compressor\Rar\MultiVolumeReadOnlyStream.cs" />
<Compile Include="Compressor\Rar\RarCRC.cs" />
<Compile Include="Compressor\Rar\Unpack.cs" />
<Compile Include="Compressor\Rar\Unpack15.cs" />
<Compile Include="Compressor\Rar\Unpack20.cs" />
<Compile Include="Compressor\Rar\UnpackFilter.cs" />
<Compile Include="Compressor\Rar\UnpackUtility.cs" />
<Compile Include="Exceptions\InvalidRarFormatException.cs" />
<Compile Include="Exceptions\MultipartStreamRequiredException.cs" />
<Compile Include="Exceptions\RarException.cs" />
<Compile Include="Exceptions\RarExtractionException.cs" />
<Compile Include="Exceptions\TarException.cs" />
<Compile Include="IO\CountingWritableSubStream.cs" />
<Compile Include="IO\MarkingBinaryReader.cs" />
<Compile Include="IO\ReadOnlySubStream.cs" />
<Compile Include="IO\RewindableStream.cs" />
<Compile Include="IO\StreamingMode.cs" />
<Compile Include="Reader\BZip2\BZip2Reader.cs" />
<Compile Include="Reader\GZip\GZipReader.cs" />
<Compile Include="Reader\Rar\MultiVolumeRarReader.cs" />
<Compile Include="Reader\Rar\NonSeekableStreamFilePart.cs" />
<Compile Include="Reader\Rar\RarReader.cs" />
<Compile Include="Reader\Rar\RarReaderEntry.cs" />
<Compile Include="Reader\Rar\RarReaderVolume.cs" />
<Compile Include="Reader\Rar\SingleVolumeRarReader.cs" />
<Compile Include="Reader\Tar\TarBZip2Reader.cs" />
<Compile Include="Reader\Tar\TarGZipReader.cs" />
<Compile Include="Reader\Tar\TarReader.cs" />
<Compile Include="Reader\Zip\ZipReader.cs" />
<Compile Include="Reader\AbstractReader.cs" />
<Compile Include="Reader\IReader.cs" />
<Compile Include="Reader\IReader.Extensions.cs" />
<Compile Include="Reader\ReaderFactory.cs" />
<Compile Include="Writer\Tar\TarWriter.cs" />
<Compile Include="Writer\Zip\ZipCentralDirectoryEntry.cs" />
<Compile Include="Writer\Zip\ZipWriter.cs" />
<Compile Include="Writer\IWriter.cs" />
<Compile Include="AssemblyInfo.cs" />
<Compile Include="ConsoleExtractionListener.cs" />
<Compile Include="LazyReadOnlyCollection.cs" />
<Compile Include="NullExtractionListener.cs" />
<Compile Include="ReadOnlyCollection.cs" />
<Compile Include="Utility.cs" />
<Compile Include="VersionInfo.cs" />
</ItemGroup>
</Project>

View File

@@ -7,7 +7,7 @@
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SharpCompress</RootNamespace>
<AssemblyName>SharpCompress.WP7</AssemblyName>
<AssemblyName>SharpCompress.Portable</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>Profile1</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
@@ -111,8 +111,11 @@
<Compile Include="Common\Rar\Headers\RarHeader.cs" />
<Compile Include="Common\Rar\Headers\RarHeaderFactory.cs" />
<Compile Include="Common\Rar\Headers\SignHeader.cs" />
<Compile Include="Common\Rar\RarCryptoBinaryReader.cs" />
<Compile Include="Common\Rar\RarCryptoWrapper.cs" />
<Compile Include="Common\Rar\RarEntry.cs" />
<Compile Include="Common\Rar\RarFilePart.cs" />
<Compile Include="Common\Rar\RarRijndael.Portable.cs" />
<Compile Include="Common\Rar\RarVolume.cs" />
<Compile Include="Common\SevenZip\ArchiveDatabase.cs" />
<Compile Include="Common\SevenZip\ArchiveReader.cs" />
@@ -133,6 +136,7 @@
<Compile Include="Common\Tar\TarReadOnlySubStream.cs" />
<Compile Include="Common\Tar\TarVolume.cs" />
<Compile Include="Common\Volume.cs" />
<Compile Include="Common\Zip\WinzipAesCryptoStream.Portable.cs" />
<Compile Include="Common\Zip\Headers\DirectoryEndHeader.cs" />
<Compile Include="Common\Zip\Headers\DirectoryEntryHeader.cs" />
<Compile Include="Common\Zip\Headers\HeaderFlags.cs" />
@@ -148,6 +152,8 @@
<Compile Include="Common\Zip\SeekableZipHeaderFactory.cs" />
<Compile Include="Common\Zip\StreamingZipFilePart.cs" />
<Compile Include="Common\Zip\StreamingZipHeaderFactory.cs" />
<Compile Include="Common\Zip\WinzipAesEncryptionData.Portable.cs" />
<Compile Include="Common\Zip\WinzipAesKeySize.cs" />
<Compile Include="Common\Zip\ZipCompressionMethod.cs" />
<Compile Include="Common\Zip\ZipEntry.cs" />
<Compile Include="Common\Zip\ZipFilePart.cs" />
@@ -166,7 +172,6 @@
<Compile Include="Compressor\Deflate\GZipStream.cs" />
<Compile Include="Compressor\Deflate\Inflate.cs" />
<Compile Include="Compressor\Deflate\InfTree.cs" />
<Compile Include="Compressor\Deflate\ParallelDeflateOutputStream.cs" />
<Compile Include="Compressor\Deflate\Tree.cs" />
<Compile Include="Compressor\Deflate\Zlib.cs" />
<Compile Include="Compressor\Deflate\ZlibBaseStream.cs" />
@@ -254,6 +259,23 @@
<Compile Include="Compressor\Rar\VM\VMPreparedProgram.cs" />
<Compile Include="Compressor\Rar\VM\VMStandardFilters.cs" />
<Compile Include="Compressor\Rar\VM\VMStandardFilterSignature.cs" />
<Compile Include="Crypto\BufferedBlockCipher.cs" />
<Compile Include="Crypto\BufferedCipherBase.cs" />
<Compile Include="Crypto\CryptoException.cs" />
<Compile Include="Crypto\DataLengthException.cs" />
<Compile Include="Crypto\GeneralDigest.cs" />
<Compile Include="Crypto\HMac.cs" />
<Compile Include="Crypto\IBlockCipher.cs" />
<Compile Include="Crypto\IBufferedCipher.cs" />
<Compile Include="Crypto\ICipherParameters.cs" />
<Compile Include="Crypto\IDigest.cs" />
<Compile Include="Crypto\IMac.cs" />
<Compile Include="Crypto\KeyParameter.cs" />
<Compile Include="Crypto\BigInteger.cs" />
<Compile Include="Crypto\Pack.cs" />
<Compile Include="Crypto\PBKDF2.cs" />
<Compile Include="Crypto\RijndaelEngine.cs" />
<Compile Include="Crypto\Sha1Digest.cs" />
<Compile Include="IO\CountingWritableSubStream.cs" />
<Compile Include="IO\ListeningStream.cs" />
<Compile Include="IO\MarkingBinaryReader.cs" />

View File

@@ -1,17 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{43F219EC-21D3-4EA8-8379-151AF9580CB8}</ProjectGuid>
<ProjectGuid>{EFDCAF57-FD4D-4E5D-A3D5-F26B875817ED}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SharpCompress</RootNamespace>
<AssemblyName>SharpCompress.3.5</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<AssemblyName>SharpCompress.PortableTest</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<StartupObject>
</StartupObject>
<FileUpgradeFlags>
</FileUpgradeFlags>
<OldToolsVersion>3.5</OldToolsVersion>
<UpgradeBackupLocation />
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
<SccProjectName>
</SccProjectName>
@@ -29,21 +50,27 @@
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\bin\</OutputPath>
<DefineConstants>TRACE;DEBUG;THREEFIVE</DefineConstants>
<DefineConstants>TRACE;DEBUG;DISABLE_TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
<NoWarn>1591</NoWarn>
<DocumentationFile>..\bin\SharpCompress.PortableTest.xml</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\bin\</OutputPath>
<DefineConstants>TRACE;THREEFIVE</DefineConstants>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
<DocumentationFile>..\bin\SharpCompress.PortableTest.xml</DocumentationFile>
<NoWarn>1591</NoWarn>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
<PropertyGroup>
<SignAssembly>true</SignAssembly>
@@ -53,121 +80,81 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Archive\AbstractArchive.cs" />
<Compile Include="Common\ArchiveEncoding.cs" />
<Compile Include="Archive\AbstractWritableArchive.cs" />
<Compile Include="Archive\AbstractArchive.cs" />
<Compile Include="Archive\AbstractWritableArchive.Extensions.cs" />
<Compile Include="Archive\ArchiveFactory.cs" />
<Compile Include="Archive\GZip\GZipWritableArchiveEntry.cs" />
<Compile Include="Archive\IArchive.Extensions.cs" />
<Compile Include="Archive\GZip\GZipArchive.cs" />
<Compile Include="Archive\GZip\GZipArchiveEntry.cs" />
<Compile Include="Archive\GZip\GZipWritableArchiveEntry.cs" />
<Compile Include="Archive\IArchive.cs" />
<Compile Include="Archive\IArchiveEntry.cs" />
<Compile Include="Archive\IArchiveEntry.Extensions.cs" />
<Compile Include="Archive\Rar\FileInfoRarArchiveVolume.cs" />
<Compile Include="Archive\Rar\FileInfoRarFilePart.cs" />
<Compile Include="Archive\Rar\RarArchive.cs" />
<Compile Include="Archive\Rar\RarArchive.Extensions.cs" />
<Compile Include="Archive\Rar\RarArchiveEntry.cs" />
<Compile Include="Archive\Rar\RarArchiveEntryFactory.cs" />
<Compile Include="Archive\Rar\RarArchiveVolumeFactory.cs" />
<Compile Include="Archive\Rar\SeekableStreamFilePart.cs" />
<Compile Include="Archive\IArchive.cs" />
<Compile Include="Archive\Rar\StreamRarArchiveVolume.cs" />
<Compile Include="Archive\SevenZip\SevenZipArchive.cs" />
<Compile Include="Archive\SevenZip\SevenZipArchiveEntry.cs" />
<Compile Include="Archive\Tar\TarArchive.cs" />
<Compile Include="Archive\Tar\TarArchiveEntry.cs" />
<Compile Include="Archive\Tar\TarWritableArchiveEntry.cs" />
<Compile Include="Archive\Zip\ZipWritableArchiveEntry.cs" />
<Compile Include="Archive\Zip\ZipArchive.cs" />
<Compile Include="Archive\Zip\ZipArchiveEntry.cs" />
<Compile Include="Archive\Zip\ZipWritableArchiveEntry.cs" />
<Compile Include="AssemblyInfo.cs" />
<Compile Include="Common\ArchiveEncoding.cs" />
<Compile Include="Common\ArchiveException.cs" />
<Compile Include="Common\ArchiveExtractionEventArgs.cs" />
<Compile Include="Common\ArchiveType.cs" />
<Compile Include="Common\CompressedBytesReadEventArgs.cs" />
<Compile Include="Common\CompressionInfo.cs" />
<Compile Include="Common\CompressionType.cs" />
<Compile Include="Common\CryptographicException.cs" />
<Compile Include="Common\Entry.cs" />
<Compile Include="Common\EntryStream.cs" />
<Compile Include="Common\ExtractionException.cs" />
<Compile Include="Common\ExtractOptions.cs" />
<Compile Include="Common\FilePart.cs" />
<Compile Include="Common\FilePartExtractionBeginEventArgs.cs" />
<Compile Include="Common\FlagUtility.cs" />
<Compile Include="Common\GenericVolume.cs" />
<Compile Include="Common\IncompleteArchiveException.cs" />
<Compile Include="Common\MultiVolumeExtractionException.cs" />
<Compile Include="Common\PasswordProtectedException.cs" />
<Compile Include="Common\CryptographicException.cs" />
<Compile Include="Common\FlagUtility.cs" />
<Compile Include="Common\GZip\GZipEntry.cs" />
<Compile Include="Common\GZip\GZipFilePart.cs" />
<Compile Include="Common\GZip\GZipVolume.cs" />
<Compile Include="Common\ExtractOptions.cs" />
<Compile Include="Common\FilePart.cs" />
<Compile Include="Common\Entry.cs" />
<Compile Include="Common\IEntry.cs" />
<Compile Include="Common\IncompleteArchiveException.cs" />
<Compile Include="Common\InvalidFormatException.cs" />
<Compile Include="Common\IStreamListener.cs" />
<Compile Include="Common\IVolume.cs" />
<Compile Include="Common\MultipartStreamRequiredException.cs" />
<Compile Include="Common\MultiVolumeExtractionException.cs" />
<Compile Include="Common\Options.cs" />
<Compile Include="Common\PasswordProtectedException.cs" />
<Compile Include="Common\Rar\Headers\ArchiveHeader.cs" />
<Compile Include="Common\Rar\Headers\AVHeader.cs" />
<Compile Include="Common\Rar\Headers\CommentHeader.cs" />
<Compile Include="Common\Rar\Headers\EndArchiveHeader.cs" />
<Compile Include="Common\Rar\Headers\FileHeader.cs" />
<Compile Include="Common\Rar\Headers\FileNameDecoder.cs" />
<Compile Include="Common\Rar\Headers\Flags.cs" />
<Compile Include="Common\Rar\Headers\MarkHeader.cs" />
<Compile Include="Common\Rar\Headers\NewSubHeader.cs" />
<Compile Include="Common\Rar\Headers\RarHeader.cs" />
<Compile Include="Common\Rar\Headers\RarHeaderFactory.cs" />
<Compile Include="Common\Rar\Headers\SignHeader.cs" />
<Compile Include="Common\Rar\RarEntry.cs" />
<Compile Include="Common\Rar\RarFilePart.cs" />
<Compile Include="Common\Rar\RarVolume.cs" />
<Compile Include="Common\SevenZip\ArchiveDatabase.cs" />
<Compile Include="Common\SevenZip\ArchiveReader.cs" />
<Compile Include="Common\Rar\RarCryptoWrapper.cs" />
<Compile Include="Common\Rar\RarRijndael.Portable.cs" />
<Compile Include="Common\SevenZip\CBindPair.cs" />
<Compile Include="Common\SevenZip\CCoderInfo.cs" />
<Compile Include="Common\SevenZip\CFileItem.cs" />
<Compile Include="Common\SevenZip\CFolder.cs" />
<Compile Include="Common\SevenZip\CMethodId.cs" />
<Compile Include="Common\SevenZip\CStreamSwitch.cs" />
<Compile Include="Common\SevenZip\DataReader.cs" />
<Compile Include="Common\SevenZip\SevenZipEntry.cs" />
<Compile Include="Common\SevenZip\SevenZipFilePart.cs" />
<Compile Include="Common\SevenZip\SevenZipVolume.cs" />
<Compile Include="Common\Tar\Headers\TarHeader.cs" />
<Compile Include="Common\Tar\TarReadOnlySubStream.cs" />
<Compile Include="Common\Tar\TarVolume.cs" />
<Compile Include="Common\Tar\TarEntry.cs" />
<Compile Include="Common\Tar\TarFilePart.cs" />
<Compile Include="Common\Tar\TarHeaderFactory.cs" />
<Compile Include="Common\Tar\TarReadOnlySubStream.cs" />
<Compile Include="Common\Tar\TarVolume.cs" />
<Compile Include="Common\Volume.cs" />
<Compile Include="Common\Zip\Headers\DirectoryEndHeader.cs" />
<Compile Include="Common\Zip\Headers\DirectoryEntryHeader.cs" />
<Compile Include="Common\Zip\Headers\HeaderFlags.cs" />
<Compile Include="Common\Zip\Headers\IgnoreHeader.cs" />
<Compile Include="Common\Zip\Headers\LocalEntryHeader.cs" />
<Compile Include="Common\Zip\Headers\SplitHeader.cs" />
<Compile Include="Common\Zip\Headers\ZipFileEntry..cs" />
<Compile Include="Common\Zip\Headers\ZipHeader.cs" />
<Compile Include="Common\Zip\Headers\ZipHeaderType.cs" />
<Compile Include="Common\Zip\PkwareTraditionalCryptoStream.cs" />
<Compile Include="Common\Zip\PkwareTraditionalEncryptionData.cs" />
<Compile Include="Common\Zip\SeekableZipFilePart.cs" />
<Compile Include="Common\Zip\SeekableZipHeaderFactory.cs" />
<Compile Include="Common\Zip\StreamingZipFilePart.cs" />
<Compile Include="Common\Zip\StreamingZipHeaderFactory.cs" />
<Compile Include="Common\Zip\WinzipAesCryptoStream.cs" />
<Compile Include="Common\Zip\WinzipAesEncryptionData.cs" />
<Compile Include="Common\Zip\WinzipAesCryptoStream.Portable.cs" />
<Compile Include="Common\Zip\WinzipAesEncryptionData.Portable.cs" />
<Compile Include="Common\Zip\WinzipAesKeySize.cs" />
<Compile Include="Common\Zip\ZipCompressionMethod.cs" />
<Compile Include="Common\Zip\ZipEntry.cs" />
<Compile Include="Common\Zip\ZipFilePart.cs" />
<Compile Include="Common\Zip\ZipHeaderFactory.cs" />
<Compile Include="Common\Zip\ZipVolume.cs" />
<Compile Include="Compressor\BZip2\BZip2Constants.cs" />
<Compile Include="Compressor\BZip2\BZip2Stream.cs" />
@@ -175,73 +162,57 @@
<Compile Include="Compressor\BZip2\CBZip2OutputStream.cs" />
<Compile Include="Compressor\BZip2\CRC.cs" />
<Compile Include="Compressor\CompressionMode.cs" />
<Compile Include="Compressor\Deflate\Crc32.cs" />
<Compile Include="Compressor\Deflate\DeflateManager.cs" />
<Compile Include="Compressor\Deflate\DeflateStream.cs" />
<Compile Include="Compressor\Deflate\FlushType.cs" />
<Compile Include="Compressor\Deflate\GZipStream.cs" />
<Compile Include="Compressor\Deflate\Inflate.cs" />
<Compile Include="Compressor\Deflate\InfTree.cs" />
<Compile Include="Compressor\Deflate\ParallelDeflateOutputStream.cs" />
<Compile Include="Compressor\Deflate\Tree.cs" />
<Compile Include="Compressor\Deflate\Zlib.cs" />
<Compile Include="Compressor\Deflate\ZlibBaseStream.cs" />
<Compile Include="Compressor\Deflate\ZlibCodec.cs" />
<Compile Include="Compressor\Deflate\ZlibConstants.cs" />
<Compile Include="Compressor\Deflate\ZlibStream.cs" />
<Compile Include="Common\Zip\PkwareTraditionalCryptoStream.cs" />
<Compile Include="Common\Zip\PkwareTraditionalEncryptionData.cs" />
<Compile Include="Compressor\Deflate\GZipStream.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Compressor\Filters\BCJ2Filter.cs" />
<Compile Include="Compressor\Filters\BCJFilter.cs" />
<Compile Include="Compressor\Filters\Filter.cs" />
<Compile Include="Compressor\LZMA\BitVector.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Compressor\LZMA\LZ\CRC.cs" />
<Compile Include="Compressor\LZMA\CRC.cs" />
<Compile Include="Common\SevenZip\ArchiveDatabase.cs" />
<Compile Include="Common\SevenZip\ArchiveReader.cs" />
<Compile Include="Common\SevenZip\CMethodId.cs" />
<Compile Include="Compressor\LZMA\AesDecoderStream.cs" />
<Compile Include="Compressor\LZMA\Bcj2DecoderStream.cs" />
<Compile Include="Compressor\LZMA\BitVector.cs" />
<Compile Include="Compressor\LZMA\CRC.cs" />
<Compile Include="Compressor\LZMA\DecoderStream.cs" />
<Compile Include="Compressor\LZMA\Registry.cs" />
<Compile Include="Compressor\LZMA\ICoder.cs" />
<Compile Include="Compressor\LZMA\Log.cs" />
<Compile Include="Compressor\LZMA\LzmaEncoderProperties.cs" />
<Compile Include="Compressor\LZMA\LzmaStream.cs" />
<Compile Include="Compressor\LZMA\LZ\CRC.cs" />
<Compile Include="Compressor\LZMA\LZ\LzBinTree.cs" />
<Compile Include="Compressor\LZMA\LZ\LzInWindow.cs" />
<Compile Include="Compressor\LZMA\Log.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Compressor\LZMA\LzmaBase.cs" />
<Compile Include="Compressor\LZMA\LzmaDecoder.cs" />
<Compile Include="Compressor\LZMA\LzmaEncoder.cs" />
<Compile Include="Compressor\LZMA\LzmaEncoderProperties.cs" />
<Compile Include="Compressor\LZMA\LzmaStream.cs" />
<Compile Include="Compressor\LZMA\LZ\LzBinTree.cs" />
<Compile Include="Compressor\LZMA\LZ\LzInWindow.cs" />
<Compile Include="Compressor\LZMA\LZ\LzOutWindow.cs" />
<Compile Include="Compressor\LZMA\RangeCoder\RangeCoder.cs" />
<Compile Include="Compressor\LZMA\RangeCoder\RangeCoderBit.cs" />
<Compile Include="Compressor\LZMA\RangeCoder\RangeCoderBitTree.cs" />
<Compile Include="Compressor\LZMA\Registry.cs" />
<Compile Include="Compressor\LZMA\Utilites\CrcBuilderStream.cs" />
<Compile Include="Compressor\LZMA\Utilites\CrcCheckStream.cs" />
<Compile Include="Compressor\LZMA\Utilites\IPasswordProvider.cs" />
<Compile Include="Compressor\LZMA\Utilites\SyncStreamView.cs" />
<Compile Include="Compressor\LZMA\Utilites\UnpackSubStream.cs" />
<Compile Include="Compressor\LZMA\Utilites\Utils.cs" />
<Compile Include="Compressor\PPMd\I1\Allocator.cs" />
<Compile Include="Compressor\PPMd\I1\Coder.cs" />
<Compile Include="Compressor\PPMd\I1\MemoryNode.cs" />
<Compile Include="Compressor\PPMd\I1\Model.cs" />
<Compile Include="Compressor\PPMd\I1\ModelRestorationMethod.cs" />
<Compile Include="Compressor\PPMd\I1\Pointer.cs" />
<Compile Include="Compressor\PPMd\I1\PpmContext.cs" />
<Compile Include="Compressor\PPMd\PpmdProperties.cs" />
<Compile Include="Compressor\PPMd\PpmdStream.cs" />
<Compile Include="Compressor\PPMd\I1\PpmState.cs" />
<Compile Include="Compressor\PPMd\I1\See2Context.cs" />
<Compile Include="Compressor\Rar\Decode\AudioVariables.cs" />
<Compile Include="Compressor\Rar\Decode\BitDecode.cs" />
<Compile Include="Compressor\Rar\Decode\CodeType.cs" />
<Compile Include="Compressor\Rar\Decode\Compress.cs" />
<Compile Include="Compressor\Rar\Decode\Decode.cs" />
<Compile Include="Compressor\Rar\Decode\DistDecode.cs" />
<Compile Include="Compressor\Rar\Decode\FilterType.cs" />
<Compile Include="Compressor\Rar\Decode\LitDecode.cs" />
<Compile Include="Compressor\Rar\Decode\LowDistDecode.cs" />
<Compile Include="Compressor\Rar\Decode\MultDecode.cs" />
<Compile Include="Compressor\Rar\Decode\RepDecode.cs" />
<Compile Include="Compressor\Rar\MultiVolumeReadOnlyStream.cs" />
<Compile Include="Compressor\Rar\PPM\BlockTypes.cs" />
<Compile Include="Compressor\LZMA\Utilites\CrcBuilderStream.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Compressor\LZMA\Utilites\CrcCheckStream.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Compressor\LZMA\Utilites\IPasswordProvider.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Compressor\LZMA\Utilites\SyncStreamView.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Compressor\LZMA\Utilites\Utils.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Compressor\PPMd\H\FreqData.cs" />
<Compile Include="Compressor\PPMd\H\ModelPPM.cs" />
<Compile Include="Compressor\PPMd\H\Pointer.cs" />
@@ -253,13 +224,118 @@
<Compile Include="Compressor\PPMd\H\State.cs" />
<Compile Include="Compressor\PPMd\H\StateRef.cs" />
<Compile Include="Compressor\PPMd\H\SubAllocator.cs" />
<Compile Include="Compressor\Rar\RarCRC.cs" />
<Compile Include="Compressor\PPMd\I1\Allocator.cs" />
<Compile Include="Compressor\PPMd\I1\Coder.cs" />
<Compile Include="Compressor\PPMd\I1\MemoryNode.cs" />
<Compile Include="Compressor\PPMd\I1\Model.cs" />
<Compile Include="Compressor\PPMd\I1\ModelRestorationMethod.cs" />
<Compile Include="Compressor\PPMd\I1\Pointer.cs" />
<Compile Include="Compressor\PPMd\I1\PpmContext.cs" />
<Compile Include="Compressor\PPMd\I1\PpmState.cs" />
<Compile Include="Compressor\PPMd\I1\See2Context.cs" />
<Compile Include="Compressor\PPMd\PpmdProperties.cs" />
<Compile Include="Compressor\PPMd\PpmdStream.cs" />
<Compile Include="Compressor\Rar\RarStream.cs" />
<Compile Include="Crypto\BigInteger.cs" />
<Compile Include="Crypto\BufferedBlockCipher.cs" />
<Compile Include="Crypto\BufferedCipherBase.cs" />
<Compile Include="Crypto\CryptoException.cs" />
<Compile Include="Crypto\DataLengthException.cs" />
<Compile Include="Crypto\GeneralDigest.cs" />
<Compile Include="Crypto\HMac.cs" />
<Compile Include="Crypto\IBlockCipher.cs" />
<Compile Include="Crypto\IBufferedCipher.cs" />
<Compile Include="Crypto\ICipherParameters.cs" />
<Compile Include="Crypto\IDigest.cs" />
<Compile Include="Crypto\IMac.cs" />
<Compile Include="Crypto\KeyParameter.cs" />
<Compile Include="Crypto\Pack.cs" />
<Compile Include="Crypto\PBKDF2.cs" />
<Compile Include="Crypto\RijndaelEngine.cs" />
<Compile Include="Crypto\Sha1Digest.cs" />
<Compile Include="IO\CountingWritableSubStream.cs" />
<Compile Include="Common\EntryStream.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="IO\ListeningStream.cs" />
<Compile Include="IO\NonDisposingStream.cs" />
<Compile Include="Common\Rar\RarCryptoBinaryReader.cs" />
<Compile Include="IO\RewindableStream.cs" />
<Compile Include="Reader\GZip\GZipReader.cs" />
<Compile Include="Reader\ReaderFactory.cs" />
<Compile Include="Reader\AbstractReader.cs" />
<Compile Include="Common\Volume.cs" />
<Compile Include="Compressor\Deflate\CRC32.cs" />
<Compile Include="Compressor\Deflate\DeflateManager.cs" />
<Compile Include="Compressor\Deflate\DeflateStream.cs" />
<Compile Include="Compressor\Deflate\Inflate.cs" />
<Compile Include="Compressor\Deflate\InfTree.cs" />
<Compile Include="Compressor\Deflate\Tree.cs" />
<Compile Include="Compressor\Deflate\Zlib.cs" />
<Compile Include="Compressor\Deflate\ZlibBaseStream.cs" />
<Compile Include="Compressor\Deflate\ZlibCodec.cs" />
<Compile Include="Compressor\Deflate\ZlibConstants.cs" />
<Compile Include="Compressor\Deflate\ZlibStream.cs" />
<Compile Include="Common\Rar\Headers\FileNameDecoder.cs" />
<Compile Include="Common\InvalidFormatException.cs" />
<Compile Include="IO\ReadOnlySubStream.cs" />
<Compile Include="IO\StreamingMode.cs" />
<Compile Include="Common\IStreamListener.cs" />
<Compile Include="Common\MultipartStreamRequiredException.cs" />
<Compile Include="LazyReadOnlyCollection.cs" />
<Compile Include="Archive\Rar\RarArchive.Extensions.cs" />
<Compile Include="Archive\IArchiveEntry.Extensions.cs" />
<Compile Include="Archive\Rar\RarArchiveEntry.cs" />
<Compile Include="Common\ExtractionException.cs" />
<Compile Include="Common\Rar\RarEntry.cs" />
<Compile Include="Common\Options.cs" />
<Compile Include="Reader\IReader.cs" />
<Compile Include="Reader\Rar\MultiVolumeRarReader.cs" />
<Compile Include="Reader\Rar\RarReader.cs" />
<Compile Include="Reader\IReader.Extensions.cs" />
<Compile Include="Reader\Rar\RarReaderEntry.cs" />
<Compile Include="Archive\Rar\SeekableStreamFilePart.cs" />
<Compile Include="Reader\Rar\SingleVolumeRarReader.cs" />
<Compile Include="Common\ArchiveType.cs" />
<Compile Include="Reader\Tar\TarReader.cs" />
<Compile Include="ReadOnlyCollection.cs" />
<Compile Include="VersionInfo.cs" />
<Compile Include="Archive\Rar\FileInfoRarFilePart.cs" />
<Compile Include="Archive\Rar\FileInfoRarArchiveVolume.cs" />
<Compile Include="Common\Rar\RarFilePart.cs" />
<Compile Include="Common\Rar\Headers\AVHeader.cs" />
<Compile Include="Common\Rar\Headers\CommentHeader.cs" />
<Compile Include="Common\Rar\Headers\EndArchiveHeader.cs" />
<Compile Include="Common\Rar\Headers\SignHeader.cs" />
<Compile Include="Common\Rar\RarVolume.cs" />
<Compile Include="Compressor\Rar\UnpackUtility.cs" />
<Compile Include="Archive\Rar\RarArchive.cs" />
<Compile Include="Compressor\Rar\MultiVolumeReadOnlyStream.cs" />
<Compile Include="Compressor\Rar\RarCRC.cs" />
<Compile Include="Common\Rar\Headers\FileHeader.cs" />
<Compile Include="Common\Rar\Headers\ArchiveHeader.cs" />
<Compile Include="Common\Rar\Headers\RarHeader.cs" />
<Compile Include="IO\MarkingBinaryReader.cs" />
<Compile Include="Common\Rar\Headers\NewSubHeader.cs" />
<Compile Include="AssemblyInfo.cs" />
<Compile Include="Common\Rar\Headers\RarHeaderFactory.cs" />
<Compile Include="Common\Rar\Headers\Flags.cs" />
<Compile Include="Compressor\Rar\Decode\AudioVariables.cs" />
<Compile Include="Compressor\Rar\Decode\BitDecode.cs" />
<Compile Include="Compressor\Rar\Decode\CodeType.cs" />
<Compile Include="Compressor\Rar\Decode\Compress.cs" />
<Compile Include="Compressor\Rar\Decode\Decode.cs" />
<Compile Include="Compressor\Rar\Decode\DistDecode.cs" />
<Compile Include="Compressor\Rar\Decode\FilterType.cs" />
<Compile Include="Compressor\Rar\Decode\LitDecode.cs" />
<Compile Include="Compressor\Rar\Decode\LowDistDecode.cs" />
<Compile Include="Compressor\Rar\Decode\MultDecode.cs" />
<Compile Include="Compressor\Rar\Decode\RepDecode.cs" />
<Compile Include="Compressor\Rar\PPM\BlockTypes.cs" />
<Compile Include="Compressor\Rar\Unpack.cs" />
<Compile Include="Compressor\Rar\Unpack15.cs" />
<Compile Include="Compressor\Rar\Unpack20.cs" />
<Compile Include="Compressor\Rar\UnpackFilter.cs" />
<Compile Include="Compressor\Rar\UnpackUtility.cs" />
<Compile Include="Compressor\Rar\VM\BitInput.cs" />
<Compile Include="Compressor\Rar\VM\RarVM.cs" />
<Compile Include="Compressor\Rar\VM\VMCmdFlags.cs" />
@@ -271,43 +347,51 @@
<Compile Include="Compressor\Rar\VM\VMPreparedProgram.cs" />
<Compile Include="Compressor\Rar\VM\VMStandardFilters.cs" />
<Compile Include="Compressor\Rar\VM\VMStandardFilterSignature.cs" />
<Compile Include="IO\CountingWritableSubStream.cs" />
<Compile Include="IO\ListeningStream.cs" />
<Compile Include="IO\MarkingBinaryReader.cs" />
<Compile Include="IO\NonDisposingStream.cs" />
<Compile Include="IO\ReadOnlySubStream.cs" />
<Compile Include="IO\RewindableStream.cs" />
<Compile Include="IO\StreamingMode.cs" />
<Compile Include="LazyReadOnlyCollection.cs" />
<Compile Include="Reader\AbstractReader.cs" />
<Compile Include="Reader\GZip\GZipReader.cs" />
<Compile Include="Reader\IReader.cs" />
<Compile Include="Reader\IReader.Extensions.cs" />
<Compile Include="Reader\Rar\MultiVolumeRarReader.cs" />
<Compile Include="Reader\Rar\NonSeekableStreamFilePart.cs" />
<Compile Include="Reader\Rar\RarReader.cs" />
<Compile Include="Reader\Rar\RarReaderEntry.cs" />
<Compile Include="Reader\Rar\RarReaderVolume.cs" />
<Compile Include="Reader\Rar\SingleVolumeRarReader.cs" />
<Compile Include="Reader\ReaderFactory.cs" />
<Compile Include="Reader\Tar\TarReader.cs" />
<Compile Include="Reader\Zip\ZipReader.cs" />
<Compile Include="ReadOnlyCollection.cs" />
<Compile Include="Utility.cs" />
<Compile Include="VersionInfo.cs" />
<Compile Include="Common\Rar\Headers\MarkHeader.cs" />
<Compile Include="Archive\Rar\RarArchiveVolumeFactory.cs" />
<Compile Include="Reader\Rar\NonSeekableStreamFilePart.cs" />
<Compile Include="Reader\Rar\RarReaderVolume.cs" />
<Compile Include="Common\Zip\ZipCompressionMethod.cs" />
<Compile Include="Common\Zip\Headers\DirectoryEndHeader.cs" />
<Compile Include="Common\Zip\Headers\DirectoryEntryHeader.cs" />
<Compile Include="Common\Zip\Headers\LocalEntryHeader.cs" />
<Compile Include="Common\Zip\ZipFilePart.cs" />
<Compile Include="Common\Zip\Headers\ZipHeader.cs" />
<Compile Include="Common\Zip\ZipHeaderFactory.cs" />
<Compile Include="Reader\Zip\ZipReader.cs" />
<Compile Include="Common\Zip\ZipEntry.cs" />
<Compile Include="Writer\AbstractWriter.cs" />
<Compile Include="Writer\GZip\GZipWriter.cs" />
<Compile Include="Writer\IWriter.cs" />
<Compile Include="Writer\IWriter.Extensions.cs" />
<Compile Include="Writer\IWriter.cs" />
<Compile Include="Writer\Tar\TarWriter.cs" />
<Compile Include="Writer\WriterFactory.cs" />
<Compile Include="Writer\Zip\ZipCentralDirectoryEntry.cs" />
<Compile Include="Writer\Zip\ZipWriter.cs" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
<Visible>False</Visible>
<ProductName>Windows Installer 3.1</ProductName>
<Install>true</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<None Include="SharpCompress.pfx" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<ItemGroup />
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">

View File

@@ -1,76 +1,105 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.50727</ProductVersion>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{185ED218-A74F-4F57-85A5-30647495E615}</ProjectGuid>
<ProjectTypeGuids>{A1591282-1198-4647-A2B1-27E5FF5F6F3B};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
<ProjectGuid>{1DF6D83C-31FF-47B6-82FE-C4603BE916B5}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SharpCompress</RootNamespace>
<AssemblyName>SharpCompress.Silverlight</AssemblyName>
<TargetFrameworkIdentifier>Silverlight</TargetFrameworkIdentifier>
<TargetFrameworkVersion>v5.0</TargetFrameworkVersion>
<SilverlightVersion>$(TargetFrameworkVersion)</SilverlightVersion>
<SilverlightApplication>false</SilverlightApplication>
<ValidateXaml>true</ValidateXaml>
<ThrowErrorsInValidation>true</ThrowErrorsInValidation>
<SccProjectName>
</SccProjectName>
<SccLocalPath>
</SccLocalPath>
<SccAuxPath>
</SccAuxPath>
<SccProvider>
</SccProvider>
<TargetFrameworkProfile />
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\sharpcompress\</SolutionDir>
<RestorePackages>true</RestorePackages>
</PropertyGroup>
<!-- This property group is only here to support building this project using the
MSBuild 3.5 toolset. In order to work correctly with this older toolset, it needs
to set the TargetFrameworkVersion to v3.5 -->
<PropertyGroup Condition="'$(MSBuildToolsVersion)' == '3.5'">
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<AssemblyName>SharpCompress.WindowsStore</AssemblyName>
<DefaultLanguage>en-US</DefaultLanguage>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{BC8A1FFA-BEE3-4634-8014-F334798102B3};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\bin\</OutputPath>
<DefineConstants>DEBUG;TRACE;SILVERLIGHT</DefineConstants>
<NoStdLib>true</NoStdLib>
<NoConfig>true</NoConfig>
<DefineConstants>DEBUG;TRACE;NETFX_CORE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\bin\</OutputPath>
<DefineConstants>TRACE;SILVERLIGHT</DefineConstants>
<NoStdLib>true</NoStdLib>
<NoConfig>true</NoConfig>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE;NETFX_CORE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
<PropertyGroup>
<SignAssembly>true</SignAssembly>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|ARM'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\ARM\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;NETFX_CORE</DefineConstants>
<NoWarn>;2008</NoWarn>
<DebugType>full</DebugType>
<PlatformTarget>ARM</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup>
<AssemblyOriginatorKeyFile>SharpCompress.pfx</AssemblyOriginatorKeyFile>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|ARM'">
<OutputPath>bin\ARM\Release\</OutputPath>
<DefineConstants>TRACE;NETFX_CORE</DefineConstants>
<Optimize>true</Optimize>
<NoWarn>;2008</NoWarn>
<DebugType>pdbonly</DebugType>
<PlatformTarget>ARM</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;NETFX_CORE</DefineConstants>
<NoWarn>;2008</NoWarn>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE;NETFX_CORE</DefineConstants>
<Optimize>true</Optimize>
<NoWarn>;2008</NoWarn>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>..\bin\</OutputPath>
<DefineConstants>DEBUG;TRACE;NETFX_CORE</DefineConstants>
<NoWarn>;2008</NoWarn>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>bin\x86\Release\</OutputPath>
<DefineConstants>TRACE;NETFX_CORE</DefineConstants>
<Optimize>true</Optimize>
<NoWarn>;2008</NoWarn>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="mscorlib" />
<Reference Include="system" />
<Reference Include="System.Core" />
<Reference Include="System.Net" />
</ItemGroup>
<ItemGroup>
<!-- A reference to the entire .Net Framework and Windows SDK are automatically included -->
<Compile Include="Archive\AbstractArchive.cs" />
<Compile Include="Archive\AbstractWritableArchive.cs" />
<Compile Include="Archive\AbstractWritableArchive.Extensions.cs" />
@@ -79,10 +108,9 @@
<Compile Include="Archive\GZip\GZipArchiveEntry.cs" />
<Compile Include="Archive\GZip\GZipWritableArchiveEntry.cs" />
<Compile Include="Archive\IArchive.cs" />
<Compile Include="Archive\IArchive.Extensions.cs" />
<Compile Include="Archive\IArchiveEntry.cs" />
<Compile Include="Archive\IArchiveEntry.Extensions.cs" />
<Compile Include="Archive\Rar\FileInfoRarArchiveVolume.cs" />
<Compile Include="Archive\Rar\FileInfoRarFilePart.cs" />
<Compile Include="Archive\Rar\RarArchive.cs" />
<Compile Include="Archive\Rar\RarArchive.Extensions.cs" />
<Compile Include="Archive\Rar\RarArchiveEntry.cs" />
@@ -139,8 +167,11 @@
<Compile Include="Common\Rar\Headers\RarHeader.cs" />
<Compile Include="Common\Rar\Headers\RarHeaderFactory.cs" />
<Compile Include="Common\Rar\Headers\SignHeader.cs" />
<Compile Include="Common\Rar\RarCryptoBinaryReader.cs" />
<Compile Include="Common\Rar\RarCryptoWrapper.cs" />
<Compile Include="Common\Rar\RarEntry.cs" />
<Compile Include="Common\Rar\RarFilePart.cs" />
<Compile Include="Common\Rar\RarRijndael.Portable.cs" />
<Compile Include="Common\Rar\RarVolume.cs" />
<Compile Include="Common\SevenZip\ArchiveDatabase.cs" />
<Compile Include="Common\SevenZip\ArchiveReader.cs" />
@@ -176,8 +207,8 @@
<Compile Include="Common\Zip\SeekableZipHeaderFactory.cs" />
<Compile Include="Common\Zip\StreamingZipFilePart.cs" />
<Compile Include="Common\Zip\StreamingZipHeaderFactory.cs" />
<Compile Include="Common\Zip\WinzipAesCryptoStream.cs" />
<Compile Include="Common\Zip\WinzipAesEncryptionData.cs" />
<Compile Include="Common\Zip\WinzipAesCryptoStream.Portable.cs" />
<Compile Include="Common\Zip\WinzipAesEncryptionData.Portable.cs" />
<Compile Include="Common\Zip\WinzipAesKeySize.cs" />
<Compile Include="Common\Zip\ZipCompressionMethod.cs" />
<Compile Include="Common\Zip\ZipEntry.cs" />
@@ -190,14 +221,13 @@
<Compile Include="Compressor\BZip2\CBZip2OutputStream.cs" />
<Compile Include="Compressor\BZip2\CRC.cs" />
<Compile Include="Compressor\CompressionMode.cs" />
<Compile Include="Compressor\Deflate\Crc32.cs" />
<Compile Include="Compressor\Deflate\CRC32.cs" />
<Compile Include="Compressor\Deflate\DeflateManager.cs" />
<Compile Include="Compressor\Deflate\DeflateStream.cs" />
<Compile Include="Compressor\Deflate\FlushType.cs" />
<Compile Include="Compressor\Deflate\GZipStream.cs" />
<Compile Include="Compressor\Deflate\Inflate.cs" />
<Compile Include="Compressor\Deflate\InfTree.cs" />
<Compile Include="Compressor\Deflate\ParallelDeflateOutputStream.cs" />
<Compile Include="Compressor\Deflate\Tree.cs" />
<Compile Include="Compressor\Deflate\Zlib.cs" />
<Compile Include="Compressor\Deflate\ZlibBaseStream.cs" />
@@ -213,14 +243,14 @@
<Compile Include="Compressor\LZMA\DecoderStream.cs" />
<Compile Include="Compressor\LZMA\ICoder.cs" />
<Compile Include="Compressor\LZMA\Log.cs" />
<Compile Include="Compressor\LZMA\LzmaBase.cs" />
<Compile Include="Compressor\LZMA\LzmaDecoder.cs" />
<Compile Include="Compressor\LZMA\LzmaEncoder.cs" />
<Compile Include="Compressor\LZMA\LzmaEncoderProperties.cs" />
<Compile Include="Compressor\LZMA\LzmaStream.cs" />
<Compile Include="Compressor\LZMA\LZ\CRC.cs" />
<Compile Include="Compressor\LZMA\LZ\LzBinTree.cs" />
<Compile Include="Compressor\LZMA\LZ\LzInWindow.cs" />
<Compile Include="Compressor\LZMA\LzmaBase.cs" />
<Compile Include="Compressor\LZMA\LzmaDecoder.cs" />
<Compile Include="Compressor\LZMA\LzmaEncoder.cs" />
<Compile Include="Compressor\LZMA\LZ\LzOutWindow.cs" />
<Compile Include="Compressor\LZMA\RangeCoder\RangeCoder.cs" />
<Compile Include="Compressor\LZMA\RangeCoder\RangeCoderBit.cs" />
@@ -285,6 +315,24 @@
<Compile Include="Compressor\Rar\VM\VMPreparedProgram.cs" />
<Compile Include="Compressor\Rar\VM\VMStandardFilters.cs" />
<Compile Include="Compressor\Rar\VM\VMStandardFilterSignature.cs" />
<Compile Include="Crypto\BigInteger.cs" />
<Compile Include="Crypto\BufferedBlockCipher.cs" />
<Compile Include="Crypto\BufferedCipherBase.cs" />
<Compile Include="Crypto\CryptoException.cs" />
<Compile Include="Crypto\DataLengthException.cs" />
<Compile Include="Crypto\GeneralDigest.cs" />
<Compile Include="Crypto\HMac.cs" />
<Compile Include="Crypto\IBlockCipher.cs" />
<Compile Include="Crypto\IBufferedCipher.cs" />
<Compile Include="Crypto\ICipherParameters.cs" />
<Compile Include="Crypto\IDigest.cs" />
<Compile Include="Crypto\IMac.cs" />
<Compile Include="Crypto\KeyParameter.cs" />
<Compile Include="Crypto\PBKDF2.cs" />
<Compile Include="Crypto\RijndaelEngine.cs" />
<Compile Include="Crypto\Pack.cs" />
<Compile Include="Crypto\Sha1Digest.cs" />
<Compile Include="IO\AppendingStream.cs" />
<Compile Include="IO\CountingWritableSubStream.cs" />
<Compile Include="IO\ListeningStream.cs" />
<Compile Include="IO\MarkingBinaryReader.cs" />
@@ -319,16 +367,15 @@
<Compile Include="Writer\Zip\ZipWriter.cs" />
</ItemGroup>
<ItemGroup>
<None Include="SharpCompress.pfx" />
<Folder Include="Properties\" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Silverlight\$(SilverlightVersion)\Microsoft.Silverlight.CSharp.targets" />
<ProjectExtensions>
<VisualStudio>
<FlavorProperties GUID="{A1591282-1198-4647-A2B1-27E5FF5F6F3B}">
<SilverlightProjectProperties />
</FlavorProperties>
</VisualStudio>
</ProjectExtensions>
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '11.0' ">
<VisualStudioVersion>11.0</VisualStudioVersion>
</PropertyGroup>
<PropertyGroup>
<StartupObject />
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">

View File

@@ -126,6 +126,8 @@
<Compile Include="Common\Entry.cs" />
<Compile Include="Common\IEntry.cs" />
<Compile Include="Common\IVolume.cs" />
<Compile Include="Common\Rar\RarCryptoWrapper.cs" />
<Compile Include="Common\Rar\RarRijndael.cs" />
<Compile Include="Common\SevenZip\CBindPair.cs" />
<Compile Include="Common\SevenZip\CCoderInfo.cs" />
<Compile Include="Common\SevenZip\CFileItem.cs" />
@@ -150,8 +152,10 @@
<Compile Include="Common\Zip\SeekableZipHeaderFactory.cs" />
<Compile Include="Common\Zip\StreamingZipFilePart.cs" />
<Compile Include="Common\Zip\StreamingZipHeaderFactory.cs" />
<Compile Include="Common\Zip\WinzipAesCryptoStream.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Common\Zip\WinzipAesEncryptionData.cs" />
<Compile Include="Common\Zip\WinzipAesCryptoStream.cs" />
<Compile Include="Common\Zip\WinzipAesKeySize.cs" />
<Compile Include="Common\Zip\ZipVolume.cs" />
<Compile Include="Compressor\BZip2\BZip2Constants.cs" />
@@ -240,6 +244,7 @@
</Compile>
<Compile Include="IO\ListeningStream.cs" />
<Compile Include="IO\NonDisposingStream.cs" />
<Compile Include="Common\Rar\RarCryptoBinaryReader.cs" />
<Compile Include="IO\RewindableStream.cs" />
<Compile Include="Reader\GZip\GZipReader.cs" />
<Compile Include="Reader\ReaderFactory.cs" />
@@ -250,7 +255,6 @@
<Compile Include="Compressor\Deflate\DeflateStream.cs" />
<Compile Include="Compressor\Deflate\Inflate.cs" />
<Compile Include="Compressor\Deflate\InfTree.cs" />
<Compile Include="Compressor\Deflate\ParallelDeflateOutputStream.cs" />
<Compile Include="Compressor\Deflate\Tree.cs" />
<Compile Include="Compressor\Deflate\Zlib.cs" />
<Compile Include="Compressor\Deflate\ZlibBaseStream.cs" />

Some files were not shown because too many files have changed in this diff Show More