introduced a PA-TNC attribute manager

This commit is contained in:
Andreas Steffen
2011-09-10 22:39:56 +02:00
parent cf8fd42c77
commit 74eb850dc0
19 changed files with 570 additions and 207 deletions
+1
View File
@@ -6,6 +6,7 @@ ipseclib_LTLIBRARIES = libpts.la
libpts_la_LIBADD = -ltspi
libpts_la_SOURCES = \
libpts.h libpts.c \
pts/pts.h pts/pts.c \
pts/pts_error.h pts/pts_error.c \
pts/pts_proto_caps.h pts/pts_funct_comp_name.h pts/pts_file_type.h \
+62
View File
@@ -0,0 +1,62 @@
/*
* Copyright (C) 2011 Andreas Steffen, 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 "libpts.h"
#include "tcg/tcg_attr.h"
#include <imcv.h>
#include <debug.h>
/**
* Reference count for IMC/IMV instances
*/
static refcount_t libpts_ref = 0;
/**
* Described in header.
*/
bool libpts_init(void)
{
if (libpts_ref == 0)
{
if (!imcv_pa_tnc_attributes)
{
return FALSE;
}
imcv_pa_tnc_attributes->add_vendor(imcv_pa_tnc_attributes, PEN_TCG,
tcg_attr_create_from_data, tcg_attr_names);
DBG1(DBG_LIB, "libpts initialized");
}
ref_get(&libpts_ref);
return TRUE;
}
/**
* Described in header.
*/
void libpts_deinit(void)
{
if (ref_put(&libpts_ref))
{
if (!imcv_pa_tnc_attributes)
{
return;
}
imcv_pa_tnc_attributes->remove_vendor(imcv_pa_tnc_attributes, PEN_TCG);
DBG1(DBG_LIB, "libpts terminated");
}
}
+42
View File
@@ -0,0 +1,42 @@
/*
* Copyright (C) 2011 Andreas Steffen, 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 libpts libpts
*
* @defgroup iplugins plugins
* @ingroup libpts
*
* @addtogroup libpts
* @{
*/
#ifndef LIBPTS_H_
#define LIBPTS_H_
#include <library.h>
/**
* Initialize libpts.
*
* @return FALSE if initialization failed
*/
bool libpts_init(void);
/**
* Deinitialize libpts.
*/
void libpts_deinit(void);
#endif /** LIBPTS_H_ @}*/
+67
View File
@@ -13,6 +13,18 @@
*/
#include "tcg_attr.h"
#include "tcg/tcg_pts_attr_proto_caps.h"
#include "tcg/tcg_pts_attr_meas_algo.h"
#include "tcg/tcg_pts_attr_get_tpm_version_info.h"
#include "tcg/tcg_pts_attr_tpm_version_info.h"
#include "tcg/tcg_pts_attr_get_aik.h"
#include "tcg/tcg_pts_attr_aik.h"
#include "tcg/tcg_pts_attr_req_funct_comp_evid.h"
#include "tcg/tcg_pts_attr_gen_attest_evid.h"
#include "tcg/tcg_pts_attr_simple_comp_evid.h"
#include "tcg/tcg_pts_attr_simple_evid_final.h"
#include "tcg/tcg_pts_attr_req_file_meas.h"
#include "tcg/tcg_pts_attr_file_meas.h"
ENUM_BEGIN(tcg_attr_names, TCG_PTS_REQ_FUNCT_COMP_EVID,
TCG_PTS_REQ_FUNCT_COMP_EVID,
@@ -130,3 +142,58 @@ ENUM_NEXT(tcg_attr_names, TCG_PTS_AIK,
TCG_PTS_GET_AIK,
"Attestation Identity Key");
ENUM_END(tcg_attr_names, TCG_PTS_AIK);
/**
* See header
*/
pa_tnc_attr_t* tcg_attr_create_from_data(u_int32_t type, chunk_t value)
{
switch (type)
{
case TCG_PTS_REQ_PROTO_CAPS:
return tcg_pts_attr_proto_caps_create_from_data(value, TRUE);
case TCG_PTS_PROTO_CAPS:
return tcg_pts_attr_proto_caps_create_from_data(value, FALSE);
case TCG_PTS_MEAS_ALGO:
return tcg_pts_attr_meas_algo_create_from_data(value, FALSE);
case TCG_PTS_MEAS_ALGO_SELECTION:
return tcg_pts_attr_meas_algo_create_from_data(value, TRUE);
case TCG_PTS_GET_TPM_VERSION_INFO:
return tcg_pts_attr_get_tpm_version_info_create_from_data(value);
case TCG_PTS_TPM_VERSION_INFO:
return tcg_pts_attr_tpm_version_info_create_from_data(value);
case TCG_PTS_GET_AIK:
return tcg_pts_attr_get_aik_create_from_data(value);
case TCG_PTS_AIK:
return tcg_pts_attr_aik_create_from_data(value);
case TCG_PTS_REQ_FUNCT_COMP_EVID:
return tcg_pts_attr_req_funct_comp_evid_create_from_data(value);
case TCG_PTS_GEN_ATTEST_EVID:
return tcg_pts_attr_gen_attest_evid_create_from_data(value);
case TCG_PTS_SIMPLE_COMP_EVID:
return tcg_pts_attr_simple_comp_evid_create_from_data(value);
case TCG_PTS_SIMPLE_EVID_FINAL:
return tcg_pts_attr_simple_evid_final_create_from_data(value);
case TCG_PTS_REQ_FILE_MEAS:
return tcg_pts_attr_req_file_meas_create_from_data(value);
case TCG_PTS_FILE_MEAS:
return tcg_pts_attr_file_meas_create_from_data(value);
case TCG_PTS_DH_NONCE_PARAMS_REQ:
case TCG_PTS_DH_NONCE_PARAMS_RESP:
case TCG_PTS_DH_NONCE_FINISH:
case TCG_PTS_REQ_TEMPL_REF_MANI_SET_META:
case TCG_PTS_TEMPL_REF_MANI_SET_META:
case TCG_PTS_UPDATE_TEMPL_REF_MANI:
case TCG_PTS_VERIFICATION_RESULT:
case TCG_PTS_INTEG_REPORT:
case TCG_PTS_REQ_FILE_META:
case TCG_PTS_WIN_FILE_META:
case TCG_PTS_UNIX_FILE_META:
case TCG_PTS_REQ_REGISTRY_VALUE:
case TCG_PTS_REGISTRY_VALUE:
case TCG_PTS_REQ_INTEG_MEAS_LOG:
case TCG_PTS_INTEG_MEAS_LOG:
default:
return NULL;
}
}
+9
View File
@@ -21,6 +21,7 @@
#ifndef TCG_ATTR_H_
#define TCG_ATTR_H_
#include <pa_tnc/pa_tnc_attr.h>
#include <library.h>
typedef enum tcg_attr_t tcg_attr_t;
@@ -69,4 +70,12 @@ enum tcg_attr_t {
*/
extern enum_name_t *tcg_attr_names;
/**
* Create a TCG PA-TNC attribute from data
*
* @param type attribute type
* @param value attribute value
*/
pa_tnc_attr_t* tcg_attr_create_from_data(u_int32_t type, chunk_t value);
#endif /** TCG_ATTR_H_ @}*/