define tpm_version_info as a chunk
[strongswan.git] / src / libimcv / plugins / imc_attestation / imc_attestation.c
1 /*
2 * Copyright (C) 2011 Sansar Choinyambuu
3 * HSR Hochschule fuer Technik Rapperswil
4 *
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>.
9 *
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
13 * for more details.
14 */
15
16 #include "imc_attestation_state.h"
17
18 #include <imc/imc_agent.h>
19 #include <pa_tnc/pa_tnc_msg.h>
20 #include <ietf/ietf_attr.h>
21 #include <ietf/ietf_attr_pa_tnc_error.h>
22
23 #include <tcg/tcg_pts_attr_proto_caps.h>
24 #include <tcg/tcg_pts_attr_meas_algo.h>
25 #include <tcg/tcg_pts_attr_get_tpm_version_info.h>
26 #include <tcg/tcg_pts_attr_tpm_version_info.h>
27 #include <tcg/tcg_pts_attr_get_aik.h>
28 #include <tcg/tcg_pts_attr_aik.h>
29 #include <tcg/tcg_pts_attr_req_funct_comp_evid.h>
30 #include <tcg/tcg_pts_attr_gen_attest_evid.h>
31 #include <tcg/tcg_pts_attr_simple_comp_evid.h>
32 #include <tcg/tcg_pts_attr_simple_evid_final.h>
33 #include <tcg/tcg_pts_attr_req_file_meas.h>
34 #include <tcg/tcg_pts_attr_file_meas.h>
35
36 #include <tncif_pa_subtypes.h>
37
38 #include <pen/pen.h>
39 #include <debug.h>
40 #include <utils/linked_list.h>
41 #include <crypto/hashers/hasher.h>
42 #include <dirent.h>
43 #include <errno.h>
44
45 #include <trousers/tss.h>
46 #include <trousers/trousers.h>
47
48
49 /* IMC definitions */
50
51 static const char imc_name[] = "Attestation";
52
53 #define IMC_VENDOR_ID PEN_TCG
54 #define IMC_SUBTYPE PA_SUBTYPE_TCG_PTS
55 #define IMC_ATTESTATION_BUF_SIZE 32768
56
57 static imc_agent_t *imc_attestation;
58
59 /**
60 * Supported PTS measurement algorithms
61 */
62 static pts_meas_algorithms_t supported_algorithms = 0;
63
64 /**
65 * PTS Protocol capabilities
66 */
67 static pts_proto_caps_flag_t proto_caps;
68
69 /**
70 * Selected PTS measurement algorithm after attribute exchange
71 */
72 static pts_meas_algorithms_t selected_algorithm = PTS_MEAS_ALGO_SHA256;
73
74 /**
75 * List of files and directories to measure
76 */
77 static linked_list_t *file_list, *directory_list;
78
79 /**
80 * List of file measurements
81 */
82 static linked_list_t *file_measurements;
83
84 /* TODO: Move the struct to some header file? Duplicate with imv_attestation*/
85 /**
86 * Struct to hold file or directory name with the request ID for Request File Measurement attribute
87 */
88 typedef struct measurement_req_entry_t measurement_req_entry_t;
89
90 struct measurement_req_entry_t {
91 char *path;
92 u_int16_t request_id;
93 };
94
95 /**
96 * see section 3.7.1 of TCG TNC IF-IMC Specification 1.2
97 */
98 TNC_Result TNC_IMC_Initialize(TNC_IMCID imc_id,
99 TNC_Version min_version,
100 TNC_Version max_version,
101 TNC_Version *actual_version)
102 {
103 if (imc_attestation)
104 {
105 DBG1(DBG_IMC, "IMC \"%s\" has already been initialized", imc_name);
106 return TNC_RESULT_ALREADY_INITIALIZED;
107 }
108 imc_attestation = imc_agent_create(imc_name, IMC_VENDOR_ID, IMC_SUBTYPE,
109 imc_id, actual_version);
110 if (!imc_attestation || !pts_meas_probe_algorithms(&supported_algorithms))
111 {
112 return TNC_RESULT_FATAL;
113 }
114 if (min_version > TNC_IFIMC_VERSION_1 || max_version < TNC_IFIMC_VERSION_1)
115 {
116 DBG1(DBG_IMC, "no common IF-IMC version");
117 return TNC_RESULT_NO_COMMON_VERSION;
118 }
119 return TNC_RESULT_SUCCESS;
120 }
121
122 /**
123 * see section 3.7.2 of TCG TNC IF-IMC Specification 1.2
124 */
125 TNC_Result TNC_IMC_NotifyConnectionChange(TNC_IMCID imc_id,
126 TNC_ConnectionID connection_id,
127 TNC_ConnectionState new_state)
128 {
129 imc_state_t *state;
130 /* TODO: Not used so far */
131 //imc_attestation_state_t *attestation_state;
132
133 if (!imc_attestation)
134 {
135 DBG1(DBG_IMC, "IMC \"%s\" has not been initialized", imc_name);
136 return TNC_RESULT_NOT_INITIALIZED;
137 }
138 switch (new_state)
139 {
140 case TNC_CONNECTION_STATE_CREATE:
141 state = imc_attestation_state_create(connection_id);
142 return imc_attestation->create_state(imc_attestation, state);
143 case TNC_CONNECTION_STATE_DELETE:
144 return imc_attestation->delete_state(imc_attestation, connection_id);
145 case TNC_CONNECTION_STATE_HANDSHAKE:
146 case TNC_CONNECTION_STATE_ACCESS_ISOLATED:
147 case TNC_CONNECTION_STATE_ACCESS_NONE:
148 default:
149 return imc_attestation->change_state(imc_attestation, connection_id,
150 new_state, NULL);
151 }
152 }
153
154 /**
155 * Get the TPM Version Information
156 */
157 static TSS_RESULT get_tpm_version_info(chunk_t *info)
158 {
159 TSS_HCONTEXT hContext;
160 TSS_HTPM hTPM;
161 TSS_RESULT result;
162
163 /* TODO: Needed for parsing version info on IMV side */
164 //TPM_CAP_VERSION_INFO versionInfo;
165 //UINT64 offset = 0;
166
167 result = Tspi_Context_Create(&hContext);
168 if (result != TSS_SUCCESS)
169 {
170 return result;
171 }
172 result = Tspi_Context_Connect(hContext, NULL);
173 if (result != TSS_SUCCESS)
174 {
175 return result;
176 }
177 result = Tspi_Context_GetTpmObject (hContext, &hTPM);
178 if (result != TSS_SUCCESS)
179 {
180 return result;
181 }
182 result = Tspi_TPM_GetCapability(hTPM, TSS_TPMCAP_VERSION_VAL, 0, NULL,
183 &info->len, &info->ptr);
184 return result;
185 }
186
187 /**
188 * Get Hash Measurement of a file
189 */
190 static TNC_Result hash_file(char *path, char *out)
191 {
192 BYTE buffer[IMC_ATTESTATION_BUF_SIZE];
193 FILE *file;
194 int bytes_read;
195 hasher_t *hasher;
196 hash_algorithm_t hash_alg;
197
198 /* Create a hasher */
199 hash_alg = pts_meas_to_hash_algorithm(selected_algorithm);
200 hasher = lib->crypto->create_hasher(lib->crypto, hash_alg);
201 if (!hasher)
202 {
203 DBG1(DBG_IMC, "hasher %N not available", hash_algorithm_names, hash_alg);
204 return TNC_RESULT_FATAL;
205 }
206
207 file = fopen(path, "rb");
208 if (!file)
209 {
210 DBG1(DBG_IMC,"file '%s' can not be opened", path);
211 hasher->destroy(hasher);
212 return TNC_RESULT_FATAL;
213 }
214 while (TRUE)
215 {
216 bytes_read = fread(buffer, 1, sizeof(buffer), file);
217 if (bytes_read > 0)
218 {
219 hasher->get_hash(hasher, chunk_create(buffer, bytes_read), NULL);
220 }
221 else
222 {
223 hasher->get_hash(hasher, chunk_empty, out);
224 break;
225 }
226 }
227 fclose(file);
228 hasher->destroy(hasher);
229
230 return TNC_RESULT_SUCCESS;
231 }
232
233 /**
234 * Get hash of all the files in a directory
235 */
236 static TNC_Result hash_directory(char *path)
237 {
238 DIR *dir;
239 struct dirent *ent;
240 linked_list_t *file_measurements;
241 file_meas_entry_t *entry;
242
243 file_measurements = linked_list_create();
244 entry = malloc_thing(file_meas_entry_t);
245
246 dir = opendir(path);
247 if (dir == NULL)
248 {
249 DBG1(DBG_IMC, "opening directory '%s' failed: %s", path, strerror(errno));
250 return TNC_RESULT_FATAL;
251 }
252 while ((ent = readdir(dir)))
253 {
254 char *file_hash;
255
256 if(hash_file(ent->d_name,file_hash) != TNC_RESULT_SUCCESS)
257 {
258 DBG1(DBG_IMC, "Hashing the given file has failed");
259 return TNC_RESULT_FATAL;
260 }
261
262 entry->measurement = chunk_create(file_hash,strlen(file_hash));
263 entry->file_name_len = strlen(ent->d_name);
264 entry->file_name = chunk_create(ent->d_name,strlen(ent->d_name));
265
266 file_measurements->insert_last(file_measurements,entry);
267 }
268 closedir(dir);
269
270 return TNC_RESULT_SUCCESS;
271 }
272
273 static TNC_Result send_message(TNC_ConnectionID connection_id)
274 {
275 pa_tnc_msg_t *msg;
276 pa_tnc_attr_t *attr;
277 imc_state_t *state;
278 imc_attestation_state_t *attestation_state;
279 imc_attestation_handshake_state_t handshake_state;
280 TNC_Result result;
281
282 if (!imc_attestation->get_state(imc_attestation, connection_id, &state))
283 {
284 return TNC_RESULT_FATAL;
285 }
286 attestation_state = (imc_attestation_state_t*)state;
287 handshake_state = attestation_state->get_handshake_state(attestation_state);
288
289 /* Switch on the attribute type IMC has received */
290 switch (handshake_state)
291 {
292 case IMC_ATTESTATION_STATE_REQ_PROTO_CAP:
293 {
294 pts_proto_caps_flag_t flags;
295 if(proto_caps & PTS_PROTO_CAPS_T)
296 {
297 flags = PTS_PROTO_CAPS_T;
298 }
299 if(proto_caps & PTS_PROTO_CAPS_V)
300 {
301 flags |= PTS_PROTO_CAPS_V;
302 }
303 attr = tcg_pts_attr_proto_caps_create(flags, FALSE);
304 break;
305 }
306 case IMC_ATTESTATION_STATE_REQ_MEAS_ALGO:
307 {
308 attr = tcg_pts_attr_meas_algo_create(selected_algorithm, TRUE);
309 break;
310 }
311 case IMC_ATTESTATION_STATE_GET_TPM_INFO:
312 {
313 TSS_RESULT result;
314 chunk_t tpm_version_info;
315
316 result = get_tpm_version_info(&tpm_version_info);
317 if (result != TSS_SUCCESS)
318 {
319 DBG1(DBG_IMC,"Error 0x%x on get_tpm_version_info\n", result);
320 return TNC_RESULT_FATAL;
321 }
322
323 attr = tcg_pts_attr_tpm_version_info_create(tpm_version_info);
324 break;
325 }
326 case IMC_ATTESTATION_STATE_REQ_FILE_MEAS:
327 {
328 measurement_req_entry_t *entry;
329 enumerator_t *enumerator;
330 tcg_pts_attr_file_meas_t *attr_file_meas;
331 u_int16_t meas_len = HASH_SIZE_SHA1;
332
333 if (selected_algorithm & PTS_MEAS_ALGO_SHA384)
334 {
335 meas_len = HASH_SIZE_SHA384;
336 }
337 else if(selected_algorithm & PTS_MEAS_ALGO_SHA256)
338 {
339 meas_len = HASH_SIZE_SHA512;
340 }
341
342 msg = pa_tnc_msg_create();
343
344 /**
345 * Hash the files and add them as attribute
346 */
347 enumerator = enumerator_create_single(file_list, NULL);
348 while (enumerator->enumerate(enumerator, &entry))
349 {
350 char * file_hash;
351
352 attr = tcg_pts_attr_file_meas_create(1,
353 entry->request_id, meas_len);
354 attr->set_noskip_flag(attr, TRUE);
355 attr_file_meas = (tcg_pts_attr_file_meas_t*)attr;
356
357 if(hash_file(entry->path,file_hash) != TNC_RESULT_SUCCESS)
358 {
359 DBG1(DBG_IMC, "Hashing the given file has failed");
360 return TNC_RESULT_FATAL;
361 }
362 attr_file_meas->add_file_meas(attr_file_meas,
363 chunk_create(file_hash,strlen(file_hash)),
364 chunk_create(entry->path,strlen(entry->path)));
365
366 msg->add_attribute(msg, attr);
367 }
368
369 /**
370 * Hash the files in each directory and add them as attribute
371 */
372 enumerator = enumerator_create_single(directory_list, NULL);
373 while (enumerator->enumerate(enumerator, &entry))
374 {
375 enumerator_t *meas_enumerator;
376 file_meas_entry_t *meas_entry;
377 u_int64_t num_of_files = 0 ;
378
379 if(hash_directory(entry->path) != TNC_RESULT_SUCCESS)
380 {
381 DBG1(DBG_IMC, "Hashing the files in a given directory has failed");
382 return TNC_RESULT_FATAL;
383 }
384
385 attr = tcg_pts_attr_file_meas_create(0,
386 entry->request_id, meas_len);
387 attr->set_noskip_flag(attr, TRUE);
388 attr_file_meas = (tcg_pts_attr_file_meas_t*)attr;
389
390 meas_enumerator = enumerator_create_single(file_measurements, NULL);
391 while (meas_enumerator->enumerate(meas_enumerator, &meas_entry))
392 {
393 num_of_files++;
394 attr_file_meas->add_file_meas(attr_file_meas,
395 meas_entry->measurement,
396 meas_entry->file_name);
397 }
398
399 attr_file_meas->set_number_of_files(attr_file_meas,
400 num_of_files);
401 msg->add_attribute(msg, attr);
402 }
403 enumerator->destroy(enumerator);
404 goto end;
405 }
406 case IMC_ATTESTATION_STATE_GET_AIK:
407 /* TODO: Implement AIK retrieve */
408 case IMC_ATTESTATION_STATE_REQ_FUNCT_COMP_EVID:
409 case IMC_ATTESTATION_STATE_GEN_ATTEST_EVID:
410 case IMC_ATTESTATION_STATE_REQ_FILE_METADATA:
411 case IMC_ATTESTATION_STATE_REQ_IML:
412 case IMC_ATTESTATION_STATE_INIT:
413 DBG1(DBG_IMC, "Attestation IMC has nothing to send: \"%s\"", handshake_state);
414 return TNC_RESULT_FATAL;
415 default:
416 DBG1(DBG_IMC, "Attestation IMC is in unknown state: \"%s\"", handshake_state);
417 return TNC_RESULT_FATAL;
418 }
419
420
421 attr->set_noskip_flag(attr, TRUE);
422 msg = pa_tnc_msg_create();
423 msg->add_attribute(msg, attr);
424
425 end:
426 msg->build(msg);
427 result = imc_attestation->send_message(imc_attestation, connection_id,
428 msg->get_encoding(msg));
429 msg->destroy(msg);
430
431 return result;
432 }
433
434 /**
435 * see section 3.7.3 of TCG TNC IF-IMC Specification 1.2
436 */
437 TNC_Result TNC_IMC_BeginHandshake(TNC_IMCID imc_id,
438 TNC_ConnectionID connection_id)
439 {
440 if (!imc_attestation)
441 {
442 DBG1(DBG_IMC, "IMC \"%s\" has not been initialized", imc_name);
443 return TNC_RESULT_NOT_INITIALIZED;
444 }
445 return send_message(connection_id);
446 }
447
448 /**
449 * see section 3.7.4 of TCG TNC IF-IMC Specification 1.2
450 */
451 TNC_Result TNC_IMC_ReceiveMessage(TNC_IMCID imc_id,
452 TNC_ConnectionID connection_id,
453 TNC_BufferReference msg,
454 TNC_UInt32 msg_len,
455 TNC_MessageType msg_type)
456 {
457 pa_tnc_msg_t *pa_tnc_msg;
458 pa_tnc_attr_t *attr;
459 imc_state_t *state;
460 imc_attestation_state_t *attestation_state;
461 enumerator_t *enumerator;
462 TNC_Result result;
463 bool fatal_error = FALSE;
464
465 if (!imc_attestation)
466 {
467 DBG1(DBG_IMC, "IMC \"%s\" has not been initialized", imc_name);
468 return TNC_RESULT_NOT_INITIALIZED;
469 }
470
471 /* parse received PA-TNC message and automatically handle any errors */
472 result = imc_attestation->receive_message(imc_attestation, connection_id,
473 chunk_create(msg, msg_len), msg_type,
474 &pa_tnc_msg);
475
476 /* no parsed PA-TNC attributes available if an error occurred */
477 if (!pa_tnc_msg)
478 {
479 return result;
480 }
481
482 /* analyze PA-TNC attributes */
483 enumerator = pa_tnc_msg->create_attribute_enumerator(pa_tnc_msg);
484 while (enumerator->enumerate(enumerator, &attr))
485 {
486 if (attr->get_vendor_id(attr) == PEN_IETF &&
487 attr->get_type(attr) == IETF_ATTR_PA_TNC_ERROR)
488 {
489 ietf_attr_pa_tnc_error_t *error_attr;
490 pa_tnc_error_code_t error_code;
491 chunk_t msg_info, attr_info;
492 u_int32_t offset;
493
494 error_attr = (ietf_attr_pa_tnc_error_t*)attr;
495 error_code = error_attr->get_error_code(error_attr);
496 msg_info = error_attr->get_msg_info(error_attr);
497
498 DBG1(DBG_IMC, "received PA-TNC error '%N' concerning message %#B",
499 pa_tnc_error_code_names, error_code, &msg_info);
500 switch (error_code)
501 {
502 case PA_ERROR_INVALID_PARAMETER:
503 offset = error_attr->get_offset(error_attr);
504 DBG1(DBG_IMC, " occurred at offset of %u bytes", offset);
505 break;
506 case PA_ERROR_ATTR_TYPE_NOT_SUPPORTED:
507 attr_info = error_attr->get_attr_info(error_attr);
508 DBG1(DBG_IMC, " unsupported attribute %#B", &attr_info);
509 break;
510 default:
511 break;
512 }
513 fatal_error = TRUE;
514 }
515 else if (attr->get_vendor_id(attr) == PEN_TCG)
516 {
517 /**
518 * Handle TCG PTS attributes
519 */
520
521 /* get current IMC state */
522 if (!imc_attestation->get_state(imc_attestation, connection_id, &state))
523 {
524 return TNC_RESULT_FATAL;
525 }
526 attestation_state = (imc_attestation_state_t*)state;
527
528 switch(attr->get_type(attr))
529 {
530 case TCG_PTS_REQ_PROTO_CAPS:
531 {
532 tcg_pts_attr_proto_caps_t *attr_req_proto_caps;
533
534 attr_req_proto_caps = (tcg_pts_attr_proto_caps_t*)attr;
535 proto_caps = attr_req_proto_caps->get_flags(attr_req_proto_caps);
536
537 attestation_state->set_handshake_state(attestation_state,
538 IMC_ATTESTATION_STATE_REQ_PROTO_CAP);
539 break;
540 }
541 case TCG_PTS_MEAS_ALGO:
542 {
543 tcg_pts_attr_meas_algo_t *attr_meas_algo;
544
545 attr_meas_algo = (tcg_pts_attr_meas_algo_t*)attr;
546 selected_algorithm = attr_meas_algo->get_algorithms(attr_meas_algo);
547
548 if ((supported_algorithms & PTS_MEAS_ALGO_SHA384) &&
549 (selected_algorithm & PTS_MEAS_ALGO_SHA384))
550 {
551 selected_algorithm = PTS_MEAS_ALGO_SHA384;
552 }
553 else if (selected_algorithm & PTS_MEAS_ALGO_SHA256)
554 {
555 selected_algorithm = PTS_MEAS_ALGO_SHA256;
556 }
557 else if (selected_algorithm & PTS_MEAS_ALGO_SHA1)
558 {
559 selected_algorithm = PTS_MEAS_ALGO_SHA1;
560 }
561 else
562 {
563 /* TODO generate an error message */
564 selected_algorithm = PTS_MEAS_ALGO_SHA256;
565 }
566 DBG2(DBG_IMC, "selected PTS measurement algorithm is %N",
567 hash_algorithm_names,
568 pts_meas_to_hash_algorithm(selected_algorithm));
569
570 attestation_state->set_handshake_state(attestation_state,
571 IMC_ATTESTATION_STATE_REQ_MEAS_ALGO);
572 break;
573 }
574
575 case TCG_PTS_GET_TPM_VERSION_INFO:
576 {
577 attestation_state->set_handshake_state(attestation_state,
578 IMC_ATTESTATION_STATE_GET_TPM_INFO);
579 break;
580 }
581 case TCG_PTS_GET_AIK:
582 {
583 attestation_state->set_handshake_state(attestation_state,
584 IMC_ATTESTATION_STATE_GET_AIK);
585 break;
586 }
587
588 /* PTS-based Attestation Evidence */
589 case TCG_PTS_REQ_FUNCT_COMP_EVID:
590 break;
591 case TCG_PTS_GEN_ATTEST_EVID:
592 break;
593 case TCG_PTS_REQ_FILE_MEAS:
594 {
595 tcg_pts_attr_req_file_meas_t *attr_req_file_meas;
596 measurement_req_entry_t *entry;
597 u_int32_t delimiter;
598
599 attr_req_file_meas = (tcg_pts_attr_req_file_meas_t*)attr;
600 file_list = linked_list_create();
601 directory_list = linked_list_create();
602 delimiter = attr_req_file_meas->get_delimiter(attr_req_file_meas);
603 entry = malloc_thing(measurement_req_entry_t);
604 entry->request_id = attr_req_file_meas->get_request_id(attr_req_file_meas);
605 entry->path = attr_req_file_meas->get_file_path(attr_req_file_meas).ptr;
606
607 (attr_req_file_meas->get_directory_flag(attr_req_file_meas)) ?
608 directory_list->insert_last(directory_list, entry) :
609 file_list->insert_last(file_list, entry);
610
611 attestation_state->set_handshake_state(attestation_state,
612 IMC_ATTESTATION_STATE_REQ_FILE_MEAS);
613 break;
614 }
615
616 /* TODO: Not implemented yet */
617 case TCG_PTS_DH_NONCE_PARAMS_REQ:
618 case TCG_PTS_DH_NONCE_FINISH:
619 case TCG_PTS_REQ_FILE_META:
620 case TCG_PTS_REQ_INTEG_MEAS_LOG:
621 /* Attributes using XML */
622 case TCG_PTS_REQ_TEMPL_REF_MANI_SET_META:
623 case TCG_PTS_UPDATE_TEMPL_REF_MANI:
624 /* On Windows only*/
625 case TCG_PTS_REQ_REGISTRY_VALUE:
626 /* Received on IMV side only*/
627 case TCG_PTS_PROTO_CAPS:
628 case TCG_PTS_DH_NONCE_PARAMS_RESP:
629 case TCG_PTS_MEAS_ALGO_SELECTION:
630 case TCG_PTS_TPM_VERSION_INFO:
631 case TCG_PTS_TEMPL_REF_MANI_SET_META:
632 case TCG_PTS_AIK:
633 case TCG_PTS_SIMPLE_COMP_EVID:
634 case TCG_PTS_SIMPLE_EVID_FINAL:
635 case TCG_PTS_VERIFICATION_RESULT:
636 case TCG_PTS_INTEG_REPORT:
637 case TCG_PTS_UNIX_FILE_META:
638 case TCG_PTS_FILE_MEAS:
639 case TCG_PTS_INTEG_MEAS_LOG:
640 default:
641 DBG1(DBG_IMC, "received unsupported attribute '%N'",
642 tcg_attr_names, attr->get_type(attr));
643 break;
644 }
645
646
647 }
648 }
649 enumerator->destroy(enumerator);
650 pa_tnc_msg->destroy(pa_tnc_msg);
651
652 /* if no error occurred then always return the same response */
653 return fatal_error ? TNC_RESULT_FATAL : send_message(connection_id);
654 }
655
656 /**
657 * see section 3.7.5 of TCG TNC IF-IMC Specification 1.2
658 */
659 TNC_Result TNC_IMC_BatchEnding(TNC_IMCID imc_id,
660 TNC_ConnectionID connection_id)
661 {
662 if (!imc_attestation)
663 {
664 DBG1(DBG_IMC, "IMC \"%s\" has not been initialized", imc_name);
665 return TNC_RESULT_NOT_INITIALIZED;
666 }
667 return TNC_RESULT_SUCCESS;
668 }
669
670 /**
671 * see section 3.7.6 of TCG TNC IF-IMC Specification 1.2
672 */
673 TNC_Result TNC_IMC_Terminate(TNC_IMCID imc_id)
674 {
675 if (!imc_attestation)
676 {
677 DBG1(DBG_IMC, "IMC \"%s\" has not been initialized", imc_name);
678 return TNC_RESULT_NOT_INITIALIZED;
679 }
680 imc_attestation->destroy(imc_attestation);
681 imc_attestation = NULL;
682
683 return TNC_RESULT_SUCCESS;
684 }
685
686 /**
687 * see section 4.2.8.1 of TCG TNC IF-IMC Specification 1.2
688 */
689 TNC_Result TNC_IMC_ProvideBindFunction(TNC_IMCID imc_id,
690 TNC_TNCC_BindFunctionPointer bind_function)
691 {
692 if (!imc_attestation)
693 {
694 DBG1(DBG_IMC, "IMC \"%s\" has not been initialized", imc_name);
695 return TNC_RESULT_NOT_INITIALIZED;
696 }
697 return imc_attestation->bind_functions(imc_attestation, bind_function);
698 }