Possible BUG or misdocumentation

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Possible BUG or misdocumentation

saturatio
Hi

Maybe I just misunderstand how it should work, but if you try to use the
buffer version of

public static void writeFileToLiteralData(
        OutputStream out,
        char fileType,
        File file,
        byte[] buffer)
        throws IOException

It just fails if the file is too small. To test you can use the example

https://github.com/bcgit/bc-java/blob/master/pg/src/main/java/org/bouncycastle/openpgp/examples/KeyBasedLargeFileProcessor.java

with a two line text file. It will fail silently, generating a wrong pgp
file. If you try to decrypt with command line gpg, it will have the contents
as the file name.

gpg --verbose -d outputfile.txt.pgp
gpg: la clave pública es 37465DE215DE0CA0
gpg: cifrado con clave de 2048 bits RSA, ID 37465DE215DE0CA0, creada el
2018-10-08
      "[hidden email]"
gpg: datos cifrados AES256
gpg: nombre fichero original='*\n\x09 * Version 2\n\x1b/**\n\x09 *
Versio\0\0\0\0\0\0\0\0\0\0\0'


Can this be considered a bug?

Saludos



--
Sent from: http://bouncy-castle.1462172.n4.nabble.com/Bouncy-Castle-Dev-f1462173.html

Reply | Threaded
Open this post in threaded view
|

Re: Possible BUG or misdocumentation

David Hook-3

Thanks for the report - yes this is a bug. Looks like it just got
introduced recently.

I've pushed an update for the class to github. It will also appear in
161b13 at the end of the week.

Apologies,

David

On 09/10/18 04:17, saturatio wrote:

> Hi
>
> Maybe I just misunderstand how it should work, but if you try to use the
> buffer version of
>
> public static void writeFileToLiteralData(
>         OutputStream out,
>         char fileType,
>         File file,
>         byte[] buffer)
>         throws IOException
>
> It just fails if the file is too small. To test you can use the example
>
> https://github.com/bcgit/bc-java/blob/master/pg/src/main/java/org/bouncycastle/openpgp/examples/KeyBasedLargeFileProcessor.java
>
> with a two line text file. It will fail silently, generating a wrong pgp
> file. If you try to decrypt with command line gpg, it will have the contents
> as the file name.
>
> gpg --verbose -d outputfile.txt.pgp
> gpg: la clave pública es 37465DE215DE0CA0
> gpg: cifrado con clave de 2048 bits RSA, ID 37465DE215DE0CA0, creada el
> 2018-10-08
>       "[hidden email]"
> gpg: datos cifrados AES256
> gpg: nombre fichero original='*\n\x09 * Version 2\n\x1b/**\n\x09 *
> Versio\0\0\0\0\0\0\0\0\0\0\0'
>
>
> Can this be considered a bug?
>
> Saludos
>
>
>
> --
> Sent from: http://bouncy-castle.1462172.n4.nabble.com/Bouncy-Castle-Dev-f1462173.html
>
>