From 6a0959b4ed0a1dc8be0d3fd4b4bdc1f4ebc674c9 Mon Sep 17 00:00:00 2001 From: Val Melamed Date: Thu, 10 Dec 2015 12:45:49 -0500 Subject: [PATCH] The ciphers support only .NET v4.6 --- .../Serialization/Properties/AssemblyInfo.cs | 6 +- Aspects/Model/EncryptedParts.cs | 6 +- Aspects/Model/Properties/AssemblyInfo.cs | 6 +- Aspects/NuGet/vm.Aspects.nuspec | 2 +- Aspects/Parsers/Properties/AssemblyInfo.cs | 6 +- Aspects/Properties/AssemblyInfo.cs | 6 +- .../Cryptography/Ciphers/DpapiCipher.cs | 40 ++-- .../Ciphers/EncryptedNewKeyCipher.cs | 18 +- .../Ciphers/EncryptedNewKeyHashedCipher.cs | 4 - .../Ciphers/EncryptedNewKeySignedCipher.cs | 18 +- .../Cryptography/Ciphers/FromByteArray.cs | 4 - .../Ciphers/HashAlgorithmFactory.cs | 12 +- .../Security/Cryptography/Ciphers/Hasher.cs | 59 +++--- .../Cryptography/Ciphers/ICipherAsync.cs | 8 +- .../Ciphers/ICipherExtensions.Etc.cs | 8 - .../Cryptography/Ciphers/IHasherAsync.cs | 8 +- .../Cryptography/Ciphers/IKeyManagement.cs | 2 - .../Cryptography/Ciphers/IKeyStorageAsync.cs | 8 +- .../Security/Cryptography/Ciphers/KeyFile.cs | 8 +- .../Cryptography/Ciphers/NuGet/Ciphers.nuspec | 35 ++-- .../Ciphers/NuGet/PublishCiphers.cmd | 12 +- .../Cryptography/Ciphers/NullCipher.cs | 24 +-- .../Cryptography/Ciphers/NullHasher.cs | 6 +- .../Cryptography/Ciphers/NullStream.cs | 8 +- .../Cryptography/Ciphers/PasswordHasher.cs | 16 +- .../Ciphers/PasswordProtectedKeyCipher.cs | 6 - .../Ciphers/Properties/AssemblyInfo.cs | 6 +- .../Ciphers/ProtectedKeyCipher.cs | 66 +++---- .../Cryptography/Ciphers/RsaSigner.cs | 6 +- .../Ciphers/SymmetricAlgorithmFactory.cs | 13 +- .../Ciphers/SymmetricKeyCipherBase.cs | 20 +- .../Ciphers/Test/EncryptedKeyCipherTest.cs | 9 +- .../Ciphers/Test/EncryptedKeyCipherTest1.cs | 9 +- .../Ciphers/Test/EncryptedNewKeyCipherTest.cs | 13 +- .../Test/EncryptedNewKeyHashedCipherTest.cs | 16 +- .../EncryptedNewKeySha256SignedCipherTest.cs | 8 +- .../Test/EncryptedNewKeySignedCipherTest.cs | 10 +- .../Ciphers/Test/GenericCipherTest.cs | 11 +- .../Ciphers/Test/GenericHasherTest.cs | 16 +- .../Ciphers/Test/HashAlgorithmFactoryTest.cs | 16 +- .../Cryptography/Ciphers/Test/HasherTest.cs | 10 +- .../Cryptography/Ciphers/Test/KeyFileTest.cs | 8 +- .../Ciphers/Test/NullHasherTest.cs | 10 +- .../Ciphers/Test/NullStreamTest.cs | 8 +- .../Ciphers/Test/PasswordHasherTest.cs | 4 +- .../Test/PasswordProtectedKeyCipherTest.cs | 16 +- .../Test/ProtectedKeyCipherDIAlgorithmTest.cs | 10 +- .../Ciphers/Test/ProtectedKeyCipherTest.cs | 38 +--- .../Ciphers/Test/RsaSignerSha256Test.cs | 4 +- .../Ciphers/Test/RsaSignerTest.cs | 4 +- .../Test/SymmetricAlgorithmFactoryTest.cs | 23 +-- .../Test/Xml/EncryptedKeyXmlCipherTest.cs | 4 +- .../Xml/EncryptedNewKeySignedXmlCipherTest.cs | 8 +- .../Test/Xml/EncryptedNewKeyXmlCipherTest.cs | 8 +- .../Test/Xml/ProtectedKeyXmlCipherTest.cs | 4 +- .../Test/Xml/RsaXmlSignerSha256Test.cs | 4 +- .../Ciphers/Test/Xml/RsaXmlSignerTest.cs | 4 +- ...Security.Cryptography.Ciphers.Tests.csproj | 6 +- .../Cryptography/Ciphers/ToByteArray.cs | 4 - .../Ciphers/Xml/EncryptedNewKeyXmlCipher.cs | 6 +- .../Cryptography/Ciphers/Xml/RsaXmlSigner.cs | 16 +- ...pects.Security.Cryptography.Ciphers.csproj | 172 +----------------- Aspects/Wcf/Properties/AssemblyInfo.cs | 6 +- 63 files changed, 218 insertions(+), 714 deletions(-) diff --git a/Aspects/Linq/Expressions/Serialization/Properties/AssemblyInfo.cs b/Aspects/Linq/Expressions/Serialization/Properties/AssemblyInfo.cs index 2cb9a3c..462039c 100644 --- a/Aspects/Linq/Expressions/Serialization/Properties/AssemblyInfo.cs +++ b/Aspects/Linq/Expressions/Serialization/Properties/AssemblyInfo.cs @@ -4,9 +4,9 @@ [assembly: AssemblyTitle("vm.Aspects.Linq.Expressions.Serialization")] [assembly: AssemblyDescription("Serializes and deserializes LINQ expression trees to and from XML documents.")] -[assembly: AssemblyVersion("1.0.5")] -[assembly: AssemblyFileVersion("1.0.5")] -[assembly: AssemblyInformationalVersion("1.0.5")] +[assembly: AssemblyVersion("1.0.6")] +[assembly: AssemblyFileVersion("1.0.6")] +[assembly: AssemblyInformationalVersion("1.0.6")] [assembly: InternalsVisibleTo( "vm.Aspects.Linq.Expressions.Serialization.Test, " + diff --git a/Aspects/Model/EncryptedParts.cs b/Aspects/Model/EncryptedParts.cs index b7526e5..a4efde1 100644 --- a/Aspects/Model/EncryptedParts.cs +++ b/Aspects/Model/EncryptedParts.cs @@ -97,10 +97,10 @@ void Verify() .All(mi => { var pi = mi as PropertyInfo; + var pType = pi != null ? pi.PropertyType : ((FieldInfo)mi).FieldType; - return ICipherExtensions.DecryptTypedData.ContainsKey(pi != null - ? pi.PropertyType - : ((FieldInfo)mi).FieldType); + return pType.IsSerializable && + ICipherExtensions.DecryptTypedData.ContainsKey(pType); })) throw new InvalidOperationException("The properties marked with DecryptedAttribute must be encryptable: must be of any of the following types: "+ "bool, char, byte, sbyte, short, ushort, int, uint, long, ulong, decimal, float, double, DateTime, Guid, "+ diff --git a/Aspects/Model/Properties/AssemblyInfo.cs b/Aspects/Model/Properties/AssemblyInfo.cs index 812a990..bf62b8e 100644 --- a/Aspects/Model/Properties/AssemblyInfo.cs +++ b/Aspects/Model/Properties/AssemblyInfo.cs @@ -3,9 +3,9 @@ [assembly: AssemblyTitle("vm.Aspect.Model")] [assembly: AssemblyDescription("Defines the IRepository and related base classes and utilities - a framework of building domain object model.")] -[assembly: AssemblyVersion("1.0.5")] -[assembly: AssemblyFileVersion("1.0.5")] -[assembly: AssemblyInformationalVersion("1.0.5")] +[assembly: AssemblyVersion("1.0.6")] +[assembly: AssemblyFileVersion("1.0.6")] +[assembly: AssemblyInformationalVersion("1.0.6")] [assembly: System.Runtime.CompilerServices.InternalsVisibleTo( "vm.Aspects.Model.Tests, " + diff --git a/Aspects/NuGet/vm.Aspects.nuspec b/Aspects/NuGet/vm.Aspects.nuspec index cc739a9..fbea97c 100644 --- a/Aspects/NuGet/vm.Aspects.nuspec +++ b/Aspects/NuGet/vm.Aspects.nuspec @@ -2,7 +2,7 @@ vm.Aspects - 1.0.5-beta + 1.0.6-beta Val Melamed Val Melamed diff --git a/Aspects/Parsers/Properties/AssemblyInfo.cs b/Aspects/Parsers/Properties/AssemblyInfo.cs index d236982..679c264 100644 --- a/Aspects/Parsers/Properties/AssemblyInfo.cs +++ b/Aspects/Parsers/Properties/AssemblyInfo.cs @@ -6,9 +6,9 @@ [assembly: AssemblyTitle("vm.Aspects.Parser")] [assembly: AssemblyDescription("Text parsing readers, e.g. CSV/TSV reader.")] -[assembly: AssemblyVersion("1.0.5")] -[assembly: AssemblyFileVersion("1.0.5")] -[assembly: AssemblyInformationalVersion("1.0.5")] +[assembly: AssemblyVersion("1.0.6")] +[assembly: AssemblyFileVersion("1.0.6")] +[assembly: AssemblyInformationalVersion("1.0.6")] [assembly: System.Runtime.CompilerServices.InternalsVisibleTo( "vm.Aspects.Parsers.Tests, " + diff --git a/Aspects/Properties/AssemblyInfo.cs b/Aspects/Properties/AssemblyInfo.cs index d521c26..676bdd3 100644 --- a/Aspects/Properties/AssemblyInfo.cs +++ b/Aspects/Properties/AssemblyInfo.cs @@ -2,9 +2,9 @@ [assembly: AssemblyTitle("vm.Aspects")] [assembly: AssemblyDescription("A set of classes addressing various common cross-cutting concerns.")] -[assembly: AssemblyVersion("1.0.5")] -[assembly: AssemblyFileVersion("1.0.5")] -[assembly: AssemblyInformationalVersion("1.0.5")] +[assembly: AssemblyVersion("1.0.6")] +[assembly: AssemblyFileVersion("1.0.6")] +[assembly: AssemblyInformationalVersion("1.0.6")] [assembly: System.Runtime.CompilerServices.InternalsVisibleTo( diff --git a/Aspects/Security/Cryptography/Ciphers/DpapiCipher.cs b/Aspects/Security/Cryptography/Ciphers/DpapiCipher.cs index 062a939..cff3834 100644 --- a/Aspects/Security/Cryptography/Ciphers/DpapiCipher.cs +++ b/Aspects/Security/Cryptography/Ciphers/DpapiCipher.cs @@ -2,9 +2,7 @@ using System.Diagnostics.CodeAnalysis; using System.IO; using System.Security.Cryptography; -#if NET45 using System.Threading.Tasks; -#endif namespace vm.Aspects.Security.Cryptography.Ciphers { @@ -18,7 +16,7 @@ namespace vm.Aspects.Security.Cryptography.Ciphers /// The bytes of the encrypted text. /// /// - [SuppressMessage("Microsoft.Design", "CA1063:ImplementIDisposableCorrectly", Justification="Nothing to dispose")] + [SuppressMessage("Microsoft.Design", "CA1063:ImplementIDisposableCorrectly", Justification = "Nothing to dispose")] public sealed class DpapiCipher : ICipherAsync { const int BlockLength = 4096; @@ -49,7 +47,7 @@ public DpapiCipher( /// /// Gets or sets the entropy which makes the encryption stronger. /// - [SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays", Justification="It is an opaque value.")] + [SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays", Justification = "It is an opaque value.")] public byte[] Entropy { get; set; } /// @@ -88,9 +86,9 @@ public DpapiCipher( /// /// An I/O error occurred. /// - [SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Justification="The CryptoStream will do it.")] - [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId="1")] - [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId="0")] + [SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Justification = "The CryptoStream will do it.")] + [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "1")] + [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0")] public void Encrypt( Stream dataStream, Stream encryptedStream) @@ -156,9 +154,9 @@ public void Encrypt( /// /// An I/O error occurred. /// - [SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Justification="The CryptoStream will do it.")] - [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId="1")] - [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId="0")] + [SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Justification = "The CryptoStream will do it.")] + [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "1")] + [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0")] public void Decrypt( Stream encryptedStream, Stream dataStream) @@ -193,7 +191,7 @@ public void Decrypt( buffer = new byte[bufferLen]; else if (buffer.Length != bufferLen) - Array.Resize(ref buffer, bufferLen); + Array.Resize(ref buffer, bufferLen); read = inputStream.Read(buffer, 0, bufferLen); @@ -261,7 +259,6 @@ public byte[] Decrypt( } #endregion -#if NET45 #region ICipherAsync Members /// /// Asynchronously reads the clear text from the , encrypts it and writes the result into the @@ -290,8 +287,8 @@ public byte[] Decrypt( /// /// An I/O error occurred. /// - [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId="1")] - [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId="0")] + [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "1")] + [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0")] public async Task EncryptAsync( Stream dataStream, Stream encryptedStream) @@ -308,7 +305,7 @@ public async Task EncryptAsync( first = false; else if (read == 0) - return; + return; if (read < buffer.Length) Array.Resize(ref buffer, read); @@ -348,8 +345,8 @@ public async Task EncryptAsync( /// /// An I/O error occurred. /// - [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId="1")] - [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId="0")] + [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "1")] + [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0")] public async Task DecryptAsync( Stream encryptedStream, Stream dataStream) @@ -369,7 +366,7 @@ public async Task DecryptAsync( first = false; else if (read == 0) - return; + return; if (read != bufferLenBytes.Length) throw new ArgumentException("The input stream does not seem to be produced with compatible cipher.", "encryptedStream"); @@ -380,7 +377,7 @@ public async Task DecryptAsync( buffer = new byte[bufferLen]; else if (buffer.Length != bufferLen) - Array.Resize(ref buffer, bufferLen); + Array.Resize(ref buffer, bufferLen); read = await encryptedStream.ReadAsync(buffer, 0, bufferLen); @@ -393,14 +390,13 @@ public async Task DecryptAsync( while (decrypted.Length == BlockLength); } #endregion -#endif #region IDisposable Members /// /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources, here it does nothing. /// - [SuppressMessage("Microsoft.Usage", "CA1816:CallGCSuppressFinalizeCorrectly", Justification="Nothing to dispose")] - [SuppressMessage("Microsoft.Design", "CA1063:ImplementIDisposableCorrectly", Justification="Nothing to dispose")] + [SuppressMessage("Microsoft.Usage", "CA1816:CallGCSuppressFinalizeCorrectly", Justification = "Nothing to dispose")] + [SuppressMessage("Microsoft.Design", "CA1063:ImplementIDisposableCorrectly", Justification = "Nothing to dispose")] public void Dispose() { GC.SuppressFinalize(this); diff --git a/Aspects/Security/Cryptography/Ciphers/EncryptedNewKeyCipher.cs b/Aspects/Security/Cryptography/Ciphers/EncryptedNewKeyCipher.cs index 96f5f61..61a8f68 100644 --- a/Aspects/Security/Cryptography/Ciphers/EncryptedNewKeyCipher.cs +++ b/Aspects/Security/Cryptography/Ciphers/EncryptedNewKeyCipher.cs @@ -2,9 +2,7 @@ using System.Diagnostics.CodeAnalysis; using System.IO; using System.Security.Cryptography.X509Certificates; -#if NET45 using System.Threading.Tasks; -#endif namespace vm.Aspects.Security.Cryptography.Ciphers { @@ -91,7 +89,7 @@ public override string KeyLocation /// /// The key. /// Always thrown. - [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId="0")] + [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0")] public override void ImportSymmetricKey( byte[] key) { @@ -107,13 +105,12 @@ public override byte[] ExportSymmetricKey() throw new NotImplementedException(); } -#if NET45 /// /// Asynchronously imports the symmetric key as a clear text. /// /// The key. /// Always thrown. - [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId="0")] + [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0")] public override Task ImportSymmetricKeyAsync( byte[] key) { @@ -128,7 +125,6 @@ public override Task ExportSymmetricKeyAsync() { throw new NotImplementedException(); } -#endif #endregion #region Initialization of the symmetric key overrides @@ -154,7 +150,7 @@ protected override void InitializeSymmetricKey() /// Thrown when is . /// Thrown when cannot be written to. /// The method is called by the GoF template-methods. - [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId="0")] + [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0")] protected override void BeforeWriteEncrypted( Stream encryptedStream) { @@ -181,7 +177,7 @@ protected override void BeforeWriteEncrypted( /// /// /// The method is called by the GoF template-methods. - [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId="0")] + [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0")] protected override void BeforeReadDecrypted(Stream encryptedStream) { // read the length of the key and allocate an array for it @@ -204,7 +200,6 @@ protected override void BeforeReadDecrypted(Stream encryptedStream) } #endregion -#if NET45 /// /// Initializes asynchronously the symmetric key by either reading it from the storage with the specified key location name or by /// generating a new key and saving it in it. @@ -229,7 +224,7 @@ protected override Task InitializeSymmetricKeyAsync() /// Thrown when is . /// Thrown when cannot be written to. /// The method is called by the GoF template-methods. - [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId="0")] + [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0")] protected override async Task BeforeWriteEncryptedAsync( Stream encryptedStream) { @@ -256,7 +251,7 @@ protected override async Task BeforeWriteEncryptedAsync( /// /// /// The method is called by the GoF template-methods. - [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId="0")] + [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0")] protected override async Task BeforeReadDecryptedAsync( Stream encryptedStream) { @@ -279,6 +274,5 @@ protected override async Task BeforeReadDecryptedAsync( await base.BeforeReadDecryptedAsync(encryptedStream); } #endregion -#endif } } diff --git a/Aspects/Security/Cryptography/Ciphers/EncryptedNewKeyHashedCipher.cs b/Aspects/Security/Cryptography/Ciphers/EncryptedNewKeyHashedCipher.cs index 60c8fbb..eb85158 100644 --- a/Aspects/Security/Cryptography/Ciphers/EncryptedNewKeyHashedCipher.cs +++ b/Aspects/Security/Cryptography/Ciphers/EncryptedNewKeyHashedCipher.cs @@ -5,9 +5,7 @@ using System.Linq; using System.Security.Cryptography; using System.Security.Cryptography.X509Certificates; -#if NET45 using System.Threading.Tasks; -#endif namespace vm.Aspects.Security.Cryptography.Ciphers { @@ -491,7 +489,6 @@ protected byte[] FinalizeHashAfterRead( } #endregion -#if NET45 /// /// Asynchronously reads the clear text from the , encrypts it and writes the result into the /// stream. This is the reverse method of . @@ -610,7 +607,6 @@ protected virtual async Task LoadHashToValidateAsync( : storedHash; } #endregion -#endif #region IDisposable Members diff --git a/Aspects/Security/Cryptography/Ciphers/EncryptedNewKeySignedCipher.cs b/Aspects/Security/Cryptography/Ciphers/EncryptedNewKeySignedCipher.cs index b2b4164..566b482 100644 --- a/Aspects/Security/Cryptography/Ciphers/EncryptedNewKeySignedCipher.cs +++ b/Aspects/Security/Cryptography/Ciphers/EncryptedNewKeySignedCipher.cs @@ -36,7 +36,7 @@ namespace vm.Aspects.Security.Cryptography.Ciphers /// /// /// - [SuppressMessage("Microsoft.Maintainability", "CA1501:AvoidExcessiveInheritance", Justification="Makes sense.")] + [SuppressMessage("Microsoft.Maintainability", "CA1501:AvoidExcessiveInheritance", Justification = "Makes sense.")] public class EncryptedNewKeySignedCipher : EncryptedNewKeyHashedCipher { #region Fields @@ -95,7 +95,7 @@ public EncryptedNewKeySignedCipher( string symmetricAlgorithmName = null, string hashAlgorithmName = null) : base(exchangeCertificate, symmetricAlgorithmName, !string.IsNullOrWhiteSpace(hashAlgorithmName) - ? hashAlgorithmName + ? hashAlgorithmName : signCertificate.HashAlgorithm()) { if (signCertificate == null) @@ -120,7 +120,7 @@ public EncryptedNewKeySignedCipher( /// /// The encrypted stream. /// encryptedStream - [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId="0")] + [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0")] protected override void ReserveSpaceForHash( Stream encryptedStream) { @@ -138,7 +138,7 @@ protected override void ReserveSpaceForHash( /// The encrypted stream. /// The hash. /// encryptedStream - [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId="0")] + [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0")] protected override void WriteHashInReservedSpace( Stream encryptedStream, byte[] hash) @@ -173,7 +173,7 @@ protected override void WriteHashInReservedSpace( /// or /// The input data does not represent a valid crypto package: could not read the signature. /// - [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId="0")] + [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0")] protected override void LoadHashToValidate( Stream encryptedStream) { @@ -200,8 +200,8 @@ protected override void LoadHashToValidate( /// The crypto stream. /// Invalid signature. /// The method is called by the GoF template-methods. - [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId="1")] - [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId="0")] + [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "1")] + [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0")] protected override void AfterReadDecrypted( Stream encryptedStream, CryptoStream cryptoStream) @@ -222,7 +222,6 @@ protected override void AfterReadDecrypted( } #endregion -#if NET45 #region Overrides of the async primitives /// /// Loads asynchronously the signature to validate. @@ -234,7 +233,7 @@ protected override void AfterReadDecrypted( /// or /// The input data does not represent a valid crypto package: could not read the signature. /// - [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId="0")] + [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0")] protected override async Task LoadHashToValidateAsync( Stream encryptedStream) { @@ -252,7 +251,6 @@ protected override async Task LoadHashToValidateAsync( throw new ArgumentException("The input data does not represent a valid crypto package: could not read the signature.", "encryptedStream"); } #endregion -#endif #region IDisposable Members /// diff --git a/Aspects/Security/Cryptography/Ciphers/FromByteArray.cs b/Aspects/Security/Cryptography/Ciphers/FromByteArray.cs index 7e5b8d7..fcdfbe0 100644 --- a/Aspects/Security/Cryptography/Ciphers/FromByteArray.cs +++ b/Aspects/Security/Cryptography/Ciphers/FromByteArray.cs @@ -528,11 +528,7 @@ public static Guid[] ToGuidArray( /// /// Dictionary of types and the corresponding methods that can decrypt those types. /// -#if NET45 public readonly static IReadOnlyDictionary> ToTypedData = new ReadOnlyDictionary>( new Dictionary> -#elif NET40 - public readonly static IDictionary> ToTypedData = (new Dictionary> -#endif { [typeof(bool)] = d => ToBoolean(d), [typeof(bool[])] = d => ToBooleanArray(d), diff --git a/Aspects/Security/Cryptography/Ciphers/HashAlgorithmFactory.cs b/Aspects/Security/Cryptography/Ciphers/HashAlgorithmFactory.cs index b24b6a0..26343fa 100644 --- a/Aspects/Security/Cryptography/Ciphers/HashAlgorithmFactory.cs +++ b/Aspects/Security/Cryptography/Ciphers/HashAlgorithmFactory.cs @@ -144,15 +144,6 @@ public string HashAlgorithmName /// int _disposed; -#if NET40 - /// - /// Returns true if the object has already been disposed, otherwise false. - /// - public bool IsDisposed - { - get { return _disposed != 0; } - } -#else /// /// Returns true if the object has already been disposed, otherwise false. /// @@ -160,13 +151,12 @@ public bool IsDisposed { get { return Volatile.Read(ref _disposed) != 0; } } -#endif /// /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. /// /// Invokes the protected virtual . - [SuppressMessage("Microsoft.Design", "CA1063:ImplementIDisposableCorrectly", Justification="It is correct.")] + [SuppressMessage("Microsoft.Design", "CA1063:ImplementIDisposableCorrectly", Justification = "It is correct.")] public void Dispose() { // if it is disposed or in a process of disposing - return. diff --git a/Aspects/Security/Cryptography/Ciphers/Hasher.cs b/Aspects/Security/Cryptography/Ciphers/Hasher.cs index 6239450..af3fa6f 100644 --- a/Aspects/Security/Cryptography/Ciphers/Hasher.cs +++ b/Aspects/Security/Cryptography/Ciphers/Hasher.cs @@ -4,9 +4,7 @@ using System.IO; using System.Security.Cryptography; using System.Threading; -#if NET45 using System.Threading.Tasks; -#endif namespace vm.Aspects.Security.Cryptography.Ciphers { @@ -141,7 +139,7 @@ public virtual byte[] Hash( /// /// Thrown when is . /// Thrown when the hash has an invalid size. - [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId="1")] + [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "1")] public virtual bool TryVerifyHash( Stream dataStream, byte[] hash) @@ -161,10 +159,10 @@ public virtual bool TryVerifyHash( else // the parameter hash has the length of the expected product from this algorithm + the length of the salt, i.e. there is salt in the parameter salt if (hash.Length > hashAlgorithm.HashSize/8) - SaltLength = hash.Length - hashAlgorithm.HashSize/8; - else - // this is wrong... - return false; + SaltLength = hash.Length - hashAlgorithm.HashSize/8; + else + // this is wrong... + return false; using (var hashStream = CreateHashStream(hashAlgorithm)) { @@ -215,7 +213,7 @@ public virtual byte[] Hash( /// /// Thrown when is . /// Thrown when the hash is invalid. - [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId="1")] + [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "1")] public virtual bool TryVerifyHash( byte[] data, byte[] hash) @@ -235,10 +233,10 @@ public virtual bool TryVerifyHash( else // the parameter hash has the length of the expected product from this algorithm + the length of the salt, i.e. there is salt in the parameter salt if (hash.Length > hashAlgorithm.HashSize/8) - SaltLength = hash.Length - hashAlgorithm.HashSize/8; - else - // this is wrong... - return false; + SaltLength = hash.Length - hashAlgorithm.HashSize/8; + else + // this is wrong... + return false; using (var hashStream = CreateHashStream(hashAlgorithm)) { @@ -258,7 +256,6 @@ public virtual bool TryVerifyHash( } #endregion -#if NET45 #region IhasherAsync members /// /// Computes the hash of a stream. @@ -314,10 +311,10 @@ public virtual async Task TryVerifyHashAsync( else // the hash has the same length as the length of the key + the length of the salt - there is salt in the parameter salt if (hash.Length > hashAlgorithm.HashSize/8) - SaltLength = hash.Length - hashAlgorithm.HashSize/8; - else - // this is wrong... - return false; + SaltLength = hash.Length - hashAlgorithm.HashSize/8; + else + // this is wrong... + return false; using (var hashStream = CreateHashStream(hashAlgorithm)) { @@ -336,14 +333,13 @@ public virtual async Task TryVerifyHashAsync( } } #endregion -#endif #region Primitives called by the GoF method templates. /// /// Creates the crypto stream. /// /// CryptoStream. - [SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Justification="It will be disposed by the calling code.")] + [SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Justification = "It will be disposed by the calling code.")] protected virtual CryptoStream CreateHashStream( HashAlgorithm hashAlgorithm) { @@ -358,7 +354,7 @@ protected virtual CryptoStream CreateHashStream( /// The hash stream. /// The salt. /// Thrown when is . - [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId="0")] + [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0")] protected virtual byte[] WriteSalt( CryptoStream hashStream, byte[] salt) @@ -387,9 +383,9 @@ protected virtual byte[] WriteSalt( /// The salt. /// The hash. /// Thrown when is . - [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId="1")] - [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId="0")] - [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId="2", Justification="salt is conditionally validated.")] + [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "1")] + [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0")] + [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Justification = "salt is conditionally validated.")] protected virtual byte[] FinalizeHashing( CryptoStream hashStream, HashAlgorithm hashAlgorithm, @@ -414,7 +410,6 @@ protected virtual byte[] FinalizeHashing( } #endregion -#if NET45 #region Async primitives called by the GoF method templates. /// /// Writes the salt (if any) into the crypto stream. @@ -422,7 +417,7 @@ protected virtual byte[] FinalizeHashing( /// The hash stream. /// The salt. /// Thrown when is . - [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId="0")] + [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0")] protected virtual async Task WriteSaltAsync( CryptoStream hashStream, byte[] salt) @@ -443,7 +438,6 @@ protected virtual async Task WriteSaltAsync( return salt; } #endregion -#endif #region IDisposable pattern implementation /// @@ -456,15 +450,6 @@ protected virtual async Task WriteSaltAsync( /// int _disposed; -#if NET40 - /// - /// Returns true if the object has already been disposed, otherwise false. - /// - public bool IsDisposed - { - get { return _disposed != 0; } - } -#else /// /// Returns true if the object has already been disposed, otherwise false. /// @@ -472,12 +457,12 @@ public bool IsDisposed { get { return Volatile.Read(ref _disposed) != 0; } } -#endif + /// /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. /// /// Invokes the protected virtual . - [SuppressMessage("Microsoft.Design", "CA1063:ImplementIDisposableCorrectly", Justification="It is correct.")] + [SuppressMessage("Microsoft.Design", "CA1063:ImplementIDisposableCorrectly", Justification = "It is correct.")] public void Dispose() { // if it is disposed or in a process of disposing - return. diff --git a/Aspects/Security/Cryptography/Ciphers/ICipherAsync.cs b/Aspects/Security/Cryptography/Ciphers/ICipherAsync.cs index 31cf7ee..91e7542 100644 --- a/Aspects/Security/Cryptography/Ciphers/ICipherAsync.cs +++ b/Aspects/Security/Cryptography/Ciphers/ICipherAsync.cs @@ -1,9 +1,7 @@ using System.Diagnostics.Contracts; -using vm.Aspects.Security.Cryptography.Ciphers.Contracts; -#if NET45 -using System.Threading.Tasks; using System.IO; -#endif +using System.Threading.Tasks; +using vm.Aspects.Security.Cryptography.Ciphers.Contracts; namespace vm.Aspects.Security.Cryptography.Ciphers { @@ -14,7 +12,6 @@ namespace vm.Aspects.Security.Cryptography.Ciphers [ContractClass(typeof(ICipherAsyncContract))] public interface ICipherAsync : ICipher { -#if NET45 /// /// Asynchronously reads the clear text from the , encrypts it and writes the result into the /// stream. This is the reverse method of . @@ -76,6 +73,5 @@ Task EncryptAsync( Task DecryptAsync( Stream encryptedStream, Stream dataStream); -#endif } } diff --git a/Aspects/Security/Cryptography/Ciphers/ICipherExtensions.Etc.cs b/Aspects/Security/Cryptography/Ciphers/ICipherExtensions.Etc.cs index ded05ed..6c7eb1e 100644 --- a/Aspects/Security/Cryptography/Ciphers/ICipherExtensions.Etc.cs +++ b/Aspects/Security/Cryptography/Ciphers/ICipherExtensions.Etc.cs @@ -406,11 +406,7 @@ public static byte[] EncryptNullable( /// Dictionary of types and the corresponding methods that can decrypt those types. /// [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")] -#if NET45 public readonly static IReadOnlyDictionary> EncryptTypedData = new ReadOnlyDictionary>( new Dictionary> -#elif NET40 - public readonly static IDictionary> EncryptTypedData = (new Dictionary> -#endif { #region EncryptTypedData [typeof(bool)] = (c,d) => c.Encrypt((bool) d), @@ -532,11 +528,7 @@ public static Nullable DecryptNullable( /// Dictionary of types and the corresponding methods that can decrypt those types. /// [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")] -#if NET45 public readonly static IReadOnlyDictionary> DecryptTypedData = new ReadOnlyDictionary>( new Dictionary> -#elif NET40 - public readonly static IDictionary> DecryptTypedData = (new Dictionary> -#endif { #region DecryptTypedData [typeof(bool)] = (c,d) => c.DecryptBoolean(d), diff --git a/Aspects/Security/Cryptography/Ciphers/IHasherAsync.cs b/Aspects/Security/Cryptography/Ciphers/IHasherAsync.cs index 4b421ce..3a3ca09 100644 --- a/Aspects/Security/Cryptography/Ciphers/IHasherAsync.cs +++ b/Aspects/Security/Cryptography/Ciphers/IHasherAsync.cs @@ -1,9 +1,7 @@ using System.Diagnostics.Contracts; -using vm.Aspects.Security.Cryptography.Ciphers.Contracts; -#if NET45 -using System.Threading.Tasks; using System.IO; -#endif +using System.Threading.Tasks; +using vm.Aspects.Security.Cryptography.Ciphers.Contracts; namespace vm.Aspects.Security.Cryptography.Ciphers { @@ -14,7 +12,6 @@ namespace vm.Aspects.Security.Cryptography.Ciphers [ContractClass(typeof(IHasherAsyncContract))] public interface IHasherAsync : IHasher { -#if NET45 /// /// Computes the hash of the asynchronously. /// @@ -54,6 +51,5 @@ public interface IHasherAsync : IHasher /// Thrown if has invalid length. /// The hash or the encryption failed. Task TryVerifyHashAsync(Stream dataStream, byte[] hash); -#endif } } diff --git a/Aspects/Security/Cryptography/Ciphers/IKeyManagement.cs b/Aspects/Security/Cryptography/Ciphers/IKeyManagement.cs index 0c7ce1d..de71035 100644 --- a/Aspects/Security/Cryptography/Ciphers/IKeyManagement.cs +++ b/Aspects/Security/Cryptography/Ciphers/IKeyManagement.cs @@ -28,7 +28,6 @@ public interface IKeyManagement /// The key. void ImportSymmetricKey(byte[] key); -#if NET45 /// /// Asynchronously exports the symmetric key as a clear text. /// @@ -46,6 +45,5 @@ public interface IKeyManagement /// A object representing the process of asynchronously importing the symmetric key. /// Task ImportSymmetricKeyAsync(byte[] key); -#endif } } diff --git a/Aspects/Security/Cryptography/Ciphers/IKeyStorageAsync.cs b/Aspects/Security/Cryptography/Ciphers/IKeyStorageAsync.cs index c5ab497..1999f48 100644 --- a/Aspects/Security/Cryptography/Ciphers/IKeyStorageAsync.cs +++ b/Aspects/Security/Cryptography/Ciphers/IKeyStorageAsync.cs @@ -1,9 +1,7 @@ using System.Diagnostics.CodeAnalysis; using System.Diagnostics.Contracts; -using vm.Aspects.Security.Cryptography.Ciphers.Contracts; -#if NET45 using System.Threading.Tasks; -#endif +using vm.Aspects.Security.Cryptography.Ciphers.Contracts; namespace vm.Aspects.Security.Cryptography.Ciphers { @@ -11,11 +9,10 @@ namespace vm.Aspects.Security.Cryptography.Ciphers /// The interface IKeyStorageAsync extends IKeyStorage with asynchronous versions of the methods /// and . /// - [SuppressMessage("Microsoft.Design", "CA1040:AvoidEmptyInterfaces", Justification="Only for .NET 4.0")] + [SuppressMessage("Microsoft.Design", "CA1040:AvoidEmptyInterfaces", Justification = "Only for .NET 4.0")] [ContractClass(typeof(IKeyStorageAsyncContract))] public interface IKeyStorageAsync : IKeyStorage { -#if NET45 /// /// Asynchronously puts the key to the storage with the specified location name. /// @@ -30,6 +27,5 @@ public interface IKeyStorageAsync : IKeyStorage /// The key location name. /// A object representing the process of getting the encrypted symmetric key from the storage. Task GetKeyAsync(string keyLocation); -#endif } } diff --git a/Aspects/Security/Cryptography/Ciphers/KeyFile.cs b/Aspects/Security/Cryptography/Ciphers/KeyFile.cs index 55c8cd2..7b006d4 100644 --- a/Aspects/Security/Cryptography/Ciphers/KeyFile.cs +++ b/Aspects/Security/Cryptography/Ciphers/KeyFile.cs @@ -3,9 +3,7 @@ using System.IO; using System.Security.AccessControl; using System.Security.Principal; -#if NET45 using System.Threading.Tasks; -#endif namespace vm.Aspects.Security.Cryptography.Ciphers { @@ -60,7 +58,7 @@ public bool KeyLocationExists( /// The specified path, file name, or both exceed the system-defined maximum length. /// For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters. /// - [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId="0")] + [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0")] public void PutKey( byte[] key, string keyLocation) @@ -120,7 +118,6 @@ public byte[] GetKey( } } -#if NET45 /// /// Asynchronously puts the key in the specified file. /// If the file doesn't exist it creates it, stores the key and sets the appropriate security on the file. @@ -155,7 +152,7 @@ public byte[] GetKey( /// The specified path, file name, or both exceed the system-defined maximum length. /// For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters. /// - [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId="0")] + [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0")] public async Task PutKeyAsync( byte[] key, string keyLocation) @@ -217,7 +214,6 @@ public async Task GetKeyAsync( return key; } } -#endif /// /// Deletes the storage (the file) with the specified location name. diff --git a/Aspects/Security/Cryptography/Ciphers/NuGet/Ciphers.nuspec b/Aspects/Security/Cryptography/Ciphers/NuGet/Ciphers.nuspec index a64cb23..803fee2 100644 --- a/Aspects/Security/Cryptography/Ciphers/NuGet/Ciphers.nuspec +++ b/Aspects/Security/Cryptography/Ciphers/NuGet/Ciphers.nuspec @@ -2,7 +2,7 @@ Ciphers - 1.9.1 + 1.9.2 Val Melamed Val Melamed @@ -15,7 +15,7 @@ * It is very easy to integrate with a Dependency Injection container like Unity, i.e. the behaviors are abstracted with a handful of simple interfaces. * It is very easy to use and configure the objects. No configuration parameters default to sensible defaults. * The package does not have dependencies except the .NET framework BCL and the Common Service Locator 1.3. - * Built and tested with .NET 4.0, 4.5 and 4.6. + * Built and tested with .NET v4.6. In 1.8.0 added sets of ICipher extension overrides for data of the primitive and some basic types and arrays of the same: @@ -29,10 +29,10 @@ byte[] ICipherExtensions.Encrypt<T>(ICipher cipher, T data); T ICipherExtensions.Decrypt<T>(ICipher cipher, byte[] encrypted); - + The generics work with nullable types too. - - This is the last version which supports .NET 4.0 and .NET 4.5. In the next release the only supported version will be .NET 4.6. + + This is the first version which supports only .NET 4.6. (Microsoft is dropping support for .NET v4.5 and v4.5.1. I do not want to support v4.0 anymore.) https://github.com/vmelamed/vm/blob/master/LICENSE https://github.com/vmelamed/vm/tree/master/Aspects/Security/Cryptography/Ciphers @@ -46,29 +46,16 @@ + target="lib\net46"/> + target="lib\net46"/> + target="tools\net46"/> + target="tools\net46"/> - - - - - - - + target="tools\net46"/> + target="tools\net46"/> \ No newline at end of file diff --git a/Aspects/Security/Cryptography/Ciphers/NuGet/PublishCiphers.cmd b/Aspects/Security/Cryptography/Ciphers/NuGet/PublishCiphers.cmd index eebcf4e..33365ef 100644 --- a/Aspects/Security/Cryptography/Ciphers/NuGet/PublishCiphers.cmd +++ b/Aspects/Security/Cryptography/Ciphers/NuGet/PublishCiphers.cmd @@ -3,17 +3,11 @@ cd %~dp0.. NuGet Update -self call "%VS140COMNTOOLS%vsvars32.bat" if not .%1.==.. NuGet SetApiKey %1 -msbuild vm.Aspects.Security.Cryptography.Ciphers.csproj /t:Rebuild /p:Configuration=Release40 /p:TargetFrameworkVersion=v4.0 +msbuild vm.Aspects.Security.Cryptography.Ciphers.csproj /t:Rebuild /p:Configuration=Release /p:TargetFrameworkVersion=v4.6 if errorlevel 1 goto exit -msbuild vm.Aspects.Security.Cryptography.Ciphers.csproj /t:Rebuild /p:Configuration=Release /p:TargetFrameworkVersion=v4.5 +msbuild EncryptedKey\EncryptedKey.csproj /t:Rebuild /p:Configuration=Release /p:TargetFrameworkVersion=v4.6 if errorlevel 1 goto exit -msbuild EncryptedKey\EncryptedKey.csproj /t:Rebuild /p:Configuration=Release40 /p:TargetFrameworkVersion=v4.0 -if errorlevel 1 goto exit -msbuild EncryptedKey\EncryptedKey.csproj /t:Rebuild /p:Configuration=Release /p:TargetFrameworkVersion=v4.5 -if errorlevel 1 goto exit -msbuild ProtectedKey\ProtectedKey.csproj /t:Rebuild /p:Configuration=Release40 /p:TargetFrameworkVersion=v4.0 -if errorlevel 1 goto exit -msbuild ProtectedKey\ProtectedKey.csproj /t:Rebuild /p:Configuration=Release /p:TargetFrameworkVersion=v4.5 +msbuild ProtectedKey\ProtectedKey.csproj /t:Rebuild /p:Configuration=Release /p:TargetFrameworkVersion=v4.6 if errorlevel 1 goto exit NuGet Pack NuGet\Ciphers.nuspec -Prop Configuration=Release if errorlevel 1 goto exit diff --git a/Aspects/Security/Cryptography/Ciphers/NullCipher.cs b/Aspects/Security/Cryptography/Ciphers/NullCipher.cs index 8c3c15d..c1950e0 100644 --- a/Aspects/Security/Cryptography/Ciphers/NullCipher.cs +++ b/Aspects/Security/Cryptography/Ciphers/NullCipher.cs @@ -1,9 +1,7 @@ using System; using System.Diagnostics.CodeAnalysis; using System.IO; -#if NET45 using System.Threading.Tasks; -#endif namespace vm.Aspects.Security.Cryptography.Ciphers { @@ -11,7 +9,7 @@ namespace vm.Aspects.Security.Cryptography.Ciphers /// The class NullCipher is a development- and test-friendly convenience class which implements trivially the interface: /// copies the source data blindly into the output target. /// - [SuppressMessage("Microsoft.Design", "CA1063:ImplementIDisposableCorrectly", Justification="N/A")] + [SuppressMessage("Microsoft.Design", "CA1063:ImplementIDisposableCorrectly", Justification = "N/A")] public sealed class NullCipher : ICipherAsync { #region ICipher Members @@ -34,8 +32,8 @@ public sealed class NullCipher : ICipherAsync /// or /// encryptedStream /// - [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId="1")] - [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId="0")] + [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "1")] + [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0")] public void Encrypt( Stream dataStream, Stream encryptedStream) @@ -57,8 +55,8 @@ public void Encrypt( /// or /// encryptedStream /// - [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId="1")] - [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId="0")] + [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "1")] + [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0")] public void Decrypt( Stream encryptedStream, Stream dataStream) @@ -99,7 +97,6 @@ public byte[] Decrypt( } #endregion -#if NET45 #region ICipherAsync Members /// /// encrypt as an asynchronous operation. @@ -113,8 +110,8 @@ public byte[] Decrypt( /// or /// encryptedStream /// - [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId="1")] - [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId="0")] + [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "1")] + [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0")] public async Task EncryptAsync( Stream dataStream, Stream encryptedStream) @@ -134,8 +131,8 @@ public async Task EncryptAsync( /// or /// encryptedStream /// - [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId="1")] - [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId="0")] + [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "1")] + [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0")] public async Task DecryptAsync( Stream encryptedStream, Stream dataStream) @@ -143,13 +140,12 @@ public async Task DecryptAsync( await encryptedStream.CopyToAsync(dataStream); } #endregion -#endif #region IDisposable pattern implementation /// /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. /// - [SuppressMessage("Microsoft.Design", "CA1063:ImplementIDisposableCorrectly", Justification="N/A")] + [SuppressMessage("Microsoft.Design", "CA1063:ImplementIDisposableCorrectly", Justification = "N/A")] public void Dispose() { GC.SuppressFinalize(this); diff --git a/Aspects/Security/Cryptography/Ciphers/NullHasher.cs b/Aspects/Security/Cryptography/Ciphers/NullHasher.cs index 9c248fb..03fae5c 100644 --- a/Aspects/Security/Cryptography/Ciphers/NullHasher.cs +++ b/Aspects/Security/Cryptography/Ciphers/NullHasher.cs @@ -9,7 +9,7 @@ namespace vm.Aspects.Security.Cryptography.Ciphers /// The class NullHasher is a development and test-friendly convenience class which implements trivially the interface: /// generates an empty array for hash and always verifies the hash to be correct. /// - [SuppressMessage("Microsoft.Design", "CA1063:ImplementIDisposableCorrectly", Justification="N/A")] + [SuppressMessage("Microsoft.Design", "CA1063:ImplementIDisposableCorrectly", Justification = "N/A")] public class NullHasher : IHasherAsync { #region IHasher Members @@ -89,7 +89,6 @@ public bool TryVerifyHash( public int SaltLength { get; set; } #endregion -#if NET45 #region IHasherAsync implementation /// /// hash as an asynchronous operation. @@ -130,14 +129,13 @@ public async Task TryVerifyHashAsync( return await Task.FromResult(true); } #endregion -#endif #region IDisposable Members /// /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. /// - [SuppressMessage("Microsoft.Design", "CA1063:ImplementIDisposableCorrectly", Justification="N/A")] + [SuppressMessage("Microsoft.Design", "CA1063:ImplementIDisposableCorrectly", Justification = "N/A")] public void Dispose() { GC.SuppressFinalize(this); diff --git a/Aspects/Security/Cryptography/Ciphers/NullStream.cs b/Aspects/Security/Cryptography/Ciphers/NullStream.cs index 9b6d73a..699aaed 100644 --- a/Aspects/Security/Cryptography/Ciphers/NullStream.cs +++ b/Aspects/Security/Cryptography/Ciphers/NullStream.cs @@ -1,10 +1,8 @@ using System.Diagnostics.CodeAnalysis; -using System.IO; using System.Diagnostics.Contracts; -#if NET45 -using System.Threading.Tasks; +using System.IO; using System.Threading; -#endif +using System.Threading.Tasks; namespace vm.Aspects.Security.Cryptography.Ciphers { @@ -117,7 +115,6 @@ public override void Write( { } -#if NET45 /// /// Asynchronously reads a sequence of bytes from the current stream, advances the position within the stream by the number of bytes read, and monitors cancellation requests. /// @@ -166,7 +163,6 @@ public override Task CopyToAsync( { return Task.FromResult(null); } -#endif /// /// When overridden in a derived class, sets the position within the current stream. diff --git a/Aspects/Security/Cryptography/Ciphers/PasswordHasher.cs b/Aspects/Security/Cryptography/Ciphers/PasswordHasher.cs index eef237f..febdc3f 100644 --- a/Aspects/Security/Cryptography/Ciphers/PasswordHasher.cs +++ b/Aspects/Security/Cryptography/Ciphers/PasswordHasher.cs @@ -4,9 +4,7 @@ using System.IO; using System.Security.Cryptography; using System.Threading; -#if NET45 using System.Threading.Tasks; -#endif namespace vm.Aspects.Security.Cryptography.Ciphers { @@ -145,7 +143,6 @@ public bool TryVerifyHash( return TryVerifyHash(data, hash); } -#if NET45 /// /// hash as an asynchronous operation. /// @@ -196,7 +193,6 @@ public async Task TryVerifyHashAsync( return await Task.Run(() => TryVerifyHash(data, hash)); } -#endif /// /// Computes the hash of a specified . @@ -329,15 +325,6 @@ static byte[] GetHash( /// int _disposed; -#if NET40 - /// - /// Returns true if the object has already been disposed, otherwise false. - /// - public bool IsDisposed - { - get { return _disposed != 0; } - } -#else /// /// Returns true if the object has already been disposed, otherwise false. /// @@ -345,13 +332,12 @@ public bool IsDisposed { get { return Volatile.Read(ref _disposed) != 0; } } -#endif /// /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. /// /// Invokes the protected virtual . - [SuppressMessage("Microsoft.Design", "CA1063:ImplementIDisposableCorrectly", Justification="It is correct.")] + [SuppressMessage("Microsoft.Design", "CA1063:ImplementIDisposableCorrectly", Justification = "It is correct.")] public void Dispose() { // if it is disposed or in a process of disposing - return. diff --git a/Aspects/Security/Cryptography/Ciphers/PasswordProtectedKeyCipher.cs b/Aspects/Security/Cryptography/Ciphers/PasswordProtectedKeyCipher.cs index 668e4dd..fb36c51 100644 --- a/Aspects/Security/Cryptography/Ciphers/PasswordProtectedKeyCipher.cs +++ b/Aspects/Security/Cryptography/Ciphers/PasswordProtectedKeyCipher.cs @@ -185,7 +185,6 @@ public override byte[] ExportSymmetricKey() throw new NotImplementedException(); } -#if NET45 /// /// Asynchronously imports the symmetric key as a clear text. /// @@ -206,7 +205,6 @@ public override Task ExportSymmetricKeyAsync() { throw new NotImplementedException(); } -#endif #endregion #region Initialization of the symmetric key overrides @@ -222,7 +220,6 @@ protected override void InitializeSymmetricKey() IsSymmetricKeyInitialized = true; } -#if NET45 /// /// If not yet initialized, the method initializes the symmetric key by deriving it from the password and generating new salt bytes. /// @@ -232,7 +229,6 @@ protected override Task InitializeSymmetricKeyAsync() IsSymmetricKeyInitialized = true; return Task.FromResult(null); } -#endif /// /// If not yet initialized, the method initializes the symmetric key by deriving it from the password and generating new salt bytes. @@ -346,7 +342,6 @@ protected override void BeforeReadDecrypted( } #endregion -#if NET45 #region Async encrypting primitives /// /// Allows the inheritors to write asynchronously some unencrypted information to the @@ -410,7 +405,6 @@ protected override async Task BeforeReadDecryptedAsync( await base.BeforeReadDecryptedAsync(encryptedStream); } #endregion -#endif /// /// Performs the actual job of disposing the object. Here it disposes the password if it is not disposed yet. diff --git a/Aspects/Security/Cryptography/Ciphers/Properties/AssemblyInfo.cs b/Aspects/Security/Cryptography/Ciphers/Properties/AssemblyInfo.cs index cda1cf6..42fc259 100644 --- a/Aspects/Security/Cryptography/Ciphers/Properties/AssemblyInfo.cs +++ b/Aspects/Security/Cryptography/Ciphers/Properties/AssemblyInfo.cs @@ -5,9 +5,9 @@ // associated with an assembly. [assembly: AssemblyTitle("vm.Aspects.Security.Cryptography.Ciphers")] [assembly: AssemblyDescription("A set of cipher classes producing cipher-packages and encrypted and/or signed XML documents and elements.")] -[assembly: AssemblyVersion("1.9.1")] -[assembly: AssemblyFileVersion("1.9.1")] -[assembly: AssemblyInformationalVersion("1.9.1")] +[assembly: AssemblyVersion("1.9.2")] +[assembly: AssemblyFileVersion("1.9.2")] +[assembly: AssemblyInformationalVersion("1.9.2")] [assembly: System.Runtime.CompilerServices.InternalsVisibleTo( "vm.Aspects.Security.Cryptography.Ciphers.Tests, " + diff --git a/Aspects/Security/Cryptography/Ciphers/ProtectedKeyCipher.cs b/Aspects/Security/Cryptography/Ciphers/ProtectedKeyCipher.cs index 7dc4796..5cf9000 100644 --- a/Aspects/Security/Cryptography/Ciphers/ProtectedKeyCipher.cs +++ b/Aspects/Security/Cryptography/Ciphers/ProtectedKeyCipher.cs @@ -3,9 +3,7 @@ using System.Diagnostics.Contracts; using System.IO; using System.Security.Cryptography; -#if NET45 using System.Threading.Tasks; -#endif namespace vm.Aspects.Security.Cryptography.Ciphers { @@ -137,9 +135,9 @@ protected ProtectedKeyCipher( /// /// An I/O error occurred. /// - [SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Justification="The CryptoStream will do it.")] - [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId="1")] - [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId="0")] + [SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Justification = "The CryptoStream will do it.")] + [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "1")] + [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0")] public virtual void Encrypt( Stream dataStream, Stream encryptedStream) @@ -199,9 +197,9 @@ public virtual void Encrypt( /// /// An I/O error occurred. /// - [SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Justification="The CryptoStream will do it.")] - [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId="1")] - [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId="0")] + [SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Justification = "The CryptoStream will do it.")] + [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "1")] + [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0")] public virtual void Decrypt( Stream encryptedStream, Stream dataStream) @@ -302,7 +300,6 @@ public virtual byte[] Decrypt( } #endregion -#if NET45 #region ICipherAsync Members /// /// Asynchronously reads the clear text from the , encrypts it and writes the result into the @@ -331,8 +328,8 @@ public virtual byte[] Decrypt( /// /// An I/O error occurred. /// - [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId="1")] - [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId="0")] + [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "1")] + [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0")] public virtual async Task EncryptAsync( Stream dataStream, Stream encryptedStream) @@ -381,8 +378,8 @@ public virtual async Task EncryptAsync( /// /// An I/O error occurred. /// - [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId="1")] - [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId="0")] + [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "1")] + [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0")] public virtual async Task DecryptAsync( Stream encryptedStream, Stream dataStream) @@ -404,7 +401,6 @@ public virtual async Task DecryptAsync( } } #endregion -#endif #region Initialization of the symmetric key overrides /// @@ -426,7 +422,7 @@ protected override byte[] EncryptSymmetricKey() /// The method is called by the GoF template-methods. /// /// The encrypted key. - [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId="0")] + [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0")] protected override void DecryptSymmetricKey( byte[] encryptedKey) { @@ -445,7 +441,7 @@ protected override void DecryptSymmetricKey( /// The encrypted stream. /// Thrown when is . /// Thrown when cannot be written to. - [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId="0")] + [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0")] protected virtual void BeforeWriteEncrypted( Stream encryptedStream) { @@ -473,7 +469,7 @@ protected virtual byte[] EncryptIV() { Contract.Requires(IsSymmetricKeyInitialized, "The symmetric key must be initialized first."); - return ShouldEncryptIV + return ShouldEncryptIV ? ProtectedData.Protect(Symmetric.IV, null, DataProtectionScope.LocalMachine) : Symmetric.IV; } @@ -489,7 +485,7 @@ protected virtual byte[] EncryptIV() /// The created CryptoStream. /// Thrown when is . /// Thrown when cannot be written. - [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId="0")] + [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0")] protected virtual CryptoStream CreateEncryptingStream( Stream encryptedStream) { @@ -517,8 +513,8 @@ protected virtual CryptoStream CreateEncryptingStream( /// /// Thrown when either cannot be read or the cannot be written. /// - [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId="1")] - [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId="0")] + [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "1")] + [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0")] protected virtual void DoEncrypt( Stream dataStream, Stream cryptoStream) @@ -541,8 +537,8 @@ protected virtual void DoEncrypt( /// /// The encrypted stream. /// The crypto stream. - [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId="1")] - [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId="0")] + [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "1")] + [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0")] protected virtual void AfterWriteEncrypted( Stream encryptedStream, CryptoStream cryptoStream) @@ -566,7 +562,7 @@ protected virtual void AfterWriteEncrypted( /// The encrypted stream. /// Thrown when is . /// Thrown when cannot be read. - [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId="0")] + [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0")] protected virtual void BeforeReadDecrypted( Stream encryptedStream) { @@ -619,7 +615,7 @@ protected virtual void DecryptIV( /// The created CryptoStream. /// Thrown when is . /// Thrown when cannot be read. - [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId="0")] + [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0")] protected virtual CryptoStream CreateDecryptingStream( Stream encryptedStream) { @@ -649,8 +645,8 @@ protected virtual CryptoStream CreateDecryptingStream( /// /// Thrown when either cannot be written or the cannot be read. /// - [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId="1")] - [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId="0")] + [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "1")] + [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0")] protected virtual void DoDecrypt( Stream cryptoStream, Stream dataStream) @@ -671,8 +667,8 @@ protected virtual void DoDecrypt( /// The encrypted stream. /// The crypto stream. /// The method is called by the GoF template-methods. - [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId="1")] - [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId="0")] + [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "1")] + [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0")] protected virtual void AfterReadDecrypted( Stream encryptedStream, CryptoStream cryptoStream) @@ -685,7 +681,6 @@ protected virtual void AfterReadDecrypted( } #endregion -#if NET45 #region Async encrypting primitives /// /// Allows the inheritors to write asynchronously some unencrypted information to the @@ -700,7 +695,7 @@ protected virtual void AfterReadDecrypted( /// /// Thrown when is . /// Thrown when cannot be written to. - [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId="0")] + [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0")] protected virtual async Task BeforeWriteEncryptedAsync( Stream encryptedStream) { @@ -732,8 +727,8 @@ protected virtual async Task BeforeWriteEncryptedAsync( /// /// Thrown when either cannot be read or the cannot be written. /// - [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId="1")] - [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId="0")] + [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "1")] + [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0")] protected virtual async Task DoEncryptAsync( Stream dataStream, Stream cryptoStream) @@ -760,7 +755,7 @@ protected virtual async Task DoEncryptAsync( /// The encrypted stream. /// Thrown when is . /// Thrown when cannot be read. - [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId="0")] + [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0")] protected virtual async Task BeforeReadDecryptedAsync( Stream encryptedStream) { @@ -802,8 +797,8 @@ protected virtual async Task BeforeReadDecryptedAsync( /// /// Thrown when either cannot be written or the cannot be read. /// - [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId="1")] - [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId="0")] + [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "1")] + [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0")] protected virtual async Task DoDecryptAsync( Stream cryptoStream, Stream dataStream) @@ -817,7 +812,6 @@ protected virtual async Task DoDecryptAsync( await cryptoStream.CopyToAsync(dataStream); } #endregion -#endif #region IDisposable pattern implementation /// diff --git a/Aspects/Security/Cryptography/Ciphers/RsaSigner.cs b/Aspects/Security/Cryptography/Ciphers/RsaSigner.cs index b78cf9b..44bc505 100644 --- a/Aspects/Security/Cryptography/Ciphers/RsaSigner.cs +++ b/Aspects/Security/Cryptography/Ciphers/RsaSigner.cs @@ -4,10 +4,8 @@ using System.IO; using System.Security.Cryptography; using System.Security.Cryptography.X509Certificates; -using Microsoft.Practices.ServiceLocation; -#if NET45 using System.Threading.Tasks; -#endif +using Microsoft.Practices.ServiceLocation; namespace vm.Aspects.Security.Cryptography.Ciphers { @@ -157,7 +155,6 @@ public override bool TryVerifyHash( } #endregion -#if NET45 #region IHasherAsync methods /// /// hash as an asynchronous operation. @@ -198,7 +195,6 @@ public override async Task TryVerifyHashAsync( return deformatter.VerifySignature(hash, signature); } #endregion -#endif #region IDisposable pattern implementation /// diff --git a/Aspects/Security/Cryptography/Ciphers/SymmetricAlgorithmFactory.cs b/Aspects/Security/Cryptography/Ciphers/SymmetricAlgorithmFactory.cs index ac91558..c8451d0 100644 --- a/Aspects/Security/Cryptography/Ciphers/SymmetricAlgorithmFactory.cs +++ b/Aspects/Security/Cryptography/Ciphers/SymmetricAlgorithmFactory.cs @@ -1,6 +1,5 @@ using System; using System.Diagnostics.CodeAnalysis; -using System.Diagnostics.Contracts; using System.Globalization; using System.Security.Cryptography; using System.Threading; @@ -128,15 +127,6 @@ public string SymmetricAlgorithmName /// int _disposed; -#if NET40 - /// - /// Returns true if the object has already been disposed, otherwise false. - /// - public bool IsDisposed - { - get { return _disposed != 0; } - } -#else /// /// Returns true if the object has already been disposed, otherwise false. /// @@ -144,13 +134,12 @@ public bool IsDisposed { get { return Volatile.Read(ref _disposed) != 0; } } -#endif /// /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. /// /// Invokes the protected virtual . - [SuppressMessage("Microsoft.Design", "CA1063:ImplementIDisposableCorrectly", Justification="It is correct.")] + [SuppressMessage("Microsoft.Design", "CA1063:ImplementIDisposableCorrectly", Justification = "It is correct.")] public void Dispose() { // if it is disposed or in a process of disposing - return. diff --git a/Aspects/Security/Cryptography/Ciphers/SymmetricKeyCipherBase.cs b/Aspects/Security/Cryptography/Ciphers/SymmetricKeyCipherBase.cs index 510e1ae..596951f 100644 --- a/Aspects/Security/Cryptography/Ciphers/SymmetricKeyCipherBase.cs +++ b/Aspects/Security/Cryptography/Ciphers/SymmetricKeyCipherBase.cs @@ -131,7 +131,7 @@ protected void ResolveKeyStorage( /// Imports the symmetric key as a clear text. /// /// The key. - [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId="0")] + [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0")] public virtual void ImportSymmetricKey( byte[] key) { @@ -152,7 +152,6 @@ public virtual byte[] ExportSymmetricKey() return Symmetric.Key; } -#if NET45 /// /// Asynchronously imports the symmetric key as a clear text. /// @@ -160,7 +159,7 @@ public virtual byte[] ExportSymmetricKey() /// /// A object representing the process of asynchronously importing the symmetric key. /// - [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId="0")] + [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0")] public virtual async Task ImportSymmetricKeyAsync( byte[] key) { @@ -180,7 +179,6 @@ public virtual async Task ExportSymmetricKeyAsync() await InitializeSymmetricKeyAsync(); return Symmetric.Key; } -#endif #endregion #region Initialization of the symmetric key @@ -206,7 +204,6 @@ protected virtual void InitializeSymmetricKey() IsSymmetricKeyInitialized = true; } -#if NET45 /// /// Asynchronously initializes the symmetric key for encryption. /// @@ -229,7 +226,6 @@ protected virtual async Task InitializeSymmetricKeyAsync() IsSymmetricKeyInitialized = true; } -#endif /// /// Encrypts the symmetric key in preparation to put it in the crypto-package. @@ -260,15 +256,6 @@ protected abstract void DecryptSymmetricKey( /// int _disposed; -#if NET40 - /// - /// Returns true if the object has already been disposed, otherwise false. - /// - public bool IsDisposed - { - get { return _disposed != 0; } - } -#else /// /// Returns true if the object has already been disposed, otherwise false. /// @@ -276,13 +263,12 @@ public bool IsDisposed { get { return Volatile.Read(ref _disposed) != 0; } } -#endif /// /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. /// /// Invokes the protected virtual . - [SuppressMessage("Microsoft.Design", "CA1063:ImplementIDisposableCorrectly", Justification="It is correct.")] + [SuppressMessage("Microsoft.Design", "CA1063:ImplementIDisposableCorrectly", Justification = "It is correct.")] public void Dispose() { Contract.Ensures(_disposed!=0, "The object was not disposed successfully."); diff --git a/Aspects/Security/Cryptography/Ciphers/Test/EncryptedKeyCipherTest.cs b/Aspects/Security/Cryptography/Ciphers/Test/EncryptedKeyCipherTest.cs index 9d73cf7..2584ddb 100644 --- a/Aspects/Security/Cryptography/Ciphers/Test/EncryptedKeyCipherTest.cs +++ b/Aspects/Security/Cryptography/Ciphers/Test/EncryptedKeyCipherTest.cs @@ -78,7 +78,6 @@ public void IsDisposedTest() target.Dispose(); } -#if NET45 [TestMethod] public void FinalizerTest() { @@ -89,8 +88,7 @@ public void FinalizerTest() EncryptedKeyCipher collected; Assert.IsFalse(target.TryGetTarget(out collected)); - } -#endif + } #endregion #region IKeyManagement tests @@ -130,7 +128,6 @@ public void ExportSymmetricKeyTest() Assert.AreEqual(32, key.Length); } -#if NET45 [TestMethod] public void ExportSymmetricKeyAsyncTest() { @@ -158,9 +155,7 @@ public void ImportSymmetricKeyAsyncTest() var key = new byte[keyOld.Length].FillRandom(); target.ImportSymmetricKeyAsync(key).Wait(); - } -#endif - + } #endregion class InheritedEncryptedKeyCipher : EncryptedKeyCipher diff --git a/Aspects/Security/Cryptography/Ciphers/Test/EncryptedKeyCipherTest1.cs b/Aspects/Security/Cryptography/Ciphers/Test/EncryptedKeyCipherTest1.cs index cf645f6..cf54aaa 100644 --- a/Aspects/Security/Cryptography/Ciphers/Test/EncryptedKeyCipherTest1.cs +++ b/Aspects/Security/Cryptography/Ciphers/Test/EncryptedKeyCipherTest1.cs @@ -78,7 +78,6 @@ public void IsDisposedTest() target.Dispose(); } -#if NET45 [TestMethod] public void FinalizerTest() { @@ -89,8 +88,7 @@ public void FinalizerTest() EncryptedKeyCipher collected; Assert.IsFalse(target.TryGetTarget(out collected)); - } -#endif + } #endregion #region IKeyManagement tests @@ -130,7 +128,6 @@ public void ExportSymmetricKeyTest() Assert.AreEqual(32, key.Length); } -#if NET45 [TestMethod] public void ExportSymmetricKeyAsyncTest() { @@ -143,7 +140,7 @@ public void ExportSymmetricKeyAsyncTest() Assert.IsNotNull(key); Assert.AreEqual(32, key.Length); - } + } [TestMethod] public void ImportSymmetricKeyAsyncTest() @@ -159,8 +156,6 @@ public void ImportSymmetricKeyAsyncTest() target.ImportSymmetricKeyAsync(key).Wait(); } -#endif - #endregion class InheritedEncryptedKeyCipher : EncryptedKeyCipher diff --git a/Aspects/Security/Cryptography/Ciphers/Test/EncryptedNewKeyCipherTest.cs b/Aspects/Security/Cryptography/Ciphers/Test/EncryptedNewKeyCipherTest.cs index c0ca3dd..9459991 100644 --- a/Aspects/Security/Cryptography/Ciphers/Test/EncryptedNewKeyCipherTest.cs +++ b/Aspects/Security/Cryptography/Ciphers/Test/EncryptedNewKeyCipherTest.cs @@ -1,9 +1,7 @@ using System; using System.IO; -using Microsoft.VisualStudio.TestTools.UnitTesting; -#if NET45 using System.Threading.Tasks; -#endif +using Microsoft.VisualStudio.TestTools.UnitTesting; namespace vm.Aspects.Security.Cryptography.Ciphers.Tests { @@ -65,8 +63,6 @@ public void ImportSymmetricKeyTest() } } -#if NET45 - [TestMethod] [ExpectedException(typeof(NotImplementedException))] public void ExportSymmetricKeyAsyncTest() @@ -91,7 +87,6 @@ public void ImportSymmetricKeyAsyncTest() Assert.IsNull(target.ExportSymmetricKeyAsync().Result); } } -#endif #endregion #region IsDisposed tests @@ -110,7 +105,6 @@ public void IsDisposedTest() target.Dispose(); } -#if NET45 [TestMethod] public void FinalizerTest() { @@ -122,7 +116,6 @@ public void FinalizerTest() Assert.IsFalse(target.TryGetTarget(out collected)); } -#endif #endregion class InheritedEncryptedNewKeyCipher : EncryptedNewKeyCipher @@ -146,7 +139,6 @@ public void PublicBeforeReadDecrypted( base.BeforeReadDecrypted(encryptedStream); } -#if NET45 public async Task PublicBeforeWriteEncryptedAsync( Stream encryptedStream) { @@ -160,7 +152,6 @@ public async Task PublicBeforeReadDecryptedAsync( await InitializeSymmetricKeyAsync(); await base.BeforeReadDecryptedAsync(encryptedStream); } -#endif } [TestMethod] @@ -172,7 +163,6 @@ public void BeforeWriteEncryptedNonWritableStreamTest() target.PublicBeforeWriteEncrypted(TestUtilities.CreateNonWritableStream()); } -#if NET45 [TestMethod] [ExpectedException(typeof(ArgumentNullException))] public void BeforeWriteEncryptedAsyncNullStreamTest() @@ -221,7 +211,6 @@ public void BeforeReadDecryptedAsyncNonReadableStreamTest() target.PublicBeforeReadDecryptedAsync(stream).Wait(); }); } -#endif [TestMethod] [ExpectedException(typeof(ArgumentException))] diff --git a/Aspects/Security/Cryptography/Ciphers/Test/EncryptedNewKeyHashedCipherTest.cs b/Aspects/Security/Cryptography/Ciphers/Test/EncryptedNewKeyHashedCipherTest.cs index 49453d5..ed0691d 100644 --- a/Aspects/Security/Cryptography/Ciphers/Test/EncryptedNewKeyHashedCipherTest.cs +++ b/Aspects/Security/Cryptography/Ciphers/Test/EncryptedNewKeyHashedCipherTest.cs @@ -1,11 +1,9 @@ using System; +using System.Linq; using System.IO; using System.Security.Cryptography; -using Microsoft.VisualStudio.TestTools.UnitTesting; -#if NET45 -using System.Linq; using System.Threading.Tasks; -#endif +using Microsoft.VisualStudio.TestTools.UnitTesting; namespace vm.Aspects.Security.Cryptography.Ciphers.Tests { @@ -64,7 +62,6 @@ public void ImportSymmetricKeyTest() } } -#if NET45 [TestMethod] [ExpectedException(typeof(NotImplementedException))] public void ExportSymmetricKeyAsyncTest() @@ -89,7 +86,6 @@ public void ImportSymmetricKeyAsyncTest() Assert.IsNull(target.ExportSymmetricKeyAsync().Result); } } -#endif #endregion #region IsDisposed tests @@ -108,7 +104,6 @@ public void IsDisposedTest() target.Dispose(); } -#if NET45 [TestMethod] public void FinalizerTest() { @@ -120,7 +115,6 @@ public void FinalizerTest() Assert.IsFalse(target.TryGetTarget(out collected)); } -#endif #endregion [TestMethod] @@ -202,7 +196,6 @@ public void PublicBeforeReadDecrypted( base.BeforeReadDecrypted(encryptedStream); } -#if NET45 public async Task PublicBeforeWriteEncryptedAsync( Stream encryptedStream) { @@ -226,7 +219,6 @@ public async Task PublicLoadHashToValidateAsync( { await base.LoadHashToValidateAsync(encryptedStream); } -#endif public void PublicAfterReadDecrypted( Stream encryptedStream, @@ -290,7 +282,6 @@ public void BeforeWriteEncrypted2Test() } } -#if NET45 [TestMethod] [ExpectedException(typeof(ArgumentNullException))] public void BeforeWriteEncryptedAsync1Test() @@ -320,7 +311,6 @@ public void BeforeWriteEncryptedAsync2Test() throw x.InnerExceptions.First(); } } -#endif [TestMethod] [ExpectedException(typeof(ArgumentException))] @@ -374,7 +364,6 @@ public void BeforeReadDecrypted2Test() } } -#if NET45 [TestMethod] [ExpectedException(typeof(ArgumentNullException))] public void BeforeReadDecryptedAsync1Test() @@ -439,7 +428,6 @@ public void LoadHashToValidateAsync2Test() } }); } -#endif [TestMethod] [ExpectedException(typeof(ArgumentException))] diff --git a/Aspects/Security/Cryptography/Ciphers/Test/EncryptedNewKeySha256SignedCipherTest.cs b/Aspects/Security/Cryptography/Ciphers/Test/EncryptedNewKeySha256SignedCipherTest.cs index f97592b..d8899a9 100644 --- a/Aspects/Security/Cryptography/Ciphers/Test/EncryptedNewKeySha256SignedCipherTest.cs +++ b/Aspects/Security/Cryptography/Ciphers/Test/EncryptedNewKeySha256SignedCipherTest.cs @@ -75,7 +75,6 @@ public void ImportSymmetricKeyTest() } } -#if NET45 [TestMethod] [ExpectedException(typeof(NotImplementedException))] public void ExportSymmetricKeyAsyncTest() @@ -99,8 +98,7 @@ public void ImportSymmetricKeyAsyncTest() target.ImportSymmetricKey(new byte[17]); Assert.IsNull(target.ExportSymmetricKeyAsync().Result); } - } -#endif + } #endregion #region IsDisposed tests @@ -119,7 +117,6 @@ public void IsDisposedTest() target.Dispose(); } -#if NET45 [TestMethod] public void FinalizerTest() { @@ -130,8 +127,7 @@ public void FinalizerTest() EncryptedNewKeySignedCipher collected; Assert.IsFalse(target.TryGetTarget(out collected)); - } -#endif + } #endregion } } diff --git a/Aspects/Security/Cryptography/Ciphers/Test/EncryptedNewKeySignedCipherTest.cs b/Aspects/Security/Cryptography/Ciphers/Test/EncryptedNewKeySignedCipherTest.cs index 9f078ff..096913b 100644 --- a/Aspects/Security/Cryptography/Ciphers/Test/EncryptedNewKeySignedCipherTest.cs +++ b/Aspects/Security/Cryptography/Ciphers/Test/EncryptedNewKeySignedCipherTest.cs @@ -1,10 +1,8 @@ using System; using System.IO; using System.Security.Cryptography; -using Microsoft.VisualStudio.TestTools.UnitTesting; -#if NET45 using System.Threading.Tasks; -#endif +using Microsoft.VisualStudio.TestTools.UnitTesting; namespace vm.Aspects.Security.Cryptography.Ciphers.Tests { @@ -64,7 +62,6 @@ public void SignatureVerificationFailTest() var output = target.Decrypt(encrypted); } -#if NET45 [ExpectedException(typeof(CryptographicException))] [TestMethod] public void SignatureVerificationFailAsyncTest() @@ -90,7 +87,6 @@ public void SignatureVerificationFailAsyncTest() target.DecryptAsync(input, output).Wait(); }); } -#endif class InheritedEncryptedNewKeySignedCipher : EncryptedNewKeySignedCipher { @@ -118,13 +114,11 @@ public void PublicLoadHashToValidate( base.LoadHashToValidate(encryptedStream); } -#if NET45 public async Task PublicLoadHashToValidateAsync( Stream encryptedStream) { await base.LoadHashToValidateAsync(encryptedStream); } -#endif } [TestMethod] @@ -155,7 +149,6 @@ public void LoadHashToValidateNonReadableStreamTest() target.PublicLoadHashToValidate(stream); } -#if NET45 [TestMethod] [ExpectedException(typeof(ArgumentNullException))] public void LoadHashToValidateAsyncNullStreamTest() @@ -180,6 +173,5 @@ public void LoadHashToValidateAsyncNonReadableStreamTest() target.PublicLoadHashToValidateAsync(stream).Wait(); }); } -#endif } } diff --git a/Aspects/Security/Cryptography/Ciphers/Test/GenericCipherTest.cs b/Aspects/Security/Cryptography/Ciphers/Test/GenericCipherTest.cs index d520c17..3137fc0 100644 --- a/Aspects/Security/Cryptography/Ciphers/Test/GenericCipherTest.cs +++ b/Aspects/Security/Cryptography/Ciphers/Test/GenericCipherTest.cs @@ -1,10 +1,8 @@ using System; using System.IO; using System.Linq; -using Microsoft.VisualStudio.TestTools.UnitTesting; -#if NET45 using System.Threading.Tasks; -#endif +using Microsoft.VisualStudio.TestTools.UnitTesting; namespace vm.Aspects.Security.Cryptography.Ciphers.Tests { @@ -563,7 +561,6 @@ void StreamParameterizedEncryptTest64(int length) } } -#if NET45 async Task StreamParameterizedAsyncEncryptTest(int length) { using (var target = GetCipher()) @@ -609,8 +606,6 @@ async Task StreamParameterizedAsyncEncryptTest64(int length) } } } -#endif - void RoundTripParameterizedEncryptTest(int length) { @@ -699,7 +694,6 @@ void RoundTripParameterizedEncryptTest64(int length) } } -#if NET45 async Task RoundTripParameterizedAsyncEncryptTest(int length) { byte[] clearData = new byte[length].FillRandom(); @@ -785,7 +779,6 @@ async Task RoundTripParameterizedAsyncEncryptTest64(int length) Assert.IsTrue(clearData.SequenceEqual(decryptedData)); } } -#endif // -------------------------------------- @@ -927,7 +920,6 @@ public void RoundTripStreamMoreThanNx4kEncryptTest64() // -------------------------------------- -#if NET45 [TestMethod] [ExpectedException(typeof(ArgumentNullException))] public void StreamNullInputAsyncEncryptTest() @@ -1242,6 +1234,5 @@ public void RoundTripStreamMoreThanNx4kAsyncEncryptTest64() { RoundTripParameterizedAsyncEncryptTest64(3*4096+734).Wait(); } -#endif } } diff --git a/Aspects/Security/Cryptography/Ciphers/Test/GenericHasherTest.cs b/Aspects/Security/Cryptography/Ciphers/Test/GenericHasherTest.cs index 5c14b5e..08d3cc6 100644 --- a/Aspects/Security/Cryptography/Ciphers/Test/GenericHasherTest.cs +++ b/Aspects/Security/Cryptography/Ciphers/Test/GenericHasherTest.cs @@ -148,7 +148,6 @@ public void HashStreamNullInputHashTest() Assert.IsNull(hash); } -#if NET45 [TestMethod] public void StreamNullInputAsyncHashTest() { @@ -180,8 +179,7 @@ public void VerifyStreamNullInputAsyncHashTest() var verifiedTask = target.TryVerifyHashAsync(input, null); Assert.IsTrue(verifiedTask.Result); - } -#endif + } [TestMethod] public void VerifyStreamNullInputHashTest() @@ -233,7 +231,6 @@ void StreamParameterizedHashTest(int length, int saltLength = 8) } } -#if NET45 [TestMethod] public void RoundTripWrongLengthAsyncHashTest() { @@ -271,8 +268,7 @@ void StreamParameterizedAsyncHashTest(int length, int saltLength = 8) Assert.IsNotNull(hashTask.Result); Assert.IsTrue(hashTask.Result.Length > 0); } - } -#endif + } void RoundTripParameterizedHashTest(int length, int saltLength = 8, bool failed = false) { @@ -304,7 +300,6 @@ void RoundTripParameterizedHashTest(int length, int saltLength = 8, bool failed } } -#if NET45 void RoundTripParameterizedAsyncHashTest(int length, int saltLength = 8, bool failed = false) { var clearData = new byte[length].FillRandom(); @@ -333,8 +328,7 @@ void RoundTripParameterizedAsyncHashTest(int length, int saltLength = 8, bool fa else Assert.AreEqual(actual, !failed); } - } -#endif + } [TestMethod] public void Stream0HashTest() @@ -436,7 +430,6 @@ public void RoundTripStreamMoreThanNx4kTest() // -------------------------------------------- -#if NET45 [TestMethod] public void Stream0AsyncHashTest() { @@ -533,7 +526,6 @@ public void StreamMoreThanNx4kAsyncHashTest() public void RoundTripStreamMoreThanNx4kAsyncHashTest() { RoundTripParameterizedAsyncHashTest(3*4096+734); - } -#endif + } } } diff --git a/Aspects/Security/Cryptography/Ciphers/Test/HashAlgorithmFactoryTest.cs b/Aspects/Security/Cryptography/Ciphers/Test/HashAlgorithmFactoryTest.cs index 8d93b1c..6c14a45 100644 --- a/Aspects/Security/Cryptography/Ciphers/Test/HashAlgorithmFactoryTest.cs +++ b/Aspects/Security/Cryptography/Ciphers/Test/HashAlgorithmFactoryTest.cs @@ -1,15 +1,12 @@ -#if NET45 -using System; +using System; using System.Security.Cryptography; using System.Threading; using Microsoft.Practices.ServiceLocation; using Microsoft.Practices.Unity; using Microsoft.VisualStudio.TestTools.UnitTesting; -#endif namespace vm.Aspects.Security.Cryptography.Ciphers.Tests { -#if NET45 /// /// Summary description for HasherBadNameTest /// @@ -22,7 +19,7 @@ public class HashAlgorithmFactoryTest /// public TestContext TestContext { get; set; } - #region Additional test attributes + #region Additional test attributes static UnityServiceLocator _unityServiceLocator; public static void InitializeHashNameTest(string name) @@ -52,7 +49,7 @@ public static void CleanupTest() } #endregion - #region IsDisposed tests + #region IsDisposed tests [TestMethod] public void IsDisposedTest() { @@ -111,7 +108,7 @@ public void FinalizerTest() HashAlgorithmFactory collected; Assert.IsFalse(target.TryGetTarget(out collected)); - } + } #endregion [TestMethod] @@ -172,7 +169,7 @@ public void InitializedWithBadNameTest() { CleanupTest(); } - } + } [TestMethod] public void InitializedWithAlgorithmFromDITest() @@ -381,7 +378,6 @@ public void InitializedWithBadNameFromDIHashTest() { CleanupTest(); } - } + } } -#endif } diff --git a/Aspects/Security/Cryptography/Ciphers/Test/HasherTest.cs b/Aspects/Security/Cryptography/Ciphers/Test/HasherTest.cs index 24a0ded..c729558 100644 --- a/Aspects/Security/Cryptography/Ciphers/Test/HasherTest.cs +++ b/Aspects/Security/Cryptography/Ciphers/Test/HasherTest.cs @@ -1,10 +1,8 @@ using System; using System.IO; using System.Security.Cryptography; -using Microsoft.VisualStudio.TestTools.UnitTesting; -#if NET45 using System.Threading.Tasks; -#endif +using Microsoft.VisualStudio.TestTools.UnitTesting; namespace vm.Aspects.Security.Cryptography.Ciphers.Tests { @@ -36,7 +34,6 @@ public void IsDisposedTest() target.Dispose(); } -#if NET45 [TestMethod] public void FinalizerTest() { @@ -48,7 +45,6 @@ public void FinalizerTest() Assert.IsFalse(target.TryGetTarget(out collected)); } -#endif #endregion class InheritedHasher : Hasher @@ -60,14 +56,12 @@ public byte[] PublicWriteSalt( return base.WriteSalt(hashStream, salt); } -#if NET45 public async Task PublicWriteSaltAsync( CryptoStream hashStream, byte[] salt) { return await base.WriteSaltAsync(hashStream, salt); } -#endif public byte[] PublicFinalizeHashing( CryptoStream hashStream, @@ -111,7 +105,6 @@ public void WriteSaltNonWritableStreamTest() new byte[8]); } -#if NET45 [TestMethod] [ExpectedException(typeof(ArgumentNullException))] public void WriteSaltNullStreamAsyncTest() @@ -135,7 +128,6 @@ public void WriteSaltNonWritableStreamAsyncTest() new byte[8]).Wait(); }); } -#endif [TestMethod] [ExpectedException(typeof(ArgumentException))] diff --git a/Aspects/Security/Cryptography/Ciphers/Test/KeyFileTest.cs b/Aspects/Security/Cryptography/Ciphers/Test/KeyFileTest.cs index 253c27e..f8f8728 100644 --- a/Aspects/Security/Cryptography/Ciphers/Test/KeyFileTest.cs +++ b/Aspects/Security/Cryptography/Ciphers/Test/KeyFileTest.cs @@ -105,7 +105,6 @@ public void PutKeyBlankLocationTest() #endregion #region PutKeyAsync tests -#if NET45 [TestMethod] public void PutKeyAsyncTest() { @@ -167,8 +166,7 @@ public void PutKeyBlankLocationAsyncTest() target.PutKeyAsync(new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }, " \t").Wait(); }); - } -#endif + } #endregion #region GetKey tests @@ -212,7 +210,6 @@ public void GetKeyBlankLocationTest() #endregion #region GetKeyAsync tests -#if NET45 [TestMethod] public void GetKeyAsyncTest() { @@ -269,8 +266,7 @@ public void GetKeyBlankLocationAsyncTest() target.GetKeyAsync(" \t").Wait(); }); - } -#endif + } #endregion #region DeleteKey tests diff --git a/Aspects/Security/Cryptography/Ciphers/Test/NullHasherTest.cs b/Aspects/Security/Cryptography/Ciphers/Test/NullHasherTest.cs index 15a08bc..b4d29f6 100644 --- a/Aspects/Security/Cryptography/Ciphers/Test/NullHasherTest.cs +++ b/Aspects/Security/Cryptography/Ciphers/Test/NullHasherTest.cs @@ -1,7 +1,5 @@ -using Microsoft.VisualStudio.TestTools.UnitTesting; -#if NET45 -using System; -#endif +using System; +using Microsoft.VisualStudio.TestTools.UnitTesting; namespace vm.Aspects.Security.Cryptography.Ciphers.Tests { @@ -30,7 +28,6 @@ public void IsDisposedTest() target.Dispose(); } -#if NET45 [TestMethod] public void FinalizerTest() { @@ -41,8 +38,7 @@ public void FinalizerTest() NullHasher collected; Assert.IsFalse(target.TryGetTarget(out collected)); - } -#endif + } #endregion } } diff --git a/Aspects/Security/Cryptography/Ciphers/Test/NullStreamTest.cs b/Aspects/Security/Cryptography/Ciphers/Test/NullStreamTest.cs index f1d85c7..4c0bbea 100644 --- a/Aspects/Security/Cryptography/Ciphers/Test/NullStreamTest.cs +++ b/Aspects/Security/Cryptography/Ciphers/Test/NullStreamTest.cs @@ -84,7 +84,6 @@ public void ReadTest() Assert.IsTrue(buffer.SequenceEqual(new byte[10] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 })); } -#if NET45 [TestMethod] public void ReadAsyncTest() { @@ -93,8 +92,7 @@ public void ReadAsyncTest() Assert.AreEqual(0, target.ReadAsync(buffer, 0, buffer.Length).Result); Assert.IsTrue(buffer.SequenceEqual(new byte[10] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 })); - } -#endif + } [TestMethod] public void WriteTest() @@ -111,7 +109,6 @@ public void WriteTest() Assert.AreEqual(0, target.Length); } -#if NET45 [TestMethod] public void WriteAsyncTest() { @@ -125,7 +122,7 @@ public void WriteAsyncTest() Assert.AreEqual(0, target.Position); Assert.AreEqual(0, target.Length); - } + } [TestMethod] public void CopyToAsyncTest() @@ -142,7 +139,6 @@ public void CopyToAsyncTest() Assert.AreEqual(0, stream.Length); } } -#endif [TestMethod] public void SeekTest() diff --git a/Aspects/Security/Cryptography/Ciphers/Test/PasswordHasherTest.cs b/Aspects/Security/Cryptography/Ciphers/Test/PasswordHasherTest.cs index bce668f..89e6560 100644 --- a/Aspects/Security/Cryptography/Ciphers/Test/PasswordHasherTest.cs +++ b/Aspects/Security/Cryptography/Ciphers/Test/PasswordHasherTest.cs @@ -38,7 +38,6 @@ public void IsDisposedTest() target.Dispose(); } -#if NET45 [TestMethod] public void FinalizerTest() { @@ -49,8 +48,7 @@ public void FinalizerTest() PasswordHasher collected; Assert.IsFalse(target.TryGetTarget(out collected)); - } -#endif + } #endregion [TestMethod] diff --git a/Aspects/Security/Cryptography/Ciphers/Test/PasswordProtectedKeyCipherTest.cs b/Aspects/Security/Cryptography/Ciphers/Test/PasswordProtectedKeyCipherTest.cs index 0677a1a..9a09953 100644 --- a/Aspects/Security/Cryptography/Ciphers/Test/PasswordProtectedKeyCipherTest.cs +++ b/Aspects/Security/Cryptography/Ciphers/Test/PasswordProtectedKeyCipherTest.cs @@ -60,7 +60,6 @@ public void ImportSymmetricKeyTest() } } -#if NET45 [TestMethod] [ExpectedException(typeof(NotImplementedException))] public void ExportSymmetricKeyAsyncTest() @@ -84,8 +83,7 @@ public void ImportSymmetricKeyAsyncTest() target.ImportSymmetricKey(new byte[17]); Assert.IsNull(target.ExportSymmetricKeyAsync().Result); } - } -#endif + } #endregion #region IsDisposed tests @@ -104,7 +102,6 @@ public void IsDisposedTest() target.Dispose(); } -#if NET45 [TestMethod] public void FinalizerTest() { @@ -115,8 +112,7 @@ public void FinalizerTest() PasswordProtectedKeyCipher collected; Assert.IsFalse(target.TryGetTarget(out collected)); - } -#endif + } #endregion SecureString CreateSecureString(string password) @@ -168,7 +164,6 @@ public void PublicBeforeReadDecrypted( base.BeforeReadDecrypted(encryptedStream); } -#if NET45 public Task PublicBeforeWriteEncryptedAsync( Stream encryptedStream) { @@ -179,8 +174,7 @@ public Task PublicBeforeReadDecryptedAsync( Stream encryptedStream) { return base.BeforeReadDecryptedAsync(encryptedStream); - } -#endif + } public byte[] PublicEncryptSymmetricKey() { @@ -212,7 +206,6 @@ public void BeforeReadDecryptedNonReadableStreamTest() target.PublicBeforeReadDecrypted(TestUtilities.CreateNonReadableStream()); } -#if NET45 [TestMethod] [ExpectedException(typeof(NotImplementedException))] public void EncryptSymmetricKeyTest() @@ -268,7 +261,6 @@ public void BeforeReadDecryptedNonReadableStreamAsyncTest() target.PublicBeforeReadDecryptedAsync(TestUtilities.CreateNonReadableStream()).Wait(); }); - } -#endif + } } } diff --git a/Aspects/Security/Cryptography/Ciphers/Test/ProtectedKeyCipherDIAlgorithmTest.cs b/Aspects/Security/Cryptography/Ciphers/Test/ProtectedKeyCipherDIAlgorithmTest.cs index 0f0b895..07ed58b 100644 --- a/Aspects/Security/Cryptography/Ciphers/Test/ProtectedKeyCipherDIAlgorithmTest.cs +++ b/Aspects/Security/Cryptography/Ciphers/Test/ProtectedKeyCipherDIAlgorithmTest.cs @@ -1,11 +1,9 @@ using System; using System.IO; -using Microsoft.VisualStudio.TestTools.UnitTesting; -#if NET45 using System.Security.Cryptography; -using Microsoft.Practices.Unity; using Microsoft.Practices.ServiceLocation; -#endif +using Microsoft.Practices.Unity; +using Microsoft.VisualStudio.TestTools.UnitTesting; namespace vm.Aspects.Security.Cryptography.Ciphers.Tests { @@ -14,21 +12,17 @@ public class ProtectedKeyCipherTest : GenericCipherTest { const string keyFileName = "protected.key"; -#if NET45 static IUnityContainer _container; static IServiceLocator _serviceLocator; -#endif [ClassInitialize] public static void ClassInitialize(TestContext testContext) { -#if NET45 _container = new UnityContainer(); _container.RegisterType(); _serviceLocator = new UnityServiceLocator(_container); ServiceLocator.SetLocatorProvider(() => _serviceLocator); -#endif ClassCleanup(); } diff --git a/Aspects/Security/Cryptography/Ciphers/Test/ProtectedKeyCipherTest.cs b/Aspects/Security/Cryptography/Ciphers/Test/ProtectedKeyCipherTest.cs index d475052..d8ccebe 100644 --- a/Aspects/Security/Cryptography/Ciphers/Test/ProtectedKeyCipherTest.cs +++ b/Aspects/Security/Cryptography/Ciphers/Test/ProtectedKeyCipherTest.cs @@ -2,10 +2,8 @@ using System.IO; using System.Linq; using System.Security.Cryptography; -using Microsoft.VisualStudio.TestTools.UnitTesting; -#if NET45 using System.Threading.Tasks; -#endif +using Microsoft.VisualStudio.TestTools.UnitTesting; namespace vm.Aspects.Security.Cryptography.Ciphers.Tests { @@ -81,7 +79,6 @@ public void RoundTripTest0() } } -#if NET45 [TestMethod] public void RoundTripAsyncTest0() { @@ -119,8 +116,7 @@ public void RoundTripAsyncTest0() if (!string.IsNullOrWhiteSpace(keyFile)) File.Delete(keyFile); } - } -#endif + } #region IsDisposed tests [TestMethod] @@ -138,7 +134,6 @@ public void IsDisposedTest() target.Dispose(); } -#if NET45 [TestMethod] public void FinalizerTest() { @@ -149,8 +144,7 @@ public void FinalizerTest() ProtectedKeyCipher collected; Assert.IsFalse(target.TryGetTarget(out collected)); - } -#endif + } #endregion #region IKeyManagement tests @@ -190,7 +184,6 @@ public void ExportSymmetricKeyTest() Assert.IsTrue(key.Length >= 24); } -#if NET45 [TestMethod] public void ExportSymmetricKeyAsyncTest() { @@ -217,9 +210,7 @@ public void ImportSymmetricKeyAsyncTest() var key = new byte[keyOld.Length].FillRandom(); target.ImportSymmetricKeyAsync(key).Wait(); - } -#endif - + } #endregion class InheritedProtectedKeyCipher : ProtectedKeyCipher @@ -241,19 +232,17 @@ public void PublicBeforeReadDecrypted( base.BeforeReadDecrypted(encryptedStream); } -#if NET45 public Task PublicBeforeWriteEncryptedAsync( Stream encryptedStream) { return base.BeforeWriteEncryptedAsync(encryptedStream); - } + } public Task PublicBeforeReadDecryptedAsync( Stream encryptedStream) { return base.BeforeReadDecryptedAsync(encryptedStream); } -#endif public CryptoStream PublicCreateEncryptingStream( Stream encryptedStream) @@ -281,7 +270,6 @@ public void PublicDoDecrypt( base.DoDecrypt(cryptoStream, dataStream); } -#if NET45 public Task PublicDoEncryptAsync( Stream dataStream, Stream cryptoStream) @@ -294,8 +282,7 @@ public Task PublicDoDecryptAsync( Stream dataStream) { return base.DoDecryptAsync(cryptoStream, dataStream); - } -#endif + } } [TestMethod] @@ -316,7 +303,6 @@ public void BeforeReadDecryptedNonReadableStreamTest() target.PublicBeforeReadDecrypted(TestUtilities.CreateNonReadableStream()); } -#if NET45 [TestMethod] [ExpectedException(typeof(ArgumentNullException))] public void BeforeWriteEncryptedNullStreamAsyncTest() @@ -363,8 +349,7 @@ public void BeforeReadDecryptedNonReadableStreamAsyncTest() target.PublicBeforeReadDecryptedAsync(TestUtilities.CreateNonReadableStream()).Wait(); }); - } -#endif + } [TestMethod] [ExpectedException(typeof(ArgumentException))] @@ -403,7 +388,6 @@ public void DoEncryptNonWritableCryptoTest() } -#if NET45 [TestMethod] [ExpectedException(typeof(ArgumentNullException))] public void DoEncryptNullDataAsyncTest() @@ -450,8 +434,7 @@ public void DoEncryptNonWritableCryptoAsyncTest() target.PublicDoEncryptAsync(new MemoryStream(new byte[10]), TestUtilities.CreateNonWritableStream()).Wait(); }); - } -#endif + } //// @@ -474,7 +457,6 @@ public void DoDecryptNonWritableDataTest() } -#if NET45 [TestMethod] [ExpectedException(typeof(ArgumentNullException))] public void DoDecryptNullCryptoAsyncTest() @@ -521,8 +503,6 @@ public void DoDecryptNonWritableDataAsyncTest() target.PublicDoDecryptAsync(new MemoryStream(new byte[10]), TestUtilities.CreateNonWritableStream()).Wait(); }); - } -#endif - + } } } diff --git a/Aspects/Security/Cryptography/Ciphers/Test/RsaSignerSha256Test.cs b/Aspects/Security/Cryptography/Ciphers/Test/RsaSignerSha256Test.cs index c771d23..18f14a5 100644 --- a/Aspects/Security/Cryptography/Ciphers/Test/RsaSignerSha256Test.cs +++ b/Aspects/Security/Cryptography/Ciphers/Test/RsaSignerSha256Test.cs @@ -32,7 +32,6 @@ public void IsDisposedTest() target.Dispose(); } -#if NET45 [TestMethod] public void FinalizerTest() { @@ -43,8 +42,7 @@ public void FinalizerTest() RsaSigner collected; Assert.IsFalse(target.TryGetTarget(out collected)); - } -#endif + } #endregion } } diff --git a/Aspects/Security/Cryptography/Ciphers/Test/RsaSignerTest.cs b/Aspects/Security/Cryptography/Ciphers/Test/RsaSignerTest.cs index f15fc31..1f0b613 100644 --- a/Aspects/Security/Cryptography/Ciphers/Test/RsaSignerTest.cs +++ b/Aspects/Security/Cryptography/Ciphers/Test/RsaSignerTest.cs @@ -32,7 +32,6 @@ public void IsDisposedTest() target.Dispose(); } -#if NET45 [TestMethod] public void FinalizerTest() { @@ -43,8 +42,7 @@ public void FinalizerTest() RsaSigner collected; Assert.IsFalse(target.TryGetTarget(out collected)); - } -#endif + } #endregion [TestMethod] diff --git a/Aspects/Security/Cryptography/Ciphers/Test/SymmetricAlgorithmFactoryTest.cs b/Aspects/Security/Cryptography/Ciphers/Test/SymmetricAlgorithmFactoryTest.cs index 8d5df90..ca977b2 100644 --- a/Aspects/Security/Cryptography/Ciphers/Test/SymmetricAlgorithmFactoryTest.cs +++ b/Aspects/Security/Cryptography/Ciphers/Test/SymmetricAlgorithmFactoryTest.cs @@ -1,11 +1,9 @@ using System; using System.Security.Cryptography; using System.Threading; -using Microsoft.VisualStudio.TestTools.UnitTesting; -#if NET45 -using Microsoft.Practices.Unity; using Microsoft.Practices.ServiceLocation; -#endif +using Microsoft.Practices.Unity; +using Microsoft.VisualStudio.TestTools.UnitTesting; namespace vm.Aspects.Security.Cryptography.Ciphers.Tests @@ -23,40 +21,32 @@ public class SymmetricAlgorithmFactoryTest public TestContext TestContext { get; set; } #region Additional test attributes -#if NET45 static UnityServiceLocator _unityServiceLocator; -#endif public static void InitializeSymmetricNameTest(string name) { -#if NET45 ServiceLocatorWrapper.Reset(); _unityServiceLocator = new UnityServiceLocator( new UnityContainer() .RegisterInstance(Algorithms.Symmetric.ResolveName, name)); ServiceLocator.SetLocatorProvider(() => _unityServiceLocator); -#endif } public static void InitializeSymmetricAlgorithmTest() { -#if NET45 ServiceLocatorWrapper.Reset(); _unityServiceLocator = new UnityServiceLocator( new UnityContainer() .RegisterType()); ServiceLocator.SetLocatorProvider(() => _unityServiceLocator); -#endif } public static void CleanupTest() { -#if NET45 ServiceLocator.SetLocatorProvider(null); if (_unityServiceLocator != null) _unityServiceLocator.Dispose(); ServiceLocatorWrapper.Reset(); -#endif } #endregion @@ -150,7 +140,7 @@ public void InitializedWithGoodNameTest() } } - [TestMethod] + [TestMethod] public void InitializedWithAlgorithmFromDITest() { try @@ -177,8 +167,6 @@ public void InitializedWithAlgorithmFromDITest() } } -#if NET45 - [TestMethod] [TestCategory("SlowTest")] public void FinalizerTest() @@ -348,7 +336,6 @@ public void InitializedTest5() CleanupTest(); } } -#endif [TestMethod] public void InitializedWithEmptyNameFromDITest() @@ -376,7 +363,6 @@ public void InitializedWithEmptyNameFromDITest() } } -#if NET45 [TestMethod] [ExpectedException(typeof(ActivationException))] public void InitializedWithBadNameFromDISymmetricTest() @@ -393,7 +379,6 @@ public void InitializedWithBadNameFromDISymmetricTest() { CleanupTest(); } - } -#endif + } } } diff --git a/Aspects/Security/Cryptography/Ciphers/Test/Xml/EncryptedKeyXmlCipherTest.cs b/Aspects/Security/Cryptography/Ciphers/Test/Xml/EncryptedKeyXmlCipherTest.cs index c92e8b0..1c6637c 100644 --- a/Aspects/Security/Cryptography/Ciphers/Test/Xml/EncryptedKeyXmlCipherTest.cs +++ b/Aspects/Security/Cryptography/Ciphers/Test/Xml/EncryptedKeyXmlCipherTest.cs @@ -83,7 +83,6 @@ public void IsDisposedTest() target.Dispose(); } -#if NET45 [TestMethod] public void FinalizerTest() { @@ -94,8 +93,7 @@ public void FinalizerTest() EncryptedKeyXmlCipher collected; Assert.IsFalse(target.TryGetTarget(out collected)); - } -#endif + } #endregion } } diff --git a/Aspects/Security/Cryptography/Ciphers/Test/Xml/EncryptedNewKeySignedXmlCipherTest.cs b/Aspects/Security/Cryptography/Ciphers/Test/Xml/EncryptedNewKeySignedXmlCipherTest.cs index 2dbfe14..5595ac5 100644 --- a/Aspects/Security/Cryptography/Ciphers/Test/Xml/EncryptedNewKeySignedXmlCipherTest.cs +++ b/Aspects/Security/Cryptography/Ciphers/Test/Xml/EncryptedNewKeySignedXmlCipherTest.cs @@ -111,7 +111,6 @@ public void ImportSymmetricKeyTest() } } -#if NET45 [TestMethod] [ExpectedException(typeof(NotImplementedException))] public void ExportSymmetricKeyAsyncTest() @@ -135,8 +134,7 @@ public void ImportSymmetricKeyAsyncTest() target.ImportSymmetricKey(new byte[17]); Assert.IsNull(target.ExportSymmetricKeyAsync().Result); } - } -#endif + } #endregion #region IsDisposed tests @@ -155,7 +153,6 @@ public void IsDisposedTest() target.Dispose(); } -#if NET45 [TestMethod] public void FinalizerTest() { @@ -166,8 +163,7 @@ public void FinalizerTest() EncryptedNewKeySignedXmlCipher collected; Assert.IsFalse(target.TryGetTarget(out collected)); - } -#endif + } #endregion } } diff --git a/Aspects/Security/Cryptography/Ciphers/Test/Xml/EncryptedNewKeyXmlCipherTest.cs b/Aspects/Security/Cryptography/Ciphers/Test/Xml/EncryptedNewKeyXmlCipherTest.cs index 1abf493..8bdf138 100644 --- a/Aspects/Security/Cryptography/Ciphers/Test/Xml/EncryptedNewKeyXmlCipherTest.cs +++ b/Aspects/Security/Cryptography/Ciphers/Test/Xml/EncryptedNewKeyXmlCipherTest.cs @@ -81,7 +81,6 @@ public void ImportSymmetricKeyTest() } } -#if NET45 [TestMethod] [ExpectedException(typeof(NotImplementedException))] public void ExportSymmetricKeyAsyncTest() @@ -105,8 +104,7 @@ public void ImportSymmetricKeyAsyncTest() target.ImportSymmetricKey(new byte[17]); Assert.IsNull(target.ExportSymmetricKeyAsync().Result); } - } -#endif + } #endregion #region IsDisposed tests @@ -125,7 +123,6 @@ public void IsDisposedTest() target.Dispose(); } -#if NET45 [TestMethod] public void FinalizerTest() { @@ -136,8 +133,7 @@ public void FinalizerTest() EncryptedNewKeyXmlCipher collected; Assert.IsFalse(target.TryGetTarget(out collected)); - } -#endif + } #endregion } } diff --git a/Aspects/Security/Cryptography/Ciphers/Test/Xml/ProtectedKeyXmlCipherTest.cs b/Aspects/Security/Cryptography/Ciphers/Test/Xml/ProtectedKeyXmlCipherTest.cs index caf5344..410db33 100644 --- a/Aspects/Security/Cryptography/Ciphers/Test/Xml/ProtectedKeyXmlCipherTest.cs +++ b/Aspects/Security/Cryptography/Ciphers/Test/Xml/ProtectedKeyXmlCipherTest.cs @@ -138,7 +138,6 @@ public void IsDisposedTest() target.Dispose(); } -#if NET45 [TestMethod] public void FinalizerTest() { @@ -149,8 +148,7 @@ public void FinalizerTest() ProtectedKeyXmlCipher collected; Assert.IsFalse(target.TryGetTarget(out collected)); - } -#endif + } #endregion } } diff --git a/Aspects/Security/Cryptography/Ciphers/Test/Xml/RsaXmlSignerSha256Test.cs b/Aspects/Security/Cryptography/Ciphers/Test/Xml/RsaXmlSignerSha256Test.cs index f23e1d1..8edcc78 100644 --- a/Aspects/Security/Cryptography/Ciphers/Test/Xml/RsaXmlSignerSha256Test.cs +++ b/Aspects/Security/Cryptography/Ciphers/Test/Xml/RsaXmlSignerSha256Test.cs @@ -3,7 +3,6 @@ namespace vm.Aspects.Security.Cryptography.Ciphers.Xml.Tests { -#if NET45 [TestClass] public class RsaXmlSignerSha256Test : GenericXmlSignerTest { @@ -11,6 +10,5 @@ public override IXmlSigner GetSigner(SignatureLocation signatureLocation = Signa { return new RsaXmlSigner(CertificateFactory.GetSigningSha256Certificate()) { SignatureLocation = signatureLocation }; // SHA1 also works with this cert } - } -#endif + } } diff --git a/Aspects/Security/Cryptography/Ciphers/Test/Xml/RsaXmlSignerTest.cs b/Aspects/Security/Cryptography/Ciphers/Test/Xml/RsaXmlSignerTest.cs index 1a3f629..1d65f84 100644 --- a/Aspects/Security/Cryptography/Ciphers/Test/Xml/RsaXmlSignerTest.cs +++ b/Aspects/Security/Cryptography/Ciphers/Test/Xml/RsaXmlSignerTest.cs @@ -45,7 +45,6 @@ public void IsDisposedTest() target.Dispose(); } -#if NET45 [TestMethod] public void FinalizerTest() { @@ -56,8 +55,7 @@ public void FinalizerTest() RsaXmlSigner collected; Assert.IsFalse(target.TryGetTarget(out collected)); - } -#endif + } #endregion } } diff --git a/Aspects/Security/Cryptography/Ciphers/Test/vm.Aspects.Security.Cryptography.Ciphers.Tests.csproj b/Aspects/Security/Cryptography/Ciphers/Test/vm.Aspects.Security.Cryptography.Ciphers.Tests.csproj index 7a947b3..313dfaa 100644 --- a/Aspects/Security/Cryptography/Ciphers/Test/vm.Aspects.Security.Cryptography.Ciphers.Tests.csproj +++ b/Aspects/Security/Cryptography/Ciphers/Test/vm.Aspects.Security.Cryptography.Ciphers.Tests.csproj @@ -24,7 +24,7 @@ full false bin\Debug\ - TRACE;DEBUG;NET45 + TRACE;DEBUG prompt 4 True @@ -75,7 +75,7 @@ pdbonly true bin\Release\ - TRACE;NET45 + TRACE prompt 4 True @@ -131,7 +131,7 @@ true bin\DebugUnitTest\ - TRACE;DEBUG;NET40;TEST + TRACE;TEST;DEBUG full AnyCPU prompt diff --git a/Aspects/Security/Cryptography/Ciphers/ToByteArray.cs b/Aspects/Security/Cryptography/Ciphers/ToByteArray.cs index 9ff3300..1bfaba2 100644 --- a/Aspects/Security/Cryptography/Ciphers/ToByteArray.cs +++ b/Aspects/Security/Cryptography/Ciphers/ToByteArray.cs @@ -623,11 +623,7 @@ public static byte[] Convert(Guid[] data) /// /// Dictionary of types and the corresponding methods that can decrypt those types. /// -#if NET45 public readonly static IReadOnlyDictionary> ConvertTypedData = new ReadOnlyDictionary>( new Dictionary> -#elif NET40 - public readonly static IDictionary> ConvertTypedData = (new Dictionary> -#endif { #region ConvertTypedData [typeof(bool)] = d => Convert((bool) d), diff --git a/Aspects/Security/Cryptography/Ciphers/Xml/EncryptedNewKeyXmlCipher.cs b/Aspects/Security/Cryptography/Ciphers/Xml/EncryptedNewKeyXmlCipher.cs index 2c2d650..f458081 100644 --- a/Aspects/Security/Cryptography/Ciphers/Xml/EncryptedNewKeyXmlCipher.cs +++ b/Aspects/Security/Cryptography/Ciphers/Xml/EncryptedNewKeyXmlCipher.cs @@ -53,7 +53,7 @@ public override string KeyLocation /// /// The key. /// Always thrown. - [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId="0")] + [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0")] public override void ImportSymmetricKey( byte[] key) { @@ -69,13 +69,12 @@ public override byte[] ExportSymmetricKey() throw new NotImplementedException(); } -#if NET45 /// /// Asynchronously imports the symmetric key as a clear text. /// /// The key. /// Always thrown. - [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId="0")] + [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0")] public override Task ImportSymmetricKeyAsync( byte[] key) { @@ -90,7 +89,6 @@ public override Task ExportSymmetricKeyAsync() { throw new NotImplementedException(); } -#endif #endregion #region Overrides of the crypto-operations called by the GoF template-method diff --git a/Aspects/Security/Cryptography/Ciphers/Xml/RsaXmlSigner.cs b/Aspects/Security/Cryptography/Ciphers/Xml/RsaXmlSigner.cs index 7fa9092..dd434c1 100644 --- a/Aspects/Security/Cryptography/Ciphers/Xml/RsaXmlSigner.cs +++ b/Aspects/Security/Cryptography/Ciphers/Xml/RsaXmlSigner.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Deployment.Internal.CodeSigning; using System.Diagnostics.CodeAnalysis; using System.Diagnostics.Contracts; using System.Globalization; @@ -10,9 +11,6 @@ using System.Threading; using System.Xml; using Microsoft.Practices.ServiceLocation; -#if NET45 -using System.Deployment.Internal.CodeSigning; -#endif namespace vm.Aspects.Security.Cryptography.Ciphers.Xml { @@ -37,13 +35,11 @@ public class RsaXmlSigner : IXmlSigner readonly string _digestMethod; readonly AsymmetricAlgorithm _asymmetric; -#if NET45 [SuppressMessage("Microsoft.Performance", "CA1810:InitializeReferenceTypeStaticFieldsInline", Justification = "N/A")] static RsaXmlSigner() { CryptoConfig.AddAlgorithm(typeof(RSAPKCS1SHA256SignatureDescription), XmlConstants.XmlDsigRSAPKCS1SHA256Url); } -#endif #region Properties /// @@ -467,15 +463,6 @@ static string GetNewId( /// int _disposed; -#if NET40 - /// - /// Returns true if the object has already been disposed, otherwise false. - /// - public bool IsDisposed - { - get { return _disposed != 0; } - } -#else /// /// Returns true if the object has already been disposed, otherwise false. /// @@ -483,7 +470,6 @@ public bool IsDisposed { get { return Volatile.Read(ref _disposed) != 0; } } -#endif /// /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. diff --git a/Aspects/Security/Cryptography/Ciphers/vm.Aspects.Security.Cryptography.Ciphers.csproj b/Aspects/Security/Cryptography/Ciphers/vm.Aspects.Security.Cryptography.Ciphers.csproj index 56b23be..a3eed9d 100644 --- a/Aspects/Security/Cryptography/Ciphers/vm.Aspects.Security.Cryptography.Ciphers.csproj +++ b/Aspects/Security/Cryptography/Ciphers/vm.Aspects.Security.Cryptography.Ciphers.csproj @@ -9,7 +9,7 @@ Properties vm.Aspects.Security.Cryptography.Ciphers vm.Aspects.Security.Cryptography.Ciphers - v4.0 + v4.6 512 1 @@ -19,7 +19,7 @@ full false bin\Debug\ - TRACE;DEBUG;NET45 + TRACE;DEBUG;CODE_ANALYSIS prompt 4 bin\Debug\vm.Aspects.Security.Cryptography.Ciphers.XML @@ -74,7 +74,7 @@ pdbonly true bin\Release\ - TRACE;NET45 + TRACE prompt 4 bin\Release\vm.Aspects.Security.Cryptography.Ciphers.XML @@ -134,7 +134,7 @@ true bin\DebugUnitTest\ - TRACE;DEBUG;CODE_ANALYSIS;CODE_ANALYSIS;NET40;TEST + TRACE;DEBUG;CODE_ANALYSIS;TEST bin\DebugUnitTest\vm.Aspects.Security.Cryptography.Ciphers.XML full AnyCPU @@ -186,170 +186,6 @@ 0 false - - true - bin\Debug40\ - TRACE;DEBUG;CODE_ANALYSIS;NET45 - bin\Debug40\vm.Aspects.Security.Cryptography.Ciphers.XML - full - AnyCPU - true - prompt - ..\..\..\..\Common Items\vmAllRules.ruleset - True - False - True - False - False - True - True - True - True - True - True - True - True - True - True - True - True - True - True - False - False - True - True - True - True - True - True - False - False - - - - - - - - True - False - False - True - Full - DoNotBuild - 0 - false - - - bin\Release40\ - TRACE;NET40 - bin\Release40\vm.Aspects.Security.Cryptography.Ciphers.XML - true - pdbonly - AnyCPU - prompt - ..\..\..\..\Common Items\vmAllRules.ruleset - True - False - True - False - False - False - True - True - True - True - True - True - True - True - False - True - False - True - False - False - False - False - True - False - True - True - True - False - False - - - - - - - - True - False - False - True - ReleaseRequires - DoNotBuild - 0 - false - - - true - bin\DebugUnitTest40\ - CODE_ANALYSIS;TRACE;DEBUG;CODE_ANALYSIS;NET45;TEST - bin\DebugUnitTest40\vm.Aspects.Security.Cryptography.Ciphers.XML - full - AnyCPU - true - prompt - ..\..\..\..\Common Items\vmAllRules.ruleset - false - True - False - True - False - False - True - True - True - True - True - True - True - True - True - True - True - True - True - True - False - False - True - True - True - True - True - True - False - False - - - - - - - - True - False - False - True - Full - DoNotBuild - 0 - ..\..\..\..\packages\CommonServiceLocator.1.3\lib\portable-net4+sl5+netcore45+wpa81+wp8\Microsoft.Practices.ServiceLocation.dll diff --git a/Aspects/Wcf/Properties/AssemblyInfo.cs b/Aspects/Wcf/Properties/AssemblyInfo.cs index 050923a..f0dab78 100644 --- a/Aspects/Wcf/Properties/AssemblyInfo.cs +++ b/Aspects/Wcf/Properties/AssemblyInfo.cs @@ -3,9 +3,9 @@ [assembly: AssemblyTitle("Wcf")] [assembly: AssemblyDescription("A set of classes and generics simplifying the initial configuration work of creating WCF services.")] -[assembly: AssemblyVersion("1.0.5")] -[assembly: AssemblyFileVersion("1.0.5")] -[assembly: AssemblyInformationalVersion("1.0.5")] +[assembly: AssemblyVersion("1.0.6")] +[assembly: AssemblyFileVersion("1.0.6")] +[assembly: AssemblyInformationalVersion("1.0.6")] [assembly: System.Runtime.CompilerServices.InternalsVisibleTo( "vm.Aspects.Wcf.Test, " +