Illustration of DSA Algorithm with Different k and h

This section provides a tutorial example to illustrate how DSA digital signature algorithm works with same DSA key paramters but different k and h values.

In the third example, I want to use the same DSA key parameters, the same hash value, and a different k value of 7.

The same DSA key parameters are used:

{23,11,4,8}  # the public key: {p,q,g,y}
{23,11,4,7}  # the private key: {p,q,g,x} 

The process of generating a digital signature with the same private key {p,q,g,x}={23,11,4,7} and a different k value of 7 can be illustrated as:

h = 3      # the hash value as the message digest
k = 7      # selected: 0 < k < q
r = 8      # computed: r = (g**k mod p) mod q = (4**7 mod 23) mod 11
i = 8      # computed: k*i mod q = 1: 7*i mod 11 = 1
s = 10     # computed: s = i*(h+r*x) mod q = 8*(3+8*7) mod 11
{8,10}     # the digital signature: {r,s}

The process of verifying the digital signature {r,s}={8,10} with the same public key {p,q,g,y}={23,11,4,8} can be illustrated as:

h = 3      # the hash value as the message digest
w = 10     # computed: s*w mod q = 1: 10*w mod 11 = 1
u1 = 8     # computed: u1 = h*w mod q = 3*10 mod 11 = 8
u2 = 3     # computed: u2 = r*w mod q = 8*10 mod 11 = 3
v = 8      # computed: v = (((g**u1)*(y**u2)) mod p) mod q
           #             = (((4**8)*(8**3)) mod 23) mod 11 = 8
v == r     # verification passed

There is no problem. The digital signature is still good.

Now let's try on a different hash value of h=9 and generate the digital signature with same private key {p,q,g,x}={23,11,4,7}.

h = 9      # the hash value as the message digest
k = 7      # selected: 0 < k < q
r = 8      # computed: r = (g**k mod p) mod q = (4**7 mod 23) mod 11
i = 8      # computed: k*i mod q = 1: 7*i mod 11 = 1
s = 3      # computed: s = i*(h+r*x) mod q = 8*(9+8*7) mod 11
{8,3}      # the digital signature: {r,s}

Here is the verification process with the same public key {p,q,g,y}={23,11,4,8}:

h = 9      # the hash value as the message digest
w = 4      # computed: s*w mod q = 1: 3*w mod 11 = 1
u1 = 3     # computed: u1 = h*w mod q = 9*4 mod 11 = 3
u2 = 10    # computed: u2 = r*w mod q = 8*4 mod 11 = 10
v = 8      # computed: v = (((g**u1)*(y**u2)) mod p) mod q
           #             = (((4**3)*(8**10)) mod 23) mod 11 = 8
v == r     # verification passed

Looks very good.

Last update: 2013.

Table of Contents

 About This Book

 Cryptography Terminology

 Cryptography Basic Concepts

 Introduction to AES (Advanced Encryption Standard)

 Introduction to DES Algorithm

 DES Algorithm - Illustrated with Java Programs

 DES Algorithm Java Implementation

 DES Algorithm - Java Implementation in JDK JCE

 DES Encryption Operation Modes

 DES in Stream Cipher Modes

 PHP Implementation of DES - mcrypt

 Blowfish - 8-Byte Block Cipher

 Secret Key Generation and Management

 Cipher - Secret Key Encryption and Decryption

 Introduction of RSA Algorithm

 RSA Implementation using java.math.BigInteger Class

Introduction of DSA (Digital Signature Algorithm)

 What Is a Digital Signature?

 What Is DSA (Digital Signature Algorithm)?

 Illustration of DSA Algorithm: p,q=7,3

 Illustration of DSA Algorithm: p,q=23,11

Illustration of DSA Algorithm with Different k and h

 Proof of DSA Digital Signature Algorithm

 Java Default Implementation of DSA

 Private key and Public Key Pair Generation

 PKCS#8/X.509 Private/Public Encoding Standards

 Cipher - Public Key Encryption and Decryption

 MD5 Mesasge Digest Algorithm

 SHA1 Mesasge Digest Algorithm

 OpenSSL Introduction and Installation

 OpenSSL Generating and Managing RSA Keys

 OpenSSL Managing Certificates

 OpenSSL Generating and Signing CSR

 OpenSSL Validating Certificate Path

 "keytool" and "keystore" from JDK

 "OpenSSL" Signing CSR Generated by "keytool"

 Migrating Keys from "keystore" to "OpenSSL" Key Files

 Certificate X.509 Standard and DER/PEM Formats

 Migrating Keys from "OpenSSL" Key Files to "keystore"

 Using Certificates in IE (Internet Explorer)

 Using Certificates in Firefox

 Using Certificates in Google Chrome

 Outdated Tutorials

 References

 PDF Printing Version