Keypair generation, storage

Pierre Doucy pierre.doucy at
Thu Jan 20 14:22:08 CET 2005

Hi all,

as part of a school project, I'm implementing the X9.62 (ECDSA)
algorithm into gnupg.
I've done quite well until now, but I have a few questions now :

1) I'va had segfaults in the do_fingerprint_md function (which does
something with the public key) for quite a while, until I realised
that the "public key" it uses is retrieved that way :

    for( i=0; i < npkey; i++ )
        pk.pkey[i] = sk->skey[i];

which I thought was a little bit silly at first. Then I realised that
all the other algorithms constructed their private keys as an array
containing all the public parameters, then the private parameters.
Can anyone explain me the rationale for this ?

2) Now that I've corrected the last problem, my key generation
routines seem to work well, but when
$ gpg --gen-key

I get the following error :

gpg: Ohhhh jeeee: can't encode a 160 bit MD into a 255 bits frame
secmem usage: 2304/3232 bytes in 7/11 blocks of pool 3328/32768
Abort trap

Can anyone give me a hint on what this means and how I can correct
this ? I know it happens in do_encode_md :

do_encode_md( MD_HANDLE md, int algo, size_t len, unsigned nbits,
              const byte *asn, size_t asnlen, int v3compathack )
    int nframe = (nbits+7) / 8;

    if( len + asnlen + 4  > nframe )
        log_bug("can't encode a %d bit MD into a %d bits frame\n",
                    (int)(len*8), (int)nbits);

but I really don't understand what's going on here. Any idea ?

Thanks very much in advance.

Pierre DOUCY
Cats are intended to teach us that not everything in nature has a function.

More information about the Gnupg-devel mailing list