Class: Net::SSH::Transport::Kex::DiffieHellmanGroup1SHA1
- Inherits:
-
Object
- Object
- Net::SSH::Transport::Kex::DiffieHellmanGroup1SHA1
- Defined in:
- lib/net/ssh/transport/kex/diffie_hellman_group1_sha1.rb
Overview
A key-exchange service implementing the “diffie-hellman-group1-sha1” key-exchange algorithm.
Direct Known Subclasses
Constant Summary collapse
- P_s =
The value of ‘P’, as a string, in hexadecimal
"FFFFFFFF" "FFFFFFFF" "C90FDAA2" "2168C234" + "C4C6628B" "80DC1CD1" "29024E08" "8A67CC74" + "020BBEA6" "3B139B22" "514A0879" "8E3404DD" + "EF9519B3" "CD3A431B" "302B0A6D" "F25F1437" + "4FE1356D" "6D51C245" "E485B576" "625E7EC6" + "F44C42E9" "A637ED6B" "0BFF5CB6" "F406B7ED" + "EE386BFB" "5A899FA5" "AE9F2411" "7C4B1FE6" + "49286651" "ECE65381" "FFFFFFFF" "FFFFFFFF"
- P_r =
The radix in which P_s represents the value of P
16
- G =
The group constant
2
Constants included from Constants
Constants::DEBUG, Constants::DISCONNECT, Constants::IGNORE, Constants::KEXDH_INIT, Constants::KEXDH_REPLY, Constants::KEXINIT, Constants::NEWKEYS, Constants::SERVICE_ACCEPT, Constants::SERVICE_REQUEST, Constants::UNIMPLEMENTED
Instance Attribute Summary collapse
-
#algorithms ⇒ Object
readonly
Returns the value of attribute algorithms.
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#dh ⇒ Object
readonly
Returns the value of attribute dh.
-
#digester ⇒ Object
readonly
Returns the value of attribute digester.
-
#g ⇒ Object
readonly
Returns the value of attribute g.
-
#p ⇒ Object
readonly
Returns the value of attribute p.
Attributes included from Loggable
Instance Method Summary collapse
-
#exchange_keys ⇒ Object
Perform the key-exchange for the given session, with the given data.
-
#initialize(algorithms, connection, data) ⇒ DiffieHellmanGroup1SHA1
constructor
Create a new instance of the DiffieHellmanGroup1SHA1 algorithm.
Methods included from Loggable
#debug, #error, #fatal, #info, #lwarn
Constructor Details
#initialize(algorithms, connection, data) ⇒ DiffieHellmanGroup1SHA1
Create a new instance of the DiffieHellmanGroup1SHA1 algorithm. The data is a Hash of symbols representing information required by this algorithm, which was acquired during earlier processing.
42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/net/ssh/transport/kex/diffie_hellman_group1_sha1.rb', line 42 def initialize(algorithms, connection, data) @p = OpenSSL::BN.new(P_s, P_r) @g = G @digester = OpenSSL::Digest::SHA1 @algorithms = algorithms @connection = connection @data = data.dup @dh = generate_key @logger = @data.delete(:logger) end |
Instance Attribute Details
#algorithms ⇒ Object (readonly)
Returns the value of attribute algorithms.
33 34 35 |
# File 'lib/net/ssh/transport/kex/diffie_hellman_group1_sha1.rb', line 33 def algorithms @algorithms end |
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
34 35 36 |
# File 'lib/net/ssh/transport/kex/diffie_hellman_group1_sha1.rb', line 34 def connection @connection end |
#data ⇒ Object (readonly)
Returns the value of attribute data.
35 36 37 |
# File 'lib/net/ssh/transport/kex/diffie_hellman_group1_sha1.rb', line 35 def data @data end |
#dh ⇒ Object (readonly)
Returns the value of attribute dh.
36 37 38 |
# File 'lib/net/ssh/transport/kex/diffie_hellman_group1_sha1.rb', line 36 def dh @dh end |
#digester ⇒ Object (readonly)
Returns the value of attribute digester.
32 33 34 |
# File 'lib/net/ssh/transport/kex/diffie_hellman_group1_sha1.rb', line 32 def digester @digester end |
#g ⇒ Object (readonly)
Returns the value of attribute g.
31 32 33 |
# File 'lib/net/ssh/transport/kex/diffie_hellman_group1_sha1.rb', line 31 def g @g end |
#p ⇒ Object (readonly)
Returns the value of attribute p.
30 31 32 |
# File 'lib/net/ssh/transport/kex/diffie_hellman_group1_sha1.rb', line 30 def p @p end |
Instance Method Details
#exchange_keys ⇒ Object
Perform the key-exchange for the given session, with the given data. This method will return a hash consisting of the following keys:
-
:session_id
-
:server_key
-
:shared_secret
-
:hashing_algorithm
The caller is expected to be able to understand how to use these deliverables.
66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/net/ssh/transport/kex/diffie_hellman_group1_sha1.rb', line 66 def exchange_keys result = send_kexinit verify_server_key(result[:server_key]) session_id = verify_signature(result) confirm_newkeys return { :session_id => session_id, :server_key => result[:server_key], :shared_secret => result[:shared_secret], :hashing_algorithm => digester } end |