Esempio n. 1
0
        public bool VerifySignature()
        {
            if (MerchantCertificate == null || PKIType == Payment.PKIType.None)
            {
                return(false);
            }
            var data = GetSignedData();

            byte[] hash     = null;
            string hashName = null;

            if (PKIType == Payment.PKIType.X509SHA256)
            {
                hash     = Hashes.SHA256(data);
                hashName = "sha256";
            }
            else if (PKIType == Payment.PKIType.X509SHA1)
            {
                hash     = Hashes.SHA1(data, 0, data.Length);
                hashName = "sha1";
            }
            else
            {
                throw new NotSupportedException(PKIType.ToString());
            }

            return(GetCertificateProvider().GetSignatureChecker().VerifySignature(MerchantCertificate, hash, hashName, Signature));
        }
Esempio n. 2
0
        private string ToPKITypeString(PKIType pkitype)
        {
            switch (pkitype)
            {
            case Payment.PKIType.None:
                return("none");

            case Payment.PKIType.X509SHA1:
                return("x509+sha1");

            case Payment.PKIType.X509SHA256:
                return("x509+sha256");

            default:
                throw new NotSupportedException(pkitype.ToString());
            }
        }
Esempio n. 3
0
        public bool VerifySignature()
        {
            if (MerchantCertificate == null || PKIType == Payment.PKIType.None)
            {
                return(false);
            }

            var key = (RSACryptoServiceProvider)MerchantCertificate.PublicKey.Key;
            var sig = Signature;

            Signature = new byte[0];
            byte[] data = null;
            try
            {
                data = this.ToBytes();
            }
            finally
            {
                Signature = sig;
            }

            byte[] hash     = null;
            string hashName = null;

            if (PKIType == Payment.PKIType.X509SHA256)
            {
                hash     = Hashes.SHA256(data);
                hashName = "sha256";
            }
            else if (PKIType == Payment.PKIType.X509SHA1)
            {
                hash     = Hashes.SHA1(data, data.Length);
                hashName = "sha1";
            }
            else
            {
                throw new NotSupportedException(PKIType.ToString());
            }

            return(key.VerifyHash(hash, hashName, Signature));
        }