fixed memleak
This commit is contained in:
@@ -74,9 +74,10 @@ openssl_rsa_public_key_t *openssl_rsa_public_key_create_from_n_e(BIGNUM *n, BIGN
|
|||||||
* Build an EMPSA PKCS1 signature described in PKCS#1
|
* Build an EMPSA PKCS1 signature described in PKCS#1
|
||||||
*/
|
*/
|
||||||
static bool build_emsa_pkcs1_signature(private_openssl_rsa_private_key_t *this,
|
static bool build_emsa_pkcs1_signature(private_openssl_rsa_private_key_t *this,
|
||||||
int type, chunk_t data, chunk_t *signature)
|
int type, chunk_t data, chunk_t *out)
|
||||||
{
|
{
|
||||||
bool success = FALSE;
|
bool success = FALSE;
|
||||||
|
u_char *sig = NULL;
|
||||||
u_int len;
|
u_int len;
|
||||||
const EVP_MD *hasher = EVP_get_digestbynid(type);
|
const EVP_MD *hasher = EVP_get_digestbynid(type);
|
||||||
if (!hasher)
|
if (!hasher)
|
||||||
@@ -106,15 +107,17 @@ static bool build_emsa_pkcs1_signature(private_openssl_rsa_private_key_t *this,
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
*signature = chunk_alloc(RSA_size(this->rsa));
|
sig = malloc(EVP_PKEY_size(key));
|
||||||
|
if (EVP_SignFinal(ctx, sig, &len, key))
|
||||||
if (!EVP_SignFinal(ctx, signature->ptr, &len, key))
|
|
||||||
{
|
{
|
||||||
goto error;
|
out->ptr = sig;
|
||||||
|
out->len = len;
|
||||||
|
success = TRUE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
free(sig);
|
||||||
}
|
}
|
||||||
signature->len = len;
|
|
||||||
|
|
||||||
success = TRUE;
|
|
||||||
|
|
||||||
error:
|
error:
|
||||||
if (key)
|
if (key)
|
||||||
|
|||||||
Reference in New Issue
Block a user