简体   繁体   English

如何使RSACryptoServiceProvider无需填充(nopadding)就可以工作?

[英]How to make RSACryptoServiceProvider work without padding (nopadding)?

I need to make a C# application compatible with a Java application. 我需要使C#应用程序与Java应用程序兼容。

The Java application uses a Cipher.getInstance("RSA/ECB/nopadding"); Java应用程序使用Cipher.getInstance("RSA/ECB/nopadding"); initializer to make the cipher ECB and no-padding. 进行密码EC​​B和无填充的初始化程序。

However, in C#, you have 2 options for padding: OAEP padding or PKCS#1 v1.5 padding. 但是,在C#中,您有2个填充选项:OAEP填充或PKCS#1 v1.5填充。 I need a no-padding version, or else I'm definitely stuck in my project. 我需要一个无填充版本,否则我肯定会卡在我的项目中。

I don't think there is any way to make the C#.NET RSACryptoServiceProvider use a no-padding scheme. 我认为没有任何方法可以使C#.NET RSACryptoServiceProvider使用无填充方案。 However, is there a RSA custom class or library that allows this precision? 但是,是否存在允许这种精度的RSA自定义类或库?

PS: Is C#.NET's RSACryptoServiceProvider ECB by default? PS:默认情况下,C#.NET的RSACryptoServiceProvider ECB是否为ECB? I can't find documentation on this. 我找不到关于此的文档。

Using OpenSSL.NET will make no-padding available. 使用OpenSSL.NET将使无填充可用。 However, I can't make it work ( See this question if you want to help me make it work ) 但是,我无法使其正常运行( 如果您想帮助我使其正常运行,请参阅此问题

Performing RSA without padding is almost certainly going to leave you with a broken (insecure) cryptosystem. 不加填充地执行RSA几乎肯定会使您陷入瘫痪(不安全)的密码系统。 If C# won't let you do it, then that's a point in C#'s favour. 如果C#不允许您这样做,那么这就是C#支持的观点。 Get the Java side fixed. 修复Java问题。

Well, the fact is that if you have no padding, you must meet the block size exactly. 好吧,事实是,如果没有填充,则必须完全满足块大小。 Of course it's quite odd to normally reach the block size exactly, hence you pad. 当然,通常要精确达到块大小是很奇怪的,因此您要填充。

You can always pad it yourself, with some chars that you then remove on the other side. 您总是可以自己填充一些字符,然后在另一侧删除它们。

What, exactly, is the reason you need to do this? 确切地说,您需要这样做的原因是什么?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM