rubyntlm 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 33cb0ea71a4b1d8149a2a8bf39c5f24bd2752d5b
4
- data.tar.gz: 032e16ead1a05ddcf0268d79c4ffff2ff631bfcf
3
+ metadata.gz: b0f0a253f64eaf9c8dc94df34a8f2ca3e92cc43f
4
+ data.tar.gz: 85e3ac2289f6ed8cd265429280e2be7c1187d05d
5
5
  SHA512:
6
- metadata.gz: c276677b10f3f2b7fa35817fce82e1cfd5012298c752fbfc4576f0b4d45d339a5e6589fb547c16aa6609cb4174f2e9ac396c0f49ad7e7267f5b68b20f6e1fa47
7
- data.tar.gz: 40e3423ad351782e571611b32704b583c0b75a06a2b3acedc62dc9c6e916b0bc3356fe51d1060dd3cda0ef330b175ad108623625b3f7a6f6eb7728f66d03216e
6
+ metadata.gz: 9a87594be04e9d3cd5630e0ad3ed19f8d069daf4c39c78b33f5c19487fdc97960e40bc2f62b689c5f4004895befc5cb1ab38d4a781d630bcda4b50aa098d1112
7
+ data.tar.gz: 7697d3619ceef486dcde7461eabc8ba9f0a7e60f9315088e01f23285b029e506b80c6f509f3aa3964fb593b6a3842a6669e96e115ad11b69d47f3c988bddea12
@@ -42,6 +42,10 @@ module Net
42
42
  @session
43
43
  end
44
44
 
45
+ def session_key
46
+ @session.exported_session_key
47
+ end
48
+
45
49
  private
46
50
 
47
51
  # @return [Message::Type1]
@@ -38,13 +38,24 @@ module Net
38
38
  rc4 = OpenSSL::Cipher::Cipher.new("rc4")
39
39
  rc4.encrypt
40
40
  rc4.key = user_session_key
41
- sk = rc4.update master_key
41
+ sk = rc4.update exported_session_key
42
42
  sk << rc4.final
43
43
  t3.session_key = sk
44
44
  end
45
45
  t3
46
46
  end
47
47
 
48
+ def exported_session_key
49
+ @exported_session_key ||=
50
+ begin
51
+ if negotiate_key_exchange?
52
+ OpenSSL::Cipher.new("rc4").random_key
53
+ else
54
+ user_session_key
55
+ end
56
+ end
57
+ end
58
+
48
59
  def sign_message(message)
49
60
  seq = sequence
50
61
  sig = OpenSSL::HMAC.digest(OpenSSL::Digest::MD5.new, client_sign_key, "#{seq}#{message}")[0..7]
@@ -75,7 +86,6 @@ module Net
75
86
  message + server_cipher.final
76
87
  end
77
88
 
78
-
79
89
  private
80
90
 
81
91
 
@@ -83,16 +93,6 @@ module Net
83
93
  @user_session_key ||= nil
84
94
  end
85
95
 
86
- def master_key
87
- @master_key ||= begin
88
- if negotiate_key_exchange?
89
- OpenSSL::Cipher.new("rc4").random_key
90
- else
91
- user_session_key
92
- end
93
- end
94
- end
95
-
96
96
  def sequence
97
97
  [raw_sequence].pack("V*")
98
98
  end
@@ -106,19 +106,19 @@ module Net
106
106
  end
107
107
 
108
108
  def client_sign_key
109
- @client_sign_key ||= OpenSSL::Digest::MD5.digest "#{master_key}#{CLIENT_TO_SERVER_SIGNING}"
109
+ @client_sign_key ||= OpenSSL::Digest::MD5.digest "#{exported_session_key}#{CLIENT_TO_SERVER_SIGNING}"
110
110
  end
111
111
 
112
112
  def server_sign_key
113
- @server_sign_key ||= OpenSSL::Digest::MD5.digest "#{master_key}#{SERVER_TO_CLIENT_SIGNING}"
113
+ @server_sign_key ||= OpenSSL::Digest::MD5.digest "#{exported_session_key}#{SERVER_TO_CLIENT_SIGNING}"
114
114
  end
115
115
 
116
116
  def client_seal_key
117
- @client_seal_key ||= OpenSSL::Digest::MD5.digest "#{master_key}#{CLIENT_TO_SERVER_SEALING}"
117
+ @client_seal_key ||= OpenSSL::Digest::MD5.digest "#{exported_session_key}#{CLIENT_TO_SERVER_SEALING}"
118
118
  end
119
119
 
120
120
  def server_seal_key
121
- @server_seal_key ||= OpenSSL::Digest::MD5.digest "#{master_key}#{SERVER_TO_CLIENT_SEALING}"
121
+ @server_seal_key ||= OpenSSL::Digest::MD5.digest "#{exported_session_key}#{SERVER_TO_CLIENT_SEALING}"
122
122
  end
123
123
 
124
124
  def client_cipher
@@ -77,8 +77,10 @@ module Net
77
77
  ar = {:ntlm_hash => NTLM::ntlm_hash(pwd, opt), :challenge => chal}
78
78
  lm_res, ntlm_res = NTLM::ntlm2_session(ar, opt)
79
79
  else
80
- lm_res = NTLM::lm_response(pwd, chal)
81
- ntlm_res = NTLM::ntlm_response(pwd, chal)
80
+ ar = {:lm_hash => NTLM::lm_hash(pwd), :challenge => chal}
81
+ lm_res = NTLM::lm_response(ar)
82
+ ar = {:ntlm_hash => NTLM::ntlm_hash(pwd, opt), :challenge => chal}
83
+ ntlm_res = NTLM::ntlm_response(ar)
82
84
  end
83
85
 
84
86
  Type3.create({
@@ -4,7 +4,7 @@ module Net
4
4
  module VERSION
5
5
  MAJOR = 0
6
6
  MINOR = 5
7
- TINY = 0
7
+ TINY = 1
8
8
  STRING = [MAJOR, MINOR, TINY].join('.')
9
9
  end
10
10
  end
@@ -51,17 +51,17 @@ describe Net::NTLM::Client::Session do
51
51
  end
52
52
  end
53
53
 
54
- describe "#master_key" do
54
+ describe "#exported_session_key" do
55
55
  it "returns a random 16-byte key when negotiate_key_exchange? is true" do
56
56
  expect(inst).to receive(:negotiate_key_exchange?).and_return(true)
57
57
  expect(inst).not_to receive(:user_session_key)
58
- inst.send :master_key
58
+ inst.exported_session_key
59
59
  end
60
60
 
61
61
  it "returns the user_session_key when negotiate_key_exchange? is false" do
62
62
  expect(inst).to receive(:negotiate_key_exchange?).and_return(false)
63
63
  expect(inst).to receive(:user_session_key).and_return(user_session_key)
64
- inst.send :master_key
64
+ inst.exported_session_key
65
65
  end
66
66
  end
67
67
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubyntlm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kohei Kajimoto
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-02-22 00:00:00.000000000 Z
12
+ date: 2015-06-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: pry
@@ -149,7 +149,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
149
149
  version: '0'
150
150
  requirements: []
151
151
  rubyforge_project:
152
- rubygems_version: 2.4.2
152
+ rubygems_version: 2.4.7
153
153
  signing_key:
154
154
  specification_version: 4
155
155
  summary: Ruby/NTLM library.