Skip to main content

DSA

Main Source:

Digital Signature Algorithm (DSA) is a public key cryptography or asymmetric cryptography algorithm used for digital signatures. Digital signature is like a real physical signature, it is used to ensure integrity and origin of digital data.

DSA is based on the mathematical concept of modular exponentiation and the difficulty of solving the discrete logarithm problem. DSA and Diffie-Hellman key exchange both rely on the computational difficulty of the discrete logarithm problem.

Explanation

The discrete logarithm problem is finding the exponent number in the equation gxy (mod p)g^x \equiv y \space (\text{mod } p), where gg is base value, yy is the result of gx mod pg^x \text{ mod } p, and pp is a prime number. The xx is the private key which is kept secret, the remaining, gg, yy, and pp are the public keys.

Here is a more detailed explanation of DSA:

  1. Key Generation:

    • Choose parameters:

      • Choose a hash function HH with output length of H|H| bits (e.g., SHA-1 or SHA-2).
      • Choose key length LL, it should be multiple of 64 between 512 bits and 1024 bits inclusive (or even larger).
      • Choose modulus length NN, should be lower than key length and hash function's output. For example, LL and NN can be (1024, 160), (2048, 224).
      • Choose NN-bit prime qq and LL-bit prime pp, such that p1p - 1 is a multiple of qq
      • Choose a random integer hh from {2..p2}\{2..p - 2\}.
      • Compute generator gg: g:=h(p1)/q mod pg:= h^{(p - 1) / q} \text{ mod } p.
      • The pp, qq, and gg can be shared publicly.
    • Compute keys:

      • Choose random integer xx as private key from {1..q1}\{1..q - 1\}
      • Compute public key yy: y:=gx mod py:= g^x \text{ mod } p
  2. Key Distribution:

    • The (signer) of the digital data should public the public key yy, whereas the xx is kept secret.
  3. Signing:

    • Choose a random integer kk from {1..q1}\{1..q - 1\}.
    • Compute r:=(gk mod p) mod qr:= (g^k \text{ mod } p) \text{ mod } q.
    • Compute s:=(k1(H(m))+xr) mod qs:= (k^{-1} (H(m)) + xr) \text { mod } q, where H(m)H(m) is the output of hash function when inputting message mm.
    • The resulting signature is the pair (r,s)(r, s), which will be attached to the document.
  4. Signature Verification: Given a pair of signature (r,s)(r, s), to determine if it's valid for message mm:

    • Verify that 0<r<q0 < r < q and 0<s<q0 < s < q.
    • Compute w:=s1 mod qw:= s^{−1} \text{ mod } q.
    • Compute u1:=H(m)w mod qu_1:= H (m) \cdot w \text{ mod } q.
    • Compute u2:=rw mod qu_2:= r \cdot w \text{ mod } q.
    • Compute v:=(gu1yu2 mod p) mod qv:= ( g^{u_1}y^{u_2} \text{ mod } p ) \text{ mod } q.

    If vv is equal to rr, then the signature is valid.

In conclusion, the public key yy is used to verify the signature, while the private key xx (which is hard to find) is used to sign the digital data.

When an attacker tries to break DSA, their objective is to impersonate the original owner. They will try to find the private key so they can modify the content of digitally signed messages without invalidating the signature. This can lead to the manipulation or corruption of data, potentially causing harm or deception.

If we say the document is aa, the hashed document is bb, and the hashed document encrypted with private key is cc, then, the attacker must find the original private key owned by the actual signer, so that the decryption of digital signature or converting back from cc to bb will match the hashing of document from aa to bb. The verification process doesn't check if document is modified or not, the point is, the resulting hash value from the document must match with the decrypted digital signatures attached in the document.

DSA algorithm
Source: https://medium.com/@21_000_000/digital-signature-algorithm-60c8318cf9b6