[英]RSACryptoServiceProvider decrypting with ECB and MGF1 padding
I'm using RSACryptoServiceProvider from System.Security.Cryptography
package. 我正在使用
System.Security.Cryptography
包中的RSACryptoServiceProvider 。 I need to decrypt some input coming from Android application using my private key. 我需要使用我的私钥解密一些来自Android应用程序的输入。 It's encrypting it in Java code with
RSA/ECB/OAEPWithSHA256AndMGF1Padding
algorithm. 它使用
RSA/ECB/OAEPWithSHA256AndMGF1Padding
算法以Java代码RSA/ECB/OAEPWithSHA256AndMGF1Padding
加密。
The problem is I cannot find any way to set nither padding MGFT1 nor ECB . 问题是我找不到任何方法来设置nither padding MGFT1或ECB 。 Could you help me somehow?
你能以某种方式帮助我吗? Are these settings default or should I use another library?
这些设置是默认设置还是我应该使用其他库? It's hard to believe it's impossible.
很难相信这是不可能的。
Crucial part of my code goes here: 我的代码的关键部分在这里:
RSAParameters RSAParamPrivateKey = DotNetUtilities.ToRSAParameters(privateKey)
RSACryptoServiceProvider csp = new RSACryptoServiceProvider();
csp.ImportParameters(RSAParamPrivateKey);
return csp.Decrypt(encryptedAESKey, RSAEncryptionPadding.OaepSHA256);
The "ECB" is (hopefully) meaningless. “希望”是(毫无希望)毫无意义的。 RSA should only ever be used for a one block of data.
RSA仅应用于一个数据块。
MGF1 is the only standard defined MGF, so it's not an option that .NET lets you currently specify. MGF1是唯一的标准定义的MGF,因此.NET当前不允许您选择该选项。
OAEP with an algorithm other than SHA-1 is beyond RSACryptoServiceProvider
's capabilities. 使用SHA-1以外的算法的OAEP超出了
RSACryptoServiceProvider
的功能。 But RSACng
can do it: 但是
RSACng
可以做到:
RSAParameters RSAParamPrivateKey = DotNetUtilities.ToRSAParameters(privateKey);
RSA rsa = new RSACng();
rsa.ImportParameters(RSAParamPrivateKey);
return rsa.Decrypt(encryptedAESKey, RSAEncryptionPadding.OaepSHA256);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.