简体   繁体   English

RSACryptoServiceProvider使用ECB和MGF1填充进行解密

[英]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 MGFT1ECB 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.

相关问题 是否在 System.Security.Cryptography.RSA.Encrypt 方法中使用 RSAEncryptionPadding.OaepSHA256 假设 MGF1 填充? - Is MGF1 padding assumed in System.Security.Cryptography.RSA.Encrypt method with RSAEncryptionPadding.OaepSHA256? 使用 SHA-256 哈希算法使用 PSS 填充和 MGF1 掩码的 C# RSA 签名 - C# RSA signing with PSS padding and a MGF1 mask using a SHA-256 hash algorithm 带有 SHA1 的 OAEP 和带有 BouncyCastle 的 MGF1? - OAEP with SHA1 and MGF1 with BouncyCastle? 使用RSACryptoServiceProvider.Decrypt解密 - Decrypting using RSACryptoServiceProvider.Decrypt .net C# 中的 AES 128 ECB 解密 - AES 128 ECB Decrypting in .net C# 解码 OAEP 填充时出现 RSACryptoServiceProvider 错误 - RSACryptoServiceProvider error occurred while decoding OAEP padding 如何使RSACryptoServiceProvider无需填充(nopadding)就可以工作? - How to make RSACryptoServiceProvider work without padding (nopadding)? 解密流时填充无效 - Padding invalid when decrypting stream 使用RSACryptoServiceProvider解密时出现“Bad Key。”异常(C#.NET) - “Bad Key.” exception when decrypting with RSACryptoServiceProvider (C#.NET) 使用RSACryptoServiceProvider使用过期的证书加密/解密数据没有错误 - No error encrypting / decrypting data with an expired certificate using RSACryptoServiceProvider
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM