check if RSA key is large enough to sign a chunk of data

This commit is contained in:
Martin Willi 2009-06-15 13:49:30 +02:00
parent e7227f0ba0
commit 3176e4421f

View File

@ -248,6 +248,13 @@ static bool build_emsa_pkcs1_signature(private_gmp_rsa_private_key_t *this,
data = digestInfo;
}
if (data.len > this->k - 3)
{
free(digestInfo.ptr);
DBG1("unable to sign %d bytes using a %dbit key", data.len, this->k * 8);
return FALSE;
}
/* build chunk to rsa-decrypt:
* EM = 0x00 || 0x01 || PS || 0x00 || T.
* PS = 0xFF padding, with length to fill em