add compatibility with steam encoding for OTPs (e.g. otpauth://totp/test:test@example.com?secret=63BEDWCQZKTQWPESARIERL5DTTQFCJTK&issuer=Valve&algorithm=SHA1&digits=5&period=30&encoder=steam)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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<string> settings = new List<string>() { Duration, Length};
|
||||
List<string> settings = new List<string>() { Duration, Encoder == EncoderSteam ? "S" : Length};
|
||||
if (Url != null)
|
||||
settings.Add(Url);
|
||||
return settings.ToArray();
|
||||
|
||||
Reference in New Issue
Block a user