3

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?

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

3 Answers 3

3

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)

0
2

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.

2
  • Yup, I can only agree with this. Just don't use RSA without proper padding. There are too many known attacks against RSA when it is not correctly used. Sep 8, 2009 at 19:53
  • 1
    But what if I need to calculate hash and add padding by some custom algorithm? Am I need to use BigInteger to perform a custom RSA calculations too? As described here: core.telegram.org/mtproto/auth_key Dec 27, 2013 at 11:37
0

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?

3
  • I do not worry about the block size. I use it once and I know exactly the size of the block. It's a 128 bytes byte array.
    – Lazlo
    Sep 8, 2009 at 2:23
  • Ah, I follow you. I cannot help then, apologises. I would guess that if padding isn't required, it isn't done though? That's a guess though, and I assume because you're asking, that it's not, so, sorry :)
    – Noon Silk
    Sep 8, 2009 at 2:29
  • 1
    I might have found an answer! Using OpenSsl.Net might work out for me. I'll test tomorrow. :)
    – Lazlo
    Sep 8, 2009 at 2:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.