Implemented TCG PTS Attributes
This commit is contained in:
committed by
Andreas Steffen
parent
0973ec9906
commit
3b80bce8c1
@@ -0,0 +1,248 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "tcg_pts_attr_aik.h"
|
||||||
|
|
||||||
|
#include <pa_tnc/pa_tnc_msg.h>
|
||||||
|
#include <bio/bio_writer.h>
|
||||||
|
#include <bio/bio_reader.h>
|
||||||
|
#include <debug.h>
|
||||||
|
|
||||||
|
typedef struct private_tcg_pts_attr_aik_t private_tcg_pts_attr_aik_t;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attestation Identity Key (see section 3.13 of PTS Protocol: Binding to TNC IF-M Specification)
|
||||||
|
*
|
||||||
|
* 1 2 3
|
||||||
|
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
||||||
|
*
|
||||||
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
|
* | Flags | Attestation Identity Key (Variable Lenght) ~
|
||||||
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
|
* | Attestation Identity Key (Variable Lenght) ~
|
||||||
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define PTS_AIK_SIZE 4
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Private data of an private_tcg_pts_attr_aik_t object.
|
||||||
|
*/
|
||||||
|
struct private_tcg_pts_attr_aik_t {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Public members of private_tcg_pts_attr_tpm_version_info_t
|
||||||
|
*/
|
||||||
|
tcg_pts_attr_aik_t public;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attribute vendor ID
|
||||||
|
*/
|
||||||
|
pen_t vendor_id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attribute type
|
||||||
|
*/
|
||||||
|
u_int32_t type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attribute value
|
||||||
|
*/
|
||||||
|
chunk_t value;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Noskip flag
|
||||||
|
*/
|
||||||
|
bool noskip_flag;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Naked Public Key flag
|
||||||
|
*/
|
||||||
|
bool naked_pub_aik;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attestation Identity Key
|
||||||
|
*/
|
||||||
|
chunk_t aik;
|
||||||
|
};
|
||||||
|
|
||||||
|
METHOD(pa_tnc_attr_t, get_vendor_id, pen_t,
|
||||||
|
private_tcg_pts_attr_aik_t *this)
|
||||||
|
{
|
||||||
|
return this->vendor_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
METHOD(pa_tnc_attr_t, get_type, u_int32_t,
|
||||||
|
private_tcg_pts_attr_aik_t *this)
|
||||||
|
{
|
||||||
|
return this->type;
|
||||||
|
}
|
||||||
|
|
||||||
|
METHOD(pa_tnc_attr_t, get_value, chunk_t,
|
||||||
|
private_tcg_pts_attr_aik_t *this)
|
||||||
|
{
|
||||||
|
return this->value;
|
||||||
|
}
|
||||||
|
|
||||||
|
METHOD(pa_tnc_attr_t, get_noskip_flag, bool,
|
||||||
|
private_tcg_pts_attr_aik_t *this)
|
||||||
|
{
|
||||||
|
return this->noskip_flag;
|
||||||
|
}
|
||||||
|
|
||||||
|
METHOD(pa_tnc_attr_t, set_noskip_flag,void,
|
||||||
|
private_tcg_pts_attr_aik_t *this, bool noskip)
|
||||||
|
{
|
||||||
|
this->noskip_flag = noskip;
|
||||||
|
}
|
||||||
|
|
||||||
|
METHOD(pa_tnc_attr_t, build, void,
|
||||||
|
private_tcg_pts_attr_aik_t *this)
|
||||||
|
{
|
||||||
|
bio_writer_t *writer;
|
||||||
|
u_int8_t flags = 0;
|
||||||
|
|
||||||
|
writer = bio_writer_create(PTS_AIK_SIZE);
|
||||||
|
|
||||||
|
if(this->naked_pub_aik) flags += 128;
|
||||||
|
writer->write_uint8 (writer, flags);
|
||||||
|
writer->write_data(writer, this->aik);
|
||||||
|
|
||||||
|
this->value = chunk_clone(writer->get_buf(writer));
|
||||||
|
writer->destroy(writer);
|
||||||
|
}
|
||||||
|
|
||||||
|
METHOD(pa_tnc_attr_t, process, status_t,
|
||||||
|
private_tcg_pts_attr_aik_t *this)
|
||||||
|
{
|
||||||
|
bio_reader_t *reader;
|
||||||
|
u_int8_t flags;
|
||||||
|
|
||||||
|
if (this->value.len < PTS_AIK_SIZE)
|
||||||
|
{
|
||||||
|
DBG1(DBG_TNC, "insufficient data for Attestation Identity Key");
|
||||||
|
return FAILED;
|
||||||
|
}
|
||||||
|
reader = bio_reader_create(this->value);
|
||||||
|
|
||||||
|
reader->read_uint8(reader, &flags);
|
||||||
|
if(flags) this->naked_pub_aik = true;
|
||||||
|
|
||||||
|
reader->read_data (reader, sizeof(this->value - 1), &this->aik);
|
||||||
|
this->aik = chunk_clone(this->aik);
|
||||||
|
reader->destroy(reader);
|
||||||
|
|
||||||
|
return SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
METHOD(pa_tnc_attr_t, destroy, void,
|
||||||
|
private_tcg_pts_attr_aik_t *this)
|
||||||
|
{
|
||||||
|
free(this->value.ptr);
|
||||||
|
free(this->aik.ptr);
|
||||||
|
free(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
METHOD(pa_tnc_attr_t, get_naked_flag, bool,
|
||||||
|
private_tcg_pts_attr_aik_t *this)
|
||||||
|
{
|
||||||
|
return this->naked_pub_aik;
|
||||||
|
}
|
||||||
|
|
||||||
|
METHOD(pa_tnc_attr_t, set_naked_flag,void,
|
||||||
|
private_tcg_pts_attr_aik_t *this, bool naked)
|
||||||
|
{
|
||||||
|
this->naked_pub_aik = naked;
|
||||||
|
}
|
||||||
|
|
||||||
|
METHOD(tcg_pts_attr_aik_t, get_aik, chunk_t,
|
||||||
|
private_tcg_pts_attr_aik_t *this)
|
||||||
|
{
|
||||||
|
return this->aik;
|
||||||
|
}
|
||||||
|
|
||||||
|
METHOD(tcg_pts_attr_aik_t, set_aik, void,
|
||||||
|
private_tcg_pts_attr_aik_t *this,
|
||||||
|
chunk_t aik)
|
||||||
|
{
|
||||||
|
return this->aik = aik;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Described in header.
|
||||||
|
*/
|
||||||
|
pa_tnc_attr_t *tcg_pts_attr_tpm_version_info_create(bool naked_pub_aik, chunk_t aik)
|
||||||
|
{
|
||||||
|
private_tcg_pts_attr_aik_t *this;
|
||||||
|
|
||||||
|
INIT(this,
|
||||||
|
.public = {
|
||||||
|
.pa_tnc_attribute = {
|
||||||
|
.get_vendor_id = _get_vendor_id,
|
||||||
|
.get_type = _get_type,
|
||||||
|
.get_value = _get_value,
|
||||||
|
.get_noskip_flag = _get_noskip_flag,
|
||||||
|
.set_noskip_flag = _set_noskip_flag,
|
||||||
|
.build = _build,
|
||||||
|
.process = _process,
|
||||||
|
.destroy = _destroy,
|
||||||
|
},
|
||||||
|
.get_naked_flag = get_naked_flag,
|
||||||
|
.set_naked_flag = set_naked_flag,
|
||||||
|
.get_aik = get_aik,
|
||||||
|
.set_aik = set_aik,
|
||||||
|
},
|
||||||
|
.vendor_id = PEN_TCG,
|
||||||
|
.type = TCG_PTS_AIK,
|
||||||
|
.naked_pub_aik = naked_pub_aik;
|
||||||
|
.aik = aik,
|
||||||
|
);
|
||||||
|
|
||||||
|
return &this->public.pa_tnc_attribute;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Described in header.
|
||||||
|
*/
|
||||||
|
pa_tnc_attr_t *tcg_pts_attr_tpm_version_info_create_from_data(chunk_t data)
|
||||||
|
{
|
||||||
|
private_tcg_pts_attr_aik_t *this;
|
||||||
|
|
||||||
|
INIT(this,
|
||||||
|
.public = {
|
||||||
|
.pa_tnc_attribute = {
|
||||||
|
.get_vendor_id = _get_vendor_id,
|
||||||
|
.get_type = _get_type,
|
||||||
|
.get_value = _get_value,
|
||||||
|
.get_noskip_flag = _get_noskip_flag,
|
||||||
|
.set_noskip_flag = _set_noskip_flag,
|
||||||
|
.build = _build,
|
||||||
|
.process = _process,
|
||||||
|
.destroy = _destroy,
|
||||||
|
},
|
||||||
|
.get_naked_flag = get_naked_flag,
|
||||||
|
.set_naked_flag = set_naked_flag,
|
||||||
|
.get_aik = get_aik,
|
||||||
|
.set_aik = set_aik,
|
||||||
|
},
|
||||||
|
.vendor_id = PEN_TCG,
|
||||||
|
.type = TCG_PTS_AIK,
|
||||||
|
.value = chunk_clone(data),
|
||||||
|
);
|
||||||
|
|
||||||
|
return &this->public.pa_tnc_attribute;
|
||||||
|
}
|
||||||
@@ -0,0 +1,86 @@
|
|||||||
|
/*
|
||||||
|
* 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_attr_aik tcg_pts_attr_aik
|
||||||
|
* @{ @ingroup tcg_pts_attr_aik
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef TCG_PTS_ATTR_AIK_H_
|
||||||
|
#define TCG_PTS_ATTR_AIK_H_
|
||||||
|
|
||||||
|
typedef struct tcg_pts_attr_aik_t tcg_pts_attr_aik_t;
|
||||||
|
|
||||||
|
#include "tcg_attr.h"
|
||||||
|
#include "pa_tnc/pa_tnc_attr.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class implementing the TCG PTS Attestation Identity Key attribute
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
struct tcg_pts_attr_aik_t {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Public PA-TNC attribute interface
|
||||||
|
*/
|
||||||
|
pa_tnc_attr_t pa_tnc_attribute;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Naked Public Key flag
|
||||||
|
*
|
||||||
|
* @return Naked Public Key flag
|
||||||
|
*/
|
||||||
|
bool (*get_naked_flag)(tcg_pts_attr_aik_t *this);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set Naked Public Key flag
|
||||||
|
*
|
||||||
|
* @param naked flag
|
||||||
|
*/
|
||||||
|
void (*set_naked_flag)(tcg_pts_attr_aik_t *this,
|
||||||
|
bool naked);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get AIK
|
||||||
|
*
|
||||||
|
* @return Attestation Identity Key
|
||||||
|
*/
|
||||||
|
chunk_t (*get_aik)(tcg_pts_attr_aik_t *this);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set AIK
|
||||||
|
*
|
||||||
|
* @param flags set of flags
|
||||||
|
*/
|
||||||
|
void (*set_aik)(tcg_pts_attr_aik_t *this,
|
||||||
|
chunk_t aik);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an tcg_pts_attr_aik_t object
|
||||||
|
*
|
||||||
|
* @param naked_pub_aik Sender only has naked public key
|
||||||
|
* @param aik Attestation Identity Key
|
||||||
|
*/
|
||||||
|
pa_tnc_attr_t* tcg_pts_attr_aik_create(bool naked_pub_aik, chunk_t aik);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an tcg_pts_attr_aik_t object from received data
|
||||||
|
*
|
||||||
|
* @param value unparsed attribute value
|
||||||
|
*/
|
||||||
|
pa_tnc_attr_t* tcg_pts_attr_aik_create_from_data(chunk_t value);
|
||||||
|
|
||||||
|
#endif /** TCG_PTS_ATTR_AIK_H_ @}*/
|
||||||
@@ -0,0 +1,192 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "tcg_pts_attr_get_aik.h"
|
||||||
|
|
||||||
|
#include <pa_tnc/pa_tnc_msg.h>
|
||||||
|
#include <bio/bio_writer.h>
|
||||||
|
#include <bio/bio_reader.h>
|
||||||
|
#include <debug.h>
|
||||||
|
|
||||||
|
typedef struct private_tcg_pts_attr_get_aik_t private_tcg_pts_attr_get_aik_t;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Attestation Identity Key (see section 3.12 of PTS Protocol: Binding to TNC IF-M Specification)
|
||||||
|
*
|
||||||
|
* 1 2 3
|
||||||
|
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
||||||
|
*
|
||||||
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
|
* | Reserved |
|
||||||
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define PTS_GET_AIK_SIZE 4
|
||||||
|
#define PTS_GET_AIK_RESERVED 0x00
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Private data of an private_tcg_pts_attr_get_aik_t object.
|
||||||
|
*/
|
||||||
|
struct private_tcg_pts_attr_get_aik_t {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Public members of private_tcg_pts_attr_get_aik_t
|
||||||
|
*/
|
||||||
|
tcg_pts_attr_get_aik_t public;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attribute vendor ID
|
||||||
|
*/
|
||||||
|
pen_t vendor_id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attribute type
|
||||||
|
*/
|
||||||
|
u_int32_t type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attribute value
|
||||||
|
*/
|
||||||
|
chunk_t value;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Noskip flag
|
||||||
|
*/
|
||||||
|
bool noskip_flag;
|
||||||
|
};
|
||||||
|
|
||||||
|
METHOD(pa_tnc_attr_t, get_vendor_id, pen_t,
|
||||||
|
private_tcg_pts_attr_get_aik_t *this)
|
||||||
|
{
|
||||||
|
return this->vendor_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
METHOD(pa_tnc_attr_t, get_type, u_int32_t,
|
||||||
|
private_tcg_pts_attr_get_aik_t *this)
|
||||||
|
{
|
||||||
|
return this->type;
|
||||||
|
}
|
||||||
|
|
||||||
|
METHOD(pa_tnc_attr_t, get_value, chunk_t,
|
||||||
|
private_tcg_pts_attr_get_aik_t *this)
|
||||||
|
{
|
||||||
|
return this->value;
|
||||||
|
}
|
||||||
|
|
||||||
|
METHOD(pa_tnc_attr_t, get_noskip_flag, bool,
|
||||||
|
private_tcg_pts_attr_get_aik_t *this)
|
||||||
|
{
|
||||||
|
return this->noskip_flag;
|
||||||
|
}
|
||||||
|
|
||||||
|
METHOD(pa_tnc_attr_t, set_noskip_flag,void,
|
||||||
|
private_tcg_pts_attr_get_aik_t *this, bool noskip)
|
||||||
|
{
|
||||||
|
this->noskip_flag = noskip;
|
||||||
|
}
|
||||||
|
|
||||||
|
METHOD(pa_tnc_attr_t, build, void,
|
||||||
|
private_tcg_pts_attr_get_aik_t *this)
|
||||||
|
{
|
||||||
|
bio_writer_t *writer;
|
||||||
|
|
||||||
|
writer = bio_writer_create(PTS_GET_AIK_SIZE);
|
||||||
|
writer->write_uint32 (writer, PTS_GET_AIK_RESERVED);
|
||||||
|
|
||||||
|
this->value = chunk_clone(writer->get_buf(writer));
|
||||||
|
writer->destroy(writer);
|
||||||
|
}
|
||||||
|
|
||||||
|
METHOD(pa_tnc_attr_t, process, status_t,
|
||||||
|
private_tcg_pts_attr_get_aik_t *this)
|
||||||
|
{
|
||||||
|
bio_reader_t *reader;
|
||||||
|
u_int32_t reserved;
|
||||||
|
|
||||||
|
if (this->value.len < PTS_GET_AIK_SIZE)
|
||||||
|
{
|
||||||
|
DBG1(DBG_TNC, "insufficient data for Get AIK");
|
||||||
|
return FAILED;
|
||||||
|
}
|
||||||
|
reader = bio_reader_create(this->value);
|
||||||
|
reader->read_uint32 (reader, &reserved);
|
||||||
|
reader->destroy(reader);
|
||||||
|
|
||||||
|
return SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
METHOD(pa_tnc_attr_t, destroy, void,
|
||||||
|
private_tcg_pts_attr_get_aik_t *this)
|
||||||
|
{
|
||||||
|
free(this->value.ptr);
|
||||||
|
free(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Described in header.
|
||||||
|
*/
|
||||||
|
pa_tnc_attr_t *tcg_pts_attr_get_aik_create()
|
||||||
|
{
|
||||||
|
private_tcg_pts_attr_get_aik_t *this;
|
||||||
|
|
||||||
|
INIT(this,
|
||||||
|
.public = {
|
||||||
|
.pa_tnc_attribute = {
|
||||||
|
.get_vendor_id = _get_vendor_id,
|
||||||
|
.get_type = _get_type,
|
||||||
|
.get_value = _get_value,
|
||||||
|
.get_noskip_flag = _get_noskip_flag,
|
||||||
|
.set_noskip_flag = _set_noskip_flag,
|
||||||
|
.build = _build,
|
||||||
|
.process = _process,
|
||||||
|
.destroy = _destroy,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
.vendor_id = PEN_TCG,
|
||||||
|
.type = TCG_PTS_GET_AIK,
|
||||||
|
);
|
||||||
|
|
||||||
|
return &this->public.pa_tnc_attribute;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Described in header.
|
||||||
|
*/
|
||||||
|
pa_tnc_attr_t *tcg_pts_attr_get_aik_create_from_data(chunk_t data)
|
||||||
|
{
|
||||||
|
private_tcg_pts_attr_get_aik_t *this;
|
||||||
|
|
||||||
|
INIT(this,
|
||||||
|
.public = {
|
||||||
|
.pa_tnc_attribute = {
|
||||||
|
.get_vendor_id = _get_vendor_id,
|
||||||
|
.get_type = _get_type,
|
||||||
|
.get_value = _get_value,
|
||||||
|
.get_noskip_flag = _get_noskip_flag,
|
||||||
|
.set_noskip_flag = _set_noskip_flag,
|
||||||
|
.build = _build,
|
||||||
|
.process = _process,
|
||||||
|
.destroy = _destroy,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
.vendor_id = PEN_TCG,
|
||||||
|
.type = TCG_PTS_GET_AIK,
|
||||||
|
.value = chunk_clone(data),
|
||||||
|
);
|
||||||
|
|
||||||
|
return &this->public.pa_tnc_attribute;
|
||||||
|
}
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
/*
|
||||||
|
* 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_attr_get_aik tcg_pts_attr_get_aik
|
||||||
|
* @{ @ingroup tcg_pts_attr_get_aik
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef TCG_PTS_ATTR_GET_AIK_H_
|
||||||
|
#define TCG_PTS_ATTR_GET_AIK_H_
|
||||||
|
|
||||||
|
typedef struct tcg_pts_attr_get_aik_t tcg_pts_attr_get_aik_t;
|
||||||
|
|
||||||
|
#include "tcg_attr.h"
|
||||||
|
#include "pa_tnc/pa_tnc_attr.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class implementing the TCG PTS Get Attestation Identity Key Attribute
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
struct tcg_pts_attr_get_aik_t {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Public PA-TNC attribute interface
|
||||||
|
*/
|
||||||
|
pa_tnc_attr_t pa_tnc_attribute;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an tcg_pts_attr_get_aik_t object
|
||||||
|
*/
|
||||||
|
pa_tnc_attr_t* tcg_pts_attr_get_aik_create();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an tcg_pts_attr_get_aik_t object from received data
|
||||||
|
*
|
||||||
|
* @param value unparsed attribute value
|
||||||
|
*/
|
||||||
|
pa_tnc_attr_t* tcg_pts_attr_get_aik_create_from_data(chunk_t value);
|
||||||
|
|
||||||
|
#endif /** TCG_PTS_ATTR_GET_AIK_H_ @}*/
|
||||||
@@ -0,0 +1,192 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "tcg_pts_attr_get_tpm_version_info.h"
|
||||||
|
|
||||||
|
#include <pa_tnc/pa_tnc_msg.h>
|
||||||
|
#include <bio/bio_writer.h>
|
||||||
|
#include <bio/bio_reader.h>
|
||||||
|
#include <debug.h>
|
||||||
|
|
||||||
|
typedef struct private_tcg_pts_attr_get_tpm_version_info_t private_tcg_pts_attr_get_tpm_version_info_t;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get TPM Version Information (see section 3.10 of PTS Protocol: Binding to TNC IF-M Specification)
|
||||||
|
*
|
||||||
|
* 1 2 3
|
||||||
|
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
||||||
|
*
|
||||||
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
|
* | Reserved |
|
||||||
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define PTS_GET_TPM_VER_INFO_SIZE 4
|
||||||
|
#define PTS_GET_TPM_VER_INFO_RESERVED 0x00
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Private data of an private_tcg_pts_attr_get_tpm_version_info_t object.
|
||||||
|
*/
|
||||||
|
struct private_tcg_pts_attr_get_tpm_version_info_t {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Public members of private_tcg_pts_attr_req_proto_caps_t
|
||||||
|
*/
|
||||||
|
tcg_pts_attr_get_tpm_version_info_t public;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attribute vendor ID
|
||||||
|
*/
|
||||||
|
pen_t vendor_id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attribute type
|
||||||
|
*/
|
||||||
|
u_int32_t type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attribute value
|
||||||
|
*/
|
||||||
|
chunk_t value;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Noskip flag
|
||||||
|
*/
|
||||||
|
bool noskip_flag;
|
||||||
|
};
|
||||||
|
|
||||||
|
METHOD(pa_tnc_attr_t, get_vendor_id, pen_t,
|
||||||
|
private_tcg_pts_attr_get_tpm_version_info_t *this)
|
||||||
|
{
|
||||||
|
return this->vendor_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
METHOD(pa_tnc_attr_t, get_type, u_int32_t,
|
||||||
|
private_tcg_pts_attr_get_tpm_version_info_t *this)
|
||||||
|
{
|
||||||
|
return this->type;
|
||||||
|
}
|
||||||
|
|
||||||
|
METHOD(pa_tnc_attr_t, get_value, chunk_t,
|
||||||
|
private_tcg_pts_attr_get_tpm_version_info_t *this)
|
||||||
|
{
|
||||||
|
return this->value;
|
||||||
|
}
|
||||||
|
|
||||||
|
METHOD(pa_tnc_attr_t, get_noskip_flag, bool,
|
||||||
|
private_tcg_pts_attr_get_tpm_version_info_t *this)
|
||||||
|
{
|
||||||
|
return this->noskip_flag;
|
||||||
|
}
|
||||||
|
|
||||||
|
METHOD(pa_tnc_attr_t, set_noskip_flag,void,
|
||||||
|
private_tcg_pts_attr_get_tpm_version_info_t *this, bool noskip)
|
||||||
|
{
|
||||||
|
this->noskip_flag = noskip;
|
||||||
|
}
|
||||||
|
|
||||||
|
METHOD(pa_tnc_attr_t, build, void,
|
||||||
|
private_tcg_pts_attr_get_tpm_version_info_t *this)
|
||||||
|
{
|
||||||
|
bio_writer_t *writer;
|
||||||
|
|
||||||
|
writer = bio_writer_create(PTS_GET_TPM_VER_INFO_SIZE);
|
||||||
|
writer->write_uint32 (writer, PTS_GET_TPM_VER_INFO_RESERVED);
|
||||||
|
|
||||||
|
this->value = chunk_clone(writer->get_buf(writer));
|
||||||
|
writer->destroy(writer);
|
||||||
|
}
|
||||||
|
|
||||||
|
METHOD(pa_tnc_attr_t, process, status_t,
|
||||||
|
private_tcg_pts_attr_get_tpm_version_info_t *this)
|
||||||
|
{
|
||||||
|
bio_reader_t *reader;
|
||||||
|
u_int32_t reserved;
|
||||||
|
|
||||||
|
if (this->value.len < PTS_GET_TPM_VER_INFO_SIZE)
|
||||||
|
{
|
||||||
|
DBG1(DBG_TNC, "insufficient data for Get TPM Version Information");
|
||||||
|
return FAILED;
|
||||||
|
}
|
||||||
|
reader = bio_reader_create(this->value);
|
||||||
|
reader->read_uint32 (reader, &reserved);
|
||||||
|
reader->destroy(reader);
|
||||||
|
|
||||||
|
return SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
METHOD(pa_tnc_attr_t, destroy, void,
|
||||||
|
private_tcg_pts_attr_get_tpm_version_info_t *this)
|
||||||
|
{
|
||||||
|
free(this->value.ptr);
|
||||||
|
free(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Described in header.
|
||||||
|
*/
|
||||||
|
pa_tnc_attr_t *tcg_pts_attr_get_tpm_version_info_create()
|
||||||
|
{
|
||||||
|
private_tcg_pts_attr_get_tpm_version_info_t *this;
|
||||||
|
|
||||||
|
INIT(this,
|
||||||
|
.public = {
|
||||||
|
.pa_tnc_attribute = {
|
||||||
|
.get_vendor_id = _get_vendor_id,
|
||||||
|
.get_type = _get_type,
|
||||||
|
.get_value = _get_value,
|
||||||
|
.get_noskip_flag = _get_noskip_flag,
|
||||||
|
.set_noskip_flag = _set_noskip_flag,
|
||||||
|
.build = _build,
|
||||||
|
.process = _process,
|
||||||
|
.destroy = _destroy,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
.vendor_id = PEN_TCG,
|
||||||
|
.type = TCG_PTS_GET_TPM_VERSION_INFO,
|
||||||
|
);
|
||||||
|
|
||||||
|
return &this->public.pa_tnc_attribute;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Described in header.
|
||||||
|
*/
|
||||||
|
pa_tnc_attr_t *tcg_pts_attr_get_tpm_version_info_create_from_data(chunk_t data)
|
||||||
|
{
|
||||||
|
private_tcg_pts_attr_get_tpm_version_info_t *this;
|
||||||
|
|
||||||
|
INIT(this,
|
||||||
|
.public = {
|
||||||
|
.pa_tnc_attribute = {
|
||||||
|
.get_vendor_id = _get_vendor_id,
|
||||||
|
.get_type = _get_type,
|
||||||
|
.get_value = _get_value,
|
||||||
|
.get_noskip_flag = _get_noskip_flag,
|
||||||
|
.set_noskip_flag = _set_noskip_flag,
|
||||||
|
.build = _build,
|
||||||
|
.process = _process,
|
||||||
|
.destroy = _destroy,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
.vendor_id = PEN_TCG,
|
||||||
|
.type = TCG_PTS_GET_TPM_VERSION_INFO,
|
||||||
|
.value = chunk_clone(data),
|
||||||
|
);
|
||||||
|
|
||||||
|
return &this->public.pa_tnc_attribute;
|
||||||
|
}
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
/*
|
||||||
|
* 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_attr_get_tpm_version_info tcg_pts_attr_get_tpm_version_info
|
||||||
|
* @{ @ingroup tcg_pts_attr_get_tpm_version_info
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef TCG_PTS_ATTR_GET_TPM_VERSION_INFO_H_
|
||||||
|
#define TCG_PTS_ATTR_GET_TPM_VERSION_INFO_H_
|
||||||
|
|
||||||
|
typedef struct tcg_pts_attr_get_tpm_version_info_t tcg_pts_attr_get_tpm_version_info_t;
|
||||||
|
|
||||||
|
#include "tcg_attr.h"
|
||||||
|
#include "pa_tnc/pa_tnc_attr.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class implementing the TCG PTS Get TPM Version Info Attribute
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
struct tcg_pts_attr_get_tpm_version_info_t {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Public PA-TNC attribute interface
|
||||||
|
*/
|
||||||
|
pa_tnc_attr_t pa_tnc_attribute;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an tcg_pts_attr_get_tpm_version_info_t object
|
||||||
|
*/
|
||||||
|
pa_tnc_attr_t* tcg_pts_attr_get_tpm_version_info_create();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an tcg_pts_attr_get_tpm_version_info_t object from received data
|
||||||
|
*
|
||||||
|
* @param value unparsed attribute value
|
||||||
|
*/
|
||||||
|
pa_tnc_attr_t* tcg_pts_attr_get_tpm_version_info_create_from_data(chunk_t value);
|
||||||
|
|
||||||
|
#endif /** TCG_PTS_ATTR_GET_TPM_VERSION_INFO_H_ @}*/
|
||||||
@@ -0,0 +1,242 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "tcg_pts_attr_meas_algo.h"
|
||||||
|
|
||||||
|
#include <pa_tnc/pa_tnc_msg.h>
|
||||||
|
#include <bio/bio_writer.h>
|
||||||
|
#include <bio/bio_reader.h>
|
||||||
|
#include <debug.h>
|
||||||
|
|
||||||
|
typedef struct private_tcg_pts_attr_meas_algo_t private_tcg_pts_attr_meas_algo_t;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PTS Measurement Algorithm (see section 3.9.1 of PTS Protocol: Binding to TNC IF-M Specification)
|
||||||
|
*
|
||||||
|
* 1 2 3
|
||||||
|
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
||||||
|
*
|
||||||
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
|
* | Reserved | Hash Algorithm Set |
|
||||||
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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_RESERVED 0x00
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Private data of an private_tcg_pts_attr_req_proto_caps_t object.
|
||||||
|
*/
|
||||||
|
struct private_tcg_pts_attr_meas_algo_t {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Public members of private_tcg_pts_attr_meas_algo_t
|
||||||
|
*/
|
||||||
|
tcg_pts_attr_meas_algo_t public;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attribute vendor ID
|
||||||
|
*/
|
||||||
|
pen_t vendor_id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attribute type
|
||||||
|
*/
|
||||||
|
u_int32_t type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attribute value
|
||||||
|
*/
|
||||||
|
chunk_t value;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Noskip flag
|
||||||
|
*/
|
||||||
|
bool noskip_flag;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set of algorithms
|
||||||
|
*/
|
||||||
|
pts_attr_meas_algorithms_t algorithms;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
METHOD(pa_tnc_attr_t, get_vendor_id, pen_t,
|
||||||
|
private_tcg_pts_attr_meas_algo_t *this)
|
||||||
|
{
|
||||||
|
return this->vendor_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
METHOD(pa_tnc_attr_t, get_type, u_int32_t,
|
||||||
|
private_tcg_pts_attr_meas_algo_t *this)
|
||||||
|
{
|
||||||
|
return this->type;
|
||||||
|
}
|
||||||
|
|
||||||
|
METHOD(pa_tnc_attr_t, get_value, chunk_t,
|
||||||
|
private_tcg_pts_attr_meas_algo_t *this)
|
||||||
|
{
|
||||||
|
return this->value;
|
||||||
|
}
|
||||||
|
|
||||||
|
METHOD(pa_tnc_attr_t, get_noskip_flag, bool,
|
||||||
|
private_tcg_pts_attr_meas_algo_t *this)
|
||||||
|
{
|
||||||
|
return this->noskip_flag;
|
||||||
|
}
|
||||||
|
|
||||||
|
METHOD(pa_tnc_attr_t, set_noskip_flag,void,
|
||||||
|
private_tcg_pts_attr_meas_algo_t *this, bool noskip)
|
||||||
|
{
|
||||||
|
this->noskip_flag = noskip;
|
||||||
|
}
|
||||||
|
|
||||||
|
METHOD(pa_tnc_attr_t, build, void,
|
||||||
|
private_tcg_pts_attr_meas_algo_t *this)
|
||||||
|
{
|
||||||
|
bio_writer_t *writer;
|
||||||
|
u_int16_t algorithms = 0;
|
||||||
|
|
||||||
|
writer = bio_writer_create(PTS_MEAS_ALGO_SIZE);
|
||||||
|
writer->write_uint16 (writer, PTS_MEAS_ALGO_RESERVED);
|
||||||
|
|
||||||
|
/* Determine the hash algorithms to set*/
|
||||||
|
if(this->algorithms & PTS_MEAS_ALGO_SHA384) algorithms += 8192;
|
||||||
|
if(this->algorithms & PTS_MEAS_ALGO_SHA256) algorithms += 16384;
|
||||||
|
if(this->algorithms & PTS_MEAS_ALGO_SHA1) algorithms += 32768;
|
||||||
|
writer->write_uint16(writer, algorithms);
|
||||||
|
|
||||||
|
this->value = chunk_clone(writer->get_buf(writer));
|
||||||
|
writer->destroy(writer);
|
||||||
|
}
|
||||||
|
|
||||||
|
METHOD(pa_tnc_attr_t, process, status_t,
|
||||||
|
private_tcg_pts_attr_meas_algo_t *this)
|
||||||
|
{
|
||||||
|
bio_reader_t *reader;
|
||||||
|
u_int16_t reserved;
|
||||||
|
u_int16_t algorithms;
|
||||||
|
|
||||||
|
if (this->value.len < PTS_MEAS_ALGO_SIZE)
|
||||||
|
{
|
||||||
|
DBG1(DBG_TNC, "insufficient data for PTS Measurement Algorithm");
|
||||||
|
return FAILED;
|
||||||
|
}
|
||||||
|
reader = bio_reader_create(this->value);
|
||||||
|
reader->read_uint16 (reader, &reserved);
|
||||||
|
reader->read_uint16(reader, &algorithms);
|
||||||
|
|
||||||
|
if((algorithms >> 13) & 1) this->algorithms |= PTS_MEAS_ALGO_SHA384;
|
||||||
|
if((algorithms >> 14) & 1) this->algorithms |= PTS_MEAS_ALGO_SHA256;
|
||||||
|
if((algorithms >> 15) & 1) this->algorithms |= PTS_MEAS_ALGO_SHA1;
|
||||||
|
|
||||||
|
reader->destroy(reader);
|
||||||
|
|
||||||
|
return SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
METHOD(pa_tnc_attr_t, destroy, void,
|
||||||
|
private_tcg_pts_attr_meas_algo_t *this)
|
||||||
|
{
|
||||||
|
free(this->value.ptr);
|
||||||
|
free(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
METHOD(tcg_pts_attr_meas_algo_t, get_algorithms, pts_attr_meas_algorithms_t,
|
||||||
|
private_tcg_pts_attr_meas_algo_t *this)
|
||||||
|
{
|
||||||
|
return this->algorithms;
|
||||||
|
}
|
||||||
|
|
||||||
|
METHOD(tcg_pts_attr_meas_algo_t, set_algorithms, void,
|
||||||
|
private_tcg_pts_attr_meas_algo_t *this,
|
||||||
|
pts_attr_meas_algorithms_t algorithms)
|
||||||
|
{
|
||||||
|
return this->algorithms = algorithms;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Described in header.
|
||||||
|
*/
|
||||||
|
pa_tnc_attr_t *tcg_pts_attr_meas_algo_create(pts_attr_meas_algorithms_t algorithms)
|
||||||
|
{
|
||||||
|
private_tcg_pts_attr_meas_algo_t *this;
|
||||||
|
|
||||||
|
INIT(this,
|
||||||
|
.public = {
|
||||||
|
.pa_tnc_attribute = {
|
||||||
|
.get_vendor_id = _get_vendor_id,
|
||||||
|
.get_type = _get_type,
|
||||||
|
.get_value = _get_value,
|
||||||
|
.get_noskip_flag = _get_noskip_flag,
|
||||||
|
.set_noskip_flag = _set_noskip_flag,
|
||||||
|
.build = _build,
|
||||||
|
.process = _process,
|
||||||
|
.destroy = _destroy,
|
||||||
|
},
|
||||||
|
.get_algorithms = get_algorithms,
|
||||||
|
.set_algorithms = set_algorithms,
|
||||||
|
},
|
||||||
|
.vendor_id = PEN_TCG,
|
||||||
|
.type = TCG_PTS_MEAS_ALGO,
|
||||||
|
.algorithms = algorithms,
|
||||||
|
);
|
||||||
|
|
||||||
|
return &this->public.pa_tnc_attribute;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Described in header.
|
||||||
|
*/
|
||||||
|
pa_tnc_attr_t *tcg_pts_attr_meas_algo_create_from_data(chunk_t data)
|
||||||
|
{
|
||||||
|
private_tcg_pts_attr_meas_algo_t *this;
|
||||||
|
|
||||||
|
INIT(this,
|
||||||
|
.public = {
|
||||||
|
.pa_tnc_attribute = {
|
||||||
|
.get_vendor_id = _get_vendor_id,
|
||||||
|
.get_type = _get_type,
|
||||||
|
.get_value = _get_value,
|
||||||
|
.get_noskip_flag = _get_noskip_flag,
|
||||||
|
.set_noskip_flag = _set_noskip_flag,
|
||||||
|
.build = _build,
|
||||||
|
.process = _process,
|
||||||
|
.destroy = _destroy,
|
||||||
|
},
|
||||||
|
.get_algorithms = get_algorithms,
|
||||||
|
.set_algorithms = set_algorithms,
|
||||||
|
},
|
||||||
|
.vendor_id = PEN_TCG,
|
||||||
|
.type = TCG_PTS_MEAS_ALGO,
|
||||||
|
.value = chunk_clone(data),
|
||||||
|
);
|
||||||
|
|
||||||
|
return &this->public.pa_tnc_attribute;
|
||||||
|
}
|
||||||
@@ -0,0 +1,84 @@
|
|||||||
|
/*
|
||||||
|
* 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_attr_meas_algo tcg_pts_attr_meas_algo
|
||||||
|
* @{ @ingroup tcg_pts_attr_meas_algo
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef 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 enum pts_attr_meas_algorithms_t pts_attr_meas_algorithms_t;
|
||||||
|
|
||||||
|
#include "tcg_attr.h"
|
||||||
|
#include "pa_tnc/pa_tnc_attr.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PTS Measurement Algorithms
|
||||||
|
*/
|
||||||
|
enum pts_attr_meas_algorithms_t {
|
||||||
|
/** SHA-384 */
|
||||||
|
PTS_MEAS_ALGO_SHA1 = (1<<0),
|
||||||
|
/** SHA-256 */
|
||||||
|
PTS_MEAS_ALGO_SHA256 = (1<<1),
|
||||||
|
/** SHA-1 */
|
||||||
|
PTS_MEAS_ALGO_SHA384 = (1<<2),
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class implementing the TCG Measurement Algorithm Attribute
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
struct tcg_pts_attr_meas_algo_t {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Public PA-TNC attribute interface
|
||||||
|
*/
|
||||||
|
pa_tnc_attr_t pa_tnc_attribute;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get PTS Measurement Algorithm Set
|
||||||
|
*
|
||||||
|
* @return set of algorithms
|
||||||
|
*/
|
||||||
|
pts_attr_meas_algorithms_t (*get_algorithms)(tcg_pts_attr_meas_algo_t *this);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set PTS Measurement Algorithm Set
|
||||||
|
*
|
||||||
|
* @param flags set of algorithms
|
||||||
|
*/
|
||||||
|
void (*set_algorithms)(tcg_pts_attr_meas_algo_t *this,
|
||||||
|
pts_attr_meas_algorithms_t algorithms);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an tcg_pts_attr_meas_algo_t object
|
||||||
|
*
|
||||||
|
* @param algorithms set of algorithms
|
||||||
|
*/
|
||||||
|
pa_tnc_attr_t* tcg_pts_attr_meas_algo_create(pts_attr_meas_algorithms_t algorithms);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an tcg_pts_attr_meas_algo_t object from received data
|
||||||
|
*
|
||||||
|
* @param value unparsed attribute value
|
||||||
|
*/
|
||||||
|
pa_tnc_attr_t* tcg_pts_attr_meas_algo_create_from_data(chunk_t value);
|
||||||
|
|
||||||
|
#endif /** TCG_PTS_ATTR_MEAS_ALGO_H_ @}*/
|
||||||
@@ -0,0 +1,242 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "tcg_pts_attr_meas_algo_selection.h"
|
||||||
|
|
||||||
|
#include <pa_tnc/pa_tnc_msg.h>
|
||||||
|
#include <bio/bio_writer.h>
|
||||||
|
#include <bio/bio_reader.h>
|
||||||
|
#include <debug.h>
|
||||||
|
|
||||||
|
typedef struct private_tcg_pts_attr_meas_algo_selection_t private_tcg_pts_attr_meas_algo_selection_t;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PTS Measurement Algorithm Selection (see section 3.9.2 of PTS Protocol: Binding to TNC IF-M Specification)
|
||||||
|
*
|
||||||
|
* 1 2 3
|
||||||
|
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
||||||
|
*
|
||||||
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
|
* | Reserved | Hash Algorithm Set |
|
||||||
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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_SEL_SIZE 4
|
||||||
|
#define PTS_MEAS_ALGO_SEL_RESERVED 0x00
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Private data of an private_tcg_pts_attr_meas_algo_selection_t object.
|
||||||
|
*/
|
||||||
|
struct private_tcg_pts_attr_meas_algo_selection_t {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Public members of private_tcg_pts_attr_meas_algo_t
|
||||||
|
*/
|
||||||
|
tcg_pts_attr_meas_algo_selection_t public;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attribute vendor ID
|
||||||
|
*/
|
||||||
|
pen_t vendor_id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attribute type
|
||||||
|
*/
|
||||||
|
u_int32_t type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attribute value
|
||||||
|
*/
|
||||||
|
chunk_t value;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Noskip flag
|
||||||
|
*/
|
||||||
|
bool noskip_flag;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Selected Measurement Algorithm
|
||||||
|
*/
|
||||||
|
pts_attr_meas_algorithms_t algorithm;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
METHOD(pa_tnc_attr_t, get_vendor_id, pen_t,
|
||||||
|
private_tcg_pts_attr_meas_algo_selection_t *this)
|
||||||
|
{
|
||||||
|
return this->vendor_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
METHOD(pa_tnc_attr_t, get_type, u_int32_t,
|
||||||
|
private_tcg_pts_attr_meas_algo_selection_t *this)
|
||||||
|
{
|
||||||
|
return this->type;
|
||||||
|
}
|
||||||
|
|
||||||
|
METHOD(pa_tnc_attr_t, get_value, chunk_t,
|
||||||
|
private_tcg_pts_attr_meas_algo_selection_t *this)
|
||||||
|
{
|
||||||
|
return this->value;
|
||||||
|
}
|
||||||
|
|
||||||
|
METHOD(pa_tnc_attr_t, get_noskip_flag, bool,
|
||||||
|
private_tcg_pts_attr_meas_algo_selection_t *this)
|
||||||
|
{
|
||||||
|
return this->noskip_flag;
|
||||||
|
}
|
||||||
|
|
||||||
|
METHOD(pa_tnc_attr_t, set_noskip_flag,void,
|
||||||
|
private_tcg_pts_attr_meas_algo_selection_t *this, bool noskip)
|
||||||
|
{
|
||||||
|
this->noskip_flag = noskip;
|
||||||
|
}
|
||||||
|
|
||||||
|
METHOD(pa_tnc_attr_t, build, void,
|
||||||
|
private_tcg_pts_attr_meas_algo_selection_t *this)
|
||||||
|
{
|
||||||
|
bio_writer_t *writer;
|
||||||
|
u_int16_t algorithm = 0;
|
||||||
|
|
||||||
|
writer = bio_writer_create(PTS_MEAS_ALGO_SEL_SIZE);
|
||||||
|
writer->write_uint16 (writer, PTS_MEAS_ALGO_SEL_RESERVED);
|
||||||
|
|
||||||
|
/* Determine the hash algorithm to set*/
|
||||||
|
if(this->algorithm & PTS_MEAS_ALGO_SHA384) algorithm = 8192;
|
||||||
|
else if(this->algorithm & PTS_MEAS_ALGO_SHA256) algorithm = 16384;
|
||||||
|
else if(this->algorithm & PTS_MEAS_ALGO_SHA1) algorithm = 32768;
|
||||||
|
writer->write_uint16(writer, algorithm);
|
||||||
|
|
||||||
|
this->value = chunk_clone(writer->get_buf(writer));
|
||||||
|
writer->destroy(writer);
|
||||||
|
}
|
||||||
|
|
||||||
|
METHOD(pa_tnc_attr_t, process, status_t,
|
||||||
|
private_tcg_pts_attr_meas_algo_selection_t *this)
|
||||||
|
{
|
||||||
|
bio_reader_t *reader;
|
||||||
|
u_int16_t reserved;
|
||||||
|
u_int16_t algorithm;
|
||||||
|
|
||||||
|
if (this->value.len < PTS_MEAS_ALGO_SEL_SIZE)
|
||||||
|
{
|
||||||
|
DBG1(DBG_TNC, "insufficient data for PTS Measurement Algorithm Selection");
|
||||||
|
return FAILED;
|
||||||
|
}
|
||||||
|
reader = bio_reader_create(this->value);
|
||||||
|
reader->read_uint16 (reader, &reserved);
|
||||||
|
reader->read_uint16(reader, &algorithm);
|
||||||
|
|
||||||
|
if((algorithm >> 13) & 1) this->algorithm = PTS_MEAS_ALGO_SHA384;
|
||||||
|
else if((algorithm >> 14) & 1) this->algorithm = PTS_MEAS_ALGO_SHA256;
|
||||||
|
else if((algorithm >> 15) & 1) this->algorithm = PTS_MEAS_ALGO_SHA1;
|
||||||
|
|
||||||
|
reader->destroy(reader);
|
||||||
|
|
||||||
|
return SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
METHOD(pa_tnc_attr_t, destroy, void,
|
||||||
|
private_tcg_pts_attr_meas_algo_selection_t *this)
|
||||||
|
{
|
||||||
|
free(this->value.ptr);
|
||||||
|
free(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
METHOD(tcg_pts_attr_meas_algo_t, get_algorithm, pts_attr_meas_algorithms_t,
|
||||||
|
private_tcg_pts_attr_meas_algo_selection_t *this)
|
||||||
|
{
|
||||||
|
return this->algorithms;
|
||||||
|
}
|
||||||
|
|
||||||
|
METHOD(tcg_pts_attr_meas_algo_t, set_algorithm, void,
|
||||||
|
private_tcg_pts_attr_meas_algo_selection_t *this,
|
||||||
|
pts_attr_meas_algorithms_t algorithm)
|
||||||
|
{
|
||||||
|
return this->algorithm = algorithm;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Described in header.
|
||||||
|
*/
|
||||||
|
pa_tnc_attr_t *tcg_pts_attr_meas_algo_create(pts_attr_meas_algorithms_t algorithm)
|
||||||
|
{
|
||||||
|
private_tcg_pts_attr_meas_algo_selection_t *this;
|
||||||
|
|
||||||
|
INIT(this,
|
||||||
|
.public = {
|
||||||
|
.pa_tnc_attribute = {
|
||||||
|
.get_vendor_id = _get_vendor_id,
|
||||||
|
.get_type = _get_type,
|
||||||
|
.get_value = _get_value,
|
||||||
|
.get_noskip_flag = _get_noskip_flag,
|
||||||
|
.set_noskip_flag = _set_noskip_flag,
|
||||||
|
.build = _build,
|
||||||
|
.process = _process,
|
||||||
|
.destroy = _destroy,
|
||||||
|
},
|
||||||
|
.get_algorithm = get_algorithm,
|
||||||
|
.set_algorithm = set_algorithm,
|
||||||
|
},
|
||||||
|
.vendor_id = PEN_TCG,
|
||||||
|
.type = TCG_PTS_MEAS_ALGO_SELECTION,
|
||||||
|
.algorithm = algorithm,
|
||||||
|
);
|
||||||
|
|
||||||
|
return &this->public.pa_tnc_attribute;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Described in header.
|
||||||
|
*/
|
||||||
|
pa_tnc_attr_t *tcg_pts_attr_meas_algo_create_from_data(chunk_t data)
|
||||||
|
{
|
||||||
|
private_tcg_pts_attr_meas_algo_selection_t *this;
|
||||||
|
|
||||||
|
INIT(this,
|
||||||
|
.public = {
|
||||||
|
.pa_tnc_attribute = {
|
||||||
|
.get_vendor_id = _get_vendor_id,
|
||||||
|
.get_type = _get_type,
|
||||||
|
.get_value = _get_value,
|
||||||
|
.get_noskip_flag = _get_noskip_flag,
|
||||||
|
.set_noskip_flag = _set_noskip_flag,
|
||||||
|
.build = _build,
|
||||||
|
.process = _process,
|
||||||
|
.destroy = _destroy,
|
||||||
|
},
|
||||||
|
.get_algorithm = get_algorithm,
|
||||||
|
.set_algorithm = set_algorithm,
|
||||||
|
},
|
||||||
|
.vendor_id = PEN_TCG,
|
||||||
|
.type = TCG_PTS_MEAS_ALGO_SELECTION,
|
||||||
|
.value = chunk_clone(data),
|
||||||
|
);
|
||||||
|
|
||||||
|
return &this->public.pa_tnc_attribute;
|
||||||
|
}
|
||||||
@@ -0,0 +1,84 @@
|
|||||||
|
/*
|
||||||
|
* 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_attr_meas_algo_selection tcg_pts_attr_meas_algo_selection
|
||||||
|
* @{ @ingroup tcg_pts_attr_meas_algo_selection
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef TCG_PTS_ATTR_MEAS_ALGO_SELECTION_H_
|
||||||
|
#define TCG_PTS_ATTR_MEAS_ALGO_SELECTION_H_
|
||||||
|
|
||||||
|
typedef struct tcg_pts_attr_meas_algo_selection_t tcg_pts_attr_meas_algo_selection_t;
|
||||||
|
typedef enum pts_attr_meas_algorithms_t pts_attr_meas_algorithms_t;
|
||||||
|
|
||||||
|
#include "tcg_attr.h"
|
||||||
|
#include "pa_tnc/pa_tnc_attr.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PTS Measurement Algorithms
|
||||||
|
*/
|
||||||
|
enum pts_attr_meas_algorithms_t {
|
||||||
|
/** SHA-384 */
|
||||||
|
PTS_MEAS_ALGO_SHA1 = (1<<0),
|
||||||
|
/** SHA-256 */
|
||||||
|
PTS_MEAS_ALGO_SHA256 = (1<<1),
|
||||||
|
/** SHA-1 */
|
||||||
|
PTS_MEAS_ALGO_SHA384 = (1<<2),
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class implementing the TCG Measurement Algorithm Selection Attribute
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
struct tcg_pts_attr_meas_algo_selection_t {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Public PA-TNC attribute interface
|
||||||
|
*/
|
||||||
|
pa_tnc_attr_t pa_tnc_attribute;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a selected PTS Measurement Algorithm
|
||||||
|
*
|
||||||
|
* @return A Selected Measurement Algorithm
|
||||||
|
*/
|
||||||
|
pts_attr_meas_algorithms_t (*get_algorithm)(tcg_pts_attr_meas_algo_selection_t *this);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set PTS Measurement Algorithm
|
||||||
|
*
|
||||||
|
* @param flags A Selected Measurement Algorithm
|
||||||
|
*/
|
||||||
|
void (*set_algorithm)(tcg_pts_attr_meas_algo_selection_t *this,
|
||||||
|
pts_attr_meas_algorithms_t algorithms);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an tcg_pts_attr_meas_algo_selection_t object
|
||||||
|
*
|
||||||
|
* @param algorithm A Selected Measurement Algorithm
|
||||||
|
*/
|
||||||
|
pa_tnc_attr_t* tcg_pts_attr_meas_algo_selection_create(pts_attr_meas_algorithms_t algorithm);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an tcg_pts_attr_meas_algo_selection_t object from received data
|
||||||
|
*
|
||||||
|
* @param value unparsed attribute value
|
||||||
|
*/
|
||||||
|
pa_tnc_attr_t* tcg_pts_attr_meas_algo_selection_create_from_data(chunk_t value);
|
||||||
|
|
||||||
|
#endif /** TCG_PTS_ATTR_MEAS_ALGO_H_ @}*/
|
||||||
@@ -0,0 +1,234 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "tcg_pts_attr_proto_caps.h"
|
||||||
|
|
||||||
|
#include <pa_tnc/pa_tnc_msg.h>
|
||||||
|
#include <bio/bio_writer.h>
|
||||||
|
#include <bio/bio_reader.h>
|
||||||
|
#include <debug.h>
|
||||||
|
|
||||||
|
typedef struct private_tcg_pts_attr_proto_caps_t private_tcg_pts_attr_proto_caps_t;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PTS Protocol Capabilities (see section 3.7 of PTS Protocol: Binding to TNC IF-M Specification)
|
||||||
|
*
|
||||||
|
* 1 2 3
|
||||||
|
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
||||||
|
*
|
||||||
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
|
* | Reserved |C|V|D|T|X|
|
||||||
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define PTS_PROTO_CAPS_SIZE 4
|
||||||
|
#define PTS_PROTO_CAPS_RESERVED 0x00
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Private data of an private_tcg_pts_attr_proto_caps_t object.
|
||||||
|
*/
|
||||||
|
struct private_tcg_pts_attr_proto_caps_t {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Public members of private_tcg_pts_attr_proto_caps_t
|
||||||
|
*/
|
||||||
|
tcg_pts_attr_proto_caps_t public;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attribute vendor ID
|
||||||
|
*/
|
||||||
|
pen_t vendor_id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attribute type
|
||||||
|
*/
|
||||||
|
u_int32_t type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attribute value
|
||||||
|
*/
|
||||||
|
chunk_t value;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Noskip flag
|
||||||
|
*/
|
||||||
|
bool noskip_flag;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set of flags
|
||||||
|
*/
|
||||||
|
pts_attr_proto_caps_flag_t flags;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
METHOD(pa_tnc_attr_t, get_vendor_id, pen_t,
|
||||||
|
private_tcg_pts_attr_proto_caps_t *this)
|
||||||
|
{
|
||||||
|
return this->vendor_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
METHOD(pa_tnc_attr_t, get_type, u_int32_t,
|
||||||
|
private_tcg_pts_attr_proto_caps_t *this)
|
||||||
|
{
|
||||||
|
return this->type;
|
||||||
|
}
|
||||||
|
|
||||||
|
METHOD(pa_tnc_attr_t, get_value, chunk_t,
|
||||||
|
private_tcg_pts_attr_proto_caps_t *this)
|
||||||
|
{
|
||||||
|
return this->value;
|
||||||
|
}
|
||||||
|
|
||||||
|
METHOD(pa_tnc_attr_t, get_noskip_flag, bool,
|
||||||
|
private_tcg_pts_attr_proto_caps_t *this)
|
||||||
|
{
|
||||||
|
return this->noskip_flag;
|
||||||
|
}
|
||||||
|
|
||||||
|
METHOD(pa_tnc_attr_t, set_noskip_flag,void,
|
||||||
|
private_tcg_pts_attr_proto_caps_t *this, bool noskip)
|
||||||
|
{
|
||||||
|
this->noskip_flag = noskip;
|
||||||
|
}
|
||||||
|
|
||||||
|
METHOD(pa_tnc_attr_t, build, void,
|
||||||
|
private_tcg_pts_attr_proto_caps_t *this)
|
||||||
|
{
|
||||||
|
bio_writer_t *writer;
|
||||||
|
u_int8_t flags = 0;
|
||||||
|
|
||||||
|
writer = bio_writer_create(PTS_PROTO_CAPS_SIZE);
|
||||||
|
writer->write_uint24 (writer, PTS_PROTO_CAPS_RESERVED);
|
||||||
|
|
||||||
|
/* Determine the flags to set*/
|
||||||
|
if(this->flags & PTS_PROTO_CAPS_XML) flags += 1;
|
||||||
|
if(this->flags & PTS_PROTO_CAPS_T) flags += 2;
|
||||||
|
if(this->flags & PTS_PROTO_CAPS_DH) flags += 4;
|
||||||
|
if(this->flags & PTS_PROTO_CAPS_VER) flags += 8;
|
||||||
|
if(this->flags & PTS_PROTO_CAPS_CURRENT) flags += 16;
|
||||||
|
writer->write_uint8(writer, flags);
|
||||||
|
|
||||||
|
this->value = chunk_clone(writer->get_buf(writer));
|
||||||
|
writer->destroy(writer);
|
||||||
|
}
|
||||||
|
|
||||||
|
METHOD(pa_tnc_attr_t, process, status_t,
|
||||||
|
private_tcg_pts_attr_proto_caps_t *this)
|
||||||
|
{
|
||||||
|
bio_reader_t *reader;
|
||||||
|
u_int24_t reserved;
|
||||||
|
u_int8_t flags;
|
||||||
|
|
||||||
|
if (this->value.len < PTS_PROTO_CAPS_SIZE)
|
||||||
|
{
|
||||||
|
DBG1(DBG_TNC, "insufficient data for PTS Protocol Capabilities");
|
||||||
|
return FAILED;
|
||||||
|
}
|
||||||
|
reader = bio_reader_create(this->value);
|
||||||
|
reader->read_uint24 (reader, &reserved);
|
||||||
|
reader->read_uint8(reader, &flags);
|
||||||
|
|
||||||
|
if((flags >> 0) & 1) this->flags |= PTS_PROTO_CAPS_XML;
|
||||||
|
if((flags >> 1) & 1) this->flags |= PTS_PROTO_CAPS_T;
|
||||||
|
if((flags >> 2) & 1) this->flags |= PTS_PROTO_CAPS_DH;
|
||||||
|
if((flags >> 3) & 1) this->flags |= PTS_PROTO_CAPS_VER;
|
||||||
|
if((flags >> 4) & 1) this->flags |= PTS_PROTO_CAPS_CURRENT;
|
||||||
|
|
||||||
|
reader->destroy(reader);
|
||||||
|
|
||||||
|
return SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
METHOD(pa_tnc_attr_t, destroy, void,
|
||||||
|
private_tcg_pts_attr_proto_caps_t *this)
|
||||||
|
{
|
||||||
|
free(this->value.ptr);
|
||||||
|
free(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
METHOD(tcg_pts_attr_proto_caps_t, get_flags, pts_attr_proto_caps_flag_t,
|
||||||
|
private_tcg_pts_attr_proto_caps_t *this)
|
||||||
|
{
|
||||||
|
return this->flags;
|
||||||
|
}
|
||||||
|
|
||||||
|
METHOD(tcg_pts_attr_proto_caps_t, set_flags, void,
|
||||||
|
private_tcg_pts_attr_proto_caps_t *this,
|
||||||
|
pts_attr_proto_caps_flag_t flags)
|
||||||
|
{
|
||||||
|
return this->flags = flags;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Described in header.
|
||||||
|
*/
|
||||||
|
pa_tnc_attr_t *tcg_pts_attr_proto_caps_create(pts_attr_proto_caps_flag_t flags)
|
||||||
|
{
|
||||||
|
private_tcg_pts_attr_proto_caps_t *this;
|
||||||
|
|
||||||
|
INIT(this,
|
||||||
|
.public = {
|
||||||
|
.pa_tnc_attribute = {
|
||||||
|
.get_vendor_id = _get_vendor_id,
|
||||||
|
.get_type = _get_type,
|
||||||
|
.get_value = _get_value,
|
||||||
|
.get_noskip_flag = _get_noskip_flag,
|
||||||
|
.set_noskip_flag = _set_noskip_flag,
|
||||||
|
.build = _build,
|
||||||
|
.process = _process,
|
||||||
|
.destroy = _destroy,
|
||||||
|
},
|
||||||
|
.get_flags = get_flags,
|
||||||
|
.set_flags = set_flags,
|
||||||
|
},
|
||||||
|
.vendor_id = PEN_TCG,
|
||||||
|
.type = TCG_PTS_PROTO_CAPS,
|
||||||
|
.flags = flags,
|
||||||
|
);
|
||||||
|
|
||||||
|
return &this->public.pa_tnc_attribute;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Described in header.
|
||||||
|
*/
|
||||||
|
pa_tnc_attr_t *tcg_pts_attr_proto_caps_create_from_data(chunk_t data)
|
||||||
|
{
|
||||||
|
private_tcg_pts_attr_proto_caps_t *this;
|
||||||
|
|
||||||
|
INIT(this,
|
||||||
|
.public = {
|
||||||
|
.pa_tnc_attribute = {
|
||||||
|
.get_vendor_id = _get_vendor_id,
|
||||||
|
.get_type = _get_type,
|
||||||
|
.get_value = _get_value,
|
||||||
|
.get_noskip_flag = _get_noskip_flag,
|
||||||
|
.set_noskip_flag = _set_noskip_flag,
|
||||||
|
.build = _build,
|
||||||
|
.process = _process,
|
||||||
|
.destroy = _destroy,
|
||||||
|
},
|
||||||
|
.get_flags = get_flags,
|
||||||
|
.set_flags = set_flags,
|
||||||
|
},
|
||||||
|
.vendor_id = PEN_TCG,
|
||||||
|
.type = TCG_PTS_PROTO_CAPS,
|
||||||
|
.value = chunk_clone(data),
|
||||||
|
);
|
||||||
|
|
||||||
|
return &this->public.pa_tnc_attribute;
|
||||||
|
}
|
||||||
@@ -0,0 +1,88 @@
|
|||||||
|
/*
|
||||||
|
* 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_attr_proto_caps tcg_pts_attr_proto_caps
|
||||||
|
* @{ @ingroup tcg_pts_attr_proto_caps
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef TCG_PTS_ATTR_PROTO_CAPS_H_
|
||||||
|
#define TCG_PTS_ATTR_PROTO_CAPS_H_
|
||||||
|
|
||||||
|
typedef struct tcg_pts_attr_proto_caps_t tcg_pts_attr_proto_caps_t;
|
||||||
|
typedef enum pts_attr_proto_caps_flag_t pts_attr_proto_caps_flag_t;
|
||||||
|
|
||||||
|
#include "tcg_attr.h"
|
||||||
|
#include "pa_tnc/pa_tnc_attr.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PTS Protocol Capabilities Flags
|
||||||
|
*/
|
||||||
|
enum pts_attr_proto_caps_flag_t {
|
||||||
|
/** XML based Evidence Support flag */
|
||||||
|
PTS_PROTO_CAPS_XML = (1<<0),
|
||||||
|
/** Trusted Platform Evidence flag */
|
||||||
|
PTS_PROTO_CAPS_T = (1<<1),
|
||||||
|
/** DH Nonce Negotiation Support flag */
|
||||||
|
PTS_PROTO_CAPS_DH = (1<<2),
|
||||||
|
/** Verification Support flag */
|
||||||
|
PTS_PROTO_CAPS_VER = (1<<3),
|
||||||
|
/** Current (In-Memory) Evidence Support flag */
|
||||||
|
PTS_PROTO_CAPS_CURRENT = (1<<4),
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class implementing the TCG PTS Protocol Capabilities Attribute
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
struct tcg_pts_attr_proto_caps_t {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Public PA-TNC attribute interface
|
||||||
|
*/
|
||||||
|
pa_tnc_attr_t pa_tnc_attribute;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get PTS procol capabilities flags
|
||||||
|
*
|
||||||
|
* @return set of flags
|
||||||
|
*/
|
||||||
|
pts_attr_proto_caps_flag_t (*get_flags)(tcg_pts_attr_proto_caps_t *this);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set PTS procol capabilities flags
|
||||||
|
*
|
||||||
|
* @param flags set of flags
|
||||||
|
*/
|
||||||
|
void (*set_flags)(tcg_pts_attr_proto_caps_t *this,
|
||||||
|
pts_attr_proto_caps_flag_t flags);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an tcg_pts_attr_proto_caps_t object
|
||||||
|
*
|
||||||
|
* @param flags set of flags
|
||||||
|
*/
|
||||||
|
pa_tnc_attr_t* tcg_pts_attr_proto_caps_create(pts_attr_proto_caps_flag_t flags);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an tcg_pts_attr_proto_caps_t object from received data
|
||||||
|
*
|
||||||
|
* @param value unparsed attribute value
|
||||||
|
*/
|
||||||
|
pa_tnc_attr_t* tcg_pts_attr_proto_caps_create_from_data(chunk_t value);
|
||||||
|
|
||||||
|
#endif /** TCG_PTS_ATTR_PROTO_CAPS_H_ @}*/
|
||||||
@@ -0,0 +1,234 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "tcg_pts_attr_req_proto_caps.h"
|
||||||
|
|
||||||
|
#include <pa_tnc/pa_tnc_msg.h>
|
||||||
|
#include <bio/bio_writer.h>
|
||||||
|
#include <bio/bio_reader.h>
|
||||||
|
#include <debug.h>
|
||||||
|
|
||||||
|
typedef struct private_tcg_pts_attr_req_proto_caps_t private_tcg_pts_attr_req_proto_caps_t;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Request PTS Protocol Capabilities (see section 3.6 of PTS Protocol: Binding to TNC IF-M Specification)
|
||||||
|
*
|
||||||
|
* 1 2 3
|
||||||
|
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
||||||
|
*
|
||||||
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
|
* | Reserved |C|V|D|T|X|
|
||||||
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define PTS_PROTO_CAPS_SIZE 4
|
||||||
|
#define PTS_PROTO_CAPS_RESERVED 0x00
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Private data of an private_tcg_pts_attr_req_proto_caps_t object.
|
||||||
|
*/
|
||||||
|
struct private_tcg_pts_attr_req_proto_caps_t {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Public members of private_tcg_pts_attr_req_proto_caps_t
|
||||||
|
*/
|
||||||
|
tcg_pts_attr_req_proto_caps_t public;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attribute vendor ID
|
||||||
|
*/
|
||||||
|
pen_t vendor_id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attribute type
|
||||||
|
*/
|
||||||
|
u_int32_t type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attribute value
|
||||||
|
*/
|
||||||
|
chunk_t value;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Noskip flag
|
||||||
|
*/
|
||||||
|
bool noskip_flag;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set of flags
|
||||||
|
*/
|
||||||
|
pts_attr_req_proto_caps_flag_t flags;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
METHOD(pa_tnc_attr_t, get_vendor_id, pen_t,
|
||||||
|
private_tcg_pts_attr_req_proto_caps_t *this)
|
||||||
|
{
|
||||||
|
return this->vendor_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
METHOD(pa_tnc_attr_t, get_type, u_int32_t,
|
||||||
|
private_tcg_pts_attr_req_proto_caps_t *this)
|
||||||
|
{
|
||||||
|
return this->type;
|
||||||
|
}
|
||||||
|
|
||||||
|
METHOD(pa_tnc_attr_t, get_value, chunk_t,
|
||||||
|
private_tcg_pts_attr_req_proto_caps_t *this)
|
||||||
|
{
|
||||||
|
return this->value;
|
||||||
|
}
|
||||||
|
|
||||||
|
METHOD(pa_tnc_attr_t, get_noskip_flag, bool,
|
||||||
|
private_tcg_pts_attr_req_proto_caps_t *this)
|
||||||
|
{
|
||||||
|
return this->noskip_flag;
|
||||||
|
}
|
||||||
|
|
||||||
|
METHOD(pa_tnc_attr_t, set_noskip_flag,void,
|
||||||
|
private_tcg_pts_attr_req_proto_caps_t *this, bool noskip)
|
||||||
|
{
|
||||||
|
this->noskip_flag = noskip;
|
||||||
|
}
|
||||||
|
|
||||||
|
METHOD(pa_tnc_attr_t, build, void,
|
||||||
|
private_tcg_pts_attr_req_proto_caps_t *this)
|
||||||
|
{
|
||||||
|
bio_writer_t *writer;
|
||||||
|
u_int8_t flags = 0;
|
||||||
|
|
||||||
|
writer = bio_writer_create(PTS_PROTO_CAPS_SIZE);
|
||||||
|
writer->write_uint24 (writer, PTS_PROTO_CAPS_RESERVED);
|
||||||
|
|
||||||
|
/* Determine the flags to set*/
|
||||||
|
if(this->flags & PTS_PROTO_CAPS_XML) flags += 1;
|
||||||
|
if(this->flags & PTS_PROTO_CAPS_T) flags += 2;
|
||||||
|
if(this->flags & PTS_PROTO_CAPS_DH) flags += 4;
|
||||||
|
if(this->flags & PTS_PROTO_CAPS_VER) flags += 8;
|
||||||
|
if(this->flags & PTS_PROTO_CAPS_CURRENT) flags += 16;
|
||||||
|
writer->write_uint8(writer, flags);
|
||||||
|
|
||||||
|
this->value = chunk_clone(writer->get_buf(writer));
|
||||||
|
writer->destroy(writer);
|
||||||
|
}
|
||||||
|
|
||||||
|
METHOD(pa_tnc_attr_t, process, status_t,
|
||||||
|
private_tcg_pts_attr_req_proto_caps_t *this)
|
||||||
|
{
|
||||||
|
bio_reader_t *reader;
|
||||||
|
u_int24_t reserved;
|
||||||
|
u_int8_t flags;
|
||||||
|
|
||||||
|
if (this->value.len < PTS_PROTO_CAPS_SIZE)
|
||||||
|
{
|
||||||
|
DBG1(DBG_TNC, "insufficient data for Request PTS Protocol Capabilities");
|
||||||
|
return FAILED;
|
||||||
|
}
|
||||||
|
reader = bio_reader_create(this->value);
|
||||||
|
reader->read_uint24 (reader, &reserved);
|
||||||
|
reader->read_uint8(reader, &flags);
|
||||||
|
|
||||||
|
if((flags >> 0) & 1) this->flags |= PTS_PROTO_CAPS_XML;
|
||||||
|
if((flags >> 1) & 1) this->flags |= PTS_PROTO_CAPS_T;
|
||||||
|
if((flags >> 2) & 1) this->flags |= PTS_PROTO_CAPS_DH;
|
||||||
|
if((flags >> 3) & 1) this->flags |= PTS_PROTO_CAPS_VER;
|
||||||
|
if((flags >> 4) & 1) this->flags |= PTS_PROTO_CAPS_CURRENT;
|
||||||
|
|
||||||
|
reader->destroy(reader);
|
||||||
|
|
||||||
|
return SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
METHOD(pa_tnc_attr_t, destroy, void,
|
||||||
|
private_tcg_pts_attr_req_proto_caps_t *this)
|
||||||
|
{
|
||||||
|
free(this->value.ptr);
|
||||||
|
free(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
METHOD(tcg_pts_attr_req_proto_caps_t, get_flags, pts_attr_req_proto_caps_flag_t,
|
||||||
|
private_tcg_pts_attr_req_proto_caps_t *this)
|
||||||
|
{
|
||||||
|
return this->flags;
|
||||||
|
}
|
||||||
|
|
||||||
|
METHOD(tcg_pts_attr_req_proto_caps_t, set_flags, void,
|
||||||
|
private_tcg_pts_attr_req_proto_caps_t *this,
|
||||||
|
pts_attr_req_proto_caps_flag_t flags)
|
||||||
|
{
|
||||||
|
return this->flags = flags;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Described in header.
|
||||||
|
*/
|
||||||
|
pa_tnc_attr_t *tcg_pts_attr_req_proto_caps_create(pts_attr_req_proto_caps_flag_t flags)
|
||||||
|
{
|
||||||
|
private_tcg_pts_attr_req_proto_caps_t *this;
|
||||||
|
|
||||||
|
INIT(this,
|
||||||
|
.public = {
|
||||||
|
.pa_tnc_attribute = {
|
||||||
|
.get_vendor_id = _get_vendor_id,
|
||||||
|
.get_type = _get_type,
|
||||||
|
.get_value = _get_value,
|
||||||
|
.get_noskip_flag = _get_noskip_flag,
|
||||||
|
.set_noskip_flag = _set_noskip_flag,
|
||||||
|
.build = _build,
|
||||||
|
.process = _process,
|
||||||
|
.destroy = _destroy,
|
||||||
|
},
|
||||||
|
.get_flags = get_flags,
|
||||||
|
.set_flags = set_flags,
|
||||||
|
},
|
||||||
|
.vendor_id = PEN_TCG,
|
||||||
|
.type = TCG_PTS_REQ_PROTO_CAPS,
|
||||||
|
.flags = flags,
|
||||||
|
);
|
||||||
|
|
||||||
|
return &this->public.pa_tnc_attribute;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Described in header.
|
||||||
|
*/
|
||||||
|
pa_tnc_attr_t *tcg_pts_attr_req_proto_caps_create_from_data(chunk_t data)
|
||||||
|
{
|
||||||
|
private_tcg_pts_attr_req_proto_caps_t *this;
|
||||||
|
|
||||||
|
INIT(this,
|
||||||
|
.public = {
|
||||||
|
.pa_tnc_attribute = {
|
||||||
|
.get_vendor_id = _get_vendor_id,
|
||||||
|
.get_type = _get_type,
|
||||||
|
.get_value = _get_value,
|
||||||
|
.get_noskip_flag = _get_noskip_flag,
|
||||||
|
.set_noskip_flag = _set_noskip_flag,
|
||||||
|
.build = _build,
|
||||||
|
.process = _process,
|
||||||
|
.destroy = _destroy,
|
||||||
|
},
|
||||||
|
.get_flags = get_flags,
|
||||||
|
.set_flags = set_flags,
|
||||||
|
},
|
||||||
|
.vendor_id = PEN_TCG,
|
||||||
|
.type = TCG_PTS_REQ_PROTO_CAPS,
|
||||||
|
.value = chunk_clone(data),
|
||||||
|
);
|
||||||
|
|
||||||
|
return &this->public.pa_tnc_attribute;
|
||||||
|
}
|
||||||
@@ -0,0 +1,88 @@
|
|||||||
|
/*
|
||||||
|
* 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_attr_req_proto_caps tcg_pts_attr_req_proto_caps
|
||||||
|
* @{ @ingroup tcg_pts_attr_req_proto_caps
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef TCG_PTS_ATTR_REQ_PROTO_CAPS_H_
|
||||||
|
#define TCG_PTS_ATTR_REQ_PROTO_CAPS_H_
|
||||||
|
|
||||||
|
typedef struct tcg_pts_attr_req_proto_caps_t tcg_pts_attr_req_proto_caps_t;
|
||||||
|
typedef enum pts_attr_req_proto_caps_flag_t pts_attr_req_proto_caps_flag_t;
|
||||||
|
|
||||||
|
#include "tcg_attr.h"
|
||||||
|
#include "pa_tnc/pa_tnc_attr.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PTS Request Protocol Capabilities Flags
|
||||||
|
*/
|
||||||
|
enum pts_attr_req_proto_caps_flag_t {
|
||||||
|
/** XML based Evidence Support flag */
|
||||||
|
PTS_PROTO_CAPS_XML = (1<<0),
|
||||||
|
/** Trusted Platform Evidence flag */
|
||||||
|
PTS_PROTO_CAPS_T = (1<<1),
|
||||||
|
/** DH Nonce Negotiation Support flag */
|
||||||
|
PTS_PROTO_CAPS_DH = (1<<2),
|
||||||
|
/** Verification Support flag */
|
||||||
|
PTS_PROTO_CAPS_VER = (1<<3),
|
||||||
|
/** Current (In-Memory) Evidence Support flag */
|
||||||
|
PTS_PROTO_CAPS_CURRENT = (1<<4),
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class implementing the TCG Request PTS Protocol Capabilities Attribute
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
struct tcg_pts_attr_req_proto_caps_t {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Public PA-TNC attribute interface
|
||||||
|
*/
|
||||||
|
pa_tnc_attr_t pa_tnc_attribute;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get PTS procol capabilities flags
|
||||||
|
*
|
||||||
|
* @return set of flags
|
||||||
|
*/
|
||||||
|
pts_attr_req_proto_caps_flag_t (*get_flags)(tcg_pts_attr_req_proto_caps_t *this);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set PTS procol capabilities flags
|
||||||
|
*
|
||||||
|
* @param flags set of flags
|
||||||
|
*/
|
||||||
|
void (*set_flags)(tcg_pts_attr_req_proto_caps_t *this,
|
||||||
|
pts_attr_req_proto_caps_flag_t flags);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an tcg_pts_attr_req_proto_caps_t object
|
||||||
|
*
|
||||||
|
* @param flags set of flags
|
||||||
|
*/
|
||||||
|
pa_tnc_attr_t* tcg_pts_attr_req_proto_caps_create(pts_attr_req_proto_caps_flag_t flags);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an tcg_pts_attr_req_proto_caps_t object from received data
|
||||||
|
*
|
||||||
|
* @param value unparsed attribute value
|
||||||
|
*/
|
||||||
|
pa_tnc_attr_t* tcg_pts_attr_req_proto_caps_create_from_data(chunk_t value);
|
||||||
|
|
||||||
|
#endif /** TCG_PTS_ATTR_REQ_PROTO_CAPS_H_ @}*/
|
||||||
@@ -0,0 +1,216 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "tcg_pts_attr_tpm_version_info.h"
|
||||||
|
|
||||||
|
#include <pa_tnc/pa_tnc_msg.h>
|
||||||
|
#include <bio/bio_writer.h>
|
||||||
|
#include <bio/bio_reader.h>
|
||||||
|
#include <debug.h>
|
||||||
|
|
||||||
|
typedef struct private_tcg_pts_attr_tpm_version_info_t private_tcg_pts_attr_tpm_version_info_t;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TPM Version Information (see section 3.11 of PTS Protocol: Binding to TNC IF-M Specification)
|
||||||
|
*
|
||||||
|
* 1 2 3
|
||||||
|
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
||||||
|
*
|
||||||
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
|
* | TPM Version Information (Variable Lenght) |
|
||||||
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
|
*
|
||||||
|
* see TPM Structure Specification Part 2, section 21.6: TPM_CAP_VERSION_INFO
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define PTS_TPM_VER_INFO_SIZE 4
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Private data of an private_tcg_pts_attr_tpm_version_info_t object.
|
||||||
|
*/
|
||||||
|
struct private_tcg_pts_attr_tpm_version_info_t {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Public members of private_tcg_pts_attr_tpm_version_info_t
|
||||||
|
*/
|
||||||
|
tcg_pts_attr_tpm_version_info_t public;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attribute vendor ID
|
||||||
|
*/
|
||||||
|
pen_t vendor_id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attribute type
|
||||||
|
*/
|
||||||
|
u_int32_t type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attribute value
|
||||||
|
*/
|
||||||
|
chunk_t value;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Noskip flag
|
||||||
|
*/
|
||||||
|
bool noskip_flag;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TPM Version Information
|
||||||
|
*/
|
||||||
|
chunk_t tpm_version_info;
|
||||||
|
};
|
||||||
|
|
||||||
|
METHOD(pa_tnc_attr_t, get_vendor_id, pen_t,
|
||||||
|
private_tcg_pts_attr_tpm_version_info_t *this)
|
||||||
|
{
|
||||||
|
return this->vendor_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
METHOD(pa_tnc_attr_t, get_type, u_int32_t,
|
||||||
|
private_tcg_pts_attr_tpm_version_info_t *this)
|
||||||
|
{
|
||||||
|
return this->type;
|
||||||
|
}
|
||||||
|
|
||||||
|
METHOD(pa_tnc_attr_t, get_value, chunk_t,
|
||||||
|
private_tcg_pts_attr_tpm_version_info_t *this)
|
||||||
|
{
|
||||||
|
return this->value;
|
||||||
|
}
|
||||||
|
|
||||||
|
METHOD(pa_tnc_attr_t, get_noskip_flag, bool,
|
||||||
|
private_tcg_pts_attr_tpm_version_info_t *this)
|
||||||
|
{
|
||||||
|
return this->noskip_flag;
|
||||||
|
}
|
||||||
|
|
||||||
|
METHOD(pa_tnc_attr_t, set_noskip_flag,void,
|
||||||
|
private_tcg_pts_attr_tpm_version_info_t *this, bool noskip)
|
||||||
|
{
|
||||||
|
this->noskip_flag = noskip;
|
||||||
|
}
|
||||||
|
|
||||||
|
METHOD(pa_tnc_attr_t, build, void,
|
||||||
|
private_tcg_pts_attr_tpm_version_info_t *this)
|
||||||
|
{
|
||||||
|
bio_writer_t *writer;
|
||||||
|
|
||||||
|
writer = bio_writer_create(PTS_TPM_VER_INFO_SIZE);
|
||||||
|
writer->write_data(writer, this->tpm_version_info);
|
||||||
|
|
||||||
|
this->value = chunk_clone(writer->get_buf(writer));
|
||||||
|
writer->destroy(writer);
|
||||||
|
}
|
||||||
|
|
||||||
|
METHOD(pa_tnc_attr_t, process, status_t,
|
||||||
|
private_tcg_pts_attr_tpm_version_info_t *this)
|
||||||
|
{
|
||||||
|
bio_reader_t *reader;
|
||||||
|
|
||||||
|
if (this->value.len < PTS_TPM_VER_INFO_SIZE)
|
||||||
|
{
|
||||||
|
DBG1(DBG_TNC, "insufficient data for TPM Version Information");
|
||||||
|
return FAILED;
|
||||||
|
}
|
||||||
|
reader = bio_reader_create(this->value);
|
||||||
|
reader->read_data (reader, sizeof(this->value), &this->tpm_version_info);
|
||||||
|
this->tpm_version_info = chunk_clone(this->tpm_version_info);
|
||||||
|
reader->destroy(reader);
|
||||||
|
|
||||||
|
return SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
METHOD(pa_tnc_attr_t, destroy, void,
|
||||||
|
private_tcg_pts_attr_tpm_version_info_t *this)
|
||||||
|
{
|
||||||
|
free(this->value.ptr);
|
||||||
|
free(this->tpm_version_info.ptr);
|
||||||
|
free(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
METHOD(tcg_pts_attr_tpm_version_info_t, get_tpm_version_info, chunk_t,
|
||||||
|
private_tcg_pts_attr_tpm_version_info_t *this)
|
||||||
|
{
|
||||||
|
return this->tpm_version_info;
|
||||||
|
}
|
||||||
|
|
||||||
|
METHOD(tcg_pts_attr_tpm_version_info_t, set_tpm_version_info, void,
|
||||||
|
private_tcg_pts_attr_tpm_version_info_t *this,
|
||||||
|
chunk_t tpm_version_info)
|
||||||
|
{
|
||||||
|
return this->tpm_version_info = tpm_version_info;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Described in header.
|
||||||
|
*/
|
||||||
|
pa_tnc_attr_t *tcg_pts_attr_tpm_version_info_create(chunk_t tpm_version_info)
|
||||||
|
{
|
||||||
|
private_tcg_pts_attr_tpm_version_info_t *this;
|
||||||
|
|
||||||
|
INIT(this,
|
||||||
|
.public = {
|
||||||
|
.pa_tnc_attribute = {
|
||||||
|
.get_vendor_id = _get_vendor_id,
|
||||||
|
.get_type = _get_type,
|
||||||
|
.get_value = _get_value,
|
||||||
|
.get_noskip_flag = _get_noskip_flag,
|
||||||
|
.set_noskip_flag = _set_noskip_flag,
|
||||||
|
.build = _build,
|
||||||
|
.process = _process,
|
||||||
|
.destroy = _destroy,
|
||||||
|
},
|
||||||
|
.get_tpm_version_info = get_tpm_version_info,
|
||||||
|
.set_tpm_version_info = set_tpm_version_info,
|
||||||
|
},
|
||||||
|
.vendor_id = PEN_TCG,
|
||||||
|
.type = TCG_PTS_TPM_VERSION_INFO,
|
||||||
|
.tpm_version_info = tpm_version_info,
|
||||||
|
);
|
||||||
|
|
||||||
|
return &this->public.pa_tnc_attribute;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Described in header.
|
||||||
|
*/
|
||||||
|
pa_tnc_attr_t *tcg_pts_attr_tpm_version_info_create_from_data(chunk_t data)
|
||||||
|
{
|
||||||
|
private_tcg_pts_attr_tpm_version_info_t *this;
|
||||||
|
|
||||||
|
INIT(this,
|
||||||
|
.public = {
|
||||||
|
.pa_tnc_attribute = {
|
||||||
|
.get_vendor_id = _get_vendor_id,
|
||||||
|
.get_type = _get_type,
|
||||||
|
.get_value = _get_value,
|
||||||
|
.get_noskip_flag = _get_noskip_flag,
|
||||||
|
.set_noskip_flag = _set_noskip_flag,
|
||||||
|
.build = _build,
|
||||||
|
.process = _process,
|
||||||
|
.destroy = _destroy,
|
||||||
|
},
|
||||||
|
.get_tpm_version_info = get_tpm_version_info,
|
||||||
|
.set_tpm_version_info = set_tpm_version_info,
|
||||||
|
},
|
||||||
|
.vendor_id = PEN_TCG,
|
||||||
|
.type = TCG_PTS_TPM_VERSION_INFO,
|
||||||
|
.value = chunk_clone(data),
|
||||||
|
);
|
||||||
|
|
||||||
|
return &this->public.pa_tnc_attribute;
|
||||||
|
}
|
||||||
@@ -0,0 +1,70 @@
|
|||||||
|
/*
|
||||||
|
* 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_attr_tpm_version_info tcg_pts_attr_tpm_version_info
|
||||||
|
* @{ @ingroup tcg_pts_attr_tpm_version_info
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef TCG_PTS_ATTR_TPM_VERSION_INFO_H_
|
||||||
|
#define TCG_PTS_ATTR_TPM_VERSION_INFO_H_
|
||||||
|
|
||||||
|
typedef struct tcg_pts_attr_tpm_version_info_t tcg_pts_attr_tpm_version_info_t;
|
||||||
|
|
||||||
|
#include "tcg_attr.h"
|
||||||
|
#include "pa_tnc/pa_tnc_attr.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class implementing the TCG PTS TPM Version Info Attribute
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
struct tcg_pts_attr_tpm_version_info_t {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Public PA-TNC attribute interface
|
||||||
|
*/
|
||||||
|
pa_tnc_attr_t pa_tnc_attribute;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get TPM Version Info
|
||||||
|
*
|
||||||
|
* @return TPM version info
|
||||||
|
*/
|
||||||
|
chunk_t (*get_tpm_version_info)(tcg_pts_attr_tpm_version_info_t *this);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set TPM Version Info
|
||||||
|
*
|
||||||
|
* @param tpm_version_info TPM version info
|
||||||
|
*/
|
||||||
|
void (*set_tpm_version_info)(tcg_pts_attr_tpm_version_info_t *this,
|
||||||
|
chunk_t tpm_version_info);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an tcg_pts_attr_tpm_version_info_t object
|
||||||
|
*
|
||||||
|
* @param tpm_version_info TPM version info
|
||||||
|
*/
|
||||||
|
pa_tnc_attr_t* tcg_pts_attr_tpm_version_info_create(chunk_t tpm_version_info);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an tcg_pts_attr_tpm_version_info_t object from received data
|
||||||
|
*
|
||||||
|
* @param value unparsed attribute value
|
||||||
|
*/
|
||||||
|
pa_tnc_attr_t* tcg_pts_attr_tpm_version_info_create_from_data(chunk_t value);
|
||||||
|
|
||||||
|
#endif /** TCG_PTS_ATTR_TPM_VERSION_INFO_H_ @}*/
|
||||||
Reference in New Issue
Block a user