C# app signs XML with digital signature (CSXmlDigitalSignature)

This sample demonstrates how to use .NET built-in classes to implement Digital Signature for Xml documents.

C# (53.7 KB)
8,692 times
Add to favorites
E-mail Twitter del.icio.us Digg Facebook
    WINDOWS APPLICATION : CSXmlDigitalSignature Project Overview


Digital Signatures:

We take the original message and create a message digest by applying the hash
algorithm on the message. The message digest is then encrypted using the 
private key known only to the private key owner (i.e., the sender).The signed
message is formed by concatenating the original message with the unique 
digital signature and the public key that is associated with the private key 
that produced that signature. This entire signed message is then sent to the 
desired recipient.

The received signed message is broken into its three components: the original
message, the public key, and the digital signature. For comparison against 
the hash of the original message, it is necessary to compute the hash of the 
received message. If the message digest has not changed, then you can be very
confident that the message itself has not changed. On the other hand, if the
message digest has changed, then you can be quite certain that the received 
message has been corrupted or tampered with.

CSDigitalSignature demonstrates how to use .NET built-in classes to implement 
Digital Signature for Xml documents.

Code Logic:

Use .NET built-in classes to implement XML digital signature.

A. Creates a cryptographic provider object which supplies public/private
   key pair.
B. Uses the private key to sign an entire XML document.
C. Attaches the signature to the document in <Signature> element.
D. Uses the public key to verify the digital signature


.NET Security and Cryptography 

RSACryptoServiceProvider Class

Cryptography in .NET

DSACryptoServiceProvider Class

Cryptography in Microsoft.NET Part I: Encryption

Cryptography in Microsoft.NET Part II: Digital Envelop and Digital Signatures