Switch encoding of AR Identity Value from binary to UTF-8

This commit is contained in:
Andreas Steffen
2013-03-22 10:37:49 +01:00
parent 3db17b0ccc
commit a1bc67d6c9
14 changed files with 123 additions and 118 deletions
+14 -18
View File
@@ -805,13 +805,12 @@ METHOD(attest_db_t, list_devices, void,
private_attest_db_t *this)
{
enumerator_t *e, *e_ar;
chunk_t value, ar_data;
chunk_t value, ar_id_value = chunk_empty;
char *product;
time_t timestamp;
int id, last_id = 0, iid = 0, last_iid = 0, device_count = 0;
int id, last_id = 0, ar_id = 0, last_ar_id = 0, device_count = 0;
int count, count_update, count_blacklist;
id_type_t ar_type;
identification_t *ar_id = NULL;
u_int32_t ar_id_type;
u_int tstamp, flags = 0;
e = this->db->query(this->db,
@@ -826,7 +825,7 @@ METHOD(attest_db_t, list_devices, void,
if (e)
{
while (e->enumerate(e, &id, &value, &tstamp, &count, &count_update,
&count_blacklist, &flags, &iid, &product))
&count_blacklist, &flags, &ar_id, &product))
{
if (id != last_id)
{
@@ -837,32 +836,29 @@ METHOD(attest_db_t, list_devices, void,
timestamp = tstamp;
printf(" %T, %4d, %3d, %3d, %1u, '%s'", &timestamp, this->utc,
count, count_update, count_blacklist, flags, product);
if (iid)
if (ar_id)
{
if (iid != last_iid)
if (ar_id != last_ar_id)
{
DESTROY_IF(ar_id);
ar_id = NULL;
chunk_free(&ar_id_value);
e_ar = this->db->query(this->db,
"SELECT type, data FROM identities "
"WHERE id = ?", DB_INT, iid, DB_INT, DB_BLOB);
if (e_ar->enumerate(e_ar, &ar_type, &ar_data))
"WHERE id = ?", DB_INT, ar_id, DB_INT, DB_BLOB);
if (e_ar)
{
ar_id = identification_create_from_encoding(ar_type,
ar_data);
e_ar->enumerate(e_ar, &ar_id_type, &ar_id_value);
e_ar->destroy(e_ar);
}
e_ar->destroy(e_ar);
}
if (ar_id)
if (ar_id_value.len)
{
printf(" %Y", ar_id);
printf(" %.*s", ar_id_value.len, ar_id_value.ptr);
}
}
printf("\n");
}
e->destroy(e);
DESTROY_IF(ar_id);
free(ar_id_value.ptr);
printf("%d device%s found\n", device_count,
(device_count == 1) ? "" : "s");
@@ -64,9 +64,14 @@ struct private_imv_attestation_state_t {
u_int32_t max_msg_len;
/**
* Access Requestor ID
* Access Requestor ID Type
*/
identification_t *ar_id;
u_int32_t ar_id_type;
/**
* Access Requestor ID Value
*/
chunk_t ar_id_value;
/**
* IMV Attestation handshake state
@@ -222,16 +227,20 @@ METHOD(imv_state_t, get_max_msg_len, u_int32_t,
}
METHOD(imv_state_t, set_ar_id, void,
private_imv_attestation_state_t *this, identification_t *ar_id)
private_imv_attestation_state_t *this, u_int32_t id_type, chunk_t id_value)
{
/* no cloning, caller must not destroy object */
this->ar_id = ar_id;
this->ar_id_type = id_type;
this->ar_id_value = chunk_clone(id_value);
}
METHOD(imv_state_t, get_ar_id, identification_t*,
private_imv_attestation_state_t *this)
METHOD(imv_state_t, get_ar_id, chunk_t,
private_imv_attestation_state_t *this, u_int32_t *id_type)
{
return this->ar_id;
if (id_type)
{
*id_type = this->ar_id_type;
}
return this->ar_id_value;
}
METHOD(imv_state_t, change_state, void,
@@ -307,11 +316,11 @@ METHOD(imv_state_t, get_remediation_instructions, bool,
METHOD(imv_state_t, destroy, void,
private_imv_attestation_state_t *this)
{
DESTROY_IF(this->ar_id);
DESTROY_IF(this->reason_string);
this->file_meas_requests->destroy_function(this->file_meas_requests, free);
this->components->destroy_function(this->components, (void *)free_func_comp);
this->pts->destroy(this->pts);
free(this->ar_id_value.ptr);
free(this);
}