11. Digital Signatures

MACs allow entities with shared secrets to generate valid tags, providing data integrity and authentication.

Digital signatures use public key cryptography to provide additional properties: only the owner of a private signing key can generate a valid signature.

Non-repudiation: the signer cannot deny they have signed a message.

Properties

Algorithms: Key & signature generation, signature verification.

Key generation algorithm outputs a private signing key, KSK_S and public verification key, KVK_V.

Signature generation: s=Sig(M,KS)s = \mathrm{Sig}(M, K_S), where MM is a message of any length to sign. Only the owner should be able to generate a valid signature. The signature is usually a fixed size (and if there are multiple possible signatures for the same message, they will all be the same length).

Signature verification: Ver(M,s,KV)\mathrm{Ver}(M, s, K_V) outputs true or false.

Correctness: if s=Sig(M,KS)s = \mathrm{Sig}(M, K_S), then Ver(M,s,KV)=true\mathrm{Ver}(M, s, K_V) = \mathrm{true} (for matching KSK_S and KVK_V).

Unforgeability: computationally infeasible to generate signature for any message without key. Note that the signing algorithm may be randomized - many possible signatures for a message.

Stronger security definition: forging a new signature should be difficult even if they can obtain signatures for messages of their choice (chosen message oracle).

Security Goals

Key recovery: recovering the private signing key KSK_S fom the public verification key KVK_V and some known signatures.

Selective forgery: choosing a message and obtaining a signature for that message.

Existential forgery: forging a signature on any message not previously signed (even a meaningless message).

Modern digital signatures should be able to resist existential forgery under a chosen message attack.

RSA Signatures

Key Generation

Key generation is the same as for encryption keys:

A fixed public parameter, the hash function hh, is also required (e.g. SHA-256).

Signature Generation and Verification

Given message MM, modulus nn and private exponent dd, the signature is s=h(M)dmodns = h(M)^d \bmod n. (M,s)(M, s) is the signature.

Given claimed signature (M,s)(M, s), modulus nn and public exponent ee, check if semodn=h(M)s^e \bmod n = h(M)

Discrete Logarithm Signatures

Three versions:

  1. Original Elgamal signatures in Zp\mathbb{Z}_p^* (1985)
  2. Digital signature algorithm (DSA) standardized by NIST
  3. DSA based on elliptic curve groups: ECDSA

Elgamal Elements in Zp\mathbb{Z}_p^*

pp, gg and yy form the public verification key.

Signature generation:

Signature verification: check if

gMyrrs(modp) g^M \equiv y^r r^s \pmod p

Correctness

Fermat’s Little Theorem

Fermat’s little theorem: given a prime pp, for any integer a<pa < p:

apa=npa(ap11)=np \begin{aligned} a^p - a &= np \\ a(a^{p - 1} - 1) &= np \end{aligned}

if gcd(a,p)=1\mathrm{gcd}(a, p) = 1, anpa \neq np and hence:

ap11=npap11(modp) \begin{aligned} a^{p - 1} - 1 &= np \\ \therefore a^{p - 1} &\equiv 1 \pmod p \end{aligned}
Proving Correctness

Let My(modp1)M \equiv y \pmod{p - 1}:

aMaMan(p1)(modp)aM+n(p1)(modp)aMmod(p1)(modp)ay(modp) \begin{aligned} a^M &\equiv a^M \cdot a^{n(p - 1)} &\pmod{p} \\ &\equiv a^{M + n(p - 1)} &\pmod{p} \\ &\equiv a^{M \,\bmod{(p - 1)}} &\pmod{p} \\ &\equiv a^y &\pmod{p} \end{aligned}

