AKE — Authenticated Key Exchange
by FOX on 10:37 PM, under Encryption
In my previous post, there is a high level overview about how OTR works. It mentions about AKE system. Today I am gonna show you how AKE works
Assume that Alice and Bob are going to implement AKE, The general idea is that Alice and Bob do an unauthenticated Diffie-Hellman (D-H) key exchange to set up an encrypted channel, and then do mutual authentication insidethat channel.
All exponentiations are done modulo a particular 1536-bit prime, and g is a generator of that group, as indicated in the detailed description below. Alice and Bob’s long-term authentication public keys are pubA and pubB, respectively.
Bob will be initiating AKE with Alice
- Bob:
- Picks a random value r (128 bits)
- Picks a random value x (at least 320 bits)
- Sends Alice AESr(gx), HASH(gx)
- Alice:
- Picks a random value y (at least 320 bits)
- Sends Bob gy
- Bob:
- Verifies that Alice’s gy is a legal value (2 <= gy <= modulus-2)
- Computes s = (gy)x
- Computes two AES keys c, c’ and four MAC keys m1, m1′, m2, m2′ by hashing s in various ways
- Picks keyidB, a serial number for his D-H key gx
- Computes MB = MACm1(gx, gy, pubB, keyidB)
- Computes XB = pubB, keyidB, sigB(MB)
- Sends Alice r, AESc(XB), MACm2(AESc(XB))
- Alice:
- Uses r to decrypt the value of gx sent earlier
- Verifies that HASH(gx) matches the value sent earlier
- Verifies that Bob’s gx is a legal value (2 <= gx <= modulus-2)
- Computes s = (gx)y (note that this will be the same as the value of s Bob calculated)
- Computes two AES keys c, c’ and four MAC keys m1, m1′, m2, m2′ by hashing s in various ways (the same as Bob)
- Uses m2 to verify MACm2(AESc(XB))
- Uses c to decrypt AESc(XB) to obtain XB = pubB, keyidB, sigB(MB)
- Computes MB = MACm1(gx, gy, pubB, keyidB)
- Uses pubB to verify sigB(MB)
- Picks keyidA, a serial number for her D-H key gy
- Computes MA = MACm1′(gy, gx, pubA, keyidA)
- Computes XA = pubA, keyidA, sigA(MA)
- Sends Bob AESc’(XA), MACm2′(AESc’(XA))
- Bob:
- Uses m2′ to verify MACm2′(AESc’(XA))
- Uses c’ to decrypt AESc’(XA) to obtain XA = pubA, keyidA, sigA(MA)
- Computes MA = MACm1′(gy, gx, pubA, keyidA)
- Uses pubA to verify sigA(MA)
- If all of the verifications succeeded, Alice and Bob now know each other’s Diffie-Hellman public keys, and share the value s. Alice is assured that s is known by someone with access to the private key corresponding to pubB, and similarly for Bob.