public static void AddDeviceRegistration(string deviceName, FidoDeviceRegistration deviceRegistration) { CurrentUser.Devices.Add(new Device { Name = deviceName, Identifier = deviceRegistration.KeyHandle.ToString(), Usage = 0, Data = deviceRegistration.ToJson() }); }
public void ToJson() { var keyHandle = new FidoKeyHandle(Encoding.Default.GetBytes("keyhandle")); var publicKey = new FidoPublicKey(Encoding.Default.GetBytes("publickey")); var certificate = new FidoAttestationCertificate(Encoding.Default.GetBytes("certificate")); var deviceRegistration = new FidoDeviceRegistration(keyHandle, publicKey, certificate, 12345); var serialized = deviceRegistration.ToJson(); var jsonObject = JObject.Parse(serialized); var properties = jsonObject.Properties().ToLookup(x => x.Name.ToLowerInvariant(), x => x.Value.ToString()); Assert.AreEqual("Y2VydGlmaWNhdGU", properties["certificate"].Single()); Assert.AreEqual("12345", properties["counter"].Single()); Assert.AreEqual("a2V5aGFuZGxl", properties["keyhandle"].Single()); Assert.AreEqual("cHVibGlja2V5", properties["publickey"].Single()); }
public void ToJson() { var keyHandle = new FidoKeyHandle(Encoding.Default.GetBytes("keyhandle")); var publicKey = new FidoPublicKey(Encoding.Default.GetBytes("publickey")); var certificate = new FidoAttestationCertificate(Encoding.Default.GetBytes("certificate")); var deviceRegistration = new FidoDeviceRegistration(keyHandle, publicKey, certificate, 12345); var serialized = deviceRegistration.ToJson(); var jsonObject = JObject.Parse(serialized); var properties = jsonObject.Properties().ToLookup(x => x.Name.ToLowerInvariant(), x => x.Value.ToString()); Assert.AreEqual("Y2VydGlmaWNhdGU", properties["certificate"].Single()); Assert.AreEqual("12345", properties["counter"].Single()); Assert.AreEqual("a2V5aGFuZGxl", properties["keyhandle"].Single()); Assert.AreEqual("cHVibGlja2V5", properties["publickey"].Single()); }