public void SignVerify_InvalidSignature_ShouldNotVerify() { var input = Encoding.UTF8.GetBytes("Hello World"); var rsa = new RSASignatureCipher(); rsa.Init(new RSAPrivateKeyParameter(Key)); var signature = rsa.Sign(input, new SHA1Digest()); signature[signature.Length - 1] ^= 1; Assert.False(rsa.Verify(input, signature, new SHA1Digest())); }
public void SignVerify_ShouldRoundTrip() { var input = Encoding.UTF8.GetBytes("Hello World"); var rsa = new RSASignatureCipher(); rsa.Init(new RSAPrivateKeyParameter(Key)); var signature = rsa.Sign(input, new SHA1Digest()); Assert.True(rsa.Verify(input, signature, new SHA1Digest())); Assert.Equal("54eab8c1837f4ded1122e1fbf47d0225188148a092e180e83b489aba1f1dc7b5" + "241103ba8f136b393cf8c054a6a69e0c372453aa098e091a2dbe0310f0b653cb", HexConverter.ToHex(signature)); }