Пример #1
0
        public void TestSignAndVerify(String subDir, string nestDir)
        {
            var subPath = Util.TestDataPath(TEST_DATA, subDir, nestDir);

            using (var signer = new AttachedSigner(subPath))
                using (var verifier = new AttachedVerifier(subPath))
                {
                    var signedoutput = signer.Sign(input);

                    Expect(signer.Verify(signedoutput), Is.True);
                    Expect(verifier.Verify(signedoutput), Is.True);
                }
        }
Пример #2
0
        public void TestSignAndVerifyBad(String subDir, string nestDir)
        {
            var subPath = Util.TestDataPath(TEST_DATA, subDir, nestDir);

            using (var signer = new AttachedSigner(subPath))
                using (var verifier = new AttachedVerifier(subPath))
                {
                    var signedoutput = signer.Sign(input);
                    var badoutput    = signedoutput.ToBytes();
                    badoutput[10] ^= 9;

                    Expect(signer.Verify(badoutput), Is.False);
                    Expect(verifier.Verify(badoutput), Is.False);
                }
        }
Пример #3
0
        public void TestSignAndVerifyShort(String subDir, string nestDir)
        {
            var subPath = Util.TestDataPath(TEST_DATA, subDir, nestDir);

            using (var signer = new AttachedSigner(subPath))
                using (var verifier = new AttachedVerifier(subPath))
                {
                    var signedoutput = signer.Sign(input);
                    var badoutput    = signedoutput.ToBytes();
                    badoutput[10] ^= 9;
                    var badlength = new byte[12];
                    Array.Copy(badoutput, badlength, badlength.Length);

                    Expect(() => signer.Verify(badlength), Throws.InstanceOf <InvalidCryptoDataException>());
                    Expect(() => verifier.Verify(badlength), Throws.InstanceOf <InvalidCryptoDataException>());
                }
        }
Пример #4
0
        public void TestSignAndVerifyShort(String subDir, string nestDir)
        {
            var subPath = Util.TestDataPath(TEST_DATA, subDir, nestDir);
            using (var signer = new AttachedSigner(subPath))
            using (var verifier = new AttachedVerifier(subPath))
            {
                var signedoutput = signer.Sign(input);
                var badoutput = signedoutput.ToBytes();
                badoutput[10] ^= 9;
                var badlength = new byte[12];
                Array.Copy(badoutput, badlength, badlength.Length);

                Expect(() => signer.Verify(badlength), Throws.InstanceOf<InvalidCryptoDataException>());
                Expect(() => verifier.Verify(badlength), Throws.InstanceOf<InvalidCryptoDataException>());
            }
        }
Пример #5
0
        public void TestSignAndVerifyBad(String subDir, string nestDir)
        {
            var subPath = Util.TestDataPath(TEST_DATA, subDir, nestDir);
            using (var signer = new AttachedSigner(subPath))
            using (var verifier = new AttachedVerifier(subPath))
            {
                var signedoutput = signer.Sign(input);
                var badoutput = signedoutput.ToBytes();
                badoutput[10] ^= 9;

                Expect(signer.Verify(badoutput), Is.False);
                Expect(verifier.Verify(badoutput), Is.False);
            }
        }
Пример #6
0
        public void TestSignAndVerify(String subDir, string nestDir)
        {
            var subPath = Util.TestDataPath(TEST_DATA, subDir, nestDir);
            using (var signer = new AttachedSigner(subPath))
            using (var verifier = new AttachedVerifier(subPath))
            {
                var signedoutput = signer.Sign(input);

                Expect(signer.Verify(signedoutput), Is.True);
                Expect(verifier.Verify(signedoutput), Is.True);
            }
        }