From de498bdbb4eff054ed833a07400019639d740d1a Mon Sep 17 00:00:00 2001 From: Krzysztof Wicher Date: Tue, 25 Apr 2017 14:04:23 -0700 Subject: [PATCH 1/3] Disable Aes test TestDecryptorReusability when quirk disabled or old netfx --- .../AES/DecryptorReusability.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/Common/tests/System/Security/Cryptography/AlgorithmImplementations/AES/DecryptorReusability.cs b/src/Common/tests/System/Security/Cryptography/AlgorithmImplementations/AES/DecryptorReusability.cs index b411729ae8ff..42b12543aa59 100644 --- a/src/Common/tests/System/Security/Cryptography/AlgorithmImplementations/AES/DecryptorReusability.cs +++ b/src/Common/tests/System/Security/Cryptography/AlgorithmImplementations/AES/DecryptorReusability.cs @@ -13,6 +13,10 @@ public static class DecryptorReusabilty [Fact] public static void TestDecryptorReusability() { + // See https://github.com/dotnet/corefx/issues/18903 for details + if (!ShouldDescriptorBeReusable()) + return; + byte[] expectedPlainText = new byte[] { 0x14, 0x30, 0x71, 0xad, 0xed, 0x8e, 0x58, 0x84, @@ -66,5 +70,19 @@ public static void TestDecryptorReusability() } } } + + private static bool ShouldDescriptorBeReusable() + { + if (!PlatformDetection.IsFullFramework) + return true; + + bool doNotResetDecryptor; + if (AppContext.TryGetSwitch("Switch.System.Security.Cryptography.AesCryptoServiceProvider.DontCorrectlyResetDecryptor", out doNotResetDecryptor)) + { + return !doNotResetDecryptor; + } + + return false; + } } } From 919790bc9b61171e97b0f990c6059e3dd8df3cc0 Mon Sep 17 00:00:00 2001 From: Krzysztof Wicher Date: Wed, 26 Apr 2017 14:25:01 -0700 Subject: [PATCH 2/3] Replace manual test skip with ConditionalFact --- .../AlgorithmImplementations/AES/DecryptorReusability.cs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/Common/tests/System/Security/Cryptography/AlgorithmImplementations/AES/DecryptorReusability.cs b/src/Common/tests/System/Security/Cryptography/AlgorithmImplementations/AES/DecryptorReusability.cs index 42b12543aa59..1bc542a0d25c 100644 --- a/src/Common/tests/System/Security/Cryptography/AlgorithmImplementations/AES/DecryptorReusability.cs +++ b/src/Common/tests/System/Security/Cryptography/AlgorithmImplementations/AES/DecryptorReusability.cs @@ -10,13 +10,10 @@ namespace System.Security.Cryptography.Encryption.Aes.Tests public static class DecryptorReusabilty { - [Fact] + // See https://github.com/dotnet/corefx/issues/18903 for details + [ConditionalFact(nameof(ShouldDescriptorBeReusable))] public static void TestDecryptorReusability() { - // See https://github.com/dotnet/corefx/issues/18903 for details - if (!ShouldDescriptorBeReusable()) - return; - byte[] expectedPlainText = new byte[] { 0x14, 0x30, 0x71, 0xad, 0xed, 0x8e, 0x58, 0x84, From e5da9bde217ab0140c91005d5b2c35515d481e37 Mon Sep 17 00:00:00 2001 From: Krzysztof Wicher Date: Thu, 27 Apr 2017 11:41:09 -0700 Subject: [PATCH 3/3] fix typo: descriptor -> decryptor --- .../AlgorithmImplementations/AES/DecryptorReusability.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Common/tests/System/Security/Cryptography/AlgorithmImplementations/AES/DecryptorReusability.cs b/src/Common/tests/System/Security/Cryptography/AlgorithmImplementations/AES/DecryptorReusability.cs index 1bc542a0d25c..0749eacd500f 100644 --- a/src/Common/tests/System/Security/Cryptography/AlgorithmImplementations/AES/DecryptorReusability.cs +++ b/src/Common/tests/System/Security/Cryptography/AlgorithmImplementations/AES/DecryptorReusability.cs @@ -11,7 +11,7 @@ namespace System.Security.Cryptography.Encryption.Aes.Tests public static class DecryptorReusabilty { // See https://github.com/dotnet/corefx/issues/18903 for details - [ConditionalFact(nameof(ShouldDescriptorBeReusable))] + [ConditionalFact(nameof(ShouldDecryptorBeReusable))] public static void TestDecryptorReusability() { byte[] expectedPlainText = new byte[] @@ -68,7 +68,7 @@ public static void TestDecryptorReusability() } } - private static bool ShouldDescriptorBeReusable() + private static bool ShouldDecryptorBeReusable() { if (!PlatformDetection.IsFullFramework) return true;