Skip to content

Commit 7705e8b

Browse files
committed
Remove any Base32 padding included in the secret string (fix #1).
1 parent fc27fa5 commit 7705e8b

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

oathtool_from_otpauth_uri

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,12 @@ if [ -z "$secret" ]; then
9898
exit 2
9999
fi
100100

101+
# Remove any padding from the end of the secret string
102+
# While no padding should be included with the secret, according to the
103+
# key uri spec, it doesn't hurt to remove it at this stage.
104+
# Source: https://github.com/google/google-authenticator/wiki/Key-Uri-Format#secret
105+
secret=$(echo "$secret" | sed 's/\(=\|%3D\)\+$//i')
106+
101107
# Algorithm, only for TOTP
102108
if [ "$otp_type" = "totp" ]; then
103109
totp_algorithm=$(uri_get_query_value "$otpauth_uri" algorithm)

0 commit comments

Comments
 (0)