rotp 1.4.2 → 1.4.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 67fe5641fca7e9f6a1212841fffa8e71a4d4d7a5
4
+ data.tar.gz: 3ec9c8acf749da329cc2e4a9fadcd91e24f48831
5
+ SHA512:
6
+ metadata.gz: fb8f9b08057601b7a7074ed72c146f7574c420e74433cd5227653401454653ef459b64ae08d7e7ae759cf8643710c4fa60ff3561f1372d2ed2f4c5d654de8b21
7
+ data.tar.gz: 423b1e7073b18a587d53dba75acea6552b1407d3b455fd2e7a8a41b16f2fdbcbbf8e52ca65035393e41db805c5d9001135a8e4ba7dfeb3033f8562dbf240aa37
@@ -2,9 +2,10 @@ module ROTP
2
2
  class HOTP < OTP
3
3
  # Generates the OTP for the given count
4
4
  # @param [Integer] count counter
5
+ # @option [Boolean] padding (false) Issue the number as a 0 padded string
5
6
  # @returns [Integer] OTP
6
- def at(count)
7
- generate_otp(count)
7
+ def at(count, padding=false)
8
+ generate_otp(count, padding)
8
9
  end
9
10
 
10
11
  # Verifies the OTP passed in against the current time OTP
@@ -13,17 +13,18 @@ module ROTP
13
13
  # Accepts either a Unix timestamp integer or a Time object.
14
14
  # Time objects will be adjusted to UTC automatically
15
15
  # @param [Time/Integer] time the time to generate an OTP for
16
- def at(time)
16
+ # @option [Boolean] padding (false) Issue the number as a 0 padded string
17
+ def at(time, padding=false)
17
18
  unless time.class == Time
18
19
  time = Time.at(time.to_i)
19
20
  end
20
- generate_otp(timecode(time))
21
+ generate_otp(timecode(time), padding)
21
22
  end
22
23
 
23
24
  # Generate the current time OTP
24
25
  # @return [Integer] the OTP as an integer
25
- def now
26
- generate_otp(timecode(Time.now))
26
+ def now(padding=false)
27
+ generate_otp(timecode(Time.now), padding)
27
28
  end
28
29
 
29
30
  # Verifies the OTP passed in against the current time OTP
@@ -1,3 +1,3 @@
1
1
  module ROTP
2
- VERSION = "1.4.2"
2
+ VERSION = "1.4.3"
3
3
  end
@@ -1,17 +1,20 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe ROTP::HOTP do
4
- before(:all) { @now = Time.utc(2012,1,1).to_i / 30 }
4
+ before(:all) { @counter = 1234 }
5
5
 
6
6
  subject { ROTP::HOTP.new('a' * 32) }
7
7
 
8
8
  it "should generate a number given a time" do
9
- subject.at(@now).should == 160864
9
+ subject.at(@counter).should == 161024
10
+ end
11
+ it "should generate a number as a string" do
12
+ subject.at(@counter, true).should == "161024"
10
13
  end
11
14
  it "should verify a number" do
12
- subject.verify(160864, @now).should be_true
15
+ subject.verify(161024, @counter).should be_true
13
16
  end
14
17
  it "should verify a string" do
15
- subject.verify("160864", @now).should be_true
18
+ subject.verify("161024", @counter).should be_true
16
19
  end
17
20
  end
@@ -3,24 +3,27 @@ require 'spec_helper'
3
3
  describe ROTP::TOTP do
4
4
  before(:all) { @now = Time.utc(2012,1,1) }
5
5
 
6
- subject { ROTP::TOTP.new('a' * 32) }
6
+ subject { ROTP::TOTP.new("JBSWY3DPEHPK3PXP") }
7
7
 
8
8
  it "should generate a number given a number" do
9
- subject.at(@now).should == 160864
9
+ subject.at(@now).should == 68212
10
+ end
11
+ it "should generate a number as a padded string" do
12
+ subject.at(@now, true).should == "068212"
10
13
  end
11
14
  it "should verify a number" do
12
- subject.verify(160864, @now).should be_true
15
+ subject.verify(68212, @now).should be_true
13
16
  end
14
17
  it "should verify a string" do
15
- subject.verify("160864", @now).should be_true
18
+ subject.verify("68212", @now).should be_true
16
19
  end
