private void VerifyAuthSignature(FidoAppId appId, FidoSignatureData signatureData, FidoClientData clientData,
                                         FidoDeviceRegistration deviceRegistration)
        {
            if (appId == null)
            {
                throw new ArgumentNullException("appId");
            }
            if (signatureData == null)
            {
                throw new ArgumentNullException("signatureData");
            }
            if (clientData == null)
            {
                throw new ArgumentNullException("clientData");
            }
            if (deviceRegistration == null)
            {
                throw new ArgumentNullException("deviceRegistration");
            }

            if (String.IsNullOrEmpty(clientData.RawJsonValue))
            {
                throw new InvalidOperationException("Client data has no JSON representation");
            }

            var counterBytes = BitConverter.GetBytes(signatureData.Counter);

            if (BitConverter.IsLittleEndian)
            {
                Array.Reverse(counterBytes);
            }

            var signedBytes = PackBytes(
                Helpers.Sha256(appId.ToString()),
                new [] { signatureData.UserPresence },
                counterBytes,
                Helpers.Sha256(clientData.RawJsonValue));

            VerifySignature(deviceRegistration, signatureData.Signature, signedBytes);

            if (signatureData.UserPresence != UserPresentFlag)
            {
                throw new InvalidOperationException("User presence invalid during authentication");
            }
        }
 public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
 {
     return(FidoSignatureData.FromWebSafeBase64(reader.Value.ToString()));
 }
Exemple #3
0
 public FidoAuthenticateResponse(FidoClientData clientData, FidoSignatureData signatureData, FidoKeyHandle keyHandle)
 {
     ClientData    = clientData;
     SignatureData = signatureData;
     KeyHandle     = keyHandle;
 }