BaseCipherSuitePlugin.SignatureAlgorithmDSA.VerifyData C# (CSharp) Method

VerifyData() public method

public VerifyData ( ProtocolVersion version, byte data, HashAlgorithm hashAlgorithm, CertificatePublicKey publicKey, byte signature ) : bool
version AaltoTLS.PluginInterface.ProtocolVersion
data byte
hashAlgorithm System.Security.Cryptography.HashAlgorithm
publicKey CertificatePublicKey
signature byte
return bool
        public override bool VerifyData(ProtocolVersion version, byte[] data, HashAlgorithm hashAlgorithm, CertificatePublicKey publicKey, byte[] signature)
        {
            if (hashAlgorithm != null && !(hashAlgorithm is SHA1)) {
                throw new Exception("DSA signature verification requires SHA1 hash algorithm");
            }
            if (!CertificateKeyAlgorithm.Equals(publicKey.Oid) || !(publicKey.Algorithm is DSACryptoServiceProvider)) {
                throw new Exception("DSA signature verification requires DSA public key");
            }

            return VerifyData(data, (DSACryptoServiceProvider)publicKey.Algorithm, signature);
        }

Same methods

SignatureAlgorithmDSA::VerifyData ( byte buffer, DSACryptoServiceProvider dsaKey, byte signature ) : bool

Usage Example

        public void VerifySignatureTest()
        {
            string dsaKeys =
                "<DSAKeyValue>" +
                "<P>6akTyOvXOB5LjK2ui9iMyyuDAXKLE0K5mo9OC1AxuU4sz1bfPZ194ENPjqXki10+iUiVR9ZzOnQZA1Mmh91m5Q==</P>" +
                "<Q>zaJn38GM1L9hEiB41SQDRqc/220=</Q>" +
                "<G>FI6/VxOXyIMMW6i4dVJyQ27mVbzdehiprmfRnwT8cYM9Eho3BfLmv2rbiuEw8U0tJk/HzmppUKFNeWUK9xIpVg==</G>" +
                "<Y>yvGw6d2AB7YNp8LD/DJoMeWCRPf9piyn4u3LFv9I+8z4CN0nnrgkId2Vrgak+/dSD2bVmI87Rz0fS5Cj5/ikOw==</Y>" +
                "<J>AAAAASLj8uTWjQIgIxqoGQkvru1/EZyvE31USOvTd+kfdGk9f8e0QJgYg9VkzG/0</J>" +
                "<Seed>k+hx8OAOva6npEadsVeDmIDjo18=</Seed>" +
                "<PgenCounter>GQ==</PgenCounter>" +
                "<X>uLFTlRX12CsAj7p+2fnTaEWhqhc=</X>" +
                "</DSAKeyValue>";
            byte[] signature = new byte[] {
                0x30, 0x2C, 0x02, 0x14, 0x33, 0x4A, 0x7F, 0x1F,
                0xDA, 0x4F, 0x64, 0x65, 0x29, 0xDF, 0x59, 0x29,
                0xF5, 0x80, 0xED, 0x40, 0x8D, 0xAE, 0x26, 0x80,
                0x02, 0x14, 0x88, 0x5D, 0xE4, 0x18, 0xA0, 0xBB,
                0x85, 0xBD, 0x8E, 0xDC, 0xB3, 0xFF, 0x62, 0xE7,
                0x41, 0x25, 0x6A, 0x03, 0x68, 0x4F
            };

            SignatureAlgorithmDSA dsa = new SignatureAlgorithmDSA();
            DSACryptoServiceProvider key = (DSACryptoServiceProvider)
                dsa.ImportPrivateKey(System.Text.Encoding.ASCII.GetBytes(dsaKeys)).Algorithm;
            Assert.IsTrue (dsa.VerifyData(new byte[32], key, signature));
        }
All Usage Examples Of BaseCipherSuitePlugin.SignatureAlgorithmDSA::VerifyData