Question

I am using Libgcrypt with Elgamal to encrypt a block of bytes, and I am having 2 problems:

  1. When I do not use padding and my block of bytes starts which an zero byte, I lose the first byte during decryption;

  2. If I use padding the encryption works well, but when I decrypt the padding is not removed. And apparently the first zero byte still there.

With RSA I am having the same problem :(

My test code is there: www.tiago.eti.br/storage/post.c And it do not use padding.

To use padding you need to change:

#define PADDING "raw"

to

#define PADDING "pkcs1"

And to change the encryption algorithm change:

#define ALG "elg"

to

#define ALG "rsa"

To compile you need to use:

gcc -Wall -g post.c -lgcrypt -o post

What can I do to solve it?

Was it helpful?

Solution

I posted the same question in Libgcrypt mailing list and I had an answer.

Libgcrypt until 1.5.0 does not remove the padding: it recognizes the flags but does nothing with the padding.

So the solution is update Libgcrypt to 1.5.0.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top