defined various measurement hash and pcr functions
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
#include "ita_comp_func_name.h"
|
||||
|
||||
#include "pts/components/pts_component.h"
|
||||
#include "pts/components/pts_comp_evidence.h"
|
||||
|
||||
#include <debug.h>
|
||||
#include <pen/pen.h>
|
||||
@@ -81,6 +82,7 @@ METHOD(pts_component_t, measure, status_t,
|
||||
pts_comp_evidence_t *evid;
|
||||
char *meas_hex, *pcr_before_hex, *pcr_after_hex;
|
||||
chunk_t measurement, pcr_before, pcr_after;
|
||||
size_t hash_size, pcr_len;
|
||||
pts_pcr_transform_t pcr_transform;
|
||||
pts_meas_algorithms_t hash_algo;
|
||||
|
||||
@@ -112,24 +114,26 @@ METHOD(pts_component_t, measure, status_t,
|
||||
}
|
||||
|
||||
hash_algo = pts->get_meas_algorithm(pts);
|
||||
switch (hash_algo)
|
||||
{
|
||||
case PTS_MEAS_ALGO_SHA1:
|
||||
pcr_transform = PTS_PCR_TRANSFORM_MATCH;
|
||||
case PTS_MEAS_ALGO_SHA256:
|
||||
case PTS_MEAS_ALGO_SHA384:
|
||||
pcr_transform = PTS_PCR_TRANSFORM_LONG;
|
||||
case PTS_MEAS_ALGO_NONE:
|
||||
default:
|
||||
pcr_transform = PTS_PCR_TRANSFORM_NO;
|
||||
}
|
||||
hash_size = pts_meas_algo_hash_size(hash_algo);
|
||||
pcr_len = pts->get_pcr_len(pts);
|
||||
pcr_transform = pts_meas_algo_to_pcr_transform(hash_algo, pcr_len);
|
||||
|
||||
/* get and check the measurement data */
|
||||
measurement = chunk_from_hex(
|
||||
chunk_create(meas_hex, strlen(meas_hex)), NULL);
|
||||
pcr_before = chunk_from_hex(
|
||||
chunk_create(pcr_before_hex, strlen(pcr_before_hex)), NULL);
|
||||
pcr_after = chunk_from_hex(
|
||||
chunk_create(pcr_after_hex, strlen(pcr_after_hex)), NULL);
|
||||
if (pcr_before.len != pcr_len || pcr_after.len != pcr_len ||
|
||||
measurement.len != hash_size)
|
||||
{
|
||||
DBG1(DBG_PTS, "TBOOT measurement or pcr data have the wrong size");
|
||||
free(measurement.ptr);
|
||||
free(pcr_before.ptr);
|
||||
free(pcr_after.ptr);
|
||||
return FAILED;
|
||||
}
|
||||
|
||||
evid = *evidence = pts_comp_evidence_create(this->name->clone(this->name),
|
||||
this->depth, this->extended_pcr,
|
||||
@@ -137,8 +141,6 @@ METHOD(pts_component_t, measure, status_t,
|
||||
this->measurement_time, measurement);
|
||||
evid->set_pcr_info(evid, pcr_before, pcr_after);
|
||||
|
||||
|
||||
|
||||
return (this->extended_pcr == PCR_TBOOT_MLE) ? SUCCESS : NEED_MORE;
|
||||
}
|
||||
|
||||
|
||||
@@ -73,6 +73,7 @@ METHOD(pts_component_t, measure, status_t,
|
||||
chunk_t measurement, pcr_before, pcr_after;
|
||||
pts_pcr_transform_t pcr_transform;
|
||||
pts_meas_algorithms_t hash_algo;
|
||||
size_t hash_size, pcr_len;
|
||||
|
||||
/* Provisional implementation for TGRUB */
|
||||
extended_pcr = PCR_DEBUG;
|
||||
@@ -85,22 +86,14 @@ METHOD(pts_component_t, measure, status_t,
|
||||
}
|
||||
|
||||
hash_algo = pts->get_meas_algorithm(pts);
|
||||
switch (hash_algo)
|
||||
{
|
||||
case PTS_MEAS_ALGO_SHA1:
|
||||
pcr_transform = PTS_PCR_TRANSFORM_MATCH;
|
||||
case PTS_MEAS_ALGO_SHA256:
|
||||
case PTS_MEAS_ALGO_SHA384:
|
||||
pcr_transform = PTS_PCR_TRANSFORM_LONG;
|
||||
case PTS_MEAS_ALGO_NONE:
|
||||
default:
|
||||
pcr_transform = PTS_PCR_TRANSFORM_NO;
|
||||
}
|
||||
hash_size = pts_meas_algo_hash_size(hash_algo);
|
||||
pcr_len = pts->get_pcr_len(pts);
|
||||
pcr_transform = pts_meas_algo_to_pcr_transform(hash_algo, pcr_len);
|
||||
|
||||
measurement = chunk_alloc(HASH_SIZE_SHA1);
|
||||
measurement = chunk_alloc(hash_size);
|
||||
memset(measurement.ptr, 0x00, measurement.len);
|
||||
|
||||
pcr_before = chunk_alloc(PCR_LEN);
|
||||
pcr_before = chunk_alloc(pcr_len);
|
||||
memset(pcr_before.ptr, 0x00, pcr_before.len);
|
||||
|
||||
evid = *evidence = pts_comp_evidence_create(this->name->clone(this->name),
|
||||
@@ -167,7 +160,7 @@ pts_component_t *pts_ita_comp_tgrub_create(u_int8_t qualifier, u_int32_t depth)
|
||||
.verify = _verify,
|
||||
.destroy = _destroy,
|
||||
},
|
||||
.name = pts_comp_func_name_create(PEN_ITA, PTS_ITA_COMP_FUNC_NAME_TBOOT,
|
||||
.name = pts_comp_func_name_create(PEN_ITA, PTS_ITA_COMP_FUNC_NAME_TGRUB,
|
||||
qualifier),
|
||||
.depth = depth,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user