没有填充的 C# RSA [英] C# RSA with no padding
问题描述
我正忙于移植看起来像这样的 Java 代码
I'm busy trying to port Java code that looks like this
Cipher rsa = Cipher.getInstance("RSA/ECB/nopadding");
rsa.init(Cipher.DECRYPT_MODE, RSAPrivateKey);
decryptedData = rsa.doFinal(data, 0, 128);
到 C#,但 RSACryptoServiceProvider 似乎强制您使用 OEAP 或 PKCS1 填充.我知道没有填充是不安全的,但在这种情况下,我使用的是封闭源客户端,所以我对此无能为力.有没有办法解决这个填充问题?
to C#, but as it seems the RSACryptoServiceProvider, forces you to either use OEAP or PKCS1 padding. I know no padding isn't secure, but in this case Im working with a closed source client, so I can't do anything about that. Is there any way around this padding issue?
推荐答案
您可能想要从 BouncyCastle 获取代码,http://www.bouncycastle.org/csharp/,并修改下面链接中的代码,确保它可以使用上面列出的加密.
You might want to get the code from BouncyCastle, http://www.bouncycastle.org/csharp/, and modify the code from the link below, and ensure that it can use the encryption that you list above.
http://www.java2s.com/Code/Java/Security/Whatisinbouncycastlebouncycastle.htm
这篇关于没有填充的 C# RSA的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!