Hence, coming back to the Elgamal signature verification equation (and noting that gg is a generator and hence relatively prime to pp:

gMgsk+xr(modp)gskgxr(modp)gskgxr(modp)(gk)s(gx)r(modp)rsyr(modp) \begin{aligned} g^M &\equiv g^{sk + xr} &\pmod p \\ &\equiv g^{sk}g^{xr} &\pmod p \\ &\equiv g^{sk}g^{xr} &\pmod p \\ &\equiv (g^k)^s(g^x)^r &\pmod p \\ &\equiv r^s y^r &\pmod p\\ \end{aligned}

as required.

Digital Signature Algorithm (DSA)

Published by NIST in 1994. Based on Elgamal signatures but calculations are simpler and signatures shorter: done in a subgroup of Zp\mathbb{Z}_p^* or an elliptic curve group. Also prevents attacks Elgamal signatures were vulnerable to.

Prime pp chosen such that p1p - 1 has a prime divisor qq that is much smaller.

Generator gg from Elgamal signatures is replaced by:

g=hp1qmodp g = h^{\frac{p - 1}{q}} \bmod p

where hh is a generator.

gg has order qq as gqmodp=1g^q \bmod p = 1 (by Fermat’s theorem, gqmodp=(hp1q)qmodp=hp1modp=1g^q \bmod p = \left(h^\frac{p - 1}{q}\right)^q \bmod p = h^{p - 1} \bmod p = 1). Hence, all exponents can be reduced modulo qq before exponentiation.

Let HH be a standard SHA hash algorithm such that the output is NN bits long (the same size as qq).

gH(M)yrrsmodpg^{H(M)} \equiv y^r r^s \bmod p so rearranged, we get the verification equation:

(gH(M))s1(yr)s1r(modp) \left(g^{H(M)}\right)^{s^{-1}} \left(y^{-r}\right)^{s^{-1}} \equiv r \pmod p

Both sides of the equation are reduced modulo qq.

pp is a LL-bit long prime modulus, qq a NN bit long a prime divisor of p1p - 1. There are several approved combinations for (L,N,Hash fn)(L, N, \text{Hash fn}): (1024,160,SHA-1)(1024, 160, \text{SHA-1}), (2048,224,SHA-224)(2048, 224, \text{SHA-224}), (2048,256,SHA-256)(2048, 256, \text{SHA-256}), (3072,256,SHA-256)(3072, 256, \text{SHA-256}). The first option may be insecure.

Key generation:

Signature generation:

Signature verification:

Verification equation is the same as with Elgamal except that all exponents and the final result is reduced modulo qq. Signature size is also smaller at 2N2N bits.

Correctness

Fermat’s Little Theorem

Where pp and qq are primes and gcd(p1,q)=m1\text{gcd}(p - 1, q) = m \neq 1, let nn be any integer.

ab+nqmodp=ab+np1mmodp=ab(ap1)nmmodp=ab1nmmodp=abmodp \begin{aligned} & a^{b + nq} &\bmod p \\ =& a^{b + n \cdot \frac{p - 1}{m}} &\bmod p \\ =& a^{b} \left(a^{p - 1}\right)^{\frac{n}{m}} &\bmod p \\ =& a^{b} \cdot 1^{\frac{n}{m}} &\bmod p \\ =& a^b &\bmod p \end{aligned}

Hence abmodqmodpabmodpa^{b \,\bmod q} \bmod p \equiv a^b \bmod p

Proving Correctness

Let My(modp1)M \equiv y \pmod{p - 1}:

aMaMan(p1)(modp)aM+n(p1)(modp)aMmod(p1)(modp)ay(modp) \begin{aligned} a^M &\equiv a^M \cdot a^{n(p - 1)} &\pmod{p} \\ &\equiv a^{M + n(p - 1)} &\pmod{p} \\ &\equiv a^{M \,\bmod{(p - 1)}} &\pmod{p} \\ &\equiv a^y &\pmod{p} \end{aligned}

Hence, coming back to the Elgamal signature verification equation (and noting that gg is a generator and hence relatively prime to pp:

gMgsk+xr(modp)gskgxr(modp)gskgxr(modp)(gk)s(gx)r(modp)rsyr(modp) \begin{aligned} g^M &\equiv g^{sk + xr} &\pmod p \\ &\equiv g^{sk}g^{xr} &\pmod p \\ &\equiv g^{sk}g^{xr} &\pmod p \\ &\equiv (g^k)^s(g^x)^r &\pmod p \\ &\equiv r^s y^r &\pmod p\\ \end{aligned}

as required.

Elliptic Curve DSA (ECDSA)

Similar to DSA except that:

Compared to DSA, public keys are shorter but signatures are not (326 to 1142 bits).