17
20
 
18
21
  context "with drift" do
19
22
  it "should verify a number" do
20
- subject.verify_with_drift(160864, 0, @now).should be_true
23
+ subject.verify_with_drift(68212, 0, @now).should be_true
21
24
  end
22
25
  it "should verify a string" do
23
- subject.verify_with_drift("160864", 0, @now).should be_true
26
+ subject.verify_with_drift("68212", 0, @now).should be_true
24
27
  end
25
28
  it "should verify a slightly old number" do
26
29
  subject.verify_with_drift(subject.at(@now - 30), 60, @now).should be_true
metadata CHANGED
@@ -1,78 +1,64 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: rotp
3
- version: !ruby/object:Gem::Version
4
- hash: 3
5
- prerelease:
6
- segments:
7
- - 1
8
- - 4
9
- - 2
10
- version: 1.4.2
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.4.3
11
5
  platform: ruby
12
- authors:
6
+ authors:
13
7
  - Mark Percival
14
8
  autorequire:
15
9
  bindir: bin
16
10
  cert_chain: []
17
-
18
- date: 2013-09-04 00:00:00 +00:00
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
11
+ date: 2013-09-04 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
22
14
  name: rake
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- hash: 3
30
- segments:
31
- - 0
32
- version: "0"
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
33
20
  type: :development
34
- version_requirements: *id001
35
- - !ruby/object:Gem::Dependency
36
- name: rspec
37
21
  prerelease: false
38
- requirement: &id002 !ruby/object:Gem::Requirement
39
- none: false
40
- requirements:
41
- - - ">="
42
- - !ruby/object:Gem::Version
43
- hash: 3
44
- segments:
45
- - 0
46
- version: "0"
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
47
34
  type: :development
48
- version_requirements: *id002
49
- - !ruby/object:Gem::Dependency
50
- name: timecop
51
35
  prerelease: false
52
- requirement: &id003 !ruby/object:Gem::Requirement
53
- none: false
54
- requirements:
55
- - - ~>
56
- - !ruby/object:Gem::Version
57
- hash: 71
58
- segments:
59
- - 0
60
- - 5
61
- - 9
62
- - 2
63
- version: 0.5.9.2
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: timecop
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
64
48
  type: :development
65
- version_requirements: *id003
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
66
55
  description: Works for both HOTP and TOTP, and includes QR Code provisioning
67
- email:
56
+ email:
68
57
  - mark@markpercival.us
69
58
  executables: []
70
-
71
59
  extensions: []
72
-
73
60
  extra_rdoc_files: []
74
-
75
- files:
61
+ files:
76
62
  - .gitignore
77
63
  - .rspec
78
64
  - .travis.yml
@@ -109,39 +95,28 @@ files:
109
95
  - spec/hotp_spec.rb
110
96
  - spec/spec_helper.rb
111
97
  - spec/totp_spec.rb
112
- has_rdoc: true
113
98
  homepage: http://github.com/mdp/rotp
114
- licenses:
99
+ licenses:
115
100
  - MIT
101
+ metadata: {}
116
102
  post_install_message:
117
103
  rdoc_options: []
118
-
119
- require_paths:
104
+ require_paths:
120
105
  - lib
121
- required_ruby_version: !ruby/object:Gem::Requirement
122
- none: false
123
- requirements:
124
- - - ">="
125
- - !ruby/object:Gem::Version
126
- hash: 3
127
- segments:
128
- - 0
129
- version: "0"
130
- required_rubygems_version: !ruby/object:Gem::Requirement
131
- none: false
132
- requirements:
133
- - - ">="
134
- - !ruby/object:Gem::Version
135
- hash: 3
136
- segments:
137
- - 0
138
- version: "0"
106
+ required_ruby_version: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ required_rubygems_version: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - '>='
114
+ - !ruby/object:Gem::Version
115
+ version: '0'
139
116
  requirements: []
140
-
141
117
  rubyforge_project: rotp
142
- rubygems_version: 1.6.2
118
+ rubygems_version: 2.0.2
143
119
  signing_key:
144
- specification_version: 3
120
+ specification_version: 4
145
121
  summary: A Ruby library for generating and verifying one time passwords
146
122
  test_files: []
147
-