You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Why doesn't the Base32 decode function handle padding?
This doesn't work:
2.2.0 :012 > totp = ROTP::TOTP.new Base32.encode("dntqoaxas7rvtfuf")
=> #<ROTP::TOTP:0x007fdd4d062458 @interval=30, @issuer=nil, @digits=6, @digest="sha1", @secret="MRXHI4LPMF4GC4ZXOJ3HIZTVMY======">
2.2.0 :013 > totp.now
ROTP::Base32::Base32Error: Invalid Base32 Character - '='
from /Users/bjohnson/.rvm/gems/ruby-2.2.0/gems/rotp-2.1.0/lib/rotp/base32.rb:43:in `decode_quint'
from /Users/bjohnson/.rvm/gems/ruby-2.2.0/gems/rotp-2.1.0/lib/rotp/base32.rb:28:in `block in decode_block'
from /Users/bjohnson/.rvm/gems/ruby-2.2.0/gems/rotp-2.1.0/lib/rotp/base32.rb:28:in `each_char'
from /Users/bjohnson/.rvm/gems/ruby-2.2.0/gems/rotp-2.1.0/lib/rotp/base32.rb:28:in `each'
from /Users/bjohnson/.rvm/gems/ruby-2.2.0/gems/rotp-2.1.0/lib/rotp/base32.rb:28:in `map'
from /Users/bjohnson/.rvm/gems/ruby-2.2.0/gems/rotp-2.1.0/lib/rotp/base32.rb:28:in `decode_block'
from /Users/bjohnson/.rvm/gems/ruby-2.2.0/gems/rotp-2.1.0/lib/rotp/base32.rb:10:in `block in decode'
from /Users/bjohnson/.rvm/gems/ruby-2.2.0/gems/rotp-2.1.0/lib/rotp/base32.rb:9:in `each'
from /Users/bjohnson/.rvm/gems/ruby-2.2.0/gems/rotp-2.1.0/lib/rotp/base32.rb:9:in `decode'
from /Users/bjohnson/.rvm/gems/ruby-2.2.0/gems/rotp-2.1.0/lib/rotp/otp.rb:52:in `byte_secret'
from /Users/bjohnson/.rvm/gems/ruby-2.2.0/gems/rotp-2.1.0/lib/rotp/otp.rb:26:in `generate_otp'
from /Users/bjohnson/.rvm/gems/ruby-2.2.0/gems/rotp-2.1.0/lib/rotp/totp.rb:29:in `now'
ROTP::TOTP.new("dntqoaxas7rvtfuf") would be the preferred instantiation in this case and would match the output of most OTP mobile apps sharing this secret.
Why doesn't the Base32 decode function handle padding?
This doesn't work:
But this works?
P.S.
Why is the Base32 decode hand rolled? Why not use the standard library?
Thanks!
The text was updated successfully, but these errors were encountered: