+++ /dev/null
-/*
- * Copyright (C) 2011-2012 Sansar Choinyambuu, Andreas Steffen
- * HSR Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#include "tcg_pts_attr_aik.h"
-
-#include <pa_tnc/pa_tnc_msg.h>
-#include <bio/bio_writer.h>
-#include <bio/bio_reader.h>
-#include <utils/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 Length) ~
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Attestation Identity Key (Variable Length) ~
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- */
-
-#define PTS_AIK_SIZE 4
-#define PTS_AIK_FLAGS_NONE 0
-#define PTS_AIK_FLAGS_NAKED_KEY (1<<7)
-/**
- * Private data of an tcg_pts_attr_aik_t object.
- */
-struct private_tcg_pts_attr_aik_t {
-
- /**
- * Public members of tcg_pts_attr_aik_t
- */
- tcg_pts_attr_aik_t public;
-
- /**
- * Vendor-specific attribute type
- */
- pen_type_t type;
-
- /**
- * Attribute value
- */
- chunk_t value;
-
- /**
- * Noskip flag
- */
- bool noskip_flag;
-
- /**
- * AIK Certificate or Public Key
- */
- certificate_t *aik;
-
- /**
- * Reference count
- */
- refcount_t ref;
-};
-
-METHOD(pa_tnc_attr_t, get_type, pen_type_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 = PTS_AIK_FLAGS_NONE;
- cred_encoding_type_t encoding_type = CERT_ASN1_DER;
- chunk_t aik_blob;
-
- if (this->value.ptr)
- {
- return;
- }
- if (this->aik->get_type(this->aik) == CERT_TRUSTED_PUBKEY)
- {
- flags |= PTS_AIK_FLAGS_NAKED_KEY;
- encoding_type = PUBKEY_SPKI_ASN1_DER;
- }
- if (!this->aik->get_encoding(this->aik, encoding_type, &aik_blob))
- {
- DBG1(DBG_TNC, "encoding of Attestation Identity Key failed");
- aik_blob = chunk_empty;
- }
- writer = bio_writer_create(PTS_AIK_SIZE);
- writer->write_uint8(writer, flags);
- writer->write_data (writer, aik_blob);
- this->value = writer->extract_buf(writer);
- writer->destroy(writer);
- free(aik_blob.ptr);
-}
-
-METHOD(pa_tnc_attr_t, process, status_t,
- private_tcg_pts_attr_aik_t *this, u_int32_t *offset)
-{
- bio_reader_t *reader;
- u_int8_t flags;
- certificate_type_t type;
- chunk_t aik_blob;
-
- if (this->value.len < PTS_AIK_SIZE)
- {
- DBG1(DBG_TNC, "insufficient data for Attestation Identity Key");
- *offset = 0;
- return FAILED;
- }
- reader = bio_reader_create(this->value);
- reader->read_uint8(reader, &flags);
- reader->read_data (reader, reader->remaining(reader), &aik_blob);
-
- type = (flags & PTS_AIK_FLAGS_NAKED_KEY) ? CERT_TRUSTED_PUBKEY : CERT_X509;
-
- this->aik = lib->creds->create(lib->creds, CRED_CERTIFICATE, type,
- BUILD_BLOB_PEM, aik_blob, BUILD_END);
- reader->destroy(reader);
-
- if (!this->aik)
- {
- DBG1(DBG_TNC, "parsing of Attestation Identity Key failed");
- *offset = 0;
- return FAILED;
- }
- return SUCCESS;
-}
-
-METHOD(pa_tnc_attr_t, get_ref, pa_tnc_attr_t*,
- private_tcg_pts_attr_aik_t *this)
-{
- ref_get(&this->ref);
- return &this->public.pa_tnc_attribute;
-}
-
-METHOD(pa_tnc_attr_t, destroy, void,
- private_tcg_pts_attr_aik_t *this)
-{
- if (ref_put(&this->ref))
- {
- DESTROY_IF(this->aik);
- free(this->value.ptr);
- free(this);
- }
-}
-
-METHOD(tcg_pts_attr_aik_t, get_aik, certificate_t*,
- private_tcg_pts_attr_aik_t *this)
-{
- return this->aik;
-}
-
-/**
- * Described in header.
- */
-pa_tnc_attr_t *tcg_pts_attr_aik_create(certificate_t *aik)
-{
- private_tcg_pts_attr_aik_t *this;
-
- INIT(this,
- .public = {
- .pa_tnc_attribute = {
- .get_type = _get_type,
- .get_value = _get_value,
- .get_noskip_flag = _get_noskip_flag,
- .set_noskip_flag = _set_noskip_flag,
- .build = _build,
- .process = _process,
- .get_ref = _get_ref,
- .destroy = _destroy,
- },
- .get_aik = _get_aik,
- },
- .type = { PEN_TCG, TCG_PTS_AIK },
- .aik = aik->get_ref(aik),
- .ref = 1,
- );
-
- return &this->public.pa_tnc_attribute;
-}
-
-
-/**
- * Described in header.
- */
-pa_tnc_attr_t *tcg_pts_attr_aik_create_from_data(chunk_t data)
-{
- private_tcg_pts_attr_aik_t *this;
-
- INIT(this,
- .public = {
- .pa_tnc_attribute = {
- .get_type = _get_type,
- .get_value = _get_value,
- .get_noskip_flag = _get_noskip_flag,
- .set_noskip_flag = _set_noskip_flag,
- .build = _build,
- .process = _process,
- .get_ref = _get_ref,
- .destroy = _destroy,
- },
- .get_aik = _get_aik,
- },
- .type = { PEN_TCG, TCG_PTS_AIK },
- .value = chunk_clone(data),
- .ref = 1,
- );
-
- return &this->public.pa_tnc_attribute;
-}
+++ /dev/null
-/*
- * 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_attr
- */
-
-#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"
-
-#include <credentials/certificates/certificate.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 AIK
- *
- * @return AIK Certificate or Public Key
- */
- certificate_t* (*get_aik)(tcg_pts_attr_aik_t *this);
-
-};
-
-/**
- * Creates an tcg_pts_attr_aik_t object
- *
- * @param aik Attestation Identity Key
- */
-pa_tnc_attr_t* tcg_pts_attr_aik_create(certificate_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_ @}*/
+++ /dev/null
-/*
- * Copyright (C) 2011-2012 Sansar Choinyambuu, Andreas Steffen
- * HSR Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#include "tcg_pts_attr_dh_nonce_finish.h"
-
-#include <pa_tnc/pa_tnc_msg.h>
-#include <bio/bio_writer.h>
-#include <bio/bio_reader.h>
-#include <utils/debug.h>
-
-typedef struct private_tcg_pts_attr_dh_nonce_finish_t
- private_tcg_pts_attr_dh_nonce_finish_t;
-
-/**
- * PTS DH Nonce Finish
- * see section 3.8.3 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 | Nonce Len | Selected Hash Algorithm |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | D-H Initiator Public Value ... |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | D-H Initiator Nonce ... |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- *
- */
-
-#define PTS_DH_NONCE_FINISH_SIZE 12
-#define PTS_DH_NONCE_FINISH_RESERVED 0x00
-
-/**
- * Private data of an tcg_pts_attr_dh_nonce_finish_t object.
- */
-struct private_tcg_pts_attr_dh_nonce_finish_t {
-
- /**
- * Public members of tcg_pts_attr_dh_nonce_finish_t
- */
- tcg_pts_attr_dh_nonce_finish_t public;
-
- /**
- * Vendor-specific attribute type
- */
- pen_type_t type;
-
- /**
- * Attribute value
- */
- chunk_t value;
-
- /**
- * Noskip flag
- */
- bool noskip_flag;
-
- /**
- * Selected Hashing Algorithm
- */
- pts_meas_algorithms_t hash_algo;
-
- /**
- * DH Initiator Public Value
- */
- chunk_t initiator_value;
-
- /**
- * DH Initiator Nonce
- */
- chunk_t initiator_nonce;
-
- /**
- * Reference count
- */
- refcount_t ref;
-};
-
-METHOD(pa_tnc_attr_t, get_type, pen_type_t,
- private_tcg_pts_attr_dh_nonce_finish_t *this)
-{
- return this->type;
-}
-
-METHOD(pa_tnc_attr_t, get_value, chunk_t,
- private_tcg_pts_attr_dh_nonce_finish_t *this)
-{
- return this->value;
-}
-
-METHOD(pa_tnc_attr_t, get_noskip_flag, bool,
- private_tcg_pts_attr_dh_nonce_finish_t *this)
-{
- return this->noskip_flag;
-}
-
-METHOD(pa_tnc_attr_t, set_noskip_flag,void,
- private_tcg_pts_attr_dh_nonce_finish_t *this, bool noskip)
-{
- this->noskip_flag = noskip;
-}
-
-METHOD(pa_tnc_attr_t, build, void,
- private_tcg_pts_attr_dh_nonce_finish_t *this)
-{
- bio_writer_t *writer;
-
- if (this->value.ptr)
- {
- return;
- }
- writer = bio_writer_create(PTS_DH_NONCE_FINISH_SIZE);
- writer->write_uint8 (writer, PTS_DH_NONCE_FINISH_RESERVED);
- writer->write_uint8 (writer, this->initiator_nonce.len);
- writer->write_uint16(writer, this->hash_algo);
- writer->write_data (writer, this->initiator_value);
- writer->write_data (writer, this->initiator_nonce);
-
- this->value = writer->extract_buf(writer);
- writer->destroy(writer);
-}
-
-METHOD(pa_tnc_attr_t, process, status_t,
- private_tcg_pts_attr_dh_nonce_finish_t *this, u_int32_t *offset)
-{
- bio_reader_t *reader;
- u_int8_t reserved, nonce_len;
- u_int16_t hash_algo;
-
- if (this->value.len < PTS_DH_NONCE_FINISH_SIZE)
- {
- DBG1(DBG_TNC, "insufficient data for PTS DH Nonce Finish");
- *offset = 0;
- return FAILED;
- }
- reader = bio_reader_create(this->value);
- reader->read_uint8 (reader, &reserved);
- reader->read_uint8 (reader, &nonce_len);
- reader->read_uint16(reader, &hash_algo);
- reader->read_data(reader, reader->remaining(reader) - nonce_len,
- &this->initiator_value);
- reader->read_data(reader, nonce_len, &this->initiator_nonce);
- this->hash_algo = hash_algo;
- this->initiator_value = chunk_clone(this->initiator_value);
- this->initiator_nonce = chunk_clone(this->initiator_nonce);
- reader->destroy(reader);
-
- return SUCCESS;
-}
-
-METHOD(pa_tnc_attr_t, get_ref, pa_tnc_attr_t*,
- private_tcg_pts_attr_dh_nonce_finish_t *this)
-{
- ref_get(&this->ref);
- return &this->public.pa_tnc_attribute;
-}
-
-METHOD(pa_tnc_attr_t, destroy, void,
- private_tcg_pts_attr_dh_nonce_finish_t *this)
-{
- if (ref_put(&this->ref))
- {
- free(this->value.ptr);
- free(this->initiator_value.ptr);
- free(this->initiator_nonce.ptr);
- free(this);
- }
-}
-
-METHOD(tcg_pts_attr_dh_nonce_finish_t, get_hash_algo, pts_meas_algorithms_t,
- private_tcg_pts_attr_dh_nonce_finish_t *this)
-{
- return this->hash_algo;
-}
-
-METHOD(tcg_pts_attr_dh_nonce_finish_t, get_initiator_value, chunk_t,
- private_tcg_pts_attr_dh_nonce_finish_t *this)
-{
- return this->initiator_value;
-}
-
-METHOD(tcg_pts_attr_dh_nonce_finish_t, get_initiator_nonce, chunk_t,
- private_tcg_pts_attr_dh_nonce_finish_t *this)
-{
- return this->initiator_nonce;
-}
-
-/**
- * Described in header.
- */
-pa_tnc_attr_t *tcg_pts_attr_dh_nonce_finish_create(
- pts_meas_algorithms_t hash_algo,
- chunk_t initiator_value,
- chunk_t initiator_nonce)
-{
- private_tcg_pts_attr_dh_nonce_finish_t *this;
-
- INIT(this,
- .public = {
- .pa_tnc_attribute = {
- .get_type = _get_type,
- .get_value = _get_value,
- .get_noskip_flag = _get_noskip_flag,
- .set_noskip_flag = _set_noskip_flag,
- .build = _build,
- .process = _process,
- .get_ref = _get_ref,
- .destroy = _destroy,
- },
- .get_hash_algo = _get_hash_algo,
- .get_initiator_nonce = _get_initiator_nonce,
- .get_initiator_value = _get_initiator_value,
- },
- .type = { PEN_TCG, TCG_PTS_DH_NONCE_FINISH },
- .hash_algo = hash_algo,
- .initiator_value = initiator_value,
- .initiator_nonce = chunk_clone(initiator_nonce),
- .ref = 1,
- );
-
- return &this->public.pa_tnc_attribute;
-}
-
-/**
- * Described in header.
- */
-pa_tnc_attr_t *tcg_pts_attr_dh_nonce_finish_create_from_data(chunk_t value)
-{
- private_tcg_pts_attr_dh_nonce_finish_t *this;
-
- INIT(this,
- .public = {
- .pa_tnc_attribute = {
- .get_type = _get_type,
- .get_value = _get_value,
- .get_noskip_flag = _get_noskip_flag,
- .set_noskip_flag = _set_noskip_flag,
- .build = _build,
- .process = _process,
- .get_ref = _get_ref,
- .destroy = _destroy,
- },
- .get_hash_algo = _get_hash_algo,
- .get_initiator_nonce = _get_initiator_nonce,
- .get_initiator_value = _get_initiator_value,
- },
- .type = { PEN_TCG, TCG_PTS_DH_NONCE_FINISH },
- .value = chunk_clone(value),
- .ref = 1,
- );
-
- return &this->public.pa_tnc_attribute;
-}
+++ /dev/null
-/*
- * 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_dh_nonce_finish tcg_pts_attr_dh_nonce_finish
- * @{ @ingroup tcg_attr
- */
-
-#ifndef TCG_PTS_ATTR_DH_NONCE_FINISH_H_
-#define TCG_PTS_ATTR_DH_NONCE_FINISH_H_
-
-typedef struct tcg_pts_attr_dh_nonce_finish_t tcg_pts_attr_dh_nonce_finish_t;
-
-#include "tcg_attr.h"
-#include "pa_tnc/pa_tnc_attr.h"
-#include "pts/pts_meas_algo.h"
-
-/**
- * Class implementing the TCG PTS DH Nonce Finish Attribute
- */
-struct tcg_pts_attr_dh_nonce_finish_t {
-
- /**
- * Public PA-TNC attribute interface
- */
- pa_tnc_attr_t pa_tnc_attribute;
-
- /**
- * Get nonce length
- *
- * @return Length of nonce
- */
- u_int8_t (*get_nonce_len)(tcg_pts_attr_dh_nonce_finish_t *this);
-
- /**
- * Get selected hash algorithm
- *
- * @return Selected hash algorithm
- */
- pts_meas_algorithms_t (*get_hash_algo)(tcg_pts_attr_dh_nonce_finish_t *this);
-
- /**
- * Get DH Initiator Public Value
- *
- * @return DH Initiator Public Value
- */
- chunk_t (*get_initiator_value)(tcg_pts_attr_dh_nonce_finish_t *this);
-
- /**
- * Get DH Initiator Nonce
- *
- * @return DH Initiator Nonce
- */
- chunk_t (*get_initiator_nonce)(tcg_pts_attr_dh_nonce_finish_t *this);
-
-};
-
-/**
- * Creates an tcg_pts_attr_dh_nonce_finish_t object
- *
- * @param hash_algo Selected hash algorithm
- * @param initiator_value DH Initiator Public Value
- * @param initiator_nonce DH Initiator Nonce
- */
-pa_tnc_attr_t* tcg_pts_attr_dh_nonce_finish_create(
- pts_meas_algorithms_t hash_algo,
- chunk_t initiator_value,
- chunk_t initiator_nonce);
-
-/**
- * Creates an tcg_pts_attr_dh_nonce_finish_t object from received data
- *
- * @param value unparsed attribute value
- */
-pa_tnc_attr_t* tcg_pts_attr_dh_nonce_finish_create_from_data(chunk_t value);
-
-#endif /** TCG_PTS_ATTR_DH_NONCE_FINISH_H_ @}*/
+++ /dev/null
-/*
- * Copyright (C) 2011-2012 Sansar Choinyambuu, Andreas Steffen
- * HSR Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#include "tcg_pts_attr_dh_nonce_params_req.h"
-
-#include <pa_tnc/pa_tnc_msg.h>
-#include <bio/bio_writer.h>
-#include <bio/bio_reader.h>
-#include <utils/debug.h>
-
-typedef struct private_tcg_pts_attr_dh_nonce_params_req_t
- private_tcg_pts_attr_dh_nonce_params_req_t;
-
-/**
- * PTS DH Nonce Parameters Request
- * see section 3.8.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 | Min. Nonce Len | D-H Group Set |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- *
- */
-
-#define PTS_DH_NONCE_PARAMS_REQ_SIZE 4
-#define PTS_DH_NONCE_PARAMS_REQ_RESERVED 0x00
-
-/**
- * Private data of an tcg_pts_attr_dh_nonce_params_req_t object.
- */
-struct private_tcg_pts_attr_dh_nonce_params_req_t {
-
- /**
- * Public members of tcg_pts_attr_dh_nonce_params_req_t
- */
- tcg_pts_attr_dh_nonce_params_req_t public;
-
- /**
- * Vendor-specific attribute type
- */
- pen_type_t type;
-
- /**
- * Attribute value
- */
- chunk_t value;
-
- /**
- * Noskip flag
- */
- bool noskip_flag;
-
- /**
- * Minimum acceptable length of nonce
- */
- u_int8_t min_nonce_len;
-
- /**
- * Diffie Hellman group set
- */
- pts_dh_group_t dh_groups;
-
- /**
- * Reference count
- */
- refcount_t ref;
-};
-
-METHOD(pa_tnc_attr_t, get_type, pen_type_t,
- private_tcg_pts_attr_dh_nonce_params_req_t *this)
-{
- return this->type;
-}
-
-METHOD(pa_tnc_attr_t, get_value, chunk_t,
- private_tcg_pts_attr_dh_nonce_params_req_t *this)
-{
- return this->value;
-}
-
-METHOD(pa_tnc_attr_t, get_noskip_flag, bool,
- private_tcg_pts_attr_dh_nonce_params_req_t *this)
-{
- return this->noskip_flag;
-}
-
-METHOD(pa_tnc_attr_t, set_noskip_flag,void,
- private_tcg_pts_attr_dh_nonce_params_req_t *this, bool noskip)
-{
- this->noskip_flag = noskip;
-}
-
-METHOD(pa_tnc_attr_t, build, void,
- private_tcg_pts_attr_dh_nonce_params_req_t *this)
-{
- bio_writer_t *writer;
-
- if (this->value.ptr)
- {
- return;
- }
- writer = bio_writer_create(PTS_DH_NONCE_PARAMS_REQ_SIZE);
- writer->write_uint8 (writer, PTS_DH_NONCE_PARAMS_REQ_RESERVED);
- writer->write_uint8 (writer, this->min_nonce_len);
- writer->write_uint16(writer, this->dh_groups);
-
- this->value = writer->extract_buf(writer);
- writer->destroy(writer);
-}
-
-METHOD(pa_tnc_attr_t, process, status_t,
- private_tcg_pts_attr_dh_nonce_params_req_t *this, u_int32_t *offset)
-{
- bio_reader_t *reader;
- u_int8_t reserved;
- u_int16_t dh_groups;
-
- if (this->value.len < PTS_DH_NONCE_PARAMS_REQ_SIZE)
- {
- DBG1(DBG_TNC, "insufficient data for PTS DH Nonce Parameters Request");
- *offset = 0;
- return FAILED;
- }
- reader = bio_reader_create(this->value);
- reader->read_uint8(reader, &reserved);
- reader->read_uint8(reader, &this->min_nonce_len);
- reader->read_uint16(reader, &dh_groups);
- this->dh_groups = dh_groups;
- reader->destroy(reader);
-
- return SUCCESS;
-}
-
-METHOD(pa_tnc_attr_t, get_ref, pa_tnc_attr_t*,
- private_tcg_pts_attr_dh_nonce_params_req_t *this)
-{
- ref_get(&this->ref);
- return &this->public.pa_tnc_attribute;
-}
-
-METHOD(pa_tnc_attr_t, destroy, void,
- private_tcg_pts_attr_dh_nonce_params_req_t *this)
-{
- if (ref_put(&this->ref))
- {
- free(this->value.ptr);
- free(this);
- }
-}
-
-METHOD(tcg_pts_attr_dh_nonce_params_req_t, get_min_nonce_len, u_int8_t,
- private_tcg_pts_attr_dh_nonce_params_req_t *this)
-{
- return this->min_nonce_len;
-}
-
-METHOD(tcg_pts_attr_dh_nonce_params_req_t, get_dh_groups, pts_dh_group_t,
- private_tcg_pts_attr_dh_nonce_params_req_t *this)
-{
- return this->dh_groups;
-}
-
-/**
- * Described in header.
- */
-pa_tnc_attr_t *tcg_pts_attr_dh_nonce_params_req_create(u_int8_t min_nonce_len,
- pts_dh_group_t dh_groups)
-{
- private_tcg_pts_attr_dh_nonce_params_req_t *this;
-
- INIT(this,
- .public = {
- .pa_tnc_attribute = {
- .get_type = _get_type,
- .get_value = _get_value,
- .get_noskip_flag = _get_noskip_flag,
- .set_noskip_flag = _set_noskip_flag,
- .build = _build,
- .process = _process,
- .get_ref = _get_ref,
- .destroy = _destroy,
- },
- .get_min_nonce_len = _get_min_nonce_len,
- .get_dh_groups = _get_dh_groups,
- },
- .type = { PEN_TCG, TCG_PTS_DH_NONCE_PARAMS_REQ },
- .min_nonce_len = min_nonce_len,
- .dh_groups = dh_groups,
- .ref = 1,
- );
-
- return &this->public.pa_tnc_attribute;
-}
-
-/**
- * Described in header.
- */
-pa_tnc_attr_t *tcg_pts_attr_dh_nonce_params_req_create_from_data(chunk_t value)
-{
- private_tcg_pts_attr_dh_nonce_params_req_t *this;
-
- INIT(this,
- .public = {
- .pa_tnc_attribute = {
- .get_type = _get_type,
- .get_value = _get_value,
- .get_noskip_flag = _get_noskip_flag,
- .set_noskip_flag = _set_noskip_flag,
- .build = _build,
- .process = _process,
- .get_ref = _get_ref,
- .destroy = _destroy,
- },
- .get_min_nonce_len = _get_min_nonce_len,
- .get_dh_groups = _get_dh_groups,
- },
- .type = { PEN_TCG, TCG_PTS_DH_NONCE_PARAMS_REQ },
- .value = chunk_clone(value),
- .ref = 1,
- );
-
- return &this->public.pa_tnc_attribute;
-}
+++ /dev/null
-/*
- * 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_dh_nonce_params_req tcg_pts_attr_dh_nonce_params_req
- * @{ @ingroup tcg_attr
- */
-
-#ifndef TCG_PTS_ATTR_DH_NONCE_PARAMS_REQ_H_
-#define TCG_PTS_ATTR_DH_NONCE_PARAMS_REQ_H_
-
-typedef struct tcg_pts_attr_dh_nonce_params_req_t
- tcg_pts_attr_dh_nonce_params_req_t;
-
-#include "tcg_attr.h"
-#include "pa_tnc/pa_tnc_attr.h"
-#include "pts/pts_dh_group.h"
-
-/**
- * Class implementing the TCG PTS DH Nonce Parameters Request Attribute
- */
-struct tcg_pts_attr_dh_nonce_params_req_t {
-
- /**
- * Public PA-TNC attribute interface
- */
- pa_tnc_attr_t pa_tnc_attribute;
-
- /**
- * Get Minimum nonce length
- *
- * @return Minimum acceptable length of nonce
- */
- u_int8_t (*get_min_nonce_len)(tcg_pts_attr_dh_nonce_params_req_t *this);
-
- /**
- * Get supported Diffie Hellman Groups
- *
- * @return Supported Diffie Hellman Groups
- */
- pts_dh_group_t (*get_dh_groups)(tcg_pts_attr_dh_nonce_params_req_t *this);
-};
-
-/**
- * Creates an tcg_pts_attr_dh_nonce_params_req_t object
- *
- * @param min_nonce_len Minimum acceptable length of nonce
- * @param dh_groups Initiator's supported DH groups
- */
-pa_tnc_attr_t* tcg_pts_attr_dh_nonce_params_req_create(u_int8_t min_nonce_len,
- pts_dh_group_t dh_groups);
-
-/**
- * Creates an tcg_pts_attr_dh_nonce_params_req_t object from received data
- *
- * @param value unparsed attribute value
- */
-pa_tnc_attr_t* tcg_pts_attr_dh_nonce_params_req_create_from_data(chunk_t value);
-
-#endif /** TCG_PTS_ATTR_DH_NONCE_PARAMS_REQ_H_ @}*/
+++ /dev/null
-/*
- * Copyright (C) 2011-2012 Sansar Choinyambuu, Andreas Steffen
- * HSR Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#include "tcg_pts_attr_dh_nonce_params_resp.h"
-
-#include <pa_tnc/pa_tnc_msg.h>
-#include <bio/bio_writer.h>
-#include <bio/bio_reader.h>
-#include <utils/debug.h>
-
-typedef struct private_tcg_pts_attr_dh_nonce_params_resp_t
- private_tcg_pts_attr_dh_nonce_params_resp_t;
-
-/**
- * PTS DH Nonce Parameters Response
- * see section 3.8.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 | Nonce Len |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Selected D-H Group | Hash Algorithm Set |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | D-H Responder Nonce ... |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | D-H Responder Public Value ... |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- *
- */
-
-#define PTS_DH_NONCE_PARAMS_RESP_SIZE 16
-#define PTS_DH_NONCE_PARAMS_RESP_RESERVED 0x0000
-
-/**
- * Private data of an tcg_pts_attr_dh_nonce_params_resp_t object.
- */
-struct private_tcg_pts_attr_dh_nonce_params_resp_t {
-
- /**
- * Public members of tcg_pts_attr_dh_nonce_params_resp_t
- */
- tcg_pts_attr_dh_nonce_params_resp_t public;
-
- /**
- * Vendor-specific attribute type
- */
- pen_type_t type;
-
- /**
- * Attribute value
- */
- chunk_t value;
-
- /**
- * Noskip flag
- */
- bool noskip_flag;
-
- /**
- * Selected Diffie Hellman group
- */
- pts_dh_group_t dh_group;
-
- /**
- * Supported Hashing Algorithms
- */
- pts_meas_algorithms_t hash_algo_set;
-
- /**
- * DH Responder Nonce
- */
- chunk_t responder_nonce;
-
- /**
- * DH Responder Public Value
- */
- chunk_t responder_value;
-
- /**
- * Reference count
- */
- refcount_t ref;
-};
-
-METHOD(pa_tnc_attr_t, get_type, pen_type_t,
- private_tcg_pts_attr_dh_nonce_params_resp_t *this)
-{
- return this->type;
-}
-
-METHOD(pa_tnc_attr_t, get_value, chunk_t,
- private_tcg_pts_attr_dh_nonce_params_resp_t *this)
-{
- return this->value;
-}
-
-METHOD(pa_tnc_attr_t, get_noskip_flag, bool,
- private_tcg_pts_attr_dh_nonce_params_resp_t *this)
-{
- return this->noskip_flag;
-}
-
-METHOD(pa_tnc_attr_t, set_noskip_flag,void,
- private_tcg_pts_attr_dh_nonce_params_resp_t *this, bool noskip)
-{
- this->noskip_flag = noskip;
-}
-
-METHOD(pa_tnc_attr_t, build, void,
- private_tcg_pts_attr_dh_nonce_params_resp_t *this)
-{
- bio_writer_t *writer;
-
- if (this->value.ptr)
- {
- return;
- }
- writer = bio_writer_create(PTS_DH_NONCE_PARAMS_RESP_SIZE);
- writer->write_uint24(writer, PTS_DH_NONCE_PARAMS_RESP_RESERVED);
- writer->write_uint8 (writer, this->responder_nonce.len);
- writer->write_uint16(writer, this->dh_group);
- writer->write_uint16(writer, this->hash_algo_set);
- writer->write_data (writer, this->responder_nonce);
- writer->write_data (writer, this->responder_value);
-
- this->value = writer->extract_buf(writer);
- writer->destroy(writer);
-}
-
-METHOD(pa_tnc_attr_t, process, status_t,
- private_tcg_pts_attr_dh_nonce_params_resp_t *this, u_int32_t *offset)
-{
- bio_reader_t *reader;
- u_int32_t reserved;
- u_int8_t nonce_len;
- u_int16_t dh_group, hash_algo_set;
-
- if (this->value.len < PTS_DH_NONCE_PARAMS_RESP_SIZE)
- {
- DBG1(DBG_TNC, "insufficient data for PTS DH Nonce Parameters Response");
- *offset = 0;
- return FAILED;
- }
- reader = bio_reader_create(this->value);
- reader->read_uint24(reader, &reserved);
- reader->read_uint8 (reader, &nonce_len);
- reader->read_uint16(reader, &dh_group);
- reader->read_uint16(reader, &hash_algo_set);
- reader->read_data(reader, nonce_len, &this->responder_nonce);
- reader->read_data(reader, reader->remaining(reader), &this->responder_value);
- this->dh_group = dh_group;
- this->hash_algo_set = hash_algo_set;
- this->responder_nonce = chunk_clone(this->responder_nonce);
- this->responder_value = chunk_clone(this->responder_value);
- reader->destroy(reader);
-
- return SUCCESS;
-}
-
-METHOD(pa_tnc_attr_t, get_ref, pa_tnc_attr_t*,
- private_tcg_pts_attr_dh_nonce_params_resp_t *this)
-{
- ref_get(&this->ref);
- return &this->public.pa_tnc_attribute;
-}
-
-METHOD(pa_tnc_attr_t, destroy, void,
- private_tcg_pts_attr_dh_nonce_params_resp_t *this)
-{
- if (ref_put(&this->ref))
- {
- free(this->value.ptr);
- free(this->responder_nonce.ptr);
- free(this->responder_value.ptr);
- free(this);
- }
-}
-
-METHOD(tcg_pts_attr_dh_nonce_params_resp_t, get_dh_group, pts_dh_group_t,
- private_tcg_pts_attr_dh_nonce_params_resp_t *this)
-{
- return this->dh_group;
-}
-
-METHOD(tcg_pts_attr_dh_nonce_params_resp_t, get_hash_algo_set,
- pts_meas_algorithms_t, private_tcg_pts_attr_dh_nonce_params_resp_t *this)
-{
- return this->hash_algo_set;
-}
-
-METHOD(tcg_pts_attr_dh_nonce_params_resp_t, get_responder_nonce, chunk_t,
- private_tcg_pts_attr_dh_nonce_params_resp_t *this)
-{
- return this->responder_nonce;
-}
-
-METHOD(tcg_pts_attr_dh_nonce_params_resp_t, get_responder_value, chunk_t,
- private_tcg_pts_attr_dh_nonce_params_resp_t *this)
-{
- return this->responder_value;
-}
-
-/**
- * Described in header.
- */
-pa_tnc_attr_t *tcg_pts_attr_dh_nonce_params_resp_create(pts_dh_group_t dh_group,
- pts_meas_algorithms_t hash_algo_set,
- chunk_t responder_nonce,
- chunk_t responder_value)
-{
- private_tcg_pts_attr_dh_nonce_params_resp_t *this;
-
- INIT(this,
- .public = {
- .pa_tnc_attribute = {
- .get_type = _get_type,
- .get_value = _get_value,
- .get_noskip_flag = _get_noskip_flag,
- .set_noskip_flag = _set_noskip_flag,
- .build = _build,
- .process = _process,
- .get_ref = _get_ref,
- .destroy = _destroy,
- },
- .get_dh_group = _get_dh_group,
- .get_hash_algo_set = _get_hash_algo_set,
- .get_responder_nonce = _get_responder_nonce,
- .get_responder_value = _get_responder_value,
- },
- .type = { PEN_TCG, TCG_PTS_DH_NONCE_PARAMS_RESP },
- .dh_group = dh_group,
- .hash_algo_set = hash_algo_set,
- .responder_nonce = chunk_clone(responder_nonce),
- .responder_value = responder_value,
- .ref = 1,
- );
-
- return &this->public.pa_tnc_attribute;
-}
-
-/**
- * Described in header.
- */
-pa_tnc_attr_t *tcg_pts_attr_dh_nonce_params_resp_create_from_data(chunk_t value)
-{
- private_tcg_pts_attr_dh_nonce_params_resp_t *this;
-
- INIT(this,
- .public = {
- .pa_tnc_attribute = {
- .get_type = _get_type,
- .get_value = _get_value,
- .get_noskip_flag = _get_noskip_flag,
- .set_noskip_flag = _set_noskip_flag,
- .build = _build,
- .process = _process,
- .get_ref = _get_ref,
- .destroy = _destroy,
- },
- .get_dh_group = _get_dh_group,
- .get_hash_algo_set = _get_hash_algo_set,
- .get_responder_nonce = _get_responder_nonce,
- .get_responder_value = _get_responder_value,
- },
- .type = { PEN_TCG, TCG_PTS_DH_NONCE_PARAMS_RESP },
- .value = chunk_clone(value),
- .ref = 1,
- );
-
- return &this->public.pa_tnc_attribute;
-}
+++ /dev/null
-/*
- * 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_dh_nonce_params_resp tcg_pts_attr_dh_nonce_params_resp
- * @{ @ingroup tcg_attr
- */
-
-#ifndef TCG_PTS_ATTR_DH_NONCE_PARAMS_RESP_H_
-#define TCG_PTS_ATTR_DH_NONCE_PARAMS_RESP_H_
-
-typedef struct tcg_pts_attr_dh_nonce_params_resp_t
- tcg_pts_attr_dh_nonce_params_resp_t;
-
-#include "tcg_attr.h"
-#include "pa_tnc/pa_tnc_attr.h"
-#include "pts/pts_dh_group.h"
-#include "pts/pts_meas_algo.h"
-
-/**
- * Class implementing the TCG PTS DH Nonce Parameters Response Attribute
- */
-struct tcg_pts_attr_dh_nonce_params_resp_t {
-
- /**
- * Public PA-TNC attribute interface
- */
- pa_tnc_attr_t pa_tnc_attribute;
-
- /**
- * Get selected Diffie Hellman Group
- *
- * @return Selected Diffie Hellman Group
- */
- pts_dh_group_t (*get_dh_group)(tcg_pts_attr_dh_nonce_params_resp_t *this);
-
- /**
- * Get supported hash algorithms
- *
- * @return Hash algorithm set
- */
- pts_meas_algorithms_t (*get_hash_algo_set)(
- tcg_pts_attr_dh_nonce_params_resp_t *this);
-
- /**
- * Get DH Responder Nonce
- *
- * @return DH Responder Nonce
- */
- chunk_t (*get_responder_nonce)(tcg_pts_attr_dh_nonce_params_resp_t *this);
-
- /**
- * Get DH Responder Public Value
- *
- * @return DH Responder Public Value
- */
- chunk_t (*get_responder_value)(tcg_pts_attr_dh_nonce_params_resp_t *this);
-
-};
-
-/**
- * Creates an tcg_pts_attr_dh_nonce_params_resp_t object
- *
- * @param dh_group Selected DH group
- * @param hash_algo_set Set of supported hash algorithms
- * @param responder_nonce DH Responder Nonce
- * @param responder_value DH Responder Public value
- */
-pa_tnc_attr_t* tcg_pts_attr_dh_nonce_params_resp_create(pts_dh_group_t dh_group,
- pts_meas_algorithms_t hash_algo_set,
- chunk_t responder_nonce,
- chunk_t responder_value);
-
-/**
- * Creates an tcg_pts_attr_dh_nonce_params_resp_t object from received data
- *
- * @param value unparsed attribute value
- */
-pa_tnc_attr_t* tcg_pts_attr_dh_nonce_params_resp_create_from_data(chunk_t value);
-
-#endif /** TCG_PTS_ATTR_DH_NONCE_PARAMS_RESP_H_ @}*/
+++ /dev/null
-/*
- * Copyright (C) 2011-2012 Sansar Choinyambuu, Andreas Steffen
- * HSR Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#include "tcg_pts_attr_file_meas.h"
-
-#include <pa_tnc/pa_tnc_msg.h>
-#include <bio/bio_writer.h>
-#include <bio/bio_reader.h>
-#include <collections/linked_list.h>
-#include <utils/debug.h>
-
-typedef struct private_tcg_pts_attr_file_meas_t private_tcg_pts_attr_file_meas_t;
-
-/**
- * File Measurement
- * see section 3.19.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
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Number of Files included |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Number of Files included |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Request ID | Measurement Length |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Measurement #1 (Variable Length) |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Filename Length | Filename (Variable Length) ~
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * ~ Filename (Variable Length) ~
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Measurement #2 (Variable Length) |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Filename Length | Filename (Variable Length) ~
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * ~ Filename (Variable Length) ~
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * ...........................
- */
-
-#define PTS_FILE_MEAS_SIZE 12
-
-/**
- * Private data of an tcg_pts_attr_file_meas_t object.
- */
-struct private_tcg_pts_attr_file_meas_t {
-
- /**
- * Public members of tcg_pts_attr_file_meas_t
- */
- tcg_pts_attr_file_meas_t public;
-
- /**
- * Vendor-specific attribute type
- */
- pen_type_t type;
-
- /**
- * Attribute value
- */
- chunk_t value;
-
- /**
- * Noskip flag
- */
- bool noskip_flag;
-
- /**
- * PTS File Measurements
- */
- pts_file_meas_t *measurements;
-
- /**
- * Reference count
- */
- refcount_t ref;
-};
-
-METHOD(pa_tnc_attr_t, get_type, pen_type_t,
- private_tcg_pts_attr_file_meas_t *this)
-{
- return this->type;
-}
-
-METHOD(pa_tnc_attr_t, get_value, chunk_t,
- private_tcg_pts_attr_file_meas_t *this)
-{
- return this->value;
-}
-
-METHOD(pa_tnc_attr_t, get_noskip_flag, bool,
- private_tcg_pts_attr_file_meas_t *this)
-{
- return this->noskip_flag;
-}
-
-METHOD(pa_tnc_attr_t, set_noskip_flag,void,
- private_tcg_pts_attr_file_meas_t *this, bool noskip)
-{
- this->noskip_flag = noskip;
-}
-
-METHOD(pa_tnc_attr_t, build, void,
- private_tcg_pts_attr_file_meas_t *this)
-{
- bio_writer_t *writer;
- enumerator_t *enumerator;
- u_int64_t number_of_files;
- u_int16_t request_id;
- char *filename;
- chunk_t measurement;
- bool first = TRUE;
-
- if (this->value.ptr)
- {
- return;
- }
- number_of_files = this->measurements->get_file_count(this->measurements);
- request_id = this->measurements->get_request_id(this->measurements);
-
- writer = bio_writer_create(PTS_FILE_MEAS_SIZE);
- writer->write_uint64(writer, number_of_files);
- writer->write_uint16(writer, request_id);
-
- enumerator = this->measurements->create_enumerator(this->measurements);
- while (enumerator->enumerate(enumerator, &filename, &measurement))
- {
- if (first)
- {
- writer->write_uint16(writer, measurement.len);
- first = FALSE;
- }
- writer->write_data (writer, measurement);
- writer->write_data16(writer, chunk_create(filename, strlen(filename)));
- }
- enumerator->destroy(enumerator);
-
- if (first)
- {
- /* no attached measurements */
- writer->write_uint16(writer, 0);
- }
-
- this->value = writer->extract_buf(writer);
- writer->destroy(writer);
-}
-
-METHOD(pa_tnc_attr_t, process, status_t,
- private_tcg_pts_attr_file_meas_t *this, u_int32_t *offset)
-{
- bio_reader_t *reader;
- u_int64_t number_of_files;
- u_int16_t request_id, meas_len;
- chunk_t measurement, filename;
- size_t len;
- char buf[BUF_LEN];
- status_t status = FAILED;
-
- if (this->value.len < PTS_FILE_MEAS_SIZE)
- {
- DBG1(DBG_TNC, "insufficient data for PTS file measurement header");
- *offset = 0;
- return FAILED;
- }
-
- reader = bio_reader_create(this->value);
- reader->read_uint64(reader, &number_of_files);
- reader->read_uint16(reader, &request_id);
- reader->read_uint16(reader, &meas_len);
- *offset = PTS_FILE_MEAS_SIZE;
-
- this->measurements = pts_file_meas_create(request_id);
-
- while (number_of_files--)
- {
- if (!reader->read_data(reader, meas_len, &measurement))
- {
- DBG1(DBG_TNC, "insufficient data for PTS file measurement");
- goto end;
- }
- *offset += meas_len;
-
- if (!reader->read_data16(reader, &filename))
- {
- DBG1(DBG_TNC, "insufficient data for filename");
- goto end;
- }
- *offset += 2 + filename.len;
-
- len = min(filename.len, BUF_LEN-1);
- memcpy(buf, filename.ptr, len);
- buf[len] = '\0';
- this->measurements->add(this->measurements, buf, measurement);
- }
- status = SUCCESS;
-
-end:
- reader->destroy(reader);
- return status;
-}
-
-METHOD(pa_tnc_attr_t, get_ref, pa_tnc_attr_t*,
- private_tcg_pts_attr_file_meas_t *this)
-{
- ref_get(&this->ref);
- return &this->public.pa_tnc_attribute;
-}
-METHOD(pa_tnc_attr_t, destroy, void,
- private_tcg_pts_attr_file_meas_t *this)
-{
- if (ref_put(&this->ref))
- {
- DESTROY_IF(this->measurements);
- free(this->value.ptr);
- free(this);
- }
-}
-
-METHOD(tcg_pts_attr_file_meas_t, get_measurements, pts_file_meas_t*,
- private_tcg_pts_attr_file_meas_t *this)
-{
- return this->measurements;
-}
-
-/**
- * Described in header.
- */
-pa_tnc_attr_t *tcg_pts_attr_file_meas_create(pts_file_meas_t *measurements)
-{
- private_tcg_pts_attr_file_meas_t *this;
-
- INIT(this,
- .public = {
- .pa_tnc_attribute = {
- .get_type = _get_type,
- .get_value = _get_value,
- .get_noskip_flag = _get_noskip_flag,
- .set_noskip_flag = _set_noskip_flag,
- .build = _build,
- .process = _process,
- .get_ref = _get_ref,
- .destroy = _destroy,
- },
- .get_measurements = _get_measurements,
- },
- .type = { PEN_TCG, TCG_PTS_FILE_MEAS },
- .measurements = measurements,
- .ref = 1,
- );
-
- return &this->public.pa_tnc_attribute;
-}
-
-
-/**
- * Described in header.
- */
-pa_tnc_attr_t *tcg_pts_attr_file_meas_create_from_data(chunk_t data)
-{
- private_tcg_pts_attr_file_meas_t *this;
-
- INIT(this,
- .public = {
- .pa_tnc_attribute = {
- .get_type = _get_type,
- .get_value = _get_value,
- .get_noskip_flag = _get_noskip_flag,
- .set_noskip_flag = _set_noskip_flag,
- .build = _build,
- .process = _process,
- .get_ref = _get_ref,
- .destroy = _destroy,
- },
- .get_measurements = _get_measurements,
- },
- .type = { PEN_TCG, TCG_PTS_FILE_MEAS },
- .value = chunk_clone(data),
- .ref = 1,
- );
-
- return &this->public.pa_tnc_attribute;
-}
+++ /dev/null
-/*
- * 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_file_meas tcg_pts_attr_file_meas
- * @{ @ingroup tcg_attr
- */
-
-#ifndef TCG_PTS_ATTR_FILE_MEAS_H_
-#define TCG_PTS_ATTR_FILE_MEAS_H_
-
-typedef struct tcg_pts_attr_file_meas_t tcg_pts_attr_file_meas_t;
-
-#include "tcg_attr.h"
-#include "pa_tnc/pa_tnc_attr.h"
-#include "pts/pts.h"
-#include "pts/pts_file_meas.h"
-
-/**
- * Class implementing the TCG PTS File Measurement attribute
- *
- */
-struct tcg_pts_attr_file_meas_t {
-
- /**
- * Public PA-TNC attribute interface
- */
- pa_tnc_attr_t pa_tnc_attribute;
-
- /**
- * Get PTS File Measurements
- *
- * @return PTS File Measurements
- */
- pts_file_meas_t* (*get_measurements)(tcg_pts_attr_file_meas_t *this);
-
-};
-
-/**
- * Creates an tcg_pts_attr_file_meas_t object
- *
- * @param measurements PTS File Measurements
- */
-pa_tnc_attr_t* tcg_pts_attr_file_meas_create(pts_file_meas_t *measurements);
-
-/**
- * Creates an tcg_pts_attr_file_meas_t object from received data
- *
- * @param value unparsed attribute value
- */
-pa_tnc_attr_t* tcg_pts_attr_file_meas_create_from_data(chunk_t value);
-
-#endif /** TCG_PTS_ATTR_FILE_MEAS_H_ @}*/
+++ /dev/null
-/*
- * Copyright (C) 2011-2012 Sansar Choinyambuu, Andreas Steffen
- * HSR Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#include "tcg_pts_attr_gen_attest_evid.h"
-
-#include <pa_tnc/pa_tnc_msg.h>
-#include <bio/bio_writer.h>
-#include <bio/bio_reader.h>
-#include <utils/debug.h>
-
-typedef struct private_tcg_pts_attr_gen_attest_evid_t
- private_tcg_pts_attr_gen_attest_evid_t;
-
-/**
- * Generate Attestation Evidence
- * see section 3.14.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 |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- *
- */
-
-#define PTS_GEN_ATTEST_EVID_SIZE 4
-#define PTS_GEN_ATTEST_EVID_RESERVED 0x00
-
-/**
- * Private data of an tcg_pts_attr_gen_attest_evid_t object.
- */
-struct private_tcg_pts_attr_gen_attest_evid_t {
-
- /**
- * Public members of tcg_pts_attr_gen_attest_evid_t
- */
- tcg_pts_attr_gen_attest_evid_t public;
-
- /**
- * Vendor-specific attribute type
- */
- pen_type_t type;
-
- /**
- * Attribute value
- */
- chunk_t value;
-
- /**
- * Noskip flag
- */
- bool noskip_flag;
-
- /**
- * Reference count
- */
- refcount_t ref;
-};
-
-METHOD(pa_tnc_attr_t, get_type, pen_type_t,
- private_tcg_pts_attr_gen_attest_evid_t *this)
-{
- return this->type;
-}
-
-METHOD(pa_tnc_attr_t, get_value, chunk_t,
- private_tcg_pts_attr_gen_attest_evid_t *this)
-{
- return this->value;
-}
-
-METHOD(pa_tnc_attr_t, get_noskip_flag, bool,
- private_tcg_pts_attr_gen_attest_evid_t *this)
-{
- return this->noskip_flag;
-}
-
-METHOD(pa_tnc_attr_t, set_noskip_flag,void,
- private_tcg_pts_attr_gen_attest_evid_t *this, bool noskip)
-{
- this->noskip_flag = noskip;
-}
-
-METHOD(pa_tnc_attr_t, build, void,
- private_tcg_pts_attr_gen_attest_evid_t *this)
-{
- bio_writer_t *writer;
-
- if (this->value.ptr)
- {
- return;
- }
- writer = bio_writer_create(PTS_GEN_ATTEST_EVID_SIZE);
- writer->write_uint32 (writer, PTS_GEN_ATTEST_EVID_RESERVED);
-
- this->value = writer->extract_buf(writer);
- writer->destroy(writer);
-}
-
-METHOD(pa_tnc_attr_t, process, status_t,
- private_tcg_pts_attr_gen_attest_evid_t *this, u_int32_t *offset)
-{
- bio_reader_t *reader;
- u_int32_t reserved;
-
- if (this->value.len < PTS_GEN_ATTEST_EVID_SIZE)
- {
- DBG1(DBG_TNC, "insufficient data for Generate Attestation Evidence");
- *offset = 0;
- return FAILED;
- }
- reader = bio_reader_create(this->value);
- reader->read_uint32 (reader, &reserved);
- reader->destroy(reader);
-
- return SUCCESS;
-}
-
-METHOD(pa_tnc_attr_t, get_ref, pa_tnc_attr_t*,
- private_tcg_pts_attr_gen_attest_evid_t *this)
-{
- ref_get(&this->ref);
- return &this->public.pa_tnc_attribute;
-}
-
-METHOD(pa_tnc_attr_t, destroy, void,
- private_tcg_pts_attr_gen_attest_evid_t *this)
-{
- if (ref_put(&this->ref))
- {
- free(this->value.ptr);
- free(this);
- }
-}
-
-/**
- * Described in header.
- */
-pa_tnc_attr_t *tcg_pts_attr_gen_attest_evid_create()
-{
- private_tcg_pts_attr_gen_attest_evid_t *this;
-
- INIT(this,
- .public = {
- .pa_tnc_attribute = {
- .get_type = _get_type,
- .get_value = _get_value,
- .get_noskip_flag = _get_noskip_flag,
- .set_noskip_flag = _set_noskip_flag,
- .build = _build,
- .process = _process,
- .get_ref = _get_ref,
- .destroy = _destroy,
- },
- },
- .type = { PEN_TCG, TCG_PTS_GEN_ATTEST_EVID },
- .ref = 1,
- );
-
- return &this->public.pa_tnc_attribute;
-}
-
-
-/**
- * Described in header.
- */
-pa_tnc_attr_t *tcg_pts_attr_gen_attest_evid_create_from_data(chunk_t data)
-{
- private_tcg_pts_attr_gen_attest_evid_t *this;
-
- INIT(this,
- .public = {
- .pa_tnc_attribute = {
- .get_type = _get_type,
- .get_value = _get_value,
- .get_noskip_flag = _get_noskip_flag,
- .set_noskip_flag = _set_noskip_flag,
- .build = _build,
- .process = _process,
- .get_ref = _get_ref,
- .destroy = _destroy,
- },
- },
- .type = { PEN_TCG, TCG_PTS_GEN_ATTEST_EVID },
- .value = chunk_clone(data),
- .ref = 1,
- );
-
- return &this->public.pa_tnc_attribute;
-}
+++ /dev/null
-/*
- * 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_gen_attest_evid tcg_pts_attr_gen_attest_evid
- * @{ @ingroup tcg_attr
- */
-
-#ifndef TCG_PTS_ATTR_GEN_ATTEST_EVID_H_
-#define TCG_PTS_ATTR_GEN_ATTEST_EVID_H_
-
-typedef struct tcg_pts_attr_gen_attest_evid_t tcg_pts_attr_gen_attest_evid_t;
-
-#include "tcg_attr.h"
-#include "pa_tnc/pa_tnc_attr.h"
-
-/**
- * Class implementing the TCG PTS Generate Attestation Evidence Attribute
- *
- */
-struct tcg_pts_attr_gen_attest_evid_t {
-
- /**
- * Public PA-TNC attribute interface
- */
- pa_tnc_attr_t pa_tnc_attribute;
-};
-
-/**
- * Creates an tcg_pts_attr_gen_attest_evid_t object
- */
-pa_tnc_attr_t* tcg_pts_attr_gen_attest_evid_create();
-
-/**
- * Creates an tcg_pts_attr_gen_attest_evid_t object from received data
- *
- * @param value unparsed attribute value
- */
-pa_tnc_attr_t* tcg_pts_attr_gen_attest_evid_create_from_data(chunk_t value);
-
-#endif /** TCG_PTS_ATTR_GEN_ATTEST_EVID_H_ @}*/
+++ /dev/null
-/*
- * Copyright (C) 2011-2012 Sansar Choinyambuu, Andreas Steffen
- * HSR Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#include "tcg_pts_attr_get_aik.h"
-
-#include <pa_tnc/pa_tnc_msg.h>
-#include <bio/bio_writer.h>
-#include <bio/bio_reader.h>
-#include <utils/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 0x00000000
-
-/**
- * Private data of an tcg_pts_attr_get_aik_t object.
- */
-struct private_tcg_pts_attr_get_aik_t {
-
- /**
- * Public members of tcg_pts_attr_get_aik_t
- */
- tcg_pts_attr_get_aik_t public;
-
- /**
- * Vendor-specific attribute type
- */
- pen_type_t type;
-
- /**
- * Attribute value
- */
- chunk_t value;
-
- /**
- * Noskip flag
- */
- bool noskip_flag;
-
- /**
- * Reference count
- */
- refcount_t ref;
-};
-
-METHOD(pa_tnc_attr_t, get_type, pen_type_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;
-
- if (this->value.ptr)
- {
- return;
- }
- writer = bio_writer_create(PTS_GET_AIK_SIZE);
- writer->write_uint32 (writer, PTS_GET_AIK_RESERVED);
-
- this->value = writer->extract_buf(writer);
- writer->destroy(writer);
-}
-
-METHOD(pa_tnc_attr_t, process, status_t,
- private_tcg_pts_attr_get_aik_t *this, u_int32_t *offset)
-{
- bio_reader_t *reader;
- u_int32_t reserved;
-
- if (this->value.len < PTS_GET_AIK_SIZE)
- {
- DBG1(DBG_TNC, "insufficient data for Get AIK");
- *offset = 0;
- return FAILED;
- }
- reader = bio_reader_create(this->value);
- reader->read_uint32 (reader, &reserved);
- reader->destroy(reader);
-
- return SUCCESS;
-}
-
-METHOD(pa_tnc_attr_t, get_ref, pa_tnc_attr_t*,
- private_tcg_pts_attr_get_aik_t *this)
-{
- ref_get(&this->ref);
- return &this->public.pa_tnc_attribute;
-}
-
-METHOD(pa_tnc_attr_t, destroy, void,
- private_tcg_pts_attr_get_aik_t *this)
-{
- if (ref_put(&this->ref))
- {
- 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_type = _get_type,
- .get_value = _get_value,
- .get_noskip_flag = _get_noskip_flag,
- .set_noskip_flag = _set_noskip_flag,
- .build = _build,
- .process = _process,
- .get_ref = _get_ref,
- .destroy = _destroy,
- },
- },
- .type = { PEN_TCG, TCG_PTS_GET_AIK },
- .ref = 1,
- );
-
- 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_type = _get_type,
- .get_value = _get_value,
- .get_noskip_flag = _get_noskip_flag,
- .set_noskip_flag = _set_noskip_flag,
- .build = _build,
- .process = _process,
- .get_ref = _get_ref,
- .destroy = _destroy,
- },
- },
- .type = { PEN_TCG, TCG_PTS_GET_AIK },
- .value = chunk_clone(data),
- .ref = 1,
- );
-
- return &this->public.pa_tnc_attribute;
-}
+++ /dev/null
-/*
- * 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_attr
- */
-
-#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_ @}*/
+++ /dev/null
-/*
- * Copyright (C) 2011-2012 Sansar Choinyambuu, Andreas Steffen
- * HSR Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#include "tcg_pts_attr_get_tpm_version_info.h"
-
-#include <pa_tnc/pa_tnc_msg.h>
-#include <bio/bio_writer.h>
-#include <bio/bio_reader.h>
-#include <utils/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 tcg_pts_attr_get_tpm_version_info_t object.
- */
-struct private_tcg_pts_attr_get_tpm_version_info_t {
-
- /**
- * Public members of tcg_pts_attr_get_tpm_version_info_t
- */
- tcg_pts_attr_get_tpm_version_info_t public;
-
- /**
- * Vendor-specific attribute type
- */
- pen_type_t type;
-
- /**
- * Attribute value
- */
- chunk_t value;
-
- /**
- * Noskip flag
- */
- bool noskip_flag;
-
- /**
- * Reference count
- */
- refcount_t ref;
-};
-
-METHOD(pa_tnc_attr_t, get_type, pen_type_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;
-
- if (this->value.ptr)
- {
- return;
- }
- writer = bio_writer_create(PTS_GET_TPM_VER_INFO_SIZE);
- writer->write_uint32 (writer, PTS_GET_TPM_VER_INFO_RESERVED);
-
- this->value = writer->extract_buf(writer);
- writer->destroy(writer);
-}
-
-METHOD(pa_tnc_attr_t, process, status_t,
- private_tcg_pts_attr_get_tpm_version_info_t *this, u_int32_t *offset)
-{
- 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");
- *offset = 0;
- return FAILED;
- }
- reader = bio_reader_create(this->value);
- reader->read_uint32 (reader, &reserved);
- reader->destroy(reader);
-
- return SUCCESS;
-}
-
-METHOD(pa_tnc_attr_t, get_ref, pa_tnc_attr_t*,
- private_tcg_pts_attr_get_tpm_version_info_t *this)
-{
- ref_get(&this->ref);
- return &this->public.pa_tnc_attribute;
-}
-
-METHOD(pa_tnc_attr_t, destroy, void,
- private_tcg_pts_attr_get_tpm_version_info_t *this)
-{
- if (ref_put(&this->ref))
- {
- 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_type = _get_type,
- .get_value = _get_value,
- .get_noskip_flag = _get_noskip_flag,
- .set_noskip_flag = _set_noskip_flag,
- .build = _build,
- .process = _process,
- .get_ref = _get_ref,
- .destroy = _destroy,
- },
- },
- .type = { PEN_TCG, TCG_PTS_GET_TPM_VERSION_INFO },
- .ref = 1,
- );
-
- 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_type = _get_type,
- .get_value = _get_value,
- .get_noskip_flag = _get_noskip_flag,
- .set_noskip_flag = _set_noskip_flag,
- .build = _build,
- .process = _process,
- .get_ref = _get_ref,
- .destroy = _destroy,
- },
- },
- .type = { PEN_TCG, TCG_PTS_GET_TPM_VERSION_INFO },
- .value = chunk_clone(data),
- .ref = 1,
- );
-
- return &this->public.pa_tnc_attribute;
-}
+++ /dev/null
-/*
- * 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_attr
- */
-
-#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_ @}*/
+++ /dev/null
-/*
- * Copyright (C) 2011-2012 Sansar Choinyambuu, Andreas Steffen
- * HSR Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#include "tcg_pts_attr_meas_algo.h"
-
-#include <pa_tnc/pa_tnc_msg.h>
-#include <bio/bio_writer.h>
-#include <bio/bio_reader.h>
-#include <utils/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 |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- *
- */
-
-#define PTS_MEAS_ALGO_SIZE 4
-#define PTS_MEAS_ALGO_RESERVED 0x0000
-
-/**
- * Private data of an tcg_pts_attr_meas_algo_t object.
- */
-struct private_tcg_pts_attr_meas_algo_t {
-
- /**
- * Public members of tcg_pts_attr_meas_algo_t
- */
- tcg_pts_attr_meas_algo_t public;
-
- /**
- * Vendor-specific attribute type
- */
- pen_type_t type;
-
- /**
- * Attribute value
- */
- chunk_t value;
-
- /**
- * Noskip flag
- */
- bool noskip_flag;
-
- /**
- * Set of algorithms
- */
- pts_meas_algorithms_t algorithms;
-
- /**
- * Reference count
- */
- refcount_t ref;
-};
-
-METHOD(pa_tnc_attr_t, get_type, pen_type_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;
-
- if (this->value.ptr)
- {
- return;
- }
- writer = bio_writer_create(PTS_MEAS_ALGO_SIZE);
- writer->write_uint16(writer, PTS_MEAS_ALGO_RESERVED);
- writer->write_uint16(writer, this->algorithms);
- this->value = writer->extract_buf(writer);
- writer->destroy(writer);
-}
-
-METHOD(pa_tnc_attr_t, process, status_t,
- private_tcg_pts_attr_meas_algo_t *this, u_int32_t *offset)
-{
- bio_reader_t *reader;
- u_int16_t reserved, algorithms;
-
- if (this->value.len < PTS_MEAS_ALGO_SIZE)
- {
- DBG1(DBG_TNC, "insufficient data for PTS Measurement Algorithm");
- *offset = 0;
- return FAILED;
- }
- reader = bio_reader_create(this->value);
- reader->read_uint16(reader, &reserved);
- reader->read_uint16(reader, &algorithms);
- this->algorithms = algorithms;
- reader->destroy(reader);
-
- return SUCCESS;
-}
-
-METHOD(pa_tnc_attr_t, destroy, void,
- private_tcg_pts_attr_meas_algo_t *this)
-{
- if (ref_put(&this->ref))
- {
- free(this->value.ptr);
- free(this);
- }
-}
-
-METHOD(pa_tnc_attr_t, get_ref, pa_tnc_attr_t*,
- private_tcg_pts_attr_meas_algo_t *this)
-{
- ref_get(&this->ref);
- return &this->public.pa_tnc_attribute;
-}
-
-METHOD(tcg_pts_attr_meas_algo_t, get_algorithms, pts_meas_algorithms_t,
- private_tcg_pts_attr_meas_algo_t *this)
-{
- return this->algorithms;
-}
-
-/**
- * Described in header.
- */
-pa_tnc_attr_t *tcg_pts_attr_meas_algo_create(pts_meas_algorithms_t algorithms,
- bool selection)
-{
- private_tcg_pts_attr_meas_algo_t *this;
-
- INIT(this,
- .public = {
- .pa_tnc_attribute = {
- .get_type = _get_type,
- .get_value = _get_value,
- .get_noskip_flag = _get_noskip_flag,
- .set_noskip_flag = _set_noskip_flag,
- .build = _build,
- .process = _process,
- .get_ref = _get_ref,
- .destroy = _destroy,
- },
- .get_algorithms = _get_algorithms,
- },
- .type = { PEN_TCG,
- selection ? TCG_PTS_MEAS_ALGO_SELECTION : TCG_PTS_MEAS_ALGO },
- .algorithms = algorithms,
- .ref = 1,
- );
-
- return &this->public.pa_tnc_attribute;
-}
-
-
-/**
- * Described in header.
- */
-pa_tnc_attr_t *tcg_pts_attr_meas_algo_create_from_data(chunk_t data,
- bool selection)
-{
- private_tcg_pts_attr_meas_algo_t *this;
-
- INIT(this,
- .public = {
- .pa_tnc_attribute = {
- .get_type = _get_type,
- .get_value = _get_value,
- .get_noskip_flag = _get_noskip_flag,
- .set_noskip_flag = _set_noskip_flag,
- .build = _build,
- .process = _process,
- .get_ref = _get_ref,
- .destroy = _destroy,
- },
- .get_algorithms = _get_algorithms,
- },
- .type = { PEN_TCG,
- selection ? TCG_PTS_MEAS_ALGO_SELECTION : TCG_PTS_MEAS_ALGO },
- .value = chunk_clone(data),
- .ref = 1,
- );
-
- return &this->public.pa_tnc_attribute;
-}
+++ /dev/null
-/*
- * 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_attr
- */
-
-#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;
-
-#include "tcg_attr.h"
-#include "pts/pts_meas_algo.h"
-#include "pa_tnc/pa_tnc_attr.h"
-
-/**
- * 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_meas_algorithms_t (*get_algorithms)(tcg_pts_attr_meas_algo_t *this);
-
-};
-
-/**
- * Creates an tcg_pts_attr_meas_algo_t object
- *
- * @param algorithms set of algorithms
- * @param selection TRUE if a selection
- */
-pa_tnc_attr_t* tcg_pts_attr_meas_algo_create(pts_meas_algorithms_t algorithms,
- bool selection);
-
-/**
- * Creates an tcg_pts_attr_meas_algo_t object from received data
- *
- * @param value unparsed attribute value
- * @param selection TRUE if a selection
- */
-pa_tnc_attr_t* tcg_pts_attr_meas_algo_create_from_data(chunk_t value,
- bool selection);
-
-#endif /** TCG_PTS_ATTR_MEAS_ALGO_H_ @}*/
+++ /dev/null
-/*
- * Copyright (C) 2011-2012 Sansar Choinyambuu, Andreas Steffen
- * HSR Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#include "tcg_pts_attr_proto_caps.h"
-
-#include <pa_tnc/pa_tnc_msg.h>
-#include <bio/bio_writer.h>
-#include <bio/bio_reader.h>
-#include <utils/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 0x0000
-
-/**
- * Private data of an tcg_pts_attr_proto_caps_t object.
- */
-struct private_tcg_pts_attr_proto_caps_t {
-
- /**
- * Public members of tcg_pts_attr_proto_caps_t
- */
- tcg_pts_attr_proto_caps_t public;
-
- /**
- * Vendor-specific attribute type
- */
- pen_type_t type;
-
- /**
- * Attribute value
- */
- chunk_t value;
-
- /**
- * Noskip flag
- */
- bool noskip_flag;
-
- /**
- * Set of flags
- */
- pts_proto_caps_flag_t flags;
-
- /**
- * Reference count
- */
- refcount_t ref;
-};
-
-METHOD(pa_tnc_attr_t, get_type, pen_type_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;
-
- if (this->value.ptr)
- {
- return;
- }
- writer = bio_writer_create(PTS_PROTO_CAPS_SIZE);
- writer->write_uint16(writer, PTS_PROTO_CAPS_RESERVED);
- writer->write_uint16(writer, this->flags);
-
- this->value = writer->extract_buf(writer);
- writer->destroy(writer);
-}
-
-METHOD(pa_tnc_attr_t, process, status_t,
- private_tcg_pts_attr_proto_caps_t *this, u_int32_t *offset)
-{
- bio_reader_t *reader;
- u_int16_t reserved, flags;
-
- if (this->value.len < PTS_PROTO_CAPS_SIZE)
- {
- DBG1(DBG_TNC, "insufficient data for PTS Protocol Capabilities");
- *offset = 0;
- return FAILED;
- }
- reader = bio_reader_create(this->value);
- reader->read_uint16(reader, &reserved);
- reader->read_uint16(reader, &flags);
- this->flags = flags;
- reader->destroy(reader);
-
- return SUCCESS;
-}
-
-METHOD(pa_tnc_attr_t, destroy, void,
- private_tcg_pts_attr_proto_caps_t *this)
-{
- if (ref_put(&this->ref))
- {
- free(this->value.ptr);
- free(this);
- }
-}
-
-METHOD(pa_tnc_attr_t, get_ref, pa_tnc_attr_t*,
- private_tcg_pts_attr_proto_caps_t *this)
-{
- ref_get(&this->ref);
- return &this->public.pa_tnc_attribute;
-}
-
-METHOD(tcg_pts_attr_proto_caps_t, get_flags, pts_proto_caps_flag_t,
- private_tcg_pts_attr_proto_caps_t *this)
-{
- return this->flags;
-}
-
-/**
- * Described in header.
- */
-pa_tnc_attr_t *tcg_pts_attr_proto_caps_create(pts_proto_caps_flag_t flags,
- bool request)
-{
- private_tcg_pts_attr_proto_caps_t *this;
-
- INIT(this,
- .public = {
- .pa_tnc_attribute = {
- .get_type = _get_type,
- .get_value = _get_value,
- .get_noskip_flag = _get_noskip_flag,
- .set_noskip_flag = _set_noskip_flag,
- .build = _build,
- .process = _process,
- .get_ref = _get_ref,
- .destroy = _destroy,
- },
- .get_flags = _get_flags,
- },
- .type = { PEN_TCG,
- request ? TCG_PTS_REQ_PROTO_CAPS : TCG_PTS_PROTO_CAPS },
- .flags = flags,
- .ref = 1,
- );
-
- return &this->public.pa_tnc_attribute;
-}
-
-/**
- * Described in header.
- */
-pa_tnc_attr_t *tcg_pts_attr_proto_caps_create_from_data(chunk_t data,
- bool request)
-{
- private_tcg_pts_attr_proto_caps_t *this;
-
- INIT(this,
- .public = {
- .pa_tnc_attribute = {
- .get_type = _get_type,
- .get_value = _get_value,
- .get_noskip_flag = _get_noskip_flag,
- .set_noskip_flag = _set_noskip_flag,
- .build = _build,
- .process = _process,
- .get_ref = _get_ref,
- .destroy = _destroy,
- },
- .get_flags = _get_flags,
- },
- .type = { PEN_TCG,
- request ? TCG_PTS_REQ_PROTO_CAPS : TCG_PTS_PROTO_CAPS },
- .value = chunk_clone(data),
- .ref = 1,
- );
-
- return &this->public.pa_tnc_attribute;
-}
+++ /dev/null
-/*
- * 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_attr
- */
-
-#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;
-
-#include "tcg_attr.h"
-#include "pa_tnc/pa_tnc_attr.h"
-#include "pts/pts_proto_caps.h"
-
-/**
- * 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_proto_caps_flag_t (*get_flags)(tcg_pts_attr_proto_caps_t *this);
-
-};
-
-/**
- * Creates an tcg_pts_attr_proto_caps_t object
- *
- * @param flags set of flags
- * @param request TRUE for a PTS protocol capabilities request
- */
-pa_tnc_attr_t* tcg_pts_attr_proto_caps_create(pts_proto_caps_flag_t flags,
- bool request);
-
-/**
- * Creates an tcg_pts_attr_proto_caps_t object from received data
- *
- * @param value unparsed attribute value
- * @param request TRUE for a PTS protocol capabilities request
- */
-pa_tnc_attr_t* tcg_pts_attr_proto_caps_create_from_data(chunk_t value,
- bool request);
-
-#endif /** TCG_PTS_ATTR_PROTO_CAPS_H_ @}*/
+++ /dev/null
-/*
- * Copyright (C) 2011-2012 Sansar Choinyambuu, Andreas Steffen
- * HSR Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#include "tcg_pts_attr_req_file_meas.h"
-
-#include <pa_tnc/pa_tnc_msg.h>
-#include <bio/bio_writer.h>
-#include <bio/bio_reader.h>
-#include <utils/debug.h>
-
-#include <string.h>
-
-typedef struct private_tcg_pts_attr_req_file_meas_t private_tcg_pts_attr_req_file_meas_t;
-
-/**
- * Request File Measurement
- * see section 3.19.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
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Flags | Reserved | Request ID |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Delimiter |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * ~ Fully Qualified File Pathname (Variable Length) ~
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- */
-
-#define PTS_REQ_FILE_MEAS_SIZE 8
-#define PTS_REQ_FILE_MEAS_RESERVED 0x00
-#define PTS_REQ_FILE_MEAS_NO_FLAGS 0x00
-
-#define DIRECTORY_CONTENTS_FLAG (1<<7)
-
-/**
- * Private data of an tcg_pts_attr_req_file_meas_t object.
- */
-struct private_tcg_pts_attr_req_file_meas_t {
-
- /**
- * Public members of tcg_pts_attr_req_file_meas_t
- */
- tcg_pts_attr_req_file_meas_t public;
-
- /**
- * Vendor-specific attribute type
- */
- pen_type_t type;
-
- /**
- * Attribute value
- */
- chunk_t value;
-
- /**
- * Noskip flag
- */
- bool noskip_flag;
-
- /**
- * Directory Contents flag
- */
- bool directory_flag;
-
- /**
- * Request ID
- */
- u_int16_t request_id;
-
- /**
- * UTF8 Encoding of Delimiter Character
- */
- u_int32_t delimiter;
-
- /**
- * Fully Qualified File Pathname
- */
- char *pathname;
-
- /**
- * Reference count
- */
- refcount_t ref;
-};
-
-METHOD(pa_tnc_attr_t, get_type, pen_type_t,
- private_tcg_pts_attr_req_file_meas_t *this)
-{
- return this->type;
-}
-
-METHOD(pa_tnc_attr_t, get_value, chunk_t,
- private_tcg_pts_attr_req_file_meas_t *this)
-{
- return this->value;
-}
-
-METHOD(pa_tnc_attr_t, get_noskip_flag, bool,
- private_tcg_pts_attr_req_file_meas_t *this)
-{
- return this->noskip_flag;
-}
-
-METHOD(pa_tnc_attr_t, set_noskip_flag,void,
- private_tcg_pts_attr_req_file_meas_t *this, bool noskip)
-{
- this->noskip_flag = noskip;
-}
-
-METHOD(pa_tnc_attr_t, build, void,
- private_tcg_pts_attr_req_file_meas_t *this)
-{
- u_int8_t flags = PTS_REQ_FILE_MEAS_NO_FLAGS;
- chunk_t pathname;
- bio_writer_t *writer;
-
- if (this->value.ptr)
- {
- return;
- }
- if (this->directory_flag)
- {
- flags |= DIRECTORY_CONTENTS_FLAG;
- }
- pathname = chunk_create(this->pathname, strlen(this->pathname));
-
- writer = bio_writer_create(PTS_REQ_FILE_MEAS_SIZE);
- writer->write_uint8 (writer, flags);
- writer->write_uint8 (writer, PTS_REQ_FILE_MEAS_RESERVED);
- writer->write_uint16(writer, this->request_id);
- writer->write_uint32(writer, this->delimiter);
- writer->write_data (writer, pathname);
- this->value = writer->extract_buf(writer);
- writer->destroy(writer);
-}
-
-METHOD(pa_tnc_attr_t, process, status_t,
- private_tcg_pts_attr_req_file_meas_t *this, u_int32_t *offset)
-{
- bio_reader_t *reader;
- u_int8_t flags;
- u_int8_t reserved;
- chunk_t pathname;
-
- if (this->value.len < PTS_REQ_FILE_MEAS_SIZE)
- {
- DBG1(DBG_TNC, "insufficient data for Request File Measurement");
- *offset = 0;
- return FAILED;
- }
-
- reader = bio_reader_create(this->value);
- reader->read_uint8 (reader, &flags);
- reader->read_uint8 (reader, &reserved);
- reader->read_uint16(reader, &this->request_id);
- reader->read_uint32(reader, &this->delimiter);
- reader->read_data (reader, reader->remaining(reader), &pathname);
-
- this->directory_flag = (flags & DIRECTORY_CONTENTS_FLAG) !=
- PTS_REQ_FILE_MEAS_NO_FLAGS;
- this->pathname = strndup(pathname.ptr, pathname.len);
-
- reader->destroy(reader);
- return SUCCESS;
-}
-
-METHOD(pa_tnc_attr_t, get_ref, pa_tnc_attr_t*,
- private_tcg_pts_attr_req_file_meas_t *this)
-{
- ref_get(&this->ref);
- return &this->public.pa_tnc_attribute;
-}
-
-METHOD(pa_tnc_attr_t, destroy, void,
- private_tcg_pts_attr_req_file_meas_t *this)
-{
- if (ref_put(&this->ref))
- {
- free(this->pathname);
- free(this->value.ptr);
- free(this);
- }
-}
-
-METHOD(tcg_pts_attr_req_file_meas_t, get_directory_flag, bool,
- private_tcg_pts_attr_req_file_meas_t *this)
-{
- return this->directory_flag;
-}
-
-METHOD(tcg_pts_attr_req_file_meas_t, get_request_id, u_int16_t,
- private_tcg_pts_attr_req_file_meas_t *this)
-{
- return this->request_id;
-}
-
-METHOD(tcg_pts_attr_req_file_meas_t, get_delimiter, u_int32_t,
- private_tcg_pts_attr_req_file_meas_t *this)
-{
- return this->delimiter;
-}
-
-METHOD(tcg_pts_attr_req_file_meas_t, get_pathname, char*,
- private_tcg_pts_attr_req_file_meas_t *this)
-{
- return this->pathname;
-}
-
-/**
- * Described in header.
- */
-pa_tnc_attr_t *tcg_pts_attr_req_file_meas_create(bool directory_flag,
- u_int16_t request_id,
- u_int32_t delimiter,
- char *pathname)
-{
- private_tcg_pts_attr_req_file_meas_t *this;
-
- INIT(this,
- .public = {
- .pa_tnc_attribute = {
- .get_type = _get_type,
- .get_value = _get_value,
- .get_noskip_flag = _get_noskip_flag,
- .set_noskip_flag = _set_noskip_flag,
- .build = _build,
- .process = _process,
- .get_ref = _get_ref,
- .destroy = _destroy,
- },
- .get_directory_flag = _get_directory_flag,
- .get_request_id = _get_request_id,
- .get_delimiter = _get_delimiter,
- .get_pathname = _get_pathname,
- },
- .type = { PEN_TCG, TCG_PTS_REQ_FILE_MEAS },
- .directory_flag = directory_flag,
- .request_id = request_id,
- .delimiter = delimiter,
- .pathname = strdup(pathname),
- .ref = 1,
- );
-
- return &this->public.pa_tnc_attribute;
-}
-
-
-/**
- * Described in header.
- */
-pa_tnc_attr_t *tcg_pts_attr_req_file_meas_create_from_data(chunk_t data)
-{
- private_tcg_pts_attr_req_file_meas_t *this;
-
- INIT(this,
- .public = {
- .pa_tnc_attribute = {
- .get_type = _get_type,
- .get_value = _get_value,
- .get_noskip_flag = _get_noskip_flag,
- .set_noskip_flag = _set_noskip_flag,
- .build = _build,
- .process = _process,
- .get_ref = _get_ref,
- .destroy = _destroy,
- },
- .get_directory_flag = _get_directory_flag,
- .get_request_id = _get_request_id,
- .get_delimiter = _get_delimiter,
- .get_pathname = _get_pathname,
- },
- .type = { PEN_TCG, TCG_PTS_REQ_FILE_MEAS },
- .value = chunk_clone(data),
- .ref = 1,
- );
-
- return &this->public.pa_tnc_attribute;
-}
+++ /dev/null
-/*
- * 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_file_meas tcg_pts_attr_req_file_meas
- * @{ @ingroup tcg_attr
- */
-
-#ifndef TCG_PTS_ATTR_REQ_FILE_MEAS_H_
-#define TCG_PTS_ATTR_REQ_FILE_MEAS_H_
-
-typedef struct tcg_pts_attr_req_file_meas_t tcg_pts_attr_req_file_meas_t;
-
-#include "tcg_attr.h"
-#include "pa_tnc/pa_tnc_attr.h"
-
-/**
- * Class implementing the TCG PTS Request File Measurement attribute
- *
- */
-struct tcg_pts_attr_req_file_meas_t {
-
- /**
- * Public PA-TNC attribute interface
- */
- pa_tnc_attr_t pa_tnc_attribute;
-
- /**
- * Get flag for PTS Request File Measurement
- *
- * @return Directory Contents flag
- */
- bool (*get_directory_flag)(tcg_pts_attr_req_file_meas_t *this);
-
- /**
- * Get Request ID
- *
- * @return Request ID
- */
- u_int16_t (*get_request_id)(tcg_pts_attr_req_file_meas_t *this);
-
- /**
- * Get Delimiter
- *
- * @return UTF-8 encoding of a Delimiter Character
- */
- u_int32_t (*get_delimiter)(tcg_pts_attr_req_file_meas_t *this);
-
- /**
- * Get Fully Qualified File Pathname
- *
- * @return Pathname
- */
- char* (*get_pathname)(tcg_pts_attr_req_file_meas_t *this);
-
-};
-
-/**
- * Creates an tcg_pts_attr_req_file_meas_t object
- *
- * @param directory_flag Directory Contents Flag
- * @param request_id Request ID
- * @param delimiter Delimiter Character
- * @param pathname File Pathname
- */
-pa_tnc_attr_t* tcg_pts_attr_req_file_meas_create(bool directory_flag,
- u_int16_t request_id,
- u_int32_t delimiter,
- char *pathname);
-
-/**
- * Creates an tcg_pts_attr_req_file_meas_t object from received data
- *
- * @param value unparsed attribute value
- */
-pa_tnc_attr_t* tcg_pts_attr_req_file_meas_create_from_data(chunk_t value);
-
-#endif /** TCG_PTS_ATTR_REQ_FILE_MEAS_H_ @}*/
+++ /dev/null
-/*
- * Copyright (C) 2011-2012 Sansar Choinyambuu, Andreas Steffen
- * HSR Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#include "tcg_pts_attr_req_file_meta.h"
-
-#include <pa_tnc/pa_tnc_msg.h>
-#include <bio/bio_writer.h>
-#include <bio/bio_reader.h>
-#include <utils/debug.h>
-
-#include <string.h>
-
-typedef struct private_tcg_pts_attr_req_file_meta_t private_tcg_pts_attr_req_file_meta_t;
-
-/**
- * Request File Metadata
- * see section 3.17.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
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Flags | Delimiter | Reserved |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * ~ Fully Qualified File Pathname (Variable Length) ~
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- */
-
-#define PTS_REQ_FILE_META_SIZE 4
-#define PTS_REQ_FILE_META_RESERVED 0x00
-#define PTS_REQ_FILE_META_NO_FLAGS 0x00
-
-#define DIRECTORY_CONTENTS_FLAG (1<<7)
-
-/**
- * Private data of an tcg_pts_attr_req_file_meta_t object.
- */
-struct private_tcg_pts_attr_req_file_meta_t {
-
- /**
- * Public members of tcg_pts_attr_req_file_meta_t
- */
- tcg_pts_attr_req_file_meta_t public;
-
- /**
- * Vendor-specific attribute type
- */
- pen_type_t type;
-
- /**
- * Attribute value
- */
- chunk_t value;
-
- /**
- * Noskip flag
- */
- bool noskip_flag;
-
- /**
- * Directory Contents flag
- */
- bool directory_flag;
-
- /**
- * UTF8 Encoding of Delimiter Character
- */
- u_int8_t delimiter;
-
- /**
- * Fully Qualified File Pathname
- */
- char *pathname;
-
- /**
- * Reference count
- */
- refcount_t ref;
-};
-
-METHOD(pa_tnc_attr_t, get_type, pen_type_t,
- private_tcg_pts_attr_req_file_meta_t *this)
-{
- return this->type;
-}
-
-METHOD(pa_tnc_attr_t, get_value, chunk_t,
- private_tcg_pts_attr_req_file_meta_t *this)
-{
- return this->value;
-}
-
-METHOD(pa_tnc_attr_t, get_noskip_flag, bool,
- private_tcg_pts_attr_req_file_meta_t *this)
-{
- return this->noskip_flag;
-}
-
-METHOD(pa_tnc_attr_t, set_noskip_flag,void,
- private_tcg_pts_attr_req_file_meta_t *this, bool noskip)
-{
- this->noskip_flag = noskip;
-}
-
-METHOD(pa_tnc_attr_t, build, void,
- private_tcg_pts_attr_req_file_meta_t *this)
-{
- u_int8_t flags = PTS_REQ_FILE_META_NO_FLAGS;
- chunk_t pathname;
- bio_writer_t *writer;
-
- if (this->value.ptr)
- {
- return;
- }
- if (this->directory_flag)
- {
- flags |= DIRECTORY_CONTENTS_FLAG;
- }
- pathname = chunk_create(this->pathname, strlen(this->pathname));
-
- writer = bio_writer_create(PTS_REQ_FILE_META_SIZE);
- writer->write_uint8 (writer, flags);
- writer->write_uint8 (writer, this->delimiter);
- writer->write_uint16(writer, PTS_REQ_FILE_META_RESERVED);
-
- writer->write_data (writer, pathname);
- this->value = writer->extract_buf(writer);
- writer->destroy(writer);
-}
-
-METHOD(pa_tnc_attr_t, process, status_t,
- private_tcg_pts_attr_req_file_meta_t *this, u_int32_t *offset)
-{
- bio_reader_t *reader;
- u_int8_t flags;
- u_int16_t reserved;
- chunk_t pathname;
-
- if (this->value.len < PTS_REQ_FILE_META_SIZE)
- {
- DBG1(DBG_TNC, "insufficient data for Request File Metadata");
- *offset = 0;
- return FAILED;
- }
-
- reader = bio_reader_create(this->value);
- reader->read_uint8 (reader, &flags);
- reader->read_uint8 (reader, &this->delimiter);
- reader->read_uint16(reader, &reserved);
-
- reader->read_data (reader, reader->remaining(reader), &pathname);
-
- this->directory_flag = (flags & DIRECTORY_CONTENTS_FLAG) !=
- PTS_REQ_FILE_META_NO_FLAGS;
- this->pathname = strndup(pathname.ptr, pathname.len);
-
- reader->destroy(reader);
- return SUCCESS;
-}
-
-METHOD(pa_tnc_attr_t, destroy, void,
- private_tcg_pts_attr_req_file_meta_t *this)
-{
- if (ref_put(&this->ref))
- {
- free(this->pathname);
- free(this->value.ptr);
- free(this);
- }
-}
-
-METHOD(pa_tnc_attr_t, get_ref, pa_tnc_attr_t*,
- private_tcg_pts_attr_req_file_meta_t *this)
-{
- ref_get(&this->ref);
- return &this->public.pa_tnc_attribute;
-}
-
-METHOD(tcg_pts_attr_req_file_meta_t, get_directory_flag, bool,
- private_tcg_pts_attr_req_file_meta_t *this)
-{
- return this->directory_flag;
-}
-
-METHOD(tcg_pts_attr_req_file_meta_t, get_delimiter, u_int8_t,
- private_tcg_pts_attr_req_file_meta_t *this)
-{
- return this->delimiter;
-}
-
-METHOD(tcg_pts_attr_req_file_meta_t, get_pathname, char*,
- private_tcg_pts_attr_req_file_meta_t *this)
-{
- return this->pathname;
-}
-
-/**
- * Described in header.
- */
-pa_tnc_attr_t *tcg_pts_attr_req_file_meta_create(bool directory_flag,
- u_int8_t delimiter,
- char *pathname)
-{
- private_tcg_pts_attr_req_file_meta_t *this;
-
- INIT(this,
- .public = {
- .pa_tnc_attribute = {
- .get_type = _get_type,
- .get_value = _get_value,
- .get_noskip_flag = _get_noskip_flag,
- .set_noskip_flag = _set_noskip_flag,
- .build = _build,
- .process = _process,
- .get_ref = _get_ref,
- .destroy = _destroy,
- },
- .get_directory_flag = _get_directory_flag,
- .get_delimiter = _get_delimiter,
- .get_pathname = _get_pathname,
- },
- .type = { PEN_TCG, TCG_PTS_REQ_FILE_META },
- .directory_flag = directory_flag,
- .delimiter = delimiter,
- .pathname = strdup(pathname),
- .ref = 1,
- );
-
- return &this->public.pa_tnc_attribute;
-}
-
-
-/**
- * Described in header.
- */
-pa_tnc_attr_t *tcg_pts_attr_req_file_meta_create_from_data(chunk_t data)
-{
- private_tcg_pts_attr_req_file_meta_t *this;
-
- INIT(this,
- .public = {
- .pa_tnc_attribute = {
- .get_type = _get_type,
- .get_value = _get_value,
- .get_noskip_flag = _get_noskip_flag,
- .set_noskip_flag = _set_noskip_flag,
- .build = _build,
- .process = _process,
- .get_ref = _get_ref,
- .destroy = _destroy,
- },
- .get_directory_flag = _get_directory_flag,
- .get_delimiter = _get_delimiter,
- .get_pathname = _get_pathname,
- },
- .type = { PEN_TCG, TCG_PTS_REQ_FILE_META },
- .value = chunk_clone(data),
- .ref = 1,
- );
-
- return &this->public.pa_tnc_attribute;
-}
+++ /dev/null
-/*
- * 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_file_meta tcg_pts_attr_req_file_meta
- * @{ @ingroup tcg_attr
- */
-
-#ifndef TCG_PTS_ATTR_REQ_FILE_META_H_
-#define TCG_PTS_ATTR_REQ_FILE_META_H_
-
-typedef struct tcg_pts_attr_req_file_meta_t tcg_pts_attr_req_file_meta_t;
-
-#include "tcg_attr.h"
-#include "pa_tnc/pa_tnc_attr.h"
-
-/**
- * Class implementing the TCG PTS Request File Metadata attribute
- *
- */
-struct tcg_pts_attr_req_file_meta_t {
-
- /**
- * Public PA-TNC attribute interface
- */
- pa_tnc_attr_t pa_tnc_attribute;
-
- /**
- * Get directory flag for PTS Request File Metadata
- *
- * @return Directory Contents flag
- */
- bool (*get_directory_flag)(tcg_pts_attr_req_file_meta_t *this);
-
- /**
- * Get Delimiter
- *
- * @return UTF-8 encoding of a Delimiter Character
- */
- u_int8_t (*get_delimiter)(tcg_pts_attr_req_file_meta_t *this);
-
- /**
- * Get Fully Qualified File Pathname
- *
- * @return Pathname
- */
- char* (*get_pathname)(tcg_pts_attr_req_file_meta_t *this);
-
-};
-
-/**
- * Creates an tcg_pts_attr_req_file_meta_t object
- *
- * @param directory_flag Directory Contents Flag
- * @param delimiter Delimiter Character
- * @param pathname File Pathname
- */
-pa_tnc_attr_t* tcg_pts_attr_req_file_meta_create(bool directory_flag,
- u_int8_t delimiter,
- char *pathname);
-
-/**
- * Creates an tcg_pts_attr_req_file_meta_t object from received data
- *
- * @param value unparsed attribute value
- */
-pa_tnc_attr_t* tcg_pts_attr_req_file_meta_create_from_data(chunk_t value);
-
-#endif /** TCG_PTS_ATTR_REQ_FILE_META_H_ @}*/
+++ /dev/null
-/*
- * Copyright (C) 2011-2012 Sansar Choinyambuu, Andreas Steffen
- * HSR Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#include "tcg_pts_attr_req_func_comp_evid.h"
-
-#include <pa_tnc/pa_tnc_msg.h>
-#include <bio/bio_writer.h>
-#include <bio/bio_reader.h>
-#include <collections/linked_list.h>
-#include <utils/debug.h>
-
-typedef struct private_tcg_pts_attr_req_func_comp_evid_t private_tcg_pts_attr_req_func_comp_evid_t;
-
-/**
- * Request Functional Component Evidence
- * see section 3.14.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
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Flags | Sub-component Depth (for Component #1) |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Component Functional Name #1 |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Component Functional Name #1 |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | ........ |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Flags | Sub-component Depth (for Component #N) |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Component Functional Name #N |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Component Functional Name #N |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- */
-
-/**
- * Component Functional Name Structure
- * (see section 5.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
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Component Functional Name Vendor ID |Fam| Qualifier |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Component Functional Name |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- */
-
-#define PTS_REQ_FUNC_COMP_EVID_SIZE 12
-#define PTS_REQ_FUNC_COMP_FAMILY_MASK 0xC0
-
-/**
- * Private data of an tcg_pts_attr_req_func_comp_evid_t object.
- */
-struct private_tcg_pts_attr_req_func_comp_evid_t {
-
- /**
- * Public members of tcg_pts_attr_req_func_comp_evid_t
- */
- tcg_pts_attr_req_func_comp_evid_t public;
-
- /**
- * Vendor-specific attribute type
- */
- pen_type_t type;
-
- /**
- * Attribute value
- */
- chunk_t value;
-
- /**
- * Noskip flag
- */
- bool noskip_flag;
-
- /**
- * List of Functional Components
- */
- linked_list_t *list;
-
- /**
- * Reference count
- */
- refcount_t ref;
-};
-
-typedef struct entry_t entry_t;
-
-/**
- * Functional component entry
- */
-struct entry_t {
- u_int8_t flags;
- u_int32_t depth;
- pts_comp_func_name_t *name;
-};
-
-/**
- * Enumerate functional component entries
- */
-static bool entry_filter(void *null, entry_t **entry, u_int8_t *flags,
- void *i2, u_int32_t *depth, void *i3,
- pts_comp_func_name_t **name)
-{
- *flags = (*entry)->flags;
- *depth = (*entry)->depth;
- *name = (*entry)->name;
-
- return TRUE;
-}
-
-/**
- * Free an entry_t object
- */
-static void free_entry(entry_t *this)
-{
- if (this)
- {
- this->name->destroy(this->name);
- free(this);
- }
-}
-
-METHOD(pa_tnc_attr_t, get_type, pen_type_t,
- private_tcg_pts_attr_req_func_comp_evid_t *this)
-{
- return this->type;
-}
-
-METHOD(pa_tnc_attr_t, get_value, chunk_t,
- private_tcg_pts_attr_req_func_comp_evid_t *this)
-{
- return this->value;
-}
-
-METHOD(pa_tnc_attr_t, get_noskip_flag, bool,
- private_tcg_pts_attr_req_func_comp_evid_t *this)
-{
- return this->noskip_flag;
-}
-
-METHOD(pa_tnc_attr_t, set_noskip_flag,void,
- private_tcg_pts_attr_req_func_comp_evid_t *this, bool noskip)
-{
- this->noskip_flag = noskip;
-}
-
-METHOD(pa_tnc_attr_t, build, void,
- private_tcg_pts_attr_req_func_comp_evid_t *this)
-{
- bio_writer_t *writer;
- enumerator_t *enumerator;
- entry_t *entry;
-
- if (this->value.ptr)
- {
- return;
- }
- writer = bio_writer_create(PTS_REQ_FUNC_COMP_EVID_SIZE);
-
- enumerator = this->list->create_enumerator(this->list);
- while (enumerator->enumerate(enumerator, &entry))
- {
- writer->write_uint8 (writer, entry->flags);
- writer->write_uint24(writer, entry->depth);
- writer->write_uint24(writer, entry->name->get_vendor_id(entry->name));
- writer->write_uint8 (writer, entry->name->get_qualifier(entry->name));
- writer->write_uint32(writer, entry->name->get_name(entry->name));
- }
- enumerator->destroy(enumerator);
-
- this->value = writer->extract_buf(writer);
- writer->destroy(writer);
-}
-
-METHOD(pa_tnc_attr_t, process, status_t,
- private_tcg_pts_attr_req_func_comp_evid_t *this, u_int32_t *offset)
-{
- bio_reader_t *reader;
- u_int32_t depth, vendor_id, name;
- u_int8_t flags, fam_and_qualifier, qualifier;
- status_t status = FAILED;
- entry_t *entry = NULL;
-
- if (this->value.len < PTS_REQ_FUNC_COMP_EVID_SIZE)
- {
- DBG1(DBG_TNC, "insufficient data for Request Functional "
- "Component Evidence");
- *offset = 0;
- return FAILED;
- }
- reader = bio_reader_create(this->value);
-
- while (reader->remaining(reader))
- {
- if (!reader->read_uint8(reader, &flags))
- {
- DBG1(DBG_TNC, "insufficient data for PTS Request Functional "
- "Component Evidence Flags");
- goto end;
- }
- if (!reader->read_uint24(reader, &depth))
- {
- DBG1(DBG_TNC, "insufficient data for PTS Request Functional "
- "Component Evidence Sub Component Depth");
- goto end;
- }
- if (!reader->read_uint24(reader, &vendor_id))
- {
- DBG1(DBG_TNC, "insufficient data for PTS Request Functional "
- "Component Evidence Component Name Vendor ID");
- goto end;
- }
- if (!reader->read_uint8(reader, &fam_and_qualifier))
- {
- DBG1(DBG_TNC, "insufficient data for PTS Request Functional "
- "Component Evidence Family and Qualifier");
- goto end;
- }
- if (fam_and_qualifier & PTS_REQ_FUNC_COMP_FAMILY_MASK)
- {
- DBG1(DBG_TNC, "the Functional Name Encoding Family "
- "is not Binary Enumeration");
- goto end;
- }
- if (!reader->read_uint32(reader, &name))
- {
- DBG1(DBG_TNC, "insufficient data for PTS Request Functional "
- "Component Evidence Component Functional Name");
- goto end;
- }
- qualifier = fam_and_qualifier & ~PTS_REQ_FUNC_COMP_FAMILY_MASK;
-
- entry = malloc_thing(entry_t);
- entry->flags = flags;
- entry->depth = depth;
- entry->name = pts_comp_func_name_create(vendor_id, name, qualifier);
-
- this->list->insert_last(this->list, entry);
- }
- status = SUCCESS;
-
-end:
- reader->destroy(reader);
- return status;
-}
-
-METHOD(pa_tnc_attr_t, get_ref, pa_tnc_attr_t*,
- private_tcg_pts_attr_req_func_comp_evid_t *this)
-{
- ref_get(&this->ref);
- return &this->public.pa_tnc_attribute;
-}
-
-METHOD(pa_tnc_attr_t, destroy, void,
- private_tcg_pts_attr_req_func_comp_evid_t *this)
-{
- if (ref_put(&this->ref))
- {
- this->list->destroy_function(this->list, (void *)free_entry);
- free(this->value.ptr);
- free(this);
- }
-}
-
-METHOD(tcg_pts_attr_req_func_comp_evid_t, add_component, void,
- private_tcg_pts_attr_req_func_comp_evid_t *this, u_int8_t flags,
- u_int32_t depth, pts_comp_func_name_t *name)
-{
- entry_t *entry;
-
- entry = malloc_thing(entry_t);
- entry->flags = flags;
- entry->depth = depth;
- entry->name = name;
- this->list->insert_last(this->list, entry);
-}
-
-METHOD(tcg_pts_attr_req_func_comp_evid_t, get_count, int,
- private_tcg_pts_attr_req_func_comp_evid_t *this)
-{
- return this->list->get_count(this->list);
-}
-
-METHOD(tcg_pts_attr_req_func_comp_evid_t, create_enumerator, enumerator_t*,
- private_tcg_pts_attr_req_func_comp_evid_t *this)
-{
- return enumerator_create_filter(this->list->create_enumerator(this->list),
- (void*)entry_filter, NULL, NULL);
-}
-
-/**
- * Described in header.
- */
-pa_tnc_attr_t *tcg_pts_attr_req_func_comp_evid_create(void)
-{
- private_tcg_pts_attr_req_func_comp_evid_t *this;
-
- INIT(this,
- .public = {
- .pa_tnc_attribute = {
- .get_type = _get_type,
- .get_value = _get_value,
- .get_noskip_flag = _get_noskip_flag,
- .set_noskip_flag = _set_noskip_flag,
- .build = _build,
- .process = _process,
- .get_ref = _get_ref,
- .destroy = _destroy,
- },
- .add_component = _add_component,
- .get_count = _get_count,
- .create_enumerator = _create_enumerator,
- },
- .type = { PEN_TCG, TCG_PTS_REQ_FUNC_COMP_EVID },
- .list = linked_list_create(),
- .ref = 1,
- );
-
- return &this->public.pa_tnc_attribute;
-}
-
-/**
- * Described in header.
- */
-pa_tnc_attr_t *tcg_pts_attr_req_func_comp_evid_create_from_data(chunk_t data)
-{
- private_tcg_pts_attr_req_func_comp_evid_t *this;
-
- INIT(this,
- .public = {
- .pa_tnc_attribute = {
- .get_type = _get_type,
- .get_value = _get_value,
- .get_noskip_flag = _get_noskip_flag,
- .set_noskip_flag = _set_noskip_flag,
- .build = _build,
- .process = _process,
- .get_ref = _get_ref,
- .destroy = _destroy,
- },
- .add_component = _add_component,
- .get_count = _get_count,
- .create_enumerator = _create_enumerator,
- },
- .type = { PEN_TCG, TCG_PTS_REQ_FUNC_COMP_EVID },
- .list = linked_list_create(),
- .value = chunk_clone(data),
- .ref = 1,
- );
-
- return &this->public.pa_tnc_attribute;
-}
+++ /dev/null
-/*
- * 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_func_comp_evid tcg_pts_attr_req_func_comp_evid
- * @{ @ingroup tcg_attr
- */
-
-#ifndef TCG_PTS_ATTR_REQ_FUNC_COMP_EVID_H_
-#define TCG_PTS_ATTR_REQ_FUNC_COMP_EVID_H_
-
-typedef struct tcg_pts_attr_req_func_comp_evid_t tcg_pts_attr_req_func_comp_evid_t;
-
-#include "tcg_attr.h"
-#include "pts/components/pts_comp_func_name.h"
-#include "pa_tnc/pa_tnc_attr.h"
-
-/**
- * Class implementing the TCG PTS Request Functional Component Evidence attribute
- *
- */
-struct tcg_pts_attr_req_func_comp_evid_t {
-
- /**
- * Public PA-TNC attribute interface
- */
- pa_tnc_attr_t pa_tnc_attribute;
-
- /**
- * Add a component to the Functional Component Evidence Request
- *
- * @param flags Component Evidence Request Flags
- * @param depth Sub-component Depth
- * @param name Functional Component Name
- */
- void (*add_component)(tcg_pts_attr_req_func_comp_evid_t *this,
- u_int8_t flags, u_int32_t depth,
- pts_comp_func_name_t *name);
-
- /**
- * Returns the number of Functional Component entries
- *
- * @return Number of entries
- */
- int (*get_count)(tcg_pts_attr_req_func_comp_evid_t *this);
-
- /**
- * Enumerator over Functional Component entries
- *
- * @return Entry enumerator
- */
- enumerator_t* (*create_enumerator)(tcg_pts_attr_req_func_comp_evid_t *this);
-
-};
-
-/**
- * Creates a tcg_pts_attr_req_func_comp_evid_t object
- */
-pa_tnc_attr_t* tcg_pts_attr_req_func_comp_evid_create(void);
-
-/**
- * Creates a tcg_pts_attr_req_func_comp_evid_t object from received data
- *
- * @param value Unparsed attribute value
- */
-pa_tnc_attr_t* tcg_pts_attr_req_func_comp_evid_create_from_data(chunk_t value);
-
-#endif /** TCG_PTS_ATTR_REQ_FUNC_COMP_EVID_H_ @}*/
+++ /dev/null
-/*
- * Copyright (C) 2011-2012 Sansar Choinyambuu, Andreas Steffen
- * HSR Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#include "tcg_pts_attr_simple_comp_evid.h"
-
-#include <pa_tnc/pa_tnc_msg.h>
-#include <bio/bio_writer.h>
-#include <bio/bio_reader.h>
-#include <utils/debug.h>
-
-#include <time.h>
-
-typedef struct private_tcg_pts_attr_simple_comp_evid_t private_tcg_pts_attr_simple_comp_evid_t;
-
-/**
- * Simple Component Evidence
- * see section 3.15.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
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Flags | Sub-Component Depth |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Specific Functional Component |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Specific Functional Component |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Measure. Type | Extended into PCR |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Hash Algorithm | PCR Transform | Reserved |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Measurement Date/Time |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Measurement Date/Time |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Measurement Date/Time |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Measurement Date/Time |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Measurement Date/Time |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Optional Policy URI Length | Opt. Verification Policy URI ~
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * ~ Optional Verification Policy URI ~
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Optional PCR Length | Optional PCR Before Value ~
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * ~ Optional PCR Before Value (Variable Length) ~
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * ~ Optional PCR After Value (Variable Length) ~
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * ~ Component Measurement (Variable Length) ~
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- */
-
-/**
- * Specific Functional Component -> Component Functional Name Structure
- * see section 5.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
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Component Functional Name Vendor ID |Fam| Qualifier |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Component Functional Name |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- *
- */
-
-#define PTS_SIMPLE_COMP_EVID_SIZE 40
-#define PTS_SIMPLE_COMP_EVID_MEAS_TIME_SIZE 20
-#define PTS_SIMPLE_COMP_EVID_RESERVED 0x00
-#define PTS_SIMPLE_COMP_EVID_FAMILY_MASK 0xC0
-#define PTS_SIMPLE_COMP_EVID_VALIDATION_MASK 0x60
-#define PTS_SIMPLE_COMP_EVID_MEAS_TYPE (1<<7)
-#define PTS_SIMPLE_COMP_EVID_FLAG_PCR (1<<7)
-
-static char *utc_undefined_time_str = "0000-00-00T00:00:00Z";
-
-/**
- * Private data of an tcg_pts_attr_simple_comp_evid_t object.
- */
-struct private_tcg_pts_attr_simple_comp_evid_t {
-
- /**
- * Public members of tcg_pts_attr_simple_comp_evid_t
- */
- tcg_pts_attr_simple_comp_evid_t public;
-
- /**
- * Vendor-specific attribute type
- */
- pen_type_t type;
-
- /**
- * Attribute value
- */
- chunk_t value;
-
- /**
- * Noskip flag
- */
- bool noskip_flag;
-
- /**
- * PTS Component Evidence
- */
- pts_comp_evidence_t *evidence;
-
- /**
- * Reference count
- */
- refcount_t ref;
-};
-
-METHOD(pa_tnc_attr_t, get_type, pen_type_t,
- private_tcg_pts_attr_simple_comp_evid_t *this)
-{
- return this->type;
-}
-
-METHOD(pa_tnc_attr_t, get_value, chunk_t,
- private_tcg_pts_attr_simple_comp_evid_t *this)
-{
- return this->value;
-}
-
-METHOD(pa_tnc_attr_t, get_noskip_flag, bool,
- private_tcg_pts_attr_simple_comp_evid_t *this)
-{
- return this->noskip_flag;
-}
-
-METHOD(pa_tnc_attr_t, set_noskip_flag,void,
- private_tcg_pts_attr_simple_comp_evid_t *this, bool noskip)
-{
- this->noskip_flag = noskip;
-}
-
-/**
- * Convert time_t to Simple Component Evidence UTS string format
- */
-void measurement_time_to_utc(time_t measurement_time, chunk_t *utc_time)
-{
- struct tm t;
-
- if (measurement_time == UNDEFINED_TIME)
- {
- utc_time->ptr = utc_undefined_time_str;
- }
- else
- {
- gmtime_r(&measurement_time, &t);
- sprintf(utc_time->ptr, "%04d-%02d-%02dT%02d:%02d:%02dZ",
- t.tm_year + 1900, t.tm_mon + 1, t.tm_mday,
- t.tm_hour, t.tm_min, t.tm_sec);
- }
-}
-
-METHOD(pa_tnc_attr_t, build, void,
- private_tcg_pts_attr_simple_comp_evid_t *this)
-{
- bio_writer_t *writer;
- bool has_pcr_info;
- char utc_time_buf[25], *policy_uri;
- u_int8_t flags;
- u_int16_t len;
- u_int32_t depth, extended_pcr;
- pts_comp_func_name_t *name;
- pts_meas_algorithms_t hash_algorithm;
- pts_pcr_transform_t transform;
- pts_comp_evid_validation_t validation;
- time_t measurement_time;
- chunk_t measurement, utc_time, pcr_before, pcr_after;
-
- if (this->value.ptr)
- {
- return;
- }
-
- /* Extract parameters from comp_evidence_t object */
- name = this->evidence->get_comp_func_name(this->evidence,
- &depth);
- measurement = this->evidence->get_measurement(this->evidence,
- &extended_pcr, &hash_algorithm, &transform,
- &measurement_time);
- has_pcr_info = this->evidence->get_pcr_info(this->evidence,
- &pcr_before, &pcr_after);
- validation = this->evidence->get_validation(this->evidence,
- &policy_uri);
-
- /* Determine the flags to set*/
- flags = validation;
- if (has_pcr_info)
- {
- flags |= PTS_SIMPLE_COMP_EVID_FLAG_PCR;
- }
-
- utc_time = chunk_create(utc_time_buf, PTS_SIMPLE_COMP_EVID_MEAS_TIME_SIZE);
- measurement_time_to_utc(measurement_time, &utc_time);
-
- writer = bio_writer_create(PTS_SIMPLE_COMP_EVID_SIZE);
-
- writer->write_uint8 (writer, flags);
- writer->write_uint24(writer, depth);
- writer->write_uint24(writer, name->get_vendor_id(name));
- writer->write_uint8 (writer, name->get_qualifier(name));
- writer->write_uint32(writer, name->get_name(name));
- writer->write_uint8 (writer, PTS_SIMPLE_COMP_EVID_MEAS_TYPE);
- writer->write_uint24(writer, extended_pcr);
- writer->write_uint16(writer, hash_algorithm);
- writer->write_uint8 (writer, transform);
- writer->write_uint8 (writer, PTS_SIMPLE_COMP_EVID_RESERVED);
- writer->write_data (writer, utc_time);
-
- /* Optional fields */
- if (validation == PTS_COMP_EVID_VALIDATION_FAILED ||
- validation == PTS_COMP_EVID_VALIDATION_PASSED)
- {
- len = strlen(policy_uri);
- writer->write_uint16(writer, len);
- writer->write_data (writer, chunk_create(policy_uri, len));
- }
- if (has_pcr_info)
- {
- writer->write_uint16(writer, pcr_before.len);
- writer->write_data (writer, pcr_before);
- writer->write_data (writer, pcr_after);
- }
-
- writer->write_data(writer, measurement);
-
- this->value = writer->extract_buf(writer);
- writer->destroy(writer);
-}
-
-static const int days[] = { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 };
-static const int tm_leap_1970 = 477;
-
-/**
- * Convert Simple Component Evidence UTS string format to time_t
- */
-bool measurement_time_from_utc(time_t *measurement_time, chunk_t utc_time)
-{
- int tm_year, tm_mon, tm_day, tm_days, tm_hour, tm_min, tm_sec, tm_secs;
- int tm_leap_4, tm_leap_100, tm_leap_400, tm_leap;
-
- if (memeq(utc_undefined_time_str, utc_time.ptr, utc_time.len))
- {
- *measurement_time = 0;
- return TRUE;
- }
- if (sscanf(utc_time.ptr, "%4d-%2d-%2dT%2d:%2d:%2dZ",
- &tm_year, &tm_mon, &tm_day, &tm_hour, &tm_min, &tm_sec) != 6)
- {
- return FALSE;
- }
-
- /* representation of months as 0..11 */
- tm_mon--;
-
- /* representation of days as 0..30 */
- tm_day--;
-
- /* number of leap years between last year and 1970? */
- tm_leap_4 = (tm_year - 1) / 4;
- tm_leap_100 = tm_leap_4 / 25;
- tm_leap_400 = tm_leap_100 / 4;
- tm_leap = tm_leap_4 - tm_leap_100 + tm_leap_400 - tm_leap_1970;
-
- /* if date later then February, is the current year a leap year? */
- if (tm_mon > 1 && (tm_year % 4 == 0) &&
- (tm_year % 100 != 0 || tm_year % 400 == 0))
- {
- tm_leap++;
- }
- tm_days = 365 * (tm_year - 1970) + days[tm_mon] + tm_day + tm_leap;
- tm_secs = 60 * (60 * (24 * tm_days + tm_hour) + tm_min) + tm_sec;
-
- *measurement_time = tm_secs;
- return TRUE;
-}
-
-METHOD(pa_tnc_attr_t, process, status_t,
- private_tcg_pts_attr_simple_comp_evid_t *this, u_int32_t *offset)
-{
- bio_reader_t *reader;
- pts_comp_func_name_t *name;
- u_int8_t flags, fam_and_qualifier, qualifier, reserved;
- u_int8_t measurement_type, transform, validation;
- u_int16_t hash_algorithm, len;
- u_int32_t depth, vendor_id, comp_name, extended_pcr;
- chunk_t measurement, utc_time, policy_uri, pcr_before, pcr_after;
- time_t measurement_time;
- bool has_pcr_info = FALSE, has_validation = FALSE;
- status_t status = FAILED;
-
- if (this->value.len < PTS_SIMPLE_COMP_EVID_SIZE)
- {
- DBG1(DBG_TNC, "insufficient data for Simple Component Evidence");
- *offset = 0;
- return FAILED;
- }
- reader = bio_reader_create(this->value);
-
- reader->read_uint8 (reader, &flags);
- reader->read_uint24(reader, &depth);
- reader->read_uint24(reader, &vendor_id);
- reader->read_uint8 (reader, &fam_and_qualifier);
- reader->read_uint32(reader, &comp_name);
- reader->read_uint8 (reader, &measurement_type);
- reader->read_uint24(reader, &extended_pcr);
- reader->read_uint16(reader, &hash_algorithm);
- reader->read_uint8 (reader, &transform);
- reader->read_uint8 (reader, &reserved);
- reader->read_data (reader, PTS_SIMPLE_COMP_EVID_MEAS_TIME_SIZE, &utc_time);
-
- if (measurement_type != PTS_SIMPLE_COMP_EVID_MEAS_TYPE)
- {
- DBG1(DBG_TNC, "unsupported Measurement Type in "
- "Simple Component Evidence");
- *offset = 12;
- reader->destroy(reader);
- return FAILED;
- }
- if (!measurement_time_from_utc(&measurement_time, utc_time))
- {
- DBG1(DBG_TNC, "invalid Measurement Time field in "
- "Simple Component Evidence");
- *offset = 20;
- reader->destroy(reader);
- return FAILED;
- }
- validation = flags & PTS_SIMPLE_COMP_EVID_VALIDATION_MASK;
- qualifier = fam_and_qualifier & ~PTS_SIMPLE_COMP_EVID_FAMILY_MASK;
-
- /* Is optional Policy URI field included? */
- if (validation == PTS_COMP_EVID_VALIDATION_FAILED ||
- validation == PTS_COMP_EVID_VALIDATION_PASSED)
- {
- if (!reader->read_uint16(reader, &len))
- {
- DBG1(DBG_TNC, "insufficient data for PTS Simple Component Evidence "
- "Verification Policy URI Length");
- goto end;
- }
- if (!reader->read_data(reader, len, &policy_uri))
- {
- DBG1(DBG_TNC, "insufficient data for PTS Simple Component Evidence "
- "Verification Policy URI");
- goto end;
- }
- has_validation = TRUE;
- }
-
- /* Are optional PCR value fields included? */
- if (flags & PTS_SIMPLE_COMP_EVID_FLAG_PCR)
- {
- if (!reader->read_uint16(reader, &len))
- {
- DBG1(DBG_TNC, "insufficient data for PTS Simple Component Evidence "
- "PCR Value length");
- goto end;
- }
- if (!reader->read_data(reader, len, &pcr_before))
- {
- DBG1(DBG_TNC, "insufficient data for PTS Simple Component Evidence "
- "PCR Before Value");
- goto end;
- }
- if (!reader->read_data(reader, len, &pcr_after))
- {
- DBG1(DBG_TNC, "insufficient data for PTS Simple Component Evidence "
- "PCR After Value");
- goto end;
- }
- has_pcr_info = TRUE;
- }
-
- /* Measurement field comes at the very end */
- reader->read_data(reader,reader->remaining(reader), &measurement);
- reader->destroy(reader);
-
- /* Create Component Functional Name object */
- name = pts_comp_func_name_create(vendor_id, comp_name, qualifier);
-
- /* Create Component Evidence object */
- measurement = chunk_clone(measurement);
- this->evidence = pts_comp_evidence_create(name, depth, extended_pcr,
- hash_algorithm, transform,
- measurement_time, measurement);
-
- /* Add options */
- if (has_validation)
- {
- char buf[BUF_LEN];
- size_t len;
-
- len = min(policy_uri.len, BUF_LEN-1);
- memcpy(buf, policy_uri.ptr, len);
- buf[len] = '\0';
- this->evidence->set_validation(this->evidence, validation, buf);
- }
- if (has_pcr_info)
- {
- pcr_before = chunk_clone(pcr_before);
- pcr_after = chunk_clone(pcr_after);
- this->evidence->set_pcr_info(this->evidence, pcr_before, pcr_after);
- }
-
- return SUCCESS;
-
-end:
- reader->destroy(reader);
- return status;
-}
-
-METHOD(pa_tnc_attr_t, get_ref, pa_tnc_attr_t*,
- private_tcg_pts_attr_simple_comp_evid_t *this)
-{
- ref_get(&this->ref);
- return &this->public.pa_tnc_attribute;
-}
-
-METHOD(pa_tnc_attr_t, destroy, void,
- private_tcg_pts_attr_simple_comp_evid_t *this)
-{
- if (ref_put(&this->ref))
- {
- DESTROY_IF(this->evidence);
- free(this->value.ptr);
- free(this);
- }
-}
-
-METHOD(tcg_pts_attr_simple_comp_evid_t, get_comp_evidence, pts_comp_evidence_t*,
- private_tcg_pts_attr_simple_comp_evid_t *this)
-{
- return this->evidence;
-}
-
-/**
- * Described in header.
- */
-pa_tnc_attr_t *tcg_pts_attr_simple_comp_evid_create(pts_comp_evidence_t *evid)
-{
- private_tcg_pts_attr_simple_comp_evid_t *this;
-
- INIT(this,
- .public = {
- .pa_tnc_attribute = {
- .get_type = _get_type,
- .get_value = _get_value,
- .get_noskip_flag = _get_noskip_flag,
- .set_noskip_flag = _set_noskip_flag,
- .build = _build,
- .process = _process,
- .get_ref = _get_ref,
- .destroy = _destroy,
- },
- .get_comp_evidence = _get_comp_evidence,
- },
- .type = { PEN_TCG, TCG_PTS_SIMPLE_COMP_EVID },
- .evidence = evid,
- .ref = 1,
- );
-
- return &this->public.pa_tnc_attribute;
-}
-
-
-/**
- * Described in header.
- */
-pa_tnc_attr_t *tcg_pts_attr_simple_comp_evid_create_from_data(chunk_t data)
-{
- private_tcg_pts_attr_simple_comp_evid_t *this;
-
- INIT(this,
- .public = {
- .pa_tnc_attribute = {
- .get_type = _get_type,
- .get_value = _get_value,
- .get_noskip_flag = _get_noskip_flag,
- .set_noskip_flag = _set_noskip_flag,
- .build = _build,
- .process = _process,
- .get_ref = _get_ref,
- .destroy = _destroy,
- },
- .get_comp_evidence = _get_comp_evidence,
- },
- .type = { PEN_TCG, TCG_PTS_SIMPLE_COMP_EVID },
- .value = chunk_clone(data),
- .ref = 1,
- );
-
- return &this->public.pa_tnc_attribute;
-}
+++ /dev/null
-/*
- * 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_simple_comp_evid tcg_pts_attr_simple_comp_evid
- * @{ @ingroup tcg_attr
- */
-
-#ifndef TCG_PTS_ATTR_SIMPLE_COMP_EVID_H_
-#define TCG_PTS_ATTR_SIMPLE_COMP_EVID_H_
-
-typedef struct tcg_pts_attr_simple_comp_evid_t tcg_pts_attr_simple_comp_evid_t;
-
-#include "tcg_attr.h"
-#include "pts/components/pts_comp_evidence.h"
-#include "pa_tnc/pa_tnc_attr.h"
-
-/**
- * Class implementing the TCG PTS Simple Component Evidence attribute
- *
- */
-struct tcg_pts_attr_simple_comp_evid_t {
-
- /**
- * Public PA-TNC attribute interface
- */
- pa_tnc_attr_t pa_tnc_attribute;
-
- /**
- * Get Component Evidence
- *
- * @return Component Evidence
- */
- pts_comp_evidence_t* (*get_comp_evidence)(tcg_pts_attr_simple_comp_evid_t *this);
-
-};
-
-/**
- * Creates an tcg_pts_attr_simple_comp_evid_t object
- *
- * @param evid Component Evidence
- */
-pa_tnc_attr_t* tcg_pts_attr_simple_comp_evid_create(pts_comp_evidence_t *evid);
-
-/**
- * Creates an tcg_pts_attr_simple_comp_evid_t object from received data
- *
- * @param value Unparsed attribute value
- */
-pa_tnc_attr_t* tcg_pts_attr_simple_comp_evid_create_from_data(chunk_t value);
-
-#endif /** TCG_PTS_ATTR_SIMPLE_COMP_EVID_H_ @}*/
+++ /dev/null
-/*
- * Copyright (C) 2011-2012 Sansar Choinyambuu, Andreas Steffen
- * HSR Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#include "tcg_pts_attr_simple_evid_final.h"
-#include "pts/pts_simple_evid_final.h"
-
-#include <pa_tnc/pa_tnc_msg.h>
-#include <bio/bio_writer.h>
-#include <bio/bio_reader.h>
-#include <utils/debug.h>
-
-typedef struct private_tcg_pts_attr_simple_evid_final_t private_tcg_pts_attr_simple_evid_final_t;
-
-/**
- * Simple Evidence Final
- * see section 3.15.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
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Flags | Reserved | Optional Composite Hash Alg |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Optional TPM PCR Composite Length |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * ~ Optional TPM PCR Composite (Variable Length) ~
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Optional TPM Quote Signature Length |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * ~ Optional TPM Quote Signature (Variable Length) ~
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * ~ Optional Evidence Signature (Variable Length) ~
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- */
-
-#define PTS_SIMPLE_EVID_FINAL_SIZE 2
-#define PTS_SIMPLE_EVID_FINAL_RESERVED 0x00
-#define PTS_SIMPLE_EVID_FINAL_FLAG_MASK 0xC0
-/**
- * Private data of an tcg_pts_attr_simple_evid_final_t object.
- */
-struct private_tcg_pts_attr_simple_evid_final_t {
-
- /**
- * Public members of tcg_pts_attr_simple_evid_final_t
- */
- tcg_pts_attr_simple_evid_final_t public;
-
- /**
- * Vendor-specific attribute type
- */
- pen_type_t type;
-
- /**
- * Attribute value
- */
- chunk_t value;
-
- /**
- * Noskip flag
- */
- bool noskip_flag;
-
- /**
- * Set of flags for Simple Evidence Final
- */
- u_int8_t flags;
-
- /**
- * Optional Composite Hash Algorithm
- */
- pts_meas_algorithms_t comp_hash_algorithm;
-
- /**
- * Optional TPM PCR Composite
- */
- chunk_t pcr_comp;
-
- /**
- * Optional TPM Quote Signature
- */
- chunk_t tpm_quote_sig;
-
- /**
- * Is Evidence Signature included?
- */
- bool has_evid_sig;
-
- /**
- * Optional Evidence Signature
- */
- chunk_t evid_sig;
-
- /**
- * Reference count
- */
- refcount_t ref;
-};
-
-METHOD(pa_tnc_attr_t, get_type, pen_type_t,
- private_tcg_pts_attr_simple_evid_final_t *this)
-{
- return this->type;
-}
-
-METHOD(pa_tnc_attr_t, get_value, chunk_t,
- private_tcg_pts_attr_simple_evid_final_t *this)
-{
- return this->value;
-}
-
-METHOD(pa_tnc_attr_t, get_noskip_flag, bool,
- private_tcg_pts_attr_simple_evid_final_t *this)
-{
- return this->noskip_flag;
-}
-
-METHOD(pa_tnc_attr_t, set_noskip_flag,void,
- private_tcg_pts_attr_simple_evid_final_t *this, bool noskip)
-{
- this->noskip_flag = noskip;
-}
-
-METHOD(pa_tnc_attr_t, get_ref, pa_tnc_attr_t*,
- private_tcg_pts_attr_simple_evid_final_t *this)
-{
- ref_get(&this->ref);
- return &this->public.pa_tnc_attribute;
-}
-
-METHOD(pa_tnc_attr_t, destroy, void,
- private_tcg_pts_attr_simple_evid_final_t *this)
-{
- if (ref_put(&this->ref))
- {
- free(this->value.ptr);
- free(this->pcr_comp.ptr);
- free(this->tpm_quote_sig.ptr);
- free(this->evid_sig.ptr);
- free(this);
- }
-}
-
-METHOD(pa_tnc_attr_t, build, void,
- private_tcg_pts_attr_simple_evid_final_t *this)
-{
- bio_writer_t *writer;
- u_int8_t flags;
-
- if (this->value.ptr)
- {
- return;
- }
- flags = this->flags & PTS_SIMPLE_EVID_FINAL_FLAG_MASK;
-
- if (this->has_evid_sig)
- {
- flags |= PTS_SIMPLE_EVID_FINAL_EVID_SIG;
- }
-
- writer = bio_writer_create(PTS_SIMPLE_EVID_FINAL_SIZE);
- writer->write_uint8 (writer, flags);
- writer->write_uint8 (writer, PTS_SIMPLE_EVID_FINAL_RESERVED);
-
- /** Optional Composite Hash Algorithm field is always present
- * Field has value of all zeroes if not used.
- * Implemented adhering the suggestion of Paul Sangster 28.Oct.2011
- */
- writer->write_uint16(writer, this->comp_hash_algorithm);
-
- /* Optional fields */
- if (this->flags != PTS_SIMPLE_EVID_FINAL_NO)
- {
- writer->write_uint32 (writer, this->pcr_comp.len);
- writer->write_data (writer, this->pcr_comp);
-
- writer->write_uint32 (writer, this->tpm_quote_sig.len);
- writer->write_data (writer, this->tpm_quote_sig);
- }
-
- if (this->has_evid_sig)
- {
- writer->write_data (writer, this->evid_sig);
- }
-
- this->value = writer->extract_buf(writer);
- writer->destroy(writer);
-}
-
-METHOD(pa_tnc_attr_t, process, status_t,
- private_tcg_pts_attr_simple_evid_final_t *this, u_int32_t *offset)
-{
- bio_reader_t *reader;
- u_int8_t flags, reserved;
- u_int16_t algorithm;
- u_int32_t pcr_comp_len, tpm_quote_sig_len, evid_sig_len;
- status_t status = FAILED;
-
- if (this->value.len < PTS_SIMPLE_EVID_FINAL_SIZE)
- {
- DBG1(DBG_TNC, "insufficient data for Simple Evidence Final");
- *offset = 0;
- return FAILED;
- }
- reader = bio_reader_create(this->value);
-
- reader->read_uint8(reader, &flags);
- reader->read_uint8(reader, &reserved);
-
- this->flags = flags & PTS_SIMPLE_EVID_FINAL_FLAG_MASK;
-
- this->has_evid_sig = (flags & PTS_SIMPLE_EVID_FINAL_EVID_SIG) != 0;
-
- /** Optional Composite Hash Algorithm field is always present
- * Field has value of all zeroes if not used.
- * Implemented adhering the suggestion of Paul Sangster 28.Oct.2011
- */
-
- reader->read_uint16(reader, &algorithm);
- this->comp_hash_algorithm = algorithm;
-
- /* Optional Composite Hash Algorithm and TPM PCR Composite fields */
- if (this->flags != PTS_SIMPLE_EVID_FINAL_NO)
- {
- if (!reader->read_uint32(reader, &pcr_comp_len))
- {
- DBG1(DBG_TNC, "insufficient data for PTS Simple Evidence Final "
- "PCR Composite Length");
- goto end;
- }
- if (!reader->read_data(reader, pcr_comp_len, &this->pcr_comp))
- {
- DBG1(DBG_TNC, "insufficient data for PTS Simple Evidence Final "
- "PCR Composite");
- goto end;
- }
- this->pcr_comp = chunk_clone(this->pcr_comp);
-
- if (!reader->read_uint32(reader, &tpm_quote_sig_len))
- {
- DBG1(DBG_TNC, "insufficient data for PTS Simple Evidence Final "
- "TPM Quote Singature Length");
- goto end;
- }
- if (!reader->read_data(reader, tpm_quote_sig_len, &this->tpm_quote_sig))
- {
- DBG1(DBG_TNC, "insufficient data for PTS Simple Evidence Final "
- "TPM Quote Singature");
- goto end;
- }
- this->tpm_quote_sig = chunk_clone(this->tpm_quote_sig);
- }
-
- /* Optional Evidence Signature field */
- if (this->has_evid_sig)
- {
- evid_sig_len = reader->remaining(reader);
- reader->read_data(reader, evid_sig_len, &this->evid_sig);
- this->evid_sig = chunk_clone(this->evid_sig);
- }
-
- reader->destroy(reader);
- return SUCCESS;
-
-end:
- reader->destroy(reader);
- return status;
-}
-
-METHOD(tcg_pts_attr_simple_evid_final_t, get_quote_info, u_int8_t,
- private_tcg_pts_attr_simple_evid_final_t *this,
- pts_meas_algorithms_t *comp_hash_algo, chunk_t *pcr_comp, chunk_t *tpm_quote_sig)
-{
- if (comp_hash_algo)
- {
- *comp_hash_algo = this->comp_hash_algorithm;
- }
- if (pcr_comp)
- {
- *pcr_comp = this->pcr_comp;
- }
- if (tpm_quote_sig)
- {
- *tpm_quote_sig = this->tpm_quote_sig;
- }
- return this->flags;
-}
-
-METHOD(tcg_pts_attr_simple_evid_final_t, get_evid_sig, bool,
- private_tcg_pts_attr_simple_evid_final_t *this, chunk_t *evid_sig)
-{
- if (evid_sig)
- {
- *evid_sig = this->evid_sig;
- }
- return this->has_evid_sig;
-}
-
-METHOD(tcg_pts_attr_simple_evid_final_t, set_evid_sig, void,
- private_tcg_pts_attr_simple_evid_final_t *this, chunk_t evid_sig)
-{
- this->evid_sig = evid_sig;
- this->has_evid_sig = TRUE;
-}
-
-/**
- * Described in header.
- */
-pa_tnc_attr_t *tcg_pts_attr_simple_evid_final_create(u_int8_t flags,
- pts_meas_algorithms_t comp_hash_algorithm,
- chunk_t pcr_comp, chunk_t tpm_quote_sig)
-{
- private_tcg_pts_attr_simple_evid_final_t *this;
-
- INIT(this,
- .public = {
- .pa_tnc_attribute = {
- .get_type = _get_type,
- .get_value = _get_value,
- .get_noskip_flag = _get_noskip_flag,
- .set_noskip_flag = _set_noskip_flag,
- .build = _build,
- .process = _process,
- .get_ref = _get_ref,
- .destroy = _destroy,
- },
- .get_quote_info = _get_quote_info,
- .get_evid_sig = _get_evid_sig,
- .set_evid_sig = _set_evid_sig,
- },
- .type = { PEN_TCG, TCG_PTS_SIMPLE_EVID_FINAL },
- .flags = flags,
- .comp_hash_algorithm = comp_hash_algorithm,
- .pcr_comp = pcr_comp,
- .tpm_quote_sig = tpm_quote_sig,
- .ref = 1,
- );
-
- return &this->public.pa_tnc_attribute;
-}
-
-
-/**
- * Described in header.
- */
-pa_tnc_attr_t *tcg_pts_attr_simple_evid_final_create_from_data(chunk_t data)
-{
- private_tcg_pts_attr_simple_evid_final_t *this;
-
- INIT(this,
- .public = {
- .pa_tnc_attribute = {
- .get_type = _get_type,
- .get_value = _get_value,
- .get_noskip_flag = _get_noskip_flag,
- .set_noskip_flag = _set_noskip_flag,
- .build = _build,
- .process = _process,
- .get_ref = _get_ref,
- .destroy = _destroy,
- },
- .get_quote_info = _get_quote_info,
- .get_evid_sig = _get_evid_sig,
- .set_evid_sig = _set_evid_sig,
- },
- .type = { PEN_TCG, TCG_PTS_SIMPLE_EVID_FINAL },
- .value = chunk_clone(data),
- .ref = 1,
- );
-
- return &this->public.pa_tnc_attribute;
-}
+++ /dev/null
-/*
- * 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_simple_evid_final tcg_pts_attr_simple_evid_final
- * @{ @ingroup tcg_attr
- */
-
-#ifndef TCG_PTS_ATTR_SIMPLE_EVID_FINAL_H_
-#define TCG_PTS_ATTR_SIMPLE_EVID_FINAL_H_
-
-typedef struct tcg_pts_attr_simple_evid_final_t tcg_pts_attr_simple_evid_final_t;
-
-#include "tcg_attr.h"
-#include "tcg_pts_attr_meas_algo.h"
-#include "pa_tnc/pa_tnc_attr.h"
-
-/**
- * Class implementing the TCG PTS Simple Evidence Final attribute
- *
- */
-struct tcg_pts_attr_simple_evid_final_t {
-
- /**
- * Public PA-TNC attribute interface
- */
- pa_tnc_attr_t pa_tnc_attribute;
-
- /**
- * Get Optional PCR Composite and TPM Quote Signature
- *
- * @param comp_hash_algo Optional Composite Hash Algorithm
- * @param pcr_comp Optional PCR Composite
- * @param tpm_quote sig Optional TPM Quote Signature
- * @return PTS_SIMPLE_EVID_FINAL flags
- */
- u_int8_t (*get_quote_info)(tcg_pts_attr_simple_evid_final_t *this,
- pts_meas_algorithms_t *comp_hash_algo,
- chunk_t *pcr_comp, chunk_t *tpm_quote_sig);
-
- /**
- * Get Optional Evidence Signature
- *
- * @param evid_sig Optional Evidence Signature
- * @return TRUE if Evidence Signature is available
- */
- bool (*get_evid_sig)(tcg_pts_attr_simple_evid_final_t *this,
- chunk_t *evid_sig);
-
- /**
- * Set Optional Evidence Signature
- *
- * @param vid_sig Optional Evidence Signature
- */
- void (*set_evid_sig)(tcg_pts_attr_simple_evid_final_t *this,
- chunk_t evid_sig);
-
-};
-
-/**
- * Creates an tcg_pts_attr_simple_evid_final_t object
- *
- * @param flags Set of flags
- * @param comp_hash_algorithm Composite Hash Algorithm
- * @param pcr_comp Optional TPM PCR Composite
- * @param tpm_quote_sign Optional TPM Quote Signature
- */
-pa_tnc_attr_t* tcg_pts_attr_simple_evid_final_create(
- u_int8_t flags,
- pts_meas_algorithms_t comp_hash_algorithm,
- chunk_t pcr_comp,
- chunk_t tpm_quote_sign);
-
-/**
- * Creates an tcg_pts_attr_simple_evid_final_t object from received data
- *
- * @param value unparsed attribute value
- */
-pa_tnc_attr_t* tcg_pts_attr_simple_evid_final_create_from_data(chunk_t value);
-
-#endif /** TCG_PTS_ATTR_SIMPLE_EVID_FINAL_H_ @}*/
+++ /dev/null
-/*
- * Copyright (C) 2011-2012 Sansar Choinyambuu, Andreas Steffen
- * HSR Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#include "tcg_pts_attr_tpm_version_info.h"
-
-#include <pa_tnc/pa_tnc_msg.h>
-#include <bio/bio_writer.h>
-#include <bio/bio_reader.h>
-#include <utils/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 Length) |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- *
- * see TPM Structure Specification Part 2, section 21.6: TPM_CAP_VERSION_INFO
- */
-
-#define PTS_TPM_VER_INFO_SIZE 4
-
-/**
- * Private data of an tcg_pts_attr_tpm_version_info_t object.
- */
-struct private_tcg_pts_attr_tpm_version_info_t {
-
- /**
- * Public members of tcg_pts_attr_tpm_version_info_t
- */
- tcg_pts_attr_tpm_version_info_t public;
-
- /**
- * Vendor-specific attribute type
- */
- pen_type_t type;
-
- /**
- * Attribute value
- */
- chunk_t value;
-
- /**
- * Noskip flag
- */
- bool noskip_flag;
-
- /**
- * TPM Version Information
- */
- chunk_t tpm_version_info;
-
- /**
- * Reference count
- */
- refcount_t ref;
-};
-
-METHOD(pa_tnc_attr_t, get_type, pen_type_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;
-
- if (this->value.ptr)
- {
- return;
- }
- writer = bio_writer_create(PTS_TPM_VER_INFO_SIZE);
- writer->write_data(writer, this->tpm_version_info);
-
- this->value = writer->extract_buf(writer);
- writer->destroy(writer);
-}
-
-METHOD(pa_tnc_attr_t, process, status_t,
- private_tcg_pts_attr_tpm_version_info_t *this, u_int32_t *offset)
-{
- bio_reader_t *reader;
-
- if (this->value.len < PTS_TPM_VER_INFO_SIZE)
- {
- DBG1(DBG_TNC, "insufficient data for TPM Version Information");
- *offset = 0;
- return FAILED;
- }
- reader = bio_reader_create(this->value);
- reader->read_data (reader, this->value.len, &this->tpm_version_info);
- this->tpm_version_info = chunk_clone(this->tpm_version_info);
- reader->destroy(reader);
-
- return SUCCESS;
-}
-
-METHOD(pa_tnc_attr_t, get_ref, pa_tnc_attr_t*,
- private_tcg_pts_attr_tpm_version_info_t *this)
-{
- ref_get(&this->ref);
- return &this->public.pa_tnc_attribute;
-}
-
-METHOD(pa_tnc_attr_t, destroy, void,
- private_tcg_pts_attr_tpm_version_info_t *this)
-{
- if (ref_put(&this->ref))
- {
- 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)
-{
- 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_type = _get_type,
- .get_value = _get_value,
- .get_noskip_flag = _get_noskip_flag,
- .set_noskip_flag = _set_noskip_flag,
- .build = _build,
- .process = _process,
- .get_ref = _get_ref,
- .destroy = _destroy,
- },
- .get_tpm_version_info = _get_tpm_version_info,
- .set_tpm_version_info = _set_tpm_version_info,
- },
- .type = { PEN_TCG, TCG_PTS_TPM_VERSION_INFO },
- .tpm_version_info = chunk_clone(tpm_version_info),
- .ref = 1,
- );
-
- 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_type = _get_type,
- .get_value = _get_value,
- .get_noskip_flag = _get_noskip_flag,
- .set_noskip_flag = _set_noskip_flag,
- .build = _build,
- .process = _process,
- .get_ref = _get_ref,
- .destroy = _destroy,
- },
- .get_tpm_version_info = _get_tpm_version_info,
- .set_tpm_version_info = _set_tpm_version_info,
- },
- .type = { PEN_TCG, TCG_PTS_TPM_VERSION_INFO },
- .value = chunk_clone(data),
- .ref = 1,
- );
-
- return &this->public.pa_tnc_attribute;
-}
+++ /dev/null
-/*
- * 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_attr
- */
-
-#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_ @}*/
+++ /dev/null
-/*
- * Copyright (C) 2011-2012 Sansar Choinyambuu, Andreas Steffen
- * HSR Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#include "tcg_pts_attr_unix_file_meta.h"
-
-#include <pa_tnc/pa_tnc_msg.h>
-#include <bio/bio_writer.h>
-#include <bio/bio_reader.h>
-#include <collections/linked_list.h>
-#include <utils/debug.h>
-
-#include <string.h>
-
-typedef struct private_tcg_pts_attr_file_meta_t private_tcg_pts_attr_file_meta_t;
-
-/**
- * Unix-Style File Metadata
- * see section 3.17.3 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
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Number of Files included |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Number of Files included |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | File metadata Length | Type | Reserved |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | File Size |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | File Size |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | File Create Time |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | File Create Time |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Last Modify Time |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Last Modify Time |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Last Access Time |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Last Access Time |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | File Owner ID |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | File Owner ID |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | File Group ID |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | File Group ID |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * ~ Filename (Variable Length) ~
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * ...........................
- */
-
-#define PTS_FILE_META_SIZE 8
-#define PTS_FILE_MEAS_RESERVED 0x00
-#define PTS_FILE_METADATA_SIZE 52
-
-/**
- * Private data of an tcg_pts_attr_file_meta_t object.
- */
-struct private_tcg_pts_attr_file_meta_t {
-
- /**
- * Public members of tcg_pts_attr_file_meta_t
- */
- tcg_pts_attr_file_meta_t public;
-
- /**
- * Vendor-specific attribute type
- */
- pen_type_t type;
-
- /**
- * Attribute value
- */
- chunk_t value;
-
- /**
- * Noskip flag
- */
- bool noskip_flag;
-
- /**
- * PTS File Metadata
- */
- pts_file_meta_t *metadata;
-
- /**
- * Reference count
- */
- refcount_t ref;
-};
-
-METHOD(pa_tnc_attr_t, get_type, pen_type_t,
- private_tcg_pts_attr_file_meta_t *this)
-{
- return this->type;
-}
-
-METHOD(pa_tnc_attr_t, get_value, chunk_t,
- private_tcg_pts_attr_file_meta_t *this)
-{
- return this->value;
-}
-
-METHOD(pa_tnc_attr_t, get_noskip_flag, bool,
- private_tcg_pts_attr_file_meta_t *this)
-{
- return this->noskip_flag;
-}
-
-METHOD(pa_tnc_attr_t, set_noskip_flag,void,
- private_tcg_pts_attr_file_meta_t *this, bool noskip)
-{
- this->noskip_flag = noskip;
-}
-
-METHOD(pa_tnc_attr_t, build, void,
- private_tcg_pts_attr_file_meta_t *this)
-{
- bio_writer_t *writer;
- enumerator_t *enumerator;
- pts_file_metadata_t *entry;
- u_int64_t number_of_files;
-
- if (this->value.ptr)
- {
- return;
- }
- number_of_files = this->metadata->get_file_count(this->metadata);
- writer = bio_writer_create(PTS_FILE_META_SIZE);
-
- writer->write_uint64(writer, number_of_files);
-
- enumerator = this->metadata->create_enumerator(this->metadata);
- while (enumerator->enumerate(enumerator, &entry))
- {
- writer->write_uint16(writer, PTS_FILE_METADATA_SIZE +
- strlen(entry->filename));
- writer->write_uint8 (writer, entry->type);
- writer->write_uint8 (writer, PTS_FILE_MEAS_RESERVED);
- writer->write_uint64(writer, entry->filesize);
- writer->write_uint64(writer, entry->created);
- writer->write_uint64(writer, entry->modified);
- writer->write_uint64(writer, entry->accessed);
- writer->write_uint64(writer, entry->owner);
- writer->write_uint64(writer, entry->group);
- writer->write_data (writer, chunk_create(entry->filename,
- strlen(entry->filename)));
- }
- enumerator->destroy(enumerator);
-
- this->value = writer->extract_buf(writer);
- writer->destroy(writer);
-}
-
-METHOD(pa_tnc_attr_t, process, status_t,
- private_tcg_pts_attr_file_meta_t *this, u_int32_t *offset)
-{
- bio_reader_t *reader;
- pts_file_metadata_t *entry;
- u_int8_t type, reserved;
- u_int16_t len;
- u_int64_t number_of_files, filesize, created, modified, accessed;
- u_int64_t owner, group;
- chunk_t filename;
- status_t status = FAILED;
-
- if (this->value.len < PTS_FILE_META_SIZE)
- {
- DBG1(DBG_TNC, "insufficient data for PTS Unix-Style file metadata header");
- *offset = 0;
- return FAILED;
- }
- reader = bio_reader_create(this->value);
- reader->read_uint64(reader, &number_of_files);
-
- this->metadata = pts_file_meta_create();
-
- while (number_of_files--)
- {
- if (!reader->read_uint16(reader, &len))
- {
- DBG1(DBG_TNC, "insufficient data for PTS file metadata length");
- goto end;
- }
- if (!reader->read_uint8(reader, &type))
- {
- DBG1(DBG_TNC, "insufficient data for file type");
- goto end;
- }
- if (!reader->read_uint8(reader, &reserved))
- {
- DBG1(DBG_TNC, "insufficient data for reserved field");
- goto end;
- }
- if (!reader->read_uint64(reader, &filesize))
- {
- DBG1(DBG_TNC, "insufficient data for file size");
- goto end;
- }
- if (!reader->read_uint64(reader, &created))
- {
- DBG1(DBG_TNC, "insufficient data for file create time");
- goto end;
- }
- if (!reader->read_uint64(reader, &modified))
- {
- DBG1(DBG_TNC, "insufficient data for last modify time");
- goto end;
- }
- if (!reader->read_uint64(reader, &accessed))
- {
- DBG1(DBG_TNC, "insufficient data for last access time");
- goto end;
- }
- if (!reader->read_uint64(reader, &owner))
- {
- DBG1(DBG_TNC, "insufficient data for owner id");
- goto end;
- }
- if (!reader->read_uint64(reader, &group))
- {
- DBG1(DBG_TNC, "insufficient data for group id");
- goto end;
- }
- if (!reader->read_data(reader, len - PTS_FILE_METADATA_SIZE, &filename))
- {
- DBG1(DBG_TNC, "insufficient data for filename");
- goto end;
- }
-
- entry = malloc_thing(pts_file_metadata_t);
- entry->type = type;
- entry->filesize = filesize;
- entry->created = created;
- entry->modified = modified;
- entry->accessed = accessed;
- entry->owner = owner;
- entry->group = group;
- entry->filename = strndup(filename.ptr, filename.len);
-
- this->metadata->add(this->metadata, entry);
- }
- status = SUCCESS;
-
-end:
- reader->destroy(reader);
- return status;
-}
-
-METHOD(pa_tnc_attr_t, get_ref, pa_tnc_attr_t*,
- private_tcg_pts_attr_file_meta_t *this)
-{
- ref_get(&this->ref);
- return &this->public.pa_tnc_attribute;
-}
-
-METHOD(pa_tnc_attr_t, destroy, void,
- private_tcg_pts_attr_file_meta_t *this)
-{
- if (ref_put(&this->ref))
- {
- DESTROY_IF(this->metadata);
- free(this->value.ptr);
- free(this);
- }
-}
-
-METHOD(tcg_pts_attr_file_meta_t, get_metadata, pts_file_meta_t*,
- private_tcg_pts_attr_file_meta_t *this)
-{
- return this->metadata;
-}
-
-/**
- * Described in header.
- */
-pa_tnc_attr_t *tcg_pts_attr_unix_file_meta_create(pts_file_meta_t *metadata)
-{
- private_tcg_pts_attr_file_meta_t *this;
-
- INIT(this,
- .public = {
- .pa_tnc_attribute = {
- .get_type = _get_type,
- .get_value = _get_value,
- .get_noskip_flag = _get_noskip_flag,
- .set_noskip_flag = _set_noskip_flag,
- .build = _build,
- .process = _process,
- .get_ref = _get_ref,
- .destroy = _destroy,
- },
- .get_metadata = _get_metadata,
- },
- .type = { PEN_TCG, TCG_PTS_UNIX_FILE_META },
- .metadata = metadata,
- .ref = 1,
- );
-
- return &this->public.pa_tnc_attribute;
-}
-
-
-/**
- * Described in header.
- */
-pa_tnc_attr_t *tcg_pts_attr_unix_file_meta_create_from_data(chunk_t data)
-{
- private_tcg_pts_attr_file_meta_t *this;
-
- INIT(this,
- .public = {
- .pa_tnc_attribute = {
- .get_type = _get_type,
- .get_value = _get_value,
- .get_noskip_flag = _get_noskip_flag,
- .set_noskip_flag = _set_noskip_flag,
- .build = _build,
- .process = _process,
- .get_ref = _get_ref,
- .destroy = _destroy,
- },
- .get_metadata = _get_metadata,
- },
- .type = { PEN_TCG, TCG_PTS_UNIX_FILE_META },
- .value = chunk_clone(data),
- .ref = 1,
- );
-
- return &this->public.pa_tnc_attribute;
-}
+++ /dev/null
-/*
- * 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_unix_file_meta tcg_pts_attr_unix_file_meta
- * @{ @ingroup tcg_attr
- */
-
-#ifndef TCG_PTS_ATTR_UNIX_FILE_META_H_
-#define TCG_PTS_ATTR_UNIX_FILE_META_H_
-
-typedef struct tcg_pts_attr_file_meta_t tcg_pts_attr_file_meta_t;
-
-#include "tcg_attr.h"
-#include "pa_tnc/pa_tnc_attr.h"
-#include "pts/pts.h"
-#include "pts/pts_file_meta.h"
-
-/**
- * Class implementing the TCG PTS File Measurement attribute
- *
- */
-struct tcg_pts_attr_file_meta_t {
-
- /**
- * Public PA-TNC attribute interface
- */
- pa_tnc_attr_t pa_tnc_attribute;
-
- /**
- * Get PTS File Metadata
- *
- * @return PTS File Metadata
- */
- pts_file_meta_t* (*get_metadata)(tcg_pts_attr_file_meta_t *this);
-
-};
-
-/**
- * Creates an tcg_pts_attr_file_meta_t object
- *
- * @param metadata PTS File Metadata
- */
-pa_tnc_attr_t* tcg_pts_attr_unix_file_meta_create(pts_file_meta_t *metadata);
-
-/**
- * Creates an tcg_pts_attr_file_meta_t object from received data
- *
- * @param value unparsed attribute value
- */
-pa_tnc_attr_t* tcg_pts_attr_unix_file_meta_create_from_data(chunk_t value);
-
-#endif /** TCG_PTS_ATTR_UNIX_FILE_META_H_ @}*/