public async Task VerifyAsync_DoNotVerifySignedStream(KeyType keyType) { // Arrange TestFactory testFactory = new TestFactory(); TestFactory testFactory2 = new TestFactory(); await testFactory.ArrangeAsync(keyType, FileType.Known); await testFactory2.ArrangeAsync(KeyType.Generated, FileType.Known); PGP pgp = new PGP(); bool verified = false; // Act using (FileStream inputFileStream = new FileStream(testFactory.ContentFilePath, FileMode.Open, FileAccess.Read)) using (Stream outputFileStream = File.Create(testFactory.SignedContentFilePath)) using (Stream privateKeyStream = new FileStream(testFactory.PrivateKeyFilePath, FileMode.Open, FileAccess.Read)) await pgp.SignStreamAsync(inputFileStream, outputFileStream, privateKeyStream, testFactory.Password); using (FileStream inputFileStream = new FileStream(testFactory.SignedContentFilePath, FileMode.Open, FileAccess.Read)) using (Stream publicKeyStream = new FileStream(testFactory2.PublicKeyFilePath, FileMode.Open, FileAccess.Read)) verified = await pgp.VerifyStreamAsync(inputFileStream, publicKeyStream); // Assert Assert.True(File.Exists(testFactory.SignedContentFilePath)); Assert.False(verified); // Teardown testFactory.Teardown(); }
public async Task <bool> VerifyStreamAsync(Stream inputStream, Stream outputStream, PublicKey publicKey) { using var pgp = new PGP(); using var publicKeyStream = GetPublicKey(publicKey); return(await pgp.VerifyStreamAsync(inputStream, publicKeyStream)); }