Esempio n. 1
0
        public void SignHash_SignAndVerifyAHash_Pass()
        {
            byte[] dataToSign = Encoding.UTF8.GetBytes("wabdwadbwadbwadbw awdbwdbawd adbwdbw");
            byte[] hash;
            byte[] signedhash;
            bool verified = false;
            using(var x = new ECDsaCipher<ECDsaCng>())
            {
                hash = new SHA512Managed().ComputeHash(dataToSign);
                signedhash = x.SignHash(hash);
                verified = x.VerifyHash(hash, signedhash);
            }

            Assert.IsTrue(verified);
        }
Esempio n. 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);
        }