mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-07-15 01:57:40 -05:00
Move some manual freeing into freersakey().
Several pieces of old code were disposing of pieces of an RSAKey by manually freeing them one at a time. We have a centralised freersakey(), so we should use that instead wherever possible. Where it wasn't possible to switch over to that, it was because we were only freeing the private fields of the key - so I've fixed that by cutting freersakey() down the middle and exposing the private-only half as freersapriv().
This commit is contained in:
41
sshrsa.c
41
sshrsa.c
@ -486,22 +486,41 @@ int rsa_ssh1_public_blob_len(void *data, int maxlen)
|
||||
return src->pos;
|
||||
}
|
||||
|
||||
void freersapriv(struct RSAKey *key)
|
||||
{
|
||||
if (key->private_exponent) {
|
||||
freebn(key->private_exponent);
|
||||
key->private_exponent = NULL;
|
||||
}
|
||||
if (key->p) {
|
||||
freebn(key->p);
|
||||
key->p = NULL;
|
||||
}
|
||||
if (key->q) {
|
||||
freebn(key->q);
|
||||
key->q = NULL;
|
||||
}
|
||||
if (key->iqmp) {
|
||||
freebn(key->iqmp);
|
||||
key->iqmp = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void freersakey(struct RSAKey *key)
|
||||
{
|
||||
if (key->modulus)
|
||||
freersapriv(key);
|
||||
if (key->modulus) {
|
||||
freebn(key->modulus);
|
||||
if (key->exponent)
|
||||
key->modulus = NULL;
|
||||
}
|
||||
if (key->exponent) {
|
||||
freebn(key->exponent);
|
||||
if (key->private_exponent)
|
||||
freebn(key->private_exponent);
|
||||
if (key->p)
|
||||
freebn(key->p);
|
||||
if (key->q)
|
||||
freebn(key->q);
|
||||
if (key->iqmp)
|
||||
freebn(key->iqmp);
|
||||
if (key->comment)
|
||||
key->exponent = NULL;
|
||||
}
|
||||
if (key->comment) {
|
||||
sfree(key->comment);
|
||||
key->comment = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
|
Reference in New Issue
Block a user