public void Verify_Should_ReturnTrue_When_ValidatingUnChangedSignedData() { // Arrange var secretData = new EncryptionData(Secret); var publicKey = new RsaPublicKey(); var privateKey = new RsaPrivateKey(); var e1 = new RsaEncryption(); e1.GenerateNewKeyset(ref publicKey, ref privateKey); // Act var signature = e1.Sign(secretData, privateKey); var actual = e1.Verify(secretData, signature, publicKey); // Assert Assert.True(actual); }
public void Sign_Should_CorrectlyCreateProperSignature() { // Arrange var secretData = new EncryptionData(Secret); var xml = File.ReadAllText($"{_assemblyPath}privateKey.xml"); var privateKey = RsaPrivateKey.LoadFromXml(xml); const string expected = "kZmV1cUO91lpOQkgz5HLbWsfeXabJOPfcWjH72EytH95AAJEVq+nonJm9A" + "UjHy53VAIagJFJYiORcgsHC1klkppM71hRD1xUs70ggPiMIcTv/CDij3" + "6FYxGd7n9GAh5LikojbWJxJHc3A5LqnAwSBBfOfY2K4gY5lZ3rSmhNHDM="; var e1 = new RsaEncryption(); // Act var signature = e1.Sign(secretData, privateKey); // Assert Assert.Equal(signature.Base64, expected); }