rotp 1.4.4 → 1.4.5
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.
- checksums.yaml +4 -4
- data/README.markdown +5 -1
- data/lib/rotp.rb +1 -1
- data/lib/rotp/otp.rb +1 -1
- data/lib/rotp/version.rb +1 -1
- data/rotp.gemspec +1 -0
- data/spec/base_spec.rb +0 -11
- metadata +16 -3
- data/lib/rotp/base32.rb +0 -47
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 53b1578ba5f12cd83cf8e616619b34d9f0135677
|
4
|
+
data.tar.gz: 2102035657efa48f1b85c621db30d68563a77b87
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 05a24b43f5622b2464cc174ba23cea19efe112ad838a8c9c9bdd05d31c6ac3e8e235b6ef550e38dd239569a25622e278887617eb39ecb83ebaa803848cf41108
|
7
|
+
data.tar.gz: c26363a86a528d49d672aed06ebc9c8852eb27aa53d93c5c4dc50c75a5a8e823b93c373ddc34845972734a86a4bad594ef342da6b354f56cdd1cafa572dca48a
|
data/README.markdown
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# ROTP - The Ruby One Time Password Library
|
2
|
-
](http://travis-ci.org/mdp/rotp)
|
3
3
|
|
4
4
|
A ruby library for generating one time passwords according to [ RFC 4226 ](http://tools.ietf.org/html/rfc4226) and the [ HOTP RFC ](http://tools.ietf.org/html/draft-mraihi-totp-timebased-00)
|
5
5
|
|
@@ -92,6 +92,10 @@ Now run the following and compare the output
|
|
92
92
|
|
93
93
|
### Changelog
|
94
94
|
|
95
|
+
#### 1.4.5
|
96
|
+
|
97
|
+
- Fix and test correct implementation of Base32
|
98
|
+
|
95
99
|
#### 1.4.4
|
96
100
|
|
97
101
|
- Fix issue with base32 decoding of strings in a length that's not a multiple of 8
|
data/lib/rotp.rb
CHANGED
data/lib/rotp/otp.rb
CHANGED
data/lib/rotp/version.rb
CHANGED
data/rotp.gemspec
CHANGED
@@ -20,6 +20,7 @@ Gem::Specification.new do |s|
|
|
20
20
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
21
21
|
s.require_paths = ["lib"]
|
22
22
|
|
23
|
+
s.add_dependency('base32', '~> 0.2.0')
|
23
24
|
s.add_development_dependency('rake')
|
24
25
|
s.add_development_dependency('rspec')
|
25
26
|
if RUBY_VERSION < "1.9"
|
data/spec/base_spec.rb
CHANGED
@@ -1,15 +1,5 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/spec_helper'
|
2
2
|
|
3
|
-
describe "generating a random base32 secret" do
|
4
|
-
it "should be 16 characters by default" do
|
5
|
-
ROTP::Base32.random_base32.length.should == 16
|
6
|
-
ROTP::Base32.random_base32.should match /\A[a-z2-7]+\z/
|
7
|
-
end
|
8
|
-
it "should be allow a specific length" do
|
9
|
-
ROTP::Base32.random_base32(32).length.should == 32
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
3
|
describe "HOTP example values from the rfc" do
|
14
4
|
it "should match the RFC" do
|
15
5
|
# 12345678901234567890 in Bas32
|
@@ -67,7 +57,6 @@ describe "TOTP example values from the rfc" do
|
|
67
57
|
end
|
68
58
|
end
|
69
59
|
|
70
|
-
|
71
60
|
it "should output its provisioning URI" do
|
72
61
|
totp = ROTP::TOTP.new("wrn3pqx5uqxqvnqr")
|
73
62
|
totp.provisioning_uri('mark@percival').should == "otpauth://totp/mark@percival?secret=wrn3pqx5uqxqvnqr"
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rotp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark Percival
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-11-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: base32
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.2.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.2.0
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: rake
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -85,7 +99,6 @@ files:
|
|
85
99
|
- doc/method_list.html
|
86
100
|
- doc/top-level-namespace.html
|
87
101
|
- lib/rotp.rb
|
88
|
-
- lib/rotp/base32.rb
|
89
102
|
- lib/rotp/hotp.rb
|
90
103
|
- lib/rotp/otp.rb
|
91
104
|
- lib/rotp/totp.rb
|
data/lib/rotp/base32.rb
DELETED
@@ -1,47 +0,0 @@
|
|
1
|
-
module ROTP
|
2
|
-
class Base32
|
3
|
-
CHARS = "abcdefghijklmnopqrstuvwxyz234567".each_char.to_a
|
4
|
-
|
5
|
-
class << self
|
6
|
-
def decode(str)
|
7
|
-
output = []
|
8
|
-
str.scan(/.{1,8}/).each do |block|
|
9
|
-
char_array = decode_block(block).map{|c| c.chr}
|
10
|
-
output << char_array
|
11
|
-
end
|
12
|
-
output.join
|
13
|
-
end
|
14
|
-
|
15
|
-
def random_base32(length=16)
|
16
|
-
b32 = ''
|
17
|
-
OpenSSL::Random.random_bytes(length).each_byte do |b|
|
18
|
-
b32 << CHARS[b % 32]
|
19
|
-
end
|
20
|
-
b32
|
21
|
-
end
|
22
|
-
|
23
|
-
private
|
24
|
-
|
25
|
-
def decode_block(block)
|
26
|
-
length = block.scan(/[^=]/).length
|
27
|
-
quints = block.each_char.map {|c| decode_quint(c)}
|
28
|
-
bytes = []
|
29
|
-
bytes[0] = (quints[0] << 3) + (quints[1] >> 2)
|
30
|
-
return bytes if length < 3
|
31
|
-
bytes[1] = ((quints[1] & 3) << 6) + (quints[2] << 1) + (quints[3] >> 4)
|
32
|
-
return bytes if length < 5
|
33
|
-
bytes[2] = ((quints[3] & 15) << 4) + (quints[4] >> 1)
|
34
|
-
return bytes if length < 6
|
35
|
-
bytes[3] = ((quints[4] & 1) << 7) + (quints[5] << 2) + (quints[6] >> 3)
|
36
|
-
bytes[4] = ((quints[6] & 7) << 5) + quints[7]
|
37
|
-
bytes
|
38
|
-
end
|
39
|
-
|
40
|
-
def decode_quint(q)
|
41
|
-
CHARS.index(q.downcase)
|
42
|
-
end
|
43
|
-
|
44
|
-
end
|
45
|
-
|
46
|
-
end
|
47
|
-
end
|