-
-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathKnownFacets.cs
44 lines (37 loc) · 1.72 KB
/
KnownFacets.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
namespace APDU
{
public class KnownFacets
{
private static readonly Dictionary<byte[], string> KnownFacetsMap = new Dictionary<byte[], string>
{
{ GetDigest("https://github.com/u2f/trusted_facets"), "https://github.com" },
{ GetDigest("https://demo.yubico.com"), "https://demo.yubico.com" },
{ GetDigest("https://www.dropbox.com/u2f-app-id.json"), "https://dropbox.com" },
{ GetDigest("https://www.gstatic.com/securitykey/origins.json"), "https://google.com" },
{ GetDigest("https://vault.bitwarden.com/app-id.json"), "https://vault.bitwarden.com" },
{ GetDigest("https://keepersecurity.com"), "https://keepersecurity.com" },
{ GetDigest("https://api-fdf6878a.duosecurity.com"), "https://api-fdf6878a.duosecurity.com" },
{ GetDigest("https://dashboard.stripe.com"), "https://dashboard.stripe.com" },
{ GetDigest("https://id.fedoraproject.org/u2f-origins.json"), "https://id.fedoraproject.org" },
{ GetDigest("https://lastpass.com"), "https://lastpass.com" },
{ Encoding.ASCII.GetBytes("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"), "bogus" }
};
public static string GetKnownFacet(byte[] key)
{
return KnownFacetsMap.TryGetValue(key, out var facet) ? facet : string.Empty;
}
private static byte[] GetDigest(string s)
{
using (var sha256Hasher = SHA256.Create())
{
return sha256Hasher.ComputeHash(Encoding.UTF8.GetBytes(s));
}
}
}
}