Example #1
0
        public void can_sign_with_timestamp() {
            var timedsigner = new TimeStampSigner("testing");
            var signed = timedsigner.Sign("hello world");

            var unsigned = timedsigner.Unsign(signed);

            unsigned.ShouldBe("hello world");
        }
Example #2
0
        public void tampering_with_timestamp_throws() {
            var timedsigner = new TimeStampSigner("testing");
            var signed = timedsigner.Sign("hello world");

            signed = signed.Substring(0, 15) + 3 + signed.Substring(15);

            Assert.Throws<BadSignatureException>(() => {
                var unsigned = timedsigner.Unsign(signed, 1);
            });
        }
Example #3
0
        public void timestamp_age_check_works() {
            var timedsigner = new TimeStampSigner("testing");
            var signed = timedsigner.Sign("hello world");

            Trace.WriteLine(signed);

            System.Threading.Thread.Sleep(1100);

            Assert.Throws<SignatureExpiredException>(() => {
                var unsigned = timedsigner.Unsign(signed, 1);
            });
        }