示例#1
0
        public void CanCreateVerifyableSignature()
        {
            var payload   = new byte[] { 1, 2, 3 };
            var key       = RSA.Create();
            var signature = new RsaSignature(payload, key);

            Assert.True(signature.Verify(payload, key.ExportRSAPublicKey()));
        }
示例#2
0
        public void CannotVerifySignatureWithWrongKey()
        {
            var payload   = new byte[] { 1, 2, 3 };
            var key       = RSA.Create();
            var otherKey  = RSA.Create();
            var signature = new RsaSignature(payload, key);

            Assert.False(signature.Verify(payload, otherKey.ExportRSAPublicKey()));
        }
示例#3
0
        public void CannotVerifySignatureWithWrongPayload()
        {
            var payload1  = new byte[] { 1, 2, 3 };
            var payload2  = new byte[] { 2, 3, 4 };
            var key       = RSA.Create();
            var signature = new RsaSignature(payload1, key);

            Assert.False(signature.Verify(payload2, key.ExportRSAPublicKey()));
        }