Practical 10

Digital Signature Algorithm

Using NIST DSA (FIPS 186-3)
🎯

Objective

To implement and understand the Digital Signature Algorithm (DSA) as per NIST standards for generating and verifying digital signatures to ensure message authenticity and integrity.

📚

Theory: What is DSA?

Digital Signature Algorithm (DSA)

DSA is a standard for digital signatures defined by NIST (National Institute of Standards and Technology) in the FIPS 186 series. It's an asymmetric cryptographic algorithm based on modular exponentiation and discrete logarithms.

Purpose of Digital Signatures:

Authenticity

Proves that the message is from the claimed sender.

Integrity

Detects any changes to the message.

Non-repudiation

Sender cannot deny signing the message.

What is FIPS 186-3?

FIPS = Federal Information Processing Standard
186-3 = Digital Signature Standard (DSS), Version 3
Published by NIST, it defines key sizes (1024, 2048, 3072 bits), hash functions (SHA-1, SHA-224, SHA-256), and secure signing/verification methods.

DSA Process:

Step 1

Hash the message using a secure hash function (e.g., SHA-256)

Step 2

Sign the hash using the private key

Step 3

Verify the signature using the public key and the original hash

💻

Implementation Code

Python Implementation
from Crypto.PublicKey import DSA
from Crypto.Signature import DSS
from Crypto.Hash import SHA256

# Generate DSA key pair
key = DSA.generate(2048)
public_key = key.publickey() 

# Sign a message
message = b'GECBHARUCH DIGITAL SIGNATURE DEMO'
hash_msg = SHA256.new(message)
signer = DSS.new(key, 'fips-186-3')
signature = signer.sign(hash_msg)

print("Signature (hex):", signature.hex())

# Verifier have message and public_key
# Verify the signature
recv_message = b'GECBHARUCH DIGITAL SIGNATURE DEMO'
hash_msg_verify = SHA256.new(recv_message)
verifier = DSS.new(public_key, 'fips-186-3')
try:
    verifier.verify(hash_msg_verify, signature)
    print("Signature is valid.")
except ValueError:
    print("Signature is invalid.")
📄

Output

Signature (hex): 2409bc2306d25c85cb34d23e387bb1bd45790e906514d3a60d103248054ffafe60b9e54
c1c8bc0fd5bec9839cd48816dd1bb51910939b4f9
Signature is valid.
🔒

Security Aspects

Authentication

Confirms that the message was signed by the genuine sender.

Integrity

Even a single-bit change in the message will cause signature verification to fail.

Non-repudiation

The signer cannot deny creating the signature, as only they possess the private key.

Mathematical Foundation

Based on hard mathematical problems (discrete logarithms), making it computationally infeasible to forge a valid signature.

🌐

Real-World Applications

Digital certificates (X.509)
Software code signing
Electronic document authentication
e-Governance
Secure communications
Banking systems
Legal documents
📋

Key Features Summary

Feature Description
DSA U.S. government digital signature standard
FIPS-186-3 Updated NIST standard supporting 2048/3072-bit keys
Hash Required DSA signs hashed messages, not raw messages
No Encryption DSA only signs and verifies; use RSA/ECC for encryption
Randomness Each signature is different even for the same message (secure design)

Learning Outcomes

After this practical, students will be able to:

Summary

This practical demonstrates the use of NIST DSA for digitally signing and verifying messages. The use of SHA-256 ensures a secure hash before signing. This mechanism is widely used in secure communications, e-governance, banking, software distribution, and legal documents, where authenticity, integrity, and non-repudiation are essential.