moved pts_meas_algorithms_t to own header file
This commit is contained in:
@@ -16,6 +16,7 @@ libimcv_la_SOURCES = \
|
|||||||
pa_tnc/pa_tnc_msg.h pa_tnc/pa_tnc_msg.c \
|
pa_tnc/pa_tnc_msg.h pa_tnc/pa_tnc_msg.c \
|
||||||
pa_tnc/pa_tnc_attr.h pa_tnc/pa_tnc_attr.c \
|
pa_tnc/pa_tnc_attr.h pa_tnc/pa_tnc_attr.c \
|
||||||
tcg/tcg_attr.h tcg/tcg_attr.c \
|
tcg/tcg_attr.h tcg/tcg_attr.c \
|
||||||
|
tcg/tcg_pts_meas_algo.h tcg/tcg_pts_meas_algo.c \
|
||||||
tcg/tcg_pts_attr_req_proto_caps.h tcg/tcg_pts_attr_req_proto_caps.c \
|
tcg/tcg_pts_attr_req_proto_caps.h tcg/tcg_pts_attr_req_proto_caps.c \
|
||||||
tcg/tcg_pts_attr_proto_caps.h tcg/tcg_pts_attr_proto_caps.c \
|
tcg/tcg_pts_attr_proto_caps.h tcg/tcg_pts_attr_proto_caps.c \
|
||||||
tcg/tcg_pts_attr_meas_algo.h tcg/tcg_pts_attr_meas_algo.c \
|
tcg/tcg_pts_attr_meas_algo.h tcg/tcg_pts_attr_meas_algo.c \
|
||||||
|
|||||||
@@ -49,11 +49,13 @@ static const char imc_name[] = "Attestation";
|
|||||||
|
|
||||||
static imc_agent_t *imc_attestation;
|
static imc_agent_t *imc_attestation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Supported PTS measurement algorithms
|
||||||
|
*/
|
||||||
|
static pts_meas_algorithms_t supported_algorithms = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Selected Measurement Algorithm, which is selected during
|
* Selected PTS measurement algorithm after attribute exchange
|
||||||
* the PTS Measurement Algorithm attributes exchange
|
|
||||||
* Default value is SHA256
|
|
||||||
*/
|
*/
|
||||||
static pts_meas_algorithms_t selected_algorithm = PTS_MEAS_ALGO_SHA256;
|
static pts_meas_algorithms_t selected_algorithm = PTS_MEAS_ALGO_SHA256;
|
||||||
|
|
||||||
@@ -77,7 +79,8 @@ TNC_Result TNC_IMC_Initialize(TNC_IMCID imc_id,
|
|||||||
}
|
}
|
||||||
imc_attestation = imc_agent_create(imc_name, IMC_VENDOR_ID, IMC_SUBTYPE,
|
imc_attestation = imc_agent_create(imc_name, IMC_VENDOR_ID, IMC_SUBTYPE,
|
||||||
imc_id, actual_version);
|
imc_id, actual_version);
|
||||||
if (!imc_attestation)
|
if (!imc_attestation ||
|
||||||
|
!tcg_pts_probe_meas_algorithms(&supported_algorithms))
|
||||||
{
|
{
|
||||||
return TNC_RESULT_FATAL;
|
return TNC_RESULT_FATAL;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,6 +53,11 @@ static const char imv_name[] = "Attestation";
|
|||||||
|
|
||||||
static imv_agent_t *imv_attestation;
|
static imv_agent_t *imv_attestation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Supported PTS measurement algorithms
|
||||||
|
*/
|
||||||
|
static pts_meas_algorithms_t supported_algorithms = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List of files and directories to measure
|
* List of files and directories to measure
|
||||||
*/
|
*/
|
||||||
@@ -88,7 +93,8 @@ TNC_Result TNC_IMV_Initialize(TNC_IMVID imv_id,
|
|||||||
}
|
}
|
||||||
imv_attestation = imv_agent_create(imv_name, IMV_VENDOR_ID, IMV_SUBTYPE,
|
imv_attestation = imv_agent_create(imv_name, IMV_VENDOR_ID, IMV_SUBTYPE,
|
||||||
imv_id, actual_version);
|
imv_id, actual_version);
|
||||||
if (!imv_attestation)
|
if (!imv_attestation ||
|
||||||
|
!tcg_pts_probe_meas_algorithms(&supported_algorithms))
|
||||||
{
|
{
|
||||||
return TNC_RESULT_FATAL;
|
return TNC_RESULT_FATAL;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,18 +34,6 @@ typedef struct private_tcg_pts_attr_meas_algo_t private_tcg_pts_attr_meas_algo_t
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
|
||||||
* Diffie-Hellman Hash Algorithm Values
|
|
||||||
* see section 3.8.5 of PTS Protocol: Binding to TNC IF-M Specification
|
|
||||||
*
|
|
||||||
* 1
|
|
||||||
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
|
|
||||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
* |1|2|3|R|R|R|R|R|R|R|R|R|R|R|R|R|
|
|
||||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define PTS_MEAS_ALGO_SIZE 4
|
#define PTS_MEAS_ALGO_SIZE 4
|
||||||
#define PTS_MEAS_ALGO_RESERVED 0x00
|
#define PTS_MEAS_ALGO_RESERVED 0x00
|
||||||
|
|
||||||
|
|||||||
@@ -22,20 +22,11 @@
|
|||||||
#define TCG_PTS_ATTR_MEAS_ALGO_H_
|
#define TCG_PTS_ATTR_MEAS_ALGO_H_
|
||||||
|
|
||||||
typedef struct tcg_pts_attr_meas_algo_t tcg_pts_attr_meas_algo_t;
|
typedef struct tcg_pts_attr_meas_algo_t tcg_pts_attr_meas_algo_t;
|
||||||
typedef enum pts_meas_algorithms_t pts_meas_algorithms_t;
|
|
||||||
|
|
||||||
#include "tcg_attr.h"
|
#include "tcg_attr.h"
|
||||||
|
#include "tcg_pts_meas_algo.h"
|
||||||
#include "pa_tnc/pa_tnc_attr.h"
|
#include "pa_tnc/pa_tnc_attr.h"
|
||||||
|
|
||||||
/**
|
|
||||||
* PTS Measurement Algorithms
|
|
||||||
*/
|
|
||||||
enum pts_meas_algorithms_t {
|
|
||||||
PTS_MEAS_ALGO_SHA1 = (1<<15),
|
|
||||||
PTS_MEAS_ALGO_SHA256 = (1<<14),
|
|
||||||
PTS_MEAS_ALGO_SHA384 = (1<<13),
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class implementing the TCG Measurement Algorithm Attribute
|
* Class implementing the TCG Measurement Algorithm Attribute
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -26,15 +26,13 @@ typedef enum pts_attr_simple_comp_evid_flag_t pts_attr_simple_comp_evid_flag_t;
|
|||||||
typedef enum pts_attr_simple_comp_evid_pcr_transform_t pts_attr_simple_comp_evid_pcr_transform_t;
|
typedef enum pts_attr_simple_comp_evid_pcr_transform_t pts_attr_simple_comp_evid_pcr_transform_t;
|
||||||
|
|
||||||
#include "tcg_attr.h"
|
#include "tcg_attr.h"
|
||||||
|
#include "tcg_pts_meas_algo.h"
|
||||||
#include "pa_tnc/pa_tnc_attr.h"
|
#include "pa_tnc/pa_tnc_attr.h"
|
||||||
|
|
||||||
/* For Qualifier and Component Name fields, tcg_pts_qualifier_t,
|
/* For Qualifier and Component Name fields, tcg_pts_qualifier_t,
|
||||||
* pts_attr_req_funct_comp_name_bin_enum_t, pts_attr_req_funct_comp_type_t */
|
* pts_attr_req_funct_comp_name_bin_enum_t, pts_attr_req_funct_comp_type_t */
|
||||||
#include "tcg_pts_attr_req_funct_comp_evid.h"
|
#include "tcg_pts_attr_req_funct_comp_evid.h"
|
||||||
|
|
||||||
/* For Hash Algorithm field, pts_attr_meas_algorithms_t */
|
|
||||||
#include "tcg_pts_attr_meas_algo.h"
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PTS Simple Component Evidence Flags
|
* PTS Simple Component Evidence Flags
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -25,10 +25,8 @@ typedef struct tcg_pts_attr_simple_evid_final_t tcg_pts_attr_simple_evid_final_t
|
|||||||
typedef enum pts_simple_evid_final_flag_t pts_simple_evid_final_flag_t;
|
typedef enum pts_simple_evid_final_flag_t pts_simple_evid_final_flag_t;
|
||||||
|
|
||||||
#include "tcg_attr.h"
|
#include "tcg_attr.h"
|
||||||
#include "pa_tnc/pa_tnc_attr.h"
|
|
||||||
|
|
||||||
/* For Optional Composite Hash Algorithm field, pts_attr_meas_algorithms_t*/
|
|
||||||
#include "tcg_pts_attr_meas_algo.h"
|
#include "tcg_pts_attr_meas_algo.h"
|
||||||
|
#include "pa_tnc/pa_tnc_attr.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PTS Simple Evidence Final Flags
|
* PTS Simple Evidence Final Flags
|
||||||
|
|||||||
@@ -0,0 +1,77 @@
|
|||||||
|
/*
|
||||||
|
* 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 "tcg_pts_meas_algo.h"
|
||||||
|
|
||||||
|
#include <debug.h>
|
||||||
|
#include <crypto/hashers/hasher.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Described in header.
|
||||||
|
*/
|
||||||
|
bool tcg_pts_probe_meas_algorithms(pts_meas_algorithms_t *algorithms)
|
||||||
|
{
|
||||||
|
enumerator_t *enumerator;
|
||||||
|
hash_algorithm_t hash_alg;
|
||||||
|
const char *plugin_name;
|
||||||
|
char format1[] = " %s PTS measurement algorithm %N[%s] available";
|
||||||
|
char format2[] = " %s PTS measurement algorithm %N not available";
|
||||||
|
|
||||||
|
*algorithms = 0;
|
||||||
|
|
||||||
|
enumerator = lib->crypto->create_hasher_enumerator(lib->crypto);
|
||||||
|
while (enumerator->enumerate(enumerator, &hash_alg, &plugin_name))
|
||||||
|
{
|
||||||
|
if (hash_alg == HASH_SHA1)
|
||||||
|
{
|
||||||
|
*algorithms |= PTS_MEAS_ALGO_SHA1;
|
||||||
|
DBG2(DBG_TNC, format1, "mandatory", hash_algorithm_names, hash_alg,
|
||||||
|
plugin_name);
|
||||||
|
}
|
||||||
|
else if (hash_alg == HASH_SHA256)
|
||||||
|
{
|
||||||
|
*algorithms |= PTS_MEAS_ALGO_SHA256;
|
||||||
|
DBG2(DBG_TNC, format1, "mandatory", hash_algorithm_names, hash_alg,
|
||||||
|
plugin_name);
|
||||||
|
}
|
||||||
|
else if (hash_alg == HASH_SHA384)
|
||||||
|
{
|
||||||
|
*algorithms |= PTS_MEAS_ALGO_SHA384;
|
||||||
|
DBG2(DBG_TNC, format1, "optional ", hash_algorithm_names, hash_alg,
|
||||||
|
plugin_name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
enumerator->destroy(enumerator);
|
||||||
|
|
||||||
|
if (!(*algorithms & PTS_MEAS_ALGO_SHA384))
|
||||||
|
{
|
||||||
|
DBG1(DBG_TNC, format2, "optional ", hash_algorithm_names, HASH_SHA384);
|
||||||
|
}
|
||||||
|
if ((*algorithms & PTS_MEAS_ALGO_SHA1) &&
|
||||||
|
(*algorithms & PTS_MEAS_ALGO_SHA256))
|
||||||
|
{
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
if (!(*algorithms & PTS_MEAS_ALGO_SHA1))
|
||||||
|
{
|
||||||
|
DBG1(DBG_TNC, format2, "mandatory", hash_algorithm_names, HASH_SHA1);
|
||||||
|
}
|
||||||
|
if (!(*algorithms & PTS_MEAS_ALGO_SHA256))
|
||||||
|
{
|
||||||
|
DBG1(DBG_TNC, format2, "mandatory", hash_algorithm_names, HASH_SHA256);
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
/*
|
||||||
|
* 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 tcg_pts_meas_algo tcg_pts_meas_algo
|
||||||
|
* @{ @ingroup tcg_pts_meas_algo
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef TCG_PTS_MEAS_ALGO_H_
|
||||||
|
#define TCG_PTS_MEAS_ALGO_H_
|
||||||
|
|
||||||
|
#include <library.h>
|
||||||
|
|
||||||
|
typedef enum pts_meas_algorithms_t pts_meas_algorithms_t;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PTS Measurement Algorithms
|
||||||
|
*/
|
||||||
|
enum pts_meas_algorithms_t {
|
||||||
|
PTS_MEAS_ALGO_SHA1 = (1<<15),
|
||||||
|
PTS_MEAS_ALGO_SHA256 = (1<<14),
|
||||||
|
PTS_MEAS_ALGO_SHA384 = (1<<13),
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Diffie-Hellman Hash Algorithm Values
|
||||||
|
* see section 3.8.5 of PTS Protocol: Binding to TNC IF-M Specification
|
||||||
|
*
|
||||||
|
* 1
|
||||||
|
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
|
||||||
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
|
* |1|2|3|R|R|R|R|R|R|R|R|R|R|R|R|R|
|
||||||
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Probe available PTS measurement algorithms
|
||||||
|
*
|
||||||
|
* @param algorithms set of available algorithms
|
||||||
|
* @return TRUE if mandatory algorithms are available
|
||||||
|
*/
|
||||||
|
bool tcg_pts_probe_meas_algorithms(pts_meas_algorithms_t *algorithms);
|
||||||
|
|
||||||
|
#endif /** TCG_PTS_MEAS_ALGO_H_ @}*/
|
||||||
Reference in New Issue
Block a user