Have NO_CRYPTO and add Profile259

This commit is contained in:
Adam Hathcock
2016-01-02 15:02:45 +00:00
parent df62c1d3b2
commit b0fdac3e6f
15 changed files with 47 additions and 24 deletions

View File

@@ -20,10 +20,12 @@ namespace SharpCompress.Archive.Rar
internal override Stream GetCompressedStream()
{
stream.Position = FileHeader.DataStartPosition;
#if !NO_CRYPTO
if (FileHeader.Salt != null)
{
return new RarCryptoWrapper(stream, password, FileHeader.Salt);
}
#endif
return stream;
}

View File

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

View File

@@ -117,6 +117,7 @@ namespace SharpCompress.Common.Rar.Headers
private RarHeader ReadNextHeader(Stream stream)
{
#if !NO_CRYPTO
var reader = new RarCryptoBinaryReader(stream, Password);
if (IsEncrypted)
@@ -129,6 +130,10 @@ namespace SharpCompress.Common.Rar.Headers
byte[] salt = reader.ReadBytes(8);
reader.InitializeAes(salt);
}
#else
var reader = new MarkingBinaryReader(stream);
#endif
RarHeader header = RarHeader.Create(reader);
if (header == null)
@@ -218,7 +223,11 @@ namespace SharpCompress.Common.Rar.Headers
}
else
{
#if !NO_CRYPTO
fh.PackedStream = new RarCryptoWrapper(ms, Password, fh.Salt);
#else
throw new NotSupportedException("RarCrypto not supported");
#endif
}
}
break;

View File

@@ -1,4 +1,5 @@
using System.Collections.Generic;
#if !NO_CRYPTO
using System.Collections.Generic;
using System.IO;
using SharpCompress.IO;
@@ -78,4 +79,5 @@ namespace SharpCompress.Common.Rar
ClearQueue();
}
}
}
}
#endif

View File

@@ -1,3 +1,4 @@
#if !NO_CRYPTO
using System;
using System.Collections.Generic;
using System.IO;
@@ -105,4 +106,5 @@ namespace SharpCompress.Common.Rar
base.Dispose(disposing);
}
}
}
}
#endif

View File

@@ -1,4 +1,5 @@
using System;
#if !NO_CRYPTO
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
@@ -110,4 +111,5 @@ namespace SharpCompress.Common.Rar
{
}
}
}
}
#endif

View File

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

View File

@@ -1,3 +1,4 @@
#if !NO_CRYPTO
using System;
using System.IO;
using System.Security.Cryptography;
@@ -178,3 +179,4 @@ namespace SharpCompress.Common.Zip
}
}
}
#endif

View File

@@ -1,3 +1,4 @@
#if !NO_CRYPTO
using System;
using System.Security.Cryptography;
using System.Text;
@@ -72,3 +73,4 @@ namespace SharpCompress.Common.Zip
}
}
}
#endif

View File

@@ -133,7 +133,7 @@ namespace SharpCompress.Common.Zip
protected Stream GetCryptoStream(Stream plainStream)
{
if ((Header.CompressedSize == 0)
#if !DOTNET51
#if !NO_CRYPTO
&& ((Header.PkwareTraditionalEncryptionData != null)
|| (Header.WinzipAesEncryptionData != null)))
#else
@@ -156,7 +156,7 @@ namespace SharpCompress.Common.Zip
return new PkwareTraditionalCryptoStream(plainStream, Header.PkwareTraditionalEncryptionData,
CryptoMode.Decrypt);
}
#if !DOTNET51
#if !NO_FILE
if (Header.WinzipAesEncryptionData != null)
{
//only read 10 less because the last ten are auth bytes

View File

@@ -132,7 +132,7 @@ namespace SharpCompress.Common.Zip
}
else
{
#if DOTNET51
#if NO_CRYPTO
throw new NotSupportedException("Cannot decrypt Winzip AES with Silverlight or WP7.");
#else

View File

@@ -1,4 +1,5 @@
using System;
#if !NO_CRYPTO
using System;
using System.IO;
using System.Security.Cryptography;
using System.Text;
@@ -8,7 +9,7 @@ namespace SharpCompress.Compressor.LZMA
{
internal class AesDecoderStream : DecoderStream2
{
#region Variables
#region Variables
private Stream mStream;
private ICryptoTransform mDecoder;
@@ -20,9 +21,9 @@ namespace SharpCompress.Compressor.LZMA
private int mUnderflow;
private bool isDisposed;
#endregion
#endregion
#region Stream Methods
#region Stream Methods
public AesDecoderStream(Stream input, byte[] info, IPasswordProvider pass, long limit)
{
@@ -130,9 +131,9 @@ namespace SharpCompress.Compressor.LZMA
return processed;
}
#endregion
#endregion
#region Private Methods
#region Private Methods
private void Init(byte[] info, out int numCyclesPower, out byte[] salt, out byte[] iv)
{
@@ -185,7 +186,7 @@ namespace SharpCompress.Compressor.LZMA
}
else
{
#if DOTNET51 || DNXCORE50
#if NO_FILE || DNXCORE50
using (IncrementalHash sha = IncrementalHash.CreateHash(HashAlgorithmName.SHA256))
{
byte[] counter = new byte[8];
@@ -251,4 +252,5 @@ namespace SharpCompress.Compressor.LZMA
#endregion
}
}
}
#endif

View File

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

View File

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

View File

@@ -22,7 +22,7 @@
},
".NETPortable,Version=v4.5,Profile=Profile259": {
"compilationOptions": {
"define": [ "PROFILE259", "NO_FILE" ]
"define": [ "PROFILE259", "NO_FILE", "NO_CRYPTO" ]
},
"frameworkAssemblies": {
"Microsoft.CSharp": "",