gpapa key generation

Bernhard Herzog bh@intevation.de
05 Jan 2001 19:21:01 +0100


Markus Gerwinski <markus@gerwinski.de> writes:


> Hello Folks!
>
> Bernhard Herzog wrote:
> > Why are publicKey and secretKey initialized at all? The implementation
> > of gpapa_create_key_pair overwrites them anyway without ever looking at
> > the values passed into it. That's at least a memory leak.
>
> Back when I wrote that code, the implementation of gpapa_create_key_pair
> wasn't yet complete, thus to be able to test the rest of the function I had
> to allocate publicKey and secretKey myself. These lines of code are obsolete
> now, that's right. (Usually, whenever I mark a line with "/*!!!*/", this
> means they're just a workaround or debugging code.)
>
> > Later in keys_generateKey_generate, dummyKey, publicKey and secretKey
> > are free'd:
> >
> > gpapa_key_release (dummyKey, gpa_callback, keeperGenerate->window); /*!!! */
> > free (publicKey); /*!!! */
> > free (secretKey); /*!!! */
> >
> > Is it even correct to do that?
>
> It was necessary back then to avoid the memory leak you mentioned. If I
> recall everything right, these lines should be obsolete now, too.
Ah, I see. My code is now basically the following (It's in CVS now in the file keyring.c, lines 364ff): GpapaPublicKey *publicKey; GpapaSecretKey *secretKey; /* ... */ gpapa_create_key_pair (&publicKey, &secretKey, params->password, params->algo, params->keysize, params->userID, params->email, params->comment, gpa_callback, editor->window); and no code to free the keys again. If I understand you correctly that's the way gpapa_create_key_pair is supposed to be used.
> P.S.: Due to some travelling, I'll be cut from the net for a while, so if
> you answer to that mail, don't wonder about my silence.
Well, I hope there's someone else on this list who can answer my questions about gpapa. Bernhard -- Intevation GmbH http://intevation.de/ MapIt! http://mapit.de/ Sketch http://sketch.sourceforge.net/