Update PCR store to utilize TCG event types
Update PCR store to utilize TCG event types
This commit is contained in:
Родитель
1d885cbb92
Коммит
73ea81042a
|
@ -147,6 +147,34 @@ int pcr_update_buffer (struct pcr_bank *pcr, struct hash_engine *hash, uint8_t m
|
|||
return pcr_update_digest (pcr, measurement_index, digest, sizeof (digest));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update event type for a measurement in the PCR bank
|
||||
*
|
||||
* @param pcr PCR bank to update measurement in
|
||||
* @param measurement_index The index of measurement being updated
|
||||
* @param event_type Event type to associate with measurment
|
||||
*
|
||||
* @return Completion status, 0 if success or an error code
|
||||
*/
|
||||
int pcr_update_event_type (struct pcr_bank *pcr, uint8_t measurement_index, uint32_t event_type)
|
||||
{
|
||||
if (pcr == NULL) {
|
||||
return PCR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
if (measurement_index >= pcr->num_measurements) {
|
||||
return PCR_INVALID_INDEX;
|
||||
}
|
||||
|
||||
platform_mutex_lock (&pcr->lock);
|
||||
|
||||
pcr->measurement_list[measurement_index].event_type = event_type;
|
||||
|
||||
platform_mutex_unlock (&pcr->lock);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compute aggregate of all measurements that have added to PCR bank
|
||||
*
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
struct pcr_measurement {
|
||||
uint8_t digest[PCR_DIGEST_LENGTH]; /**< Digest buffer */
|
||||
uint8_t measurement[PCR_DIGEST_LENGTH]; /**< Aggregated measurement buffer */
|
||||
uint32_t event_type; /**< TCG event type */
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -42,6 +43,7 @@ int pcr_update_digest (struct pcr_bank *pcr, uint8_t measurement_index, const ui
|
|||
size_t digest_len);
|
||||
int pcr_update_buffer (struct pcr_bank *pcr, struct hash_engine *hash, uint8_t measurement_index,
|
||||
const uint8_t *buf, size_t buf_len);
|
||||
int pcr_update_event_type (struct pcr_bank *pcr, uint8_t measurement_index, uint32_t event_type);
|
||||
|
||||
int pcr_compute (struct pcr_bank *pcr, struct hash_engine *hash, uint8_t *measurement, bool lock);
|
||||
int pcr_get_measurement (struct pcr_bank *pcr, uint8_t measurement_index,
|
||||
|
|
|
@ -163,6 +163,32 @@ int pcr_store_update_buffer (struct pcr_store *store, struct hash_engine *hash,
|
|||
return pcr_update_buffer (&store->banks[pcr_bank], hash, measurement_index, buf, buf_len);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update event type in PCR bank's list of measurements
|
||||
*
|
||||
* @param store PCR store containing PCR to be updated
|
||||
* @param measurement_type The type of measurement being added
|
||||
* @param event_type TCG event type to associate measurement with
|
||||
*
|
||||
* @return 0 if successful or an error code
|
||||
*/
|
||||
int pcr_store_update_event_type (struct pcr_store *store, uint16_t measurement_type,
|
||||
uint32_t event_type)
|
||||
{
|
||||
uint8_t pcr_bank = (uint8_t) (measurement_type >> 8);
|
||||
uint8_t measurement_index = (uint8_t) measurement_type;
|
||||
|
||||
if (store == NULL) {
|
||||
return PCR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
if (pcr_bank >= store->num_pcr_banks) {
|
||||
return PCR_INVALID_PCR;
|
||||
}
|
||||
|
||||
return pcr_update_event_type (&store->banks[pcr_bank], measurement_index, event_type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Compute aggregate of all measurements that have added to PCR bank
|
||||
*
|
||||
|
@ -382,7 +408,7 @@ int pcr_store_get_tcg_log (struct pcr_store *store, struct hash_engine *hash, ui
|
|||
|
||||
log_entry.entry.digest_algorithm_id = 0x0B;
|
||||
log_entry.entry.digest_count = 1;
|
||||
log_entry.entry.measurement_index = i_measurement;
|
||||
log_entry.entry.event_type = measurements[i_measurement].event_type;
|
||||
log_entry.entry.measurement_type = PCR_MEASUREMENT (i_bank, i_measurement);
|
||||
log_entry.entry.measurement_size = sizeof (measurements[i_measurement].digest);
|
||||
|
||||
|
|
|
@ -28,8 +28,8 @@ struct pcr_store {
|
|||
* Format for an entry in the TCG log.
|
||||
*/
|
||||
struct pcr_store_tcg_log_entry_info {
|
||||
uint32_t measurement_index; /**< Measurement index extended to. */
|
||||
uint32_t measurement_type; /**< Type of event. */
|
||||
uint32_t event_type; /**< TCG event type */
|
||||
uint32_t measurement_type; /**< PCR and measurement index */
|
||||
uint32_t digest_count; /**< Number of digests. */
|
||||
uint16_t digest_algorithm_id; /**< ID of hashing algorithm. */
|
||||
uint8_t digest[SHA256_HASH_LENGTH]; /**< Value extended to measurement. */
|
||||
|
@ -60,6 +60,8 @@ int pcr_store_update_digest (struct pcr_store *store, uint16_t measurement_type,
|
|||
const uint8_t *digest, size_t digest_len);
|
||||
int pcr_store_update_buffer (struct pcr_store *store, struct hash_engine *hash,
|
||||
uint16_t measurement_type, const uint8_t *buf, size_t buf_len);
|
||||
int pcr_store_update_event_type (struct pcr_store *store, uint16_t measurement_type,
|
||||
uint32_t event_type);
|
||||
|
||||
int pcr_store_compute (struct pcr_store *store, struct hash_engine *hash, uint8_t pcr_num,
|
||||
uint8_t *measurement);
|
||||
|
|
|
@ -84,7 +84,7 @@ static void attestation_slave_testing_init_dependencies (CuTest *test,
|
|||
status = rng_mock_init (&attestation->rng);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = pcr_store_init (&attestation->store, num_pcr_measurements,
|
||||
status = pcr_store_init (&attestation->store, num_pcr_measurements,
|
||||
sizeof (num_pcr_measurements));
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
|
@ -1047,7 +1047,7 @@ static void attestation_slave_test_get_alias_certificate_fail (CuTest *test)
|
|||
status = rng_mock_init (&attestation.rng);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = pcr_store_init (&attestation.store, num_pcr_measurements,
|
||||
status = pcr_store_init (&attestation.store, num_pcr_measurements,
|
||||
sizeof (num_pcr_measurements));
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
|
|
|
@ -3262,7 +3262,7 @@ void cerberus_protocol_optional_commands_testing_process_log_read_tcg (CuTest *t
|
|||
exp_buf[i_measurement].entry.digest_algorithm_id = 0x0B;
|
||||
exp_buf[i_measurement].entry.digest_count = 1;
|
||||
exp_buf[i_measurement].entry.measurement_size = 32;
|
||||
exp_buf[i_measurement].entry.measurement_index = i_measurement;
|
||||
exp_buf[i_measurement].entry.event_type = 0xA + i_measurement;
|
||||
exp_buf[i_measurement].entry.measurement_type = PCR_MEASUREMENT (0, i_measurement);
|
||||
|
||||
memcpy (exp_buf[i_measurement].entry.digest, digests[i_measurement],
|
||||
|
@ -3340,6 +3340,8 @@ void cerberus_protocol_optional_commands_testing_process_log_read_tcg (CuTest *t
|
|||
for (i_measurement = 0; i_measurement < 6; ++i_measurement) {
|
||||
pcr_store_update_digest (store, PCR_MEASUREMENT (0, i_measurement),
|
||||
digests[i_measurement], PCR_DIGEST_LENGTH);
|
||||
pcr_store_update_event_type (store, PCR_MEASUREMENT (0, i_measurement),
|
||||
0x0A + i_measurement);
|
||||
}
|
||||
|
||||
request.new_request = true;
|
||||
|
@ -3424,7 +3426,7 @@ void cerberus_protocol_optional_commands_testing_process_log_read_tcg_limited_re
|
|||
exp_buf[i_measurement].entry.digest_algorithm_id = 0x0B;
|
||||
exp_buf[i_measurement].entry.digest_count = 1;
|
||||
exp_buf[i_measurement].entry.measurement_size = 32;
|
||||
exp_buf[i_measurement].entry.measurement_index = i_measurement;
|
||||
exp_buf[i_measurement].entry.event_type = 0xA + i_measurement;
|
||||
exp_buf[i_measurement].entry.measurement_type = PCR_MEASUREMENT (0, i_measurement);
|
||||
|
||||
memcpy (exp_buf[i_measurement].entry.digest, digests[i_measurement],
|
||||
|
@ -3502,6 +3504,8 @@ void cerberus_protocol_optional_commands_testing_process_log_read_tcg_limited_re
|
|||
for (i_measurement = 0; i_measurement < 6; ++i_measurement) {
|
||||
pcr_store_update_digest (store, PCR_MEASUREMENT (0, i_measurement),
|
||||
digests[i_measurement], PCR_DIGEST_LENGTH);
|
||||
pcr_store_update_event_type (store, PCR_MEASUREMENT (0, i_measurement),
|
||||
0x0A + i_measurement);
|
||||
}
|
||||
|
||||
request.new_request = true;
|
||||
|
|
|
@ -385,6 +385,64 @@ static void pcr_store_test_update_buffer_update_fail (CuTest *test)
|
|||
complete_pcr_store_mock_test (test, &store, &hash);
|
||||
}
|
||||
|
||||
static void pcr_store_test_update_event_type (CuTest *test)
|
||||
{
|
||||
struct pcr_store store;
|
||||
struct hash_engine_mock hash;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
||||
setup_pcr_store_mock_test (test, &store, &hash, 6, 6);
|
||||
|
||||
status = pcr_store_update_event_type (&store, PCR_MEASUREMENT (1, 1), 0x0A);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
complete_pcr_store_mock_test (test, &store, &hash);
|
||||
}
|
||||
|
||||
static void pcr_store_test_update_event_type_invalid_arg (CuTest *test)
|
||||
{
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
||||
status = pcr_store_update_event_type (NULL, 5, 0x0A);
|
||||
CuAssertIntEquals (test, PCR_INVALID_ARGUMENT, status);
|
||||
}
|
||||
|
||||
static void pcr_store_test_update_event_type_invalid_pcr (CuTest *test)
|
||||
{
|
||||
struct pcr_store store;
|
||||
struct hash_engine_mock hash;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
||||
setup_pcr_store_mock_test (test, &store, &hash, 6, 6);
|
||||
|
||||
status = pcr_store_update_event_type (&store, (((uint16_t)4 << 8) | 1), 0x0A);
|
||||
CuAssertIntEquals (test, PCR_INVALID_PCR, status);
|
||||
|
||||
complete_pcr_store_mock_test (test, &store, &hash);
|
||||
}
|
||||
|
||||
static void pcr_store_test_update_event_type_update_fail (CuTest *test)
|
||||
{
|
||||
struct pcr_store store;
|
||||
struct hash_engine_mock hash;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
||||
setup_pcr_store_mock_test (test, &store, &hash, 6, 6);
|
||||
|
||||
status = pcr_store_update_event_type (&store, (((uint16_t)1 << 8) | 10), 0x0A);
|
||||
CuAssertIntEquals (test, PCR_INVALID_INDEX, status);
|
||||
|
||||
complete_pcr_store_mock_test (test, &store, &hash);
|
||||
}
|
||||
|
||||
static void pcr_store_test_compute (CuTest *test)
|
||||
{
|
||||
struct pcr_store store;
|
||||
|
@ -752,6 +810,7 @@ static void pcr_store_test_get_tcg_log (CuTest *test)
|
|||
exp_buf[i_measurement].entry.digest_algorithm_id = 0x0B;
|
||||
exp_buf[i_measurement].entry.digest_count = 1;
|
||||
exp_buf[i_measurement].entry.measurement_size = 32;
|
||||
exp_buf[i_measurement].entry.event_type = 0x0A + i_measurement;
|
||||
|
||||
memcpy (exp_buf[i_measurement].entry.digest, digests[i_measurement],
|
||||
sizeof (exp_buf[i_measurement].entry.digest));
|
||||
|
@ -759,12 +818,10 @@ static void pcr_store_test_get_tcg_log (CuTest *test)
|
|||
sizeof (exp_buf[i_measurement].entry.measurement));
|
||||
|
||||
if (i_measurement >= 3) {
|
||||
exp_buf[i_measurement].entry.measurement_index = i_measurement - 3;
|
||||
exp_buf[i_measurement].entry.measurement_type =
|
||||
PCR_MEASUREMENT (1, (i_measurement - 3));
|
||||
}
|
||||
else {
|
||||
exp_buf[i_measurement].entry.measurement_index = i_measurement;
|
||||
exp_buf[i_measurement].entry.measurement_type = PCR_MEASUREMENT (0, i_measurement);
|
||||
}
|
||||
}
|
||||
|
@ -834,11 +891,15 @@ static void pcr_store_test_get_tcg_log (CuTest *test)
|
|||
for (i_measurement = 0; i_measurement < 3; ++i_measurement) {
|
||||
pcr_store_update_digest (&store, PCR_MEASUREMENT (0, i_measurement), digests[i_measurement],
|
||||
PCR_DIGEST_LENGTH);
|
||||
pcr_store_update_event_type (&store, PCR_MEASUREMENT (0, i_measurement),
|
||||
0x0A + i_measurement);
|
||||
}
|
||||
|
||||
for (i_measurement = 0; i_measurement < 3; ++i_measurement) {
|
||||
pcr_store_update_digest (&store, PCR_MEASUREMENT (1, i_measurement),
|
||||
digests[3 + i_measurement], PCR_DIGEST_LENGTH);
|
||||
pcr_store_update_event_type (&store, PCR_MEASUREMENT (1, i_measurement),
|
||||
0x0A + i_measurement + 3);
|
||||
}
|
||||
|
||||
status = pcr_store_get_tcg_log (&store, &hash.base, 0, (uint8_t*) buf, sizeof (buf));
|
||||
|
@ -895,6 +956,7 @@ static void pcr_store_test_get_tcg_log_invalid_entry (CuTest *test)
|
|||
exp_buf[i_measurement].entry.digest_algorithm_id = 0x0B;
|
||||
exp_buf[i_measurement].entry.digest_count = 1;
|
||||
exp_buf[i_measurement].entry.measurement_size = 32;
|
||||
exp_buf[i_measurement].entry.event_type = 0x0A + i_measurement;
|
||||
|
||||
memcpy (exp_buf[i_measurement].entry.digest, digests[i_measurement],
|
||||
sizeof (exp_buf[i_measurement].entry.digest));
|
||||
|
@ -902,12 +964,10 @@ static void pcr_store_test_get_tcg_log_invalid_entry (CuTest *test)
|
|||
sizeof (exp_buf[i_measurement].entry.measurement));
|
||||
|
||||
if (i_measurement >= 3) {
|
||||
exp_buf[i_measurement].entry.measurement_index = i_measurement - 3;
|
||||
exp_buf[i_measurement].entry.measurement_type =
|
||||
PCR_MEASUREMENT (1, (i_measurement - 3));
|
||||
}
|
||||
else {
|
||||
exp_buf[i_measurement].entry.measurement_index = i_measurement;
|
||||
exp_buf[i_measurement].entry.measurement_type = PCR_MEASUREMENT (0, i_measurement);
|
||||
}
|
||||
}
|
||||
|
@ -977,13 +1037,19 @@ static void pcr_store_test_get_tcg_log_invalid_entry (CuTest *test)
|
|||
for (i_measurement = 0; i_measurement < 3; ++i_measurement) {
|
||||
pcr_store_update_digest (&store, PCR_MEASUREMENT (0, i_measurement), digests[i_measurement],
|
||||
PCR_DIGEST_LENGTH);
|
||||
pcr_store_update_event_type (&store, PCR_MEASUREMENT (0, i_measurement),
|
||||
0x0A + i_measurement);
|
||||
}
|
||||
|
||||
for (i_measurement = 0; i_measurement < 2; ++i_measurement) {
|
||||
pcr_store_update_digest (&store, PCR_MEASUREMENT (1, i_measurement),
|
||||
digests[3 + i_measurement], PCR_DIGEST_LENGTH);
|
||||
pcr_store_update_event_type (&store, PCR_MEASUREMENT (1, i_measurement),
|
||||
0x0A + i_measurement + 3);
|
||||
}
|
||||
|
||||
pcr_store_update_event_type (&store, PCR_MEASUREMENT (1, 2), 0x0A + 5);
|
||||
|
||||
status = pcr_store_get_tcg_log (&store, &hash.base, 0, (uint8_t*) buf, sizeof (buf));
|
||||
CuAssertIntEquals (test, 6 * sizeof (struct pcr_store_tcg_log_entry), status);
|
||||
|
||||
|
@ -1044,7 +1110,7 @@ static void pcr_store_test_get_tcg_log_explicit (CuTest *test)
|
|||
memcpy (exp_buf[i_measurement].entry.measurement, digests[5 - i_measurement],
|
||||
sizeof (exp_buf[i_measurement].entry.measurement));
|
||||
|
||||
exp_buf[i_measurement].entry.measurement_index = i_measurement;
|
||||
exp_buf[i_measurement].entry.event_type = 0x0A + i_measurement;
|
||||
exp_buf[i_measurement].entry.measurement_type = PCR_MEASUREMENT (0, i_measurement);
|
||||
}
|
||||
|
||||
|
@ -1083,6 +1149,8 @@ static void pcr_store_test_get_tcg_log_explicit (CuTest *test)
|
|||
for (i_measurement = 0; i_measurement < 3; ++i_measurement) {
|
||||
pcr_store_update_digest (&store, PCR_MEASUREMENT (0, i_measurement), digests[i_measurement],
|
||||
PCR_DIGEST_LENGTH);
|
||||
pcr_store_update_event_type (&store, PCR_MEASUREMENT (0, i_measurement),
|
||||
0x0A + i_measurement);
|
||||
}
|
||||
|
||||
pcr_store_update_digest (&store, PCR_MEASUREMENT (1, 0), digests[3], PCR_DIGEST_LENGTH);
|
||||
|
@ -1141,6 +1209,7 @@ static void pcr_store_test_get_tcg_log_non_zero_offset (CuTest *test)
|
|||
exp_buf[i_measurement].entry.digest_algorithm_id = 0x0B;
|
||||
exp_buf[i_measurement].entry.digest_count = 1;
|
||||
exp_buf[i_measurement].entry.measurement_size = 32;
|
||||
exp_buf[i_measurement].entry.event_type = 0x0A + i_measurement;
|
||||
|
||||
memcpy (exp_buf[i_measurement].entry.digest, digests[i_measurement],
|
||||
sizeof (exp_buf[i_measurement].entry.digest));
|
||||
|
@ -1148,12 +1217,10 @@ static void pcr_store_test_get_tcg_log_non_zero_offset (CuTest *test)
|
|||
sizeof (exp_buf[i_measurement].entry.measurement));
|
||||
|
||||
if (i_measurement >= 3) {
|
||||
exp_buf[i_measurement].entry.measurement_index = i_measurement - 3;
|
||||
exp_buf[i_measurement].entry.measurement_type =
|
||||
PCR_MEASUREMENT (1, (i_measurement - 3));
|
||||
}
|
||||
else {
|
||||
exp_buf[i_measurement].entry.measurement_index = i_measurement;
|
||||
exp_buf[i_measurement].entry.measurement_type = PCR_MEASUREMENT (0, i_measurement);
|
||||
}
|
||||
}
|
||||
|
@ -1223,11 +1290,15 @@ static void pcr_store_test_get_tcg_log_non_zero_offset (CuTest *test)
|
|||
for (i_measurement = 0; i_measurement < 3; ++i_measurement) {
|
||||
pcr_store_update_digest (&store, PCR_MEASUREMENT (0, i_measurement), digests[i_measurement],
|
||||
PCR_DIGEST_LENGTH);
|
||||
pcr_store_update_event_type (&store, PCR_MEASUREMENT (0, i_measurement),
|
||||
0x0A + i_measurement);
|
||||
}
|
||||
|
||||
for (i_measurement = 0; i_measurement < 3; ++i_measurement) {
|
||||
pcr_store_update_digest (&store, PCR_MEASUREMENT (1, i_measurement),
|
||||
digests[3 + i_measurement], PCR_DIGEST_LENGTH);
|
||||
pcr_store_update_event_type (&store, PCR_MEASUREMENT (1, i_measurement),
|
||||
0x0A + i_measurement + 3);
|
||||
}
|
||||
|
||||
status = pcr_store_get_tcg_log (&store, &hash.base, 3 * sizeof (struct pcr_store_tcg_log_entry),
|
||||
|
@ -1285,6 +1356,7 @@ static void pcr_store_test_get_tcg_log_partial_measurement (CuTest *test)
|
|||
exp_buf[i_measurement].entry.digest_algorithm_id = 0x0B;
|
||||
exp_buf[i_measurement].entry.digest_count = 1;
|
||||
exp_buf[i_measurement].entry.measurement_size = 32;
|
||||
exp_buf[i_measurement].entry.event_type = 0x0A + i_measurement;
|
||||
|
||||
memcpy (exp_buf[i_measurement].entry.digest, digests[i_measurement],
|
||||
sizeof (exp_buf[i_measurement].entry.digest));
|
||||
|
@ -1292,12 +1364,10 @@ static void pcr_store_test_get_tcg_log_partial_measurement (CuTest *test)
|
|||
sizeof (exp_buf[i_measurement].entry.measurement));
|
||||
|
||||
if (i_measurement >= 3) {
|
||||
exp_buf[i_measurement].entry.measurement_index = i_measurement - 3;
|
||||
exp_buf[i_measurement].entry.measurement_type =
|
||||
PCR_MEASUREMENT (1, (i_measurement - 3));
|
||||
}
|
||||
else {
|
||||
exp_buf[i_measurement].entry.measurement_index = i_measurement;
|
||||
exp_buf[i_measurement].entry.measurement_type = PCR_MEASUREMENT (0, i_measurement);
|
||||
}
|
||||
}
|
||||
|
@ -1367,11 +1437,15 @@ static void pcr_store_test_get_tcg_log_partial_measurement (CuTest *test)
|
|||
for (i_measurement = 0; i_measurement < 3; ++i_measurement) {
|
||||
pcr_store_update_digest (&store, PCR_MEASUREMENT (0, i_measurement), digests[i_measurement],
|
||||
PCR_DIGEST_LENGTH);
|
||||
pcr_store_update_event_type (&store, PCR_MEASUREMENT (0, i_measurement),
|
||||
0x0A + i_measurement);
|
||||
}
|
||||
|
||||
for (i_measurement = 0; i_measurement < 3; ++i_measurement) {
|
||||
pcr_store_update_digest (&store, PCR_MEASUREMENT (1, i_measurement),
|
||||
digests[3 + i_measurement], PCR_DIGEST_LENGTH);
|
||||
pcr_store_update_event_type (&store, PCR_MEASUREMENT (1, i_measurement),
|
||||
0x0A + i_measurement + 3);
|
||||
}
|
||||
|
||||
status = pcr_store_get_tcg_log (&store, &hash.base,
|
||||
|
@ -1430,6 +1504,7 @@ static void pcr_store_test_get_tcg_log_small_buffer (CuTest *test)
|
|||
exp_buf[i_measurement].entry.digest_algorithm_id = 0x0B;
|
||||
exp_buf[i_measurement].entry.digest_count = 1;
|
||||
exp_buf[i_measurement].entry.measurement_size = 32;
|
||||
exp_buf[i_measurement].entry.event_type = 0x0A + i_measurement;
|
||||
|
||||
memcpy (exp_buf[i_measurement].entry.digest, digests[i_measurement],
|
||||
sizeof (exp_buf[i_measurement].entry.digest));
|
||||
|
@ -1437,12 +1512,10 @@ static void pcr_store_test_get_tcg_log_small_buffer (CuTest *test)
|
|||
sizeof (exp_buf[i_measurement].entry.measurement));
|
||||
|
||||
if (i_measurement >= 3) {
|
||||
exp_buf[i_measurement].entry.measurement_index = i_measurement - 3;
|
||||
exp_buf[i_measurement].entry.measurement_type =
|
||||
PCR_MEASUREMENT (1, (i_measurement - 3));
|
||||
}
|
||||
else {
|
||||
exp_buf[i_measurement].entry.measurement_index = i_measurement;
|
||||
exp_buf[i_measurement].entry.measurement_type = PCR_MEASUREMENT (0, i_measurement);
|
||||
}
|
||||
}
|
||||
|
@ -1482,11 +1555,15 @@ static void pcr_store_test_get_tcg_log_small_buffer (CuTest *test)
|
|||
for (i_measurement = 0; i_measurement < 3; ++i_measurement) {
|
||||
pcr_store_update_digest (&store, PCR_MEASUREMENT (0, i_measurement), digests[i_measurement],
|
||||
PCR_DIGEST_LENGTH);
|
||||
pcr_store_update_event_type (&store, PCR_MEASUREMENT (0, i_measurement),
|
||||
0x0A + i_measurement);
|
||||
}
|
||||
|
||||
for (i_measurement = 0; i_measurement < 3; ++i_measurement) {
|
||||
pcr_store_update_digest (&store, PCR_MEASUREMENT (1, i_measurement),
|
||||
digests[3 + i_measurement], PCR_DIGEST_LENGTH);
|
||||
pcr_store_update_event_type (&store, PCR_MEASUREMENT (1, i_measurement),
|
||||
0x0A + i_measurement + 3);
|
||||
}
|
||||
|
||||
status = pcr_store_get_tcg_log (&store, &hash.base, 0, (uint8_t*) buf,
|
||||
|
@ -1544,6 +1621,7 @@ static void pcr_store_test_get_tcg_log_small_buffer_not_entry_aligned (CuTest *t
|
|||
exp_buf[i_measurement].entry.digest_algorithm_id = 0x0B;
|
||||
exp_buf[i_measurement].entry.digest_count = 1;
|
||||
exp_buf[i_measurement].entry.measurement_size = 32;
|
||||
exp_buf[i_measurement].entry.event_type = 0x0A + i_measurement;
|
||||
|
||||
memcpy (exp_buf[i_measurement].entry.digest, digests[i_measurement],
|
||||
sizeof (exp_buf[i_measurement].entry.digest));
|
||||
|
@ -1551,12 +1629,10 @@ static void pcr_store_test_get_tcg_log_small_buffer_not_entry_aligned (CuTest *t
|
|||
sizeof (exp_buf[i_measurement].entry.measurement));
|
||||
|
||||
if (i_measurement >= 3) {
|
||||
exp_buf[i_measurement].entry.measurement_index = i_measurement - 3;
|
||||
exp_buf[i_measurement].entry.measurement_type =
|
||||
PCR_MEASUREMENT (1, (i_measurement - 3));
|
||||
}
|
||||
else {
|
||||
exp_buf[i_measurement].entry.measurement_index = i_measurement;
|
||||
exp_buf[i_measurement].entry.measurement_type = PCR_MEASUREMENT (0, i_measurement);
|
||||
}
|
||||
}
|
||||
|
@ -1596,11 +1672,15 @@ static void pcr_store_test_get_tcg_log_small_buffer_not_entry_aligned (CuTest *t
|
|||
for (i_measurement = 0; i_measurement < 3; ++i_measurement) {
|
||||
pcr_store_update_digest (&store, PCR_MEASUREMENT (0, i_measurement), digests[i_measurement],
|
||||
PCR_DIGEST_LENGTH);
|
||||
pcr_store_update_event_type (&store, PCR_MEASUREMENT (0, i_measurement),
|
||||
0x0A + i_measurement);
|
||||
}
|
||||
|
||||
for (i_measurement = 0; i_measurement < 3; ++i_measurement) {
|
||||
pcr_store_update_digest (&store, PCR_MEASUREMENT (1, i_measurement),
|
||||
digests[3 + i_measurement], PCR_DIGEST_LENGTH);
|
||||
pcr_store_update_event_type (&store, PCR_MEASUREMENT (1, i_measurement),
|
||||
0x0A + i_measurement + 3);
|
||||
}
|
||||
|
||||
status = pcr_store_get_tcg_log (&store, &hash.base, 0, (uint8_t*) buf,
|
||||
|
@ -1658,6 +1738,7 @@ static void pcr_store_test_get_tcg_log_small_buffer_nonzero_offset (CuTest *test
|
|||
exp_buf[i_measurement].entry.digest_algorithm_id = 0x0B;
|
||||
exp_buf[i_measurement].entry.digest_count = 1;
|
||||
exp_buf[i_measurement].entry.measurement_size = 32;
|
||||
exp_buf[i_measurement].entry.event_type = 0x0A + i_measurement;
|
||||
|
||||
memcpy (exp_buf[i_measurement].entry.digest, digests[i_measurement],
|
||||
sizeof (exp_buf[i_measurement].entry.digest));
|
||||
|
@ -1665,12 +1746,10 @@ static void pcr_store_test_get_tcg_log_small_buffer_nonzero_offset (CuTest *test
|
|||
sizeof (exp_buf[i_measurement].entry.measurement));
|
||||
|
||||
if (i_measurement >= 3) {
|
||||
exp_buf[i_measurement].entry.measurement_index = i_measurement - 3;
|
||||
exp_buf[i_measurement].entry.measurement_type =
|
||||
PCR_MEASUREMENT (1, (i_measurement - 3));
|
||||
}
|
||||
else {
|
||||
exp_buf[i_measurement].entry.measurement_index = i_measurement;
|
||||
exp_buf[i_measurement].entry.measurement_type = PCR_MEASUREMENT (0, i_measurement);
|
||||
}
|
||||
}
|
||||
|
@ -1740,11 +1819,15 @@ static void pcr_store_test_get_tcg_log_small_buffer_nonzero_offset (CuTest *test
|
|||
for (i_measurement = 0; i_measurement < 3; ++i_measurement) {
|
||||
pcr_store_update_digest (&store, PCR_MEASUREMENT (0, i_measurement), digests[i_measurement],
|
||||
PCR_DIGEST_LENGTH);
|
||||
pcr_store_update_event_type (&store, PCR_MEASUREMENT (0, i_measurement),
|
||||
0x0A + i_measurement);
|
||||
}
|
||||
|
||||
for (i_measurement = 0; i_measurement < 3; ++i_measurement) {
|
||||
pcr_store_update_digest (&store, PCR_MEASUREMENT (1, i_measurement),
|
||||
digests[3 + i_measurement], PCR_DIGEST_LENGTH);
|
||||
pcr_store_update_event_type (&store, PCR_MEASUREMENT (1, i_measurement),
|
||||
0x0A + i_measurement + 3);
|
||||
}
|
||||
|
||||
status = pcr_store_get_tcg_log (&store, &hash.base, sizeof (struct pcr_store_tcg_log_entry),
|
||||
|
@ -1802,6 +1885,7 @@ static void pcr_store_test_get_tcg_log_invalid_offset (CuTest *test)
|
|||
exp_buf[i_measurement].entry.digest_algorithm_id = 0x0B;
|
||||
exp_buf[i_measurement].entry.digest_count = 1;
|
||||
exp_buf[i_measurement].entry.measurement_size = 32;
|
||||
exp_buf[i_measurement].entry.event_type = 0x0A + i_measurement;
|
||||
|
||||
memcpy (exp_buf[i_measurement].entry.digest, digests[i_measurement],
|
||||
sizeof (exp_buf[i_measurement].entry.digest));
|
||||
|
@ -1809,12 +1893,10 @@ static void pcr_store_test_get_tcg_log_invalid_offset (CuTest *test)
|
|||
sizeof (exp_buf[i_measurement].entry.measurement));
|
||||
|
||||
if (i_measurement >= 3) {
|
||||
exp_buf[i_measurement].entry.measurement_index = i_measurement - 3;
|
||||
exp_buf[i_measurement].entry.measurement_type =
|
||||
PCR_MEASUREMENT (1, (i_measurement - 3));
|
||||
}
|
||||
else {
|
||||
exp_buf[i_measurement].entry.measurement_index = i_measurement;
|
||||
exp_buf[i_measurement].entry.measurement_type = PCR_MEASUREMENT (0, i_measurement);
|
||||
}
|
||||
}
|
||||
|
@ -1884,11 +1966,15 @@ static void pcr_store_test_get_tcg_log_invalid_offset (CuTest *test)
|
|||
for (i_measurement = 0; i_measurement < 3; ++i_measurement) {
|
||||
pcr_store_update_digest (&store, PCR_MEASUREMENT (0, i_measurement), digests[i_measurement],
|
||||
PCR_DIGEST_LENGTH);
|
||||
pcr_store_update_event_type (&store, PCR_MEASUREMENT (0, i_measurement),
|
||||
0x0A + i_measurement);
|
||||
}
|
||||
|
||||
for (i_measurement = 0; i_measurement < 3; ++i_measurement) {
|
||||
pcr_store_update_digest (&store, PCR_MEASUREMENT (1, i_measurement),
|
||||
digests[3 + i_measurement], PCR_DIGEST_LENGTH);
|
||||
pcr_store_update_event_type (&store, PCR_MEASUREMENT (1, i_measurement),
|
||||
0x0A + i_measurement + 3);
|
||||
}
|
||||
|
||||
status = pcr_store_get_tcg_log (&store, &hash.base, 6 * sizeof (struct pcr_store_tcg_log_entry),
|
||||
|
@ -2086,6 +2172,10 @@ CuSuite* get_pcr_store_suite ()
|
|||
SUITE_ADD_TEST (suite, pcr_store_test_update_buffer_invalid_arg);
|
||||
SUITE_ADD_TEST (suite, pcr_store_test_update_buffer_invalid_pcr);
|
||||
SUITE_ADD_TEST (suite, pcr_store_test_update_buffer_update_fail);
|
||||
SUITE_ADD_TEST (suite, pcr_store_test_update_event_type);
|
||||
SUITE_ADD_TEST (suite, pcr_store_test_update_event_type_invalid_arg);
|
||||
SUITE_ADD_TEST (suite, pcr_store_test_update_event_type_invalid_pcr);
|
||||
SUITE_ADD_TEST (suite, pcr_store_test_update_event_type_update_fail);
|
||||
SUITE_ADD_TEST (suite, pcr_store_test_compute);
|
||||
SUITE_ADD_TEST (suite, pcr_store_test_compute_explicit);
|
||||
SUITE_ADD_TEST (suite, pcr_store_test_compute_invalid_arg);
|
||||
|
|
|
@ -439,6 +439,72 @@ static void pcr_test_update_buffer_update_digest_fail (CuTest *test)
|
|||
complete_pcr_mock_test (test, &pcr, &hash);
|
||||
}
|
||||
|
||||
static void pcr_test_update_event_type (CuTest *test)
|
||||
{
|
||||
struct pcr_bank pcr;
|
||||
struct hash_engine_mock hash;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
||||
setup_pcr_mock_test (test, &pcr, &hash, 5);
|
||||
|
||||
status = pcr_update_event_type (&pcr, 2, 0x0A);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
CuAssertIntEquals (test, 0x0A, pcr.measurement_list[2].event_type);
|
||||
|
||||
complete_pcr_mock_test (test, &pcr, &hash);
|
||||
}
|
||||
|
||||
static void pcr_test_update_event_type_explicit (CuTest *test)
|
||||
{
|
||||
struct pcr_bank pcr;
|
||||
struct hash_engine_mock hash;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
||||
setup_pcr_mock_test (test, &pcr, &hash, 0);
|
||||
|
||||
status = pcr_update_event_type (&pcr, 0, 0x0A);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
CuAssertIntEquals (test, 0x0A, pcr.measurement_list[0].event_type);
|
||||
|
||||
complete_pcr_mock_test (test, &pcr, &hash);
|
||||
}
|
||||
|
||||
static void pcr_test_update_event_type_invalid_arg (CuTest *test)
|
||||
{
|
||||
struct pcr_bank pcr;
|
||||
struct hash_engine_mock hash;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
||||
setup_pcr_mock_test (test, &pcr, &hash, 5);
|
||||
|
||||
status = pcr_update_event_type (NULL, 2, 0x0A);
|
||||
CuAssertIntEquals (test, PCR_INVALID_ARGUMENT, status);
|
||||
|
||||
complete_pcr_mock_test (test, &pcr, &hash);
|
||||
}
|
||||
|
||||
static void pcr_test_update_event_type_invalid_index (CuTest *test)
|
||||
{
|
||||
struct pcr_bank pcr;
|
||||
struct hash_engine_mock hash;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
||||
setup_pcr_mock_test (test, &pcr, &hash, 1);
|
||||
|
||||
status = pcr_update_event_type (&pcr, 2, 0x0A);
|
||||
CuAssertIntEquals (test, PCR_INVALID_INDEX, status);
|
||||
|
||||
complete_pcr_mock_test (test, &pcr, &hash);
|
||||
}
|
||||
|
||||
static void pcr_test_compute (CuTest *test)
|
||||
{
|
||||
struct pcr_bank pcr;
|
||||
|
@ -1325,6 +1391,10 @@ CuSuite* get_pcr_suite ()
|
|||
SUITE_ADD_TEST (suite, pcr_test_update_buffer_invalid_arg);
|
||||
SUITE_ADD_TEST (suite, pcr_test_update_buffer_hash_fail);
|
||||
SUITE_ADD_TEST (suite, pcr_test_update_buffer_update_digest_fail);
|
||||
SUITE_ADD_TEST (suite, pcr_test_update_event_type);
|
||||
SUITE_ADD_TEST (suite, pcr_test_update_event_type_explicit);
|
||||
SUITE_ADD_TEST (suite, pcr_test_update_event_type_invalid_arg);
|
||||
SUITE_ADD_TEST (suite, pcr_test_update_event_type_invalid_index);
|
||||
SUITE_ADD_TEST (suite, pcr_test_compute);
|
||||
SUITE_ADD_TEST (suite, pcr_test_compute_explicit);
|
||||
SUITE_ADD_TEST (suite, pcr_test_compute_no_lock);
|
||||
|
|
|
@ -184,7 +184,8 @@ static void recovery_image_observer_pcr_test_on_recovery_image_activated_hash_er
|
|||
status = recovery_image_mock_init (&image);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = recovery_image_observer_pcr_init (&observer, &hash.base, &store, PCR_MEASUREMENT (0, 0));
|
||||
status = recovery_image_observer_pcr_init (&observer, &hash.base, &store,
|
||||
PCR_MEASUREMENT (0, 0));
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = pcr_store_get_measurement (&store, PCR_MEASUREMENT (0, 0), &measurement);
|
||||
|
|
Загрузка…
Ссылка в новой задаче