diff --git a/src/keepass2android/Totp/KeeWebOtpPluginAdapter.cs b/src/keepass2android/Totp/KeeWebOtpPluginAdapter.cs index 45265131..4ad360ac 100644 --- a/src/keepass2android/Totp/KeeWebOtpPluginAdapter.cs +++ b/src/keepass2android/Totp/KeeWebOtpPluginAdapter.cs @@ -30,13 +30,18 @@ namespace keepass2android res.TotpSeed = parsedQuery.Get("secret"); res.Length = parsedQuery.Get("digits"); res.Duration = parsedQuery.Get("period"); + res.Encoder = parsedQuery.Get("encoder"); + + //set defaults according to https://github.com/google/google-authenticator/wiki/Key-Uri-Format if (res.Length == null) res.Length = "6"; if (res.Duration == null) res.Duration = "30"; + if (res.Encoder == null) + res.Encoder = TotpData.EncoderRfc6238; } - catch (Exception) + catch (Exception e) { return res; } diff --git a/src/keepass2android/Totp/TotpData.cs b/src/keepass2android/Totp/TotpData.cs index 84b34296..be0ab504 100644 --- a/src/keepass2android/Totp/TotpData.cs +++ b/src/keepass2android/Totp/TotpData.cs @@ -3,18 +3,22 @@ using System.Collections.Generic; namespace PluginTOTP { struct TotpData - { - public bool IsTotpEnry { get; set; } + { + public const string EncoderSteam = "steam"; + public const string EncoderRfc6238 = "rfc6238"; + + public bool IsTotpEnry { get; set; } public string TotpSeed { get; set; } public string Duration { get; set; } - public string Length { get; set; } + public string Encoder { get; set; } + public string Length { get; set; } public string Url { get; set; } public string[] Settings { get { - List settings = new List() { Duration, Length}; + List settings = new List() { Duration, Encoder == EncoderSteam ? "S" : Length}; if (Url != null) settings.Add(Url); return settings.ToArray();