none
How specify the type of padding when using RSAPKCS1SignatureFormatter RRS feed

  • Question

  • I need to sign a hash value of data and get a digital signature in PKCS1 v1.5 format. I think that RSAPKCS1SignatureFormatter.CreateSignature method is the right one but how can I specify the padding type (PaddingMode.ISO10126, PaddingMode.PKCS7, ....)?
    Monday, December 28, 2015 3:00 PM

All replies

  • Hi nlprogrammer,

    Since you mentioned RSAPKCS1SignatureFormatter.CreateSignature method and with hash value.

    When check RSAPKCS1SignatureFormatter.CreateSignature Method (Byte[]) in MSDN,                    //Create a signature for HashValue and return it.
                    byte[] SignedHash = RSAFormatter.CreateSignature(hash);

    Now let's talk about the padding mode PKCS7. Padding comes when a message data block is shorter than the full number of bytes needed for a cryptographic operation. Why did we choose PCKS7. Because PCKS#7 padding string consists of a sequence of bytes, each of which is equal to the total number of padding bytes added. So from my point of view, I would suggest PKCS#7 padding, which involves adding bytes that each represent the length of the padding,  The benefit over some other padding mechanisms is that it's easy to tell if the padding is corrupted - the longer the padding, the higher the chance of random data corruption, but it also increases the number of copies of the padding length you have. With no real chance of broken padding somehow validating as correct.

    Hope this helps.

    Have a nice day!

    Kristin


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, December 29, 2015 2:52 AM
  • Thanks for your help but how can I choose padding type?

    Bye

    nl


    Sunday, January 3, 2016 3:54 PM
  • @nl,

    Please see the answer on Crypto - Stack Exchange: crypto.stackexchange.com/questions/1486/…


    • Edited by Linki Tan Monday, January 4, 2016 5:30 AM
    Monday, January 4, 2016 5:29 AM