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.
Algorithms: Key & signature generation, signature verification.
Key generation algorithm outputs a private signing key, KS and public verification key, KV.
Signature generation: s=Sig(M,KS), where M 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) outputs true or false.
Correctness: if s=Sig(M,KS), then Ver(M,s,KV)=true (for matching KS and KV).
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).
Key recovery: recovering the private signing key KS fom the public verification key KV 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.
Key generation is the same as for encryption keys:
- Public verification key: n, e where n is the product of two large primes p and q
- Private signing key: p, q, d such that edmodϕ(n)=1
A fixed public parameter, the hash function h, is also required (e.g. SHA-256).
Given message M, modulus n and private exponent d, the signature is s=h(M)dmodn. (M,s) is the signature.
Given claimed signature (M,s), modulus n and public exponent e, check if semodn=h(M)
Three versions:
- Original Elgamal signatures in Zp∗ (1985)
- Digital signature algorithm (DSA) standardized by NIST
- DSA based on elliptic curve groups: ECDSA
-
p is a large prime
-
g is a generator of Zp∗
-
x is the private signing key, where 0<x<p−1
-
y=gxmodp is part of the public key
- A message m in 0<M<p−1
p, g and y form the public verification key.
Signature generation:
-
Pick random k such that gcd(k,p−1)=1
-
Compute r=gkmodp
-
Solve M=xr+ksmod(p−1) for s:
s=k−1(M−xr)mod(p−1)
-
Output the tuple (M,r,s)
Signature verification: check if
gM≡yrrs(modp)
Fermat’s little theorem: given a prime p, for any integer a<p:
ap−aa(ap−1−1)=np=np
if gcd(a,p)=1, a=np and hence:
ap−1−1∴ap−1=np≡1(modp)
Let M≡y(modp−1):
aM≡aM⋅an(p−1)≡aM+n(p−1)≡aMmod(p−1)≡ay(modp)(modp)(modp)(modp)
Hence, coming back to the Elgamal signature verification equation (and noting that g is a generator and hence relatively prime to p:
gM≡gsk+xr≡gskgxr≡gskgxr≡(gk)s(gx)r≡rsyr(modp)(modp)(modp)(modp)(modp)
as required.
Published by NIST in 1994. Based on Elgamal signatures but calculations are simpler and signatures shorter: done in a subgroup of Zp∗ or an elliptic curve group. Also prevents attacks Elgamal signatures were vulnerable to.
Prime p chosen such that p−1 has a prime divisor q that is much smaller.
Generator g from Elgamal signatures is replaced by:
g=hqp−1modp
where h is a generator.
g has order q as gqmodp=1 (by Fermat’s theorem, gqmodp=(hqp−1)qmodp=hp−1modp=1).
Hence, all exponents can be reduced modulo q before exponentiation.
Let H be a standard SHA hash algorithm such that the output is N bits long (the same size as q).
gH(M)≡yrrsmodp so rearranged, we get the verification equation:
(gH(M))s−1(y−r)s−1≡r(modp)
Both sides of the equation are reduced modulo q.
p is a L-bit long prime modulus, q a N bit long a prime divisor of p−1. There are several approved combinations for (L,N,Hash fn): (1024,160,SHA-1), (2048,224,SHA-224), (2048,256,SHA-256), (3072,256,SHA-256). The first option may be insecure.
Key generation:
- Choose secret key 0<x<q
- Compute the public key, y=gxmodp.
Signature generation:
- Message M
- Pick 0<k<q
- Compute r=(gkmodp)modq
- Compute s=k−1(H(M)−xr)modq
- Set the signature as (M,r,s)
Signature verification:
- Check if 0<r<q, 0<s<q
- Compute w=s−1modq
- Compute u1=H(M)wmodq
- Compute u2=rwmodq
- Check that (gu1y−u2modp)modq=r
Verification equation is the same as with Elgamal except that all exponents and the final result is reduced modulo q. Signature size is also smaller at 2N bits.
Where p and q are primes and gcd(p−1,q)=m=1, let n be any integer.
====ab+nqab+n⋅mp−1ab(ap−1)mnab⋅1mnabmodpmodpmodpmodpmodp
Hence abmodqmodp≡abmodp
Let M≡y(modp−1):
aM≡aM⋅an(p−1)≡aM+n(p−1)≡aMmod(p−1)≡ay(modp)(modp)(modp)(modp)
Hence, coming back to the Elgamal signature verification equation (and noting that g is a generator and hence relatively prime to p:
gM≡gsk+xr≡gskgxr≡gskgxr≡(gk)s(gx)r≡rsyr(modp)(modp)(modp)(modp)(modp)
as required.
Similar to DSA except that:
-
q becomes the order of the elliptic curve group
- Multiplication modulo p is replaced by the elliptic curve group operation
- After operations on group elements, only the x coordinate is kept from the pair (x,y)
Compared to DSA, public keys are shorter but signatures are not (326 to 1142 bits).