示例#1
0
        private void Verify(Stream cryptMsg, Level?level)
        {
            IDataVerifier verifier = new DataVerifierFactory().Create(level);

            SignatureSecurityInformation result;

            if (useSenderWKey)
            {
                result = verifier.Verify(cryptMsg, senderWKey);
            }
            else
            {
                result = verifier.Verify(cryptMsg);
            }
            Console.WriteLine(result.ToString());

            Assert.AreEqual(validationStatus, result.ValidationStatus);
            Assert.AreEqual(trustStatus, result.TrustStatus);
            if (useSenderWKey)
            {
                Assert.IsNull(result.Signer);
                Assert.IsFalse(result.IsNonRepudiatable);
            }
            else
            {
                Assert.IsNotNull(result.Signer);
                Assert.IsTrue(result.IsNonRepudiatable);
            }
            Assert.IsNotNull(result.SignerId);
            Assert.AreEqual((level & Level.T_Level) == Level.T_Level, result.TimestampRenewalTime > DateTime.UtcNow);
            Assert.IsNotNull(result.SignatureValue);
            Assert.IsTrue((DateTime.UtcNow - result.SigningTime) < new TimeSpan(0, 1, 0));
        }
示例#2
0
        private void VerifyAsTma(Stream output)
        {
            TimemarkKey      key;
            ITmaDataVerifier verifier = new DataVerifierFactory().CreateAsTimemarkAuthority(level.Value);

            SignatureSecurityInformation result = verifier.Verify(output, DateTime.UtcNow, out key);

            Console.WriteLine(result.ToString());

            Assert.IsNotNull(key.SignatureValue);
            Assert.AreEqual(key.Signer.Thumbprint, result.Signer.Thumbprint);
            Assert.IsTrue((DateTime.UtcNow - key.SigningTime) < new TimeSpan(0, 1, 0));


            Assert.AreEqual(validationStatus, result.ValidationStatus);
            Assert.AreEqual(trustStatus, result.TrustStatus);
            Assert.AreEqual(subject, result.Signer.Subject);
            Assert.IsFalse(result.IsNonRepudiatable); //outer is never repudiatable
        }