Problem with gcry_pk_decrypt (libgcrypt)
Johan Wevers
johanw at vulcan.xs4all.nl
Wed Aug 3 18:56:30 CEST 2005
Claudia Reuter wrote:
>I like to encrypt and decrypt large files e.g. pdf files. I wrote some
>code based on libgcrypt. I tested it with .txt files. Encryption seems
>to work, but gcry_pk_decrypt works only, if there's a single line in the
>txt file.
That suggests your read operations assume textmode.
>fread(&retSize, 1, sizeof(retSize), InputFile);
>//read encrypted text
>Buffer = (char *) malloc(retSize);
>fread(Buffer, 1, retSize, InputFile);
Do you store the file length in the first sizeof(retSize) byte(s)?
You now read sizeof(retSize) bytes of data and store them in *retSize.
Now you consider retSize as a size_t and read that many bytes into
Buffer. Are you sure this is what you want?
--
ir. J.C.A. Wevers // Physics and science fiction site:
johanw at vulcan.xs4all.nl // http://www.xs4all.nl/~johanw/index.html
PGP/GPG public keys at http://www.xs4all.nl/~johanw/pgpkeys.html
More information about the Gnupg-users
mailing list