Presentation is loading. Please wait.

Presentation is loading. Please wait.

Digital Signatures Assignment

Similar presentations


Presentation on theme: "Digital Signatures Assignment"— Presentation transcript:

1 Digital Signatures Assignment
- By Teja Shinde

2 Digital Signatures – Overview
Basis – Sender A and Receiver B A encrypts the message with its private key and sends it to B. B decrypts the message with A’s public key. Hence, we achieve Integrity, Authentication and non-repudiation with Digital Signatures. Digital Signatures are very similar to the process of physically signing important documents to prove its validity.

3 Steps for Digital Signature Process RSA and Digital Signatures
We can use RSA for performing digital signature over a message. Steps: Sender A uses SHA/MD5 algorithm to calculate the Message Digest(MD1) over the Original Message(M). Sender encrypts MD1 with her private key (Using RSA). The output of this step is the Digital Signature(DS) of A.

4 3. Sender A sends M + DS to B. 4. B uses same Message Digest Algorithm used by A to calculate its Message Digest(MD2) 5. Now B uses A’s public key to decrypt the DS. - Only A’s public key can perform decryption - Output of this step is the original MD – MD1. 6. B compares the calculated MD2 and retrieved MD1. If MD1 = MD2 – B is assured that OM is correct and unaltered and coming from A.

5 Program Implementation in Java. Packages to be imported
Package – java.security Classes - Signature, SignatureException, KeyPair, KeyPairGenerator. Package – sun.misc.*

6 Program Logic Generate 1024 bit RSA Key Pair. Print Private Key
KeyPairGenerator kpg=KeyPairGenerator.getInstance("RSA"); kpg.initialize(1024); KeyPair keypair = kpg.generateKeyPair(); Print Private Key PrivateKey pri = keypair.getPrivate(); Accept data to be signed in a byte array. Print Original Message in String format.

7 Get an instance of Signature Object using :
Signature sig = Signature.getInstance("MD5WithRSA"); Initialize Digital Signature using Private Key sig.initSign(pri); Update signature Object with the no. of bytes of input. sig.update(data); Call sign() to generate Digital Signature. The output is stored in a byte array. Print the Digital Signature

8 10. Get the public key for Decryption
- PublicKey pub = keypair.getPublic() 11. Initialize the Signature for Verification by using initVerify(pub) method. 12. Pass the signed data to be verified to the update() method. 13. Verify the Signature using verify(SignatureObject) – returns Boolean. - If the data was altered verification would fail, otherwise it is successful.

9 Expected Output Accept the data to be signed using command line argument and print it. Print Private Key. Print the Digital Signature. Print the Public Key. Print the Message Digest. (Check – The Message digest and the original data to be signed should be the same) Print if “Signature Verified” or “Not Verified”


Download ppt "Digital Signatures Assignment"

Similar presentations


Ads by Google