.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Articles >> Security >> Post New Resource Bookmark and Share   

 Subscribe to Articles

Cryptography : Asymmetric Encryption by using Asymmetric Algorithm Classes-Part 2

Posted By:Ravi Ranjan Kumar       Posted Date: August 31, 2012    Points: 200    Category: Security    URL: http://www.dotnetspark.com  

This Blog enable you to learn the DSA encrytion class of Asymmetric Algorithm.
 

As we have read about Asymmetric encryption in previous article, so now its extended part of previous article to let you understand the basic concept of DSA.

DSA Encryption

The DSA class is an abastract(MustInherit) class that extends the AsymmetricAlgorithm class and providews suport for the DSA algorithm.

From Wikipedia
The Digital Signature Algorithm (DSA) is a United States Federal Government standard or FIPS for digital signatures. It was proposed by the National Institute of Standards and Technology (NIST) in August 1991 for use in their Digital Signature Standard (DSS), specified in FIPS 186, adopted in 1993. A minor revision was issued in 1996 as FIPS 186-1. The standard was expanded further in 2000 as FIPS 186-2 and again in 2009 as FIPS 186-3.

Key generation has two phases. The first phase is a choice of algorithm parameters which may be shared between different users of the system, while the second phase computes public and private keys for a single user.

The .Net framework DSA algorithm support an encryption key size ranging from 512 bits to 1024 bits in increaments of 64 bits.

Where to use DSA Encryption
Lets take an example where a public-key system need to digitally sign a message, In that case the sender first applies a hash function to the appropriate message to create a message that can be digest. The sender then encrypts the message digest with the sender's private key to create the sender's personal signature, This is because this private key uniquely identifies the sender. after receiving the message and signature, the receiver decrypts the signature using the sender's public key to recover the message digest and hashes the message using the same hash algorithm that the sender used. If the message digest that the receiver computes exactly matches the message digest received from the sender, the receiver can assume that the message came from the sender.

The DSACryptoServiceProvider class extends the DSA class and is the concrete DSA algorithm class. The DSA class provides the CreateSignature and VerifySignature methods, which help create and verify a digital Signature. 

Implementing the DSACryptoServiceProvider class :
byte[] hashbyte = { 10,20,12,15,30,45,55,65,70,80,75}
DSACryptoServiceProvider signer = new DSACryptoServiceProvider();
DSASignatureFormatter formatter = new DSASignatureFormattter(signer);
formatter.SetHashAlgorithm("SHA1");
byte[] signedhashvalue = formatter.CreateSignature(hashbyte);
DSASignatureDeformatter deformatter = new DSASignatureDeformatter(signer);
deformatter.SetHashAlgorithm("SHA1");

//'Signature Validated...
}
else 
//'Signature not Validated... "
signer.Clear();
signer= null; 
deformatter = null;

The Following code example enable you to learn how to implement it using C#
a) create a user-defined hash key
b) create a digital signature provider and a digital Signature formatted.
c)  Configure the hash algorithm
d) create and verify the signature
e) verify the signature.
f) cleanup

so here how signing will done

Have a look at process

  1. Sender calculates a hash from the data before sending

  2. Sender encrypts that hash with senders private key

  3. Receiver calculates hash from the received data

  4. Receiver decrypts senders signature with senders public key

  5. Receiver compares the locally calculated hash and the decrypted signature

The class DSACryptoServiceProvider has the function VerifySignature which takes both the signed signed value and the un-signed value!

For more Information, must read :
http://en.wikipedia.org/wiki/Digital_Signature_Algorithm
http://msdn.microsoft.com/en-us/library/system.security.cryptography.dsacryptoserviceprovider.aspx



 Subscribe to Articles

     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend