rotp 3.3.0 → 3.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +1 -1
- data/CHANGELOG.md +5 -0
- data/README.md +6 -6
- data/lib/rotp.rb +1 -0
- data/lib/rotp/base32.rb +1 -0
- data/lib/rotp/otp.rb +4 -0
- data/lib/rotp/totp.rb +1 -0
- data/lib/rotp/version.rb +1 -1
- data/spec/lib/rotp/base32_spec.rb +6 -0
- data/spec/lib/rotp/totp_spec.rb +15 -0
- metadata +2 -3
- data/Gemfile.lock +0 -41
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6597229fd1ace9419ec1212d4cdedaa8392d5e2c
|
4
|
+
data.tar.gz: 7784edcd67e532d6e1c14e229c79e2b1c6c5bb6e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cc83e697d928afc3be726fa0a7569f87bb5d69362ae429af512e35bc5f15d6cce947c510ab6204b6cac99601a3870600577360750f3e9af35762e316ce45080b
|
7
|
+
data.tar.gz: 5cdefb29436b550ecd825baa13cc2365c994705f575b474d9a8d02ecad1764ce9982bc04537ea95afbfe24b304c1a1a71e339f4223f496138f7eaeaa76261050
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# The Ruby One Time Password Library
|
2
2
|
|
3
|
-
[![Build Status](https://
|
3
|
+
[![Build Status](https://travis-ci.org/mdp/rotp.svg?branch=master)](https://travis-ci.org/mdp/rotp)
|
4
4
|
[![Gem Version](https://badge.fury.io/rb/rotp.svg)](https://rubygems.org/gems/rotp)
|
5
5
|
[![License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat)](https://github.com/mdp/rotp/blob/master/LICENSE)
|
6
6
|
|
@@ -46,13 +46,13 @@ totp.provisioning_uri("alice@google.com")
|
|
46
46
|
|
47
47
|
```ruby
|
48
48
|
hotp = ROTP::HOTP.new("base32secretkey3232")
|
49
|
-
hotp.at(0) # => "
|
50
|
-
hotp.at(1) # => "
|
51
|
-
hotp.at(1401) # => "
|
49
|
+
hotp.at(0) # => "786922"
|
50
|
+
hotp.at(1) # => "595254"
|
51
|
+
hotp.at(1401) # => "259769"
|
52
52
|
|
53
53
|
# OTP verified with a counter
|
54
|
-
hotp.verify("
|
55
|
-
hotp.verify("
|
54
|
+
hotp.verify("259769", 1401) # => true
|
55
|
+
hotp.verify("259769", 1402) # => false
|
56
56
|
```
|
57
57
|
|
58
58
|
### Verifying a Time based OTP with drift
|
data/lib/rotp.rb
CHANGED
data/lib/rotp/base32.rb
CHANGED
data/lib/rotp/otp.rb
CHANGED
data/lib/rotp/totp.rb
CHANGED
data/lib/rotp/version.rb
CHANGED
@@ -44,6 +44,12 @@ RSpec.describe ROTP::Base32 do
|
|
44
44
|
expect(ROTP::Base32.decode('234BCDEFG').unpack('H*').first).to eq 'd6f8110c8530'
|
45
45
|
expect(ROTP::Base32.decode('234BCDEFG234BCDEFG').unpack('H*').first).to eq 'd6f8110c8536b7c0886429'
|
46
46
|
end
|
47
|
+
|
48
|
+
context 'with padding' do
|
49
|
+
it 'correctly decodes a string' do
|
50
|
+
expect(ROTP::Base32.decode('F==').unpack('H*').first).to eq '28'
|
51
|
+
end
|
52
|
+
end
|
47
53
|
end
|
48
54
|
end
|
49
55
|
end
|
data/spec/lib/rotp/totp_spec.rb
CHANGED
@@ -161,6 +161,21 @@ RSpec.describe ROTP::TOTP do
|
|
161
161
|
|
162
162
|
end
|
163
163
|
|
164
|
+
describe 'invalid_verification with nil time as argument' do
|
165
|
+
let(:verification) { totp.verify_with_drift token, drift, nil }
|
166
|
+
|
167
|
+
context 'positive drift' do
|
168
|
+
let(:token) { totp.at now - 30 }
|
169
|
+
let(:drift) { 60 }
|
170
|
+
|
171
|
+
it 'raises error' do
|
172
|
+
expect do
|
173
|
+
verification
|
174
|
+
end.to raise_error(ArgumentError)
|
175
|
+
end
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
164
179
|
describe '#verify_with_drift' do
|
165
180
|
let(:verification) { totp.verify_with_drift token, drift, now }
|
166
181
|
let(:drift) { 0 }
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rotp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.3.
|
4
|
+
version: 3.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark Percival
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-03-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -82,7 +82,6 @@ files:
|
|
82
82
|
- Dockerfile-2.1
|
83
83
|
- Dockerfile-2.3
|
84
84
|
- Gemfile
|
85
|
-
- Gemfile.lock
|
86
85
|
- Guardfile
|
87
86
|
- LICENSE
|
88
87
|
- README.md
|
data/Gemfile.lock
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
rotp (3.2.0)
|
5
|
-
|
6
|
-
GEM
|
7
|
-
remote: http://rubygems.org/
|
8
|
-
specs:
|
9
|
-
diff-lcs (1.2.5)
|
10
|
-
docile (1.1.5)
|
11
|
-
json (1.8.3)
|
12
|
-
rake (10.5.0)
|
13
|
-
rspec (3.5.0)
|
14
|
-
rspec-core (~> 3.5.0)
|
15
|
-
rspec-expectations (~> 3.5.0)
|
16
|
-
rspec-mocks (~> 3.5.0)
|
17
|
-
rspec-core (3.5.2)
|
18
|
-
rspec-support (~> 3.5.0)
|
19
|
-
rspec-expectations (3.5.0)
|
20
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
21
|
-
rspec-support (~> 3.5.0)
|
22
|
-
rspec-mocks (3.5.0)
|
23
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
24
|
-
rspec-support (~> 3.5.0)
|
25
|
-
rspec-support (3.5.0)
|
26
|
-
simplecov (0.12.0)
|
27
|
-
docile (~> 1.1.0)
|
28
|
-
json (>= 1.8, < 3)
|
29
|
-
simplecov-html (~> 0.10.0)
|
30
|
-
simplecov-html (0.10.0)
|
31
|
-
timecop (0.8.1)
|
32
|
-
|
33
|
-
PLATFORMS
|
34
|
-
ruby
|
35
|
-
|
36
|
-
DEPENDENCIES
|
37
|
-
rake (~> 10.5)
|
38
|
-
rotp!
|
39
|
-
rspec (~> 3.5)
|
40
|
-
simplecov (~> 0.12)
|
41
|
-
timecop (~> 0.8)
|