I am using Libgcrypt with Elgamal to encrypt a block of bytes, and I am having 2 problems:
When I do not use padding and my block of bytes starts which an zero byte, I lose the first byte during decryption;
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?