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.TotpSeed = parsedQuery.Get("secret");
|
||||||
res.Length = parsedQuery.Get("digits");
|
res.Length = parsedQuery.Get("digits");
|
||||||
res.Duration = parsedQuery.Get("period");
|
res.Duration = parsedQuery.Get("period");
|
||||||
|
res.Encoder = parsedQuery.Get("encoder");
|
||||||
|
|
||||||
|
|
||||||
//set defaults according to https://github.com/google/google-authenticator/wiki/Key-Uri-Format
|
//set defaults according to https://github.com/google/google-authenticator/wiki/Key-Uri-Format
|
||||||
if (res.Length == null)
|
if (res.Length == null)
|
||||||
res.Length = "6";
|
res.Length = "6";
|
||||||
if (res.Duration == null)
|
if (res.Duration == null)
|
||||||
res.Duration = "30";
|
res.Duration = "30";
|
||||||
|
if (res.Encoder == null)
|
||||||
|
res.Encoder = TotpData.EncoderRfc6238;
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,18 +3,22 @@ using System.Collections.Generic;
|
|||||||
namespace PluginTOTP
|
namespace PluginTOTP
|
||||||
{
|
{
|
||||||
struct TotpData
|
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 TotpSeed { get; set; }
|
||||||
public string Duration { 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 Url { get; set; }
|
||||||
|
|
||||||
public string[] Settings
|
public string[] Settings
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
List<string> settings = new List<string>() { Duration, Length};
|
List<string> settings = new List<string>() { Duration, Encoder == EncoderSteam ? "S" : Length};
|
||||||
if (Url != null)
|
if (Url != null)
|
||||||
settings.Add(Url);
|
settings.Add(Url);
|
||||||
return settings.ToArray();
|
return settings.ToArray();
|
||||||
|
|||||||
Reference in New Issue
Block a user