ruby-srp 0.1.4 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/srp/client.rb +9 -4
- data/lib/srp/user.rb +19 -0
- data/ruby-srp.gemspec +1 -1
- data/test/auth_test.rb +8 -3
- data/test/client_test.rb +6 -2
- data/test/session_test.rb +6 -2
- metadata +3 -2
data/lib/srp/client.rb
CHANGED
@@ -5,11 +5,16 @@ module SRP
|
|
5
5
|
|
6
6
|
attr_reader :salt, :verifier, :username
|
7
7
|
|
8
|
-
def initialize(username,
|
8
|
+
def initialize(username, options)
|
9
9
|
@username = username
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
if options[:password]
|
11
|
+
@password = options[:password]
|
12
|
+
@salt = options[:salt] || bigrand(4).hex
|
13
|
+
calculate_verifier
|
14
|
+
else
|
15
|
+
@verifier = options[:verifier]
|
16
|
+
@salt = options[:salt]
|
17
|
+
end
|
13
18
|
end
|
14
19
|
|
15
20
|
def authenticate(server)
|
data/lib/srp/user.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
#
|
2
|
+
# SRP User on the server.
|
3
|
+
#
|
4
|
+
# This will be used in the session instead of the real user record so the
|
5
|
+
# session does not get cluttered with the whole user record.
|
6
|
+
#
|
7
|
+
module SRP
|
8
|
+
class User
|
9
|
+
|
10
|
+
attr_reader :username, :salt, :verifier
|
11
|
+
|
12
|
+
def initialize(user)
|
13
|
+
@username = user.username
|
14
|
+
@salt = user.salt
|
15
|
+
@verifier = user.verifier
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
data/ruby-srp.gemspec
CHANGED
data/test/auth_test.rb
CHANGED
@@ -29,7 +29,8 @@ class AuthTest < Test::Unit::TestCase
|
|
29
29
|
def setup
|
30
30
|
@username = 'user'
|
31
31
|
@password = 'opensesami'
|
32
|
-
@client = SRP::Client.new
|
32
|
+
@client = SRP::Client.new @username,
|
33
|
+
:password => @password
|
33
34
|
@server = Server.new(@client.salt, @client.verifier, @username)
|
34
35
|
end
|
35
36
|
|
@@ -38,12 +39,16 @@ class AuthTest < Test::Unit::TestCase
|
|
38
39
|
end
|
39
40
|
|
40
41
|
def test_a_wrong_password
|
41
|
-
client = SRP::Client.new
|
42
|
+
client = SRP::Client.new @username,
|
43
|
+
:password => "wrong password",
|
44
|
+
:salt => @client.salt
|
42
45
|
assert !client.authenticate(@server)
|
43
46
|
end
|
44
47
|
|
45
48
|
def test_wrong_username
|
46
|
-
client = SRP::Client.new
|
49
|
+
client = SRP::Client.new "wrong username",
|
50
|
+
:password => @password,
|
51
|
+
:salt => @client.salt
|
47
52
|
assert !client.authenticate(@server)
|
48
53
|
end
|
49
54
|
end
|
data/test/client_test.rb
CHANGED
@@ -8,7 +8,9 @@ class ClientTest < Test::Unit::TestCase
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def test_calculation_of_private_key
|
11
|
-
@client = SRP::Client.new
|
11
|
+
@client = SRP::Client.new @login,
|
12
|
+
:password => @password,
|
13
|
+
:salt => "7686acb8".hex
|
12
14
|
assert_equal "84d6bb567ddf584b1d8c8728289644d45dbfbb02deedd05c0f64db96740f0398",
|
13
15
|
"%x" % @client.send(:private_key)
|
14
16
|
end
|
@@ -17,7 +19,9 @@ class ClientTest < Test::Unit::TestCase
|
|
17
19
|
# s,V = pysrp.create_salted_verification_key("testuser", "password", pysrp.SHA256, pysrp.NG_1024)
|
18
20
|
|
19
21
|
def test_verifier
|
20
|
-
@client = SRP::Client.new
|
22
|
+
@client = SRP::Client.new @login,
|
23
|
+
:password => @password,
|
24
|
+
:salt => '4c78c3f8'.hex
|
21
25
|
v = '474c26aa42d11f20544a00f7bf9711c4b5cf7aab95ed448df82b95521b96668e7480b16efce81c861870302560ddf6604c67df54f1d04b99d5bb9d0f02c6051ada5dc9d594f0d4314e12f876cfca3dcd99fc9c98c2e6a5e04298b11061fb8549a22cde0564e91514080df79bca1c38c682214d65d590f66b3719f954b078b83c'
|
22
26
|
assert_equal v, "%x" % @client.verifier
|
23
27
|
end
|
data/test/session_test.rb
CHANGED
@@ -9,7 +9,9 @@ class SessionTest < Test::Unit::TestCase
|
|
9
9
|
@username = "testuser"
|
10
10
|
@password = "password"
|
11
11
|
@salt = '4c78c3f8'.hex
|
12
|
-
@client = SRP::Client.new
|
12
|
+
@client = SRP::Client.new @username,
|
13
|
+
:password => @password,
|
14
|
+
:salt => @salt
|
13
15
|
@verifier = @client.verifier
|
14
16
|
end
|
15
17
|
|
@@ -35,7 +37,9 @@ class SessionTest < Test::Unit::TestCase
|
|
35
37
|
b = "78e12fc099be1409e0fce3bf84484d89d58710bcc3d8a0e05227fb291be3fb28".hex
|
36
38
|
bb = "d8d50a862b7e8a897f8b0554c4a474e8aa152bd08f23436773fbb977e81cbf5e8262937ffb7ad6b72e3aa7f72deec947cdb286ab466e490d7c544bf443331ad12657c8f9bb2aabf508b73ea1ed29d03a060f5f2a70baef858bdb79c5c878844c058fe10c2cc746b0fb701e98d8d6405ab7d0b65bb4f87cf8e47b25ae4ee6e53b".hex
|
37
39
|
m = "d5cbec7254ce66f421ceddbfe8a0a8991b5be2aa9c25d868f073f4459dfc358b".hex
|
38
|
-
client = SRP::Client.new
|
40
|
+
client = SRP::Client.new @username,
|
41
|
+
:password => password,
|
42
|
+
:salt => @salt
|
39
43
|
assert_equal @verifier.to_s(16), client.verifier.to_s(16)
|
40
44
|
session = SRP::Session.new(self, aa)
|
41
45
|
session.send(:initialize_server, aa, b) # seeding b to compare to py_srp
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-srp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-02-06 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: SRP client and server based on version 6 of the standard
|
15
15
|
email:
|
@@ -41,6 +41,7 @@ files:
|
|
41
41
|
- lib/ruby-srp.rb
|
42
42
|
- lib/srp/client.rb
|
43
43
|
- lib/srp/session.rb
|
44
|
+
- lib/srp/user.rb
|
44
45
|
- lib/srp/util.rb
|
45
46
|
- ruby-srp.gemspec
|
46
47
|
- test/auth_test.rb
|