Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to parse long totp secret #10

Closed
maximbaz opened this issue Apr 16, 2018 · 5 comments
Closed

Unable to parse long totp secret #10

maximbaz opened this issue Apr 16, 2018 · 5 comments

Comments

@maximbaz
Copy link

Creating a bug on behalf of @dustinwilson who will provide you with additional details if needed 😉

twofactor.FromURL("otpauth://totp/Hover:user?secret=a6mryljlbufszudtjdt42nh5by&issuer=Hover")

Returns the error error: illegal base32 data at input byte 24.

pass-otp and iOS pass reportedly support this URL just fine.

Reference: browserpass/browserpass-legacy#255

@kisom
Copy link
Member

kisom commented Apr 16, 2018

I think we'll have a fix here shortly, thanks to @qbit.

@gl-sergei
Copy link

I think 'a6mryljlbufszudtjdt42nh5by' is base32 encoded, it just missing padding. 'a6mryljlbufszudtjdt42nh5by======' should be decoded correctly.

@dustinwilson
Copy link

Hey thanks for this update. I've updated, and the OTPs I'm getting aren't valid. Here is a URI for Amazon:

otpauth://totp/Amazon%3Auser%40domain.tld?secret=UU3Y3AYRPU524DBAOFC5XWXCGI7R6YXWX5LEH7EGHAHEK3D6APNQ&issuer=Amazon

When using the secret with oathtool I get the correct otp:

oathtool -b --totp UU3Y3AYRPU524DBAOFC5XWXCGI7R6YXWX5LEH7EGHAHEK3D6APNQ

It looks like it is indeed base32 encoded as @gl-sergei said.

@qbit
Copy link
Collaborator

qbit commented Apr 17, 2018

looks like we will have to add a check for padding. I will come up with something shortly.

@gl-sergei
Copy link

Looks like this snippet does the thing:

package main

import (
    "fmt"
    "strings"
    "encoding/base32"
)

func main() {
    secret := strings.ToUpper("a6mryljlbufszudtjdt42nh5by")
    bytes, err := base32.StdEncoding.WithPadding(base32.NoPadding).DecodeString(secret)
    if err != nil {
        fmt.Println("error: ", err)
    } else {
        fmt.Println("bytes: ", bytes)
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants