DiffieHellman Secret Key Exchange

The purpose of this algorithm is to enable two users to exchange a key securely that can then be used for subsequent encryption of messages. The algorithm itself is limited to the exchange of keys.

Two publicly known parameters:

1.prime number q

2.integer g that is primitive root of q.

Using these two parameters, suppose two users A and B want to exchange a key. Respectively A and B generate their own private key Xa and Xb. (Xa<q, Xb<q). Calculate Ya=g^Xa mod q, Yb=g^Xb mod q. A sends Ya to B. B sends Yb to A. Now they can calculate the private as follows:

                                     A:   Yb^Xa mod q=(g^Xb mod q)^Xa mod q=g^(Xb*Xa) mod q

                                     B:   Ya^Xb mod q=(g^Xa mod q)^Xb mod q=g^(Xa*Xb) mod q

posted @ 2013-11-09 00:50  丸子No1  阅读(137)  评论(0编辑  收藏  举报