PartialInputStream durante a descriptografia de Bouncycastle PGP

Estou tentando descriptografar um arquivo que acabei de criptografar usando o bouncycastle, mas estou recebendo esta exceção:

Premature end of stream in PartialInputStream

Estou usando o código de exemplo do bouncycastle e não mudei nad

Estou recebendo isso quando uso esse código para criptografia:

private static byte[] EncryptFile(byte[] clearData, string fileName, PgpPublicKey encKey, bool withIntegrityCheck)
{
    MemoryStream encOut = new MemoryStream();
    try
    {
        MemoryStream bOut = new MemoryStream();

        PgpCompressedDataGenerator comData = new PgpCompressedDataGenerator( CompressionAlgorithmTag.Zip );

        //PgpUtilities.WriteFileToLiteralData(
        //    comData.Open(bOut),
        //    PgpLiteralData.Binary,
        //    new FileInfo(fileName));
        Stream cos = comData.Open(bOut);
        PgpLiteralDataGenerator lData = new PgpLiteralDataGenerator();

        Stream pOut = lData.Open(
            cos,
            PgpLiteralData.Binary,
            fileName,
            clearData.Length,
            DateTime.UtcNow
            );

        lData.Close();
        comData.Close();

        PgpEncryptedDataGenerator cPk = new PgpEncryptedDataGenerator( SymmetricKeyAlgorithmTag.Cast5, withIntegrityCheck, new SecureRandom() );

        cPk.AddMethod(encKey);

        byte[] bytes = bOut.ToArray();

        Stream os = encOut;

        Stream cOut = cPk.Open(os, bytes.Length);
        cOut.Write(bytes, 0, bytes.Length);
        cOut.Close();

        encOut.Close();
    }
    catch (PgpException e)
    {
        Console.Error.WriteLine(e);

        Exception underlyingException = e.InnerException;
        if (underlyingException != null)
        {
            Console.Error.WriteLine(underlyingException.Message);
            Console.Error.WriteLine(underlyingException.StackTrace);
        }
    }
    return encOut.ToArray();
}

Acho que tem algo a ver com oPgpLiteralDataGenerator. Mas preciso usá-lo porque quero criptografar dados de uma matriz de bytes, não de um arquivo. Existe alguma outra maneira de fazer isso?

questionAnswers(2)

yourAnswerToTheQuestion