moved TSS into pts object
This commit is contained in:
@@ -3,7 +3,7 @@ INCLUDES = -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/libtncif
|
|||||||
|
|
||||||
ipseclib_LTLIBRARIES = libimcv.la
|
ipseclib_LTLIBRARIES = libimcv.la
|
||||||
|
|
||||||
libimcv_la_LIBADD = $(top_builddir)/src/libtncif/libtncif.la
|
libimcv_la_LIBADD = $(top_builddir)/src/libtncif/libtncif.la -ltspi
|
||||||
|
|
||||||
libimcv_la_SOURCES = \
|
libimcv_la_SOURCES = \
|
||||||
imcv.h imcv.c \
|
imcv.h imcv.c \
|
||||||
@@ -29,6 +29,7 @@ libimcv_la_SOURCES = \
|
|||||||
tcg/tcg_pts_attr_simple_evid_final.h tcg/tcg_pts_attr_simple_evid_final.c \
|
tcg/tcg_pts_attr_simple_evid_final.h tcg/tcg_pts_attr_simple_evid_final.c \
|
||||||
tcg/tcg_pts_attr_req_file_meas.h tcg/tcg_pts_attr_req_file_meas.c \
|
tcg/tcg_pts_attr_req_file_meas.h tcg/tcg_pts_attr_req_file_meas.c \
|
||||||
tcg/tcg_pts_attr_file_meas.h tcg/tcg_pts_attr_file_meas.c \
|
tcg/tcg_pts_attr_file_meas.h tcg/tcg_pts_attr_file_meas.c \
|
||||||
|
tcg/pts/pts.h tcg/pts/pts.c \
|
||||||
tcg/pts/pts_funct_comp_name.h \
|
tcg/pts/pts_funct_comp_name.h \
|
||||||
tcg/pts/pts_meas_algo.h tcg/pts/pts_meas_algo.c
|
tcg/pts/pts_meas_algo.h tcg/pts/pts_meas_algo.c
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ AM_CFLAGS = -rdynamic
|
|||||||
imcv_LTLIBRARIES = imc-attestation.la
|
imcv_LTLIBRARIES = imc-attestation.la
|
||||||
|
|
||||||
imc_attestation_la_LIBADD = $(top_builddir)/src/libimcv/libimcv.la \
|
imc_attestation_la_LIBADD = $(top_builddir)/src/libimcv/libimcv.la \
|
||||||
$(top_builddir)/src/libstrongswan/libstrongswan.la -ltspi
|
$(top_builddir)/src/libstrongswan/libstrongswan.la
|
||||||
|
|
||||||
imc_attestation_la_SOURCES = imc_attestation.c \
|
imc_attestation_la_SOURCES = imc_attestation.c \
|
||||||
imc_attestation_state.h imc_attestation_state.c
|
imc_attestation_state.h imc_attestation_state.c
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
#include <ietf/ietf_attr.h>
|
#include <ietf/ietf_attr.h>
|
||||||
#include <ietf/ietf_attr_pa_tnc_error.h>
|
#include <ietf/ietf_attr_pa_tnc_error.h>
|
||||||
|
|
||||||
|
#include <tcg/pts/pts.h>
|
||||||
#include <tcg/tcg_pts_attr_proto_caps.h>
|
#include <tcg/tcg_pts_attr_proto_caps.h>
|
||||||
#include <tcg/tcg_pts_attr_meas_algo.h>
|
#include <tcg/tcg_pts_attr_meas_algo.h>
|
||||||
#include <tcg/tcg_pts_attr_get_tpm_version_info.h>
|
#include <tcg/tcg_pts_attr_get_tpm_version_info.h>
|
||||||
@@ -42,10 +43,6 @@
|
|||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
#include <trousers/tss.h>
|
|
||||||
#include <trousers/trousers.h>
|
|
||||||
|
|
||||||
|
|
||||||
/* IMC definitions */
|
/* IMC definitions */
|
||||||
|
|
||||||
static const char imc_name[] = "Attestation";
|
static const char imc_name[] = "Attestation";
|
||||||
@@ -151,45 +148,13 @@ TNC_Result TNC_IMC_NotifyConnectionChange(TNC_IMCID imc_id,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the TPM Version Information
|
|
||||||
*/
|
|
||||||
static TSS_RESULT get_tpm_version_info(chunk_t *info)
|
|
||||||
{
|
|
||||||
TSS_HCONTEXT hContext;
|
|
||||||
TSS_HTPM hTPM;
|
|
||||||
TSS_RESULT result;
|
|
||||||
|
|
||||||
/* TODO: Needed for parsing version info on IMV side */
|
|
||||||
//TPM_CAP_VERSION_INFO versionInfo;
|
|
||||||
//UINT64 offset = 0;
|
|
||||||
|
|
||||||
result = Tspi_Context_Create(&hContext);
|
|
||||||
if (result != TSS_SUCCESS)
|
|
||||||
{
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
result = Tspi_Context_Connect(hContext, NULL);
|
|
||||||
if (result != TSS_SUCCESS)
|
|
||||||
{
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
result = Tspi_Context_GetTpmObject (hContext, &hTPM);
|
|
||||||
if (result != TSS_SUCCESS)
|
|
||||||
{
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
result = Tspi_TPM_GetCapability(hTPM, TSS_TPMCAP_VERSION_VAL, 0, NULL,
|
|
||||||
&info->len, &info->ptr);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Hash Measurement of a file
|
* Get Hash Measurement of a file
|
||||||
*/
|
*/
|
||||||
static TNC_Result hash_file(char *path, char *out)
|
static TNC_Result hash_file(char *path, char *out)
|
||||||
{
|
{
|
||||||
BYTE buffer[IMC_ATTESTATION_BUF_SIZE];
|
char buffer[IMC_ATTESTATION_BUF_SIZE];
|
||||||
FILE *file;
|
FILE *file;
|
||||||
int bytes_read;
|
int bytes_read;
|
||||||
hasher_t *hasher;
|
hasher_t *hasher;
|
||||||
@@ -289,7 +254,7 @@ static TNC_Result send_message(TNC_ConnectionID connection_id)
|
|||||||
/* Switch on the attribute type IMC has received */
|
/* Switch on the attribute type IMC has received */
|
||||||
switch (handshake_state)
|
switch (handshake_state)
|
||||||
{
|
{
|
||||||
case IMC_ATTESTATION_STATE_REQ_PROTO_CAP:
|
case IMC_ATTESTATION_STATE_REQ_PROTO_CAPS:
|
||||||
{
|
{
|
||||||
pts_proto_caps_flag_t flags;
|
pts_proto_caps_flag_t flags;
|
||||||
if(proto_caps & PTS_PROTO_CAPS_T)
|
if(proto_caps & PTS_PROTO_CAPS_T)
|
||||||
@@ -310,16 +275,14 @@ static TNC_Result send_message(TNC_ConnectionID connection_id)
|
|||||||
}
|
}
|
||||||
case IMC_ATTESTATION_STATE_GET_TPM_INFO:
|
case IMC_ATTESTATION_STATE_GET_TPM_INFO:
|
||||||
{
|
{
|
||||||
TSS_RESULT result;
|
|
||||||
chunk_t tpm_version_info;
|
chunk_t tpm_version_info;
|
||||||
|
pts_t *pts;
|
||||||
|
|
||||||
result = get_tpm_version_info(&tpm_version_info);
|
pts = attestation_state->get_pts(attestation_state);
|
||||||
if (result != TSS_SUCCESS)
|
if (!pts->get_tpm_version_info(pts, &tpm_version_info))
|
||||||
{
|
{
|
||||||
DBG1(DBG_IMC,"Error 0x%x on get_tpm_version_info\n", result);
|
/* TODO return TCG_PTS_TPM_VERS_NOT_SUPPORTED error attribute */
|
||||||
return TNC_RESULT_FATAL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
attr = tcg_pts_attr_tpm_version_info_create(tpm_version_info);
|
attr = tcg_pts_attr_tpm_version_info_create(tpm_version_info);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -535,7 +498,7 @@ TNC_Result TNC_IMC_ReceiveMessage(TNC_IMCID imc_id,
|
|||||||
proto_caps = attr_req_proto_caps->get_flags(attr_req_proto_caps);
|
proto_caps = attr_req_proto_caps->get_flags(attr_req_proto_caps);
|
||||||
|
|
||||||
attestation_state->set_handshake_state(attestation_state,
|
attestation_state->set_handshake_state(attestation_state,
|
||||||
IMC_ATTESTATION_STATE_REQ_PROTO_CAP);
|
IMC_ATTESTATION_STATE_REQ_PROTO_CAPS);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TCG_PTS_MEAS_ALGO:
|
case TCG_PTS_MEAS_ALGO:
|
||||||
|
|||||||
@@ -44,6 +44,11 @@ struct private_imc_attestation_state_t {
|
|||||||
*/
|
*/
|
||||||
imc_attestation_handshake_state_t handshake_state;
|
imc_attestation_handshake_state_t handshake_state;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PTS object
|
||||||
|
*/
|
||||||
|
pts_t *pts;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
METHOD(imc_state_t, get_connection_id, TNC_ConnectionID,
|
METHOD(imc_state_t, get_connection_id, TNC_ConnectionID,
|
||||||
@@ -61,6 +66,7 @@ METHOD(imc_state_t, change_state, void,
|
|||||||
METHOD(imc_state_t, destroy, void,
|
METHOD(imc_state_t, destroy, void,
|
||||||
private_imc_attestation_state_t *this)
|
private_imc_attestation_state_t *this)
|
||||||
{
|
{
|
||||||
|
this->pts->destroy(this->pts);
|
||||||
free(this);
|
free(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -71,11 +77,18 @@ METHOD(imc_attestation_state_t, get_handshake_state, imc_attestation_handshake_s
|
|||||||
}
|
}
|
||||||
|
|
||||||
METHOD(imc_attestation_state_t, set_handshake_state, void,
|
METHOD(imc_attestation_state_t, set_handshake_state, void,
|
||||||
private_imc_attestation_state_t *this, imc_attestation_handshake_state_t new_state)
|
private_imc_attestation_state_t *this,
|
||||||
|
imc_attestation_handshake_state_t new_state)
|
||||||
{
|
{
|
||||||
this->handshake_state = new_state;
|
this->handshake_state = new_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
METHOD(imc_attestation_state_t, get_pts, pts_t*,
|
||||||
|
private_imc_attestation_state_t *this)
|
||||||
|
{
|
||||||
|
return this->pts;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Described in header.
|
* Described in header.
|
||||||
*/
|
*/
|
||||||
@@ -92,10 +105,12 @@ imc_state_t *imc_attestation_state_create(TNC_ConnectionID connection_id)
|
|||||||
},
|
},
|
||||||
.get_handshake_state = _get_handshake_state,
|
.get_handshake_state = _get_handshake_state,
|
||||||
.set_handshake_state = _set_handshake_state,
|
.set_handshake_state = _set_handshake_state,
|
||||||
|
.get_pts = _get_pts,
|
||||||
},
|
},
|
||||||
.state = TNC_CONNECTION_STATE_CREATE,
|
|
||||||
.connection_id = connection_id,
|
.connection_id = connection_id,
|
||||||
|
.state = TNC_CONNECTION_STATE_CREATE,
|
||||||
.handshake_state = IMC_ATTESTATION_STATE_INIT,
|
.handshake_state = IMC_ATTESTATION_STATE_INIT,
|
||||||
|
.pts = pts_create(),
|
||||||
);
|
);
|
||||||
|
|
||||||
return &this->public.interface;
|
return &this->public.interface;
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
#define IMC_ATTESTATION_STATE_H_
|
#define IMC_ATTESTATION_STATE_H_
|
||||||
|
|
||||||
#include <imc/imc_state.h>
|
#include <imc/imc_state.h>
|
||||||
|
#include <tcg/pts/pts.h>
|
||||||
#include <library.h>
|
#include <library.h>
|
||||||
|
|
||||||
typedef struct imc_attestation_state_t imc_attestation_state_t;
|
typedef struct imc_attestation_state_t imc_attestation_state_t;
|
||||||
@@ -33,7 +34,7 @@ typedef enum imc_attestation_handshake_state_t imc_attestation_handshake_state_t
|
|||||||
*/
|
*/
|
||||||
enum imc_attestation_handshake_state_t {
|
enum imc_attestation_handshake_state_t {
|
||||||
IMC_ATTESTATION_STATE_INIT,
|
IMC_ATTESTATION_STATE_INIT,
|
||||||
IMC_ATTESTATION_STATE_REQ_PROTO_CAP,
|
IMC_ATTESTATION_STATE_REQ_PROTO_CAPS,
|
||||||
IMC_ATTESTATION_STATE_REQ_MEAS_ALGO,
|
IMC_ATTESTATION_STATE_REQ_MEAS_ALGO,
|
||||||
IMC_ATTESTATION_STATE_GET_TPM_INFO,
|
IMC_ATTESTATION_STATE_GET_TPM_INFO,
|
||||||
IMC_ATTESTATION_STATE_GET_AIK,
|
IMC_ATTESTATION_STATE_GET_AIK,
|
||||||
@@ -55,24 +56,33 @@ struct imc_attestation_state_t {
|
|||||||
imc_state_t interface;
|
imc_state_t interface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get state of the handshake
|
* Get state of the handshake
|
||||||
*
|
*
|
||||||
* @return the handshake state of IMC
|
* @return the handshake state of IMC
|
||||||
*/
|
*/
|
||||||
imc_attestation_handshake_state_t (*get_handshake_state)(imc_attestation_state_t *this);
|
imc_attestation_handshake_state_t (*get_handshake_state)(imc_attestation_state_t *this);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get state of the handshake
|
* Set state of the handshake
|
||||||
*
|
*
|
||||||
* @param new_state the handshake state of IMC
|
* @param new_state the handshake state of IMC
|
||||||
*/
|
*/
|
||||||
void (*set_handshake_state)(imc_attestation_state_t *this, imc_attestation_handshake_state_t new_state);
|
void (*set_handshake_state)(imc_attestation_state_t *this,
|
||||||
|
imc_attestation_handshake_state_t new_state);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the PTS object
|
||||||
|
*
|
||||||
|
* @return PTS object
|
||||||
|
*/
|
||||||
|
pts_t* (*get_pts)(imc_attestation_state_t *this);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create an imc_attestation_state_t instance
|
* Create an imc_attestation_state_t instance
|
||||||
*
|
*
|
||||||
* @param id connection ID
|
* @param id connection ID
|
||||||
*/
|
*/
|
||||||
imc_state_t* imc_attestation_state_create(TNC_ConnectionID id);
|
imc_state_t* imc_attestation_state_create(TNC_ConnectionID id);
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ AM_CFLAGS = -rdynamic
|
|||||||
imcv_LTLIBRARIES = imv-attestation.la
|
imcv_LTLIBRARIES = imv-attestation.la
|
||||||
|
|
||||||
imv_attestation_la_LIBADD = $(top_builddir)/src/libimcv/libimcv.la \
|
imv_attestation_la_LIBADD = $(top_builddir)/src/libimcv/libimcv.la \
|
||||||
$(top_builddir)/src/libstrongswan/libstrongswan.la -ltspi
|
$(top_builddir)/src/libstrongswan/libstrongswan.la
|
||||||
|
|
||||||
imv_attestation_la_SOURCES = imv_attestation.c \
|
imv_attestation_la_SOURCES = imv_attestation.c \
|
||||||
imv_attestation_state.h imv_attestation_state.c
|
imv_attestation_state.h imv_attestation_state.c
|
||||||
|
|||||||
@@ -19,8 +19,9 @@
|
|||||||
#include <pa_tnc/pa_tnc_msg.h>
|
#include <pa_tnc/pa_tnc_msg.h>
|
||||||
#include <ietf/ietf_attr.h>
|
#include <ietf/ietf_attr.h>
|
||||||
#include <ietf/ietf_attr_pa_tnc_error.h>
|
#include <ietf/ietf_attr_pa_tnc_error.h>
|
||||||
#include <tcg/tcg_attr.h>
|
|
||||||
|
|
||||||
|
#include <tcg/pts/pts.h>
|
||||||
|
#include <tcg/tcg_attr.h>
|
||||||
#include <tcg/tcg_pts_attr_proto_caps.h>
|
#include <tcg/tcg_pts_attr_proto_caps.h>
|
||||||
#include <tcg/tcg_pts_attr_meas_algo.h>
|
#include <tcg/tcg_pts_attr_meas_algo.h>
|
||||||
#include <tcg/tcg_pts_attr_get_tpm_version_info.h>
|
#include <tcg/tcg_pts_attr_get_tpm_version_info.h>
|
||||||
@@ -40,9 +41,6 @@
|
|||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
#include <utils/linked_list.h>
|
#include <utils/linked_list.h>
|
||||||
|
|
||||||
#include <trousers/tss.h>
|
|
||||||
#include <trousers/trousers.h>
|
|
||||||
|
|
||||||
/* IMV definitions */
|
/* IMV definitions */
|
||||||
|
|
||||||
static const char imv_name[] = "Attestation";
|
static const char imv_name[] = "Attestation";
|
||||||
@@ -250,7 +248,7 @@ static TNC_Result send_message(TNC_ConnectionID connection_id)
|
|||||||
attr = tcg_pts_attr_proto_caps_create(flags, TRUE);
|
attr = tcg_pts_attr_proto_caps_create(flags, TRUE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case IMV_ATTESTATION_STATE_PROTO_CAP:
|
case IMV_ATTESTATION_STATE_PROTO_CAPS:
|
||||||
{
|
{
|
||||||
/* Send Measurement Algorithms attribute */
|
/* Send Measurement Algorithms attribute */
|
||||||
attr = tcg_pts_attr_meas_algo_create(supported_algorithms, FALSE);
|
attr = tcg_pts_attr_meas_algo_create(supported_algorithms, FALSE);
|
||||||
@@ -428,7 +426,7 @@ TNC_Result TNC_IMV_ReceiveMessage(TNC_IMVID imv_id,
|
|||||||
proto_caps = attr_proto_caps->get_flags(attr_proto_caps);
|
proto_caps = attr_proto_caps->get_flags(attr_proto_caps);
|
||||||
/* TODO: What to do with the protocol capabilities from imc */
|
/* TODO: What to do with the protocol capabilities from imc */
|
||||||
attestation_state->set_handshake_state(attestation_state,
|
attestation_state->set_handshake_state(attestation_state,
|
||||||
IMV_ATTESTATION_STATE_PROTO_CAP);
|
IMV_ATTESTATION_STATE_PROTO_CAPS);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TCG_PTS_MEAS_ALGO_SELECTION:
|
case TCG_PTS_MEAS_ALGO_SELECTION:
|
||||||
@@ -457,27 +455,12 @@ TNC_Result TNC_IMV_ReceiveMessage(TNC_IMVID imv_id,
|
|||||||
{
|
{
|
||||||
tcg_pts_attr_tpm_version_info_t *attr_tpm;
|
tcg_pts_attr_tpm_version_info_t *attr_tpm;
|
||||||
chunk_t tpm_version_info;
|
chunk_t tpm_version_info;
|
||||||
TSS_RESULT result;
|
pts_t *pts;
|
||||||
TPM_CAP_VERSION_INFO versionInfo;
|
|
||||||
UINT64 offset = 0;
|
|
||||||
|
|
||||||
attr_tpm = (tcg_pts_attr_tpm_version_info_t*)attr;
|
attr_tpm = (tcg_pts_attr_tpm_version_info_t*)attr;
|
||||||
tpm_version_info = attr_tpm->get_tpm_version_info(attr_tpm);
|
tpm_version_info = attr_tpm->get_tpm_version_info(attr_tpm);
|
||||||
|
pts = attestation_state->get_pts(attestation_state);
|
||||||
result = Trspi_UnloadBlob_CAP_VERSION_INFO(&offset,
|
pts->set_tpm_version_info(pts, tpm_version_info);
|
||||||
tpm_version_info.ptr, &versionInfo);
|
|
||||||
if (result != TSS_SUCCESS)
|
|
||||||
{
|
|
||||||
DBG1(DBG_IMV, "TSS Error 0x%x", result);
|
|
||||||
return TNC_RESULT_FATAL;
|
|
||||||
}
|
|
||||||
DBG2(DBG_IMV, "TPM 1.2 Version Info: "
|
|
||||||
"Chip Version: %hhu.%hhu.%hhu.%hhu, "
|
|
||||||
"Spec Level: %hu, Errata Rev: %hhu, Vendor ID: %.4s",
|
|
||||||
versionInfo.version.major, versionInfo.version.minor,
|
|
||||||
versionInfo.version.revMajor, versionInfo.version.revMinor,
|
|
||||||
versionInfo.specLevel, versionInfo.errataRev,
|
|
||||||
versionInfo.tpmVendorID);
|
|
||||||
|
|
||||||
attestation_state->set_handshake_state(attestation_state,
|
attestation_state->set_handshake_state(attestation_state,
|
||||||
IMV_ATTESTATION_STATE_TPM_INFO);
|
IMV_ATTESTATION_STATE_TPM_INFO);
|
||||||
|
|||||||
@@ -54,6 +54,12 @@ struct private_imv_attestation_state_t {
|
|||||||
* IMV evaluation result
|
* IMV evaluation result
|
||||||
*/
|
*/
|
||||||
TNC_IMV_Evaluation_Result eval;
|
TNC_IMV_Evaluation_Result eval;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PTS object
|
||||||
|
*/
|
||||||
|
pts_t *pts;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct entry_t entry_t;
|
typedef struct entry_t entry_t;
|
||||||
@@ -150,6 +156,7 @@ METHOD(imv_state_t, get_reason_string, bool,
|
|||||||
METHOD(imv_state_t, destroy, void,
|
METHOD(imv_state_t, destroy, void,
|
||||||
private_imv_attestation_state_t *this)
|
private_imv_attestation_state_t *this)
|
||||||
{
|
{
|
||||||
|
this->pts->destroy(this->pts);
|
||||||
free(this);
|
free(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -165,6 +172,12 @@ METHOD(imv_attestation_state_t, set_handshake_state, void,
|
|||||||
this->handshake_state = new_state;
|
this->handshake_state = new_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
METHOD(imv_attestation_state_t, get_pts, pts_t*,
|
||||||
|
private_imv_attestation_state_t *this)
|
||||||
|
{
|
||||||
|
return this->pts;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Described in header.
|
* Described in header.
|
||||||
*/
|
*/
|
||||||
@@ -184,12 +197,14 @@ imv_state_t *imv_attestation_state_create(TNC_ConnectionID connection_id)
|
|||||||
},
|
},
|
||||||
.get_handshake_state = _get_handshake_state,
|
.get_handshake_state = _get_handshake_state,
|
||||||
.set_handshake_state = _set_handshake_state,
|
.set_handshake_state = _set_handshake_state,
|
||||||
|
.get_pts = _get_pts,
|
||||||
},
|
},
|
||||||
|
.connection_id = connection_id,
|
||||||
.state = TNC_CONNECTION_STATE_CREATE,
|
.state = TNC_CONNECTION_STATE_CREATE,
|
||||||
.handshake_state = IMV_ATTESTATION_STATE_INIT,
|
.handshake_state = IMV_ATTESTATION_STATE_INIT,
|
||||||
.rec = TNC_IMV_ACTION_RECOMMENDATION_NO_RECOMMENDATION,
|
.rec = TNC_IMV_ACTION_RECOMMENDATION_NO_RECOMMENDATION,
|
||||||
.eval = TNC_IMV_EVALUATION_RESULT_DONT_KNOW,
|
.eval = TNC_IMV_EVALUATION_RESULT_DONT_KNOW,
|
||||||
.connection_id = connection_id,
|
.pts = pts_create(),
|
||||||
);
|
);
|
||||||
|
|
||||||
return &this->public.interface;
|
return &this->public.interface;
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
#define IMV_ATTESTATION_STATE_H_
|
#define IMV_ATTESTATION_STATE_H_
|
||||||
|
|
||||||
#include <imv/imv_state.h>
|
#include <imv/imv_state.h>
|
||||||
|
#include <tcg/pts/pts.h>
|
||||||
#include <library.h>
|
#include <library.h>
|
||||||
|
|
||||||
typedef struct imv_attestation_state_t imv_attestation_state_t;
|
typedef struct imv_attestation_state_t imv_attestation_state_t;
|
||||||
@@ -33,7 +34,7 @@ typedef enum imv_attestation_handshake_state_t imv_attestation_handshake_state_t
|
|||||||
*/
|
*/
|
||||||
enum imv_attestation_handshake_state_t {
|
enum imv_attestation_handshake_state_t {
|
||||||
IMV_ATTESTATION_STATE_INIT,
|
IMV_ATTESTATION_STATE_INIT,
|
||||||
IMV_ATTESTATION_STATE_PROTO_CAP,
|
IMV_ATTESTATION_STATE_PROTO_CAPS,
|
||||||
IMV_ATTESTATION_STATE_MEAS_ALGO,
|
IMV_ATTESTATION_STATE_MEAS_ALGO,
|
||||||
IMV_ATTESTATION_STATE_TPM_INFO,
|
IMV_ATTESTATION_STATE_TPM_INFO,
|
||||||
IMV_ATTESTATION_STATE_AIK,
|
IMV_ATTESTATION_STATE_AIK,
|
||||||
@@ -55,24 +56,33 @@ struct imv_attestation_state_t {
|
|||||||
imv_state_t interface;
|
imv_state_t interface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get state of the handshake
|
* Get state of the handshake
|
||||||
*
|
*
|
||||||
* @return the handshake state of IMV
|
* @return the handshake state of IMV
|
||||||
*/
|
*/
|
||||||
imv_attestation_handshake_state_t (*get_handshake_state)(imv_attestation_state_t *this);
|
imv_attestation_handshake_state_t (*get_handshake_state)(imv_attestation_state_t *this);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get state of the handshake
|
* Set state of the handshake
|
||||||
*
|
*
|
||||||
* @param new_state the handshake state of IMV
|
* @param new_state the handshake state of IMV
|
||||||
*/
|
*/
|
||||||
void (*set_handshake_state)(imv_attestation_state_t *this, imv_attestation_handshake_state_t new_state);
|
void (*set_handshake_state)(imv_attestation_state_t *this,
|
||||||
|
imv_attestation_handshake_state_t new_state);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the PTS object
|
||||||
|
*
|
||||||
|
* @return PTS object
|
||||||
|
*/
|
||||||
|
pts_t* (*get_pts)(imv_attestation_state_t *this);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create an imv_attestation_state_t instance
|
* Create an imv_attestation_state_t instance
|
||||||
*
|
*
|
||||||
* @param id connection ID
|
* @param id connection ID
|
||||||
*/
|
*/
|
||||||
imv_state_t* imv_attestation_state_create(TNC_ConnectionID id);
|
imv_state_t* imv_attestation_state_create(TNC_ConnectionID id);
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,142 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2011 Sansar Choinyambuu
|
||||||
|
* HSR Hochschule fuer Technik Rapperswil
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by the
|
||||||
|
* Free Software Foundation; either version 2 of the License, or (at your
|
||||||
|
* option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "pts.h"
|
||||||
|
|
||||||
|
#include <debug.h>
|
||||||
|
|
||||||
|
#include <trousers/tss.h>
|
||||||
|
#include <trousers/trousers.h>
|
||||||
|
|
||||||
|
typedef struct private_pts_t private_pts_t;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Private data of a pts_t object.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
struct private_pts_t {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Public pts_t interface.
|
||||||
|
*/
|
||||||
|
pts_t public;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contains a TPM_CAP_VERSION_INFO struct
|
||||||
|
*/
|
||||||
|
chunk_t tpm_version_info;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Print TPM 1.2 Version Info
|
||||||
|
*/
|
||||||
|
static void print_tpm_version_info(private_pts_t *this)
|
||||||
|
{
|
||||||
|
TPM_CAP_VERSION_INFO versionInfo;
|
||||||
|
UINT64 offset = 0;
|
||||||
|
TSS_RESULT result;
|
||||||
|
|
||||||
|
result = Trspi_UnloadBlob_CAP_VERSION_INFO(&offset,
|
||||||
|
this->tpm_version_info.ptr, &versionInfo);
|
||||||
|
if (result != TSS_SUCCESS)
|
||||||
|
{
|
||||||
|
DBG1(DBG_TNC, "could not parse tpm version info: tss error 0x%x",
|
||||||
|
result);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DBG2(DBG_TNC, "TPM 1.2 Version Info: Chip Version: %hhu.%hhu.%hhu.%hhu,"
|
||||||
|
" Spec Level: %hu, Errata Rev: %hhu, Vendor ID: %.4s",
|
||||||
|
versionInfo.version.major, versionInfo.version.minor,
|
||||||
|
versionInfo.version.revMajor, versionInfo.version.revMinor,
|
||||||
|
versionInfo.specLevel, versionInfo.errataRev,
|
||||||
|
versionInfo.tpmVendorID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
METHOD(pts_t, get_tpm_version_info, bool,
|
||||||
|
private_pts_t *this, chunk_t *info)
|
||||||
|
{
|
||||||
|
TSS_HCONTEXT hContext;
|
||||||
|
TSS_HTPM hTPM;
|
||||||
|
TSS_RESULT result;
|
||||||
|
|
||||||
|
if (!this->tpm_version_info.ptr)
|
||||||
|
{
|
||||||
|
result = Tspi_Context_Create(&hContext);
|
||||||
|
if (result != TSS_SUCCESS)
|
||||||
|
{
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
result = Tspi_Context_Connect(hContext, NULL);
|
||||||
|
if (result != TSS_SUCCESS)
|
||||||
|
{
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
result = Tspi_Context_GetTpmObject (hContext, &hTPM);
|
||||||
|
if (result != TSS_SUCCESS)
|
||||||
|
{
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
result = Tspi_TPM_GetCapability(hTPM, TSS_TPMCAP_VERSION_VAL, 0, NULL,
|
||||||
|
&this->tpm_version_info.len,
|
||||||
|
&this->tpm_version_info.ptr);
|
||||||
|
if (result != TSS_SUCCESS)
|
||||||
|
{
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
this->tpm_version_info = chunk_clone(this->tpm_version_info);
|
||||||
|
}
|
||||||
|
*info = this->tpm_version_info;
|
||||||
|
print_tpm_version_info(this);
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
err:
|
||||||
|
DBG1(DBG_TNC, "could not get tpm version info: tss error 0x%x", result);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
METHOD(pts_t, set_tpm_version_info, void,
|
||||||
|
private_pts_t *this, chunk_t info)
|
||||||
|
{
|
||||||
|
this->tpm_version_info = chunk_clone(info);
|
||||||
|
print_tpm_version_info(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
METHOD(pts_t, destroy, void,
|
||||||
|
private_pts_t *this)
|
||||||
|
{
|
||||||
|
free(this->tpm_version_info.ptr);
|
||||||
|
free(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* See header
|
||||||
|
*/
|
||||||
|
pts_t *pts_create(void)
|
||||||
|
{
|
||||||
|
private_pts_t *this;
|
||||||
|
|
||||||
|
INIT(this,
|
||||||
|
.public = {
|
||||||
|
.get_tpm_version_info = _get_tpm_version_info,
|
||||||
|
.set_tpm_version_info = _set_tpm_version_info,
|
||||||
|
.destroy = _destroy,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
return &this->public;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2011 Sansar Choinyambuu
|
||||||
|
* HSR Hochschule fuer Technik Rapperswil
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by the
|
||||||
|
* Free Software Foundation; either version 2 of the License, or (at your
|
||||||
|
* option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @defgroup pts pts
|
||||||
|
* @{ @ingroup pts
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef PTS_H_
|
||||||
|
#define PTS_H_
|
||||||
|
|
||||||
|
typedef struct pts_t pts_t;
|
||||||
|
|
||||||
|
#include <library.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class implementing the TCG Platform Trust System (PTS)
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
struct pts_t {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get TPM 1.2 Version Info
|
||||||
|
*
|
||||||
|
* @param info chunk containing a TPM_CAP_VERSION_INFO struct
|
||||||
|
* @return TRUE if TPM Version Info available
|
||||||
|
*/
|
||||||
|
bool (*get_tpm_version_info)(pts_t *this, chunk_t *info);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set TPM 1.2 Version Info
|
||||||
|
*
|
||||||
|
* @param info chunk containing a TPM_CAP_VERSION_INFO struct
|
||||||
|
*/
|
||||||
|
void (*set_tpm_version_info)(pts_t *this, chunk_t info);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Destroys a pts_t object.
|
||||||
|
*/
|
||||||
|
void (*destroy)(pts_t *this);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an pts_t object
|
||||||
|
*/
|
||||||
|
pts_t* pts_create(void);
|
||||||
|
|
||||||
|
#endif /** PTS_H_ @}*/
|
||||||
Reference in New Issue
Block a user