mirror of
https://github.com/adamhathcock/sharpcompress.git
synced 2026-02-04 13:34:59 +00:00
Compare commits
53 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
00ce509b08 | ||
|
|
13ef1c3701 | ||
|
|
ee2d6216b7 | ||
|
|
a42414bdaa | ||
|
|
3e201053c6 | ||
|
|
46c03ce027 | ||
|
|
718dac1a31 | ||
|
|
137f2655a5 | ||
|
|
8109ae003d | ||
|
|
8325b919ce | ||
|
|
61c97faf6c | ||
|
|
2dc297394f | ||
|
|
7aa5d310f2 | ||
|
|
e3fb32aa3c | ||
|
|
65090b0fb0 | ||
|
|
3bbb407bdb | ||
|
|
404fa8c62d | ||
|
|
9cf8c1a747 | ||
|
|
0937c63a9e | ||
|
|
f367f489eb | ||
|
|
d78677186b | ||
|
|
9447c1ed71 | ||
|
|
a16219763b | ||
|
|
430263b672 | ||
|
|
cc902bcb2d | ||
|
|
a29f7d4500 | ||
|
|
f9194b645d | ||
|
|
c7f6b506b5 | ||
|
|
1ab89ba59c | ||
|
|
3370fadbd1 | ||
|
|
a73c831647 | ||
|
|
203a7beef7 | ||
|
|
6c2b447530 | ||
|
|
1e7d6dc4f5 | ||
|
|
37c4665630 | ||
|
|
d15c8785ac | ||
|
|
ab19dedf1f | ||
|
|
34190f6576 | ||
|
|
78cecda03a | ||
|
|
13de04ddd2 | ||
|
|
e1511bf3ba | ||
|
|
e78ead7bc3 | ||
|
|
bb2dcce57a | ||
|
|
c0b630c795 | ||
|
|
22d181e637 | ||
|
|
af8e4f9da8 | ||
|
|
ad421936dc | ||
|
|
1d10ea29da | ||
|
|
31f8c18bc5 | ||
|
|
692bebf658 | ||
|
|
0ab103e1b1 | ||
|
|
483f2e564a | ||
|
|
ea6661ee8e |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -6,4 +6,5 @@ bin/
|
||||
*.user
|
||||
TestArchives/Scratch/
|
||||
TestArchives/Scratch2/
|
||||
TestResults/
|
||||
*.nupkg
|
||||
|
||||
@@ -2,21 +2,21 @@
|
||||
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
|
||||
<metadata>
|
||||
<id>sharpcompress</id>
|
||||
<version>0.9</version>
|
||||
<version>0.10.1.3</version>
|
||||
<title>SharpCompress - Pure C# Decompression/Compression</title>
|
||||
<authors>Adam Hathcock</authors>
|
||||
<owners>Adam Hathcock</owners>
|
||||
<licenseUrl>http://sharpcompress.codeplex.com/license</licenseUrl>
|
||||
<projectUrl>http://sharpcompress.codeplex.com/</projectUrl>
|
||||
<projectUrl>https://github.com/adamhathcock/sharpcompress</projectUrl>
|
||||
<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>
|
||||
<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" />
|
||||
<file src="..\bin\Full\SharpCompress.dll" target="lib\net40\SharpCompress.dll" />
|
||||
<file src="..\bin\WindowsStore\SharpCompress.dll" target="lib\netcore45\SharpCompress.dll" />
|
||||
<file src="..\bin\Portable\SharpCompress.dll" target="lib\portable-net4+sl4+wp7+win8\SharpCompress.dll" />
|
||||
</files>
|
||||
</package>
|
||||
26
README.md
26
README.md
@@ -16,9 +16,31 @@ Want to contribute?
|
||||
I'm always looking for help or ideas. Please submit code or email with ideas. Unfortunately, just letting me know you'd like to help is not enough because I really have no overall plan of what needs to be done. I'll definitely accept code submissions and add you as a member of the project!
|
||||
|
||||
TODOs (always lots):
|
||||
* RAR 5 support
|
||||
* 7Zip writing
|
||||
* RAR Decryption
|
||||
* Zip64
|
||||
* Multi-volume Zip support.
|
||||
|
||||
7Zip implementation based on: https://code.google.com/p/managed-lzma/
|
||||
Version 0.10.1:
|
||||
==============
|
||||
- Fixed 7Zip extraction performance problem
|
||||
|
||||
Version 0.10:
|
||||
==============
|
||||
- Added support for RAR Decryption (thanks to https://github.com/hrasyid)
|
||||
- Embedded some BouncyCastle crypto classes to allow RAR Decryption and Winzip AES Decryption in Portable and Windows Store DLLs
|
||||
- Built in Release (I think)
|
||||
|
||||
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.
|
||||
60
SharpCompress.Test/Rar/RarHeaderFactoryTest.cs
Normal file
60
SharpCompress.Test/Rar/RarHeaderFactoryTest.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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()
|
||||
{
|
||||
|
||||
@@ -61,6 +61,17 @@ namespace SharpCompress.Test
|
||||
ArchiveFileRead("7Zip.BZip2.7z");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void SevenZipArchive_LZMA2_SFX_PathRead()
|
||||
{
|
||||
ArchiveFileRead("7Zip.LZMA2.sfx.exe");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void SevenZipArchive_LZMA2_SFX_StreamRead() {
|
||||
ArchiveStreamRead("7Zip.LZMA2.sfx.exe");
|
||||
}
|
||||
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(IndexOutOfRangeException))]
|
||||
|
||||
113
SharpCompress.Test/SharpCompress.Test.Portable.csproj
Normal file
113
SharpCompress.Test/SharpCompress.Test.Portable.csproj
Normal 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>
|
||||
@@ -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" />
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using SharpCompress.Common;
|
||||
using SharpCompress.Reader;
|
||||
@@ -9,12 +11,13 @@ namespace SharpCompress.Test
|
||||
{
|
||||
public class TestBase
|
||||
{
|
||||
protected const string TEST_BASE_PATH = @"C:\Git\sharpcompress";
|
||||
protected static readonly string TEST_ARCHIVES_PATH = Path.Combine(TEST_BASE_PATH, "TestArchives", "Archives");
|
||||
protected static readonly string ORIGINAL_FILES_PATH = Path.Combine(TEST_BASE_PATH, "TestArchives", "Original");
|
||||
protected static readonly string MISC_TEST_FILES_PATH = Path.Combine(TEST_BASE_PATH, "TestArchives", "MiscTest");
|
||||
protected static readonly string SCRATCH_FILES_PATH = Path.Combine(TEST_BASE_PATH, "TestArchives", "Scratch");
|
||||
protected static readonly string SCRATCH2_FILES_PATH = Path.Combine(TEST_BASE_PATH, "TestArchives", "Scratch2");
|
||||
//protected const string TEST_BASE_PATH = @"C:\Git\sharpcompress";
|
||||
protected static string TEST_BASE_PATH=null;
|
||||
protected static string TEST_ARCHIVES_PATH;
|
||||
protected static string ORIGINAL_FILES_PATH;
|
||||
protected static string MISC_TEST_FILES_PATH;
|
||||
protected static string SCRATCH_FILES_PATH;
|
||||
protected static string SCRATCH2_FILES_PATH;
|
||||
|
||||
protected static IEnumerable<string> GetRarArchives()
|
||||
{
|
||||
@@ -122,14 +125,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 +151,35 @@ namespace SharpCompress.Test
|
||||
Assert.IsFalse(archive2.MoveToNextEntry());
|
||||
}
|
||||
}
|
||||
|
||||
private static readonly object testLock = new object();
|
||||
|
||||
private TestContext ctx;
|
||||
public TestContext TestContext {
|
||||
get {
|
||||
return ctx;
|
||||
}
|
||||
set {
|
||||
ctx = value;
|
||||
}
|
||||
}
|
||||
|
||||
[TestInitialize]
|
||||
public void TestSetup()
|
||||
{
|
||||
Monitor.Enter(testLock);
|
||||
TEST_BASE_PATH = Path.GetDirectoryName(Path.GetDirectoryName(ctx.TestDir));
|
||||
TEST_ARCHIVES_PATH = Path.Combine(TEST_BASE_PATH, "TestArchives", "Archives");
|
||||
ORIGINAL_FILES_PATH = Path.Combine(TEST_BASE_PATH, "TestArchives", "Original");
|
||||
MISC_TEST_FILES_PATH = Path.Combine(TEST_BASE_PATH, "TestArchives", "MiscTest");
|
||||
SCRATCH_FILES_PATH = Path.Combine(TEST_BASE_PATH, "TestArchives", "Scratch");
|
||||
SCRATCH2_FILES_PATH = Path.Combine(TEST_BASE_PATH, "TestArchives", "Scratch2");
|
||||
}
|
||||
|
||||
[TestCleanup]
|
||||
public void TestCleanup()
|
||||
{
|
||||
Monitor.Exit(testLock);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,17 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpCompress.Portable", "S
|
||||
EndProject
|
||||
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.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
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{F18F1765-4A02-42FD-9BEF-F0E2FCBD9D17}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
NuGet\sharpcompress.nuspec = NuGet\sharpcompress.nuspec
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@@ -31,8 +42,21 @@ Global
|
||||
{1DF6D83C-31FF-47B6-82FE-C4603BE916B5}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{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
|
||||
{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}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{EFDCAF57-FD4D-4E5D-A3D5-F26B875817ED}.Release|Any CPU.Build.0 = 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}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{E9C3C94B-FB27-4B4F-B225-57513C254D37}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(NestedProjects) = preSolution
|
||||
{EFDCAF57-FD4D-4E5D-A3D5-F26B875817ED} = {932BBFCC-76E3-45FF-90CA-6BE4FBF4A097}
|
||||
{E9C3C94B-FB27-4B4F-B225-57513C254D37} = {932BBFCC-76E3-45FF-90CA-6BE4FBF4A097}
|
||||
{15679D7A-F22C-4943-87FF-BF5C76C4A6FD} = {932BBFCC-76E3-45FF-90CA-6BE4FBF4A097}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
||||
6
SharpCompress.sln.DotSettings
Normal file
6
SharpCompress.sln.DotSettings
Normal 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>
|
||||
@@ -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);
|
||||
@@ -43,10 +43,12 @@ namespace SharpCompress.Archive
|
||||
return TarArchive.Open(stream, options);
|
||||
}
|
||||
stream.Seek(0, SeekOrigin.Begin);
|
||||
if (SevenZipArchive.IsSevenZipFile(stream))
|
||||
{
|
||||
stream.Seek(0, SeekOrigin.Begin);
|
||||
return SevenZipArchive.Open(stream, options);
|
||||
long offset = SevenZipArchive.FindSignature(stream);
|
||||
if (offset > -1) {
|
||||
stream.Seek(offset, SeekOrigin.Begin);
|
||||
return SevenZipArchive.Open(stream, options);
|
||||
}
|
||||
}
|
||||
stream.Seek(0, SeekOrigin.Begin);
|
||||
if (GZipArchive.IsGZipFile(stream))
|
||||
@@ -54,7 +56,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)
|
||||
|
||||
@@ -145,7 +145,7 @@ namespace SharpCompress.Archive.SevenZip
|
||||
{
|
||||
if (database == null)
|
||||
{
|
||||
stream.Position = 0;
|
||||
stream.Seek(FindSignature(stream),SeekOrigin.Begin);
|
||||
var reader = new ArchiveReader();
|
||||
reader.Open(stream);
|
||||
database = reader.ReadDatabase(null);
|
||||
@@ -157,7 +157,7 @@ namespace SharpCompress.Archive.SevenZip
|
||||
{
|
||||
try
|
||||
{
|
||||
return SignatureMatch(stream);
|
||||
return FindSignature(stream)>-1;
|
||||
}
|
||||
catch
|
||||
{
|
||||
@@ -165,13 +165,27 @@ namespace SharpCompress.Archive.SevenZip
|
||||
}
|
||||
}
|
||||
|
||||
private static readonly byte[] SIGNATURE = new byte[] {(byte) '7', (byte) 'z', 0xBC, 0xAF, 0x27, 0x1C};
|
||||
|
||||
private static bool SignatureMatch(Stream stream)
|
||||
{
|
||||
private static readonly byte[] SIGNATURE = {(byte) '7', (byte) 'z', 0xBC, 0xAF, 0x27, 0x1C};
|
||||
const int MAX_BYTES_TO_ARCHIVE = 0x40000;
|
||||
public static long FindSignature(Stream stream){
|
||||
BinaryReader reader = new BinaryReader(stream);
|
||||
byte[] signatureBytes = reader.ReadBytes(6);
|
||||
return signatureBytes.BinaryEquals(SIGNATURE);
|
||||
int j = 0;
|
||||
long match=-1;
|
||||
var maxPos = Math.Min(MAX_BYTES_TO_ARCHIVE+SIGNATURE.Length, stream.Length);
|
||||
for (; stream.Position < maxPos; ) {
|
||||
var bt = reader.ReadByte();
|
||||
if (bt == SIGNATURE[j]){
|
||||
if (j == SIGNATURE.Length-1){
|
||||
match = stream.Position - j-1;
|
||||
break;
|
||||
}
|
||||
j++;
|
||||
continue;
|
||||
}
|
||||
|
||||
j = 0;
|
||||
}
|
||||
return match;
|
||||
}
|
||||
|
||||
protected override IReader CreateReaderForSolidExtraction()
|
||||
|
||||
@@ -1,20 +1,19 @@
|
||||
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")]
|
||||
[assembly: AssemblyTitle("SharpCompress.Portable")]
|
||||
[assembly: AssemblyProduct("SharpCompress.Portable")]
|
||||
#else
|
||||
|
||||
[assembly: AssemblyTitle("SharpCompress")]
|
||||
[assembly: AssemblyProduct("SharpCompress")]
|
||||
[assembly:
|
||||
InternalsVisibleTo(
|
||||
"SharpCompress.Test, PublicKey=002400000480000094000000060200000024000052534131000400000100010005d6ae1b0f6875393da83c920a5b9408f5191aaf4e8b3c2c476ad2a11f5041ecae84ce9298bc4c203637e2fd3a80ad5378a9fa8da1363e98cea45c73969198a4b64510927c910001491cebbadf597b22448ad103b0a4007e339faf8fe8665dcdb70d65b27ac05b1977c0655fad06b372b820ecbdccf10a0f214fee0986dfeded"
|
||||
"SharpCompress.Test"
|
||||
)]
|
||||
[assembly:
|
||||
InternalsVisibleTo(
|
||||
"SharpCompress.Test.Portable"
|
||||
)]
|
||||
#endif
|
||||
#endif
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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); }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
@@ -107,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)
|
||||
{
|
||||
@@ -119,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:
|
||||
{
|
||||
@@ -162,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:
|
||||
|
||||
82
SharpCompress/Common/Rar/RarCryptoBinaryReader.cs
Normal file
82
SharpCompress/Common/Rar/RarCryptoBinaryReader.cs
Normal 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
108
SharpCompress/Common/Rar/RarCryptoWrapper.cs
Normal file
108
SharpCompress/Common/Rar/RarCryptoWrapper.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
113
SharpCompress/Common/Rar/RarRijndael.Portable.cs
Normal file
113
SharpCompress/Common/Rar/RarRijndael.Portable.cs
Normal 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()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
112
SharpCompress/Common/Rar/RarRijndael.cs
Normal file
112
SharpCompress/Common/Rar/RarRijndael.cs
Normal 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -941,6 +941,7 @@ namespace SharpCompress.Common.SevenZip
|
||||
|
||||
#region Public Methods
|
||||
|
||||
const int HEADER_SIZE=0x20;
|
||||
public void Open(Stream stream)
|
||||
{
|
||||
Close();
|
||||
@@ -949,13 +950,14 @@ namespace SharpCompress.Common.SevenZip
|
||||
_streamEnding = stream.Length;
|
||||
|
||||
// TODO: Check Signature!
|
||||
_header = new byte[0x20];
|
||||
for (int offset = 0; offset < 0x20; )
|
||||
_header = new byte[HEADER_SIZE];
|
||||
int delta;
|
||||
for (int offset = 0; offset < HEADER_SIZE; offset += delta)
|
||||
{
|
||||
int delta = stream.Read(_header, offset, 0x20 - offset);
|
||||
delta = stream.Read(_header, offset, HEADER_SIZE - offset);
|
||||
if (delta == 0)
|
||||
throw new EndOfStreamException();
|
||||
offset += delta;
|
||||
throw new EndOfStreamException("ArchiveReader.Open : unable to read");
|
||||
|
||||
}
|
||||
|
||||
_stream = stream;
|
||||
@@ -995,7 +997,7 @@ namespace SharpCompress.Common.SevenZip
|
||||
crc = CRC.Finish(crc);
|
||||
|
||||
if (crc != crcFromArchive)
|
||||
throw new InvalidOperationException();
|
||||
throw new InvalidOperationException("Bad CRC");
|
||||
|
||||
db.StartPositionAfterHeader = _streamOrigin + 0x20;
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
170
SharpCompress/Common/Zip/WinzipAesCryptoStream.Portable.cs
Normal file
170
SharpCompress/Common/Zip/WinzipAesCryptoStream.Portable.cs
Normal 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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 !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]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
68
SharpCompress/Common/Zip/WinzipAesEncryptionData.Portable.cs
Normal file
68
SharpCompress/Common/Zip/WinzipAesEncryptionData.Portable.cs
Normal 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");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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:
|
||||
@@ -134,7 +134,7 @@ namespace SharpCompress.Common.Zip
|
||||
{
|
||||
if ((Header.CompressedSize == 0)
|
||||
#if !PORTABLE && !NETFX_CORE
|
||||
&& ((Header.PkwareTraditionalEncryptionData != null)
|
||||
&& ((Header.PkwareTraditionalEncryptionData != null)
|
||||
|| (Header.WinzipAesEncryptionData != null)))
|
||||
#else
|
||||
&& (Header.PkwareTraditionalEncryptionData != null))
|
||||
@@ -160,8 +160,7 @@ namespace SharpCompress.Common.Zip
|
||||
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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -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;
|
||||
|
||||
|
||||
@@ -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; }
|
||||
|
||||
@@ -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; }
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.IO;
|
||||
using SharpCompress.Common.SevenZip;
|
||||
using SharpCompress.Compressor.LZMA.Utilites;
|
||||
using SharpCompress.IO;
|
||||
|
||||
namespace SharpCompress.Compressor.LZMA
|
||||
{
|
||||
@@ -158,12 +159,10 @@ namespace SharpCompress.Compressor.LZMA
|
||||
if (!folderInfo.CheckStructure())
|
||||
throw new NotSupportedException("Unsupported stream binding structure.");
|
||||
|
||||
// We have multiple views into the same stream which will be used by several threads - need to sync those.
|
||||
object sync = new object();
|
||||
Stream[] inStreams = new Stream[folderInfo.PackStreams.Count];
|
||||
for (int j = 0; j < folderInfo.PackStreams.Count; j++)
|
||||
{
|
||||
inStreams[j] = new SyncStreamView(sync, inStream, startPos, packSizes[j]);
|
||||
inStreams[j] = new ReadOnlySubStream(inStream, startPos, packSizes[j]);
|
||||
startPos += packSizes[j];
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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; }
|
||||
|
||||
@@ -1,108 +0,0 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace SharpCompress.Compressor.LZMA.Utilites
|
||||
{
|
||||
/// <summary>
|
||||
/// Allows reading the same stream from multiple threads by synchronizing read access.
|
||||
/// </summary>
|
||||
internal class SyncStreamView : Stream
|
||||
{
|
||||
private object mSync;
|
||||
private Stream mStream;
|
||||
private long mOrigin;
|
||||
private long mEnding;
|
||||
private long mOffset;
|
||||
|
||||
public SyncStreamView(object sync, Stream stream, long origin, long length)
|
||||
{
|
||||
mSync = sync;
|
||||
mStream = stream;
|
||||
mOrigin = origin;
|
||||
mEnding = checked(origin + length);
|
||||
mOffset = 0;
|
||||
}
|
||||
|
||||
public override bool CanRead
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
public override bool CanSeek
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
public override bool CanWrite
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
public override void Flush()
|
||||
{
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
|
||||
public override long Length
|
||||
{
|
||||
get { return mEnding - mOrigin; }
|
||||
}
|
||||
|
||||
public override long Position
|
||||
{
|
||||
get { return mOffset; }
|
||||
set
|
||||
{
|
||||
if (value < 0 || value > Length)
|
||||
throw new ArgumentOutOfRangeException("value");
|
||||
|
||||
mOffset = value;
|
||||
}
|
||||
}
|
||||
|
||||
public override int Read(byte[] buffer, int offset, int count)
|
||||
{
|
||||
long remaining = mEnding - mOrigin - mOffset;
|
||||
if (count > remaining)
|
||||
count = (int) remaining;
|
||||
|
||||
if (count == 0)
|
||||
return 0;
|
||||
|
||||
int delta;
|
||||
lock (mSync)
|
||||
{
|
||||
mStream.Position = mOrigin + mOffset;
|
||||
delta = mStream.Read(buffer, offset, count);
|
||||
}
|
||||
|
||||
mOffset += delta;
|
||||
return delta;
|
||||
}
|
||||
|
||||
public override long Seek(long offset, SeekOrigin origin)
|
||||
{
|
||||
switch (origin)
|
||||
{
|
||||
case SeekOrigin.Begin:
|
||||
return Position = offset;
|
||||
case SeekOrigin.Current:
|
||||
return Position += offset;
|
||||
case SeekOrigin.End:
|
||||
return Position = Length + offset;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException("origin");
|
||||
}
|
||||
}
|
||||
|
||||
public override void SetLength(long value)
|
||||
{
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
|
||||
public override void Write(byte[] buffer, int offset, int count)
|
||||
{
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,96 +0,0 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace master._7zip.Utilities
|
||||
{
|
||||
/// <remarks>
|
||||
/// This stream is a length-constrained wrapper around a cached stream so it does not dispose the inner stream.
|
||||
/// </remarks>
|
||||
internal class UnpackSubStream: Stream
|
||||
{
|
||||
private Stream mSource;
|
||||
private long mLength;
|
||||
private long mOffset;
|
||||
|
||||
internal UnpackSubStream(Stream source, long length)
|
||||
{
|
||||
mSource = source;
|
||||
mLength = length;
|
||||
}
|
||||
|
||||
public override bool CanRead
|
||||
{
|
||||
get { return mSource.CanRead; }
|
||||
}
|
||||
|
||||
public override bool CanSeek
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
public override bool CanWrite
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
public override void Flush()
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public override long Length
|
||||
{
|
||||
get { return mLength; }
|
||||
}
|
||||
|
||||
public override long Position
|
||||
{
|
||||
get { return mOffset; }
|
||||
set { throw new NotSupportedException(); }
|
||||
}
|
||||
|
||||
public override int Read(byte[] buffer, int offset, int count)
|
||||
{
|
||||
if(buffer == null)
|
||||
throw new ArgumentNullException("buffer");
|
||||
|
||||
if(offset < 0 || offset > buffer.Length)
|
||||
throw new ArgumentOutOfRangeException("offset");
|
||||
|
||||
if(count < 0 || count > buffer.Length - offset)
|
||||
throw new ArgumentOutOfRangeException("count");
|
||||
|
||||
if(count > mLength - mOffset)
|
||||
count = (int)(mLength - mOffset);
|
||||
|
||||
if(count == 0)
|
||||
return 0;
|
||||
|
||||
int processed = mSource.Read(buffer, offset, count);
|
||||
if(processed == 0)
|
||||
throw new EndOfStreamException("Decoded stream ended prematurely, unpacked data is corrupt.");
|
||||
|
||||
mOffset += processed;
|
||||
return processed;
|
||||
}
|
||||
|
||||
public override long Seek(long offset, SeekOrigin origin)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public override void SetLength(long value)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public override void Write(byte[] buffer, int offset, int count)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
3145
SharpCompress/Crypto/BigInteger.cs
Normal file
3145
SharpCompress/Crypto/BigInteger.cs
Normal file
File diff suppressed because it is too large
Load Diff
376
SharpCompress/Crypto/BufferedBlockCipher.cs
Normal file
376
SharpCompress/Crypto/BufferedBlockCipher.cs
Normal 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
113
SharpCompress/Crypto/BufferedCipherBase.cs
Normal file
113
SharpCompress/Crypto/BufferedCipherBase.cs
Normal 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();
|
||||
}
|
||||
}
|
||||
25
SharpCompress/Crypto/CryptoException.cs
Normal file
25
SharpCompress/Crypto/CryptoException.cs
Normal 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)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
33
SharpCompress/Crypto/DataLengthException.cs
Normal file
33
SharpCompress/Crypto/DataLengthException.cs
Normal 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)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
115
SharpCompress/Crypto/GeneralDigest.cs
Normal file
115
SharpCompress/Crypto/GeneralDigest.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
134
SharpCompress/Crypto/HMac.cs
Normal file
134
SharpCompress/Crypto/HMac.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
35
SharpCompress/Crypto/IBlockCipher.cs
Normal file
35
SharpCompress/Crypto/IBlockCipher.cs
Normal 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();
|
||||
}
|
||||
}
|
||||
44
SharpCompress/Crypto/IBufferedCipher.cs
Normal file
44
SharpCompress/Crypto/IBufferedCipher.cs
Normal 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();
|
||||
}
|
||||
}
|
||||
7
SharpCompress/Crypto/ICipherParameters.cs
Normal file
7
SharpCompress/Crypto/ICipherParameters.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
|
||||
namespace Org.BouncyCastle.Crypto
|
||||
{
|
||||
public interface ICipherParameters
|
||||
{
|
||||
}
|
||||
}
|
||||
56
SharpCompress/Crypto/IDigest.cs
Normal file
56
SharpCompress/Crypto/IDigest.cs
Normal 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();
|
||||
}
|
||||
}
|
||||
64
SharpCompress/Crypto/IMac.cs
Normal file
64
SharpCompress/Crypto/IMac.cs
Normal 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();
|
||||
}
|
||||
}
|
||||
40
SharpCompress/Crypto/KeyParameter.cs
Normal file
40
SharpCompress/Crypto/KeyParameter.cs
Normal 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
119
SharpCompress/Crypto/PBKDF2.cs
Normal file
119
SharpCompress/Crypto/PBKDF2.cs
Normal 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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
129
SharpCompress/Crypto/Pack.cs
Normal file
129
SharpCompress/Crypto/Pack.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
740
SharpCompress/Crypto/RijndaelEngine.cs
Normal file
740
SharpCompress/Crypto/RijndaelEngine.cs
Normal 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]);
|
||||
}
|
||||
}
|
||||
}
|
||||
255
SharpCompress/Crypto/Sha1Digest.cs
Normal file
255
SharpCompress/Crypto/Sha1Digest.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
@@ -65,45 +66,49 @@ namespace SharpCompress.IO
|
||||
#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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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; }
|
||||
|
||||
@@ -5,8 +5,17 @@ namespace SharpCompress.IO
|
||||
internal class ReadOnlySubStream : Stream
|
||||
{
|
||||
public ReadOnlySubStream(Stream stream, long bytesToRead)
|
||||
: this(stream, null, bytesToRead)
|
||||
{
|
||||
}
|
||||
|
||||
public ReadOnlySubStream(Stream stream, long? origin, long bytesToRead)
|
||||
{
|
||||
Stream = stream;
|
||||
if (origin != null)
|
||||
{
|
||||
stream.Position = origin.Value;
|
||||
}
|
||||
BytesLeftToRead = bytesToRead;
|
||||
}
|
||||
|
||||
@@ -57,7 +66,7 @@ namespace SharpCompress.IO
|
||||
{
|
||||
if (BytesLeftToRead < count)
|
||||
{
|
||||
count = (int) BytesLeftToRead;
|
||||
count = (int)BytesLeftToRead;
|
||||
}
|
||||
int read = Stream.Read(buffer, offset, count);
|
||||
if (read > 0)
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,19 +7,20 @@
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>SharpCompress</RootNamespace>
|
||||
<AssemblyName>SharpCompress.Portable</AssemblyName>
|
||||
<AssemblyName>SharpCompress</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<TargetFrameworkProfile>Profile1</TargetFrameworkProfile>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\sharpcompress\</SolutionDir>
|
||||
<BaseIntermediateOutputPath>obj\Portable\</BaseIntermediateOutputPath>
|
||||
<RestorePackages>true</RestorePackages>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\bin\</OutputPath>
|
||||
<OutputPath>..\bin\Portable\</OutputPath>
|
||||
<DefineConstants>TRACE;DEBUG;PORTABLE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
@@ -28,7 +29,7 @@
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>..\bin\</OutputPath>
|
||||
<OutputPath>..\bin\Portable\</OutputPath>
|
||||
<DefineConstants>TRACE;PORTABLE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
@@ -111,8 +112,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 +137,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 +153,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 +173,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" />
|
||||
@@ -198,8 +204,6 @@
|
||||
<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\H\FreqData.cs" />
|
||||
<Compile Include="Compressor\PPMd\H\ModelPPM.cs" />
|
||||
@@ -254,6 +258,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" />
|
||||
|
||||
399
SharpCompress/SharpCompress.PortableTest.csproj
Normal file
399
SharpCompress/SharpCompress.PortableTest.csproj
Normal file
@@ -0,0 +1,399 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<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>{EFDCAF57-FD4D-4E5D-A3D5-F26B875817ED}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>SharpCompress</RootNamespace>
|
||||
<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>
|
||||
<SccLocalPath>
|
||||
</SccLocalPath>
|
||||
<SccAuxPath>
|
||||
</SccAuxPath>
|
||||
<SccProvider>
|
||||
</SccProvider>
|
||||
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\sharpcompress\</SolutionDir>
|
||||
<RestorePackages>true</RestorePackages>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\bin\</OutputPath>
|
||||
<DefineConstants>TRACE;DEBUG;DISABLE_TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<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</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<DocumentationFile>..\bin\SharpCompress.PortableTest.xml</DocumentationFile>
|
||||
<NoWarn>1591</NoWarn>
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<SignAssembly>true</SignAssembly>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<AssemblyOriginatorKeyFile>SharpCompress.pfx</AssemblyOriginatorKeyFile>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<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\IArchiveEntry.cs" />
|
||||
<Compile Include="Archive\Rar\RarArchiveEntryFactory.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="Common\ArchiveException.cs" />
|
||||
<Compile Include="Common\ArchiveExtractionEventArgs.cs" />
|
||||
<Compile Include="Common\CompressedBytesReadEventArgs.cs" />
|
||||
<Compile Include="Common\CompressionInfo.cs" />
|
||||
<Compile Include="Common\CompressionType.cs" />
|
||||
<Compile Include="Common\FilePartExtractionBeginEventArgs.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\IVolume.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\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\Zip\Headers\HeaderFlags.cs" />
|
||||
<Compile Include="Common\Zip\Headers\IgnoreHeader.cs" />
|
||||
<Compile Include="Common\Zip\Headers\SplitHeader.cs" />
|
||||
<Compile Include="Common\Zip\Headers\ZipFileEntry..cs" />
|
||||
<Compile Include="Common\Zip\Headers\ZipHeaderType.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.Portable.cs" />
|
||||
<Compile Include="Common\Zip\WinzipAesEncryptionData.Portable.cs" />
|
||||
<Compile Include="Common\Zip\WinzipAesKeySize.cs" />
|
||||
<Compile Include="Common\Zip\ZipVolume.cs" />
|
||||
<Compile Include="Compressor\BZip2\BZip2Constants.cs" />
|
||||
<Compile Include="Compressor\BZip2\BZip2Stream.cs" />
|
||||
<Compile Include="Compressor\BZip2\CBZip2InputStream.cs" />
|
||||
<Compile Include="Compressor\BZip2\CBZip2OutputStream.cs" />
|
||||
<Compile Include="Compressor\BZip2\CRC.cs" />
|
||||
<Compile Include="Compressor\CompressionMode.cs" />
|
||||
<Compile Include="Compressor\Deflate\FlushType.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\DecoderStream.cs" />
|
||||
<Compile Include="Compressor\LZMA\Registry.cs" />
|
||||
<Compile Include="Compressor\LZMA\ICoder.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\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\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" />
|
||||
<Compile Include="Compressor\PPMd\H\PPMContext.cs" />
|
||||
<Compile Include="Compressor\PPMd\H\RangeCoder.cs" />
|
||||
<Compile Include="Compressor\PPMd\H\RarMemBlock.cs" />
|
||||
<Compile Include="Compressor\PPMd\H\RarNode.cs" />
|
||||
<Compile Include="Compressor\PPMd\H\SEE2Context.cs" />
|
||||
<Compile Include="Compressor\PPMd\H\State.cs" />
|
||||
<Compile Include="Compressor\PPMd\H\StateRef.cs" />
|
||||
<Compile Include="Compressor\PPMd\H\SubAllocator.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\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="Utility.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.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>
|
||||
<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">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
@@ -10,16 +10,17 @@
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>SharpCompress</RootNamespace>
|
||||
<AssemblyName>SharpCompress.WindowsStore</AssemblyName>
|
||||
<AssemblyName>SharpCompress</AssemblyName>
|
||||
<DefaultLanguage>en-US</DefaultLanguage>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<ProjectTypeGuids>{BC8A1FFA-BEE3-4634-8014-F334798102B3};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<BaseIntermediateOutputPath>obj\WindowsStore\</BaseIntermediateOutputPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\bin\</OutputPath>
|
||||
<OutputPath>..\bin\WindowsStore\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE;NETFX_CORE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
@@ -27,77 +28,11 @@
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<OutputPath>..\bin\WindowsStore\</OutputPath>
|
||||
<DefineConstants>TRACE;NETFX_CORE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<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 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>
|
||||
<!-- A reference to the entire .Net Framework and Windows SDK are automatically included -->
|
||||
<Compile Include="Archive\AbstractArchive.cs" />
|
||||
@@ -167,8 +102,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" />
|
||||
@@ -204,6 +142,9 @@
|
||||
<Compile Include="Common\Zip\SeekableZipHeaderFactory.cs" />
|
||||
<Compile Include="Common\Zip\StreamingZipFilePart.cs" />
|
||||
<Compile Include="Common\Zip\StreamingZipHeaderFactory.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" />
|
||||
@@ -253,8 +194,6 @@
|
||||
<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\H\FreqData.cs" />
|
||||
<Compile Include="Compressor\PPMd\H\ModelPPM.cs" />
|
||||
@@ -309,6 +248,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\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" />
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
<UseApplicationTrust>false</UseApplicationTrust>
|
||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
|
||||
<BaseIntermediateOutputPath>obj\Full\</BaseIntermediateOutputPath>
|
||||
<SccProjectName>
|
||||
</SccProjectName>
|
||||
<SccLocalPath>
|
||||
@@ -49,7 +50,7 @@
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\bin\</OutputPath>
|
||||
<OutputPath>..\bin\Full\</OutputPath>
|
||||
<DefineConstants>TRACE;DEBUG;DISABLE_TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
@@ -57,18 +58,20 @@
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<NoWarn>1591</NoWarn>
|
||||
<DocumentationFile>..\bin\SharpCompress.XML</DocumentationFile>
|
||||
<DocumentationFile>
|
||||
</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>..\bin\</OutputPath>
|
||||
<OutputPath>..\bin\Full\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<DocumentationFile>..\bin\SharpCompress.xml</DocumentationFile>
|
||||
<DocumentationFile>
|
||||
</DocumentationFile>
|
||||
<NoWarn>1591</NoWarn>
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
</PropertyGroup>
|
||||
@@ -126,6 +129,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 +155,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" />
|
||||
@@ -205,9 +212,6 @@
|
||||
<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>
|
||||
@@ -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" />
|
||||
|
||||
@@ -11,5 +11,5 @@ using System.Runtime.InteropServices;
|
||||
[assembly: AssemblyCopyright("Copyright © Adam Hathcock")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
[assembly: AssemblyVersion("0.9.0.0")]
|
||||
[assembly: AssemblyFileVersion("0.9.0.0")]
|
||||
[assembly: AssemblyVersion("0.10.1.3")]
|
||||
[assembly: AssemblyFileVersion("0.10.1.3")]
|
||||
129
SharpCompress/sharpcompress.DotSettings
Normal file
129
SharpCompress/sharpcompress.DotSettings
Normal file
@@ -0,0 +1,129 @@
|
||||
<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:Boolean x:Key="/Default/CodeEditing/ContextActionTable/DisabledContextActions/=JetBrains_002EReSharper_002EIntentions_002ECSharp_002EContextActions_002ECatchToCatchExceptionAction/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeEditing/Intellisense/CodeCompletion/AutoCompleteBasicCompletion/@EntryValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeEditing/Intellisense/CodeCompletion/IntelliSenseCompletingCharacters/IntelliSenseCompletingCharactersSettingCSharp/UpgradedFromVSSettings/@EntryValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeEditing/Intellisense/CodeCompletion/IntellisenseEnabled/IntellisenseEnabledSettingCSharp/IntellisenseEnabled/@EntryValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeEditing/Intellisense/CodeCompletion/IntellisenseEnabled/IntellisenseEnabledSettingXaml/IntellisenseEnabled/@EntryValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeEditing/Intellisense/LookupWindow/ShowSummary/@EntryValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeEditing/Localization/CSharpLocalizationOptions/DontAnalyseVerbatimStrings/@EntryValue">False</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/ExcludedFiles/FileMasksToSkip/=_002A_002Ecpp/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/ExcludedFiles/FileMasksToSkip/=_002A_002Eh/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:String x:Key="/Default/CodeInspection/Highlighting/CodeIssueFilter/IssueTypesToHide/=_003CConfigurableSeverity_0020Id_003D_0022ClassCanBeSealed_002EGlobal_0022_0020_002F_003E/@EntryIndexedValue">DoHide</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/Highlighting/CodeIssueFilter/IssueTypesToHide/=_003CConfigurableSeverity_0020Id_003D_0022ClassCanBeSealed_002ELocal_0022_0020_002F_003E/@EntryIndexedValue">DoHide</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/Highlighting/CodeIssueFilter/IssueTypesToHide/=_003CConfigurableSeverity_0020Id_003D_0022ConvertIfStatementToReturnStatement_0022_0020_002F_003E/@EntryIndexedValue">DoHide</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/Highlighting/CodeIssueFilter/IssueTypesToHide/=_003CConfigurableSeverity_0020Id_003D_0022ConvertIfStatementToSwitchStatement_0022_0020_002F_003E/@EntryIndexedValue">DoHide</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/Highlighting/CodeIssueFilter/IssueTypesToHide/=_003CConfigurableSeverity_0020Id_003D_0022ConvertToAutoPropertyWithPrivateSetter_0022_0020_002F_003E/@EntryIndexedValue">DoHide</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/Highlighting/CodeIssueFilter/IssueTypesToHide/=_003CConfigurableSeverity_0020Id_003D_0022InvertIf_0022_0020_002F_003E/@EntryIndexedValue">DoHide</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/Highlighting/CodeIssueFilter/IssueTypesToHide/=_003CConfigurableSeverity_0020Id_003D_0022LoopCanBePartlyConvertedToQuery_0022_0020_002F_003E/@EntryIndexedValue">DoHide</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/Highlighting/CodeIssueFilter/IssueTypesToHide/=_003CConfigurableSeverity_0020Id_003D_0022MemberCanBeInternal_0022_0020_002F_003E/@EntryIndexedValue">DoHide</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/Highlighting/CodeIssueFilter/IssueTypesToHide/=_003CConfigurableSeverity_0020Id_003D_0022MemberCanBeMadeStatic_002EGlobal_0022_0020_002F_003E/@EntryIndexedValue">DoHide</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/Highlighting/CodeIssueFilter/IssueTypesToHide/=_003CConfigurableSeverity_0020Id_003D_0022MemberCanBeMadeStatic_002ELocal_0022_0020_002F_003E/@EntryIndexedValue">DoHide</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/Highlighting/CodeIssueFilter/IssueTypesToHide/=_003CConfigurableSeverity_0020Id_003D_0022RedundantArgumentNameForLiteralExpression_0022_0020_002F_003E/@EntryIndexedValue">DoHide</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/Highlighting/CodeIssueFilter/IssueTypesToHide/=_003CConfigurableSeverity_0020Id_003D_0022RedundantToStringCallForValueType_0022_0020_002F_003E/@EntryIndexedValue">DoHide</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/Highlighting/CodeIssueFilter/IssueTypesToHide/=_003CConfigurableSeverity_0020Id_003D_0022SimilarAnonymousTypeNearby_0022_0020_002F_003E/@EntryIndexedValue">DoHide</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/Highlighting/CodeIssueFilter/IssueTypesToHide/=_003CConfigurableSeverity_0020Id_003D_0022SuggestBaseTypeForParameter_0022_0020_002F_003E/@EntryIndexedValue">DoHide</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/Highlighting/CodeIssueFilter/IssueTypesToHide/=_003CConfigurableSeverity_0020Id_003D_0022SuggestUseVarKeywordEverywhere_0022_0020_002F_003E/@EntryIndexedValue">DoHide</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/Highlighting/CodeIssueFilter/IssueTypesToHide/=_003CConfigurableSeverity_0020Id_003D_0022TryStatementsCanBeMerged_0022_0020_002F_003E/@EntryIndexedValue">DoHide</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/Highlighting/CodeIssueFilter/IssueTypesToHide/=_003CConfigurableSeverity_0020Id_003D_0022UnknownCssVendorExtension_0022_0020_002F_003E/@EntryIndexedValue">DoHide</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/Highlighting/CodeIssueFilter/IssueTypesToHide/=_003CConfigurableSeverity_0020Id_003D_0022Xaml_002EBindingWithoutContextReferenceNotResolvedHighlighting_0022_0020_002F_003E/@EntryIndexedValue">DoHide</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/Highlighting/CodeIssueFilter/IssueTypesToHide/=_003CStaticSeverity_0020Severity_003D_00222_0022_0020Title_003D_0022Structural_0020Search_0020Hints_0022_0020GroupId_003D_0022StructuralSearch_0022_0020_002F_003E/@EntryIndexedValue">DoHide</s:String>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/Highlighting/IdentifierHighlightingEnabled/@EntryValue">True</s:Boolean>
|
||||
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=FieldCanBeMadeReadOnly_002EGlobal/@EntryIndexedValue">ERROR</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=FieldCanBeMadeReadOnly_002ELocal/@EntryIndexedValue">ERROR</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ImpureMethodCallOnReadonlyValueField/@EntryIndexedValue">ERROR</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=PossibleAssignmentToReadonlyField/@EntryIndexedValue">ERROR</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=RedundantThisQualifier/@EntryIndexedValue">ERROR</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=SpecifyACultureInStringConversionExplicitly/@EntryIndexedValue">DO_NOT_SHOW</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=SuggestUseVarKeywordEverywhere/@EntryIndexedValue">DO_NOT_SHOW</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=SuggestUseVarKeywordEvident/@EntryIndexedValue">DO_NOT_SHOW</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=UnassignedReadonlyField/@EntryIndexedValue">ERROR</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=UseObjectOrCollectionInitializer/@EntryIndexedValue">DO_NOT_SHOW</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/CodeCleanup/Profiles/=Adam_0020Clean/@EntryIndexedValue"><?xml version="1.0" encoding="utf-16"?><Profile name="Adam Clean"><CSUseVar><BehavourStyle>CAN_CHANGE_TO_IMPLICIT</BehavourStyle><LocalVariableStyle>ALWAYS_IMPLICIT</LocalVariableStyle><ForeachVariableStyle>ALWAYS_IMPLICIT</ForeachVariableStyle></CSUseVar><CSRemoveCodeRedundancies>True</CSRemoveCodeRedundancies><CSUseAutoProperty>True</CSUseAutoProperty><CSMakeFieldReadonly>True</CSMakeFieldReadonly><CSOptimizeUsings><OptimizeUsings>True</OptimizeUsings><EmbraceInRegion>False</EmbraceInRegion><RegionName></RegionName></CSOptimizeUsings><CSReformatCode>True</CSReformatCode><CSShortenReferences>True</CSShortenReferences><HtmlReformatCode>True</HtmlReformatCode><JsInsertSemicolon>True</JsInsertSemicolon><JsReformatCode>True</JsReformatCode><CSArrangeThisQualifier>True</CSArrangeThisQualifier></Profile></s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/CodeCleanup/Profiles/=NaaS_0020Clean/@EntryIndexedValue"><?xml version="1.0" encoding="utf-16"?><Profile name="NaaS Clean"><CSReformatCode>True</CSReformatCode><CSOptimizeUsings><OptimizeUsings>True</OptimizeUsings><EmbraceInRegion>False</EmbraceInRegion><RegionName></RegionName></CSOptimizeUsings><CSShortenReferences>True</CSShortenReferences><CSReorderTypeMembers>True</CSReorderTypeMembers><CSMakeFieldReadonly>True</CSMakeFieldReadonly><CSRemoveCodeRedundancies>True</CSRemoveCodeRedundancies><CSUseAutoProperty>True</CSUseAutoProperty></Profile></s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/CodeCleanup/RecentlyUsedProfile/@EntryValue">NaaS Clean</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/CodeCleanup/SilentCleanupProfile/@EntryValue">Default: Full Cleanup</s:String>
|
||||
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/ALIGN_FIRST_ARG_BY_PAREN/@EntryValue">True</s:Boolean>
|
||||
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/ANONYMOUS_METHOD_DECLARATION_BRACES/@EntryValue">NEXT_LINE</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/CASE_BLOCK_BRACES/@EntryValue">NEXT_LINE</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/FORCE_ATTRIBUTE_STYLE/@EntryValue">SEPARATE</s:String>
|
||||
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/FORCE_CHOP_COMPOUND_DO_EXPRESSION/@EntryValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/FORCE_CHOP_COMPOUND_IF_EXPRESSION/@EntryValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/FORCE_CHOP_COMPOUND_WHILE_EXPRESSION/@EntryValue">True</s:Boolean>
|
||||
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/FORCE_FIXED_BRACES_STYLE/@EntryValue">ALWAYS_ADD</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/FORCE_FOR_BRACES_STYLE/@EntryValue">ALWAYS_ADD</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/FORCE_FOREACH_BRACES_STYLE/@EntryValue">ALWAYS_ADD</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/FORCE_IFELSE_BRACES_STYLE/@EntryValue">ALWAYS_ADD</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/FORCE_USING_BRACES_STYLE/@EntryValue">ALWAYS_ADD</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/FORCE_WHILE_BRACES_STYLE/@EntryValue">ALWAYS_ADD</s:String>
|
||||
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/INDENT_ANONYMOUS_METHOD_BLOCK/@EntryValue">True</s:Boolean>
|
||||
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/INITIALIZER_BRACES/@EntryValue">NEXT_LINE</s:String>
|
||||
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_CONSTRUCTOR_INITIALIZER_ON_SAME_LINE/@EntryValue">False</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_FIELD_ATTRIBUTE_ON_SAME_LINE/@EntryValue">False</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_SIMPLE_ACCESSOR_ON_SINGLE_LINE/@EntryValue">False</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_SIMPLE_ANONYMOUSMETHOD_ON_SINGLE_LINE/@EntryValue">False</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_SIMPLE_INITIALIZER_ON_SINGLE_LINE/@EntryValue">False</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_SIMPLE_LINQ_ON_SINGLE_LINE/@EntryValue">False</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_TYPE_CONSTRAINTS_ON_SAME_LINE/@EntryValue">False</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_WHILE_ON_NEW_LINE/@EntryValue">True</s:Boolean>
|
||||
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/SIMPLE_EMBEDDED_STATEMENT_STYLE/@EntryValue">LINE_BREAK</s:String>
|
||||
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/SPACE_BEFORE_SIZEOF_PARENTHESES/@EntryValue">False</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/SPACE_BEFORE_TYPEOF_PARENTHESES/@EntryValue">False</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_BEFORE_BINARY_OPSIGN/@EntryValue">True</s:Boolean>
|
||||
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_CHAINED_METHOD_CALLS/@EntryValue">WRAP_IF_LONG</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_FOR_STMT_HEADER_STYLE/@EntryValue">WRAP_IF_LONG</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_MULTIPLE_DECLARATION_STYLE/@EntryValue">WRAP_IF_LONG</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_MULTIPLE_TYPE_PARAMEER_CONSTRAINTS_STYLE/@EntryValue">CHOP_ALWAYS</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_OBJECT_AND_COLLECTION_INITIALIZER_STYLE/@EntryValue">CHOP_ALWAYS</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_TERNARY_EXPR_STYLE/@EntryValue">WRAP_IF_LONG</s:String>
|
||||
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/JavaScriptCodeFormatting/JavaScriptFormatOther/ALIGN_MULTIPLE_DECLARATION/@EntryValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeStyle/Generate/=Constructor/@KeyIndexDefined">True</s:Boolean>
|
||||
<s:String x:Key="/Default/CodeStyle/Generate/=Constructor/Options/=XmlDocumentation/@EntryIndexedValue">False</s:String>
|
||||
<s:Boolean x:Key="/Default/CodeStyle/Generate/=Global/@KeyIndexDefined">True</s:Boolean>
|
||||
<s:String x:Key="/Default/CodeStyle/Generate/=Global/Options/=PropertyBody/@EntryIndexedValue">Automatic property</s:String>
|
||||
<s:Boolean x:Key="/Default/CodeStyle/Generate/=Implementations/@KeyIndexDefined">True</s:Boolean>
|
||||
<s:String x:Key="/Default/CodeStyle/Generate/=Implementations/Options/=WrapInRegion/@EntryIndexedValue">False</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Generate/=Implementations/Options/=XmlDocumentation/@EntryIndexedValue">False</s:String>
|
||||
<s:Boolean x:Key="/Default/CodeStyle/Generate/=Overrides/@KeyIndexDefined">True</s:Boolean>
|
||||
<s:String x:Key="/Default/CodeStyle/Generate/=Overrides/Options/=WrapInRegion/@EntryIndexedValue">False</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Generate/=Overrides/Options/=XmlDocumentation/@EntryIndexedValue">False</s:String>
|
||||
<s:Boolean x:Key="/Default/CodeStyle/Generate/=Properties/@KeyIndexDefined">True</s:Boolean>
|
||||
<s:String x:Key="/Default/CodeStyle/Generate/=Properties/Options/=DebuggerStepsThrough/@EntryIndexedValue">False</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Generate/=Properties/Options/=XmlDocumentation/@EntryIndexedValue">False</s:String>
|
||||
<s:Boolean x:Key="/Default/CodeStyle/Generate/=ReadProperties/@KeyIndexDefined">True</s:Boolean>
|
||||
<s:String x:Key="/Default/CodeStyle/Generate/=ReadProperties/Options/=DebuggerStepsThrough/@EntryIndexedValue">False</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Generate/=ReadProperties/Options/=XmlDocumentation/@EntryIndexedValue">False</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=EC/@EntryIndexedValue">EC</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=IIS/@EntryIndexedValue">IIS</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=Constants/@EntryIndexedValue"><Policy Inspect="True" Prefix="" Suffix="" Style="AA_BB" /></s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=EnumMember/@EntryIndexedValue"><Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /></s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=Interfaces/@EntryIndexedValue"><Policy Inspect="True" Prefix="I" Suffix="" Style="AaBb" /></s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=LocalConstants/@EntryIndexedValue"><Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /></s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=Locals/@EntryIndexedValue"><Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /></s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=MethodPropertyEvent/@EntryIndexedValue"><Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /></s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=Other/@EntryIndexedValue"><Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /></s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=Parameters/@EntryIndexedValue"><Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /></s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateConstants/@EntryIndexedValue"><Policy Inspect="True" Prefix="" Suffix="" Style="AA_BB" /></s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateInstanceFields/@EntryIndexedValue"><Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /></s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateStaticFields/@EntryIndexedValue"><Policy Inspect="True" Prefix="" Suffix="" Style="AA_BB" /></s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateStaticReadonly/@EntryIndexedValue"><Policy Inspect="True" Prefix="" Suffix="" Style="AA_BB" /></s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PublicFields/@EntryIndexedValue"><Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /></s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=StaticReadonly/@EntryIndexedValue"><Policy Inspect="True" Prefix="" Suffix="" Style="AA_BB" /></s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=TypeParameters/@EntryIndexedValue"><Policy Inspect="True" Prefix="T" Suffix="" Style="AaBb" /></s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=TypesAndNamespaces/@EntryIndexedValue"><Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /></s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/VBNaming/EventHandlerPatternLong/@EntryValue">$object$_On$event$</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/VBNaming/PredefinedNamingRules/=Constants/@EntryIndexedValue"><Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /></s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/VBNaming/PredefinedNamingRules/=EnumMember/@EntryIndexedValue"><Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /></s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/VBNaming/PredefinedNamingRules/=Interfaces/@EntryIndexedValue"><Policy Inspect="True" Prefix="I" Suffix="" Style="AaBb" /></s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/VBNaming/PredefinedNamingRules/=LocalConstants/@EntryIndexedValue"><Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /></s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/VBNaming/PredefinedNamingRules/=Locals/@EntryIndexedValue"><Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /></s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/VBNaming/PredefinedNamingRules/=MethodPropertyEvent/@EntryIndexedValue"><Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /></s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/VBNaming/PredefinedNamingRules/=Other/@EntryIndexedValue"><Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /></s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/VBNaming/PredefinedNamingRules/=Parameters/@EntryIndexedValue"><Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /></s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/VBNaming/PredefinedNamingRules/=PrivateConstants/@EntryIndexedValue"><Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /></s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/VBNaming/PredefinedNamingRules/=PrivateInstanceFields/@EntryIndexedValue"><Policy Inspect="True" Prefix="_" Suffix="" Style="aaBb" /></s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/VBNaming/PredefinedNamingRules/=PrivateStaticFields/@EntryIndexedValue"><Policy Inspect="True" Prefix="_" Suffix="" Style="aaBb" /></s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/VBNaming/PredefinedNamingRules/=PrivateStaticReadonly/@EntryIndexedValue"><Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /></s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/VBNaming/PredefinedNamingRules/=PublicFields/@EntryIndexedValue"><Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /></s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/VBNaming/PredefinedNamingRules/=StaticReadonly/@EntryIndexedValue"><Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /></s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/VBNaming/PredefinedNamingRules/=TypeParameters/@EntryIndexedValue"><Policy Inspect="True" Prefix="T" Suffix="" Style="AaBb" /></s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/VBNaming/PredefinedNamingRules/=TypesAndNamespaces/@EntryIndexedValue"><Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /></s:String></wpf:ResourceDictionary>
|
||||
BIN
TestArchives/Archives/7Zip.LZMA2.sfx.exe
Normal file
BIN
TestArchives/Archives/7Zip.LZMA2.sfx.exe
Normal file
Binary file not shown.
BIN
TestArchives/Archives/Encrypted.rar
Normal file
BIN
TestArchives/Archives/Encrypted.rar
Normal file
Binary file not shown.
BIN
TestArchives/Archives/Rar.encrypted_filesAndHeader.rar
Normal file
BIN
TestArchives/Archives/Rar.encrypted_filesAndHeader.rar
Normal file
Binary file not shown.
BIN
TestArchives/Archives/Rar.encrypted_filesOnly.rar
Normal file
BIN
TestArchives/Archives/Rar.encrypted_filesOnly.rar
Normal file
Binary file not shown.
Reference in New Issue
Block a user