summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAzul <azul@riseup.net>2013-02-06 16:05:59 +0100
committerAzul <azul@riseup.net>2013-02-06 16:05:59 +0100
commitc3fdb32a13c0028536109c17fb6f75db8708a43f (patch)
treeae11a9db160256a206a95c7c38e5b6165e30f69c /lib
parentbda0084efb0ebadcbe22fb4a91ec925593564e1a (diff)
changed SRP:Client so it can be used to wrap a user record on the server
Diffstat (limited to 'lib')
-rw-r--r--lib/srp/client.rb13
-rw-r--r--lib/srp/user.rb19
2 files changed, 28 insertions, 4 deletions
diff --git a/lib/srp/client.rb b/lib/srp/client.rb
index 3882f1d..ebe158f 100644
--- a/lib/srp/client.rb
+++ b/lib/srp/client.rb
@@ -5,11 +5,16 @@ module SRP
attr_reader :salt, :verifier, :username
- def initialize(username, password, salt = nil)
+ def initialize(username, options)
@username = username
- @password = password
- @salt = salt || bigrand(4).hex
- calculate_verifier
+ if options[:password]
+ @password = options[:password]
+ @salt = options[:salt] || bigrand(4).hex
+ calculate_verifier
+ else
+ @verifier = options[:verifier]
+ @salt = options[:salt]
+ end
end
def authenticate(server)
diff --git a/lib/srp/user.rb b/lib/srp/user.rb
new file mode 100644
index 0000000..1330de7
--- /dev/null
+++ b/lib/srp/user.rb
@@ -0,0 +1,19 @@
+#
+# SRP User on the server.
+#
+# This will be used in the session instead of the real user record so the
+# session does not get cluttered with the whole user record.
+#
+module SRP
+ class User
+
+ attr_reader :username, :salt, :verifier
+
+ def initialize(user)
+ @username = user.username
+ @salt = user.salt
+ @verifier = user.verifier
+ end
+
+ end
+end