2 * Copyright (C) 2011 Sansar Choinyambuu
3 * HSR Hochschule fuer Technik Rapperswil
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 #include "tcg_pts_attr_get_aik.h"
18 #include <pa_tnc/pa_tnc_msg.h>
19 #include <bio/bio_writer.h>
20 #include <bio/bio_reader.h>
23 typedef struct private_tcg_pts_attr_get_aik_t private_tcg_pts_attr_get_aik_t
;
26 * Get Attestation Identity Key
27 * see section 3.12 of PTS Protocol: Binding to TNC IF-M Specification
30 * 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
31 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
33 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
36 #define PTS_GET_AIK_SIZE 4
37 #define PTS_GET_AIK_RESERVED 0x00000000
40 * Private data of an tcg_pts_attr_get_aik_t object.
42 struct private_tcg_pts_attr_get_aik_t
{
45 * Public members of tcg_pts_attr_get_aik_t
47 tcg_pts_attr_get_aik_t
public;
70 METHOD(pa_tnc_attr_t
, get_vendor_id
, pen_t
,
71 private_tcg_pts_attr_get_aik_t
*this)
73 return this->vendor_id
;
76 METHOD(pa_tnc_attr_t
, get_type
, u_int32_t
,
77 private_tcg_pts_attr_get_aik_t
*this)
82 METHOD(pa_tnc_attr_t
, get_value
, chunk_t
,
83 private_tcg_pts_attr_get_aik_t
*this)
88 METHOD(pa_tnc_attr_t
, get_noskip_flag
, bool,
89 private_tcg_pts_attr_get_aik_t
*this)
91 return this->noskip_flag
;
94 METHOD(pa_tnc_attr_t
, set_noskip_flag
,void,
95 private_tcg_pts_attr_get_aik_t
*this, bool noskip
)
97 this->noskip_flag
= noskip
;
100 METHOD(pa_tnc_attr_t
, build
, void,
101 private_tcg_pts_attr_get_aik_t
*this)
103 bio_writer_t
*writer
;
105 writer
= bio_writer_create(PTS_GET_AIK_SIZE
);
106 writer
->write_uint32 (writer
, PTS_GET_AIK_RESERVED
);
108 this->value
= chunk_clone(writer
->get_buf(writer
));
109 writer
->destroy(writer
);
112 METHOD(pa_tnc_attr_t
, process
, status_t
,
113 private_tcg_pts_attr_get_aik_t
*this, u_int32_t
*offset
)
115 bio_reader_t
*reader
;
118 if (this->value
.len
< PTS_GET_AIK_SIZE
)
120 DBG1(DBG_TNC
, "insufficient data for Get AIK");
124 reader
= bio_reader_create(this->value
);
125 reader
->read_uint32 (reader
, &reserved
);
126 reader
->destroy(reader
);
131 METHOD(pa_tnc_attr_t
, destroy
, void,
132 private_tcg_pts_attr_get_aik_t
*this)
134 free(this->value
.ptr
);
139 * Described in header.
141 pa_tnc_attr_t
*tcg_pts_attr_get_aik_create()
143 private_tcg_pts_attr_get_aik_t
*this;
147 .pa_tnc_attribute
= {
148 .get_vendor_id
= _get_vendor_id
,
149 .get_type
= _get_type
,
150 .get_value
= _get_value
,
151 .get_noskip_flag
= _get_noskip_flag
,
152 .set_noskip_flag
= _set_noskip_flag
,
158 .vendor_id
= PEN_TCG
,
159 .type
= TCG_PTS_GET_AIK
,
162 return &this->public.pa_tnc_attribute
;
167 * Described in header.
169 pa_tnc_attr_t
*tcg_pts_attr_get_aik_create_from_data(chunk_t data
)
171 private_tcg_pts_attr_get_aik_t
*this;
175 .pa_tnc_attribute
= {
176 .get_vendor_id
= _get_vendor_id
,
177 .get_type
= _get_type
,
178 .get_value
= _get_value
,
179 .get_noskip_flag
= _get_noskip_flag
,
180 .set_noskip_flag
= _set_noskip_flag
,
186 .vendor_id
= PEN_TCG
,
187 .type
= TCG_PTS_GET_AIK
,
188 .value
= chunk_clone(data
),
191 return &this->public.pa_tnc_attribute
;