diff options
author | Azul <azul@leap.se> | 2012-08-06 12:34:47 +0200 |
---|---|---|
committer | Azul <azul@leap.se> | 2012-08-06 12:41:06 +0200 |
commit | 552574bfb0a0160935452b605bb262b5b52c4f67 (patch) | |
tree | 71ec6bba217db018f20a4270eacdcdb02c7a8dbe | |
parent | 8d489f7c431cf24c84ac5fc23be1b9b3531b402b (diff) |
added authenticate! which raises SRP::WrongPassword if it fails, version 0.0.2
-rw-r--r-- | lib/ruby-srp.rb (renamed from lib/srp.rb) | 2 | ||||
-rw-r--r-- | lib/srp/authentication.rb | 4 | ||||
-rw-r--r-- | ruby-srp.gemspec | 2 | ||||
-rw-r--r-- | test/test_helper.rb | 2 |
4 files changed, 8 insertions, 2 deletions
diff --git a/lib/srp.rb b/lib/ruby-srp.rb index a008b82..7cbe06f 100644 --- a/lib/srp.rb +++ b/lib/ruby-srp.rb @@ -10,4 +10,6 @@ $:.unshift File.dirname(__FILE__) module SRP autoload :Client, 'srp/client' autoload :Authentication, 'srp/authentication' + class WrongPassword < StandardError + end end diff --git a/lib/srp/authentication.rb b/lib/srp/authentication.rb index a2431d0..4afe20b 100644 --- a/lib/srp/authentication.rb +++ b/lib/srp/authentication.rb @@ -41,6 +41,10 @@ module SRP return Session.new(aa, verifier) end + def authenticate!(m, session) + authenticate(m, session) || raise(SRP::WrongPassword) + end + def authenticate(m, session) if(m == session.m1(verifier)) return session.m2(m, verifier) diff --git a/ruby-srp.gemspec b/ruby-srp.gemspec index a7383c9..eac9076 100644 --- a/ruby-srp.gemspec +++ b/ruby-srp.gemspec @@ -1,6 +1,6 @@ Gem::Specification.new do |s| s.name = "ruby-srp" - s.version = "0.0.1" + s.version = "0.0.2" s.platform = Gem::Platform::RUBY s.authors = ["Azul"] s.email = ["azul@leap.se"] diff --git a/test/test_helper.rb b/test/test_helper.rb index 68d3acf..65be0d5 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,3 +1,3 @@ require "rubygems" require 'test/unit' -require File.expand_path(File.dirname(__FILE__) + '/../lib/srp.rb') +require File.expand_path(File.dirname(__FILE__) + '/../lib/ruby-srp.rb') |