From cfbc40a824434e5965d4432074e3df36e214f5d0 Mon Sep 17 00:00:00 2001 From: Michael Schwarz Date: Thu, 10 Oct 2024 08:50:51 +0200 Subject: [PATCH] changed to mark unsafe encrpytions to obsolete and support only with compile switch UNSAFEENCYPTION --- AjaxPro/Security/DecryptTransformer.cs | 3 ++- AjaxPro/Security/EncryptTransformer.cs | 8 +++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/AjaxPro/Security/DecryptTransformer.cs b/AjaxPro/Security/DecryptTransformer.cs index a4ea7bc..c7f62ca 100644 --- a/AjaxPro/Security/DecryptTransformer.cs +++ b/AjaxPro/Security/DecryptTransformer.cs @@ -59,6 +59,7 @@ internal ICryptoTransform GetCryptoServiceProvider(byte[] bytesKey) { switch(algorithmID) { +#if (UNSAFEENCYPTION) case EncryptionAlgorithm.Des: DES des = new DESCryptoServiceProvider(); des.Mode = CipherMode.CBC; @@ -70,7 +71,7 @@ internal ICryptoTransform GetCryptoServiceProvider(byte[] bytesKey) TripleDES des3 = new TripleDESCryptoServiceProvider(); des3.Mode = CipherMode.CBC; return des3.CreateDecryptor(bytesKey, initVec); - +#endif case EncryptionAlgorithm.Rc2: RC2 rc2 = new RC2CryptoServiceProvider(); rc2.Mode = CipherMode.CBC; diff --git a/AjaxPro/Security/EncryptTransformer.cs b/AjaxPro/Security/EncryptTransformer.cs index f4cdc45..a576f77 100644 --- a/AjaxPro/Security/EncryptTransformer.cs +++ b/AjaxPro/Security/EncryptTransformer.cs @@ -25,7 +25,7 @@ */ /* * MS 06-04-25 enums should have a zero value - * MS 24-10-10 changed to set DES encryption obsolete + * MS 24-10-10 changed to mark unsafe encrpytions to obsolete and support only with compile switch UNSAFEENCYPTION * * */ @@ -39,10 +39,10 @@ namespace AjaxPro.Cryptography /// public enum EncryptionAlgorithm { - [Obsolete("Use EncryptionAlgorithm.Aes instead.")] /// /// /// + [Obsolete("Use EncryptionAlgorithm.Aes instead.")] Des = 0, /// @@ -58,6 +58,7 @@ public enum EncryptionAlgorithm /// /// /// + [Obsolete("Use EncryptionAlgorithm.Aes instead.")] TripleDes, Aes }; @@ -89,6 +90,7 @@ internal ICryptoTransform GetCryptoServiceProvider(byte[] bytesKey) { switch (algorithmID) { +#if (UNSAFEENCYPTION) case EncryptionAlgorithm.Des: DES des = new DESCryptoServiceProvider(); des.Mode = CipherMode.CBC; @@ -136,7 +138,7 @@ internal ICryptoTransform GetCryptoServiceProvider(byte[] bytesKey) des3.IV = initVec; } return des3.CreateEncryptor(); - +#endif case EncryptionAlgorithm.Rc2: RC2 rc2 = new RC2CryptoServiceProvider(); rc2.Mode = CipherMode.CBC;