class
Ruby latest stable (v2_5_5)
-
0 notes
- Superclass:
cPKey
- 1_8_6_287
- 1_8_7_72
- 1_8_7_330
- 1_9_1_378 (0)
- 1_9_2_180 (0)
- 1_9_3_125 (38)
- 1_9_3_392 (0)
- 2_1_10 (0)
- 2_2_9 (0)
- 2_4_6 (0)
- 2_5_5 (0)
- 2_6_3 (0)
- What's this?
An implementation of the Diffie-Hellman key exchange protocol based on discrete logarithms in finite fields, the same basis that DSA is built on.
Accessor methods for the Diffie-Hellman parameters
DH#p |
The prime (an OpenSSL::BN) of the Diffie-Hellman parameters. |
DH#g |
The generator (an OpenSSL::BN) g of the Diffie-Hellman parameters. |
DH#pub_key |
The per-session public key (an OpenSSL::BN) matching the private key. This needs to be passed to DH#compute_key. |
DH#priv_key |
The per-session private key, an OpenSSL::BN. |
Example of a key exchange
dh1 = OpenSSL::PKey::DH.new(2048) der = dh1.public_key.to_der #you may send this publicly to the participating party dh2 = OpenSSL::PKey::DH.new(der) dh2.generate_key! #generate the per-session key pair symm_key1 = dh1.compute_key(dh2.pub_key) symm_key2 = dh2.compute_key(dh1.pub_key) puts symm_key1 == symm_key2 # => true