From 552574bfb0a0160935452b605bb262b5b52c4f67 Mon Sep 17 00:00:00 2001 From: Azul Date: Mon, 6 Aug 2012 12:34:47 +0200 Subject: added authenticate! which raises SRP::WrongPassword if it fails, version 0.0.2 --- lib/ruby-srp.rb | 15 +++++++++++++++ lib/srp.rb | 13 ------------- lib/srp/authentication.rb | 4 ++++ ruby-srp.gemspec | 2 +- test/test_helper.rb | 2 +- 5 files changed, 21 insertions(+), 15 deletions(-) create mode 100644 lib/ruby-srp.rb delete mode 100644 lib/srp.rb diff --git a/lib/ruby-srp.rb b/lib/ruby-srp.rb new file mode 100644 index 0000000..7cbe06f --- /dev/null +++ b/lib/ruby-srp.rb @@ -0,0 +1,15 @@ +# Ruby library for the server side of the Secure Remote Password protocol + +# References +# `The Stanford SRP Homepage', +# http://srp.stanford.edu/ +# `SRP JavaScript Demo', +# http://srp.stanford.edu/demo/demo.html + +$:.unshift File.dirname(__FILE__) +module SRP + autoload :Client, 'srp/client' + autoload :Authentication, 'srp/authentication' + class WrongPassword < StandardError + end +end diff --git a/lib/srp.rb b/lib/srp.rb deleted file mode 100644 index a008b82..0000000 --- a/lib/srp.rb +++ /dev/null @@ -1,13 +0,0 @@ -# Ruby library for the server side of the Secure Remote Password protocol - -# References -# `The Stanford SRP Homepage', -# http://srp.stanford.edu/ -# `SRP JavaScript Demo', -# http://srp.stanford.edu/demo/demo.html - -$:.unshift File.dirname(__FILE__) -module SRP - autoload :Client, 'srp/client' - autoload :Authentication, 'srp/authentication' -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') -- cgit v1.2.3