private void VerifyResponseSignature(FidoAppId appId, FidoRegistrationData registrationData, FidoClientData clientData) { if (appId == null) { throw new ArgumentNullException("appId"); } if (registrationData == null) { throw new ArgumentNullException("registrationData"); } if (clientData == null) { throw new ArgumentNullException("clientData"); } if (String.IsNullOrEmpty(clientData.RawJsonValue)) { throw new InvalidOperationException("Client data has no JSON representation"); } var signedBytes = PackBytes( new byte[] { 0 }, Helpers.Sha256(appId.ToString()), Helpers.Sha256(clientData.RawJsonValue), registrationData.KeyHandle.ToByteArray(), registrationData.UserPublicKey.ToByteArray()); VerifySignature(registrationData.AttestationCertificate, registrationData.Signature, signedBytes); }
public void FromWebSafeBase64() { var registrationData = FidoRegistrationData.FromWebSafeBase64(TestVectors.RegistrationResponseDataBase64); Assert.IsNotNull(registrationData.AttestationCertificate); Assert.IsNotNullOrEmpty(registrationData.KeyHandle.ToString()); Assert.IsNotNullOrEmpty(registrationData.Signature.ToString()); Assert.IsNotNullOrEmpty(registrationData.UserPublicKey.ToString()); }
private static FidoRegisterResponse GetValidRegisterResponse() { var registerResponse = new FidoRegisterResponse { RegistrationData = FidoRegistrationData.FromWebSafeBase64(TestVectors.RegistrationResponseDataBase64), ClientData = FidoClientData.FromJson(TestVectors.ClientDataRegister) }; return(registerResponse); }
internal static FidoRegisterResponse CreateGoodRegisterResponse() { return(new FidoRegisterResponse { RegistrationData = FidoRegistrationData.FromWebSafeBase64(TestVectors.RegistrationResponseDataBase64), ClientData = new FidoClientData { Challenge = TestVectors.ServerChallengeRegisterBase64, Origin = "http://localhost", Type = "type" } }); }
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { var jsonObject = JObject.Load(reader); var properties = jsonObject.Properties().ToLookup(x => x.Name.ToLowerInvariant()); var serializedRegistrationData = properties["registrationdata"].Single().Value.ToString(); var serializedClientData = properties["clientdata"].Single().Value.ToString(); return(new FidoRegisterResponse { RegistrationData = FidoRegistrationData.FromWebSafeBase64(serializedRegistrationData), ClientData = FidoClientData.FromWebSafeBase64(serializedClientData) }); }
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { return(FidoRegistrationData.FromWebSafeBase64(reader.Value.ToString())); }
private FidoRegistrationData CreateGoodRegistrationData() { return(FidoRegistrationData.FromWebSafeBase64(TestVectors.RegistrationResponseDataBase64)); }