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
32 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
34 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
38 #define PTS_GET_AIK_SIZE 4
39 #define PTS_GET_AIK_RESERVED 0x00
42 * Private data of an tcg_pts_attr_get_aik_t object.
44 struct private_tcg_pts_attr_get_aik_t
{
47 * Public members of tcg_pts_attr_get_aik_t
49 tcg_pts_attr_get_aik_t
public;
72 METHOD(pa_tnc_attr_t
, get_vendor_id
, pen_t
,
73 private_tcg_pts_attr_get_aik_t
*this)
75 return this->vendor_id
;
78 METHOD(pa_tnc_attr_t
, get_type
, u_int32_t
,
79 private_tcg_pts_attr_get_aik_t
*this)
84 METHOD(pa_tnc_attr_t
, get_value
, chunk_t
,
85 private_tcg_pts_attr_get_aik_t
*this)
90 METHOD(pa_tnc_attr_t
, get_noskip_flag
, bool,
91 private_tcg_pts_attr_get_aik_t
*this)
93 return this->noskip_flag
;
96 METHOD(pa_tnc_attr_t
, set_noskip_flag
,void,
97 private_tcg_pts_attr_get_aik_t
*this, bool noskip
)
99 this->noskip_flag
= noskip
;
102 METHOD(pa_tnc_attr_t
, build
, void,
103 private_tcg_pts_attr_get_aik_t
*this)
105 bio_writer_t
*writer
;
107 writer
= bio_writer_create(PTS_GET_AIK_SIZE
);
108 writer
->write_uint32 (writer
, PTS_GET_AIK_RESERVED
);
110 this->value
= chunk_clone(writer
->get_buf(writer
));
111 writer
->destroy(writer
);
114 METHOD(pa_tnc_attr_t
, process
, status_t
,
115 private_tcg_pts_attr_get_aik_t
*this, u_int32_t
*offset
)
117 bio_reader_t
*reader
;
120 if (this->value
.len
< PTS_GET_AIK_SIZE
)
122 DBG1(DBG_TNC
, "insufficient data for Get AIK");
126 reader
= bio_reader_create(this->value
);
127 reader
->read_uint32 (reader
, &reserved
);
128 reader
->destroy(reader
);
133 METHOD(pa_tnc_attr_t
, destroy
, void,
134 private_tcg_pts_attr_get_aik_t
*this)
136 free(this->value
.ptr
);
141 * Described in header.
143 pa_tnc_attr_t
*tcg_pts_attr_get_aik_create()
145 private_tcg_pts_attr_get_aik_t
*this;
149 .pa_tnc_attribute
= {
150 .get_vendor_id
= _get_vendor_id
,
151 .get_type
= _get_type
,
152 .get_value
= _get_value
,
153 .get_noskip_flag
= _get_noskip_flag
,
154 .set_noskip_flag
= _set_noskip_flag
,
160 .vendor_id
= PEN_TCG
,
161 .type
= TCG_PTS_GET_AIK
,
164 return &this->public.pa_tnc_attribute
;
169 * Described in header.
171 pa_tnc_attr_t
*tcg_pts_attr_get_aik_create_from_data(chunk_t data
)
173 private_tcg_pts_attr_get_aik_t
*this;
177 .pa_tnc_attribute
= {
178 .get_vendor_id
= _get_vendor_id
,
179 .get_type
= _get_type
,
180 .get_value
= _get_value
,
181 .get_noskip_flag
= _get_noskip_flag
,
182 .set_noskip_flag
= _set_noskip_flag
,
188 .vendor_id
= PEN_TCG
,
189 .type
= TCG_PTS_GET_AIK
,
190 .value
= chunk_clone(data
),
193 return &this->public.pa_tnc_attribute
;