コード例 #1
0
ファイル: FidoRegistrationData.cs プロジェクト: monosign/u2f
 private FidoRegistrationData(FidoPublicKey userPublicKey, FidoKeyHandle keyHandle,
                              FidoAttestationCertificate attestationCertificate,
                              FidoSignature signature)
 {
     UserPublicKey          = userPublicKey;
     KeyHandle              = keyHandle;
     AttestationCertificate = attestationCertificate;
     Signature              = signature;
 }
コード例 #2
0
        private void VerifySignature(FidoDeviceRegistration deviceRegistration, FidoSignature signature,
                                     byte[] signedBytes)
        {
            try
            {
                var certPublicKey = deviceRegistration.PublicKey.PublicKey;
                var signer        = SignerUtilities.GetSigner("SHA-256withECDSA");
                signer.Init(false, certPublicKey);
                signer.BlockUpdate(signedBytes, 0, signedBytes.Length);

                if (signer.VerifySignature(signature.ToByteArray()))
                {
                    throw new InvalidOperationException("Invalid signature");
                }
            }
            catch
            {
                throw new InvalidOperationException("Invalid signature");
            }
        }
コード例 #3
0
        private void VerifySignature(FidoAttestationCertificate certificate, FidoSignature signature,
                                     byte[] signedBytes)
        {
            try
            {
                var certPublicKey = certificate.Certificate.GetPublicKey();
                var signer        = SignerUtilities.GetSigner("SHA-256withECDSA");
                signer.Init(false, certPublicKey);
                signer.BlockUpdate(signedBytes, 0, signedBytes.Length);

                if (signer.VerifySignature(signature.ToByteArray()))
                {
                    throw new InvalidOperationException("Invalid signature");
                }
            }
            catch (Exception)
            {
                throw new InvalidOperationException("Invalid signature");
            }
        }
コード例 #4
0
 public FidoSignatureData(byte userPresence, uint counter, FidoSignature signature)
 {
     UserPresence = userPresence;
     Counter      = counter;
     Signature    = signature;
 }
コード例 #5
0
 public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
 {
     return(FidoSignature.FromWebSafeBase64(reader.Value.ToString()));
 }