Example #1
0
        public void ComputeAndSignHash_ComputeAndSignHashAndComputeAndVerifyHash_Pass()
        {
            byte[] dataToSign = Encoding.UTF8.GetBytes("wabdwadbwadbwadbw awdbwdbawd adbwdbw");
            byte[] signedhash;
            bool verified = false;

            using (var x = new ECDsaCipher<ECDsaCng>())
            {
                signedhash = x.ComputeAndSignHash<SHA1Managed>(dataToSign);
                verified = x.ComputeAndVerifyHash<SHA1Managed>(dataToSign, signedhash);
            }

            Assert.IsTrue(verified);
        }
Example #2
0
        public void ComputeAndSignHash_SignHashAndComputeAndVerifyAHash_FalseDueToIncorrectHash()
        {
            byte[] dataToSign = Encoding.UTF8.GetBytes("wabdwadbwadbwadbw awdbwdbawd adbwdbw");
            byte[] hash;
            byte[] signedhash;
            bool verified = false;

            using (var x = new ECDsaCipher<ECDsaCng>())
            {
                hash = new SHA1Managed().ComputeHash(dataToSign);
                signedhash = x.SignHash(hash);
                verified = x.ComputeAndVerifyHash<SHA512Managed>(hash, signedhash);
            }

            Assert.IsFalse(verified);
        }