如何在带有 OpenSSL 的 .Net 中使用自定义链接模式?
How to use custom chaining modes in .Net with OpenSSL?
我需要为加密实施自定义链接模式。我需要使用对称分组密码(AES、3DES、DES、IDEA)。我遇到的问题是,我发现的 libraries/wrappers 不允许。
BouncyCastle 将这些作为枚举:Mode = CipherMode.CBC
,所以我看不到 - 我如何使用我自己的。 System.Security.Cryptography
似乎也是如此。
是否有允许自定义链接模式的任何 .NET 库或包装器?
现在我唯一的想法是使用充满零位的 IV 的 CBC 加密每个块,并在其上实现我的链接模式,但这似乎不是一个好主意。
我不知道有哪个库支持链接回调,它有点违背大多数密码学的黑盒特性 API。
实现目标的方法是使用 ECB 进行加密,因为那是 "just apply the encryption algorithm to this data"。比如做CBC:
private byte[] _iv;
private ICryptoTransform _encryptor;
private void EncryptBlock(byte[] input, byte[] output)
{
byte[] buf = (byte[])input.Clone();
for (int i = 0; i < buf.Length; i++)
{
buf[i] ^= _iv[i];
}
_encryptor.TransformBlock(buf, 0, buf.Length, output, 0);
Buffer.BlockCopy(out, 0, _iv, 0, output.Length);
}
(省略各种错误检查)
给定某处你将事物初始化为
using (Aes aes = Aes.Create())
{
aes.Mode = CipherMode.ECB;
aes.Key = key;
_encryptor = aes.CreateEncryptor();
_decryptor = aes.CreateDecryptor();
}
(等)。
我需要为加密实施自定义链接模式。我需要使用对称分组密码(AES、3DES、DES、IDEA)。我遇到的问题是,我发现的 libraries/wrappers 不允许。
BouncyCastle 将这些作为枚举:Mode = CipherMode.CBC
,所以我看不到 - 我如何使用我自己的。 System.Security.Cryptography
似乎也是如此。
是否有允许自定义链接模式的任何 .NET 库或包装器?
现在我唯一的想法是使用充满零位的 IV 的 CBC 加密每个块,并在其上实现我的链接模式,但这似乎不是一个好主意。
我不知道有哪个库支持链接回调,它有点违背大多数密码学的黑盒特性 API。
实现目标的方法是使用 ECB 进行加密,因为那是 "just apply the encryption algorithm to this data"。比如做CBC:
private byte[] _iv;
private ICryptoTransform _encryptor;
private void EncryptBlock(byte[] input, byte[] output)
{
byte[] buf = (byte[])input.Clone();
for (int i = 0; i < buf.Length; i++)
{
buf[i] ^= _iv[i];
}
_encryptor.TransformBlock(buf, 0, buf.Length, output, 0);
Buffer.BlockCopy(out, 0, _iv, 0, output.Length);
}
(省略各种错误检查)
给定某处你将事物初始化为
using (Aes aes = Aes.Create())
{
aes.Mode = CipherMode.ECB;
aes.Key = key;
_encryptor = aes.CreateEncryptor();
_decryptor = aes.CreateDecryptor();
}
(等)。