Open
Description
Passing a string such as foo\nbar\n\n
or foo\n\nbar
into ClearSignAsync
and then the output of this into VerifyClearAsync
returns a false.
This is true for any consecutive newlines.
Example:
string message = "foo\nbar\n\n";
// Generate keys
using (PGP pgp = new PGP())
{
pgp.GenerateKey(new FileInfo("public.asc"), new FileInfo("private.asc"), "[email protected]", "insecure_password");
}
// Sign the Message
string privateKey = File.ReadAllText("private.asc");
EncryptionKeys encryptionKeys = new EncryptionKeys(privateKey, password);
PGP pgp2 = new PGP(encryptionKeys);
string signedMessage = await pgp2.ClearSignAsync(message);
// Vertify the Signed Message
string publicKey = File.ReadAllText("public.asc");
EncryptionKeys encryptionKeys = new EncryptionKeys(publicKey);
PGP pgp3 = new PGP(encryptionKeys);
bool isVerified = await pgp3.VerifyClearAsync(signedMessage);
// This will return "false"
Console.WriteLine(isVerified);
Removing the newlines is a potential workaround, albeit a suboptimal one, since some may need these characters.
message = message.Replace("\n", "").Replace("\r", "");