Cryptography Overview
64 RSA BSAFE Crypto-C Developer’s Guide
3. The two parties exchange the public values.
These private and public values correspond to the private and public key components
of a key pair. The public value is generated in such a way that computing the private
value from the public number is computationally infeasible.
Phase 2
Each participant computes the agreed-upon secret key, z, using the other participant’s
public value, y', their own private value, x, and the prime, p.
z =(y')
x
mod p
Even with knowledge of the parameters and both public keys, an outside individual
will not be able to determine the secret key. You must have one of the private values
to determine the secret key. This means secret information is never sent over unsecure
lines.
The Math
Even though the two parties involved are making computations using different
private values, they will both end up with the same secret key, as illustrated by the
following.
p: prime
g: base
x
1
: 1st party’s private value
x
2
: 2nd party’s private value
y
1
: 1st party’s public value
y
2
: 2nd party’s public value
z: secret key
In Phase 1, each party computes a private value, x
n
, and a public value, y
n
:
y
1
= g
x
1
mod p
y
2
= g
x
2
mod p
In Phase 2, the parties trade public values and compute the same secret key:
z = y
2
x
1
mod p
z = y
1
x
2
mod p
They both compute the same z, because:
y
2
x
1
= (g
x
2
)
x
1
= (g
x
1
)
x
2
= y
1
x
2
mod p