rotp 1.3.2 → 1.3.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -71,6 +71,15 @@ Now run the following and compare the output
71
71
  totp = ROTP::TOTP.new("JBSWY3DPEHPK3PXP")
72
72
  p "Current OTP: #{totp.now}"
73
73
 
74
+ ### Contributors
75
+
76
+ git shortlog -s -n
77
+
78
+ 31 Mark Percival
79
+ 3 David Vrensk
80
+ 1 Micah Gates
81
+ 1 Nathan Reynolds
82
+
74
83
  ### Changelog
75
84
 
76
85
  ####1.3.0
@@ -11,7 +11,7 @@ module ROTP
11
11
  # @param [String/Integer] otp the OTP to check against
12
12
  # @param [Integer] counter the counter of the OTP
13
13
  def verify(otp, counter)
14
- otp == self.at(counter)
14
+ super(otp, self.at(counter))
15
15
  end
16
16
 
17
17
  # Returns the provisioning URI for the OTP
@@ -36,6 +36,10 @@ module ROTP
36
36
 
37
37
  private
38
38
 
39
+ def verify(input, generated)
40
+ input.to_i == generated
41
+ end
42
+
39
43
  def byte_secret
40
44
  Base32.decode(@secret)
41
45
  end
@@ -29,7 +29,7 @@ module ROTP
29
29
  # Verifies the OTP passed in against the current time OTP
30
30
  # @param [String/Integer] otp the OTP to check against
31
31
  def verify(otp, time = Time.now)
32
- otp == self.at(time)
32
+ super(otp, self.at(time))
33
33
  end
34
34
 
35
35
  # Returns the provisioning URI for the OTP
@@ -1,3 +1,3 @@
1
1
  module ROTP
2
- VERSION = "1.3.2"
2
+ VERSION = "1.3.3"
3
3
  end
@@ -11,7 +11,7 @@ Gem::Specification.new do |s|
11
11
  s.email = ["mark@markpercival.us"]
12
12
  s.homepage = "http://github.com/mdp/rotp"
13
13
  s.summary = %q{A Ruby library for generating and verifying one time passwords}
14
- s.description = %q{Works for both HOTP and TOTP, and include QR Code provisioning}
14
+ s.description = %q{Works for both HOTP and TOTP, and includes QR Code provisioning}
15
15
 
16
16
  s.rubyforge_project = "rotp"
17
17
 
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  describe "generating a random base32 secret" do
4
4
  it "should be 16 characters by default" do
5
5
  ROTP::Base32.random_base32.length.should == 16
6
- ROTP::Base32.random_base32.should match /[a-z2-7].+/
6
+ ROTP::Base32.random_base32.should match /\A[a-z2-7]+\z/
7
7
  end
8
8
  it "should be allow a specific length" do
9
9
  ROTP::Base32.random_base32(32).length.should == 32
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ describe ROTP::HOTP do
4
+ before(:all) { @now = Time.utc(2012,1,1).to_i / 30 }
5
+
6
+ subject { ROTP::HOTP.new('a' * 32) }
7
+
8
+ it "should generate a number given a time" do
9
+ subject.at(@now).should == 160864
10
+ end
11
+ it "should verify a number" do
12
+ subject.verify(160864, @now).should be_true
13
+ end
14
+ it "should verify a string" do
15
+ subject.verify("160864", @now).should be_true
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ describe ROTP::TOTP do
4
+ before(:all) { @now = Time.utc(2012,1,1) }
5
+
6
+ subject { ROTP::TOTP.new('a' * 32) }
7
+
8
+ it "should generate a number given a number" do
9
+ subject.at(@now).should == 160864
10
+ end
11
+ it "should verify a number" do
12
+ subject.verify(160864, @now).should be_true
13
+ end
14
+ it "should verify a string" do
15
+ subject.verify("160864", @now).should be_true
16
+ end
17
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rotp
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
4
+ hash: 29
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 3
9
- - 2
10
- version: 1.3.2
9
+ - 3
10
+ version: 1.3.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Mark Percival
@@ -15,11 +15,10 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-10-04 00:00:00 -07:00
19
- default_executable:
18
+ date: 2012-05-19 00:00:00 Z
20
19
  dependencies: []
21
20
 
22
- description: Works for both HOTP and TOTP, and include QR Code provisioning
21
+ description: Works for both HOTP and TOTP, and includes QR Code provisioning
23
22
  email:
24
23
  - mark@markpercival.us
25
24
  executables: []
@@ -61,8 +60,9 @@ files:
61
60
  - lib/rotp/version.rb
62
61
  - rotp.gemspec
63
62
  - spec/base_spec.rb
63
+ - spec/hotp_spec.rb
64
64
  - spec/spec_helper.rb
65
- has_rdoc: true
65
+ - spec/totp_spec.rb
66
66
  homepage: http://github.com/mdp/rotp
67
67
  licenses:
68
68
  - MIT
@@ -92,10 +92,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
92
92
  requirements: []
93
93
 
94
94
  rubyforge_project: rotp
95
- rubygems_version: 1.6.2
95
+ rubygems_version: 1.8.18
96
96
  signing_key:
97
97
  specification_version: 3
98
98
  summary: A Ruby library for generating and verifying one time passwords
99
99
  test_files:
100
100
  - spec/base_spec.rb
101
+ - spec/hotp_spec.rb
101
102
  - spec/spec_helper.rb
103
+ - spec/totp_spec.rb