use openssl rsa_verify function

This commit is contained in:
Sansar Choinyambuu
2011-11-28 20:31:13 +01:00
committed by Andreas Steffen
parent 379f7a7533
commit 5fbbfe0a48
4 changed files with 63 additions and 47 deletions
-47
View File
@@ -1201,9 +1201,6 @@ METHOD(pts_t, verify_quote_signature, bool,
{
public_key_t *aik_pub_key;
chunk_t key_encoding;
EVP_PKEY *pkey = NULL;
RSA *rsa = NULL;
unsigned char *p;
aik_pub_key = this->aik->get_public_key(this->aik);
if (!aik_pub_key)
@@ -1228,52 +1225,8 @@ METHOD(pts_t, verify_quote_signature, bool,
goto cleanup;
}
p = key_encoding.ptr;
pkey = d2i_PUBKEY(NULL, (const unsigned char**)&p, key_encoding.len);
if (!pkey)
{
DBG1(DBG_PTS, "failed to get EVP_PKEY object from AIK public key");
goto cleanup;
}
rsa = EVP_PKEY_get1_RSA(pkey);
if (!rsa)
{
DBG1(DBG_PTS, "failed to get RSA object from EVP_PKEY");
goto cleanup;
}
if (RSA_verify(NID_sha1, data.ptr, data.len,
signature.ptr, signature.len, rsa) != 1)
{
DBG1(DBG_PTS, "signature verification failed for TPM Quote Info");
goto cleanup;
}
RSA_free(rsa);
EVP_PKEY_free(pkey);
if (key_encoding.ptr)
{
chunk_clear(&key_encoding);
}
aik_pub_key->destroy(aik_pub_key);
return TRUE;
cleanup:
if (rsa)
{
RSA_free(rsa);
}
if (pkey)
{
EVP_PKEY_free(pkey);
}
if (key_encoding.ptr)
{
chunk_clear(&key_encoding);
}
DESTROY_IF(aik_pub_key);
return FALSE;
}
METHOD(pts_t, destroy, void,