rotp 1.4.4 → 1.4.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f8ce74f1100ad298f8af11595abb6af79b90de7f
4
- data.tar.gz: 9777ea4074be03cad417c708c7b4caeb955b91ae
3
+ metadata.gz: 53b1578ba5f12cd83cf8e616619b34d9f0135677
4
+ data.tar.gz: 2102035657efa48f1b85c621db30d68563a77b87
5
5
  SHA512:
6
- metadata.gz: 8fd962693e60b864efd2f3d5d0dde1526abfb42c1b617052d0e36328ef2bdc791a6c9c14906069f9f8f10f201fb2281b9b9d69d4b3e0cdd77c3c2e500869cc0d
7
- data.tar.gz: 48728cbfb67d418e9e1d2b21370c28a4eb9a94bc0c18bedf34d7b7dea320468274d07879f89bb33dba65e292a77069afa28dcd7774422cb5a1694c8919d29130
6
+ metadata.gz: 05a24b43f5622b2464cc174ba23cea19efe112ad838a8c9c9bdd05d31c6ac3e8e235b6ef550e38dd239569a25622e278887617eb39ecb83ebaa803848cf41108
7
+ data.tar.gz: c26363a86a528d49d672aed06ebc9c8852eb27aa53d93c5c4dc50c75a5a8e823b93c373ddc34845972734a86a4bad594ef342da6b354f56cdd1cafa572dca48a
@@ -1,5 +1,5 @@
1
1
  # ROTP - The Ruby One Time Password Library
2
- ![Travis](https://secure.travis-ci.org/mdp/rturk.png)
2
+ [![Build Status](https://secure.travis-ci.org/mdp/rotp.png)](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
@@ -1,8 +1,8 @@
1
- require 'rotp/base32'
2
1
  require 'rotp/otp'
3
2
  require 'rotp/hotp'
4
3
  require 'rotp/totp'
5
4
  require 'uri'
5
+ require 'base32'
6
6
  require 'openssl'
7
7
 
8
8
  module ROTP
@@ -46,7 +46,7 @@ module ROTP
46
46
  end
47
47
 
48
48
  def byte_secret
49
- Base32.decode(@secret)
49
+ Base32.decode(@secret.upcase)
50
50
  end
51
51
 
52
52
  # Turns an integer to the OATH specified
@@ -1,3 +1,3 @@
1
1
  module ROTP
2
- VERSION = "1.4.4"
2
+ VERSION = "1.4.5"
3
3
  end
@@ -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"
@@ -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
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-09-09 00:00:00.000000000 Z
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
@@ -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