private static ICryptoTransform CreateTransformCore( CipherMode cipherMode, PaddingMode paddingMode, byte[] key, byte[] iv, int blockSize, bool encrypting) { // The algorithm pointer is a static pointer, so not having any cleanup code is correct. IntPtr algorithm; switch (cipherMode) { case CipherMode.CBC: algorithm = Interop.Crypto.EvpDesCbc(); break; case CipherMode.ECB: algorithm = Interop.Crypto.EvpDesEcb(); break; default: throw new NotSupportedException(); } BasicSymmetricCipher cipher = new OpenSslCipher(algorithm, cipherMode, blockSize, key, 0, iv, encrypting); return UniversalCryptoTransform.Create(paddingMode, cipher, encrypting); }
private static ICryptoTransform CreateTransformCore( CipherMode cipherMode, PaddingMode paddingMode, byte[] key, int effectiveKeyLength, byte[]?iv, int blockSize, int feedbackSize, int paddingSize, bool encrypting) { // The algorithm pointer is a static pointer, so not having any cleanup code is correct. IntPtr algorithm; switch (cipherMode) { case CipherMode.CBC: algorithm = Interop.Crypto.EvpRC2Cbc(); break; case CipherMode.ECB: algorithm = Interop.Crypto.EvpRC2Ecb(); break; default: throw new NotSupportedException(); } BasicSymmetricCipher cipher = new OpenSslCipher(algorithm, cipherMode, blockSize, paddingSize, key, effectiveKeyLength, iv, encrypting); return(UniversalCryptoTransform.Create(paddingMode, cipher, encrypting)); }
private static ICryptoTransform CreateTransformCore( CipherMode cipherMode, PaddingMode paddingMode, byte[] key, byte[] iv, int blockSize, bool encrypting) { // The algorithm pointer is a static pointer, so not having any cleanup code is correct. IntPtr algorithm = GetAlgorithm(key.Length * 8, cipherMode); BasicSymmetricCipher cipher = new OpenSslCipher(algorithm, cipherMode, blockSize, key, iv, encrypting); return UniversalCryptoTransform.Create(paddingMode, cipher, encrypting); }
private static ICryptoTransform CreateTransformCore( CipherMode cipherMode, PaddingMode paddingMode, byte[] key, byte[] iv, int blockSize, bool encrypting) { // The algorithm pointer is a static pointer, so not having any cleanup code is correct. IntPtr algorithm = GetAlgorithm(key.Length * 8, cipherMode); BasicSymmetricCipher cipher = new OpenSslCipher(algorithm, cipherMode, blockSize, key, iv, encrypting); return(UniversalCryptoTransform.Create(paddingMode, cipher, encrypting)); }
private static UniversalCryptoTransform CreateTransformCore( CipherMode cipherMode, PaddingMode paddingMode, byte[] key, byte[]?iv, int blockSize, int feedbackSize, int paddingSize, bool encrypting) { // The algorithm pointer is a static pointer, so not having any cleanup code is correct. IntPtr algorithm = GetAlgorithm(cipherMode, feedbackSize); Interop.Crypto.EnsureLegacyAlgorithmsRegistered(); BasicSymmetricCipher cipher = new OpenSslCipher(algorithm, cipherMode, blockSize, paddingSize, key, iv, encrypting); return(UniversalCryptoTransform.Create(paddingMode, cipher, encrypting)); }
private static UniversalCryptoTransform CreateTransformCore( CipherMode cipherMode, PaddingMode paddingMode, byte[] key, byte[]?iv, int blockSize, int feedbackSize, int paddingSize, bool encrypting) { // The algorithm pointer is a static pointer, so not having any cleanup code is correct. IntPtr algorithm = IntPtr.Zero; switch (cipherMode) { case CipherMode.CBC: algorithm = Interop.Crypto.EvpDesCbc(); break; case CipherMode.ECB: algorithm = Interop.Crypto.EvpDesEcb(); break; case CipherMode.CFB: Debug.Assert(feedbackSize == 1, "DES with CFB should have FeedbackSize set to 1"); algorithm = Interop.Crypto.EvpDesCfb8(); break; default: throw new NotSupportedException(); } Interop.Crypto.EnsureLegacyAlgorithmsRegistered(); BasicSymmetricCipher cipher = new OpenSslCipher(algorithm, cipherMode, blockSize, paddingSize, key, 0, iv, encrypting); return(UniversalCryptoTransform.Create(paddingMode, cipher, encrypting)); }
private static UniversalCryptoTransform CreateTransformCore( CipherMode cipherMode, PaddingMode paddingMode, byte[] key, byte[]?iv, int blockSize, int paddingSize, int feedbackSize, bool encrypting) { // The algorithm pointer is a static pointer, so not having any cleanup code is correct. IntPtr algorithm; switch ((cipherMode, feedbackSize)) { case (CipherMode.CBC, _): algorithm = Interop.Crypto.EvpDes3Cbc(); break; case (CipherMode.ECB, _): algorithm = Interop.Crypto.EvpDes3Ecb(); break; case (CipherMode.CFB, 1): algorithm = Interop.Crypto.EvpDes3Cfb8(); break; case (CipherMode.CFB, 8): algorithm = Interop.Crypto.EvpDes3Cfb64(); break; default: throw new NotSupportedException(); } BasicSymmetricCipher cipher = new OpenSslCipher(algorithm, cipherMode, blockSize, paddingSize, key, 0, iv, encrypting); return(UniversalCryptoTransform.Create(paddingMode, cipher, encrypting)); }