mirror of
https://github.com/strongswan/strongswan.git
synced 2025-10-08 00:02:03 -04:00
libpts: Use chunk_map() to load AIK blob
This commit is contained in:
parent
c5447bc2f5
commit
37089963b6
@ -369,43 +369,32 @@ METHOD(pts_t, set_tpm_version_info, void,
|
|||||||
*/
|
*/
|
||||||
static void load_aik_blob(private_pts_t *this)
|
static void load_aik_blob(private_pts_t *this)
|
||||||
{
|
{
|
||||||
char *blob_path;
|
char *path;
|
||||||
FILE *fp;
|
chunk_t *map;
|
||||||
u_int32_t aikBlobLen;
|
|
||||||
|
|
||||||
blob_path = lib->settings->get_str(lib->settings,
|
path = lib->settings->get_str(lib->settings,
|
||||||
"%s.plugins.imc-attestation.aik_blob", NULL, lib->ns);
|
"%s.plugins.imc-attestation.aik_blob", NULL, lib->ns);
|
||||||
|
if (path)
|
||||||
if (blob_path)
|
|
||||||
{
|
{
|
||||||
/* Read aik key blob from a file */
|
map = chunk_map(path, FALSE);
|
||||||
if ((fp = fopen(blob_path, "r")) == NULL)
|
if (map)
|
||||||
{
|
{
|
||||||
DBG1(DBG_PTS, "unable to open AIK Blob file: %s", blob_path);
|
DBG2(DBG_PTS, "loaded AIK Blob from '%s'", path);
|
||||||
return;
|
DBG3(DBG_PTS, "AIK Blob: %B", map);
|
||||||
}
|
this->aik_blob = chunk_clone(*map);
|
||||||
|
chunk_unmap(map);
|
||||||
fseek(fp, 0, SEEK_END);
|
|
||||||
aikBlobLen = ftell(fp);
|
|
||||||
fseek(fp, 0L, SEEK_SET);
|
|
||||||
|
|
||||||
this->aik_blob = chunk_alloc(aikBlobLen);
|
|
||||||
if (fread(this->aik_blob.ptr, 1, aikBlobLen, fp) == aikBlobLen)
|
|
||||||
{
|
|
||||||
DBG2(DBG_PTS, "loaded AIK Blob from '%s'", blob_path);
|
|
||||||
DBG3(DBG_PTS, "AIK Blob: %B", &this->aik_blob);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DBG1(DBG_PTS, "unable to read AIK Blob file '%s'", blob_path);
|
DBG1(DBG_PTS, "unable to map AIK Blob file '%s': %s",
|
||||||
chunk_free(&this->aik_blob);
|
path, strerror(errno));
|
||||||
}
|
}
|
||||||
fclose(fp);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
DBG1(DBG_PTS, "AIK Blob is not available");
|
DBG1(DBG_PTS, "AIK Blob is not available");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load an AIK certificate or public key
|
* Load an AIK certificate or public key
|
||||||
|
Loading…
x
Reference in New Issue
Block a user