Using output from gpg --list-packets on a key to get the mpi values to generate s-expressions

Foo Lum etiquettesg at
Wed Jun 1 07:41:41 CEST 2011

I think I figured out why it wasn't working..

I think the output from gpg is chopping off all leading zeros of all mpi
values, after checking for odd hexadecimal numbers and padding negative
numbers with zero's it seemed to encrypt/decrypt/sign/verify fine.
The secondary question I have is:

What is the largest positive value that a mpi can be when represented in
hex? is it 0x7F?

Thanks in advance again,

On Wed, Jun 1, 2011 at 9:26 AM, Foo Lum <etiquettesg at> wrote:

> Hey guys,
> I am trying to use gpg generated public keys to do encryption using
> libgcrypt. I used the list packets command on the key to get me the contents
> of the key and parsed the mpi values into an s-expression. So when I try to
> encode my session key with my public key I get the error "Odd hexadecimal
> numbers in S-expression"? I think list packets is maybe giving me hex
> numbers without the leading zero? If so what do I need to do to get me mpi
> values that I can use in libgcrypt?
> Thanks in advance,
> Foo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/attachments/20110601/e974f4ab/attachment.htm>

More information about the Gcrypt-devel mailing list