rotp 1.3.2 → 1.3.3
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/README.markdown +9 -0
- data/lib/rotp/hotp.rb +1 -1
- data/lib/rotp/otp.rb +4 -0
- data/lib/rotp/totp.rb +1 -1
- data/lib/rotp/version.rb +1 -1
- data/rotp.gemspec +1 -1
- data/spec/base_spec.rb +1 -1
- data/spec/hotp_spec.rb +17 -0
- data/spec/totp_spec.rb +17 -0
- metadata +10 -8
data/README.markdown
CHANGED
@@ -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
|
data/lib/rotp/hotp.rb
CHANGED
@@ -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
|
14
|
+
super(otp, self.at(counter))
|
15
15
|
end
|
16
16
|
|
17
17
|
# Returns the provisioning URI for the OTP
|
data/lib/rotp/otp.rb
CHANGED
data/lib/rotp/totp.rb
CHANGED
@@ -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
|
32
|
+
super(otp, self.at(time))
|
33
33
|
end
|
34
34
|
|
35
35
|
# Returns the provisioning URI for the OTP
|
data/lib/rotp/version.rb
CHANGED
data/rotp.gemspec
CHANGED
@@ -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
|
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
|
|
data/spec/base_spec.rb
CHANGED
@@ -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
|
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
|
data/spec/hotp_spec.rb
ADDED
@@ -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
|
data/spec/totp_spec.rb
ADDED
@@ -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:
|
4
|
+
hash: 29
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 1.3.
|
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:
|
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
|
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
|
-
|
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.
|
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
|