简体   繁体   中英

How to make RSACryptoServiceProvider work without padding (nopadding)?

I need to make a C# application compatible with a Java application.

The Java application uses a Cipher.getInstance("RSA/ECB/nopadding"); initializer to make the cipher ECB and no-padding.

However, in C#, you have 2 options for padding: OAEP padding or PKCS#1 v1.5 padding. 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. However, is there a RSA custom class or library that allows this precision?

PS: Is C#.NET's RSACryptoServiceProvider ECB by default? I can't find documentation on this.

Using OpenSSL.NET will make no-padding available. 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. If C# won't let you do it, then that's a point in C#'s favour. Get the Java side fixed.

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?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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