* \brief TCG TNC IF-IMC v1.2 R8
* @author Seiji Munetoh <munetoh@users.sourceforge.jp>
* @date 2010-05-07
- * cleanup 2011-07-06 SM
+ * cleanup 2011-08-22 SM
*
* http://www.trustedcomputinggroup.org/resources/tnc_ifimc_specification
* http://www.trustedcomputinggroup.org/files/resource_files/8CB977E1-1D09-3519-AD48484530EF6639/TNC_IFIMC_v1_2_r8.pdf
static OPENPTS_CONFIG *conf = NULL;
static OPENPTS_CONTEXT *ctx = NULL;
-// static char *config_filename = NULL;
-
int verbose = 0;
// int verbose = DEBUG_IFM_FLAG;
// int verbose = DEBUG_FLAG | DEBUG_IFM_FLAG;
-#if 1
+
static TNC_Result sendMessage(
/*in*/ TNC_IMCID imcID,
/*in*/ TNC_ConnectionID connectionID,
/*in*/ TNC_BufferReference message,
/*in*/ TNC_UInt32 messageLength,
/*in*/ TNC_MessageType messageType);
-#endif
+
/* List of receive message types */
static TNC_MessageType messageTypes[] = {
/* initialize PTS Collector */
conf = newPtsConfig();
if (conf == NULL) {
- ERROR("no memory\n");
+ ERROR("Can not allocate OPENPTS_CONFIG\n");
rc = TNC_RESULT_FATAL;
goto error;
}
ctx = newPtsContext(conf);
if (ctx == NULL) {
+ ERROR("Can not allocate OPENPTS_CONTEXT\n");
rc = TNC_RESULT_FATAL;
goto error;
}
rc = readOpenptsUuidFile(conf->newrm_uuid);
if (rc != PTS_SUCCESS) {
DEBUG("conf->str_newrm_uuid : missing (file:%s)\n", conf->newrm_uuid->filename);
- // goto free;
+ // May not exist
} else {
DEBUG("conf->str_newrm_uuid : %s (for next boot)\n", conf->newrm_uuid->str);
}
error:
if (ctx != NULL) freePtsContext(ctx);
ctx = NULL;
+ if (conf != NULL) freePtsConfig(conf);
+ conf = NULL;
return rc;
}
/*in*/ TNC_IMCID imcID,
/*in*/ TNC_ConnectionID connectionID,
/*in*/ TNC_ConnectionState newState) {
- DEBUG("TNC_IMC_Initialize\n");
+ DEBUG("TNC_IMC_NotifyConnectionChange\n");
/* check internal status */
if (!initialized)
/* connection ID */
cid = connectionID;
- /* just send hello to verifier */
-
- // DEBUG_IFM("C imcID=%d, connectionID=%d - TNC_IMC_BeginHandshake\n", (int)imcID, (int)connectionID);
-
-
+ /* just send OPENPTS_CAPABILITIES to verifier */
msg = getPtsTlvMessage(ctx, OPENPTS_CAPABILITIES, &len);
DEBUG_IFM("[C->V] OPENPTS_CAPABILITIES[%d]\n", len);
return TNC_RESULT_FATAL;
}
-
-
-
-
-#if 0
- if (messageType == TNCMESSAGENUM(VENDORID, 1)) {
- /* capability from client */
- read_tlv = (PTS_IF_M_Attribute *) messageBuffer;
- if (read_tlv->type != OPENPTS_CAPABILITIES) {
- ERROR("bad msg\n");
- return TNC_RESULT_FATAL;
- }
-
- /* send PTS_CAPABILITIES */
- char* msg = getPtsTlvMessage(ctx, OPENPTS_CAPABILITIES, &len);
- rc = sendMessage(imcID,
- connectionID,
- (TNC_BufferReference)msg,
- len,
- TNCMESSAGENUM(VENDORID, 2));
- free(msg);
- DEBUG_IFM("Collector send PTS_CAPABILITIES len=%d\n", len);
- return rc;
- } else if (messageType == TNCMESSAGENUM(VENDORID, 3)) {
- /* DH_NONCE_PARAMETERS_REQUEST from client */
- read_tlv = (PTS_IF_M_Attribute *) messageBuffer;
- if (read_tlv->type != DH_NONCE_PARAMETERS_REQUEST) {
- ERROR("bad msg\n");
- return TNC_RESULT_FATAL;
- }
-
- /* send DH_NONCE_PARAMETORS_RESPONSE */
- char* msg = getPtsTlvMessage(ctx, DH_NONCE_PARAMETORS_RESPONSE, &len);
- rc = sendMessage(imcID,
- connectionID,
- (TNC_BufferReference)msg,
- len,
- TNCMESSAGENUM(VENDORID, 4));
- free(msg);
- DEBUG_IFM("Collector send PTS_CAPABILITIES len=%d\n", len);
- return rc;
- } else if (messageType == TNCMESSAGENUM(VENDORID, 5)) {
- /* DH_NONCE_FINISH from client */
- read_tlv = (PTS_IF_M_Attribute *) messageBuffer;
- if (read_tlv->type != DH_NONCE_FINISH) {
- ERROR("bad msg\n");
- return TNC_RESULT_FATAL;
- }
- /* ack to keep TNC handshake */
- // TODO(munetoh) otherwise TNC HS was terminated.
- char* msg = "ack";
- rc = sendMessage(imcID,
- connectionID,
- (TNC_BufferReference)msg,
- strlen(msg),
- TNCMESSAGENUM(VENDORID, 6));
- DEBUG_IFM("Collector send PTS_CAPABILITIES len=%d\n", len);
- return rc;
- } else if (messageType == TNCMESSAGENUM(VENDORID, 7)) {
- /* REQUEST_TEMPLATE_RIMM_SET_METADATA from client */
- read_tlv = (PTS_IF_M_Attribute *) messageBuffer;
- if (read_tlv->type != REQUEST_RIMM_SET) {
- ERROR("bad msg\n");
- return TNC_RESULT_FATAL;
- }
-
- /* send DH_NONCE_PARAMETORS_RESPONSE */
- char* msg = getPtsTlvMessage(ctx, RIMM_SET, &len);
- rc = sendMessage(imcID,
- connectionID,
- (TNC_BufferReference)msg,
- len,
- TNCMESSAGENUM(VENDORID, 8));
- free(msg);
- DEBUG_IFM("Collector send TEMPLATE_RIMM_SET_METADATA len=%d\n", len);
- return rc;
- } else if (messageType == TNCMESSAGENUM(VENDORID, 9)) {
- /* REQUEST_TEMPLATE_RIMM_SET_METADATA from client */
- read_tlv = (PTS_IF_M_Attribute *) messageBuffer;
- if (read_tlv->type != REQUEST_INTEGRITY_REPORT) {
- ERROR("bad msg\n");
- return TNC_RESULT_FATAL;
- }
-
- /* send DH_NONCE_PARAMETORS_RESPONSE */
- char* msg = getPtsTlvMessage(ctx, INTEGRITY_REPORT, &len);
- rc = sendMessage(imcID,
- connectionID,
- (TNC_BufferReference)msg,
- len,
- TNCMESSAGENUM(VENDORID, 10));
- // free(msg);
- DEBUG_IFM("Collector send INTEGRITY_REPORT len=%d\n", len);
- return rc;
- } else {
- ERROR("bad msg from verifier\n");
- return TNC_RESULT_FATAL;
- }
-#endif
-
return TNC_RESULT_SUCCESS;
}
/* connection ID */
// TODO(munetoh)
- /* PTS */
+ /* Free PTS contexts */
freePtsContext(ctx);
freePtsConfig(conf);
return rc;
}
-
-
-
-
-
* \brief TCG TNC IF-IMV v1.2 R8
* @author Seiji Munetoh <munetoh@users.sourceforge.jp>
* @date 2010-05-07
- * cleanup 2011-07-06 SM
+ * cleanup 2011-08-22 SM
*
* http://www.trustedcomputinggroup.org/resources/tnc_ifimv_specification
* http://www.trustedcomputinggroup.org/files/static_page_files/646808C3-1D09-3519-AD2E60765779A42A/TNC_IFIMV_v1_2_r8.pdf
#include <string.h>
#include <tncifimv.h>
-// #include <libtnc.h>
#include <openpts.h>
-
// ifm.c
BYTE* getPtsTlvMessage(OPENPTS_CONTEXT *ctx, int type, int *len);
-
/* global */
-
static TNC_IMVID imv_id = -1;
static int initialized = 0;
// int verbose = DEBUG_IFM_FLAG;
// int verbose = DEBUG_FLAG | DEBUG_IFM_FLAG;
-#if 1
static TNC_Result sendMessage(
/*in*/ TNC_IMVID imvID,
/*in*/ TNC_ConnectionID connectionID,
/*in*/ TNC_BufferReference message,
/*in*/ TNC_UInt32 messageLength,
/*in*/ TNC_MessageType messageType);
-#endif
+
static TNC_Result provideRecommendation(
/*in*/ TNC_IMVID imvID,
/*in*/ TNC_ConnectionID connectionID,
/*in*/ TNC_IMV_Action_Recommendation recommendation,
/*in*/ TNC_IMV_Evaluation_Result evaluation);
+
static TNC_Result setAttribute(
/*in*/ TNC_IMVID imvID,
/*in*/ TNC_ConnectionID connectionID,
*pOutActualVersion = TNC_IFIMV_VERSION_1;
imv_id = imvID;
-
/* initialize PTS */
conf = newPtsConfig();
if (conf == NULL) {
- ERROR("no memory\n");
+ ERROR("Can not allocate OPENPTS_CONFIG\n");
rc = TNC_RESULT_FATAL;
goto error;
}
ctx = newPtsContext(conf);
if (ctx == NULL) {
- ERROR("no memory\n");
+ ERROR("Can not allocate OPENPTS_CONTEXT\n");
rc = TNC_RESULT_FATAL;
goto error;
}
DEBUG_IFM("conf->config_dir : %s\n",
conf->config_dir);
-
- // IIDB -- TODO
+ // TODO IIDB
initialized++;
error:
if (ctx != NULL) freePtsContext(ctx);
ctx = NULL;
- // TODO conf = NULL;
+ if (conf != NULL) freePtsConfig(conf);
+ conf = NULL;
return rc;
}
+
/**
* TNC_IMV_NotifyConnectionChange (OPTIONAL)
*/
return TNC_RESULT_FATAL;
}
-
DEBUG_IFM("[C->V] vid=%X, type=%08X, length=%d\n", vid, type, length);
/* message type */
/* Capability */
cap = (OPENPTS_IF_M_Capability *) value;
-
rc = verifierHandleCapability(ctx, conf->config_dir, NULL, cap);
if (rc == PTS_NOT_INITIALIZED) {
return TNC_RESULT_FATAL;
}
-#if 0
- /* capability from client */
- read_tlv = (PTS_IF_M_Attribute *) messageBuffer;
- if (read_tlv->type != OPENPTS_CAPABILITIES) {
- ERROR("bad msg\n");
- return TNC_RESULT_FATAL;
- }
-
- /* send DH-nonce param req */
- char* msg = getPtsTlvMessage(ctx, DH_NONCE_PARAMETERS_REQUEST, &len);
- rc = sendMessage(imvID,
- connectionID,
- (TNC_BufferReference)msg,
- len,
- TNCMESSAGENUM(VENDORID, 3));
- free(msg);
- DEBUG_IFM("Verifier send DH_NONCE_PARAMETERS_REQUEST len=%d\n", len);
- return rc;
- } else if (messageType == TNCMESSAGENUM(VENDORID, 4)) {
- /* DH-nonce param res from client */
- read_tlv = (PTS_IF_M_Attribute *) messageBuffer;
- if (read_tlv->type != DH_NONCE_PARAMETORS_RESPONSE) {
- ERROR("bad msg\n");
- return TNC_RESULT_FATAL;
- }
-
- /* send DH-nonce param done */
- char* msg = getPtsTlvMessage(ctx, DH_NONCE_FINISH, &len);
- rc = sendMessage(imvID,
- connectionID,
- (TNC_BufferReference)msg,
- len,
- TNCMESSAGENUM(VENDORID, 5));
- free(msg);
- DEBUG_IFM("Verifier send DH_NONCE_FINISH len=%d\n", len);
- return rc;
- } else if (messageType == TNCMESSAGENUM(VENDORID, 6)) {
- /* send template RIMM req */
- char* msg = getPtsTlvMessage(ctx, REQUEST_RIMM_SET, &len);
- rc = sendMessage(imvID,
- connectionID,
- (TNC_BufferReference)msg,
- len,
- TNCMESSAGENUM(VENDORID, 7));
- free(msg);
- DEBUG_IFM("Verifier send REQUEST_TEMPLATE_RIMM_SET_METADATA len=%d\n", len);
- return rc;
- } else if (messageType == TNCMESSAGENUM(VENDORID, 8)) {
- /* RIMM from client */
- read_tlv = (PTS_IF_M_Attribute *) messageBuffer;
- if (read_tlv->type != RIMM_SET) {
- ERROR("bad msg\n");
- return TNC_RESULT_FATAL;
- }
-
- /* Save RIMM to where? */
- // TODO(munetoh)
-
- /* send IR req */
- char* msg = getPtsTlvMessage(ctx, REQUEST_INTEGRITY_REPORT, &len);
- rc = sendMessage(imvID,
- connectionID,
- (TNC_BufferReference)msg,
- len,
- TNCMESSAGENUM(VENDORID, 9));
- free(msg);
- DEBUG_IFM("Verifier send REQUEST_INTEGRITY_REPORT len=%d\n", len);
- return rc;
- } else if (messageType == TNCMESSAGENUM(VENDORID, 10)) {
- /* IR from client */
- read_tlv = (PTS_IF_M_Attribute *) messageBuffer;
- if (read_tlv->type != INTEGRITY_REPORT) {
- ERROR("bad msg\n");
- return TNC_RESULT_FATAL;
- }
-
- /* Save IR to where? */
- // TODO(munetoh)
-
- /* Validate IR */
- // TODO(munetoh)
-
- /* Recommendation */
- setAttribute(imvID,
- connectionID,
- TNC_ATTRIBUTEID_REASON_LANGUAGE,
- 2,
- (TNC_BufferReference)"en");
-
- setAttribute(imvID,
- connectionID,
- TNC_ATTRIBUTEID_REASON_STRING,
- 7,
- (TNC_BufferReference)"testing"); // TODO(munetoh)
-
- rc = provideRecommendation(
- imvID,
- connectionID,
- TNC_IMV_ACTION_RECOMMENDATION_ISOLATE,
- TNC_IMV_EVALUATION_RESULT_NONCOMPLIANT_MAJOR);
- return rc;
-#endif
-
-
return TNC_RESULT_SUCCESS;
}
+
/**
* from IMV spec.
*
evaluation);
}
+
/**
* from IMV spec.
*
return TNC_RESULT_SUCCESS;
}
+
/**
* TNC_IMV_Terminate (OPTIONAL)
*/
return (*reportMessageTypesPtr)(imvID, supportedTypes, typeCount);
}
-#if 1
+
/**
* Call TNC_TNCS_SendMessage (MANDATORY) in the TNCS
*/
messageLength,
messageType);
}
-#endif
+
#if 0
// imv.c:343: error: ‘requestHandshakeRetry’ defined but not used
}
#endif
+
/**
* Call TNC_TNCS_ProvideRecommendation (MANDATORY) in the TNCS
*/
evaluation);
}
+
#if 0
// imv.c:381: error: ‘getAttribute’ defined but not used
/**
}
-
-
/* Platform-Specific IMV Functions */
/**
return TNC_RESULT_FATAL;
}
}
-