示例#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 VerifyFromTma(Stream output)
        {
            IDataVerifier verifier;

            if (!level.HasValue || level.Value == Level.B_Level || !useTmaInsteadOfTsa)
            {
                verifier = DataVerifierFactory.Create(level);
            }
            else
            {
                verifier = DataVerifierFactory.CreateFromTimemarkAuthority(level.Value, new CurrentTimemarkProvider());
            }

            SignatureSecurityInformation result = verifier.Verify(output);

            Console.WriteLine(result.ToString());


            Assert.AreEqual(validationStatus, result.ValidationStatus);
            Assert.AreEqual(trustStatus, result.TrustStatus);
            Assert.AreEqual(subject, result.Signer.Subject);
            Assert.IsNull(result.TimestampRenewalTime);
            Assert.IsNotNull(result.SignatureValue);
            Assert.IsTrue((DateTime.UtcNow - result.SigningTime) < new TimeSpan(0, 1, 0));
            Assert.IsFalse(result.IsNonRepudiatable); //outer is never repudiatable
        }
示例#3
0
        //todo make it green
        private void Verify(Stream output)
        {
            IDataVerifier verifier = DataVerifierFactory.Create(level);

            SignatureSecurityInformation result = verifier.Verify(output);

            Console.WriteLine(result.ToString());

            Assert.AreEqual(validationStatus, result.ValidationStatus);
            Assert.AreEqual(trustStatus, result.TrustStatus);
            Assert.IsNull(result.Signer);
            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));
            Assert.IsFalse(result.IsNonRepudiatable); //outer is never repudiatable
        }
示例#4
0
        private void VerifyAsTma(Stream output)
        {
            TimemarkKey      key;
            ITmaDataVerifier verifier = 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
        }