From: Sansar Choinyambuu Date: Mon, 10 Oct 2011 14:07:18 +0000 (+0200) Subject: Get AIK certificate encoding in PUBKEY_ASN1_DER if it's just public key X-Git-Tag: 4.6.2~323 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=fe247ba2a6733448f424afe5c2734c991465b4fd;p=thirdparty%2Fstrongswan.git Get AIK certificate encoding in PUBKEY_ASN1_DER if it's just public key --- diff --git a/src/libpts/pts/pts.c b/src/libpts/pts/pts.c index 4c3514690c..6b79f1bc86 100644 --- a/src/libpts/pts/pts.c +++ b/src/libpts/pts/pts.c @@ -25,6 +25,10 @@ #include #include +#include +#include +#include + #define PTS_BUF_SIZE 4096 typedef struct private_pts_t private_pts_t; @@ -358,7 +362,7 @@ static void load_aik(private_pts_t *this) METHOD(pts_t, get_aik, certificate_t*, private_pts_t *this) { - return this->aik; + return this->aik; } METHOD(pts_t, set_aik, void, @@ -817,7 +821,7 @@ METHOD(pts_t, quote_tpm, bool, /* Create from AIK public key a HKEY object to sign Quote operation output*/ if (this->aik->get_type(this->aik) == CERT_TRUSTED_PUBKEY) { - if (!this->aik->get_encoding(this->aik, CERT_ASN1_DER, &aik_key_encoding)) + if (!this->aik->get_encoding(this->aik, PUBKEY_ASN1_DER, &aik_key_encoding)) { DBG1(DBG_PTS, "encoding AIK certificate for quote operation failed"); goto err1; @@ -826,7 +830,6 @@ METHOD(pts_t, quote_tpm, bool, else if (this->aik->get_type(this->aik) == CERT_X509) { public_key_t *key = this->aik->get_public_key(this->aik); - if (key == NULL) { DBG1(DBG_PTS, "unable to retrieve public key from AIK certificate"); @@ -843,9 +846,9 @@ METHOD(pts_t, quote_tpm, bool, DBG1(DBG_PTS, "AIK is neither X509 certificate nor Public Key"); goto err1; } - + result = Tspi_Context_LoadKeyByBlob (hContext, hSRK, aik_key_encoding.len, - (BYTE*)aik_key_encoding.ptr, &hAIK); + aik_key_encoding.ptr, &hAIK); if (result != TSS_SUCCESS) { goto err1;