Our application decrypt pgp-encrypted file using something adapted from KeyBasedFileProcessor.cs , similar to this one. Normally, this works okay, but we encountered issue with certain files. The problematic code is below:
if (message is PgpLiteralData)
{
PgpLiteralData ld = (PgpLiteralData)message;
Stream fOut = File.Create(ld.FileName);
Stream unc = ld.GetInputStream();
Streams.PipeAll(unc, fOut);
fOut.Close();
}
else if (message is PgpOnePassSignatureList)
{
throw new PgpException("encrypted message contains a signed message - not literal data.");
}
else
{
// the code goes here and throw this exception, when I debug, message is of type PgpMarker
throw new PgpException("message is not a simple encrypted file - type unknown.");
}
At this part, I believe the code is expecting PgpLiteralData. But instead we got PgpMarker, which causes exception to be thrown. Why is there a PgpMarker? How to find the PgpLiteralData instead?