Tuesday, December 31, 2013

RSA Digital Signature C#

Using .net libraries we can easily implement RSA digital signature scheme. I wrote this blog post to explain how RSA digital signature algorithm works.

Here I get private and public key pair out of rsa object for more understandability of the code.

//Get rsaKeys

The following method will explain how to sign a message. You need to provide a private key and a message need to be signed. This method will be returned signed message.

//Sign message

Next step is verify the message that you signed using your private key. You need to pass original message, signed message and public key to method. This method will be returned boolean value verified or not.

//Verify message

To this point we are done with methods we need to sign and verify. Lets see how to use them. I wrote it in main method.

//RSA main


4 comments:

  1. I currently study software engineering and the concept of a digital signature sounds really challenging as the whole crypthography course.

    ReplyDelete
  2. Hello,

    Everytime I run this, will the private/public be generated newly?
    What if I want to hash and sign a message with the same private key everytime?

    Please suggest

    Thanks

    ReplyDelete
  3. Then you should store your key somewhere. Certificate srore is the standard, but you can use XMls too.

    ReplyDelete