Exemplo n.º 1
0
        public void should_detect_a_base64_fake_signature()
        {
            const string message = "message to sign";

            var simpleRsa = new SimpleRSA();
            var pair      = simpleRsa.GeneratePair();

            var signed = "fake signature".ToByteArray().ToBase64String();

            var verification = simpleRsa.Verify(message, signed, pair.PublicKey);

            verification.Should().Be(false);
        }
Exemplo n.º 2
0
        public void should_sign_and_verify_a_message_with_KeyPair()
        {
            const string message = "message to sign";

            var simpleRsa = new SimpleRSA();
            var pair      = simpleRsa.GeneratePair();

            var signed = simpleRsa.Sign(message, pair.PrivateKey);

            var verification = simpleRsa.Verify(message, signed, pair.PublicKey);

            verification.Should().Be(true);
        }