#
#EXTRA_DIST = LICENSE
-SUBDIRS = m4 po src doc models
+SUBDIRS = m4 po include src doc models man
#
# Symlink to openpts-version dir
man/Makefile \
man/man1/Makefile \
man/man3/Makefile \
+ man/man5/Makefile \
man/man8/Makefile)
AC_OUTPUT
openpts.version=@VERSION@
#
+# Logging&Debug
+# logging.file=./openpts.log
+logging.location=syslog
+debug.mode=0x0
+
+#
# Platform metadata (SMBIOS) - TBD
#
# set manually
#define INCLUDE_OPENPTS_LOG_H_
#include <syslog.h>
-#include <assert.h>
#ifdef NLS
#undef NLS
extern int debugBits;
extern int verbosity;
+/* Macro for console out (stdout) */
+
+#define OUTPUT(fmt, ...) fprintf(stdout, fmt, ##__VA_ARGS__)
+
+/* Macro for console out (stderr) */
+
+#define ERROR(fmt, ...) fprintf(stderr, fmt, ##__VA_ARGS__)
+
+/* Macro for console out (stderr) */
+
+#define VERBOSE(v, fmt, ...) if (verbosity >= v) fprintf(stderr, fmt, ##__VA_ARGS__)
+/* helpers */
+#define setVerbosity(x) (verbosity = (x))
+#define incVerbosity() (verbosity++)
+#define getVerbosity() (verbosity)
+
+/* Macro for logging out (syslog/file/console) */
+
#define OPENPTS_LOG_UNDEFINED 0
#define OPENPTS_LOG_SYSLOG 1
#define OPENPTS_LOG_CONSOLE 2
#define OPENPTS_LOG_FILE 3
#define OPENPTS_LOG_NULL 4
+/* ERROR/INFO/TODO */
+#define LOG_TODO 0x0006 // = LOG_INFO
+#define LOG(type, fmt, ...) writeLog(type, "%s:%d " fmt, __FILE__, __LINE__, ##__VA_ARGS__)
+
+/* DEBUG */
#define DEBUG_FLAG 0x01
#define DEBUG_FSM_FLAG 0x02
#define DEBUG_XML_FLAG 0x04
#define DEBUG_TPM_FLAG 0x20
#define DEBUG_CAL_FLAG 0x40
-#define isDebugFlagSet(x) (debugBits & (x))
-#define isAnyDebugFlagSet(x) (debugBits != 0)
-#define setDebugFlags(x) (debugBits = (x))
-#define getDebugFlags() (debugBits)
-#define addDebugFlags(x) (debugBits |= (x))
-
-#define setVerbosity(x) (verbosity = (x))
-#define incVerbosity() (verbosity++)
-#define getVerbosity() (verbosity)
-
-#define OUTPUT(fmt, ...) fprintf(stdout, fmt, ##__VA_ARGS__)
-#define VERBOSE(v, fmt, ...) if (verbosity >= v) fprintf(stderr, fmt, ##__VA_ARGS__)
-
-#define ERROR(fmt, ...) writeLog(LOG_ERR, "%s:%d " fmt, __FILE__, __LINE__, ##__VA_ARGS__)
-#define TODO(fmt, ...) writeLog(LOG_INFO, "%s:%d TODO " fmt, __FILE__, __LINE__, ##__VA_ARGS__)
-#define INFO(fmt, ...) writeLog(LOG_INFO, fmt, ##__VA_ARGS__)
-
#define DEBUG_WITH_FLAG(debug_level, fmt, ...) if (debugBits & debug_level) \
writeLog(LOG_DEBUG, "%s:%4d " fmt, __FILE__, __LINE__, ##__VA_ARGS__)
#define DEBUG_TPM(fmt, ...) DEBUG_WITH_FLAG(DEBUG_TPM_FLAG, fmt, ##__VA_ARGS__)
#define DEBUG_CAL(fmt, ...) DEBUG_WITH_FLAG(DEBUG_CAL_FLAG, fmt, ##__VA_ARGS__)
+/* helpers */
+#define isDebugFlagSet(x) (debugBits & (x))
+#define isAnyDebugFlagSet(x) (debugBits != 0)
+#define setDebugFlags(x) (debugBits = (x))
+#define getDebugFlags() (debugBits)
+#define addDebugFlags(x) (debugBits |= (x))
+
+
+
+
void writeLog(int priority, const char *format, ...);
void initCatalog(void);
void setLogLocation(int ll, char *filename);
# http://www.opensource.org/licenses/cpl1.0.php.
#
-SUBDIRS = man1 man3 man8
+SUBDIRS = man1 man3 man5 man8
# http://www.opensource.org/licenses/cpl1.0.php.
#
-man8_MANS = openpts.8
-
-# tpm_clear.8 \
-# tpm_createek.8 \
-# tpm_getpubek.8 \
-# tpm_restrictpubek.8 \
-# tpm_selftest.8 \
-# tpm_setactive.8 \
-# tpm_setclearable.8 \
-# tpm_setenable.8 \
-# tpm_setownable.8 \
-# tpm_setpresence.8 \
-# tpm_takeownership.8
-#
-#if TSS_LIB_IS_12
-#man8_MANS+=tpm_revokeek.8 tpm_setoperatorauth.8 tpm_resetdalock.8
-#endif
+man8_MANS = openpts.8 \
+ ptsc.8 \
+ iml2text.8
EXTRA_DIST = $(man8_MANS)
+.\" Copyright (C) 2011 International Business Machines Corporation
+.\"
+.de Sh \" Subsection
+.br
+.ie \\n(.$>=3 .ne \\$3
+.el .ne 3
+.IP "\\$1" \\$2
+..
+.TH "openpts" 8 "2012-01-04" "Platform Trust Services(PTS)"
+.ce 1
+Platform Trust Services(PTS) - openpts
+.SH NAME
+openpts \- PTS verifier command
+.SH "SYNOPSIS"
+.ad l
+.hy 0
+.B openpts
+.RB [ OPTION ]
+.RB <target>
+
+.SH "DESCRIPTION"
+.PP
+\fBopenpts\fR is a verifier side application of Platform Trust Services(PTS).
+
+
+.SH "COMMANDS"
+
+.TP
+\fB-i\fR
+Enroll a target node and acquire [overwrite (-f)] the reference measurement.
+
+.TP
+\fB-v\fR
+Verify target (collector) integrity against known measurement.
+
+.TP
+\fB-r\fR
+Remove the target from the set of known reference measurements.
+
+.TP
+\fB\-h\fR
+Display command usage info.
+
+.TP
+\fB-D\fR
+Display the configuration (target/ALL)
+
+.SH "OPTIONS"
+
+.TP
+\fB-u\fR
+Accept a measurement update during attestation, if there are any available.
+
+
+.TP
+\fB-l username\fR
+ssh username [ssh default]
+
+.TP
+\fB-p port\fR
+ssh port number [ssh default]
+
+.TP
+\fB-c configfile\fR
+Set configuration file [~/.openpts/openpts.conf]
+
+.TP
+\fB-V\fR
+Verbose mode. Multiple -V options increase the verbosity.
+
+
+.SH "SEE ALSO"
+.PP
+\fBptsc\fR(8)
+.SH "AUTHOR"
+Seiji Munetoh
+.SH "REPORTING BUGS"
+Report bugs to <openpts-users@lists.sourceforge.jp>
+
#base64.c log.c
-ptsevt_CFLAGS = $(AM_CFLAGS)
-ptsevt_LDFLAGS = $(AM_LDFLAGS)
-ptsevt_SOURCES = ptsevt.c
+# AIX
+#ptsevt_CFLAGS = $(AM_CFLAGS)
+#ptsevt_LDFLAGS = $(AM_LDFLAGS)
+#ptsevt_SOURCES = ptsevt.c
-ptsevtd_CFLAGS = $(AM_CFLAGS)
-ptsevtd_LDFLAGS = $(AM_LDFLAGS) -lrt
-ptsevtd_SOURCES = ptsevtd.c
+#ptsevtd_CFLAGS = $(AM_CFLAGS)
+#ptsevtd_LDFLAGS = $(AM_LDFLAGS) -lrt
+#ptsevtd_SOURCES = ptsevtd.c
if HAVE_LIBUUID
DEBUG_FSM("resetPCR(%d)\n", pcr_index);
rc = resetTpmPcr(&ctx->tpm, pcr_index);
if (rc != PTS_SUCCESS) {
- ERROR("reset PCR[%d] was failed, check the model");
+ LOG(LOG_ERR, "reset PCR[%d] was failed, check the model");
return PTS_INTERNAL_ERROR;
}
event = eventWrapper->event;
if (event == NULL) {
- ERROR("null input\n");
+ LOG(LOG_ERR, "null input\n");
return PTS_FATAL;
}
/* event */
if (eventWrapper == NULL) {
- ERROR("addBIOSSpecificProperty- eventWrapper is NULL\n");
+ LOG(LOG_ERR, "addBIOSSpecificProperty- eventWrapper is NULL\n");
return PTS_INTERNAL_ERROR; // -1
}
event = eventWrapper->event;
if (event->eventType != 0x06) {
- ERROR("addBIOSSpecificProperty - bad event type 0x%x !- 0x06\n", event->eventType);
+ LOG(LOG_ERR, "addBIOSSpecificProperty - bad event type 0x%x !- 0x06\n", event->eventType);
return PTS_INTERNAL_ERROR; // -1
}
/* check EventData */
if (event->ulEventLength == 0) {
- ERROR("addBIOSSpecificProperty - Bad IML, ulEventLength is 0.");
+ LOG(LOG_ERR, "addBIOSSpecificProperty - Bad IML, ulEventLength is 0.");
return PTS_FATAL;
}
if (&event->rgbEvent[0] == NULL) {
- ERROR("addBIOSSpecificProperty - Bad IML, rgbEvent is NULL.");
+ LOG(LOG_ERR, "addBIOSSpecificProperty - Bad IML, rgbEvent is NULL.");
return PTS_FATAL;
}
ctx->conf->smbios_length,
&buf_len);
if (buf == NULL) {
- ERROR("encodeBase64 fail");
+ LOG(LOG_ERR, "encodeBase64 fail");
return PTS_FATAL;
}
if (buf_len > BUF_SIZE) {
- ERROR("SMBIOS size = %d\n", buf_len); // Thinkpad X200 => 3324
+ LOG(LOG_ERR, "SMBIOS size = %d\n", buf_len); // Thinkpad X200 => 3324
setProperty(ctx, "bios.smbios", "too big");
} else {
setProperty(ctx, "bios.smbios", buf);
TSS_PCR_EVENT *event;
if (eventWrapper == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_INTERNAL_ERROR; // -1;
}
event = eventWrapper->event;
if (event == NULL) {
- ERROR("event is NULL\n");
+ LOG(LOG_ERR, "event is NULL\n");
return PTS_INTERNAL_ERROR; // -1;
}
// DEBUG("validateEltoritoBootImage - NA\n");
if (eventWrapper == NULL) {
- ERROR("eventWrapper is NULL\n");
+ LOG(LOG_ERR, "eventWrapper is NULL\n");
return PTS_INTERNAL_ERROR; // -1;
}
event = eventWrapper->event;
if (event == NULL) {
- ERROR("event is NULL\n");
+ LOG(LOG_ERR, "event is NULL\n");
return PTS_INTERNAL_ERROR; // -1;
}
/* check */
if (eventWrapper == NULL) {
- ERROR("eventWrapper is NULL\n");
+ LOG(LOG_ERR, "eventWrapper is NULL\n");
return PTS_INTERNAL_ERROR; // -1;
}
event = eventWrapper->event;
if (event == NULL) {
- ERROR("event is NULL\n");
+ LOG(LOG_ERR, "event is NULL\n");
return PTS_INTERNAL_ERROR; // -1;
}
SHA1_DIGEST_SIZE,
&buf_len);
if (buf == NULL) {
- ERROR("encodeBase64 fail");
+ LOG(LOG_ERR, "encodeBase64 fail");
return PTS_INTERNAL_ERROR;
}
setProperty(ctx, "kernel.initrd.digest", buf);
/* input check */
if (eventWrapper == NULL) {
- ERROR("eventWrapper is NULL\n");
+ LOG(LOG_ERR, "eventWrapper is NULL\n");
return PTS_FATAL;
}
event = eventWrapper->event;
if (event == NULL) {
- ERROR("event is NULL\n");
+ LOG(LOG_ERR, "event is NULL\n");
return PTS_FATAL;
}
if (event->rgbEvent == NULL) {
- ERROR("event->rgbEvent is NULL, BAD IML?\n");
+ LOG(LOG_ERR, "event->rgbEvent is NULL, BAD IML?\n");
return PTS_FATAL;
}
if (event->ulEventLength == 0) {
- ERROR("event->ulEventLength is 0, BAD IML?\n");
+ LOG(LOG_ERR, "event->ulEventLength is 0, BAD IML?\n");
return PTS_FATAL;
}
* deprecated
*/
int validateKernelCmdline(OPENPTS_CONTEXT *ctx, OPENPTS_PCR_EVENT_WRAPPER *eventWrapper) {
- TODO("validateKernelCmdline - NA\n");
+ LOG(LOG_TODO, "validateKernelCmdline - NA\n");
setProperty(ctx, "kernel.commandline", "TBD");
return PTS_SUCCESS;
}
/* check */
if (eventWrapper == NULL) {
- ERROR("null input\n");
+ LOG(LOG_ERR, "null input\n");
return PTS_INTERNAL_ERROR; // -1;
}
event = eventWrapper->event;
if (event == NULL) {
- ERROR("event is NULL\n");
+ LOG(LOG_ERR, "event is NULL\n");
return PTS_INTERNAL_ERROR; // -1;
}
if (isDebugFlagSet(DEBUG_FLAG)) {
int j;
BYTE pcr[SHA1_DIGEST_SIZE];
- TODO("validateImaAggregate - "
+ LOG(LOG_TODO, "validateImaAggregate - "
"Wrong IMA aggregete - check FSM, "
"maybe it should use validateOldImaAggregate()\n");
OUTPUT("PCR = ");
/* check */
if (eventWrapper == NULL) {
- ERROR("eventWrapper is NULL\n");
+ LOG(LOG_ERR, "eventWrapper is NULL\n");
return PTS_INTERNAL_ERROR; // -1;
}
event = eventWrapper->event;
if (event == NULL) {
- ERROR("event is NULL\n");
+ LOG(LOG_ERR, "event is NULL\n");
return PTS_INTERNAL_ERROR; // -1;
}
SHA1_DIGEST_SIZE,
&buf_len);
if (buf == NULL) {
- ERROR("encodeBase64 fail");
+ LOG(LOG_ERR, "encodeBase64 fail");
return PTS_INTERNAL_ERROR;
}
updateImaProperty(ctx, md->name, buf, "valid");
SHA1_DIGEST_SIZE,
&buf_len);
if (buf == NULL) {
- ERROR("encodeBase64 fail");
+ LOG(LOG_ERR, "encodeBase64 fail");
return PTS_INTERNAL_ERROR;
}
updateImaProperty(ctx, name, buf, "unknown"); // action.c
return PTS_SUCCESS;
} else {
// ERROR
- ERROR("validateImaMeasurement - checkEventByAide fail, rc - %d\n", rc);
+ LOG(LOG_ERR, "validateImaMeasurement - checkEventByAide fail, rc - %d\n", rc);
eventWrapper->status = PTS_INTERNAL_ERROR; // OPENPTS_RESULT_INT_ERROR;
xfree(name);
return PTS_INTERNAL_ERROR; // -1;
// freeAideMetadata(md);
// xfree(name);
} else if (ctx->conf->ima_validation_mode == OPENPTS_VALIDATION_MODE_IIDB) {
- ERROR("validateImaMeasurementNG w/ IIDB - NA\n");
+ LOG(LOG_ERR, "validateImaMeasurementNG w/ IIDB - NA\n");
}
#else // !CONFIG_AIDE
if (ctx->conf->ima_validation_mode == OPENPTS_VALIDATION_MODE_IIDB) {
- ERROR("validateImaMeasurementNG w/ IIDB - NA\n");
+ LOG(LOG_ERR, "validateImaMeasurementNG w/ IIDB - NA\n");
}
#endif
else {
return PTS_SUCCESS;
}
- ERROR("validateImaMeasurement - ERROR\n");
+ LOG(LOG_ERR, "validateImaMeasurement - ERROR\n");
return PTS_INTERNAL_ERROR; // -1;
}
/* IMA NG */
int validateImaAggregateNG(OPENPTS_CONTEXT *ctx, OPENPTS_PCR_EVENT_WRAPPER *eventWrapper) {
- ERROR("validateImaAggregateNG - NA\n");
+ LOG(LOG_ERR, "validateImaAggregateNG - NA\n");
setProperty(ctx, "ima.aggregate", "TBD");
return PTS_INTERNAL_ERROR; // -1;
}
/* check ctx */
if (ctx == NULL) {
- ERROR("startCollector() - ctx is null");
+ LOG(LOG_ERR, "startCollector() - ctx is null");
return PTS_FATAL;
}
if (ctx->target_conf == NULL) {
}
if (ctx->target_conf->uuid == NULL) {
/* collector */
- ERROR("startCollector() - uuid is NULL\n");
+ LOG(LOG_ERR, "startCollector() - uuid is NULL\n");
return PTS_FATAL;
}
/* check eventWrapper */
if (eventWrapper == NULL) {
- ERROR("startCollector() - eventWrapper is NULL\n");
+ LOG(LOG_ERR, "startCollector() - eventWrapper is NULL\n");
return PTS_FATAL;
}
event = eventWrapper->event;
if (event == NULL) {
- ERROR("startCollector() - event is NULL\n");
+ LOG(LOG_ERR, "startCollector() - event is NULL\n");
return PTS_FATAL;
}
if (event->ulEventLength != sizeof(OPENPTS_EVENT_COLLECTOR_START)) {
- ERROR("startCollector() - Bad eventData size %d != %d\n",
+ LOG(LOG_ERR, "startCollector() - Bad eventData size %d != %d\n",
event->ulEventLength,
sizeof(OPENPTS_EVENT_COLLECTOR_START));
return PTS_FATAL;
/* validation - TSS version */
if (memcmp(&start->pts_version, &ctx->target_conf->pts_version, 4) != 0) {
- ERROR("startCollector() - Bad PTS version\n");
+ LOG(LOG_ERR, "startCollector() - Bad PTS version\n");
rc = PTS_INVALID_COLLECTOR;
}
/* validation - Collector UUID */
if (memcmp(&start->collector_uuid, ctx->target_conf->uuid->uuid, 16) != 0) {
- ERROR("startCollector() - Bad Collector UUID (Unit Testing?)\n");
+ LOG(LOG_ERR, "startCollector() - Bad Collector UUID (Unit Testing?)\n");
rc = PTS_INVALID_COLLECTOR;
}
/* validation - Manifest UUID */
if (memcmp(&start->manifest_uuid, ctx->target_conf->rm_uuid->uuid, 16) != 0) {
// TODO in the test ptsc generate new RM UUID
- ERROR("startCollector() - Bad Manifest UUID (Unit Testing?)\n");
+ LOG(LOG_ERR, "startCollector() - Bad Manifest UUID (Unit Testing?)\n");
rc = PTS_INVALID_COLLECTOR;
}
/* event */
if (eventWrapper == NULL) {
- ERROR("addBIOSSpecificProperty- eventWrapper is NULL\n");
+ LOG(LOG_ERR, "addBIOSSpecificProperty- eventWrapper is NULL\n");
return -1;
}
event = eventWrapper->event;
if (event->ulEventLength < 48) {
// Bad EventData
- TODO("addIntelTxtTbootProperty() bad eventdata, size = %d\n",
+ LOG(LOG_TODO, "addIntelTxtTbootProperty() bad eventdata, size = %d\n",
event->ulEventLength);
} else {
// EventData
break;
default:
- ERROR("Unknown event tupe 0x%x\n", event->eventType);
+ LOG(LOG_ERR, "Unknown event tupe 0x%x\n", event->eventType);
break;
}
/* check */
if (ctx == NULL) {
- ERROR("doActivity - ctx is NULL");
+ LOG(LOG_ERR, "doActivity - ctx is NULL");
return PTS_FATAL;
}
if (action == NULL) {
- ERROR("doActivity - action is NULL");
+ LOG(LOG_ERR, "doActivity - action is NULL");
return PTS_FATAL;
}
if (eventWrapper == NULL) {
rc = action_table[i].func_7(ctx, value, eventWrapper);
goto end;
default:
- ERROR("unknown OPENPTS_ACTION_TABLE func tyoe\n");
+ LOG(LOG_ERR, "unknown OPENPTS_ACTION_TABLE func tyoe\n");
break;
}
}
}
/* error */
- ERROR("unknown action '%s'\n", action);
+ LOG(LOG_ERR, "unknown action '%s'\n", action);
addReason(ctx, -1, NLS(MS_OPENPTS, OPENPTS_ACTION_UNKNOWN, "[FSM] Unknown action='%s'"), action);
rc = OPENPTS_FSM_ERROR;
AIDE_METADATA *metadata;
metadata = (AIDE_METADATA *) xmalloc(sizeof(AIDE_METADATA));
if (metadata == NULL) {
- // ERROR("no memory\n");
+ // LOG(LOG_ERR, "no memory\n");
return NULL;
}
memset(metadata, 0, sizeof(AIDE_METADATA));
memset(ctx->aide_md_table, 0, sizeof(struct hsearch_data));
rc = hcreate_r(AIDE_HASH_TABLE_SIZE, ctx->aide_md_table); // hash table for metadata
if (rc == 0) {
- ERROR("hcreate faild, errno=%x\n", errno);
+ LOG(LOG_ERR, "hcreate faild, errno=%x\n", errno);
goto error;
}
ctx->aide_md_table_size = 0;
// 4096 full
rc = hcreate_r(AIDE_HASH_TABLE_SIZE, ctx->aide_in_table); // hash table for ignore name
if (rc == 0) {
- ERROR("hcreate faild\n");
+ LOG(LOG_ERR, "hcreate faild\n");
goto error;
}
ctx->aide_in_table_size = 0;
void freeAideContext(AIDE_CONTEXT *ctx) {
/* check */
if (ctx == NULL) {
- ERROR("ctx is NULL\n");
+ LOG(LOG_ERR, "ctx is NULL\n");
return;
}
DEBUG("freeAideContext %p \n", ctx);
} else if (!strncmp(buf, "xattrs", 6)) {
return AIDE_ITEM_XATTRS;
} else {
- ERROR("Unknown AIDE item [%s]\n", buf);
+ LOG(LOG_ERR, "Unknown AIDE item [%s]\n", buf);
return -1;
}
}
fp = gzopen(filename, "r");
if (fp == NULL) {
- ERROR("%s missing\n", filename);
+ LOG(LOG_ERR, "%s missing\n", filename);
return -1;
}
while (ptr < end) {
/* skip space */
while ((ptr < end) && (*ptr == 0x20)) {
- printf("skip %d ", *ptr);
+ // skip
ptr++;
}
/* find sep */
sep = strstr(ptr, " ");
if (sep == NULL) {
- ERROR("bad data, %s\n", buf);
+ LOG(LOG_ERR, "bad data, %s\n", buf);
return -1;
} else {
// terminate at " "
items[item_num] = getAideItemIndex(ptr);
if (items[item_num] < 0) {
- ERROR("Bad spec\n");
+ LOG(LOG_ERR, "Bad spec\n");
return -1;
}
item_num++;
body = 2;
if (item_num > AIDE_MAX_ITEM_NUM) {
- ERROR("loadAideDatabaseFile - %d items > %d \n", item_num, AIDE_MAX_ITEM_NUM);
+ LOG(LOG_ERR, "loadAideDatabaseFile - %d items > %d \n", item_num, AIDE_MAX_ITEM_NUM);
return -1;
}
DEBUG("loadAideDatabaseFile - has %d items\n", item_num);
for (i = 0; i < item_num; i++) {
/* space -> \0 */
if (i != item_num - 1) {
- // printf("SEP %d %d\n",i, item_num);
sep = strstr(ptr, " ");
if (sep == NULL) {
- ERROR("bad data, %s\n", buf);
+ LOG(LOG_ERR, "bad data, %s\n", buf);
freeAideMetadata(md);
return -1;
} else {
SHA1_BASE64_DIGEST_SIZE,
&len);
if (md->sha1 == NULL) {
- ERROR("decodeBase64 fail");
+ LOG(LOG_ERR, "decodeBase64 fail");
goto close;
}
if (len != SHA1_DIGEST_SIZE) {
- ERROR("bad SHA1 size %d %s\n", len, ptr);
- // printf("base64 [%s] => [", ptr);
+ LOG(LOG_ERR, "bad SHA1 size %d %s\n", len, ptr);
printHex("digest", md->sha1, len, "\n");
- // printf("]\n");
}
}
break;
SHA256_BASE64_DIGEST_SIZE,
&len);
if (md->sha256 == NULL) {
- ERROR("decodeBase64 fail");
+ LOG(LOG_ERR, "decodeBase64 fail");
goto close;
}
if (len != SHA256_DIGEST_SIZE) {
- ERROR("bad SHA256 size %d\n", len);
- printf("base64 [%s] => [", ptr);
+ LOG(LOG_ERR, "bad SHA256 size %d\n", len);
+ OUTPUT("base64 [%s] => [", ptr);
printHex("", (BYTE *)ptr, 2, " ");
- printf("][\n");
+ OUTPUT("][\n");
printHex("", md->sha256, len, " ");
- printf("]\n");
+ OUTPUT("]\n");
}
}
break;
SHA512_BASE64_DIGEST_SIZE,
&len);
if (md->sha512 == NULL) {
- ERROR("decodeBase64 fail");
+ LOG(LOG_ERR, "decodeBase64 fail");
goto close;
}
if (len != SHA512_DIGEST_SIZE) {
- ERROR("bad SHA512 size %d\n", len);
- printf("base64 [%s] => [", ptr);
+ LOG(LOG_ERR, "bad SHA512 size %d\n", len);
+ OUTPUT("base64 [%s] => [", ptr);
printHex("", (BYTE *)ptr, 2, "");
- printf("][\n");
+ OUTPUT("][\n");
printHex("", md->sha512, len, "");
- printf("]\n");
+ OUTPUT("]\n");
}
}
break;
if (rc == 0) {
if (errno == ENOMEM) {
- ERROR(" hsearch_r failed, table is full, errno=%x\n", errno);
+ LOG(LOG_ERR, " hsearch_r failed, table is full, errno=%x\n", errno);
} else {
- ERROR(" hsearch_r failed, errno=%x\n", errno);
+ LOG(LOG_ERR, " hsearch_r failed, errno=%x\n", errno);
}
}
// CAUTION too many messages, use for debugging the unit test
// DEBUG("Hash Table <- %4d [%s] %s\n", ctx->aide_md_table_size, md->hash_key, md->name);
ctx->aide_md_table_size++;
}
-
-
#if 0
if (ctx->start == NULL) {
ctx->start = md;
ctx->metadata_num++;
#endif
} else {
- // ignore printf("??? [%s]\n", buf);
+ // ignore
} // if
} // while
close:
/* new */
list = xmalloc(sizeof(AIDE_LIST));
if (list == NULL) {
- ERROR("no mem\n");
+ LOG(LOG_ERR, "no mem\n");
rc = PTS_OS_ERROR;
goto error; // return -1;
}
rc = hsearch_r(e, ENTER, &ep, ctx->aide_in_table);
if (rc == 0) {
if (errno == ENOMEM) {
- ERROR(" hsearch_r failed, ignore name table is full, errno=%x\n", errno);
+ LOG(LOG_ERR, " hsearch_r failed, ignore name table is full, errno=%x\n", errno);
} else {
- ERROR(" hsearch_r failed, errno=%x\n", errno);
+ LOG(LOG_ERR, " hsearch_r failed, errno=%x\n", errno);
}
}
ctx->aide_in_table_size++;
md = ctx->start;
for (i = 0; i < ctx->metadata_num; i++) {
- printf("%4d ", i);
- if ( md->name != NULL) printf("%30s ", md->name);
- if ( md->lname != NULL) printf("%20s ", md->lname);
- if ( md->attr != 0) printf("%08X ", md->attr);
+ OUTPUT("%4d ", i);
+ if ( md->name != NULL) OUTPUT("%30s ", md->name);
+ if ( md->lname != NULL) OUTPUT("%20s ", md->lname);
+ if ( md->attr != 0) OUTPUT("%08X ", md->attr);
if (md->sha1 != NULL)
printHex("", md->sha1, 20, " ");
else
- printf(" -");
+ OUTPUT(" -");
if (md->sha256 != NULL)
printHex("", md->sha256, 32, " ");
else
- printf(" -");
+ OUTPUT(" -");
- printf(" <<\n");
+ OUTPUT(" <<\n");
md = md->next;
}
/* check */
if (name == NULL) {
- ERROR("checkIgnoreList() - name is null\n");
+ LOG(LOG_ERR, "checkIgnoreList() - name is null\n");
return -2;
}
return 0;
}
} else {
- ERROR("checkIgnoreList() - list->name is null\n");
+ LOG(LOG_ERR, "checkIgnoreList() - list->name is null\n");
return -2;
}
// DEBUG("checkEventByAide - start\n");
if (ctx == NULL) {
- ERROR("checkEventByAide - AIDE_CONTEXT is NULL\n");
+ LOG(LOG_ERR, "checkEventByAide - AIDE_CONTEXT is NULL\n");
return -1;
}
if (eventWrapper == NULL) {
- ERROR("OcheckEventByAide - PENPTS_PCR_EVENT_WRAPPER is NULL\n");
+ LOG(LOG_ERR, "OcheckEventByAide - PENPTS_PCR_EVENT_WRAPPER is NULL\n");
return -1;
}
// 20100627 ignore pseudo event
if (event->eventType == OPENPTS_PSEUDO_EVENT_TYPE) {
- ERROR("validateImaMeasurement - event->eventType == OPENPTS_PSEUDO_EVENT_TYPE\n");
+ LOG(LOG_ERR, "validateImaMeasurement - event->eventType == OPENPTS_PSEUDO_EVENT_TYPE\n");
return 1;
}
20
&buf_len);
if (buf == NULL) {
- ERROR("encodeBase64 fail");
+ LOG(LOG_ERR, "encodeBase64 fail");
return -1;
}
rc = verifyBySQLite(ctx, (char*)buf);
20,
&buf_len);
if (buf == NULL) {
- ERROR("encodeBase64 fail");
+ LOG(LOG_ERR, "encodeBase64 fail");
return -1;
}
e.key = (char *) buf; // size?
/* file open for write */
fp = gzopen(filename, "wb");
if (fp == NULL) {
- ERROR("%s fail to open\n", filename);
+ LOG(LOG_ERR, "%s fail to open\n", filename);
return -1;
}
/* IMLs */
ss = getSnapshotFromTable(ctx->ss_table, 10, 1); // TODO def or conf
if (ss == NULL) {
- ERROR("events is missing\n");
+ LOG(LOG_ERR, "events is missing\n");
goto close;
}
eventWrapper = ss->start;
if (eventWrapper == NULL) {
- ERROR("events is missing\n");
+ LOG(LOG_ERR, "events is missing\n");
goto close;
}
// DEBUG("SM DEBUG event %p\n",event);
if (event == NULL) {
- ERROR("event is NULL\n");
+ LOG(LOG_ERR, "event is NULL\n");
goto close;
}
if (event->rgbEvent == NULL) {
- ERROR("event->rgbEvent is NULL\n");
+ LOG(LOG_ERR, "event->rgbEvent is NULL\n");
goto close;
}
/* filename (allocated) */
len = escapeFilename(&aide_filename, (char *) &eventWrapper->event->rgbEvent[20]);
if (len < 0) {
- ERROR("convertImlToAideDbFile - no mem?\n");
+ LOG(LOG_ERR, "convertImlToAideDbFile - no mem?\n");
gzprintf(fp, "bad_filename ");
} else {
gzprintf(fp, "%s ", aide_filename);
SHA1_DIGEST_SIZE,
&buf_len);
if (buf == NULL) {
- ERROR("encodeBase64 fail");
+ LOG(LOG_ERR, "encodeBase64 fail");
goto close;
}
gzprintf(fp, "%s \n", buf);
xfree(buf);
- // printf("%d %s\n", i, buf);
-
eventWrapper = eventWrapper->next_pcr;
if (eventWrapper == NULL) break;
event = eventWrapper->event;
/* file open for write */
fp = gzopen(filename, "wb");
if (fp == NULL) {
- ERROR("%s fail to open\n", filename);
+ LOG(LOG_ERR, "%s fail to open\n", filename);
return -1;
}
}
if (md->status == OPENPTS_AIDE_MD_STATUS_HIT) {
- // printf("+");
buf = encodeBase64(
(unsigned char *)md->sha1,
SHA1_DIGEST_SIZE,
&buf_len);
if (buf == NULL) {
- ERROR("encodeBase64 fail");
+ LOG(LOG_ERR, "encodeBase64 fail");
return -1;
}
gzprintf(fp, "%s ", md->name);
/* check */
if (aide_filename == NULL) {
- ERROR("AIDE file is null\n");
+ LOG(LOG_ERR, "AIDE file is null\n");
return PTS_INTERNAL_ERROR;
}
if (sqlite_filename == NULL) {
- ERROR("sqlite file is null\n");
+ LOG(LOG_ERR, "sqlite file is null\n");
return PTS_INTERNAL_ERROR;
}
/* read AIDE DB file -> ctx */
rc = loadAideDatabaseFile(ctx, aide_filename);
if (rc < 0) {
- ERROR("read AIDE DB %s fail, rc = %d", aide_filename, rc);
+ LOG(LOG_ERR, "read AIDE DB %s fail, rc = %d", aide_filename, rc);
return -1;
}
/* open */
sqlite3_open(sqlite_filename, &db);
if (db == NULL) {
- ERROR("open AIDE DB fail\n");
+ LOG(LOG_ERR, "open AIDE DB fail\n");
rc = PTS_INTERNAL_ERROR;
goto free;
}
int loadSQLiteDatabaseFile(AIDE_CONTEXT *ctx, char *filename) {
/* check */
if (ctx == NULL) {
- ERROR("ctx == NULL\n");
+ LOG(LOG_ERR, "ctx == NULL\n");
return PTS_INTERNAL_ERROR;
}
if (filename == NULL) {
- ERROR("filename == NULL\n");
+ LOG(LOG_ERR, "filename == NULL\n");
return PTS_INTERNAL_ERROR;
}
/* open */
sqlite3_open(filename, &ctx->sqlite_db);
if (ctx->sqlite_db == NULL) {
- ERROR("open AIDE SQLite DB %s fail\n", filename);
+ LOG(LOG_ERR, "open AIDE SQLite DB %s fail\n", filename);
return PTS_INTERNAL_ERROR;
}
/* check */
if (ctx == NULL) {
- ERROR("ctx == NULL\n");
+ LOG(LOG_ERR, "ctx == NULL\n");
return PTS_INTERNAL_ERROR;
}
if (ctx->sqlite_db == NULL) {
- ERROR("ctx->sqlite_db == NULL\n");
+ LOG(LOG_ERR, "ctx->sqlite_db == NULL\n");
return PTS_INTERNAL_ERROR;
}
return OPENPTS_RESULT_VALID;
}
- // ERROR("row = %d\n",row);
+ // LOG(LOG_ERR, "row = %d\n",row);
/* free */
sqlite3_free(sql);
ctx = xmalloc(sizeof(OPENPTS_UPDATE_CONTEXT));
if (ctx == NULL) {
- ERROR("no memory");
+ LOG(LOG_ERR, "no memory");
return NULL;
}
memset(ctx, 0, sizeof(OPENPTS_UPDATE_CONTEXT));
uss = xmalloc(sizeof(OPENPTS_UPDATE_SNAPSHOT));
if (uss == NULL) {
- ERROR("no memory");
+ LOG(LOG_ERR, "no memory");
return NULL;
}
memset(uss, 0, sizeof(OPENPTS_UPDATE_SNAPSHOT));
int resetFsm(OPENPTS_SNAPSHOT *ss) {
/* check */
if (ss == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
/* check input */
if (ctx == NULL) {
- ERROR("null input\n");
+ LOG(LOG_ERR, "null input\n");
return PTS_FATAL;
}
conf = ctx->conf;
if (conf == NULL) {
- ERROR("null input\n");
+ LOG(LOG_ERR, "null input\n");
return PTS_FATAL;
}
/* check conf */
/* check */
if (eventWrapper == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
event = eventWrapper->event;
if (event == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
if (event->ulEventLength <= 20) { // TODO sizeof
- ERROR("startUpdate() - bad eventdata\n");
+ LOG(LOG_ERR, "startUpdate() - bad eventdata\n");
return PTS_FATAL;
}
if (event->rgbEvent == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
if (conf->update == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
ctx->conf->iml_endian);
if (target_pcr_index >= MAX_PCRNUM) {
- ERROR("startUpdate() - Bad PCR index %d 0x%08x\n",
+ LOG(LOG_ERR, "startUpdate() - Bad PCR index %d 0x%08x\n",
target_pcr_index, target_pcr_index);
return PTS_INTERNAL_ERROR;
}
if (target_snapshot_level >= MAX_SSLEVEL) {
- ERROR("startUpdate() - Bad SS Level %d 0x%08x\n",
+ LOG(LOG_ERR, "startUpdate() - Bad SS Level %d 0x%08x\n",
target_snapshot_level, target_snapshot_level);
return PTS_INTERNAL_ERROR;
}
/* check input */
if (ctx == NULL) {
- ERROR("null input\n");
+ LOG(LOG_ERR, "null input\n");
return PTS_FATAL;
}
conf = ctx->conf;
if (conf == NULL) {
- ERROR("null input\n");
+ LOG(LOG_ERR, "null input\n");
return PTS_FATAL;
}
/* check */
if (eventWrapper == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
event = eventWrapper->event;
if (event == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
update = conf->update;
if (update == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
[update->target_pcr_index]
[update->target_snapshot_level];
if (uss == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
/* check input */
if (ctx == NULL) {
- ERROR("null input\n");
+ LOG(LOG_ERR, "null input\n");
return PTS_FATAL;
}
conf = ctx->conf;
if (conf == NULL) {
- ERROR("null input\n");
+ LOG(LOG_ERR, "null input\n");
return PTS_FATAL;
}
/* check */
if (eventWrapper == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
event = eventWrapper->event;
if (event == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
update = conf->update;
if (update == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
[update->target_pcr_index]
[update->target_snapshot_level];
if (uss == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
/* start structure */
start = uss->start;
if (start == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
/* check the event num */
if (uss->event_count != event_num) {
/* actual event number is different with the number in start event */
- ERROR("number of events (%08x) are not same with definition at start (%08x), BAD eventlog?\n",
+ LOG(LOG_ERR, "number of events (%08x) are not same with definition at start (%08x), BAD eventlog?\n",
uss->event_count, event_num);
return PTS_INVALID_SNAPSHOT;
}
/* check input */
if (ctx == NULL) {
- ERROR("null input\n");
+ LOG(LOG_ERR, "null input\n");
return PTS_FATAL;
}
conf = ctx->conf;
if (conf == NULL) {
- ERROR("null input\n");
+ LOG(LOG_ERR, "null input\n");
return PTS_FATAL;
}
/* check */
if (eventWrapper == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
event = eventWrapper->event;
if (event == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
if (event->ulEventLength != sizeof(OPENPTS_EVENT_COLLECTOR_UPDATE)) {
- ERROR("updateCollector() - Bad eventData size %d != %d\n",
+ LOG(LOG_ERR, "updateCollector() - Bad eventData size %d != %d\n",
event->ulEventLength,
sizeof(OPENPTS_EVENT_COLLECTOR_UPDATE));
return PTS_INVALID_SNAPSHOT;
if (conf->target_newrm_uuid == NULL) {
conf->target_newrm_uuid = xmalloc(sizeof(PTS_UUID));
if (NULL == conf->target_newrm_uuid) {
- ERROR("no memory");
+ LOG(LOG_ERR, "no memory");
return PTS_FATAL;
}
}
/* check input */
if (ctx == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
if (uss == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
/* update target snaposhot */
ss = getSnapshotFromTable(ctx->ss_table, i, j);
if (NULL == ss) {
- ERROR("null snapshot\n");
+ LOG(LOG_ERR, "null snapshot\n");
return PTS_FATAL;
}
/* WORK NEEDED: I guess that bosrenew should really pass in all IPL events including the final one */
num++;
#endif
- INFO("UPDATE_IPL_IMAGE iml.ipl.maxcount=%d (0x%x)\n", num, num);
+ LOG(LOG_INFO, "UPDATE_IPL_IMAGE iml.ipl.maxcount=%d (0x%x)\n", num, num);
snprintf(buf, BUF_SIZE, "%d", num);
setProperty(ctx, "iml.ipl.maxcount", buf);
}
// goto end;
break;
} else {
- ERROR("updateFsm rc=%d\n", rc);
+ LOG(LOG_ERR, "updateFsm rc=%d\n", rc);
}
/* update SS chain */
/*check */
if (conf == NULL) {
- ERROR("null input\n");
+ LOG(LOG_ERR, "null input\n");
return PTS_FATAL;
}
if (conf->newrm_uuid == NULL) {
- ERROR("null input\n");
+ LOG(LOG_ERR, "null input\n");
return PTS_FATAL;
}
if (conf->newrm_uuid->uuid == NULL) {
- ERROR("null input\n");
+ LOG(LOG_ERR, "null input\n");
return PTS_FATAL;
}
/* check input */
if (ctx == NULL) {
- ERROR("null input\n");
+ LOG(LOG_ERR, "null input\n");
return PTS_FATAL;
}
conf = ctx->conf;
if (conf == NULL) {
- ERROR("null input\n");
+ LOG(LOG_ERR, "null input\n");
return PTS_FATAL;
}
if (conf->update_exist == 0) {
- TODO("updateSnapshots() - done, no update\n");
+ LOG(LOG_TODO, "updateSnapshots() - done, no update\n");
return PTS_SUCCESS;
}
update = (OPENPTS_UPDATE_CONTEXT *)conf->update;
if (update == NULL) {
- ERROR("null input\n");
+ LOG(LOG_ERR, "null input\n");
return PTS_FATAL;
}
/* check */
if (conf == NULL) {
- ERROR("null input\n");
+ LOG(LOG_ERR, "null input\n");
return PTS_FATAL;
}
/* ctx for init */
ctx = newPtsContext(conf);
if (ctx == NULL) {
- ERROR("no memory");
+ LOG(LOG_ERR, "no memory");
return PTS_FATAL;
}
if (prop_count > 0) {
/* check */
if (prop_start == NULL) {
- ERROR("null input\n");
+ LOG(LOG_ERR, "null input\n");
return PTS_FATAL;
}
if (prop_end == NULL) {
- ERROR("null input\n");
+ LOG(LOG_ERR, "null input\n");
return PTS_FATAL;
}
ctx->prop_start = prop_start;
/* read FSM */
rc = readFsmFromPropFile(ctx, conf->config_file);
if (rc != PTS_SUCCESS) {
- ERROR("update() - read FSM failed\n");
+ LOG(LOG_ERR, "update() - read FSM failed\n");
rc = PTS_INTERNAL_ERROR;
goto free;
}
/* load current IML using FSMs */
if (conf->iml_mode == 0) { // TODO use def
#ifdef CONFIG_NO_TSS
- ERROR("update() - Build with --without-tss. iml.mode=tss is not supported\n");
+ LOG(LOG_ERR, "update() - Build with --without-tss. iml.mode=tss is not supported\n");
#else
rc = getIml(ctx, 0);
rc = getPcr(ctx);
conf->runtime_iml_filename,
conf->runtime_iml_type, 0, &count); // TODO endian?
if (rc < 0) {
- ERROR("read IMA IML, %s has failed\n", conf->runtime_iml_filename);
+ LOG(LOG_ERR, "read IMA IML, %s has failed\n", conf->runtime_iml_filename);
rc = PTS_INTERNAL_ERROR;
goto free;
}
}
} else {
- ERROR("unknown IML mode, %d\n", conf->iml_mode);
+ LOG(LOG_ERR, "unknown IML mode, %d\n", conf->iml_mode);
}
/* get SMBIOS data */
/* Update the Manifests */
rc = updateSnapshots(ctx);
if (rc != PTS_SUCCESS) {
- ERROR("update() - updateSnapshots fail\n");
+ LOG(LOG_ERR, "update() - updateSnapshots fail\n");
goto free;
}
/* new UUID for this RM set */
if (conf->newrm_uuid == NULL) {
- INFO("conf->newrm_uuid == NULL, generate new reference manifest UUID\n");
+ LOG(LOG_INFO, "conf->newrm_uuid == NULL, generate new reference manifest UUID\n");
conf->newrm_uuid = newOpenptsUuid(); // empty
conf->newrm_uuid->filename = getFullpathName(conf->config_dir, "newrm_uuid");
DEBUG("conf->newrm_uuid->filename %s\n", conf->newrm_uuid->filename);
rc = genOpenptsUuid(conf->newrm_uuid);
// TODO
} else {
- ERROR("update() - conf->newrm_uuid->status %d\n", conf->newrm_uuid->status);
- ERROR("update() - use given reference manifest UUID %s (for test)\n", conf->rm_uuid->str);
+ LOG(LOG_ERR, "update() - conf->newrm_uuid->status %d\n", conf->newrm_uuid->status);
+ LOG(LOG_ERR, "update() - use given reference manifest UUID %s (for test)\n", conf->rm_uuid->str);
rc = PTS_FATAL;
goto free;
}
/* RM set DIR */
rc = makeNewRmSetDir(conf);
if (rc != PTS_SUCCESS) {
- ERROR("mkdir of RM set dir was failed\n");
+ LOG(LOG_ERR, "mkdir of RM set dir was failed\n");
goto free;
}
DEBUG("update() - writeRm %s\n", conf->newrm_filename[i]);
rc = writeRm(ctx, conf->newrm_filename[i], i);
if (rc < 0) {
- ERROR("write RM, %s was failed\n", conf->newrm_filename[i]);
+ LOG(LOG_ERR, "write RM, %s was failed\n", conf->newrm_filename[i]);
rc = PTS_INTERNAL_ERROR;
goto free;
}
DEBUG("update() - dowriteRm %s\n", conf->newrm_filename[i]);
rc = writeRm(ctx, conf->newrm_filename[i], i);
if (rc < 0) {
- ERROR("write RM, %s was failed\n", conf->newrm_filename[i]);
+ LOG(LOG_ERR, "write RM, %s was failed\n", conf->newrm_filename[i]);
rc = PTS_INTERNAL_ERROR;
goto free;
}
/* Extend Collector Update event */
rc = extendEvCollectorUpdate(conf);
if (rc != PTS_SUCCESS) {
- ERROR("updateSnapshots() - extendEvCollectorUpdate fail\n");
+ LOG(LOG_ERR, "updateSnapshots() - extendEvCollectorUpdate fail\n");
goto free;
}
- printf(NLS(MS_OPENPTS, OPENPTS_UPDATE_SUCCESS, "Successfully updated the reference manifests\n\n"));
+ OUTPUT(NLS(MS_OPENPTS, OPENPTS_UPDATE_SUCCESS,
+ "Successfully updated the reference manifests\n\n"));
} else {
- printf(NLS(MS_OPENPTS, OPENPTS_UPDATE_NONE, "There is no update.\n\n"));
+ OUTPUT(NLS(MS_OPENPTS, OPENPTS_UPDATE_NONE,
+ "There is no update.\n\n"));
}
free:
if ( rc != PTS_SUCCESS ) {
- printf(NLS(MS_OPENPTS, OPENPTS_UPDATE_FAILED, "Failed to update the reference manifests\n"));
+ ERROR(NLS(MS_OPENPTS, OPENPTS_UPDATE_FAILED,
+ "Failed to update the reference manifests\n"));
}
if ( NULL != ctx ) {
int fd = open(fileName, O_RDONLY);
if (fd == -1) {
- ERROR("Failed to open '%s', errno %d\n", fileName, errno);
+ LOG(LOG_ERR, "Failed to open '%s', errno %d\n", fileName, errno);
} else if (fstat(fd, &statBuf) == -1) {
- ERROR("Failed to stat '%s' (fd %d), errno %d\n", fileName, fd, errno);
+ LOG(LOG_ERR, "Failed to stat '%s' (fd %d), errno %d\n", fileName, fd, errno);
} else if ( len != statBuf.st_size ) {
DEBUG("File length for pending RM '%s' (%d) does not match cached length (%d) from collector.\n",
fileName, (int)statBuf.st_size, len);
char page[4096];
ssize_t bytesRead = read(fd, page, 4096);
if ( -1 == bytesRead ) {
- ERROR("Failed to read from fd %d, errno %d\n", fd, errno);
+ LOG(LOG_ERR, "Failed to read from fd %d, errno %d\n", fd, errno);
break;
} else if ( bytesRead == 0) {
if (totalBytesRead != len) {
- ERROR("Finished reading from file prematurely, still expecting data.");
+ LOG(LOG_ERR, "Finished reading from file prematurely, still expecting data.");
return PTS_FATAL;
}
rc = PTS_SUCCESS;
} else {
totalBytesRead += bytesRead;
if (totalBytesRead > len) {
- ERROR("Read more data from RM file than expected.");
+ LOG(LOG_ERR, "Read more data from RM file than expected.");
return PTS_FATAL;
}
DEBUG("Read %ld bytes, total = %d out of %d\n", bytesRead, totalBytesRead, len);
/* check */
if (ctx == NULL) {
- ERROR("null input\n");
+ LOG(LOG_ERR, "null input\n");
return PTS_FATAL;
}
conf = ctx->conf;
if (conf == NULL) {
- ERROR("null input\n");
+ LOG(LOG_ERR, "null input\n");
return PTS_FATAL;
}
newRmSet = conf->newRmSet;
if (newRmSet == NULL) {
- ERROR("null input\n");
+ LOG(LOG_ERR, "null input\n");
return PTS_FATAL;
}
target_conf = ctx->target_conf;
if (target_conf == NULL) {
- ERROR("null input\n");
+ LOG(LOG_ERR, "null input\n");
return PTS_FATAL;
}
if (target_conf->uuid == NULL) {
- ERROR("null input\n");
+ LOG(LOG_ERR, "null input\n");
return PTS_FATAL;
}
if (target_conf->rm_uuid == NULL) {
- ERROR("null input\n");
+ LOG(LOG_ERR, "null input\n");
return PTS_FATAL;
}
rc = checkDir(collector_dir);
if (rc != PTS_SUCCESS) {
/* unknwon collector */
- ERROR("isNewRmStillValid() - Unknown collector, UUID= %s dir=%s\n",
+ LOG(LOG_ERR, "isNewRmStillValid() - Unknown collector, UUID= %s dir=%s\n",
str_collector_uuid, collector_dir);
addReason(ctx, -1, NLS(MS_OPENPTS, OPENPTS_ARU_MISSING_COLLECTOR_CONFIG,
"Missing collector configuration"));
newRmSet += 4;
if (num > MAX_RM_NUM) {
- ERROR("Bad NUM %d\n", num);
+ LOG(LOG_ERR, "Bad NUM %d\n", num);
goto out;
}
/* check */
if (ctx == NULL) {
- ERROR("null input\n");
+ LOG(LOG_ERR, "null input\n");
return PTS_FATAL;
}
conf = ctx->conf;
if (conf == NULL) {
- ERROR("null input\n");
+ LOG(LOG_ERR, "null input\n");
return PTS_FATAL;
}
newRmSet = conf->newRmSet;
if (newRmSet == NULL) {
- ERROR("null input\n");
+ LOG(LOG_ERR, "null input\n");
return PTS_FATAL;
}
if (ctx->target_conf == NULL) {
- ERROR("null input\n");
+ LOG(LOG_ERR, "null input\n");
return PTS_FATAL;
}
if (ctx->target_conf->uuid == NULL) {
- ERROR("null input\n");
+ LOG(LOG_ERR, "null input\n");
return PTS_FATAL;
}
if (ctx->target_conf->rm_uuid == NULL) {
- ERROR("null input\n");
+ LOG(LOG_ERR, "null input\n");
return PTS_FATAL;
}
// TODO check
rc = readTargetConf(target_conf, target_conf_filename);
if (rc != PTS_SUCCESS) {
- ERROR("updateNewRm() - readTargetConf failed\n");
+ LOG(LOG_ERR, "updateNewRm() - readTargetConf failed\n");
// TODO so?
}
rc = checkDir(collector_dir);
if (rc != PTS_SUCCESS) {
/* unknwon collector */
- ERROR("updateNewRm() - Unknown collector, UUID= %s dir=%s\n",
+ LOG(LOG_ERR, "updateNewRm() - Unknown collector, UUID= %s dir=%s\n",
str_collector_uuid, collector_dir);
addReason(ctx, -1, NLS(MS_OPENPTS, OPENPTS_ARU_MISSING_COLLECTOR_CONFIG,
"Missing collector configuration"));
rc = makeDir(rm_dir);
if (rc != PTS_SUCCESS) {
/* unknwon collector */
- ERROR("updateNewRm() - Create New RM dir failed, %s\n", rm_dir);
+ LOG(LOG_ERR, "updateNewRm() - Create New RM dir failed, %s\n", rm_dir);
rc = PTS_INTERNAL_ERROR;
goto out;
}
newRmSet += 4;
if (num > MAX_RM_NUM) {
- ERROR("Bad NUM %d\n", num);
+ LOG(LOG_ERR, "Bad NUM %d\n", num);
rc = PTS_INTERNAL_ERROR;
goto out;
}
rc = saveToFile(rm_filename[i], len, newRmSet);
if (rc != PTS_SUCCESS) {
- ERROR("updateNewRm() - save RM[%d], %s failed\n", i, rm_filename[i]);
+ LOG(LOG_ERR, "updateNewRm() - save RM[%d], %s failed\n", i, rm_filename[i]);
goto out;
}
target_conf->rm_filename[i] = smalloc_assert(rm_filename[i]);
/* check */
if (in == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return 0;
}
/* check */
if (out == NULL) {
- ERROR("null input\n");
+ LOG(LOG_ERR, "null input\n");
return -1;
}
if (len == 0) {
return 0;
}
if (in == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return 0;
}
/* check */
if (in == NULL) {
- ERROR("null input\n");
+ LOG(LOG_ERR, "null input\n");
return NULL;
}
*outlen = _sizeofBase64Encode(inlen);
out = (char *) xmalloc_assert(*outlen);
if (out == NULL) {
- ERROR("no memory");
+ LOG(LOG_ERR, "no memory");
*outlen = 0;
return NULL;
}
len2 = _encodeBase64(out, in, inlen);
if (len2 > *outlen) {
- ERROR("fatal error");
+ LOG(LOG_ERR, "fatal error");
xfree(out);
*outlen = 0;
return NULL;
/* check */
if (in == NULL) {
- ERROR("null input\n");
+ LOG(LOG_ERR, "null input\n");
return -1;
}
/* check */
if (out == NULL) {
- ERROR("decodeBase64core - out is NULL\n");
+ LOG(LOG_ERR, "decodeBase64core - out is NULL\n");
return -1;
}
/* null input? */
if (in == NULL) {
- ERROR("decodeBase64core - in is NULL\n");
+ LOG(LOG_ERR, "decodeBase64core - in is NULL\n");
return -1;
}
/* in[0] => out[0]=\0 */
while (1) {
/* check remain buffer size >= 4 */
if (len2 < 4) {
- ERROR("bad base64 data size");
+ LOG(LOG_ERR, "bad base64 data size");
goto error;
}
/* remove CR and Space and check bad string */
j++;
} else {
/* BAD BASE64 String */
- ERROR("bad base64 data string, 0x%0x", in2[i]);
+ LOG(LOG_ERR, "bad base64 data string, 0x%0x", in2[i]);
goto error;
}
}
/* check */
if (in == NULL) {
- ERROR("null input\n");
+ LOG(LOG_ERR, "null input\n");
return NULL;
}
len1 = _sizeofBase64Decode(inlen);
out = (unsigned char *) xmalloc_assert(len1);
if (out == NULL) {
- ERROR("no memory");
+ LOG(LOG_ERR, "no memory");
*outlen = 0;
return NULL;
}
len2 = _decodeBase64(out, in, inlen);
if (len2 < 0) {
- ERROR("fatal error");
+ LOG(LOG_ERR, "fatal error");
xfree(out);
*outlen = 0;
return NULL;
/* check */
if (conf == NULL) {
- ERROR("FATAL");
+ LOG(LOG_ERR, "FATAL");
return PTS_FATAL;
}
if (conf->uuid == NULL) {
- ERROR("FATAL");
+ LOG(LOG_ERR, "FATAL");
return PTS_FATAL;
}
if (conf->uuid->filename == NULL) {
- ERROR("FATAL");
+ LOG(LOG_ERR, "FATAL");
return PTS_FATAL;
}
/* ctx for init */
ctx = newPtsContext(conf);
if (ctx == NULL) {
- ERROR("no memory?");
+ LOG(LOG_ERR, "no memory?");
return PTS_FATAL;
}
/* UUID for RM */
if (conf->rm_uuid == NULL) {
// init/set by readPtsConf
- // ERROR("conf->rm_uuid == NULL\n");
+ // LOG(LOG_ERR, "conf->rm_uuid == NULL\n");
addReason(ctx, -1,
"[PTSC-INIT] RM_UUID file is not defined (rm.uuid.file) in the ptsc configulation, %s",
conf->config_file);
if (conf->rm_filename[i] != NULL) {
rc = writeRm(ctx, conf->rm_filename[i], i);
if (rc != PTS_SUCCESS) {
- ERROR("ERROR, initialization was failed\n");
+ LOG(LOG_ERR, "ERROR, initialization was failed\n");
// WORK NEEDED: Reason need putting in NLS
addReason(ctx, -1,
"[PTSC-INIT] Couldn't create the manifest file, %s",
OUTPUT(NLS(MS_OPENPTS, OPENPTS_INIT_SUCCESS,
"\nptsc has successfully initialized!\n\n"));
- INFO("ptsc has successfully initialized!\n");
+ LOG(LOG_INFO, "ptsc has successfully initialized!\n");
goto free;
error:
OUTPUT(NLS(MS_OPENPTS, OPENPTS_INIT_FAIL,
"ptsc initialization was failed\n\n"));
printReason(ctx, 0);
- INFO("ptsc initialization was failed\n");
+ LOG(LOG_INFO, "ptsc initialization was failed\n");
free:
/* free */
prop = prop_start;
for (i = 0; i < prop_count; i++) {
if (prop == NULL) {
- ERROR("prop == NULL\n");
+ LOG(LOG_ERR, "prop == NULL\n");
return PTS_INTERNAL_ERROR; // TODO free
}
addProperty(ctx, prop->name, prop->value);
/* gen IR */
rc = genIr(ctx, NULL);
if (rc != PTS_SUCCESS) {
- ERROR("selftest() - genIR failed\n");
+ LOG(LOG_ERR, "selftest() - genIR failed\n");
rc = PTS_INTERNAL_ERROR;
goto free;
}
/* setup RMs */
rc = getRmSetDir(conf);
if (rc != PTS_SUCCESS) {
- ERROR("selftest() - getRmSetDir() failed\n");
- TODO("conf->rm_uuid->filename %s\n", conf->rm_uuid->filename);
- TODO("conf->rm_uuid->str %s\n", conf->rm_uuid->str);
+ LOG(LOG_ERR, "selftest() - getRmSetDir() failed\n");
+ LOG(LOG_TODO, "conf->rm_uuid->filename %s\n", conf->rm_uuid->filename);
+ LOG(LOG_TODO, "conf->rm_uuid->str %s\n", conf->rm_uuid->str);
rc = PTS_INTERNAL_ERROR;
goto free;
}
for (i = 0; i < conf->rm_num; i++) {
rc = readRmFile(ctx, conf->rm_filename[i], i);
if (rc < 0) {
- ERROR("readRmFile fail\n");
+ LOG(LOG_ERR, "readRmFile fail\n");
rc = PTS_INTERNAL_ERROR;
goto free;
}
/* update rm_uuid */
rc = writeOpenptsUuidFile(conf->rm_uuid, 1);
if (rc != PTS_SUCCESS) {
- ERROR("writeOpenptsUuidFile fail\n");
+ LOG(LOG_ERR, "writeOpenptsUuidFile fail\n");
}
// TODO check rc
rc = OPENPTS_SELFTEST_RENEWED;
} else {
/* fail */
- TODO("\n");
+ LOG(LOG_ERR, "sleftest fail\n");
addReason(ctx, -1, NLS(MS_OPENPTS, OPENPTS_COLLECTOR_SELFTEST_FAILED_2,
"[SELFTEST] The self test using both current and new UUIDs has failed"));
printReason(ctx, 0);
prop = prop_start;
for (i = 0; i < prop_count; i++) {
if (prop == NULL) {
- ERROR("prop == NULL\n");
+ LOG(LOG_ERR, "prop == NULL\n");
return PTS_INTERNAL_ERROR; // TODO free
}
addProperty(ctx, prop->name, prop->value);
/* read FSM */
rc = readFsmFromPropFile(ctx, conf->config_file);
if (rc != PTS_SUCCESS) {
- fprintf(stderr, NLS(MS_OPENPTS, OPENPTS_COLLECTOR_FAILED_READ_FSM, "Failed to read the FSM file\n"));
+ ERROR(NLS(MS_OPENPTS, OPENPTS_COLLECTOR_FAILED_READ_FSM,
+ "Failed to read the FSM file.\n"));
rc = PTS_INTERNAL_ERROR;
goto free;
}
/* UUID for RM */
if (conf->rm_uuid == NULL) {
- ERROR("conf->rm_uuid == NULL");
+ LOG(LOG_ERR, "conf->rm_uuid == NULL");
} else if (conf->rm_uuid->status == OPENPTS_UUID_FILENAME_ONLY) {
rc = genOpenptsUuid(conf->rm_uuid);
// TODO
/* save/update rm_uuid file */
rc = writeOpenptsUuidFile(conf->rm_uuid, 1); // TODO overwite?
if (rc != PTS_SUCCESS) {
- ERROR("writeOpenptsUuidFile fail\n");
+ LOG(LOG_ERR, "writeOpenptsUuidFile fail\n");
}
/* RM set DIR */
rc = makeRmSetDir(conf);
if (rc != PTS_SUCCESS) {
- fprintf(stderr, NLS(MS_OPENPTS, OPENPTS_COLLECTOR_MKDIR_RM_SET_FAILED,
+ ERROR(NLS(MS_OPENPTS, OPENPTS_COLLECTOR_MKDIR_RM_SET_FAILED,
"Failed to create the reference manifest set directory\n"));
goto free;
}
/* load current IML using FSMs */
if (conf->iml_mode == 0) { // TODO use def
#ifdef CONFIG_NO_TSS
- ERROR("Build with --without-tss. iml.mode=tss is not supported\n");
+ LOG(LOG_ERR, "Build with --without-tss. iml.mode=tss is not supported\n");
#else
rc = getIml(ctx, 0);
rc = getPcr(ctx);
conf->bios_iml_filename, conf->iml_endian);
if (rc != PTS_SUCCESS) {
DEBUG("getBiosImlFile() was failed\n");
- ERROR("Oops! Something is wrong. Please see the reason below\n");
+ LOG(LOG_ERR, "Oops! Something is wrong. Please see the reason below\n");
printReason(ctx, 0);
goto free;
}
conf->runtime_iml_filename,
conf->runtime_iml_type, 0, &count); // TODO endian?
if (rc != PTS_SUCCESS) {
- ERROR("read IMA IML, %s was failed\n", conf->runtime_iml_filename);
+ LOG(LOG_ERR, "read IMA IML, %s was failed\n", conf->runtime_iml_filename);
rc = PTS_INTERNAL_ERROR;
goto free;
}
}
} else {
- ERROR("unknown IML mode, %d\n", conf->iml_mode);
+ LOG(LOG_ERR, "unknown IML mode, %d\n", conf->iml_mode);
}
/* get SMBIOS data */
if (conf->rm_filename[i] != NULL) {
rc = writeRm(ctx, conf->rm_filename[i], i);
if (rc != PTS_SUCCESS) {
- ERROR("write RM, %s was failed\n", conf->rm_filename[i]);
+ LOG(LOG_ERR, "write RM, %s was failed\n", conf->rm_filename[i]);
rc = PTS_INTERNAL_ERROR;
goto free;
}
OUTPUT(NLS(MS_OPENPTS, OPENPTS_NEW_RM_RM, "level %d Reference Manifest: %s\n"), i, conf->rm_filename[i]);
} else {
- ERROR("missing RM file for level %d\n", i);
+ LOG(LOG_ERR, "missing RM file for level %d\n", i);
}
}
// OUTPUT("\nptsc is successfully initialized!\n");
" Runtime IML file: %s\n"
" PCR file: %s\n"), conf->bios_iml_filename, conf->runtime_iml_filename, conf->pcrs_filename);
} else {
- ERROR("unknown IML mode, %d\n", conf->iml_mode);
+ LOG(LOG_ERR, "unknown IML mode, %d\n", conf->iml_mode);
}
/* Linux IMA mode */
/* Models */
rc = readFsmFromPropFile(ctx, conf->config_file);
if (rc != PTS_SUCCESS) {
- ERROR("read FSM failed\n");
+ LOG(LOG_ERR, "read FSM failed\n");
goto free;
}
/* check */
if (conf == NULL) {
- ERROR("conf == NULL");
+ LOG(LOG_ERR, "conf == NULL");
return PTS_FATAL;
}
if (conf->config_dir == NULL) {
- ERROR("conf->config_dir == NULL");
+ LOG(LOG_ERR, "conf->config_dir == NULL");
return PTS_FATAL;
}
/* clear */
if (isatty(STDIN_FILENO) && (force == 0) ) {
char *lineFeed;
- printf(NLS(MS_OPENPTS, OPENPTS_COLLECTOR_CLEAR,
+ OUTPUT(NLS(MS_OPENPTS, OPENPTS_COLLECTOR_CLEAR,
"Clear the PTS collector [y/N]:"));
if ( NULL != fgets(ans, 32, stdin) ) {
// strip the ending line-feed
rc = unlinkDir(conf->config_dir);
if (rc != PTS_SUCCESS) {
- ERROR("unlinkDir(%s) fail", conf->config_dir);
+ LOG(LOG_ERR, "unlinkDir(%s) fail", conf->config_dir);
}
OUTPUT(NLS(MS_OPENPTS, OPENPTS_COLLECTOR_CLEAR_YES_DONE,
"%s has been cleared\n\n") , conf->config_dir);
for (i = 0; i < num; i++) {
target = &list->target[i];
if (target == NULL) {
- ERROR("no memory cnt=%d\n", i);
+ LOG(LOG_ERR, "no memory cnt=%d\n", i);
} else {
if (target->uuid != NULL) freeUuid(target->uuid);
if (target->str_uuid != NULL) xfree(target->str_uuid);
/* check */
if (conf == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
level = strtoul(levelStr, &attributeName, 10);
if (levelStr == attributeName) {
- ERROR("readPtsConfig_CompID()- invalid level number ('%s')\n", name);
+ LOG(LOG_ERR, "readPtsConfig_CompID()- invalid level number ('%s')\n", name);
return PTS_FATAL;
}
if (*attributeName != '.') {
- ERROR("readPtsConfig_CompID()- missing '.' after level ('%s')\n", name);
+ LOG(LOG_ERR, "readPtsConfig_CompID()- missing '.' after level ('%s')\n", name);
return PTS_FATAL;
}
/******************/
if (level >= MAX_RM_NUM) {
- ERROR("readPtsConfig_CompID()- trying to affect a CompID(%s) to a level(%d) greater than MAX_RM_NUM(%d)\n",
+ LOG(LOG_ERR, "readPtsConfig_CompID()- trying to affect a CompID(%s) to a level(%d) greater than MAX_RM_NUM(%d)\n",
attributeName, level, MAX_RM_NUM);
return PTS_FATAL;
}
conf->compIDs[level].VendorID_type = VENDORID_TYPE_GUID;
attributeValue = &conf->compIDs[level].VendorID_Value;
} else {
- ERROR("unknown Component ID attribute: '%s'\n", attributeName);
+ LOG(LOG_ERR, "unknown Component ID attribute: '%s'\n", attributeName);
return PTS_FATAL;
}
DEBUG("readPtsConfig() : %s\n", filename);
if (filename == NULL) {
- ERROR("readPtsConfig - filename is NULL\n");
+ LOG(LOG_ERR, "readPtsConfig - filename is NULL\n");
return PTS_INTERNAL_ERROR;
}
/* => get fullpath */
path = getenv("PWD");
if (path[0] != '/') {
- ERROR("readPtsConfig() - path, '%s' is not a full path", path);
+ LOG(LOG_ERR, "readPtsConfig() - path, '%s' is not a full path", path);
}
filename2 = getFullpathName(path, filename);
} else {
/* check for line length */
if (line_len == LINE_BUF_SIZE) {
- ERROR("Line too long in %s at line %d\n", filename2, cnt);
+ LOG(LOG_ERR, "Line too long in %s at line %d\n", filename2, cnt);
isFileIncorrect = 1;
goto free;
}
} else if (!strncmp(value, "tss", 3)) {
conf->iml_mode = 0;
} else {
- ERROR("iml.mode is neither 'securityfs' or 'tss'\n");
+ LOG(LOG_ERR, "iml.mode is neither 'securityfs' or 'tss'\n");
isFileIncorrect = 1;
goto free;
}
conf->srk_password_mode = 1;
DEBUG("conf->srk_password_mode : known\n");
} else {
- ERROR("Bad srk.password.mode flag '%s' in %s\n",
+ LOG(LOG_ERR, "Bad srk.password.mode flag '%s' in %s\n",
value, filename);
isFileIncorrect = 1;
goto free;
conf->tpm_resetdalock = 0; // default
DEBUG("conf->tpm_resetdalock : off (default)\n");
} else {
- ERROR("Bad tpm.resetdalock flag '%s' in %s\n",
+ LOG(LOG_ERR, "Bad tpm.resetdalock flag '%s' in %s\n",
value, filename);
isFileIncorrect = 1;
goto free;
conf->tpm_quote_type = 1;
DEBUG("conf->tpm_quote_type : quote\n");
} else {
- ERROR("Bad tpm.quote.type flag %s\n", value);
+ LOG(LOG_ERR, "Bad tpm.quote.type flag %s\n", value);
isFileIncorrect = 1;
goto free;
}
DEBUG("endian mode : convert\n");
#endif
} else {
- ERROR("iml.endian is neither 'big' or 'little'\n");
+ LOG(LOG_ERR, "iml.endian is neither 'big' or 'little'\n");
isFileIncorrect = 1;
goto free;
}
} else if (!strncmp(value, "IMA", 3)) {
conf->runtime_iml_type = BINARY_IML_TYPE_IMA_ORIGINAL;
} else {
- ERROR("unknown runtime.iml.type %s\n", value);
+ LOG(LOG_ERR, "unknown runtime.iml.type %s\n", value);
isFileIncorrect = 1;
goto free;
}
if (!strncmp(name, "rm.num", 6)) {
conf->rm_num = atoi(value);
if (conf->rm_num > MAX_RM_NUM) {
- ERROR("RM number rm.num=%d is larger than MAX_RM_NUM=%d - truncking\n", conf->rm_num, MAX_RM_NUM);
+ LOG(LOG_ERR, "RM number rm.num=%d is larger than MAX_RM_NUM=%d - truncking\n", conf->rm_num, MAX_RM_NUM);
conf->rm_num = MAX_RM_NUM;
}
DEBUG("conf->rm_num : %d\n", conf->rm_num);
}
conf->ir_filename = getFullpathName(conf->config_dir, value);
DEBUG("conf->ir_filename : %s\n", conf->ir_filename);
- // ERROR("ir.file is obsolute, please use ir.dir"); /// Collectror TODO
+ // LOG(LOG_ERR, "ir.file is obsolute, please use ir.dir"); /// Collectror TODO
}
/* IR dir (collector side) */
if (!strncmp(name, "ir.dir", 6)) {
if (!strncmp(name, "ir.quote", 8)) {
if (!strncmp(value, "WITHOUT_QUOTE", 13)) {
conf->ir_without_quote = 1;
- TODO("Generate IR without TPM_Quote signature\n");
+ LOG(LOG_TODO, "Generate IR without TPM_Quote signature\n");
}
}
#if 0
if (!strncmp(name, "config.dir", 10)) {
if (conf->config_dir != NULL) {
- TODO("conf dir %s ->%s\n", conf->config_dir, value);
+ LOG(LOG_TODO, "conf dir %s ->%s\n", conf->config_dir, value);
//
} else {
conf->config_dir = getFullpathName(config_path, value);
} else if (!strncmp(value, "none", 4)) {
conf->ima_validation_mode = OPENPTS_VALIDATION_MODE_NONE;
} else {
- ERROR("unknown ima.validation.mode [%s]\n", value);
+ LOG(LOG_ERR, "unknown ima.validation.mode [%s]\n", value);
isFileIncorrect = 1;
goto free;
}
DEBUG("conf->uuid->str : %s\n", conf->uuid->str);
}
} else if (!strncmp(name, "uuid", 4)) {
- ERROR("uuid=XXX is deprecated, in %s\n", filename);
+ LOG(LOG_ERR, "uuid=XXX is deprecated, in %s\n", filename);
if (conf->uuid == NULL) {
conf->uuid = newOpenptsUuid();
}
if (conf->uuid->uuid != NULL) {
- TODO("free conf->uuid \n");
+ LOG(LOG_TODO, "free conf->uuid \n");
xfree(conf->uuid->uuid);
}
/* set */
conf->uuid->uuid = getUuidFromString(value);
if (conf->uuid->uuid == NULL) {
- ERROR("read UUID fail\n");
+ LOG(LOG_ERR, "read UUID fail\n");
}
conf->uuid->str = getStringOfUuid(conf->uuid->uuid);
if (conf->uuid->str == NULL) {
- ERROR("read UUID fail\n");
+ LOG(LOG_ERR, "read UUID fail\n");
}
}
}
conf->target_uuid = getUuidFromString(value);
if (conf->target_uuid == NULL) {
- ERROR("bad UUID ? %s\n", value);
+ LOG(LOG_ERR, "bad UUID ? %s\n", value);
} else {
// add string too
if (conf->str_target_uuid != NULL) {
}
conf->str_target_uuid = getStringOfUuid(conf->target_uuid);
if (conf->str_target_uuid == NULL) {
- ERROR("bad UUID ? %s\n", value);
+ LOG(LOG_ERR, "bad UUID ? %s\n", value);
}
}
}
strlen(value),
&buf_len);
if (conf->pubkey == NULL) {
- ERROR("decodeBase64");
+ LOG(LOG_ERR, "decodeBase64");
conf->pubkey_length = 0;
} else {
conf->pubkey_length = buf_len;
} else if (!strncmp(value, "off", 3)) {
conf->selftest = 0; // default
} else {
- ERROR("unknown selftest %s\n", value);
+ LOG(LOG_ERR, "unknown selftest %s\n", value);
isFileIncorrect = 1;
goto free;
}
conf->autoupdate = 0; // default
DEBUG("conf->autoupdate : off\n");
} else {
- ERROR("unknown autoupdate %s\n", value); // TODO
+ LOG(LOG_ERR, "unknown autoupdate %s\n", value); // TODO
isFileIncorrect = 1;
goto free;
}
conf->enrollment = IMV_ENROLLMENT_AUTO;
DEBUG("conf->enrollment : auto\n");
} else {
- ERROR("unknown enrollment %s\n", value); // TODO
+ LOG(LOG_ERR, "unknown enrollment %s\n", value); // TODO
conf->enrollment = 0;
}
}
conf->aik_storage_type = OPENPTS_AIK_STORAGE_TYPE_BLOB;
DEBUG("conf->aik_storage_type : blob\n");
} else {
- ERROR("unknown aik.storage.type %s\n", value); // TODO
+ LOG(LOG_ERR, "unknown aik.storage.type %s\n", value); // TODO
conf->aik_storage_type = 0;
}
}
conf->aik_auth_type = OPENPTS_AIK_AUTH_TYPE_COMMON;
DEBUG("conf->aik_auth_type : common\n");
} else {
- ERROR("unknown aik.auth.type %s\n", value); // TODO
+ LOG(LOG_ERR, "unknown aik.auth.type %s\n", value); // TODO
conf->aik_auth_type = 0;
}
}
DEBUG("Logging location : syslog\n");
} else if (!strncmp(value, "console", 6)) {
setLogLocation(OPENPTS_LOG_CONSOLE, NULL);
- DEBUG("Logging location : syslog\n");
+ DEBUG("Logging location : console\n");
} else {
- ERROR("unknown aik.storage.type %s\n", value); // TODO
+ LOG(LOG_ERR, "unknown aik.storage.type %s\n", value); // TODO
conf->aik_storage_type = 0;
}
}
DEBUG("Logging location : file (%s)\n", log_filename);
xfree(log_filename);
}
+ if (!strncmp(name, "debug.mode", 11)) {
+ debugBits = (int) strtol(value, NULL, 16);
+ DEBUG("DEBUG mode : 0x%x\n", debugBits);
+ }
cnt++;
} else {
ptr = line;
while (*ptr != '\0') {
if (!isspace(*ptr)) {
- ERROR("Syntax error in %s at line %d\n", filename2, cnt);
+ LOG(LOG_ERR, "Syntax error in %s at line %d\n", filename2, cnt);
isFileIncorrect = 1;
goto free;
}
/* open */
if ((fp = fopen(filename, "w")) == NULL) {
- ERROR("writeTargetConf - Conf File %s open was failed\n", filename);
+ LOG(LOG_ERR, "writeTargetConf - Conf File %s open was failed\n", filename);
return -1;
}
rc = readPtsConfig(conf, filename);
if (rc != PTS_SUCCESS) {
- ERROR("readTargetConf - fail, rc = %d\n", rc);
+ LOG(LOG_ERR, "readTargetConf - fail, rc = %d\n", rc);
}
return rc;
/* open */
if ((fp = fopen(filename, "w")) == NULL) {
- ERROR("writeOpenptsConf - Conf File %s open was failed\n", filename);
+ LOG(LOG_ERR, "writeOpenptsConf - Conf File %s open was failed\n", filename);
return PTS_INTERNAL_ERROR;
}
/* check */
if (conf == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
if (filename == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
rc = readPtsConfig(conf, filename);
if (rc < 0) {
- ERROR("readOpenptsConf - fail, rc = %d\n", rc);
+ LOG(LOG_ERR, "readOpenptsConf - fail, rc = %d\n", rc);
}
return rc;
int setModelFile(OPENPTS_CONFIG *conf, int index, int level, char *filename) {
/* check */
if (conf == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
if (level >= MAX_RM_NUM) {
- ERROR("setModelFile()- PCR[%d] trying to affect a model file(%s) to a level(%d) greater than MAX_RM_NUM(%d)\n",
+ LOG(LOG_ERR,
+ "setModelFile()- PCR[%d] trying to affect a model file(%s) to a level(%d) greater than MAX_RM_NUM(%d)\n",
index, filename, level, MAX_RM_NUM);
return PTS_FATAL;
}
} else if (type == ALGTYPE_MD5) {
return "md5";
} else {
- ERROR("unknown type %d\n", type);
+ LOG(LOG_ERR, "unknown type %d\n", type);
return NULL;
}
}
/* check for line length */
if (len == FSM_BUF_SIZE) {
- ERROR("Line too long in %s\n", filename);
- OUTPUT(NLS(MS_OPENPTS, OPENPTS_COLLECTOR_BAD_CONFIG_FILE, "Bad configuration file\n"));
+ LOG(LOG_ERR, "Line too long in %s\n", filename);
+ OUTPUT(NLS(MS_OPENPTS, OPENPTS_CONFIG_BAD_CONFIG_FILE, "Bad configuration file\n"));
rc = PTS_FATAL;
goto error;
}
#if 1
// Using config file <= version 0.2.3
if (strstr(buf, "platform.model.") != NULL) {
- ERROR("ptsc.conf has old format <=v0.2.3 %s\n", filename);
- ERROR("change platform.model to rm.model.0\n");
+ LOG(LOG_ERR, "ptsc.conf has old format <=v0.2.3 %s\n", filename);
+ LOG(LOG_ERR, "change platform.model to rm.model.0\n");
OUTPUT(NLS(MS_OPENPTS, OPENPTS_COLLECTOR_BAD_CONFIG_FILE, "Bad configuration file\n"));
rc = PTS_FATAL;
goto error;
}
if (strstr(buf, "runtime.model.") != NULL) {
- ERROR("ptsc.conf has old format <=v0.2.3 %s\n", filename);
- ERROR("change runtime.model to rm.model.1\n");
+ LOG(LOG_ERR, "ptsc.conf has old format <=v0.2.3 %s\n", filename);
+ LOG(LOG_ERR, "change runtime.model to rm.model.1\n");
OUTPUT(NLS(MS_OPENPTS, OPENPTS_COLLECTOR_BAD_CONFIG_FILE, "Bad configuration file\n"));
rc = PTS_FATAL;
goto error;
rc = readUmlModel(fsm, buf2);
// TODO(munetoh) cehck rc
if (rc != PTS_SUCCESS) {
- ERROR("addFsmByPropFile - [%s] / [%s] -> [%s] fail rc=%d, pwd = %s\n",
+ LOG(LOG_ERR, "addFsmByPropFile - [%s] / [%s] -> [%s] fail rc=%d, pwd = %s\n",
conf->model_dir, model_filename, buf2, rc,
getenv("PWD"));
goto error; // return -1;
/* setup the NEW snapshots, BIOS, GRUB */
ss = getNewSnapshotFromTable(ctx->ss_table, pcr_index, level);
if (ss == NULL) {
- ERROR("FSM has been assigned at lvl=%d pcr=%d %s. check the config file\n",
+ LOG(LOG_ERR, "FSM has been assigned at lvl=%d pcr=%d %s. check the config file\n",
level, pcr_index, buf);
rc = PTS_FATAL;
goto error;
ptr = buf;
while (*ptr != '\0') {
if (!isspace(*ptr)) {
- ERROR("Syntax error in %s\n", filename);
+ LOG(LOG_ERR, "Syntax error in %s\n", filename);
OUTPUT(NLS(MS_OPENPTS, OPENPTS_COLLECTOR_BAD_CONFIG_FILE, "Bad configuration file\n"));
rc = PTS_FATAL;
goto error;
/* malloc */
ctx = (OPENPTS_FSM_CONTEXT *) xmalloc(sizeof(OPENPTS_FSM_CONTEXT));
if (ctx == NULL) {
- ERROR("no memory");
+ LOG(LOG_ERR, "no memory");
return NULL;
}
/* init */
void freeFsmTransitionChain(OPENPTS_FSM_Transition *fsm_trans) {
/* check */
if (fsm_trans == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return;
}
/* check */
if (fsm_sub == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return;
}
/* check */
if (ctx == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
void resetFsmSubvertex(OPENPTS_FSM_CONTEXT *ctx) {
/* check */
if (ctx == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return;
}
void resetFsmTransition(OPENPTS_FSM_CONTEXT *ctx) {
/* check */
if (ctx == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return;
}
/* check */
if (ctx == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return;
}
if (type == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return;
}
if (id == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return;
}
if (name == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return;
}
if (action == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return;
}
ptr_pre->next = ptr; // else
ptr->prev = ptr_pre;
} else {
- ERROR("BAD, free last one");
+ LOG(LOG_ERR, "BAD, free last one");
xfree(ptr); // free last one
return;
}
/* check */
if (ctx == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return NULL;
}
if (id == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return NULL;
}
/* check */
if (ctx == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return NULL;
}
if (id == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return NULL;
}
/* check */
if (ctx == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return NULL;
}
if (name == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return NULL;
}
/* check */
if (str == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return NULL;
}
static int isEndOfString(char *str) {
/* check */
if (str == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return 0; // TODO
}
/* check */
if (str == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return NULL;
}
/* check */
if (cond == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return -1;
}
/* operation */
if (len < 2) {
- ERROR("ERROR 001\n");
+ LOG(LOG_ERR, "ERROR 001\n");
return -1; // end
}
if ((loc[0] == '=') && (loc[1] == '=')) { // ==
} else if ((loc[0] == 'n') && (loc[1] == 'e')) { // !=
rc = 2;
} else {
- ERROR("ERROR 002 %c %c \n", loc[0], loc[1]);
+ LOG(LOG_ERR, "ERROR 002 %c %c \n", loc[0], loc[1]);
return -1; // unknown operand
}
loc += 2;
/* check */
if (cond == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return -1;
}
/* operation, "==" only */
if (len < 2) {
- ERROR("ERROR 001\n");
+ LOG(LOG_ERR, "ERROR 001\n");
return -1; // end
}
if ((loc[0] == '=') && (loc[1] == '=')) { // ==
// operand is ==
} else {
- ERROR("ERROR 002 [%c%c] not ==, (cond = %s)\n", loc[0], loc[1], cond);
+ LOG(LOG_ERR, "ERROR 002 [%c%c] not ==, (cond = %s)\n", loc[0], loc[1], cond);
return -1; // unknown operand
}
loc +=2;
SHA1_BASE64_DIGEST_SIZE,
&buf_len);
if (buf == NULL) {
- ERROR("decodeBase64 fail");
+ LOG(LOG_ERR, "decodeBase64 fail");
*digest = NULL;
*digest_size = 0;
return -1;
*digest_size = SHA1_DIGEST_SIZE;
return DIGEST_FLAG_EQUAL; // 1
} else {
- ERROR("getDigestFlag() - decodeBase64() was failed \n");
+ LOG(LOG_ERR, "getDigestFlag() - decodeBase64() was failed \n");
xfree(buf);
*digest = NULL;
*digest_size = 0;
/* check */
if (cond == NULL) {
- ERROR("Null condition found");
+ LOG(LOG_ERR, "Null condition found");
return 0;
}
if (name == NULL) {
- ERROR("Null condition found");
+ LOG(LOG_ERR, "Null condition found");
return 0;
}
loc +=2;
len -=2;
} else {
- ERROR("unknown operand [%s]", &loc[0]);
+ LOG(LOG_ERR, "unknown operand [%s]", &loc[0]);
goto error; //return -1;
}
return rc;
error:
- ERROR("getCounterFlag(\"%s\",\"%s\") fail", cond, name);
+ LOG(LOG_ERR, "getCounterFlag(\"%s\",\"%s\") fail", cond, name);
return -1;
}
/* check */
if (cond == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return -1;
}
loc +=2;
len -=2;
} else {
- ERROR("Unknown operation [%s], cond=[%s], BAD Validation Model\n", &loc[0], cond);
+ LOG(LOG_ERR, "Unknown operation [%s], cond=[%s], BAD Validation Model\n", &loc[0], cond);
return -1;
}
loc = skipWhiteSpace(loc, &len);
if (isEndOfString(loc)) {
- ERROR("Unknown operation [%s]\n", &loc[0]);
+ LOG(LOG_ERR, "Unknown operation [%s]\n", &loc[0]);
return -1;
}
rc = LAST_FLAG_EQ;
}
} else {
- ERROR("unknown value, %s\n", loc2);
+ LOG(LOG_ERR, "unknown value, %s\n", loc2);
}
}
/* check */
if (ctx == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
if (source == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
if (target == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
if (cond == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
ptr = (OPENPTS_FSM_Transition *)
xmalloc(sizeof(OPENPTS_FSM_Transition));
if (ptr == NULL) {
- ERROR("no memory");
+ LOG(LOG_ERR, "no memory");
return PTS_INTERNAL_ERROR;
}
/* init */
// 0:don't care, 1:<, 2:>=
ptr->counter_flag = getCounterFlag(cond, "digest_count", &ptr->counter_name);
if (ptr->counter_flag < 0) {
- ERROR("getCounterFlag() fail (%s => %s [%s])", source, target, cond);
+ LOG(LOG_ERR, "getCounterFlag() fail (%s => %s [%s])", source, target, cond);
}
// 0:don't care, 1:<, 2:>=
ptr->fatal_counter_flag = getCounterFlag(cond, "fatal_count", &ptr->fatal_counter_name);
if (ptr->fatal_counter_flag < 0) {
- ERROR("getCounterFlag() fail (%s => %s [%s])", source, target, cond);
+ LOG(LOG_ERR, "getCounterFlag() fail (%s => %s [%s])", source, target, cond);
}
// 0:don't care 1: ==last 2: != last
ptr->last_flag = getLastFlag(cond);
ptr->prev = ptr_pre;
ptr->next = NULL; // last trans
} else {
- ERROR("BAD, free last one");
+ LOG(LOG_ERR, "BAD, free last one");
xfree(ptr); // free last one
return PTS_INTERNAL_ERROR;
}
ptr = (OPENPTS_FSM_Transition *)ptr->next;
}
- ERROR("missing?\n");
+ LOG(LOG_ERR, "missing?\n");
return PTS_INTERNAL_ERROR;
}
if (event != NULL) {
// len = snprintf(buf, size, "PCR[%d],TYPE=%d", (int)event->ulPcrIndex, event->eventType);
} else {
- ERROR("NULL event\n"); // TODO(munetoh)
+ LOG(LOG_ERR, "NULL event\n"); // TODO(munetoh)
xfree(buf);
return NULL;
}
/* check */
if (ctx == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return -1;
}
if (name == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return -1;
}
/* check */
if (ctx == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
if (fsm == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
/* push */
rc = updateFsm(ctx, fsm, eventWrapper);
if (rc == OPENPTS_FSM_ERROR) {
- ERROR("updateFsm() - updateFsm push was fail\n");
+ LOG(LOG_ERR, "updateFsm() - updateFsm push was fail\n");
}
if (rc == OPENPTS_FSM_ERROR_LOOP) {
// DEBUG("updateFsm -- updateFsm push - loop \n");
return OPENPTS_FSM_ERROR_LOOP;
}
} else {
- ERROR("missing event body\n");
+ LOG(LOG_ERR, "missing event body\n");
return OPENPTS_FSM_ERROR;
}
} else {
if (rc == OPENPTS_FSM_FINISH_WO_HIT) {
rc = OPENPTS_FSM_FINISH;
} else {
- ERROR("updateFsm - flash FSM was failed\n");
+ LOG(LOG_ERR, "updateFsm - flash FSM was failed\n");
rc = OPENPTS_FSM_ERROR;
}
} else if (rc == OPENPTS_FSM_TRANSIT) {
if (rc == OPENPTS_FSM_FINISH_WO_HIT) {
rc = OPENPTS_FSM_TRANSIT;
} else {
- ERROR("updateFsm - FSM did not finish\n");
+ LOG(LOG_ERR, "updateFsm - FSM did not finish\n");
rc = OPENPTS_FSM_ERROR;
}
} else if (rc == OPENPTS_FSM_ERROR) {
- ERROR("updateFsm - FSM doActivity False\n");
+ LOG(LOG_ERR, "updateFsm - FSM doActivity False\n");
return rc;
} else if (rc == OPENPTS_FSM_MIGRATE_EVENT) {
- TODO("updateFsm - OPENPTS_FSM_MIGRATE_EVENT \n");
+ LOG(LOG_TODO, "updateFsm - OPENPTS_FSM_MIGRATE_EVENT \n");
return rc;
} else if (rc == OPENPTS_FSM_SUCCESS) {
rc = updateFsm(ctx, fsm, eventWrapper);
// TODO << INFO:(TODO) action.c:97 addBIOSAction() - eventWrapper is NULL
rc = updateFsm(ctx, fsm, eventWrapper);
} else {
- TODO("updateFsm() - rc = %d, call updateFsm() again\n", rc);
+ LOG(LOG_TODO, "updateFsm() - rc = %d, call updateFsm() again\n", rc);
rc = updateFsm(ctx, fsm, eventWrapper);
}
} // curr state
} else { // hit
- TODO("no trans\n");
+ LOG(LOG_TODO, "no trans\n");
}
} else {
/* check trans chain */
int fatal_count = getCountFromProperty(ctx, trans->fatal_counter_name);
if (fatal_count < 0) {
- ERROR("getCountFromProperty() fail");
+ LOG(LOG_ERR, "getCountFromProperty() fail");
} else if (ctx->count < fatal_count) {
DEBUG_FSM("FATAL COUNTER %d < %d - HIT\n", ctx->count, fatal_count);
fatal_counter_check = 1; // HIT
// TODO at this moment we ignore >= condition,
if (fatal_count < 0) {
- ERROR("getCountFromProperty() fail");
+ LOG(LOG_ERR, "getCountFromProperty() fail");
} else if (ctx->count >= fatal_count) {
DEBUG_FSM("FATAL COUNTER %d >= %d - HIT\n", ctx->count, fatal_count);
fatal_counter_check = 1; // HIT
int thisCount = 1 + trans->event_num;
int maxCount = getCountFromProperty(ctx, trans->counter_name);
if (maxCount < 0) {
- ERROR("getCountFromProperty() fail, trans->counter_flag=%d", trans->counter_flag);
+ LOG(LOG_ERR, "getCountFromProperty() fail, trans->counter_flag=%d", trans->counter_flag);
} else if (trans->counter_flag == COUNTER_FLAG_GE &&
thisCount >= maxCount) {
DEBUG_FSM("DIGEST COUNTER %d >= %d ('%s') - digest is transparent\n",
/* Final state */
DEBUG_FSM("\tPCR[%d] level %d, Final state!! move to the next snapshot\n",
fsm->pcr_index, fsm->level);
- // ERROR("PCR[%d] level %d, Final\n", fsm->pcr_index, fsm->level);
+ // LOG(LOG_ERR, "PCR[%d] level %d, Final\n", fsm->pcr_index, fsm->level);
fsm->status = OPENPTS_FSM_FINISH;
return OPENPTS_FSM_FINISH_WO_HIT; // FINAL
}
if (rc == OPENPTS_FSM_FINISH_WO_HIT) {
rc = OPENPTS_FSM_FINISH;
} else {
- ERROR("flash FSM was failed\n");
+ LOG(LOG_ERR, "flash FSM was failed\n");
rc = OPENPTS_FSM_ERROR;
}
} else if (rc == OPENPTS_FSM_TRANSIT) {
if (rc == OPENPTS_FSM_FINISH_WO_HIT) {
rc = OPENPTS_FSM_TRANSIT;
} else {
- ERROR("updateFsm - FSM did not finish\n");
+ LOG(LOG_ERR, "updateFsm - FSM did not finish\n");
rc = OPENPTS_FSM_ERROR;
}
} else if (rc == OPENPTS_FSM_ERROR) {
fsm->pcr_index, (char *)fsm->curr_state->action, fsm->curr_state->name);
return rc;
} else if (rc == OPENPTS_FSM_MIGRATE_EVENT) {
- TODO("updateFsm - OPENPTS_FSM_MIGRATE_EVENT \n");
+ LOG(LOG_TODO, "updateFsm - OPENPTS_FSM_MIGRATE_EVENT \n");
return rc;
} else if (rc == OPENPTS_FSM_SUCCESS) {
rc = updateFsm(ctx, fsm, eventWrapper);
} else {
- TODO("rc = %d\n", rc);
+ LOG(LOG_TODO, "rc = %d\n", rc);
rc = updateFsm(ctx, fsm, eventWrapper);
}
}
if (rc == OPENPTS_FSM_FINISH_WO_HIT) {
rc = OPENPTS_FSM_FINISH;
} else {
- ERROR("updateFsm - flash FSM was failed, rc = %d\n", rc);
+ LOG(LOG_ERR, "updateFsm - flash FSM was failed, rc = %d\n", rc);
rc = OPENPTS_FSM_ERROR;
}
} else if (rc == OPENPTS_FSM_TRANSIT) {
if (rc == OPENPTS_FSM_FINISH_WO_HIT) {
rc = OPENPTS_FSM_TRANSIT;
} else {
- ERROR("updateFsm - FSM did not finish\n");
+ LOG(LOG_ERR, "updateFsm - FSM did not finish\n");
rc = OPENPTS_FSM_ERROR;
}
} else if (rc == OPENPTS_FSM_ERROR) {
- ERROR("updateFsm - FSM doActivity False, rc = %d\n", rc);
+ LOG(LOG_ERR, "updateFsm - FSM doActivity False, rc = %d\n", rc);
return rc;
} else if (rc == OPENPTS_FSM_MIGRATE_EVENT) {
// DEBUG("updateFsm - OPENPTS_FSM_MIGRATE_EVENT \n");
rc = OPENPTS_FSM_SUCCESS;
}
} else {
- ERROR("curr_state is NULL, missing %s\n", trans->target);
+ LOG(LOG_ERR, "curr_state is NULL, missing %s\n", trans->target);
rc = OPENPTS_FSM_ERROR;
return rc;
}
count = 0;
src_fsm_sub = src_fsm->fsm_sub;
if (src_fsm_sub == NULL) {
- ERROR("ERROR No FSM SUB\n");
+ LOG(LOG_ERR, "ERROR No FSM SUB\n");
goto error;
}
src_fsm_trans = src_fsm->fsm_trans;
if (src_fsm_trans == NULL) {
- ERROR("ERROR No FSM TRANS\n");
+ LOG(LOG_ERR, "ERROR No FSM TRANS\n");
goto error;
}
if (src_fsm_sub != NULL) {
dst_fsm_trans->source_subvertex = src_fsm_sub->link;
} else {
- ERROR("ERROR BHV trans %s source_subvertex is NULL\n",
+ LOG(LOG_ERR, "ERROR BHV trans %s source_subvertex is NULL\n",
src_fsm_trans->source);
}
/* check */
if (fsm_ctx == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
if (old_sub == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
if (new_sub == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
/* check */
if (fsm_ctx == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
if (old_sub == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
if (new_sub == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
/* check input */
if (fsm_ctx == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return -1;
}
if (fsm_trans == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return -1;
}
if (eventWrapper == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return -1;
}
event = eventWrapper->event;
if (event == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return -1;
}
if (fsm_trans->source_subvertex == NULL) {
- ERROR("ERROR fsm_trans->source_subvertex == NULL, %s -> %s\n",
+ LOG(LOG_ERR, "ERROR fsm_trans->source_subvertex == NULL, %s -> %s\n",
fsm_trans->source, fsm_trans->target);
return -1;
}
if (fsm_trans->target_subvertex == NULL) {
- ERROR("ERROR fsm_trans->target_subvertex == NULL\n");
+ LOG(LOG_ERR, "ERROR fsm_trans->target_subvertex == NULL\n");
return -1;
}
DEBUG_FSM("\tUpdate Trans BIN(%s -> %s)\n",
fsm_trans->source, fsm_trans->target);
} else {
- ERROR("BAD LOOP");
+ LOG(LOG_ERR, "BAD LOOP");
return PTS_FATAL;
}
} else {
- ERROR("Not a loop");
+ LOG(LOG_ERR, "Not a loop");
return PTS_FATAL;
}
/* check */
if (fsm_ctx == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
if (trans == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
/* check */
if (fsm_ctx == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
if (sub == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
/* check */
if (fsm_ctx == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
trans = fsm_ctx->fsm_trans;
if (trans == NULL) {
- ERROR("ERROR No FSM TRANS\n");
+ LOG(LOG_ERR, "ERROR No FSM TRANS\n");
return -1;
}
trans->source, trans->target);
rc = removeFsmTrans(fsm_ctx, trans); // remove Trans
if (rc < 0) {
- ERROR("removeFsmTrans of %s -> %s was failed\n",
+ LOG(LOG_ERR, "removeFsmTrans of %s -> %s was failed\n",
trans->source, trans->target);
return -1;
}
/* Delete state which does not have incomming trans */
sub = fsm_ctx->fsm_sub;
if (sub == NULL) {
- ERROR("ERROR No FSM SUB\n");
+ LOG(LOG_ERR, "ERROR No FSM SUB\n");
return -1;
}
trans = fsm_ctx->fsm_trans;
if (trans == NULL) {
- ERROR("No FSM TRANS\n");
+ LOG(LOG_ERR, "No FSM TRANS\n");
return -1;
}
/* check */
if (ctx == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
fp = stdout;
} else {
if ((fp = fopen(filename, "w")) == NULL) {
- ERROR("fopen fail %s\n", filename);
+ LOG(LOG_ERR, "fopen fail %s\n", filename);
return PTS_OS_ERROR;
}
}
/* check */
if (ctx == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return -1;
}
if (filename == NULL) {
- ERROR("writeCsvTable - filename is NULL\n");
+ LOG(LOG_ERR, "writeCsvTable - filename is NULL\n");
return -1;
}
/* check */
if (ctx == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
ptr = ctx->fsm_trans;
for (i = 0; i < ctx->transition_num; i++) {
if (ptr == NULL) {
- ERROR("PTR is NULL at %d\n", i);
+ LOG(LOG_ERR, "PTR is NULL at %d\n", i);
return PTS_FATAL;
}
OUTPUT("%5d ", i);
void htoncl(uint8_t *ptr, uint32_t value) {
/* check */
if (ptr == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return;
}
/* Convert value to network endian */
uint32_t nctohl(uint8_t *ptr) {
/* check */
if (ptr == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return 0;
}
write_size = wrapWrite(out_fd, buf, read_size);
if (write_size < 0) {
- ERROR("\n");
+ LOG(LOG_ERR, "\n");
sum = -1;
break;
}
if (write_size != read_size) {
- ERROR("\n");
+ LOG(LOG_ERR, "\n");
sum = -1;
break;
}
/* check */
if (buf == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return 0;
}
/* malloc TLV for read */
read_tlv = (PTS_IF_M_Attribute *)xmalloc(sizeof(PTS_IF_M_Attribute));
if (read_tlv == NULL) {
- ERROR("no memory");
+ LOG(LOG_ERR, "no memory");
return NULL;
}
memset(read_tlv, 0, sizeof(PTS_IF_M_Attribute));
/* check the length */
if (read_tlv->length > MAX_TLV_MESSAGE_LENGTH) {
- ERROR("read_tlv->length = %d (0x%X)> %d\n",
+ LOG(LOG_ERR, "read_tlv->length = %d (0x%X)> %d\n",
read_tlv->length, read_tlv->length, MAX_TLV_MESSAGE_LENGTH);
goto error;
}
void freePtsTlv(PTS_IF_M_Attribute *tlv) {
/* check */
if (tlv == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return;
}
PTS_IF_M_Attribute *write_tlv;
if ((buf = xmalloc(12 + length)) == NULL) {
- ERROR("no memory");
+ LOG(LOG_ERR, "no memory");
return NULL;
}
/* setup TLV header */
/* check */
if (ctx == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return NULL;
}
conf = ctx->conf;
if (conf == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return NULL;
}
#endif
buf = getTlvBuffer(type, 0);
if (buf == NULL) {
- ERROR("getTlvBuffer() is null");
+ LOG(LOG_ERR, "getTlvBuffer() is null");
goto error;
}
break;
buf = getTlvBuffer(type, length);
if (buf == NULL) {
- ERROR("getTlvBuffer() is null");
+ LOG(LOG_ERR, "getTlvBuffer() is null");
goto error;
}
length = ctx->conf->pubkey_length;
buf = getTlvBuffer(type, length);
if (buf == NULL) {
- ERROR("getTlvBuffer() is null");
+ LOG(LOG_ERR, "getTlvBuffer() is null");
goto error;
}
} else {
/* PUB key is missing */
- ERROR("writePtsTlvToSock - PUBKEY blob is missing\n");
+ LOG(LOG_ERR, "writePtsTlvToSock - PUBKEY blob is missing\n");
ctx->ifm_errno = PTS_FATAL;
ctx->ifm_strerror = smalloc_assert("Public key is missing");
length = 0;
fd[i] = open(ctx->conf->rm_filename[i], O_RDONLY);
if (fd[i] < 0) {
// 20101124 SM must be a fullpath for Daemon
- ERROR("Can't open RM[%d] files, %s\n",
+ LOG(LOG_ERR, "Can't open RM[%d] files, %s\n",
i, ctx->conf->rm_filename[i]);
/* send Error massage */
ctx->ifm_errno = PTS_FATAL;
}
/* size */
if (-1 == fstat(fd[i], &st[i])) {
- ERROR("fstat failed with errno %d\n", errno);
+ LOG(LOG_ERR, "fstat failed with errno %d\n", errno);
goto error;
}
fsize[i] = st[i].st_size;
count[i] = copyfile(&buf[ptr], fd[i], fsize[i]);
if (count[i] != fsize[i]) {
- ERROR("copyfile() faild %d != %d\n", count[i], fsize[i]);
+ LOG(LOG_ERR, "copyfile() faild %d != %d\n", count[i], fsize[i]);
}
/* close */
fd[i] = open(ctx->conf->newrm_filename[i], O_RDONLY);
if (fd[i] < 0) {
// 20101124 SM must be a fullpath for Daemon
- ERROR("Error RM file, %s not found\n", ctx->conf->newrm_filename[i]);
+ LOG(LOG_ERR, "Error RM file, %s not found\n", ctx->conf->newrm_filename[i]);
/* send Error massage */
ctx->ifm_errno = PTS_FATAL;
ctx->ifm_strerror =
}
/* check the size */
if (-1 == fstat(fd[i], &st[i])) {
- ERROR("fstat failed with errno %d\n", errno);
+ LOG(LOG_ERR, "fstat failed with errno %d\n", errno);
goto error;
}
fsize[i] = st[i].st_size;
buf = getTlvBuffer(type, length);
if (buf == NULL) {
- ERROR("getTlvBuffer() is null");
+ LOG(LOG_ERR, "getTlvBuffer() is null");
goto error;
}
ptr = 12;
length = ctx->nonce->nonce_length;
buf = getTlvBuffer(type, length);
if (buf == NULL) {
- ERROR("getTlvBuffer() is null");
+ LOG(LOG_ERR, "getTlvBuffer() is null");
goto error;
}
memcpy(&buf[12], ctx->nonce->nonce, length);
gets closed you lose the IR! */
rc = genIr(ctx, &fd[0]);
if (rc != PTS_SUCCESS) {
- ERROR("writePtsTlvToSock - gen IR failed\n");
+ LOG(LOG_ERR, "writePtsTlvToSock - gen IR failed\n");
/* send Error massage */
ctx->ifm_errno = PTS_FATAL;
ctx->ifm_strerror = smalloc_assert("Generation of IR failed");
/* check the IR size */
if (-1 == fstat(fd[0], &st[0])) {
- ERROR("fstat failed with errno %d\n", errno);
+ LOG(LOG_ERR, "fstat failed with errno %d\n", errno);
goto error;
}
fsize[0] = st[0].st_size;
buf = getTlvBuffer(type, length);
if (buf == NULL) {
- ERROR("getTlvBuffer() is null");
+ LOG(LOG_ERR, "getTlvBuffer() is null");
goto error;
}
ptr = 12;
if (-1 == lseek(fd[0], 0, SEEK_SET)) {
- ERROR("Could not seek to start of %s (fd '%d')\n", ctx->conf->ir_filename, fd[0]);
+ LOG(LOG_ERR, "Could not seek to start of %s (fd '%d')\n", ctx->conf->ir_filename, fd[0]);
goto error;
}
count[0] = copyfile(&buf[ptr], fd[0], fsize[0]);
if (count[0] != fsize[0]) {
- ERROR("copyfile() faild %d != %d\n", count[0], fsize[0]);
+ LOG(LOG_ERR, "copyfile() faild %d != %d\n", count[0], fsize[0]);
}
/* close */
fd[0] = open(ctx->conf->aide_database_filename, O_RDONLY);
if (fd[0] < 0) {
/* AIDE file is missing, erorr */
- ERROR("writePtsTlvToSock - Error AIDE DB file, %s not found\n",
+ LOG(LOG_ERR, "writePtsTlvToSock - Error AIDE DB file, %s not found\n",
ctx->conf->aide_database_filename);
/* send Error massage */
ctx->ifm_errno = PTS_FATAL;
} else {
/* OK */
if (-1 == fstat(fd[0], &st[0])) {
- ERROR("fstat failed with errno %d\n", errno);
+ LOG(LOG_ERR, "fstat failed with errno %d\n", errno);
goto error;
}
fsize[0] = st[0].st_size;
buf = getTlvBuffer(type, length);
if (buf == NULL) {
- ERROR("getTlvBuffer() is null");
+ LOG(LOG_ERR, "getTlvBuffer() is null");
goto error;
}
ptr = 12;
// BODY1
count[0] = copyfile(&buf[ptr], fd[0], fsize[0]);
if (count[0] != fsize[0]) {
- ERROR("copyfile() faild %d != %d\n", count[0], fsize[0]);
+ LOG(LOG_ERR, "copyfile() faild %d != %d\n", count[0], fsize[0]);
}
/* close */
buf = getTlvBuffer(type, length);
if (buf == NULL) {
- ERROR("getTlvBuffer() is null");
+ LOG(LOG_ERR, "getTlvBuffer() is null");
goto error;
}
ptr = 12;
buf = getTlvBuffer(type, length);
if (buf == NULL) {
- ERROR("getTlvBuffer() is null");
+ LOG(LOG_ERR, "getTlvBuffer() is null");
goto error;
}
ptr = 12;
buf = getTlvBuffer(type, length);
if (buf == NULL) {
- ERROR("getTlvBuffer() is null");
+ LOG(LOG_ERR, "getTlvBuffer() is null");
goto error;
}
ptr = 12;
default:
// BAD type
- ERROR("BAD IF-M OPENPTS MESSAGE TYPE, type=0x%x\n", type);
+ LOG(LOG_ERR, "BAD IF-M OPENPTS MESSAGE TYPE, type=0x%x\n", type);
return NULL;
}
/* check */
if (ctx == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return -1;
}
/* send ERROR */
len = writePtsTlv(ctx, fdout, OPENPTS_ERROR);
if (len < 0) {
- ERROR("send OPENPTS_ERROR was faild");
+ LOG(LOG_ERR, "send OPENPTS_ERROR was faild");
}
return -1;
imcID, minVersion, maxVersion);
if (initialized) {
- ERROR("not initialized");
+ LOG(LOG_ERR, "not initialized");
return TNC_RESULT_ALREADY_INITIALIZED;
}
/* check version - Only support version 1 */
if ((minVersion < TNC_IFIMC_VERSION_1) ||
(maxVersion > TNC_IFIMC_VERSION_1)) {
- ERROR("no common version");
+ LOG(LOG_ERR, "no common version");
return TNC_RESULT_NO_COMMON_VERSION;
}
/* initialize PTS Collector */
conf = newPtsConfig();
if (conf == NULL) {
- ERROR("no memory");
+ LOG(LOG_ERR, "no memory");
rc = TNC_RESULT_FATAL;
goto error;
}
ctx = newPtsContext(conf);
if (ctx == NULL) {
- ERROR("no memory\n");
+ LOG(LOG_ERR, "no memory\n");
rc = TNC_RESULT_FATAL;
goto error;
}
/* configure PTS Collector */
rc = readPtsConfig(conf, PTSC_CONFIG_FILE);
if (rc != PTS_SUCCESS) {
- ERROR("read config file, '%s' was failed - abort\n", PTSC_CONFIG_FILE);
+ LOG(LOG_ERR, "read config file, '%s' was failed - abort\n", PTSC_CONFIG_FILE);
rc = TNC_RESULT_FATAL;
goto error;
}
/* check IR dir */
if (checkDir(conf->ir_dir) != PTS_SUCCESS) {
- ERROR("Initialize the IMC. e.g. ptsc -i\n");
+ LOG(LOG_ERR, "Initialize the IMC. e.g. ptsc -i\n");
rc = TNC_RESULT_FATAL;
goto error;
}
/* RM UUID */
rc = readOpenptsUuidFile(conf->rm_uuid);
if (rc != PTS_SUCCESS) {
- ERROR("read RM UUID file %s was failed, initialize ptscd first\n", conf->rm_uuid->filename);
+ LOG(LOG_ERR, "read RM UUID file %s was failed, initialize ptscd first\n", conf->rm_uuid->filename);
rc = TNC_RESULT_FATAL;
goto error;
} else {
&conf->pubkey_length,
&conf->pubkey);
if (rc != TSS_SUCCESS) {
- ERROR("getTssPubKey() fail rc=0x%x srk password mode=%d, key =%s\n",
+ LOG(LOG_ERR, "getTssPubKey() fail rc=0x%x srk password mode=%d, key =%s\n",
rc, conf->srk_password_mode, conf->uuid->str);
rc = TNC_RESULT_FATAL;
goto error;
/* check internal status */
if (!initialized) {
- ERROR("not initialized");
+ LOG(LOG_ERR, "not initialized");
return TNC_RESULT_NOT_INITIALIZED;
}
/* check ID */
if (imcID != id) {
- ERROR("BAD id");
+ LOG(LOG_ERR, "BAD id");
return TNC_RESULT_INVALID_PARAMETER;
}
/* check internal status */
if (!initialized) {
- ERROR("not initialized");
+ LOG(LOG_ERR, "not initialized");
return TNC_RESULT_NOT_INITIALIZED;
}
/* check ID */
if (imcID != id) {
- ERROR("bad id");
+ LOG(LOG_ERR, "bad id");
return TNC_RESULT_INVALID_PARAMETER;
}
/* check internal status */
if (!initialized) {
- ERROR("not initialized");
+ LOG(LOG_ERR, "not initialized");
return TNC_RESULT_NOT_INITIALIZED;
}
/* check ID */
if (imcID != id) {
- ERROR("bad id");
+ LOG(LOG_ERR, "bad id");
return TNC_RESULT_INVALID_PARAMETER;
}
/* connection ID */
if (connectionID != cid) {
- ERROR("bad cid");
+ LOG(LOG_ERR, "bad cid");
return TNC_RESULT_INVALID_PARAMETER;
}
read_tlv = (PTS_IF_M_Attribute*)messageBuffer;
if (read_tlv == NULL) {
// TODO should send error?
- ERROR("TLV is null");
+ LOG(LOG_ERR, "TLV is null");
return TNC_RESULT_FATAL;
}
/* send TPM_PUBKEY */
msg = getPtsTlvMessage(ctx, TPM_PUBKEY, &len);
if (msg == NULL) {
- ERROR("return OPENPTS_ERROR");
+ LOG(LOG_ERR, "return OPENPTS_ERROR");
msg = getPtsTlvMessage(ctx, OPENPTS_ERROR, &len);
}
len,
((TNC_VENDORID_OPENPTS << 8) | TNC_SUBTYPE_OPENPTS));
if (rc != TNC_RESULT_SUCCESS) {
- ERROR("[C->V] TPM_PUBKEY[%d] fail", len);
+ LOG(LOG_ERR, "[C->V] TPM_PUBKEY[%d] fail", len);
return TNC_RESULT_FATAL;
} else {
DEBUG_IFM("[C->V] TPM_PUBKEY[%d]\n", len);
/* set RM filename */
rc = getRmSetDir(conf);
if (rc != PTS_SUCCESS) {
- ERROR("collector() - getRmSetDir() was failed\n");
+ LOG(LOG_ERR, "collector() - getRmSetDir() was failed\n");
return PTS_INTERNAL_ERROR;
}
/* send RIMM_SET */
msg = getPtsTlvMessage(ctx, RIMM_SET, &len);
if (msg == NULL) {
- ERROR("Get RIMM_SET message was faild, return OPENPTS_ERROR");
+ LOG(LOG_ERR, "Get RIMM_SET message was faild, return OPENPTS_ERROR");
msg = getPtsTlvMessage(ctx, OPENPTS_ERROR, &len);
}
len,
((TNC_VENDORID_OPENPTS << 8) | TNC_SUBTYPE_OPENPTS));
if (rc != TNC_RESULT_SUCCESS) {
- ERROR("[C->V] RIMM_SET[%d] fail\n", len);
+ LOG(LOG_ERR, "[C->V] RIMM_SET[%d] fail\n", len);
return TNC_RESULT_FATAL;
} else {
DEBUG_IFM("[C->V] RIMM_SET[%d]\n", len);
/* send INTEGRITY_REPORT */
msg = getPtsTlvMessage(ctx, INTEGRITY_REPORT, &len);
if (msg == NULL) {
- ERROR("return OPENPTS_ERROR");
+ LOG(LOG_ERR, "return OPENPTS_ERROR");
msg = getPtsTlvMessage(ctx, OPENPTS_ERROR, &len);
}
len,
((TNC_VENDORID_OPENPTS << 8) | TNC_SUBTYPE_OPENPTS));
if (rc != TNC_RESULT_SUCCESS) {
- ERROR("[C->V] INTEGRITY_REPORT[%d] fail", len);
+ LOG(LOG_ERR, "[C->V] INTEGRITY_REPORT[%d] fail", len);
return TNC_RESULT_FATAL;
} else {
DEBUG_IFM("[C->V] INTEGRITY_REPORT[%d]\n", len);
break;
default:
- ERROR("Unknown type %08X", type);
+ LOG(LOG_ERR, "Unknown type %08X", type);
break;
}
return rc;
} else if (messageType == ((TNC_VENDORID_TCG_PEN << 8) | TNC_SUBTYPE_TCG_PTS)) {
/* TCG */
- ERROR("TBD\n");
+ LOG(LOG_ERR, "TBD\n");
return TNC_RESULT_FATAL;
} else {
- ERROR("bad msg from collector");
+ LOG(LOG_ERR, "bad msg from collector");
return TNC_RESULT_FATAL;
}
/* check internal status */
if (!initialized) {
- ERROR("not initialized");
+ LOG(LOG_ERR, "not initialized");
return TNC_RESULT_NOT_INITIALIZED;
}
/* check ID */
if (imcID != id) {
- ERROR("bad id");
+ LOG(LOG_ERR, "bad id");
return TNC_RESULT_INVALID_PARAMETER;
}
/* connection ID */
if (connectionID != cid) {
- ERROR("bad cid");
+ LOG(LOG_ERR, "bad cid");
return TNC_RESULT_INVALID_PARAMETER;
}
/* check internal status */
if (!initialized) {
- ERROR("not initialized");
+ LOG(LOG_ERR, "not initialized");
return TNC_RESULT_NOT_INITIALIZED;
}
/* check ID */
if (imcID != id) {
- ERROR("bad id");
+ LOG(LOG_ERR, "bad id");
return TNC_RESULT_INVALID_PARAMETER;
}
imcID, supportedTypes, typeCount);
if (!reportMessageTypesPtr) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return TNC_RESULT_FATAL;
}
message, (int)messageType);
if (!sendMessagePtr) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return TNC_RESULT_FATAL;
}
/* check internal status */
if (!initialized) {
- ERROR("not initialized");
+ LOG(LOG_ERR, "not initialized");
return TNC_RESULT_NOT_INITIALIZED;
}
/* check ID */
if (imcID != id) {
- ERROR("bad id");
+ LOG(LOG_ERR, "bad id");
return TNC_RESULT_INVALID_PARAMETER;
}
"TNC_TNCC_ReportMessageTypes",
(void**)&reportMessageTypesPtr)
!= TNC_RESULT_SUCCESS) {
- ERROR("bind function fails -TNC_TNCC_ReportMessageTypes\n");
+ LOG(LOG_ERR, "bind function fails -TNC_TNCC_ReportMessageTypes\n");
rc = TNC_RESULT_FATAL;
return rc;
}
"TNC_TNCC_RequestHandshakeRetry",
(void**)&requestHandshakeRetryPtr)
!= TNC_RESULT_SUCCESS) {
- ERROR("bind function fails - TNC_TNCC_RequestHandshakeRetry\n");
+ LOG(LOG_ERR, "bind function fails - TNC_TNCC_RequestHandshakeRetry\n");
rc = TNC_RESULT_FATAL;
return rc;
}
"TNC_TNCC_SendMessage",
(void**)&sendMessagePtr)
!= TNC_RESULT_SUCCESS) {
- ERROR("bind functionfails - TNC_TNCC_SendMessage\n");
+ LOG(LOG_ERR, "bind functionfails - TNC_TNCC_SendMessage\n");
rc = TNC_RESULT_FATAL;
return rc;
}
/* check */
if (snapshots == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
xfree(event->rgbEvent);
xfree(event);
} else {
- ERROR("resetSnapshot - NULL event\n"); // TODO(munetoh)
+ LOG(LOG_ERR, "resetSnapshot - NULL event\n"); // TODO(munetoh)
}
eventWrapper_next = eventWrapper->next_pcr;
xfree(eventWrapper);
ew = (OPENPTS_PCR_EVENT_WRAPPER *)xmalloc(sizeof(OPENPTS_PCR_EVENT_WRAPPER));
if (ew == NULL) {
- ERROR("no memory");
+ LOG(LOG_ERR, "no memory");
return NULL;
}
void freeEventWrapper(OPENPTS_PCR_EVENT_WRAPPER * ew) {
/* check */
if (ew == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return;
}
/* check */
if (ew == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return;
}
xfree(event->rgbEvent);
xfree(event);
} else {
- ERROR("freeSnapshot - NULL event\n"); // TODO(munetoh)
+ LOG(LOG_ERR, "freeSnapshot - NULL event\n"); // TODO(munetoh)
}
xfree(ew);
ew = NULL;
/* check */
if (ctx == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
if (eventWrapper == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
if (eventWrapper->event == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
/* level 0 SS is null => check Level 1 SS */
ss = getSnapshotFromTable(ctx->ss_table, index, 1);
if (ss == NULL) {
- ERROR("getSnapshotFromTable(%d,1) is null", index);
+ LOG(LOG_ERR, "getSnapshotFromTable(%d,1) is null", index);
addReason(ctx, index, NLS(MS_OPENPTS, OPENPTS_IML_SNAPSHOT_MISSING,
"[PCR%02d] Snapshot(FSM) is missing for PCR%d. "
"Please check the configuration file '%s'"),
DEBUG_FSM("[PCR%02d] RM0 -> RM1 (RM0 is missing)\n", index);
} else {
/* FSM is missing */
- ERROR("getSnapshotFromTable(), FSM is null");
+ LOG(LOG_ERR, "getSnapshotFromTable(), FSM is null");
addReason(ctx, index, NLS(MS_OPENPTS, OPENPTS_IML_FSM_MISSING,
"[RM01-PCR%02d] FSM is missing for PCR%d, Level 1. "
"Please check the configuration file '%s'"),
ss = getSnapshotFromTable(ctx->ss_table, index, 1);
if (ss == NULL) {
/* SS is missing */
- ERROR("getSnapshotFromTable(), ss is null");
+ LOG(LOG_ERR, "getSnapshotFromTable(), ss is null");
addReason(ctx, index, NLS(MS_OPENPTS, OPENPTS_IML_SNAPSHOT_MISSING_2,
"[PCR%02d] Snapshot is missing for PCR%d for Level 0 and 1. "
"Please check the configuration file '%s'"),
active_level = 1;
} else {
/* FSM is missing*/
- ERROR("getSnapshotFromTable(), FSM is null");
+ LOG(LOG_ERR, "getSnapshotFromTable(), FSM is null");
addReason(ctx, index, NLS(MS_OPENPTS, OPENPTS_IML_FSM_MISSING_2,
"[RM01-PCR%02d] FSM is missing for PCR%d, Level 1. Please check the configuration file '%s'"),
index,
ss = getSnapshotFromTable(ctx->ss_table, index, 1);
if (ss == NULL) {
/* SS is missing */
- ERROR("getSnapshotFromTable(), ss is null");
+ LOG(LOG_ERR, "getSnapshotFromTable(), ss is null");
addReason(ctx, index, NLS(MS_OPENPTS, OPENPTS_IML_SNAPSHOT_MISSING_6,
"[RM%02d-PCR%02d] Snapshot is missing for PCR%d, Level %d. Please check the configuration file '%s'"),
active_level,
/* check FSM */
if (ss->fsm_behavior == NULL) {
/* FSm is missing */
- ERROR("getSnapshotFromTable(), FSM is null");
+ LOG(LOG_ERR, "getSnapshotFromTable(), FSM is null");
addReason(ctx, index, NLS(MS_OPENPTS, OPENPTS_IML_FSM_MISSING_3,
"[RM%02d-PCR%02d] FSM is missing for PCR%d, Level %d. Please check the configuration file '%s'"),
active_level,
/* OK, the BHV-FSM exists at Level 1*/
} else {
- ERROR("level >1 is TBD, pcr=%d level=%d\n", index, active_level);
+ LOG(LOG_ERR, "level >1 is TBD, pcr=%d level=%d\n", index, active_level);
return PTS_INTERNAL_ERROR;
}
DEBUG("[RM%02d-PCR%02d] updateFsm() => OPENPTS_FSM_ERROR ===> rc=PTS_INVALID_SNAPSHOT, added Reason\n",
active_level, index);
if (ss->fsm_behavior->curr_state == NULL) {
- ERROR("ss->fsm_behavior->curr_state == NULL");
+ LOG(LOG_ERR, "ss->fsm_behavior->curr_state == NULL");
addReason(ctx, index, NLS(MS_OPENPTS, OPENPTS_IML_VALIDATION_FAILED,
"[RM%02d-PCR%02d] IML validation by FSM has failed. State='%s' at the FSM is '%s'"),
active_level,
"unknown",
ss->fsm_behavior->uml_file);
} else if (ss->fsm_behavior->curr_state->name == NULL) {
- ERROR("ss->fsm_behavior->curr_state->name == NULL");
+ LOG(LOG_ERR, "ss->fsm_behavior->curr_state->name == NULL");
// TODO
} else if (ss->fsm_behavior->uml_file == NULL) {
- ERROR("ss->fsm_behavior->uml_file == NULL");
+ LOG(LOG_ERR, "ss->fsm_behavior->uml_file == NULL");
// TODO
} else {
- ERROR("IML validation by FSM has failed.");
+ LOG(LOG_ERR, "IML validation by FSM has failed.");
addReason(ctx, index, NLS(MS_OPENPTS, OPENPTS_IML_VALIDATION_FAILED,
"[RM%02d-PCR%02d] IML validation by FSM has failed. State='%s' at the FSM is '%s'"),
active_level,
/* this event is migrated to target PCR, remove from this SS (did not put the EW chain) */
goto end;
} else {
- ERROR("updateFsm rc=%d\n", rc);
+ LOG(LOG_ERR, "updateFsm rc=%d\n", rc);
}
/* check */
if (ctx == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
if (eventWrapper == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
if (eventWrapper->event == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
/* check next level (1) */
if (ss == NULL) {
- ERROR("addEventToSnapshotBin() - pcr=%d Level=%d snapshots is missing\n",index, active_level);
+ LOG(LOG_ERR, "addEventToSnapshotBin() - pcr=%d Level=%d snapshots is missing\n",index, active_level);
addReason(ctx, index, NLS(MS_OPENPTS, OPENPTS_IML_SNAPSHOT_MISSING_3, "[PCR%02d] Snapshot(FSM) is missing"),
index);
ctx->ss_table->error[index] = PTS_INTERNAL_ERROR;
DEBUG_FSM("addEventToSnapshotBin() - No trans, return PTS_INVALID_SNAPSHOT\n");
// TODO Broken FSM - 20110115 SM under ARU test
if (ss->fsm_binary == NULL) {
- ERROR("ss->fsm_binary == NULLn");
+ LOG(LOG_ERR, "ss->fsm_binary == NULLn");
addReason(ctx, index, NLS(MS_OPENPTS, OPENPTS_IML_IR_VALIDATION_FAILED_1,
"[RM%02d-PCR%02d-MissingFSM] IR validation by RM has failed"),
active_level,
index);
} else if (ss->fsm_binary->curr_state == NULL) {
- ERROR("ss->fsm_binary->curr_state == NULL\n");
+ LOG(LOG_ERR, "ss->fsm_binary->curr_state == NULL\n");
addReason(ctx, index, NLS(MS_OPENPTS, OPENPTS_IML_IR_VALIDATION_FAILED_2,
"[RM%02d-PCR%02d-MissingState] IR validation by RM has failed"),
active_level,
index);
} else if (ss->fsm_binary->curr_state->name == NULL) {
- ERROR("ss->fsm_binary->curr_state->name == NULL\n");
+ LOG(LOG_ERR, "ss->fsm_binary->curr_state->name == NULL\n");
addReason(ctx, index, NLS(MS_OPENPTS, OPENPTS_IML_IR_VALIDATION_FAILED_3,
"[RM%02d-PCR%02d-MissingStateName] IR validation by RM has failed"),
active_level,
/* check the next level */
ss = getSnapshotFromTable(ctx->ss_table, index, 1);
if (ss == NULL) {
- ERROR("no BIN-FSM at level 0, no SS at level 1\n");
+ LOG(LOG_ERR, "no BIN-FSM at level 0, no SS at level 1\n");
addReason(ctx, index, NLS(MS_OPENPTS, OPENPTS_IML_SNAPSHOT_MISSING_4,
"[PCR%02d] Snapshot(FSM) is missing"),
index);
/* Update with new SS */
ss = getSnapshotFromTable(ctx->ss_table, index, 1); // TODO new func for next
if (ss == NULL) {
- ERROR("getSnapshotFromTable(%d,%d) is NULL\n", index, 1);
+ LOG(LOG_ERR, "getSnapshotFromTable(%d,%d) is NULL\n", index, 1);
return PTS_INTERNAL_ERROR;
} else {
eventWrapper->snapshot = ss;
rc = updateFsm(ctx, ss->fsm_binary, eventWrapper);
if (rc == OPENPTS_FSM_ERROR) {
DEBUG_FSM("No trans, return PTS_INVALID_SNAPSHOT at %s\n", ss->fsm_binary->curr_state->name);
- ERROR("updateFsm fail\n");
+ LOG(LOG_ERR, "updateFsm fail\n");
addReason(ctx, index, NLS(MS_OPENPTS, OPENPTS_IML_IR_VALIDATION_FAILED_5,
"[RM%02d-PCR%02d-%s] IR validation by RM has failed"),
active_level + 1,
}
}
} else {
- ERROR("no BIN-FSM at level 0, no BIN-FSM at level 1\n");
+ LOG(LOG_ERR, "no BIN-FSM at level 0, no BIN-FSM at level 1\n");
addReason(ctx, index, NLS(MS_OPENPTS, OPENPTS_IML_SNAPSHOT_MISSING_5,
"[PCR%02d] Snapshot(FSM) is missing"),
index);
/* check */
if (ctx == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
/* Get Snapshot */
ss = getSnapshotFromTable(ctx->ss_table, index, active_level);
if (ss == NULL) {
- ERROR("No Snapshot at PCR[%d]. level %d\n", index, active_level);
+ LOG(LOG_ERR, "No Snapshot at PCR[%d]. level %d\n", index, active_level);
// return PTS_INTERNAL_ERROR;
// TODO 2011-05-02
active_level++;
ss = getSnapshotFromTable(ctx->ss_table, index, active_level);
if (ss == NULL) {
- ERROR("No Snapshot at PCR[%d], level %d\n", index, active_level);
+ LOG(LOG_ERR, "No Snapshot at PCR[%d], level %d\n", index, active_level);
return PTS_INTERNAL_ERROR;
} else {
DEBUG("Skip Null SS level. level = %d\n", active_level);
ss_lv0 = ss;
ss = getSnapshotFromTable(ctx->ss_table, index, 1);
if (ss == NULL) {
- ERROR("PCR[%d] level 1 SS is null\n", index);
+ LOG(LOG_ERR, "PCR[%d] level 1 SS is null\n", index);
return PTS_INTERNAL_ERROR;
}
setActiveSnapshotLevel(ctx->ss_table, index, 1);
active_level = 1;
} else {
- ERROR("level 1 BHV-FSM is null\n");
+ LOG(LOG_ERR, "level 1 BHV-FSM is null\n");
return PTS_INTERNAL_ERROR;
}
}
} else if (active_level == 1) {
/* use level 1 snapshot */
if (ss->fsm_binary == NULL) {
- ERROR("Missing BIB-FSM pcr=%d,level=%d, ss=%p -> %p\n",
+ LOG(LOG_ERR, "Missing BIB-FSM pcr=%d,level=%d, ss=%p -> %p\n",
index, active_level, ss_lv0, ss);
// printeventWrapper(eventWrapper);
return PTS_INTERNAL_ERROR;
}
} else {
- ERROR("level %d is not supported yet\n", active_level);
+ LOG(LOG_ERR, "level %d is not supported yet\n", active_level);
return PTS_INTERNAL_ERROR;
}
DEBUG_FSM("updateFsm, OPENPTS_FSM_SUCCESS => PCR[%d] level == %d\n",
index, getActiveSnapshotLevel(ctx->ss_table, index));
} else if (rc == OPENPTS_FSM_ERROR) {
- ERROR("flashSnapshot - updateFsm fail, rc = %d\n", rc);
+ LOG(LOG_ERR, "flashSnapshot - updateFsm fail, rc = %d\n", rc);
} else if (rc == OPENPTS_FSM_ERROR_LOOP) {
// IMA's last
// DEBUG("flashSnapshot - updateFsm looped - end of the IMA IML, rc = %d\n", rc);
} else {
- ERROR("flashSnapshot - updateFsm rc=%d\n", rc);
+ LOG(LOG_ERR, "flashSnapshot - updateFsm rc=%d\n", rc);
}
DEBUG_CAL("flashSnapshot - done\n");
/* check */
if (ctx == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
/* check SS table */
if (ctx->ss_table == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
/* Connect to TCSD */
result = Tspi_Context_Create(&hContext);
if (result != TSS_SUCCESS) {
- ERROR("ERROR: Tspi_Context_Create failed rc=0x%x\n", result);
+ LOG(LOG_ERR, "ERROR: Tspi_Context_Create failed rc=0x%x\n", result);
goto close;
}
result = Tspi_Context_Connect(hContext, SERVER);
if (result != TSS_SUCCESS) {
- ERROR("ERROR: Tspi_Context_Connect failed rc=0x%x\n", result);
+ LOG(LOG_ERR, "ERROR: Tspi_Context_Connect failed rc=0x%x\n", result);
goto close;
}
/* Get TPM handles */
result = Tspi_Context_GetTpmObject(hContext, &hTPM);
if (result != TSS_SUCCESS) {
- ERROR("ERROR: Tspi_Context_GetTpmObject failed rc=0x%x\n", result);
+ LOG(LOG_ERR, "ERROR: Tspi_Context_GetTpmObject failed rc=0x%x\n", result);
goto close;
}
/* Get Log */
result = Tspi_TPM_GetEventLog(hTPM, &ulEventNumber, &pcrEvents);
if (result != TSS_SUCCESS) { // ERROR
- ERROR("ERROR: Tspi_TPM_GetEventLog failed rc=0x%x\n", result);
+ LOG(LOG_ERR, "ERROR: Tspi_TPM_GetEventLog failed rc=0x%x\n", result);
goto close;
}
rc = addEventToSnapshotBhv(ctx, ew_new); // iml.c
} else {
/* Unknwon error */
- ERROR("getIml - addEventToSnapshotBhv rc = %d\n", rc);
+ LOG(LOG_ERR, "getIml - addEventToSnapshotBhv rc = %d\n", rc);
}
/* TPM Extend */
rc = extendTpm(&ctx->tpm, ew_new->event);
if (rc < 0) {
- ERROR("getIml - extendTpm fail\n");
+ LOG(LOG_ERR, "getIml - extendTpm fail\n");
goto free;
}
}
/* check */
if (stream == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return 0xFFFFFFFF;
}
size = fread(&data, 1, 4, stream);
if (size != 4) {
- // This is EOF ERROR("\n");
+ // This is EOF LOG(LOG_ERR, "\n");
return 0xFFFFFFFF; // TODO
}
/* check */
if (ctx == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
if (filename == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
/* open file */
if ((fp = fopen(filename, "rb")) == NULL) {
- ERROR("%s missing", filename);
+ LOG(LOG_ERR, "%s missing", filename);
return PTS_INTERNAL_ERROR;
}
event = (TSS_PCR_EVENT *) xmalloc(sizeof(TSS_PCR_EVENT));
if (event == NULL) {
- ERROR("no memory");
+ LOG(LOG_ERR, "no memory");
rc = PTS_FATAL;
goto close;
}
event->ulPcrValueLength = SHA1_DIGEST_SIZE;
event->rgbPcrValue = (BYTE *) xmalloc(SHA1_DIGEST_SIZE); // leaked
if (event->rgbPcrValue == NULL) {
- ERROR("no memory");
+ LOG(LOG_ERR, "no memory");
rc = PTS_FATAL;
goto close;
}
size = fread(event->rgbPcrValue, 1, SHA1_DIGEST_SIZE, fp);
if (size != SHA1_DIGEST_SIZE) { // TODO(munetoh) SHA1 only
- ERROR("BIOS IML File %s, bad pcr size %d at %d event\n",
+ LOG(LOG_ERR, "BIOS IML File %s, bad pcr size %d at %d event\n",
filename, (int)size, i);
rc = PTS_INTERNAL_ERROR;
goto close;
}
/* malloc EventData */
if ((event->rgbEvent = xmalloc_assert(eventLength)) == NULL) {
- ERROR("no memory");
+ LOG(LOG_ERR, "no memory");
rc = PTS_FATAL;
goto close;
}
// TODO if rgbevent is huge 0x4000000 #=> check the endian
size = fread(event->rgbEvent, 1, eventLength, fp);
if (size != eventLength) {
- ERROR("BIOS IML File %s, bad eventdata size 0x%x != 0x%x at %d event\n",
+ LOG(LOG_ERR, "BIOS IML File %s, bad eventdata size 0x%x != 0x%x at %d event\n",
filename, (int)size, (int)eventLength, i);
rc = PTS_INTERNAL_ERROR;
goto close;
ew_new = (OPENPTS_PCR_EVENT_WRAPPER *)
xmalloc(sizeof(OPENPTS_PCR_EVENT_WRAPPER));
if (ew_new == NULL) {
- ERROR("no memory");
+ LOG(LOG_ERR, "no memory");
rc = PTS_FATAL;
goto close;
}
/* SKIP */
} else {
/* Unknwon error */
- ERROR("getBiosImlFile - addEventToSnapshotBhv rc = %d\n", rc);
+ LOG(LOG_ERR, "getBiosImlFile - addEventToSnapshotBhv rc = %d\n", rc);
}
} else { // USE_BIN_FSM
/* BIN-FSM - map to the snapshot */
DEBUG_FSM("\tTransit to next FSM ======================================\n");
result = addEventToSnapshotBin(ctx, ew_new); // iml.c
if (result < 0) { // TODO
- TODO("getBiosImlFile - addEventToSnapshotBin rc = %d\n", rc);
+ LOG(LOG_TODO, "getBiosImlFile - addEventToSnapshotBin rc = %d\n", rc);
}
} else if (result == OPENPTS_FSM_FINISH_WO_HIT) {
DEBUG_FSM("\tTransit to next FSM ======================================\n");
result = addEventToSnapshotBin(ctx, ew_new); // iml.c
if (result < 0) { // TODO
- TODO("getBiosImlFile - addEventToSnapshotBin rc = %d\n", rc);
+ LOG(LOG_TODO, "getBiosImlFile - addEventToSnapshotBin rc = %d\n", rc);
}
} else {
/* Unknwon error */
- ERROR("getBiosImlFile - addEventToSnapshotBin rc = %d\n", rc);
+ LOG(LOG_ERR, "getBiosImlFile - addEventToSnapshotBin rc = %d\n", rc);
}
}
/* TPM Extend */
result = extendTpm(&ctx->tpm, ew_new->event);
if (result != PTS_SUCCESS) {
- ERROR("extend TPM fail\n");
+ LOG(LOG_ERR, "extend TPM fail\n");
rc = PTS_INTERNAL_ERROR;
goto close;
}
close:
if (fclose(fp) == EOF) {
- ERROR("BIOS IML File %s, read fail\n", filename);
+ LOG(LOG_ERR, "BIOS IML File %s, read fail\n", filename);
rc = PTS_INTERNAL_ERROR;
}
DEBUG("read BIOS IML, file %s => %d events\n", filename, ctx->ss_table->event_num);
/* check */
if (ctx == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
if (filename == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
/* open file */
if ((fp = fopen(filename, "rb")) == NULL) {
- ERROR("readImaImlFile - file open was failed, [%s]\n", filename);
+ LOG(LOG_ERR, "readImaImlFile - file open was failed, [%s]\n", filename);
return -1;
}
break;
}
if (pcr_index > MAX_PCRNUM) {
- ERROR("Linux-IMA IML File %s, bad pcr index value %d at %d event\n",
+ LOG(LOG_ERR, "Linux-IMA IML File %s, bad pcr index value %d at %d event\n",
filename, pcr_index, i);
rc = PTS_INTERNAL_ERROR;
goto close;
/* alloc event structure */
event = (TSS_PCR_EVENT *) xmalloc(sizeof(TSS_PCR_EVENT));
if (event == NULL) {
- ERROR("no memory");
+ LOG(LOG_ERR, "no memory");
rc = PTS_FATAL;
goto close;
}
/* read type */
size = fread(&event->eventType, 1, 4, fp);
if (size != 4) {
- ERROR("Linux-IMA(ORIGINAL) IML File %s, bad eventType at %d event\n",
+ LOG(LOG_ERR, "Linux-IMA(ORIGINAL) IML File %s, bad eventType at %d event\n",
filename, i);
rc = PTS_INTERNAL_ERROR;
goto close;
event->ulPcrValueLength = SHA1_DIGEST_SIZE;
event->rgbPcrValue = (BYTE *) xmalloc(SHA1_DIGEST_SIZE);
if (event->rgbPcrValue == NULL) {
- ERROR("no memory");
+ LOG(LOG_ERR, "no memory");
rc = PTS_FATAL;
goto close;
}
size = fread(event->rgbPcrValue, 1, SHA1_DIGEST_SIZE, fp);
if (size != SHA1_DIGEST_SIZE) {
- ERROR("Linux-IMA(ORIGINAL) IML File %s, bad pcr size %d at %d event\n",
+ LOG(LOG_ERR, "Linux-IMA(ORIGINAL) IML File %s, bad pcr size %d at %d event\n",
filename, size, i);
rc = PTS_INTERNAL_ERROR;
goto close;
/* read eventdata length */
size = fread(&event->ulEventLength, 1, 4, fp);
if (size != 4) {
- ERROR("Linux-IMA(ORIGINAL) IML File %s, bad event length size %d at %d event\n",
+ LOG(LOG_ERR, "Linux-IMA(ORIGINAL) IML File %s, bad event length size %d at %d event\n",
filename, size, i);
rc = PTS_INTERNAL_ERROR;
goto close;
}
/* alloc eventdata */
if ((event->rgbEvent = xmalloc(event->ulEventLength)) == NULL) {
- ERROR("no memory");
+ LOG(LOG_ERR, "no memory");
rc = PTS_FATAL;
goto close;
}
/* read filename */
size = fread(event->rgbEvent, 1, event->ulEventLength, fp);
if (size != event->ulEventLength) {
- ERROR("Linux-IMA(ORIGINAL) IML File %s, bad event size %d at %d event\n",
+ LOG(LOG_ERR, "Linux-IMA(ORIGINAL) IML File %s, bad event size %d at %d event\n",
filename, size, i);
rc = PTS_INTERNAL_ERROR;
goto close;
/* read type */
size = fread(&event_type, 1, 4, fp);
if (size != 4) {
- ERROR("Linux-IMA(IMA_31) IML File %s, bad eventType at %d event\n",
+ LOG(LOG_ERR, "Linux-IMA(IMA_31) IML File %s, bad eventType at %d event\n",
filename, i);
rc = PTS_INTERNAL_ERROR;
goto close;
event->ulPcrValueLength = SHA1_DIGEST_SIZE;
event->rgbPcrValue = (BYTE *) xmalloc(SHA1_DIGEST_SIZE);
if (event->rgbPcrValue == NULL) {
- ERROR("no memory");
+ LOG(LOG_ERR, "no memory");
rc = PTS_FATAL;
goto close;
}
size = fread(event->rgbPcrValue, 1, SHA1_DIGEST_SIZE, fp);
if (size != SHA1_DIGEST_SIZE) {
- ERROR("Linux-IMA(IMA_31) IML File %s, bad pcr size %d at %d event\n",
+ LOG(LOG_ERR, "Linux-IMA(IMA_31) IML File %s, bad pcr size %d at %d event\n",
filename, size, i);
rc = PTS_INTERNAL_ERROR;
goto close;
/* read Template length */
size = fread(&template_len, 1, 4, fp);
if (size != 4) {
- ERROR("Linux-IMA(IMA_31) IML File %s, bad template size %d at %d event\n",
+ LOG(LOG_ERR, "Linux-IMA(IMA_31) IML File %s, bad template size %d at %d event\n",
filename, size, i);
rc = PTS_INTERNAL_ERROR;
goto close;
event->ulEventLength = 20 + 256; // TODO(munetoh)
event->rgbEvent = xmalloc(event->ulEventLength);
if (event->rgbEvent == NULL) {
- ERROR("no memory");
+ LOG(LOG_ERR, "no memory");
rc = PTS_FATAL;
goto close;
}
/* read Template digest */
size = fread(event->rgbEvent, 1, SHA1_DIGEST_SIZE, fp);
if (size != SHA1_DIGEST_SIZE) {
- ERROR("Linux-IMA(IMA_31) IML File %s, bad event size %d at %d event\n",
+ LOG(LOG_ERR, "Linux-IMA(IMA_31) IML File %s, bad event size %d at %d event\n",
filename, size, i);
rc = PTS_INTERNAL_ERROR;
goto close;
/* read filename */
size = fread(&event->rgbEvent[20], 1, filename_len, fp);
if (size != filename_len) {
- ERROR("Linux-IMA(IMA_31) IML File %s, bad event size %d != %dat %d event\n",
+ LOG(LOG_ERR, "Linux-IMA(IMA_31) IML File %s, bad event size %d != %dat %d event\n",
filename, (int)size, (int)filename_len, i);
rc = PTS_INTERNAL_ERROR;
goto close;
event->ulPcrValueLength = SHA1_DIGEST_SIZE;
event->rgbPcrValue = (BYTE *) xmalloc_assert(SHA1_DIGEST_SIZE);
if (event->rgbPcrValue == NULL) {
- ERROR("no memory");
+ LOG(LOG_ERR, "no memory");
rc = PTS_FATAL;
goto close;
}
size = fread(event->rgbPcrValue, 1, SHA1_DIGEST_SIZE, fp);
if (size != SHA1_DIGEST_SIZE) {
- ERROR("Linux-IMA() IML File %s, bad pcr size %d at %d event\n",
+ LOG(LOG_ERR, "Linux-IMA() IML File %s, bad pcr size %d at %d event\n",
filename, size, i);
rc = PTS_INTERNAL_ERROR;
goto close;
/* read Template type length */
size = fread(&template_type_len, 1, 4, fp);
if (size != 4) {
- ERROR("Linux-IMA() IML File %s, bad template size %d at %d event\n",
+ LOG(LOG_ERR, "Linux-IMA() IML File %s, bad template size %d at %d event\n",
filename, size, i);
rc = PTS_INTERNAL_ERROR;
goto close;
}
if (template_type_len >= TEMPLATE_TYPE_SIZE) {
- ERROR("template_type_len %d(0x%x) is too big\n", template_type_len, template_type_len);
+ LOG(LOG_ERR, "template_type_len %d(0x%x) is too big\n", template_type_len, template_type_len);
rc = PTS_INTERNAL_ERROR;
goto close;
}
/* read Template type */
size = fread(&buf, 1, template_type_len, fp);
if (size != template_type_len) {
- ERROR("missing\n");
+ LOG(LOG_ERR, "missing\n");
rc = PTS_INTERNAL_ERROR;
goto close;
}
event->ulEventLength = 20 + 256; // TODO(munetoh)
event->rgbEvent = xmalloc(event->ulEventLength);
if (event->rgbEvent == NULL) {
- ERROR("no memory");
+ LOG(LOG_ERR, "no memory");
rc = PTS_FATAL;
goto close;
}
/* read Template digest */
size = fread(event->rgbEvent, 1, SHA1_DIGEST_SIZE, fp);
if (size != SHA1_DIGEST_SIZE) {
- ERROR("missing\n");
+ LOG(LOG_ERR, "missing\n");
rc = PTS_INTERNAL_ERROR;
goto close;
}
/* read filename len */
size = fread(&filename_len, 1, 4, fp);
if (size != 4) {
- ERROR("missing\n");
+ LOG(LOG_ERR, "missing\n");
rc = PTS_INTERNAL_ERROR;
goto close;
}
if (filename_len > 255) {
- ERROR("filename_len is too big, %d, 0x%x\n", filename_len, filename_len);
+ LOG(LOG_ERR, "filename_len is too big, %d, 0x%x\n", filename_len, filename_len);
rc = PTS_INTERNAL_ERROR;
goto close;
}
/* read filename */
size = fread(&event->rgbEvent[20], 1, filename_len, fp);
if (size != filename_len) {
- ERROR("missing\n");
+ LOG(LOG_ERR, "missing\n");
rc = PTS_INTERNAL_ERROR;
goto close;
}
} else {
- ERROR("Unknown template [%s]\n", buf);
+ LOG(LOG_ERR, "Unknown template [%s]\n", buf);
rc = PTS_INTERNAL_ERROR;
goto close;
}
ew = (OPENPTS_PCR_EVENT_WRAPPER *)
xmalloc(sizeof(OPENPTS_PCR_EVENT_WRAPPER));
if (ew == NULL) {
- ERROR("no memory");
+ LOG(LOG_ERR, "no memory");
rc = PTS_FATAL;
goto close;
}
/* map to the snapshot */
result = addEventToSnapshotBhv(ctx, ew_last); // iml.c
if (result != PTS_SUCCESS) {
- ERROR("readImaImlFile - addEventToSnapshotBhv fail, rc = %d\n", rc);
+ LOG(LOG_ERR, "readImaImlFile - addEventToSnapshotBhv fail, rc = %d\n", rc);
rc = PTS_INTERNAL_ERROR;
goto close;
}
/* map to the snapshot */
result = addEventToSnapshotBin(ctx, ew_last); // iml.c
if (result != PTS_SUCCESS) {
- ERROR("readImaImlFile - addEventToSnapshotBin fail\n");
+ LOG(LOG_ERR, "readImaImlFile - addEventToSnapshotBin fail\n");
rc = PTS_INTERNAL_ERROR;
goto close;
}
/* TPM Extend */
result = extendTpm(&ctx->tpm, ew_last->event);
if (result !=0) {
- ERROR("extend TPM fail\n");
+ LOG(LOG_ERR, "extend TPM fail\n");
rc = PTS_INTERNAL_ERROR;
goto close;
}
fclose(fp);
// DEBUG("iml.c - getBiosImlFile - done, %d events\n", event_num);
- // ERROR("SS LEVEL %d == 1?, ss->event_num =%d\n",ss->level,ss->event_num );
+ // LOG(LOG_ERR, "SS LEVEL %d == 1?, ss->event_num =%d\n",ss->level,ss->event_num );
DEBUG("read IMA IML, file %s => %d events\n", filename, event_num);
DEBUG_CAL("readImaImlFile - done, %d events\n", event_num);
/* check */
if (ctx == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
if (pcrs == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
/* check */
if (ctx == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
/* Connect to TCSD */
result = Tspi_Context_Create(&hContext);
if (result != TSS_SUCCESS) {
- ERROR("ERROR: Tspi_Context_Create failed rc=0x%x\n", result);
+ LOG(LOG_ERR, "ERROR: Tspi_Context_Create failed rc=0x%x\n", result);
goto close;
}
result = Tspi_Context_Connect(hContext, SERVER);
if (result != TSS_SUCCESS) {
- ERROR("ERROR: Tspi_Context_Connect failed rc=0x%x\n", result);
+ LOG(LOG_ERR, "ERROR: Tspi_Context_Connect failed rc=0x%x\n", result);
goto close;
}
/* Get TPM handles */
result = Tspi_Context_GetTpmObject(hContext, &hTPM);
if (result != TSS_SUCCESS) {
- ERROR("ERROR: Tspi_Context_GetTpmObject failed rc=0x%x\n", result);
+ LOG(LOG_ERR, "ERROR: Tspi_Context_GetTpmObject failed rc=0x%x\n", result);
goto close;
}
&blobLength,
&blob);
if (result != TSS_SUCCESS) {
- ERROR("ERROR: Tspi_TPM_GetCapability failed rc=0x%x\n", result);
+ LOG(LOG_ERR, "ERROR: Tspi_TPM_GetCapability failed rc=0x%x\n", result);
goto free;
}
result = Tspi_TPM_PcrRead(hTPM, i, &blobLength, &blob);
if (result != TSS_SUCCESS) {
- ERROR("ERROR: Tspi_TPM_PcrRead failed rc=0x%x\n", result);
+ LOG(LOG_ERR, "ERROR: Tspi_TPM_PcrRead failed rc=0x%x\n", result);
pcrNum = 0;
goto free;
}
/* check */
if (buf == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return 0;
}
/* check */
if (ctx == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
if (filename == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
/* open */
if ((fp = fopen(filename, "r")) == NULL) {
- TODO("getPcrBySysfsFile - pcr file is %s missing -- ignore in test\n", filename);
+ LOG(LOG_TODO, "getPcrBySysfsFile - pcr file is %s missing -- ignore in test\n", filename);
return -1; // TODO
}
/* check */
if (ctx == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
/* check */
if (eventWrapper == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return;
}
}
OUTPUT("eventdata[%4d]\n", event->ulEventLength);
} else {
- ERROR("NULL event\n"); // TODO(munetoh)
+ LOG(LOG_ERR, "NULL event\n"); // TODO(munetoh)
}
}
/* check */
if (ctx == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return;
}
if (ss != NULL) {
OUTPUT(" %6d\n", ss->event_num);
level1_num += ss->event_num;
- if (ss->level != 1) ERROR("bad level %d\n", ss->level);
+ if (ss->level != 1) LOG(LOG_ERR, "bad level %d\n", ss->level);
} else {
OUTPUT("\n");
}
int level0_num = 0;
int level1_num = 0;
- printf(NLS(MS_OPENPTS, OPENPTS_IML2AIDE_EVENT, "Number of events\n"
- "PCR Level0 Level1\n"));
- printf("--------------------------\n");
+ OUTPUT(NLS(MS_OPENPTS, OPENPTS_IML2AIDE_EVENT,
+ "Number of events\n"
+ "PCR Level0 Level1\n"));
+ OUTPUT("--------------------------\n");
for (i = 0; i < MAX_PCRNUM; i++) {
- printf("%2d ", i);
+ OUTPUT("%2d ", i);
ss = getSnapshotFromTable(ctx->ss_table, i, 0);
if (ss == NULL) {
- printf(" ----- - - ");
+ OUTPUT(" ----- - - ");
} else {
- printf(" %p ", ss);
- if (ss->fsm_behavior != NULL) printf(" O ");
- else printf(" X ");
+ OUTPUT(" %p ", ss);
+ if (ss->fsm_behavior != NULL) OUTPUT(" O ");
+ else OUTPUT(" X ");
- if (ss->fsm_binary != NULL) printf(" O ");
- else printf(" X ");
+ if (ss->fsm_binary != NULL) OUTPUT(" O ");
+ else OUTPUT(" X ");
/* level 1 */
ss = getSnapshotFromTable(ctx->ss_table, i, 1);
if (ss != NULL) {
- printf(" ");
- printf(" %p ", ss);
- if (ss->fsm_behavior != NULL) printf(" O ");
- else printf(" X ");
+ OUTPUT(" ");
+ OUTPUT(" %p ", ss);
+ if (ss->fsm_behavior != NULL) OUTPUT(" O ");
+ else OUTPUT(" X ");
- if (ss->fsm_binary != NULL) printf(" O ");
- else printf(" X ");
+ if (ss->fsm_binary != NULL) OUTPUT(" O ");
+ else OUTPUT(" X ");
}
}
- printf("\n");
+ OUTPUT("\n");
}
- printf("---------------------------\n");
- printf("level 0 total = %d\n", level0_num);
- printf("level 1 total = %d\n", level1_num);
- printf("---------------------------\n");
+ OUTPUT("---------------------------\n");
+ OUTPUT("level 0 total = %d\n", level0_num);
+ OUTPUT("level 1 total = %d\n", level1_num);
+ OUTPUT("---------------------------\n");
}
/**
* usage
*/
void usage(void) {
- fprintf(stderr, NLS(MS_OPENPTS, OPENPTS_IML2AIDE_USAGE, "OpenPTS command\n\n"
- "Usage: iml2aide [options]\n\n"
- "Options:\n"
- " -c filename Set config file\n"
- " -i filename Set IMA IML file. default, get IML via TSS\n"
- " -r filename Set AIDE DB file as reference of fullpathname\n"
- " -o filename Set output file (AIDE DB format, gziped)\n"
- " -w filename Set output file (Ignore name list, plain text format)\n"
- " -h Show this help message\n"
- "\n"));
+ OUTPUT(NLS(MS_OPENPTS, OPENPTS_IML2AIDE_USAGE,
+ "OpenPTS command\n\n"
+ "Usage: iml2aide [options]\n\n"
+ "Options:\n"
+ " -c filename Set config file\n"
+ " -i filename Set IMA IML file. default, get IML via TSS\n"
+ " -r filename Set AIDE DB file as reference of fullpathname\n"
+ " -o filename Set output file (AIDE DB format, gziped)\n"
+ " -w filename Set output file (Ignore name list, plain text format)\n"
+ " -h Show this help message\n"
+ "\n"));
}
/**
/* ctx */
conf = newPtsConfig();
if (conf == NULL) {
- ERROR("Internal Error\n");
+ LOG(LOG_ERR, "Internal Error\n");
return -1;
}
ctx = newPtsContext(conf);
if (ctx == NULL) {
- ERROR("Internal Error\n");
+ LOG(LOG_ERR, "Internal Error\n");
return -1;
}
/* FSM */
rc = readFsmFromPropFile(ctx, config_filename);
if (rc != PTS_SUCCESS) {
- ERROR("read FSM failed\n");
+ LOG(LOG_ERR, "read FSM failed\n");
printFsmInfo2(ctx);
}
rc = loadAideDatabaseFile(ctx->aide_ctx, aideref_filename); // ir.c
if (rc < 0) {
- ERROR("Internal Error, load AIDE DB() was failed\n");
+ LOG(LOG_ERR, "Internal Error, load AIDE DB() was failed\n");
return -1;
}
- printf(NLS(MS_OPENPTS, OPENPTS_IML2AIDE_DATABASE,
+ OUTPUT(NLS(MS_OPENPTS, OPENPTS_IML2AIDE_DATABASE,
"AIDE Database(ref): %d entries (< %s)\n"), rc, aideref_filename);
/* set flags */
if (ima_filename == NULL) {
/* IML -> TSS -> Struct */
rc = getIml(ctx, 0);
- printf(NLS(MS_OPENPTS, OPENPTS_IML2AIDE_EVENTS, "IML: %d events (< TSS)\n"), rc);
+ OUTPUT(NLS(MS_OPENPTS, OPENPTS_IML2AIDE_EVENTS,
+ "IML: %d events (< TSS)\n"), rc);
} else {
int count;
/* IML(file) -> Struct */
ima_type, 0, &count);
if (rc != PTS_SUCCESS) {
- ERROR("Internal Error, raild atr ead IMA's IML\n");
+ LOG(LOG_ERR, "Internal Error, raild atr ead IMA's IML\n");
return -1;
}
- printf(NLS(MS_OPENPTS, OPENPTS_IML2AIDE_EVENTS_2, "IML: %d events (< %s)\n"), rc, ima_filename);
+ OUTPUT(NLS(MS_OPENPTS, OPENPTS_IML2AIDE_EVENTS_2,
+ "IML: %d events (< %s)\n"), rc, ima_filename);
}
if (rc < 0) {
- ERROR("Internal Error\n");
+ LOG(LOG_ERR, "Internal Error\n");
return -1;
}
rc = writeReducedAidbDatabase(ctx->aide_ctx, aide_filename);
}
if (rc < 0) {
- ERROR("Internal Error\n");
+ LOG(LOG_ERR, "Internal Error\n");
return -1;
}
- printf(NLS(MS_OPENPTS, OPENPTS_IML2AIDE_DATABASE_2,
+ OUTPUT(NLS(MS_OPENPTS, OPENPTS_IML2AIDE_DATABASE_2,
"AIDE Database : %d entries (> %s) \n"), rc, aide_filename);
if (ignorelist_filename != NULL) {
rc = writeAideIgnoreList(ctx, ignorelist_filename);
- printf(NLS(MS_OPENPTS, OPENPTS_IML2AIDE_IGN_LIST,
+ OUTPUT(NLS(MS_OPENPTS, OPENPTS_IML2AIDE_IGN_LIST,
"Ignore list : %d entries (> %s) \n"), rc, ignorelist_filename);
}
len,
&b64buf_len);
if (b64buf == NULL) {
- ERROR("encodeBase64 fail");
+ LOG(LOG_ERR, "encodeBase64 fail");
} else {
fprintf(fp, ", base64(%s)", b64buf);
fprintf(fp, "]");
/* check */
if (filename == NULL) {
- ERROR("filename is NULL\n");
+ LOG(LOG_ERR, "filename is NULL\n");
return TSS_E_INTERNAL_ERROR;
}
}
size = fread(ew->event->rgbPcrValue, 1, SHA1_DIGEST_SIZE, fp);
if (size != SHA1_DIGEST_SIZE) { // TODO(munetoh) SHA1 only
- ERROR("SHA1 only");
+ LOG(LOG_ERR, "SHA1 only");
rc = TSS_E_INTERNAL_ERROR;
goto close;
}
/* EventData len */
size = fread(&eventLength, 1, 4, fp);
if (size != 4) {
- ERROR("fread NG\n");
+ LOG(LOG_ERR, "fread NG\n");
rc = TSS_E_INTERNAL_ERROR;
goto close;
}
}
size = fread(ew->event->rgbEvent, 1, aligned_length, fp);
if (size != aligned_length) {
- ERROR("fread NG, size = %d != %d (@PCR[%d])\n",
+ LOG(LOG_ERR, "fread NG, size = %d != %d (@PCR[%d])\n",
(unsigned int) size,
(unsigned int) ew->event->ulEventLength,
pcrIndex);
* Usage
*/
void usage(void) {
- fprintf(stderr, NLS(MS_OPENPTS, OPENPTS_IML2TEXT_USAGE,
+ OUTPUT(NLS(MS_OPENPTS, OPENPTS_IML2TEXT_USAGE,
"OpenPTS command\n\n"
"Usage: iml2text [options]\n\n"
"Options:\n"
usage();
return 0;
default:
- fprintf(stderr, NLS(MS_OPENPTS, OPENPTS_IML2TEXT_BAD_OPTION_C, "bad option '%c'\n"), c);
+ ERROR(NLS(MS_OPENPTS, OPENPTS_IML2TEXT_BAD_OPTION_C,
+ "bad option '%c'\n"), c);
usage();
return -1;
}
/* in both cases, we have to connect to TCSD */
result = Tspi_Context_Create(&hContext);
if (result != TSS_SUCCESS) {
- ERROR("ERROR: Tspi_Context_Create failed rc=0x%x\n",
+ LOG(LOG_ERR, "ERROR: Tspi_Context_Create failed rc=0x%x\n",
result);
goto close;
}
result = Tspi_Context_Connect(hContext, SERVER);
if (result != TSS_SUCCESS) {
- ERROR("ERROR: Tspi_Context_Connect failed rc=0x%x\n",
+ LOG(LOG_ERR, "ERROR: Tspi_Context_Connect failed rc=0x%x\n",
result);
goto close;
}
/* Get TPM handles */
result = Tspi_Context_GetTpmObject(hContext, &hTPM);
if (result != TSS_SUCCESS) {
- ERROR("ERROR: Tspi_Context_GetTpmObject failed rc=0x%x\n",
+ LOG(LOG_ERR, "ERROR: Tspi_Context_GetTpmObject failed rc=0x%x\n",
result);
goto close;
}
&ulEventNumber,
&PcrEvents);
if (result != TSS_SUCCESS) { // ERROR
- ERROR("ERROR: Tspi_TPM_GetEventLog failed rc=0x%x\n",
+ LOG(LOG_ERR, "ERROR: Tspi_TPM_GetEventLog failed rc=0x%x\n",
result);
goto close;
}
/* Get EventLog File */
result = getEventLog(filename, endian, aligned, &ulEventNumber, &PcrEvents);
if (result != TSS_SUCCESS) { // ERROR
- ERROR("getEventLog failed rc=0x%x\n",
+ LOG(LOG_ERR, "getEventLog failed rc=0x%x\n",
result);
goto close;
}
// actual
result = Tspi_TPM_PcrRead(hTPM, i, &blobLength, &blob);
if (result != TSS_SUCCESS) { // ERROR
- ERROR("PrcRead failed rc=0x%x\n",
+ LOG(LOG_ERR, "PrcRead failed rc=0x%x\n",
result);
goto free;
}
/* */
if (initialized) {
- ERROR("Not initialized");
+ LOG(LOG_ERR, "Not initialized");
return TNC_RESULT_ALREADY_INITIALIZED;
}
/* Only support version 1 */
if ((minVersion < TNC_IFIMV_VERSION_1 ) ||
(maxVersion > TNC_IFIMV_VERSION_1)) {
- ERROR("TNC_RESULT_NO_COMMON_VERSION\n");
+ LOG(LOG_ERR, "TNC_RESULT_NO_COMMON_VERSION\n");
return TNC_RESULT_NO_COMMON_VERSION;
}
if (!pOutActualVersion) {
- ERROR("TNC_RESULT_INVALID_PARAMETER\n");
+ LOG(LOG_ERR, "TNC_RESULT_INVALID_PARAMETER\n");
return TNC_RESULT_INVALID_PARAMETER;
}
/* initialize PTS */
conf = newPtsConfig();
if (conf == NULL) {
- ERROR("Can not allocate OPENPTS_CONFIG\n");
+ LOG(LOG_ERR, "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");
+ LOG(LOG_ERR, "Can not allocate OPENPTS_CONTEXT\n");
rc = TNC_RESULT_FATAL;
goto error;
}
/* configure PTS Verifier (System wide) */
rc = readPtsConfig(conf, PTSV_CONFIG_FILE);
if (rc != PTS_SUCCESS) {
- ERROR("read config file, '%s' was failed - abort\n",
+ LOG(LOG_ERR, "read config file, '%s' was failed - abort\n",
PTSV_CONFIG_FILE);
rc = TNC_RESULT_FATAL;
goto error;
/* 1st use?, create new UUID */
rc = genOpenptsUuid(conf->uuid);
if (rc != PTS_SUCCESS) {
- ERROR("generation of UUID was failed\n");
+ LOG(LOG_ERR, "generation of UUID was failed\n");
rc = TNC_RESULT_FATAL;
goto error;
}
/* save to the file */
rc = writeOpenptsUuidFile(conf->uuid, 1);
if (rc != PTS_SUCCESS) {
- ERROR("Creation of UUID file, %s was failed\n",
+ LOG(LOG_ERR, "Creation of UUID file, %s was failed\n",
conf->uuid->filename);
rc = TNC_RESULT_FATAL;
goto error;
DEBUG("TNC_IMV_NotifyConnectionChange\n");
if (!initialized) {
- ERROR("Not initialized");
+ LOG(LOG_ERR, "Not initialized");
return TNC_RESULT_NOT_INITIALIZED;
}
if (imvID != imv_id)
- ERROR("imvID != imv_id");
+ LOG(LOG_ERR, "imvID != imv_id");
return TNC_RESULT_INVALID_PARAMETER;
DEBUG_IFM("V imvID=%d, connectionID=%d - TNC_IMV_NotifyConnectionChange\n",
messageLength, (int)messageType);
if (!initialized) {
- ERROR("Not initialized");
+ LOG(LOG_ERR, "Not initialized");
return TNC_RESULT_NOT_INITIALIZED;
}
read_tlv = (PTS_IF_M_Attribute*)messageBuffer; // NBO
if (read_tlv == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return TNC_RESULT_FATAL;
}
vid += read_tlv->vid[1] << 8;
vid += read_tlv->vid[2];
if (vid != TNC_VENDORID_OPENPTS) {
- ERROR("read_tlv->vid = 0x%X (!= 0x%X)",
+ LOG(LOG_ERR, "read_tlv->vid = 0x%X (!= 0x%X)",
vid, TNC_VENDORID_OPENPTS);
return TNC_RESULT_FATAL;
}
/* check length */
if (messageLength != (TNC_UInt32) (12 + length)) {
- ERROR("Bad message %d != %d\n",
+ LOG(LOG_ERR, "Bad message %d != %d\n",
messageLength, 12 + length);
return TNC_RESULT_FATAL;
}
DEBUG_IFM("[C->V] OPENPTS_CAPABILITIES[%d]\n", 12 + length);
if (ctx->tnc_state != TNC_STATE_START) {
/* Bad message order */
- ERROR("Bad message order state=%d != %d, type=%08x",
+ LOG(LOG_ERR, "Bad message order state=%d != %d, type=%08x",
ctx->tnc_state, TNC_STATE_START, type);
return TNC_RESULT_FATAL;
}
/* then allow the 1st connection */
enrollment = 1;
} else if (conf->enrollment == IMV_ENROLLMENT_CREDENTIAL) {
- TODO("TBD\n");
+ LOG(LOG_TODO, "TBD\n");
return rc;
} else {
- ERROR("Collector is not initialized yet\n");
+ LOG(LOG_ERR, "Collector is not initialized yet\n");
return rc;
}
} else if (rc != PTS_SUCCESS) {
ctx->nonce->nonce = xmalloc_assert(20);
rc = getRandom(ctx->nonce->nonce, 20);
if (rc != PTS_SUCCESS) {
- ERROR("getRandom() fail\n");
+ LOG(LOG_ERR, "getRandom() fail\n");
}
ctx->tnc_state = TNC_STATE_NONCE;
// TODO check the state
if (ctx->target_conf == NULL) {
- ERROR("Bad sequence\n");
+ LOG(LOG_ERR, "Bad sequence\n");
} else {
/* PUBKEY -> target_conf */
ctx->target_conf->pubkey_length = length;
/* save to the file, UUID/UUID/rmN.xml*/
rc = verifierHandleRimmSet(ctx, value);
if (rc != PTS_SUCCESS) {
- ERROR("verifierHandleRimmSet() fail\n");
+ LOG(LOG_ERR, "verifierHandleRimmSet() fail\n");
return TNC_RESULT_FATAL;
}
ctx->nonce->nonce = xmalloc_assert(20);
rc = getRandom(ctx->nonce->nonce, 20);
if (rc != PTS_SUCCESS) {
- ERROR("getRandom() fail\n");
+ LOG(LOG_ERR, "getRandom() fail\n");
}
ctx->tnc_state = TNC_STATE_NONCE_ENROLL;
mode = OPENPTS_VERIFY_MODE;
} else {
/* BAD STATE */
- ERROR("bad state");
+ LOG(LOG_ERR, "bad state");
}
/* verify */
rc = verifierHandleIR(ctx, length, value, mode, &result);
if (rc != PTS_SUCCESS) {
- ERROR("verifierHandleIR() fail rc = %d\n", rc);
+ LOG(LOG_ERR, "verifierHandleIR() fail rc = %d\n", rc);
// 25 PTS_INVALID_SNAPSHOT?
// return TNC_RESULT_FATAL;
}
// TODO create
break;
case OPENPTS_ERROR:
- ERROR("The corrector returns ERROR message");
+ LOG(LOG_ERR, "The corrector returns ERROR message");
// TODO invalid
result = OPENPTS_RESULT_UNKNOWN;
// break;
return TNC_RESULT_FATAL;
default:
- ERROR("Unknown type %08X", type);
+ LOG(LOG_ERR, "Unknown type %08X", type);
result = OPENPTS_RESULT_UNKNOWN;
break;
}
return rc;
} else if (messageType == ((TNC_VENDORID_TCG_PEN << 8) | TNC_SUBTYPE_TCG_PTS)) {
/* TCG */
- ERROR("TBD\n");
+ LOG(LOG_ERR, "TBD\n");
return TNC_RESULT_FATAL;
} else {
- ERROR("bad msg from collector");
+ LOG(LOG_ERR, "bad msg from collector");
return TNC_RESULT_FATAL;
}
DEBUG("TNC_IMV_SolicitRecommendation\n");
if (!initialized) {
- ERROR("Not initialized");
+ LOG(LOG_ERR, "Not initialized");
return TNC_RESULT_NOT_INITIALIZED;
}
if (imvID != imv_id) {
- ERROR("Bad ID");
+ LOG(LOG_ERR, "Bad ID");
return TNC_RESULT_INVALID_PARAMETER;
}
recommendation = TNC_IMV_ACTION_RECOMMENDATION_ISOLATE;
evaluation = TNC_IMV_EVALUATION_RESULT_NONCOMPLIANT_MAJOR;
} else if (result == OPENPTS_RESULT_INVALID) {
- TODO("verifier() result : INVALID");
+ LOG(LOG_TODO, "verifier() result : INVALID");
str = (TNC_BufferReference)"invalid";
recommendation = TNC_IMV_ACTION_RECOMMENDATION_ISOLATE;
evaluation = TNC_IMV_EVALUATION_RESULT_NONCOMPLIANT_MAJOR;
DEBUG("TNC_IMV_BatchEnding\n");
if (!initialized) {
- ERROR("Not initialized");
+ LOG(LOG_ERR, "Not initialized");
return TNC_RESULT_NOT_INITIALIZED;
}
if (imvID != imv_id) {
- ERROR("imvID != imv_id");
+ LOG(LOG_ERR, "imvID != imv_id");
return TNC_RESULT_INVALID_PARAMETER;
}
DEBUG("TNC_IMV_Terminate\n");
if (!initialized) {
- ERROR("Not initialized");
+ LOG(LOG_ERR, "Not initialized");
return TNC_RESULT_NOT_INITIALIZED;
}
if (imvID != imv_id) {
- ERROR("Bad id");
+ LOG(LOG_ERR, "Bad id");
return TNC_RESULT_INVALID_PARAMETER;
}
DEBUG("reportMessageTypes %d\n", (int)imvID);
if (!reportMessageTypesPtr) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return TNC_RESULT_FATAL;
}
DEBUG("sendMessage\n");
if (!sendMessagePtr) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return TNC_RESULT_FATAL;
}
DEBUG("provideRecommendation\n");
if (!provideRecommendationPtr) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return TNC_RESULT_FATAL;
}
DEBUG("setAttribute\n");
if (!setAttributePtr) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return TNC_RESULT_FATAL;
}
DEBUG("TNC_IMV_ProvideBindFunction\n");
if (!initialized) {
- ERROR("Not initialized");
+ LOG(LOG_ERR, "Not initialized");
return TNC_RESULT_NOT_INITIALIZED;
}
if (imvID != imv_id) {
- ERROR("Bad id");
+ LOG(LOG_ERR, "Bad id");
return TNC_RESULT_INVALID_PARAMETER;
}
if ((*bindFunction)(imvID, "TNC_TNCS_ReportMessageTypes",
(void**)&reportMessageTypesPtr) !=
TNC_RESULT_SUCCESS) {
- ERROR("TBD");
+ LOG(LOG_ERR, "TBD");
return TNC_RESULT_FATAL;
}
if ((*bindFunction)(imvID, "TNC_TNCS_RequestHandshakeRetry",
(void**)&requestHandshakeRetryPtr) !=
TNC_RESULT_SUCCESS) {
- ERROR("TBD");
+ LOG(LOG_ERR, "TBD");
return TNC_RESULT_FATAL;
}
if ((*bindFunction)(imvID, "TNC_TNCS_ProvideRecommendation",
(void**)&provideRecommendationPtr) !=
TNC_RESULT_SUCCESS) {
- ERROR("TBD");
+ LOG(LOG_ERR, "TBD");
return TNC_RESULT_FATAL;
}
if ((*bindFunction)(imvID, "TNC_TNCS_SendMessage",
(void**)&sendMessagePtr) !=
TNC_RESULT_SUCCESS) {
- ERROR("TBD");
+ LOG(LOG_ERR, "TBD");
return TNC_RESULT_FATAL;
}
if ((*bindFunction)(imvID, "TNC_TNCS_GetAttribute",
(void**)&getAttributePtr) !=
TNC_RESULT_SUCCESS) {
// TODO(munetoh) optional
- ERROR("TBD");
+ LOG(LOG_ERR, "TBD");
return TNC_RESULT_FATAL;
}
if ((*bindFunction)(imvID, "TNC_TNCS_SetAttribute",
(void**)&setAttributePtr) !=
TNC_RESULT_SUCCESS) {
// TODO(munetoh) optional
- ERROR("TBD");
+ LOG(LOG_ERR, "TBD");
return TNC_RESULT_FATAL;
}
}
TNC_RESULT_SUCCESS) {
return TNC_RESULT_SUCCESS;
} else {
- ERROR("TBD");
+ LOG(LOG_ERR, "TBD");
return TNC_RESULT_FATAL;
}
}
/* check */
if (errorIndex >= XML_FUNC_END) {
- ERROR("errorIndex(%d) > XML_FUNC_END(%d)",errorIndex, XML_FUNC_END);
+ LOG(LOG_ERR, "errorIndex(%d) > XML_FUNC_END(%d)",errorIndex, XML_FUNC_END);
return;
}
/* log */
- ERROR("XML function '%s' returned '%d'\n", xmlFuncStrings[errorIndex], rc);
+ LOG(LOG_ERR, "XML function '%s' returned '%d'\n", xmlFuncStrings[errorIndex], rc);
}
/**
/* check */
if (ctx == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
ctx = (OPENPTS_IR_CONTEXT *) xmalloc(sizeof(OPENPTS_IR_CONTEXT));
if (ctx == NULL) {
- ERROR("no memory");
+ LOG(LOG_ERR, "no memory");
return NULL;
}
memset(ctx, 0, sizeof(OPENPTS_IR_CONTEXT));
ctx->buf = xmalloc(EVENTDATA_BUF_SIZE);
if (ctx->buf == NULL) {
- ERROR("no memory");
+ LOG(LOG_ERR, "no memory");
xfree(ctx);
return NULL;
}
void freeIrContext(OPENPTS_IR_CONTEXT *ctx) {
/* check */
if (ctx == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return;
}
/* check */
if (cid == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
/* check */
if (event == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
goto error;
}
} else {
- // printf("SM DEBUG no eventdata\n");
+ // no eventdata
}
/* Close the element named "stuff:Objects". */
return PTS_SUCCESS;
error:
- ERROR("writeStuffObjects() XML ERROR\n");
+ LOG(LOG_ERR, "writeStuffObjects() XML ERROR\n");
return PTS_INTERNAL_ERROR;
}
/* check */
if (startHash == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
if (hash == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
/* Write a text */
rc = xmlTextWriterWriteBase64(writer, (const char *) hash, 0, 20);
if (rc < 0) {
- // printf("SM DEBUG ERROR digest len %d \n", 20);
displayXmlError(TEXT_WRITER_WRITE_BASE64, rc);
goto error;
}
/* check */
if (tpm == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
if (cid == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
if (ss == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
level = ss->level;
/* reset PCR */
// FSM resetPCR(n) exist
if (ss->reset_pcr == 1) {
- TODO("reset PCR[%d]\n", index);
+ LOG(LOG_TODO, "reset PCR[%d]\n", index);
resetTpmPcr(tpm, index);
}
/* new UUID */
ir_uuid = newUuid();
if (ir_uuid == NULL) {
- ERROR("UUID \n");
+ LOG(LOG_ERR, "UUID \n");
rc = PTS_INTERNAL_ERROR;
goto error;
}
str_ir_uuid = getStringOfUuid(ir_uuid);
if (str_ir_uuid == NULL) {
- ERROR("UUID \n");
+ LOG(LOG_ERR, "UUID \n");
rc = PTS_INTERNAL_ERROR;
xfree(ir_uuid);
goto error;
eventWrapper = ss->start;
if (eventWrapper == NULL) {
- ERROR("writeSnapshot- eventWrapper is NULL\n");
+ LOG(LOG_ERR, "writeSnapshot- eventWrapper is NULL\n");
rc = PTS_FATAL;
goto free;
}
/* set curr PCR value */
rc = getTpmPcrValue(tpm, index, ss->curr_pcr);
if (rc != PTS_SUCCESS) {
- ERROR("getTpmPcrValue() fail");
+ LOG(LOG_ERR, "getTpmPcrValue() fail");
rc = PTS_INTERNAL_ERROR;
goto free;
}
/* add PcrHash element */
rc = writePcrHash(writer, index, level, ss->start_pcr, ss->curr_pcr, ALGTYPE_SHA1);
if (rc != PTS_SUCCESS) {
- ERROR("writePcrHash() fail");
+ LOG(LOG_ERR, "writePcrHash() fail");
rc = PTS_INTERNAL_ERROR;
goto free;
}
/* check */
if (ctx == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
if (ctx->pcrs == NULL) {
- TODO("writeQuote - OPENPTS_PCRS is NULL, SKIP QuoteData\n");
+ LOG(LOG_TODO, "writeQuote - OPENPTS_PCRS is NULL, SKIP QuoteData\n");
return PTS_FATAL;
}
if (ctx->validation_data == NULL) {
- TODO("writeQuote - TSS_VALIDATION is NULL, SKIP QuoteData\n");
+ LOG(LOG_TODO, "writeQuote - TSS_VALIDATION is NULL, SKIP QuoteData\n");
return PTS_FATAL;
}
select_byte[2] = select_int & 0xFF;
} else {
// TODO
- ERROR(" PCR NUM != 24\n");
+ LOG(LOG_ERR, " PCR NUM != 24\n");
}
/* Start an element named "PcrSelection" as child of PcrComposit. */
size_of_select,
&b64buf_len);
if (b64buf == NULL) {
- ERROR("encodeBase64 fail"); // TODO ERROR => displayXmlError
+ LOG(LOG_ERR, "encodeBase64 fail"); // TODO ERROR => displayXmlError
return PTS_INTERNAL_ERROR;
}
rc = xmlTextWriterWriteAttribute(writer, BAD_CAST "PcrSelect", BAD_CAST b64buf);
if (rc < 0) {
- // ERROR("Error at xmlTextWriterWriteAttribute\n");
+ // LOG(LOG_ERR, "Error at xmlTextWriterWriteAttribute\n");
displayXmlError(TEXT_WRITER_WRITE_ATTR, rc);
return PTS_INTERNAL_ERROR;
}
/* Close the element named "PcrSelection". */
rc = xmlTextWriterEndElement(writer);
if (rc < 0) {
- // ERROR("Error at xmlTextWriterEndElement\n");
+ // LOG(LOG_ERR, "Error at xmlTextWriterEndElement\n");
displayXmlError(TEXT_WRITER_END_ELEMENT, rc);
return PTS_INTERNAL_ERROR;
}
snprintf(tagbuf, sizeof(tagbuf), "%d", ctx->validation_data->versionInfo.bMajor);
rc = xmlTextWriterWriteAttribute(writer, BAD_CAST "VersionMajor", BAD_CAST tagbuf);
if (rc < 0) {
- // ERROR("Error at xmlTextWriterWriteAttribute\n");
+ // LOG(LOG_ERR, "Error at xmlTextWriterWriteAttribute\n");
displayXmlError(TEXT_WRITER_WRITE_ATTR, rc);
return PTS_INTERNAL_ERROR;
}
snprintf(tagbuf, sizeof(tagbuf), "%d", ctx->validation_data->versionInfo.bMinor);
rc = xmlTextWriterWriteAttribute(writer, BAD_CAST "VersionMinor", BAD_CAST tagbuf);
if (rc < 0) {
- // ERROR("Error at xmlTextWriterWriteAttribute\n");
+ // LOG(LOG_ERR, "Error at xmlTextWriterWriteAttribute\n");
displayXmlError(TEXT_WRITER_WRITE_ATTR, rc);
return PTS_INTERNAL_ERROR;
}
snprintf(tagbuf, sizeof(tagbuf), "%d", ctx->validation_data->versionInfo.bRevMajor);
rc = xmlTextWriterWriteAttribute(writer, BAD_CAST "VersionRevMajor", BAD_CAST tagbuf);
if (rc < 0) {
- // ERROR("Error at xmlTextWriterWriteAttribute\n");
+ // LOG(LOG_ERR, "Error at xmlTextWriterWriteAttribute\n");
displayXmlError(TEXT_WRITER_WRITE_ATTR, rc);
return PTS_INTERNAL_ERROR;
}
snprintf(tagbuf, sizeof(tagbuf), "%d", ctx->validation_data->versionInfo.bRevMinor);
rc = xmlTextWriterWriteAttribute(writer, BAD_CAST "VersionRevMinor", BAD_CAST tagbuf);
if (rc < 0) {
- // ERROR("Error at xmlTextWriterWriteAttribute\n");
+ // LOG(LOG_ERR, "Error at xmlTextWriterWriteAttribute\n");
displayXmlError(TEXT_WRITER_WRITE_ATTR, rc);
return PTS_INTERNAL_ERROR;
}
/* Add an attribute with name "Fixed", int */
rc = xmlTextWriterWriteAttribute(writer, BAD_CAST "Fixed", BAD_CAST "QUOT");
if (rc < 0) {
- // ERROR("Error at xmlTextWriterWriteAttribute\n");
+ // LOG(LOG_ERR, "Error at xmlTextWriterWriteAttribute\n");
displayXmlError(TEXT_WRITER_WRITE_ATTR, rc);
return -1;
}
20,
&b64buf_len); // ctx->validation_data->ulDataLength);
if (b64buf == NULL) {
- ERROR("encodeBase64() fail");
+ LOG(LOG_ERR, "encodeBase64() fail");
return PTS_INTERNAL_ERROR;
}
rc = xmlTextWriterWriteAttribute(writer, BAD_CAST "DigestValue", BAD_CAST b64buf);
ctx->validation_data->ulExternalDataLength,
&b64buf_len);
if (b64buf == NULL) {
- ERROR("encodeBase64() fail");
+ LOG(LOG_ERR, "encodeBase64() fail");
return PTS_INTERNAL_ERROR;
}
rc = xmlTextWriterWriteAttribute(writer, BAD_CAST "ExternalData", BAD_CAST b64buf);
if (rc < 0) {
- // ERROR("Error at xmlTextWriterWriteAttribute\n");
+ // LOG(LOG_ERR, "Error at xmlTextWriterWriteAttribute\n");
displayXmlError(TEXT_WRITER_WRITE_ATTR, rc);
return PTS_INTERNAL_ERROR;
}
/* Close the element named "QuoteInfo". */
rc = xmlTextWriterEndElement(writer);
if (rc < 0) {
- // ERROR("Error at xmlTextWriterEndElement\n");
+ // LOG(LOG_ERR, "Error at xmlTextWriterEndElement\n");
displayXmlError(TEXT_WRITER_END_ELEMENT, rc);
return PTS_INTERNAL_ERROR;
}
/* Close the element named "Quote". */
rc = xmlTextWriterEndElement(writer);
if (rc < 0) {
- // ERROR("Error at xmlTextWriterEndElement\n");
+ // LOG(LOG_ERR, "Error at xmlTextWriterEndElement\n");
displayXmlError(TEXT_WRITER_END_ELEMENT, rc);
return PTS_INTERNAL_ERROR;
}
/* check */
if (ctx == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
if (ctx->pcrs == NULL) {
- TODO("writeQuote2 - OPENPTS_PCRS is NULL, SKIP QuoteData\n");
+ LOG(LOG_TODO, "writeQuote2 - OPENPTS_PCRS is NULL, SKIP QuoteData\n");
return PTS_FATAL;
}
if (ctx->validation_data == NULL) {
- TODO("writeQuote2 - TSS_VALIDATION is NULL, SKIP QuoteData\n");
+ LOG(LOG_TODO, "writeQuote2 - TSS_VALIDATION is NULL, SKIP QuoteData\n");
return PTS_FATAL;
}
ctx->validation_data->ulExternalDataLength,
&b64buf_len);
if (b64buf == NULL) {
- ERROR("encodeBase64 fail");
+ LOG(LOG_ERR, "encodeBase64 fail");
return PTS_INTERNAL_ERROR;
}
rc = xmlTextWriterWriteAttribute(writer, BAD_CAST "ExternalData", BAD_CAST b64buf);
free(b64buf);
if (rc < 0) {
- // ERROR("Error at xmlTextWriterWriteAttribute\n");
+ // LOG(LOG_ERR, "Error at xmlTextWriterWriteAttribute\n");
displayXmlError(TEXT_WRITER_WRITE_ATTR, rc);
return PTS_INTERNAL_ERROR;
}
/* PcrInfoShort - start */
rc = xmlTextWriterStartElement(writer, BAD_CAST "PcrInfoShort");
if (rc < 0) {
- // ERROR("Error at xmlTextWriterStartElement\n");
+ // LOG(LOG_ERR, "Error at xmlTextWriterStartElement\n");
displayXmlError(TEXT_WRITER_START_ELEMENT, rc);
return PTS_INTERNAL_ERROR;
}
/* PcrSelection - start */
rc = xmlTextWriterStartElement(writer, BAD_CAST "PcrSelection");
if (rc < 0) {
- // ERROR("Error at xmlTextWriterStartElement\n");
+ // LOG(LOG_ERR, "Error at xmlTextWriterStartElement\n");
displayXmlError(TEXT_WRITER_START_ELEMENT, rc);
return PTS_INTERNAL_ERROR;
}
snprintf(tagbuf, sizeof(tagbuf), "%d", size_of_select);
rc = xmlTextWriterWriteAttribute(writer, BAD_CAST "SizeOfSelect", BAD_CAST tagbuf);
if (rc < 0) {
- // ERROR("Error at xmlTextWriterWriteAttribute\n");
+ // LOG(LOG_ERR, "Error at xmlTextWriterWriteAttribute\n");
displayXmlError(TEXT_WRITER_WRITE_ATTR, rc);
return PTS_INTERNAL_ERROR;
}
size_of_select,
&b64buf_len);
if (b64buf == NULL) {
- ERROR("encodeBase64 fail");
+ LOG(LOG_ERR, "encodeBase64 fail");
return PTS_INTERNAL_ERROR;
}
rc = xmlTextWriterWriteAttribute(writer, BAD_CAST "PcrSelect", BAD_CAST b64buf);
20,
&b64buf_len);
if (b64buf == NULL) {
- ERROR("encodeBase64 fail");
+ LOG(LOG_ERR, "encodeBase64 fail");
return PTS_INTERNAL_ERROR;
}
rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "CompositeHash", "%s", b64buf);
/* PcrComposite - start */
rc = xmlTextWriterStartElement(writer, BAD_CAST "PcrComposit");
if (rc < 0) {
- // ERROR("Error at xmlTextWriterStartElement\n");
+ // LOG(LOG_ERR, "Error at xmlTextWriterStartElement\n");
displayXmlError(TEXT_WRITER_START_ELEMENT, rc);
return PTS_INTERNAL_ERROR;
}
/* PcrSelection - start */
rc = xmlTextWriterStartElement(writer, BAD_CAST "PcrSelection");
if (rc < 0) {
- // ERROR("Error at xmlTextWriterStartElement\n");
+ // LOG(LOG_ERR, "Error at xmlTextWriterStartElement\n");
displayXmlError(TEXT_WRITER_START_ELEMENT, rc);
return PTS_INTERNAL_ERROR;
}
snprintf(tagbuf, sizeof(tagbuf), "%d", size_of_select);
rc = xmlTextWriterWriteAttribute(writer, BAD_CAST "SizeOfSelect", BAD_CAST tagbuf);
if (rc < 0) {
- // ERROR("Error at xmlTextWriterWriteAttribute\n");
+ // LOG(LOG_ERR, "Error at xmlTextWriterWriteAttribute\n");
displayXmlError(TEXT_WRITER_WRITE_ATTR, rc);
return PTS_INTERNAL_ERROR;
}
size_of_select,
&b64buf_len);
if (b64buf == NULL) {
- ERROR("encodeBase64 fail");
+ LOG(LOG_ERR, "encodeBase64 fail");
return PTS_INTERNAL_ERROR;
}
rc = xmlTextWriterWriteAttribute(writer, BAD_CAST "PcrSelect", BAD_CAST b64buf);
/* PcrValue - start */
rc = xmlTextWriterStartElement(writer, BAD_CAST "PcrValue");
if (rc < 0) {
- // ERROR("Error at xmlTextWriterStartElement\n");
+ // LOG(LOG_ERR, "Error at xmlTextWriterStartElement\n");
displayXmlError(TEXT_WRITER_START_ELEMENT, rc);
return PTS_INTERNAL_ERROR;
}
snprintf(tagbuf, sizeof(tagbuf), "%d", i);
rc = xmlTextWriterWriteAttribute(writer, BAD_CAST "PcrNumber", BAD_CAST tagbuf);
if (rc < 0) {
- // ERROR("Error at xmlTextWriterWriteAttribute\n");
+ // LOG(LOG_ERR, "Error at xmlTextWriterWriteAttribute\n");
displayXmlError(TEXT_WRITER_WRITE_ATTR, rc);
return PTS_INTERNAL_ERROR;
}
/* check */
if (ctx == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
/* Create a new XML buffer */
xmlbuf = xmlBufferCreate();
if (xmlbuf == NULL) {
- ERROR("creating the xml buffer fail\n");
+ LOG(LOG_ERR, "creating the xml buffer fail\n");
rc = PTS_INTERNAL_ERROR;
goto error;
}
/* Create a new XmlWriter for memory */
writer = xmlNewTextWriterMemory(xmlbuf, 0);
if (writer == NULL) {
- ERROR("creating the xml writer fail\n");
+ LOG(LOG_ERR, "creating the xml writer fail\n");
rc = PTS_INTERNAL_ERROR;
goto freexml;
}
/* generate UUID */
ir_uuid = newUuid();
if (ir_uuid == NULL) {
- ERROR("fail UUID generation\n");
+ LOG(LOG_ERR, "fail UUID generation\n");
rc = PTS_INTERNAL_ERROR;
goto freexml;
}
str_ir_uuid = getStringOfUuid(ir_uuid);
if (str_ir_uuid == NULL) {
- ERROR("fail UUID generation\n");
+ LOG(LOG_ERR, "fail UUID generation\n");
rc = PTS_INTERNAL_ERROR;
xfree(ir_uuid);
goto freexml;
/* Quote*/
if (ctx->conf->iml_mode == 0) {
if (ctx->conf->ir_without_quote == 1) {
- TODO("skip TPM_Quote\n");
+ LOG(LOG_TODO, "skip TPM_Quote\n");
} else {
if (ctx->conf->tpm_quote_type == 1) {
/* Quote */
rc = writeQuote(writer, ctx);
if (rc < 0) {
- ERROR("writeIr - writeQuote() rc = %d\n", rc);
+ LOG(LOG_ERR, "writeIr - writeQuote() rc = %d\n", rc);
rc = PTS_INTERNAL_ERROR;
goto free;
}
/* Quote2 */
rc = writeQuote2(writer, ctx);
if (rc < 0) {
- ERROR("writeIr - writeQuote2() rc = %d\n", rc);
+ LOG(LOG_ERR, "writeIr - writeQuote2() rc = %d\n", rc);
rc = PTS_INTERNAL_ERROR;
goto free;
}
if (ss != NULL) {
if (ss->event_num > 0) {
// level 0
- // printf("DEBUG add level %d snapshot for PCR%d\n",ss->level, i);
- // ERROR("writeIr PCR[%d] LV0 num=%d\n", i,ss->event_num);
+ // LOG(LOG_ERR, "writeIr PCR[%d] LV0 num=%d\n", i,ss->event_num);
writeSnapshot(writer, &tpm, &cid, i, ss);
}
}
ss = getSnapshotFromTable(ctx->ss_table, i, 1);
if (ss != NULL) {
if (ss->event_num > 0) {
- // ERROR("writeIr PCR[%d] LV1 num=%d\n", i,ss->event_num);
+ // LOG(LOG_ERR, "writeIr PCR[%d] LV1 num=%d\n", i,ss->event_num);
// writeSnapshot(writer, &tpm, &cid, i, ss);
if (i == OPENPTS_PCR_INDEX) {
DEBUG("genIr - Not writing snapshot for OPENPTS_PCR_INDEX (%d)\n",
rc = xmlTextWriterFlush(writer);
if (rc < 0) {
- // ERROR("writeRm: Error at xmlTextWriterFlush\n");
+ // LOG(LOG_ERR, "writeRm: Error at xmlTextWriterFlush\n");
displayXmlError(TEXT_WRITER_FLUSH, rc);
rc = PTS_INTERNAL_ERROR;
goto free;
/* Close all elements */
rc = xmlTextWriterEndDocument(writer);
if (rc < 0) {
- ERROR("testXmlwriterMemory: Error at xmlTextWriterEndDocument\n");
+ LOG(LOG_ERR, "testXmlwriterMemory: Error at xmlTextWriterEndDocument\n");
rc = PTS_INTERNAL_ERROR;
goto free;
}
char buf[1024];
/* use default filename */
if (ctx->conf->ir_dir == NULL) {
- ERROR("Set ir.dir in %s.\n", ctx->conf->config_file);
+ LOG(LOG_ERR, "Set ir.dir in %s.\n", ctx->conf->config_file);
ctx->conf->ir_dir = smalloc("/tmp/.ptsc");
}
snprintf(buf, sizeof(buf), "%s_%s.xml",
irFd = open(filenameDP, O_CREAT | O_EXCL | O_RDWR, S_IRUSR | S_IWUSR);
if (-1 == irFd) {
- ERROR("Failed to open ir file '%s' for writing, errno = %d\n", filename, errno);
+ LOG(LOG_ERR, "Failed to open ir file '%s' for writing, errno = %d\n", filename, errno);
rc = PTS_INTERNAL_ERROR;
goto free;
}
serious hackers probably wouldn't be deterred by this ... */
if (NULL != savedFd &&
-1 == unlink(filenameDP)) {
- ERROR("Failed to unlink file '%s', errno = %d\n", filename, errno);
+ LOG(LOG_ERR, "Failed to unlink file '%s', errno = %d\n", filename, errno);
}
lengthOfIrFile = xmlbuf->use;
{
int writeRc = write(irFd, xmlbuf->content, lengthOfIrFile);
if ( lengthOfIrFile != writeRc ) {
- ERROR("Failed to write contents to IR file - rc %d, errno %d\n", writeRc, errno);
+ LOG(LOG_ERR, "Failed to write contents to IR file - rc %d, errno %d\n", writeRc, errno);
rc = PTS_INTERNAL_ERROR;
close(irFd);
} else {
/* check */
if (ctx == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return;
}
void irEndDocument(void * ctx) {
/* check */
if (ctx == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return;
}
-
- // printf("END DOC \n");
}
/* This prevents real world buffer over-run attacks using malformed IRs
/* check */
if (value == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return -1;
}
/* check */
if (ctx == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return;
}
pctx = (OPENPTS_CONTEXT *)ctx;
ir_ctx = pctx->ir_ctx;
if (ir_ctx == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return;
}
pcrs = pctx->pcrs;
if (pcrs == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return;
}
if (name == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return;
}
validation_data = pctx->validation_data; // ckeck later
//
} else if (!strcmp((char *)name, "pcrindex")) {
/* stuff:Hash -> PCR value (base64) */
- // printf("START ELEMENT [%s] <<<< HASH HASH \n",name);
+ // DEBUG("START ELEMENT [%s] <<<< HASH HASH \n",name);
// ir_ctx->sax_state = IR_SAX_STATE_PCR_INDEX;
} else if (!strcmp((char *)name, "eventtype")) {
- // printf("START ELEMENT [%s] <<<< HASH HASH \n",name);
+ // DEBUG("START ELEMENT [%s] <<<< HASH HASH \n",name);
// ir_ctx->sax_state = IR_SAX_STATE_EVENT_TYPE;
} else if (!strcmp((char *)name, "stuff:Hash")) {
- // printf("START ELEMENT [%s] <<<< DIGEST \n",name);
+ // DEBUG("START ELEMENT [%s] <<<< DIGEST \n",name);
// ir_ctx->sax_state = IR_SAX_STATE_DIGEST;
} else if (!strcmp((char *)name, "eventdata")) {
- // printf("START ELEMENT [%s] <<<< EVENT_DATA\n",name);
+ // DEBUG("START ELEMENT [%s] <<<< EVENT_DATA\n",name);
// ir_ctx->sax_state = IR_SAX_STATE_EVENT_DATA;
} else if (!strcmp((char *)name, "PcrHash")) {
- // printf("START ELEMENT [%s] <<<< EVENT_DATA\n",name);
+ // DEBUG("START ELEMENT [%s] <<<< EVENT_DATA\n",name);
// ir_ctx->sax_state = IR_SAX_STATE_PCR;
/* get Number =pcrindex) attribute ( */
if (atts != NULL) {
for (i = 0;(atts[i] != NULL);i++) {
type = (char *)atts[i++];
- // printf(", %s='", type);
if (atts[i] != NULL) {
value= (char *)atts[i];
- // printf("%s'", value);
if (!strcmp(type, "Number")) {
ir_ctx->pcr_index = getPcrIndexFromIR(value);
}
if (atts != NULL) {
for (i = 0;(atts[i] != NULL);i++) {
type = (char *)atts[i++];
- // printf(", %s='", type);
if (atts[i] != NULL) {
value= (char *)atts[i];
- // printf("%s'", value);
if (!strcmp(type, "SizeOfSelect")) {
/* TPM1.2 - 24 PCRS -> 3 */
pcrs->pcr_select_size = atoi(value);
if (!strcmp(type, "PcrSelect")) {
/* used later */
if (b64buf != NULL) {
- ERROR("bad memory management");
+ LOG(LOG_ERR, "bad memory management");
free(b64buf);
}
b64buf = (BYTE *) decodeBase64(
// attr_cnt++;
// DEBUG("PcrSelect = 0x%02x %02x %02x \n", buf[0],buf[1],buf[2]);
if (b64buf == NULL) {
- ERROR("Failed to decode base64 string\n");
+ LOG(LOG_ERR, "Failed to decode base64 string\n");
ir_ctx->sax_error++;
pcrs->pcr_select_size = 0;
} else {
if (b64buf != NULL) {
memcpy(pcrs->pcr_select_byte, b64buf, pcrs->pcr_select_size);
} else {
- ERROR("pcr_select_byte is missing");
+ LOG(LOG_ERR, "pcr_select_byte is missing");
}
} else {
- ERROR("no memory\n");
+ LOG(LOG_ERR, "no memory\n");
}
} else {
/* BAD IR */
- ERROR("BAD IR SizeOfSelect or PcrSelect are missing\n");
+ LOG(LOG_ERR, "BAD IR SizeOfSelect or PcrSelect are missing\n");
}
/* free Base64 buffer */
if (b64buf != NULL) {
if (atts != NULL) {
for (i = 0;(atts[i] != NULL);i++) {
type = (char *)atts[i++];
- // printf(", %s='", type);
if (atts[i] != NULL) {
value= (char *)atts[i];
- // printf("%s'", value);
if (!strcmp(type, "PcrNumber")) {
ir_ctx->pcr_index = getPcrIndexFromIR(value);
}
type = (char *)atts[i++];
if (validation_data == NULL) {
- ERROR("validation_data == NULL");
+ LOG(LOG_ERR, "validation_data == NULL");
return;
}
if (validation_data->rgbData == NULL) {
validation_data->rgbData = xmalloc_assert(48);
}
- // printf(", %s='", type);
if (atts[i] != NULL) {
value= (char *)atts[i];
- // printf("%s'", value);
if (!strcmp(type, "VersionMajor")) {
validation_data->versionInfo.bMajor = atoi(value);
validation_data->rgbData[0] = atoi(value);
strlen(value),
&b64buf_len);
if (b64buf == NULL) {
- ERROR("decodeBase64 fail");
+ LOG(LOG_ERR, "decodeBase64 fail");
ir_ctx->sax_error++;
return; // TODO return?
}
if (b64buf_len == 20) {
memcpy(&validation_data->rgbData[8], b64buf, 20);
} else {
- ERROR("size of decodeBase64 out is not 20 but %d", b64buf_len);
+ LOG(LOG_ERR, "size of decodeBase64 out is not 20 but %d", b64buf_len);
ir_ctx->sax_error++;
return; // TODO
}
strlen(value),
&b64buf_len);
if (b64buf == NULL) {
- ERROR("decodeBase64 fail");
+ LOG(LOG_ERR, "decodeBase64 fail");
ir_ctx->sax_error++;
return; // TODO
}
// memcpy(validation_data->rgbExternalData, buf, rc);
memcpy(&validation_data->rgbData[28], b64buf, 20);
} else {
- ERROR("Failed to decode base64 string, len = %d not 20\n", b64buf_len);
+ LOG(LOG_ERR, "Failed to decode base64 string, len = %d not 20\n", b64buf_len);
ir_ctx->sax_error++;
return; // TODO
}
type = (char *)atts[i++];
if (validation_data == NULL) {
- ERROR("validation_data == NULL");
+ LOG(LOG_ERR, "validation_data == NULL");
return;
}
if (validation_data->rgbData == NULL) {
validation_data->rgbData = xmalloc_assert(52);
}
- // printf(", %s='", type);
if (atts[i] != NULL) {
value= (char *)atts[i];
- // printf("%s'", value);
if (!strcmp(type, "Tag")) {
int tag = atoi(value);
validation_data->rgbData[0] = (tag >> 8) & 0xFF;
strlen(value),
&b64buf_len);
if (b64buf == NULL) {
- ERROR("decodeBase64 fail");
+ LOG(LOG_ERR, "decodeBase64 fail");
ir_ctx->sax_error++;
return;
}
// memcpy(validation_data->rgbExternalData, b64buf, rc);
memcpy(&validation_data->rgbData[6], b64buf, 20);
} else {
- ERROR("Failed to decode base64 string, len = %d not 20\n", b64buf_len);
+ LOG(LOG_ERR, "Failed to decode base64 string, len = %d not 20\n", b64buf_len);
ir_ctx->sax_error++;
return; // TODO
}
} else if (!strcmp((char *)name, "SignatureMethod")) {
// TODO check alg
} else if (!strcmp((char *)name, "SignatureValue")) {
- // DONE TODO("get value(base64)\n");
+ // DONE LOG(LOG_TODO, "get value(base64)\n");
} else if (!strcmp((char *)name, "KeyInfo")) {
// TODO
} else if (!strcmp((char *)name, "KeyValue")) {
- // DONE TODO("get value(base64)\n");
+ // DONE LOG(LOG_TODO, "get value(base64)\n");
} else { /* Else? */
- ERROR("START ELEMENT [%s] \n", name);
+ LOG(LOG_ERR, "START ELEMENT [%s] \n", name);
ir_ctx->sax_state = IR_SAX_STATE_IDOL;
}
}
/* check */
if (ctx == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return;
}
pctx = (OPENPTS_CONTEXT *)ctx;
ir_ctx = pctx->ir_ctx;
if (ir_ctx == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return;
}
pcrs = pctx->pcrs;
if (pcrs == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return;
}
if (name == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return;
}
validation_data = pctx->validation_data; // ckeck later
/* set the event structure */
if (ir_ctx->event == NULL) {
- ERROR("internal error\n");
+ LOG(LOG_ERR, "internal error\n");
ir_ctx->ew_new->event = NULL;
ir_ctx->sax_error++;
} else {
/* map to the snapshot, push FSM */
rc = addEventToSnapshotBin(pctx, ir_ctx->ew_new); // iml.c
if (rc != PTS_SUCCESS) {
- // ERROR("validateIr:irStartElement - addEventToSnapshotBin rc = %d\n", rc);
+ // LOG(LOG_ERR, "validateIr:irStartElement - addEventToSnapshotBin rc = %d\n", rc);
ir_ctx->integrity = OPENPTS_RESULT_INVALID;
return;
}
DEBUG_FSM("irEndElement() -- SS has validation error\n");
ir_ctx->fsm_error_count++;
} else if (rc != PTS_SUCCESS) {
- ERROR("SnapshotCollection -> FSM flash was fail\n");
+ LOG(LOG_ERR, "SnapshotCollection -> FSM flash was fail\n");
ir_ctx->sax_error++;
return;
}
ir_ctx->char_size,
&b64buf_len);
if (ir_ctx->event->rgbPcrValue == NULL) {
- ERROR("decodeBase64 fail");
+ LOG(LOG_ERR, "decodeBase64 fail");
ir_ctx->sax_error++;
return; // TODO
} else {
ir_ctx->char_size,
&b64buf_len);
if (ir_ctx->event->rgbEvent == NULL) {
- ERROR("decodeBase64 fail");
+ LOG(LOG_ERR, "decodeBase64 fail");
ir_ctx->sax_error++;
return; // TODO
} else {
ir_ctx->char_size,
&b64buf_len);
if (b64buf == NULL) {
- ERROR("decodeBase64 fail");
+ LOG(LOG_ERR, "decodeBase64 fail");
ir_ctx->sax_error++;
return; // TODO
}
if (b64buf_len > MAX_DIGEST_SIZE) {
- ERROR("decodeBase64 out is too latge, %d > %d",
+ LOG(LOG_ERR, "decodeBase64 out is too latge, %d > %d",
b64buf_len, MAX_DIGEST_SIZE);
ir_ctx->sax_error++;
return; // TODO
/* Check with PCR in TPM */
rc = checkTpmPcr2(&pctx->tpm, ir_ctx->pcr_index, ir_ctx->pcr);
if (rc != PTS_SUCCESS) {
- ERROR("ERROR PCR[%d] != IML\n", ir_ctx->pcr_index);
+ LOG(LOG_ERR, "ERROR PCR[%d] != IML\n", ir_ctx->pcr_index);
ir_ctx->sax_error = 1;
// verbose = DEBUG_FLAG | DEBUG_TPM_FLAG; // switch DEBUG MODE
if (isDebugFlagSet(DEBUG_FLAG)) {
if (pctx->conf->iml_mode == 0) {
if (pcrs == NULL) {
/* malloc OPENPTS_PCRS */
- // ERROR("PCR is not intialized - No QuoteData element\n");
+ // LOG(LOG_ERR, "PCR is not intialized - No QuoteData element\n");
pcrs = xmalloc(sizeof(OPENPTS_PCRS));
if (pcrs == NULL) {
- ERROR("no memory\n");
+ LOG(LOG_ERR, "no memory\n");
return;
}
memset(pcrs, 0, sizeof(OPENPTS_PCRS));
} else if (!strcmp((char *)name, "LocalityAtRelease")) {
// TODO
if (validation_data == NULL) {
- ERROR("validation_data == NULL");
+ LOG(LOG_ERR, "validation_data == NULL");
return;
}
validation_data->rgbData[31] = atoi(ir_ctx->buf);
} else if (!strcmp((char *)name, "CompositeHash")) {
// DEBUG("CompositeHash %s", ir_ctx->buf);
if (validation_data == NULL) {
- ERROR("validation_data == NULL");
+ LOG(LOG_ERR, "validation_data == NULL");
return;
}
b64buf = decodeBase64(
ir_ctx->char_size,
&b64buf_len);
if (b64buf == NULL) {
- ERROR("decodeBase64 fail");
+ LOG(LOG_ERR, "decodeBase64 fail");
ir_ctx->sax_error++;
return;
}
ir_ctx->char_size,
&b64buf_len);
if (b64buf == NULL) {
- ERROR("decodeBase64 fail");
+ LOG(LOG_ERR, "decodeBase64 fail");
ir_ctx->sax_error++;
return;
}
if (b64buf_len < SHA1_DIGEST_SIZE) {
- ERROR("decodeBase64 outout is too small, %d < %d", b64buf_len, SHA1_DIGEST_SIZE);
+ LOG(LOG_ERR, "decodeBase64 outout is too small, %d < %d", b64buf_len, SHA1_DIGEST_SIZE);
ir_ctx->sax_error++;
return;
}
if (b64buf_len > MAX_DIGEST_SIZE) {
- ERROR("decodeBase64 outout is too large, %d < %d", b64buf_len, MAX_DIGEST_SIZE);
+ LOG(LOG_ERR, "decodeBase64 outout is too large, %d < %d", b64buf_len, MAX_DIGEST_SIZE);
ir_ctx->sax_error++;
return;
}
} else if (!strcmp((char *)name, "QuoteInfo2")) {
/* pcr select => validation_data */
if (pcrs->pcr_select_byte == NULL) {
- ERROR("pcrs->pcr_select_byte is null");
+ LOG(LOG_ERR, "pcrs->pcr_select_byte is null");
} else {
if (validation_data == NULL) {
- ERROR("validation_data == NULL");
+ LOG(LOG_ERR, "validation_data == NULL");
return;
}
validation_data->rgbData[26] = 0;
} else if (!strcmp((char *)name, "SignatureValue")) {
ir_ctx->buf[ir_ctx->char_size] = 0;
if (ir_ctx->char_size > IR_SAX_BUFFER_SIZE) { // TODO check buf size
- ERROR("buf is small %d \n", ir_ctx->char_size);
+ LOG(LOG_ERR, "buf is small %d \n", ir_ctx->char_size);
ir_ctx->sax_error++;
} else {
if (validation_data == NULL) {
- ERROR("validation_data == NULL");
+ LOG(LOG_ERR, "validation_data == NULL");
return;
}
if (validation_data->rgbValidationData != NULL) {
ir_ctx->char_size,
&b64buf_len);
if (validation_data->rgbValidationData == NULL) {
- ERROR("decodeBase64 fail");
+ LOG(LOG_ERR, "decodeBase64 fail");
ir_ctx->sax_error++;
return; // TODO
}
} else if (!strcmp((char *)name, "KeyValue")) {
ir_ctx->buf[ir_ctx->char_size] = 0;
if (ir_ctx->char_size > IR_SAX_BUFFER_SIZE) { // TODO check buf size
- ERROR("buf is small %d \n", ir_ctx->char_size);
+ LOG(LOG_ERR, "buf is small %d \n", ir_ctx->char_size);
} else {
pcrs->pubkey = decodeBase64(
(char *)ir_ctx->buf,
ir_ctx->char_size,
&b64buf_len);
if (pcrs->pubkey == NULL) {
- ERROR("decodeBase64 fail");
+ LOG(LOG_ERR, "decodeBase64 fail");
ir_ctx->sax_error++;
return;
}
/* Validate QuoteData */
if ( ir_ctx->sax_error > 0 ) {
- ERROR("Unable to validate quote data due to %d SAX parse errors\n", ir_ctx->sax_error);
+ LOG(LOG_ERR, "Unable to validate quote data due to %d SAX parse errors\n", ir_ctx->sax_error);
} else {
rc = validateQuoteData(pcrs, validation_data);
// DEBUG("validateQuoteData = %d\n", rc);
if (rc != PTS_SUCCESS) {
- ERROR("---------------------------------------------------------------------------\n");
- ERROR("BAD QUOTE DATA!!! BAD QUOTE DATA!!! BAD QUOTE DATA!!! BAD QUOTE DATA!!!\n");
- ERROR("---------------------------------------------------------------------------\n");
+ LOG(LOG_ERR, "---------------------------------------------------------------------------\n");
+ LOG(LOG_ERR, "BAD QUOTE DATA!!! BAD QUOTE DATA!!! BAD QUOTE DATA!!! BAD QUOTE DATA!!!\n");
+ LOG(LOG_ERR, "---------------------------------------------------------------------------\n");
addProperty(pctx, "tpm.quote.signature", "invalid");
// TODO set error
ir_ctx->bad_quote = 1;
} else {
#if 0
- TODO("---------------------------------------------------------------------------\n");
- TODO("GOOD QUOTE DATA!!! GOOD QUOTE DATA!!! GOOD QUOTE DATA!!! GOOD QUOTE DATA!!!\n");
- TODO("---------------------------------------------------------------------------\n");
+ LOG(LOG_TODO, "---------------------------------------------------------------------------\n");
+ LOG(LOG_TODO, "GOOD QUOTE DATA!!! GOOD QUOTE DATA!!! GOOD QUOTE DATA!!! GOOD QUOTE DATA!!!\n");
+ LOG(LOG_TODO, "---------------------------------------------------------------------------\n");
#endif
addProperty(pctx, "tpm.quote.signature", "valid");
}
pctx->conf->ir_without_quote = 0;
} else {
/* Else? */
- // printf("END ELEMENT [%s] ",name);
}
ir_ctx->sax_state = IR_SAX_STATE_IDOL;
/* check */
if (ctx == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return;
}
pctx = (OPENPTS_CONTEXT *)ctx;
ir_ctx = pctx->ir_ctx;
if (ir_ctx == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return;
}
//if (ch == NULL) {
- // ERROR("null input");
+ // LOG(LOG_ERR, "null input");
// return;
//}
/* copy to buf at ir_ctx, but check length first, ensuring additional space
for NULL terminator */
if ((ir_ctx->char_size + len + 1) > EVENTDATA_BUF_SIZE) {
- ERROR("Buffer for EVENTDATA is too small, %d + %d > %d\n", ir_ctx->char_size, len, EVENTDATA_BUF_SIZE);
+ LOG(LOG_ERR, "Buffer for EVENTDATA is too small, %d + %d > %d\n", ir_ctx->char_size, len, EVENTDATA_BUF_SIZE);
return;
}
memcpy(&ir_ctx->buf[ir_ctx->char_size], ch, len);
/* check */
if (ctx == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
if (ctx->target_conf == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
if (ctx->ir_filename == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
conf = ctx->target_conf;
if (conf == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
// DEBUG("loadSQLiteDatabaseFile %s\n", ctx->conf->aide_sqlite_filename);
rc = loadSQLiteDatabaseFile(ctx->aide_ctx, conf->aide_sqlite_filename);
if (rc != PTS_SUCCESS) {
- ERROR("loadSQLiteDatabaseFile fail\n");
+ LOG(LOG_ERR, "loadSQLiteDatabaseFile fail\n");
rc = PTS_FATAL;
goto free;
}
#endif
} else {
// pre loaded (see iml2aide.c)
- TODO("AIDE DB pre loaded\n");
+ LOG(LOG_TODO, "AIDE DB pre loaded\n");
}
if (ctx->conf->aide_ignorelist_filename != NULL) {
}
// DEBUG("validatePcrComposite, ctx->conf->ir_without_quote %d\n", ctx->conf->ir_without_quote);
- // ERROR("conf->pubkey_length %d\n",conf->pubkey_length);
+ // LOG(LOG_ERR, "conf->pubkey_length %d\n",conf->pubkey_length);
/* validate PCR values by QuoteData */
if ((conf->iml_mode == 0) && (conf->ir_without_quote == 0)) {
addProperty(ctx, "tpm.quote.pcrs", "invalid");
}
} else {
- ERROR("PUBKEY is missing\n");
+ LOG(LOG_ERR, "PUBKEY is missing\n");
addProperty(ctx, "tpm.quote.pcrs", "unknown");
}
} else {
/* check */
if (ctx == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
/* setup FSM */
rc = readFsmFromPropFile(ctx, ctx->conf->config_file);
if (rc != PTS_SUCCESS) {
- ERROR("readFsmFromPropFile %s failed\n", ctx->conf->config_file);
+ LOG(LOG_ERR, "readFsmFromPropFile %s failed\n", ctx->conf->config_file);
return PTS_INTERNAL_ERROR;
}
/* read BIOS IML */
rc = readBiosImlFile(ctx, ctx->conf->bios_iml_filename, ctx->conf->iml_endian);
if (rc != PTS_SUCCESS) {
- ERROR("fail to load BIOS IML, rc = %d\n", rc);
+ LOG(LOG_ERR, "fail to load BIOS IML, rc = %d\n", rc);
return PTS_INTERNAL_ERROR;
}
rc = readImaImlFile(ctx, ctx->conf->runtime_iml_filename,
ctx->conf->runtime_iml_type, 0, &count); // TODO endian?
if (rc != PTS_SUCCESS) {
- ERROR("fail to load IMA IML, rc = %d\n", rc);
+ LOG(LOG_ERR, "fail to load IMA IML, rc = %d\n", rc);
return PTS_INTERNAL_ERROR;
}
}
/* read PCRS */
rc = getPcrBySysfsFile(ctx, ctx->conf->pcrs_filename);
if (rc < 0) {
- ERROR("fail to load PCR, rc = %d -- (pcr file is missing)\n", rc);
- TODO("Get or Create PCR file for this testcase\n");
+ LOG(LOG_ERR, "fail to load PCR, rc = %d -- (pcr file is missing)\n", rc);
+ LOG(LOG_TODO, "Get or Create PCR file for this testcase\n");
// return -1;
}
// do not use tempnum,
// if (ctx->conf->ir_filename != NULL) {
- // ERROR("Redefining the IR file location %s", ctx->conf->ir_filename);
+ // LOG(LOG_ERR, "Redefining the IR file location %s", ctx->conf->ir_filename);
// }
// ctx->conf->ir_filename = tempnam(NULL, "ir_");
rc = writeIr(ctx, NULL, savedFd);
// rc = writeIr(ctx, ctx->ir_filename, savedFd);
if (rc != 0) {
- ERROR("fail to write IR, rc = %d\n", rc);
+ LOG(LOG_ERR, "fail to write IR, rc = %d\n", rc);
return PTS_INTERNAL_ERROR;
}
/* check */
if (ctx == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
// pcrSelect is set at PCR with FSM
rc = readFsmFromPropFile(ctx, ctx->conf->config_file); // fsm.c
if (rc != PTS_SUCCESS) {
- ERROR("read FSM failed\n");
+ LOG(LOG_ERR, "read FSM failed\n");
return PTS_INTERNAL_ERROR;
}
/* copy */
ctx->validation_data->rgbExternalData = malloc(ctx->nonce->nonce_length);
if (ctx->validation_data->rgbExternalData == NULL) {
- ERROR("no memory");
+ LOG(LOG_ERR, "no memory");
return PTS_FATAL;
}
memcpy(
ctx->nonce->nonce,
ctx->nonce->nonce_length);
} else {
- ERROR("genIrFromTss - nonce is missing, DH-nonce? \n");
+ LOG(LOG_ERR, "genIrFromTss - nonce is missing, DH-nonce? \n");
ctx->validation_data->ulExternalDataLength = 0;
ctx->validation_data->rgbExternalData = NULL;
}
if (ctx->conf->ir_without_quote == 1) {
- TODO("skip TPM_Quote\n");
+ LOG(LOG_TODO, "skip TPM_Quote\n");
} else {
/* TPM Quote or TPM Quote2 */
if (ctx->conf->tpm_quote_type == 1) {
ctx->validation_data); // tss.c
}
if (rc != 0) {
- ERROR("quoteTss fail, rc = 0x%04d\n", rc);
+ LOG(LOG_ERR, "quoteTss fail, rc = 0x%04d\n", rc);
return PTS_INTERNAL_ERROR;
}
}
/* set PCR to snapshot */
rc = setPcrsToSnapshot(ctx, ctx->pcrs); // TODO
if (rc < 0) {
- ERROR("fail to load PCR, rc = %d\n", rc);
+ LOG(LOG_ERR, "fail to load PCR, rc = %d\n", rc);
return PTS_INTERNAL_ERROR;
}
/* get BIOS/IMA IML */
rc = getIml(ctx, 0);
if (rc < 0) {
- ERROR("fail to load BIOS IML, rc = %d\n", rc);
+ LOG(LOG_ERR, "fail to load BIOS IML, rc = %d\n", rc);
return PTS_INTERNAL_ERROR;
}
if (ctx->conf->ir_filename != NULL) {
- ERROR("Redefining the IR file location %s", ctx->conf->ir_filename);
+ LOG(LOG_ERR, "Redefining the IR file location %s", ctx->conf->ir_filename);
}
//ctx->conf->ir_filename = tempnam(NULL, "ir_");
//DEBUG("ctx->conf->ir_filename : %s\n", ctx->conf->ir_filename);
rc = writeIr(ctx, NULL, savedFd);
// rc = writeIr(ctx, ctx->ir_filename, savedFd); // ir.c
if (rc != 0) {
- ERROR("fail to write IR, rc = %d\n", rc);
+ LOG(LOG_ERR, "fail to write IR, rc = %d\n", rc);
return PTS_INTERNAL_ERROR;
}
/* check */
if (ctx == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
if (ctx->conf->iml_mode == 1) {
rc = genIrFromSecurityfs(ctx, savedFd);
if (rc != PTS_SUCCESS) {
- ERROR("writePtsTlvToSock - gen IR failed\n");
+ LOG(LOG_ERR, "writePtsTlvToSock - gen IR failed\n");
return rc;
}
} else {
#ifdef CONFIG_NO_TSS
- TODO("OpenPTS was build with --without-tss and config option iml.mode=tssand, skip IR gen.\n");
+ LOG(LOG_TODO, "OpenPTS was build with --without-tss and config option iml.mode=tssand, skip IR gen.\n");
#else
// DEBUG("get IML/PCR via TSS is not ready\n");
rc = genIrFromTss(ctx, savedFd);
if (rc != PTS_SUCCESS) {
- ERROR("gen IR failed\n");
+ LOG(LOG_ERR, "gen IR failed\n");
return rc;
}
#endif
* SAX parser
*/
void irEndDocument(void * ctx) {
- // printf("END DOC \n");
+ // END DOC
}
/**
//
} else if (!strcmp((char *)name, "pcrindex")) {
/* stuff:Hash -> PCR value (base64) */
- // printf("START ELEMENT [%s] <<<< HASH HASH \n",name);
+ // DEBUG("START ELEMENT [%s] <<<< HASH HASH \n",name);
// ctx->sax_state = IR_SAX_STATE_PCR_INDEX;
} else if (!strcmp((char *)name, "eventtype")) {
- // printf("START ELEMENT [%s] <<<< HASH HASH \n",name);
+ // DEBUG("START ELEMENT [%s] <<<< HASH HASH \n",name);
// ctx->sax_state = IR_SAX_STATE_EVENT_TYPE;
} else if (!strcmp((char *)name, "stuff:Hash")) {
- // printf("START ELEMENT [%s] <<<< DIGEST \n",name);
+ // DEBUG("START ELEMENT [%s] <<<< DIGEST \n",name);
// ctx->sax_state = IR_SAX_STATE_DIGEST;
} else if (!strcmp((char *)name, "eventdata")) {
- // printf("START ELEMENT [%s] <<<< EVENT_DATA\n",name);
+ // DEBUG("START ELEMENT [%s] <<<< EVENT_DATA\n",name);
// ctx->sax_state = IR_SAX_STATE_EVENT_DATA;
} else if (!strcmp((char *)name, "PcrHash")) {
- // printf("START ELEMENT [%s] <<<< EVENT_DATA\n",name);
+ // DEBUG("START ELEMENT [%s] <<<< EVENT_DATA\n",name);
// ctx->sax_state = IR_SAX_STATE_PCR;
/* get Number =pcrindex) attribute ( */
if (atts != NULL) {
for (i = 0;(atts[i] != NULL);i++) {
type = (char *)atts[i++];
- // printf(", %s='", type);
if (atts[i] != NULL) {
value= (char *)atts[i];
- // printf("%s'", value);
if (!strcmp(type, "Number")) {
ctx->pcr_index = atoi(value);
}
} else if (!strcmp((char *)name, "SignatureMethod")) {
// TODO check alg
} else if (!strcmp((char *)name, "SignatureValue")) {
- // DONE TODO("get value(base64)\n");
+ // DONE LOG(LOG_TODO, "get value(base64)\n");
} else if (!strcmp((char *)name, "KeyInfo")) {
} else if (!strcmp((char *)name, "KeyValue")) {
- // DONE TODO("get value(base64)\n");
+ // DONE LOG(LOG_TODO, "get value(base64)\n");
} else {
/* Else? */
- ERROR("START ELEMENT [%s] \n", name);
+ LOG(LOG_ERR, "START ELEMENT [%s] \n", name);
ctx->sax_state = IR_SAX_STATE_IDOL;
}
}
/* set the event structure */
if (ctx->event == NULL) {
- ERROR("internal error\n");
+ LOG(LOG_ERR, "internal error\n");
ctx->sax_error++;
} else {
if (ctx->binary == 0) {
if (pad_len > 0) {
/* add padding */
rc = fwrite((BYTE *)&padding, 1, pad_len, ctx->fp); // Padding
- TODO("%d mod %d => %d\n", ctx->event->ulEventLength, ctx->aligned, pad_len);
+ LOG(LOG_TODO, "%d mod %d => %d\n", ctx->event->ulEventLength, ctx->aligned, pad_len);
}
}
}
ctx->char_size,
(int *)&ctx->event->ulPcrValueLength);
if (ctx->event->rgbEvent == NULL) {
- // ERROR()
+ // LOG(LOG_ERR, )
ctx->event->ulPcrValueLength = 0;
}
} else if (!strcmp((char *)name, "eventtype")) {
ctx->char_size,
(int *)&ctx->event->ulEventLength);
if (ctx->event->rgbEvent == NULL) {
- // ERROR()
+ // LOG(LOG_ERR, )
ctx->event->ulEventLength = 0;
}
} else if (!strcmp((char *)name, "PcrHash")) {
// rc = checkTpmPcr2(&pctx->tpm, ctx->pcr_index, ctx->pcr);
if (rc != 0) {
- ERROR("ERROR PCR[%d] != IML\n", ctx->pcr_index);
+ LOG(LOG_ERR, "ERROR PCR[%d] != IML\n", ctx->pcr_index);
ctx->sax_error = 1;
} else {
/* IML and PCR are consistent :-) */
if (pctx->conf->iml_mode == 0) {
if (pcrs == NULL) {
/* malloc OPENPTS_PCRS */
- // ERROR("PCR is not intialized - No QuoteData element\n");
+ // LOG(LOG_ERR, "PCR is not intialized - No QuoteData element\n");
pcrs = xmalloc(sizeof(OPENPTS_PCRS));
if (pcrs == NULL) {
return;
DEBUG("ignore QuoteData\n");
} else {
/* Else? */
- // printf("END ELEMENT [%s] ",name);
+ DEBUG("END ELEMENT [%s] ",name);
}
ctx->sax_state = IR_SAX_STATE_IDOL;
/* copy to buf at ctx */
if (ctx->char_size + len > EVENTDATA_BUF_SIZE) {
- ERROR("Buffer for EVENTDATA is too small, %d + %d > %d\n", ctx->char_size, len, EVENTDATA_BUF_SIZE);
+ LOG(LOG_ERR, "Buffer for EVENTDATA is too small, %d + %d > %d\n", ctx->char_size, len, EVENTDATA_BUF_SIZE);
return;
}
memcpy(&ctx->buf[ctx->char_size], ch, len);
* Usage
*/
void usage(void) {
- fprintf(stderr, NLS(MS_OPENPTS, OPENPTS_IR2TEXT_USAGE, "OpenPTS command\n\n"
- "Usage: ir2text [options]\n\n"
- "Options:\n"
- " -i filename Set IR file\n"
- " -o filename Set output file, else stdout\n"
- " -P filename Set PCR output file (option)\n"
- " -b Binary, (Convert IR to IML)\n"
- " -E Enable endian conversion (BE->LE or LE->BE)\n"
- " -h Show this help message\n"
- "\n"));
+ OUTPUT(NLS(MS_OPENPTS, OPENPTS_IR2TEXT_USAGE,
+ "OpenPTS command\n\n"
+ "Usage: ir2text [options]\n\n"
+ "Options:\n"
+ " -i filename Set IR file\n"
+ " -o filename Set output file, else stdout\n"
+ " -P filename Set PCR output file (option)\n"
+ " -b Binary, (Convert IR to IML)\n"
+ " -E Enable endian conversion (BE->LE or LE->BE)\n"
+ " -h Show this help message\n"
+ "\n"));
}
int main(int argc, char *argv[]) {
usage();
return 0;
default:
- fprintf(stderr, NLS(MS_OPENPTS, OPENPTS_IR2TEXT_BAD_OPTION_C, "bad option %c\n"), c);
+ ERROR(NLS(MS_OPENPTS, OPENPTS_IR2TEXT_BAD_OPTION_C,
+ "bad option %c\n"), c);
usage();
return -1;
}
/* open output file */
ctx->fp = fopen(out_filename, "w");
if (ctx->fp == NULL) {
- ERROR("output file %s - open failed\n", out_filename);
+ LOG(LOG_ERR, "output file %s - open failed\n", out_filename);
return rc;
}
}
} else {
/* print IR in binary text, with -o option */
if (out_filename == NULL) {
- fprintf(stderr, NLS(MS_OPENPTS, OPENPTS_IR2TEXT_OUTPUT_BINARY_MODE,
+ ERROR(NLS(MS_OPENPTS, OPENPTS_IR2TEXT_OUTPUT_BINARY_MODE,
"set the output file for the binary mode\n"));
usage();
return -1;
/* open output file */
ctx->fp = fopen(out_filename, "wb");
if (ctx->fp == NULL) {
- ERROR("output file %s - open failed\n", out_filename);
+ LOG(LOG_ERR, "output file %s - open failed\n", out_filename);
return rc;
}
}
if (pcrout_filename != NULL) {
FILE *fp;
int i, j;
- TODO("pcrout_filename = %s\n", pcrout_filename);
+ LOG(LOG_TODO, "pcrout_filename = %s\n", pcrout_filename);
/* open output file */
fp = fopen(pcrout_filename, "w");
if (fp == NULL) {
- ERROR("PCR output file %s - open failed\n", pcrout_filename);
+ LOG(LOG_ERR, "PCR output file %s - open failed\n", pcrout_filename);
return -1;
}
#endif // AIX
#ifdef ENABLE_NLS
+#include <locale.h>
#ifdef HAVE_CATGETS
#include <nl_types.h>
nl_catd catd;
char *tempLogFileName = NULL;
char *tempDebugMode = NULL;
-
-
/* Location */
if (getenv("OPENPTS_LOG_SYSLOG") != NULL) {
logLocation = OPENPTS_LOG_SYSLOG;
logLocation = ll;
if (ll == OPENPTS_LOG_FILE) {
- expandLogFilePath(filename);
+ if (logFileFd != -1) {
+ char * oldlog;
+ /* already open */
+ LOG(LOG_INFO, "Logfile changed from %s to %s\n", logFileName, filename);
+ oldlog=strdup(logFileName);
+ if (oldlog == NULL) {
+ LOG(LOG_ERR, "no memory");
+ return;
+ }
+ close(logFileFd);
+ logFileFd = -1;
+ expandLogFilePath(filename);
+ LOG(LOG_INFO, "Logfile changed from %s to %s\n", oldlog, logFileName);
+ free(oldlog);
+ } else {
+ if (filename != NULL) {
+ expandLogFilePath(filename);
+ } else {
+ expandLogFilePath(DEFAULT_LOG_FILE);
+ }
+ }
}
}
} else if (logLocation == OPENPTS_LOG_FILE) {
return logFileName;
} else {
- ERROR("logLocation %d\n", logLocation);
+ LOG(LOG_ERR, "logLocation %d\n", logLocation);
return "TBD";
}
}
int len;
char *format2 = NULL;
va_list list;
- // char buf[SYSLOG_BUF_SIZE];
va_start(list, format);
-
+ /* check def */
if (logLocation == OPENPTS_LOG_UNDEFINED) {
determineLogLocationByEnv();
- // fprintf(stderr, "logLocation == OPENPTS_LOG_UNDEFINED\n");
return;
}
if (logLocation == OPENPTS_LOG_NULL) {
+ /* disable logging */
return;
}
void *xmalloc(size_t size) {
char *result = malloc(size);
if (NULL == result) {
- ERROR("Failed to allocate %d bytes of memory\n", size);
+ LOG(LOG_ERR, "Failed to allocate %d bytes of memory\n", size);
// if ( size > 0 ) {
- // ERROR("malloc");
+ // LOG(LOG_ERR, "malloc");
// }
}
return result;
void *xmalloc_assert(size_t size) {
char *result = malloc(size);
if (NULL == result) {
- ERROR("Failed to allocate %d bytes of memory\n", size);
+ LOG(LOG_ERR, "Failed to allocate %d bytes of memory\n", size);
OUTPUT("About to return NULL pointer - cannot continue\n");
exit(1);
}
void xfree(void *buf) {
if (buf == NULL) {
- ERROR("Freeing a NULL pointer is bad");
+ LOG(LOG_ERR, "Freeing a NULL pointer is bad");
return;
}
#ifndef NEVER_FREE_MEMORY
/* check string length */
out = strdup(str);
if (out == NULL) {
- ERROR("Failed to duplicate string '%s'\n", str);
+ LOG(LOG_ERR, "Failed to duplicate string '%s'\n", str);
}
return out;
/* check string length */
out = strdup(str);
if (NULL == out) {
- ERROR("Failed to duplicate string '%s'\n", str);
+ LOG(LOG_ERR, "Failed to duplicate string '%s'\n", str);
OUTPUT("About to return NULL pointer - cannot continue\n");
exit(1);
}
/* check */
if (str == NULL) {
- ERROR("smalloc - string is NULL\n");
+ LOG(LOG_ERR, "smalloc - string is NULL\n");
return NULL;
}
/* check */
if (buf == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return NULL;
}
if (offset < 0) {
- ERROR("offset < 0");
+ LOG(LOG_ERR, "offset < 0");
return NULL;
}
if (len < 0) {
- ERROR("len < 0");
+ LOG(LOG_ERR, "len < 0");
return NULL;
}
/* check */
if (basepath == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return NULL;
}
if (filename == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return NULL;
}
/* basepath + filename */
if (basepath[0] != '/') {
/* relative path -> error when it run as daemon */
- TODO("getFullpathName() - basepath, '%s' is not started from root\n", basepath);
+ LOG(LOG_TODO, "getFullpathName() - basepath, '%s' is not started from root\n", basepath);
}
filename_len = strlen(filename);
if (filename_len < 2) {
- ERROR("ilename len < 2\n");
+ LOG(LOG_ERR, "ilename len < 2\n");
return NULL;
}
fullpath[basepath_len + filename_len - 1] = 0;
break;
default:
- ERROR("internal error\n");
+ LOG(LOG_ERR, "internal error\n");
break;
} // switch
/* check */
if (filename == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return NULL;
}
UINT32 a = 0;
if (b == NULL) {
- ERROR("byte2uint32 - NULL");
+ LOG(LOG_ERR, "byte2uint32 - NULL");
OUTPUT("About to return NULL pointer - cannot continue\n"); // TODO
exit(1);
}
/* check */
if (str == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return NULL;
}
/* check */
if (bin == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return NULL;
}
// len = snprintf(ptr, sizeof(ptr), "%02x", bin[i]);
len = snprintf(ptr, 3, "%02x", bin[i]);
if (len != 2) {
- ERROR("FATAL");
+ LOG(LOG_ERR, "FATAL");
free(buf);
return NULL;
}
/* check */
if (outBuf == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return;
}
if (head == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return;
}
if (data == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return;
}
if (tail == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return;
}
/* check */
if (fp == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return;
}
if (data == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return;
}
/* check */
if (len < 0) {
- ERROR("len <0 \n");
+ LOG(LOG_ERR, "len <0 \n");
return PTS_FATAL;
}
if (msg == NULL) {
- ERROR("msg is NULL \n");
+ LOG(LOG_ERR, "msg is NULL \n");
return PTS_FATAL;
}
if (filename == NULL) {
- ERROR("filename is NULL \n");
+ LOG(LOG_ERR, "filename is NULL \n");
return PTS_FATAL;
}
if ((fp = fopen(filename, "w+b")) == NULL) {
- ERROR("File open failed, %s \n", filename);
+ LOG(LOG_ERR, "File open failed, %s \n", filename);
return PTS_FATAL; // TODO(munetoh): set PTS error code.
}
fclose(fp);
if (len > 0) {
- ERROR("After %d retries still have %d bytes unwritten to '%s'\n", max_retries, len, filename);
+ LOG(LOG_ERR, "After %d retries still have %d bytes unwritten to '%s'\n", max_retries, len, filename);
return PTS_FATAL;
} else {
return PTS_SUCCESS;
/* check */
if (buf == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return 0; // TODO
}
// TODO check the size?
/* check */
if (dirname == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
if (rc != 0) {
switch (errno) {
case EACCES:
- ERROR("mkdir %s failed, EACCES", dirname);
+ LOG(LOG_ERR, "mkdir %s failed, EACCES", dirname);
rc = PTS_FATAL;
break;
case EEXIST:
rc = lstat(dirname, &st);
if (rc == 0) {
if ((st.st_mode & S_IFMT) != S_IFDIR) {
- ERROR("directory, %s is not a directory %x %x\n",
+ LOG(LOG_ERR, "directory, %s is not a directory %x %x\n",
dirname, (st.st_mode & S_IFMT), S_IFDIR);
rc = PTS_INTERNAL_ERROR;
} else {
rc = PTS_SUCCESS;
}
} else {
- ERROR("lstat(%s) failed, errno=%d\n", dirname, errno);
+ LOG(LOG_ERR, "lstat(%s) failed, errno=%d\n", dirname, errno);
rc = PTS_FATAL;
}
break;
case EFAULT:
- ERROR("mkdir %s failed, EFAULT", dirname);
+ LOG(LOG_ERR, "mkdir %s failed, EFAULT", dirname);
rc = PTS_FATAL;
break;
// TODO add others :-)
default:
- ERROR("mkdir %s failed, errono = 0x%X", dirname, errno);
+ LOG(LOG_ERR, "mkdir %s failed, errono = 0x%X", dirname, errno);
rc = PTS_FATAL;
break;
}
/* check */
if (dirname == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
/* check */
if (filename == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
/* check */
if (buf == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return 0; // TODO
}
/* check */
if (buf == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return 0; // TODO
}
/* check */
if (dirPath == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
dirHandle = opendir(dirPath);
if (dirHandle == NULL) {
- ERROR("opendir(%s) fail", dirPath);
+ LOG(LOG_ERR, "opendir(%s) fail", dirPath);
return PTS_FATAL;
}
snprintf(path, sizeof(path), "%s/%s", dirPath, entry->d_name);
if (stat(path, &st) != 0) {
- ERROR("stat(%s) fail", path);
+ LOG(LOG_ERR, "stat(%s) fail", path);
rc = PTS_FATAL;
goto free_error;
}
}
} else if (S_ISREG(st.st_mode)) {
if (unlink(path) != 0) {
- ERROR("unlink(%s) fail", path);
+ LOG(LOG_ERR, "unlink(%s) fail", path);
rc = PTS_FATAL;
goto free_error;
}
/* rm this dir */
if (rmdir(dirPath) != 0) {
- ERROR("rmdir(%s) fail", dirPath);
+ LOG(LOG_ERR, "rmdir(%s) fail", dirPath);
rc = PTS_FATAL;
goto free_error;
}
/* check */
if (dirPath == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
if (dirPath[0] == '\0' || strlen(dirPath) >= PATH_MAX) {
- ERROR("bad dirPath, %s", dirPath);
+ LOG(LOG_ERR, "bad dirPath, %s", dirPath);
return PTS_FATAL;
}
/* malloc */
ctx = xmalloc(sizeof(OPENPTS_NONCE));
if (ctx == NULL) {
- ERROR("no memory");
+ LOG(LOG_ERR, "no memory");
return NULL;
}
memset(ctx, 0, sizeof(OPENPTS_NONCE));
/* malloc req */
ctx->req = (PTS_IF_M_DH_Nonce_Parameters_Request *)xmalloc(sizeof(PTS_IF_M_DH_Nonce_Parameters_Request));
if (ctx->req == NULL) {
- ERROR("no memory");
+ LOG(LOG_ERR, "no memory");
xfree(ctx);
return NULL;
}
/* malloc res */
ctx->res = xmalloc(sizeof(PTS_IF_M_DH_Nonce_Parameters_Responce));
if (ctx->res == NULL) {
- ERROR("no memory");
+ LOG(LOG_ERR, "no memory");
xfree(ctx->req);
xfree(ctx);
return NULL;
/* malloc fin */
ctx->fin = xmalloc(sizeof(PTS_IF_M_DH_Nonce_Finish));
if (ctx->fin == NULL) {
- ERROR("no memory");
+ LOG(LOG_ERR, "no memory");
xfree(ctx->req);
xfree(ctx->res);
xfree(ctx);
/* check */
if (ctx == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
// DEBUG("calcExternalDataValue\n");
/* check */
if (ctx == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
ctx->nonce_length = SHA1_DIGEST_SIZE;
ctx->nonce = xmalloc_assert(SHA1_DIGEST_SIZE);
if (ctx->nonce == NULL) {
- ERROR("no memory");
+ LOG(LOG_ERR, "no memory");
return PTS_FATAL;
}
SHA1_Final(ctx->nonce, &sha_ctx);
if (isDebugFlagSet(DEBUG_FLAG)) {
- TODO("calcExternalDataValue - nonce\n");
+ LOG(LOG_TODO, "calcExternalDataValue - nonce\n");
debugHex("\t\tinitiator_nonce:", ctx->initiator_nonce, ctx->initiator_nonce_length, "\n");
debugHex("\t\trespondor_nonce:", ctx->respondor_nonce, ctx->respondor_nonce_length, "\n");
debugHex("\t\tsecret :", ctx->secret, ctx->secret_length, "\n");
/* check */
if (ctx == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
req = ctx->req;
if (req == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
res = ctx->res;
if (res == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
if (req->reserved != 0) {
- ERROR("reserved must be 0\n");
+ LOG(LOG_ERR, "reserved must be 0\n");
return PTS_INTERNAL_ERROR;
}
BN_hex2bn(&p, group14);
} else {
res->selected_dh_group = 0;
- ERROR("Unknown DH group set 0x%x", req->dh_group_set);
+ LOG(LOG_ERR, "Unknown DH group set 0x%x", req->dh_group_set);
return PTS_DENIED;
}
/* malloc */
res->dh_respondor_nonce = xmalloc(res->nonce_length);
if (res->dh_respondor_nonce == NULL) {
- ERROR("dh_respondor_nonce is null");
+ LOG(LOG_ERR, "dh_respondor_nonce is null");
return PTS_INTERNAL_ERROR;
}
/* set random */
rc = getRandom(res->dh_respondor_nonce, res->nonce_length);
if (rc != TSS_SUCCESS) {
- ERROR("get random fail\n");
+ LOG(LOG_ERR, "get random fail\n");
return PTS_INTERNAL_ERROR;
}
/* malloc */
res->dh_respondor_public = xmalloc(DH_size(ctx->dh));
if (res->dh_respondor_public == NULL) {
- ERROR("no memory");
+ LOG(LOG_ERR, "no memory");
return PTS_FATAL;
}
/* check */
if (ctx == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
} else if (res->selected_dh_group == DH_GROUP_14) {
ctx->pubkey_length = DH_GROUP_14_SIZE;
} else {
- ERROR("Bad DH group 0x%x\n", res->selected_dh_group);
+ LOG(LOG_ERR, "Bad DH group 0x%x\n", res->selected_dh_group);
return PTS_DENIED; // TODO
}
/* check */
if (ctx == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
res = ctx->res;
if (res == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
fin = ctx->fin;
if (fin == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
if (res->reserved[0] != 0) {
// TODO check 1,2 too
- ERROR("reserved must be 0\n");
+ LOG(LOG_ERR, "reserved must be 0\n");
return PTS_INTERNAL_ERROR;
}
fin->selected_hash_alg = DH_HASH_SHA1;
ctx->selected_hash_alg = DH_HASH_SHA1;
} else {
- ERROR("Bad DH hash set 0x%x\n", res->hash_alg_set);
+ LOG(LOG_ERR, "Bad DH hash set 0x%x\n", res->hash_alg_set);
return PTS_DENIED;
}
BN_hex2bn(&p, group14);
ctx->pubkey_length = DH_GROUP_14_SIZE;
} else {
- ERROR("Bad DH group 0x%x\n", res->selected_dh_group);
+ LOG(LOG_ERR, "Bad DH group 0x%x\n", res->selected_dh_group);
return PTS_DENIED;
}
/* malloc */
ctx->secret = xmalloc(ctx->secret_length);
if (ctx->secret == NULL) {
- ERROR("no memory");
+ LOG(LOG_ERR, "no memory");
return PTS_FATAL;
}
/* initiator nonce */
fin->dh_initiator_nonce = xmalloc(fin->nonce_length);
if (fin->dh_initiator_nonce == NULL) {
- ERROR("no memory");
+ LOG(LOG_ERR, "no memory");
return PTS_FATAL;
}
/* set random */
rc = getRandom(fin->dh_initiator_nonce, fin->nonce_length);
if (rc != TSS_SUCCESS) {
- ERROR("get random fail\n");
+ LOG(LOG_ERR, "get random fail\n");
return PTS_INTERNAL_ERROR;
}
/* check */
if (ctx == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
fin = ctx->fin;
if (fin == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
* Usage
*/
void usage(void) {
- fprintf(stderr, NLS(MS_OPENPTS, OPENPTS_USAGE, "OpenPTS command\n\n"
+ OUTPUT(NLS(MS_OPENPTS, OPENPTS_USAGE_1,
+ "OpenPTS command\n\n"
"Usage: openpts [options] {-i [-f]|[-v]||-r|-D} <target>\n"
" openpts -D\n\n"
"Commands:\n"
" -h Show this help message\n"
" -V Verbose mode. Multiple -V options increase the verbosity.\n"
"\n"
- "Options:\n"
+ "Options:\n"));
#ifdef CONFIG_AUTO_RM_UPDATE
- " -u Accept a measurement update during attestation, if there are any available.\n"
+ OUTPUT(NLS(MS_OPENPTS, OPENPTS_USAGE_2,
+ " -u Accept a measurement update during attestation, if there are any available.\n"));
#endif
+ OUTPUT(NLS(MS_OPENPTS, OPENPTS_USAGE_3,
" -l username ssh username [ssh default]\n"
" -p port ssh port number [ssh default]\n"
" -c configfile Set configuration file [~/.openpts/openpts.conf]\n"
#define DISPLAY 4
#define NONE 5
-
+#define OPENPTS_LOG_FILENAME "~/.openpts/openpts.log"
cmdline_hostname = argv[0];
+ /* default logging scheme */
+ debugBits = 0;
+ setLogLocation(OPENPTS_LOG_FILE, OPENPTS_LOG_FILENAME);
/* check */
if ((ptsc_path != NULL) && (ptsc_conf != NULL)) {
int len;
// char ptsc_command[PATH_MAX];
- INFO("ptsc debug mode\n");
+ LOG(LOG_INFO, "ptsc debug mode\n");
// len = strlen(ptsc_path) + strlen(ptsc_conf) + 13;
// snprintf(ptsc_command, PATH_MAX - 1, "%s -m -v -c %s", ptsc_path, ptsc_conf);
len = strlen(ptsc_path) + strlen(ptsc_conf) + 13;
ptsc_command = xmalloc(len);
snprintf(ptsc_command, len, "%s -m -v -c %s", ptsc_path, ptsc_conf);
- INFO("command: %s\n", ptsc_command);
+ LOG(LOG_INFO, "command: %s\n", ptsc_command);
}
/* default command is to verify */
if (command == NONE) command = VERIFY;
-#if 0 // 2011-12-28 controlled by conf
- /* Log */
- setLogLocation(OPENPTS_LOG_CONSOLE, NULL);
-#ifdef OPENPTS_DEBUG
- setDebugFlags(DEBUG_FLAG | DEBUG_FSM_FLAG | DEBUG_IFM_FLAG);
-#else
- /* set the DEBUG level, 1,2,3
- WORK NEEDED - should have a debug flag too. */
-
- if (getVerbosity() > 2) {
- setDebugFlags(DEBUG_FLAG | DEBUG_FSM_FLAG | DEBUG_IFM_FLAG);
- DEBUG("verbose mode : >=3");
- } else if (getVerbosity() > 1) {
- setDebugFlags(DEBUG_FLAG | DEBUG_IFM_FLAG);
- DEBUG("verbose mode : 2");
- } else if (getVerbosity() > 0) {
- setDebugFlags(DEBUG_FLAG);
- DEBUG("verbose mode : 1");
- }
-#endif
-#endif // 0
-
/* Set logging (location,filename) by ENV */
determineLogLocationByEnv();
// setLogLocation(OPENPTS_LOG_CONSOLE, NULL);
- VERBOSE(1, NLS(MS_OPENPTS, OPENPTS_VERIFIER_CONFIG_FILE,
+ VERBOSE(2, NLS(MS_OPENPTS, OPENPTS_VERIFIER_CONFIG_FILE,
"Config file : %s\n"), conf->config_file);
- VERBOSE(1, NLS(MS_OPENPTS, OPENPTS_VERIFIER_VERBOSITY,
+ VERBOSE(2, NLS(MS_OPENPTS, OPENPTS_VERIFIER_VERBOSITY,
"Verbosity : %d\n"), getVerbosity());
- VERBOSE(1, NLS(MS_OPENPTS, OPENPTS_VERIFIER_DEBUG_OUT,
+ VERBOSE(2, NLS(MS_OPENPTS, OPENPTS_VERIFIER_DEBUG_OUT,
"Logging location : %s\n"), getLogLocationString());
- VERBOSE(1, NLS(MS_OPENPTS, OPENPTS_VERIFIER_DEBUG_MODE,
+ VERBOSE(2, NLS(MS_OPENPTS, OPENPTS_VERIFIER_DEBUG_MODE,
"Logging(debig) mode : 0x%x\n"), getDebugFlags());
/* we always need the target list */
/* look up the conf of target(hostname) */
/* set the target hostname:port and search */
if (conf->hostname != NULL) {
- TODO("realloc conf->hostname\n");
+ LOG(LOG_TODO, "realloc conf->hostname\n");
xfree(conf->hostname);
}
conf->hostname = smalloc_assert(cmdline_hostname);
/* look up */
if (target_collector != NULL) {
// WORK NEEDED: Please use NLS for i18n output
- printf("hostname : %s\n", target_hostname);
- printf("UUID : %s\n", target_collector->str_uuid);
- printf("State : %d\n", target_collector->state);
- printf("Dir : %s\n", target_collector->dir);
- printf("Manifests :\n");
+ OUTPUT("hostname : %s\n", target_hostname);
+ OUTPUT("UUID : %s\n", target_collector->str_uuid);
+ OUTPUT("State : %d\n", target_collector->state);
+ OUTPUT("Dir : %s\n", target_collector->dir);
+ OUTPUT("Manifests :\n");
getRmList(target_conf, target_conf->config_dir);
printRmList(target_conf, "");
if (command == REMOVE) {
/* delete */
if (unlinkDir(target_conf_dir) != 0) {
- ERROR("unlinkDir(%s) failed", target_conf_dir);
+ LOG(LOG_ERR, "unlinkDir(%s) failed", target_conf_dir);
retVal = RETVAL_TARGET_ERROR;
goto out_free;
}
if (ssh_username != NULL) {
target_conf->ssh_username = strdup(ssh_username);
if (target_conf->ssh_username == NULL) {
- ERROR("No memory");
+ LOG(LOG_ERR, "No memory");
retVal = RETVAL_GLOBAL_ERROR;
goto out_free;
}
DEBUG("conf->config_dir %s\n", conf->config_dir);
rc = enroll(ctx, target_hostname, ssh_username, ssh_port, conf->config_dir, force); // verifier.c
if (rc != 0) {
- DEBUG("enroll was failed, rc = %d\n", rc);
+ ERROR( // TODO NLS
+ "enroll was failed, rc = %d\n", rc);
printReason(ctx, print_pcr_hints);
retVal = RETVAL_NOTENROLLED;
goto out_free;
DEBUG("conf->config_dir %s\n", conf->config_dir);
rc = verifier(ctx, target_hostname, ssh_username, ssh_port, conf->config_dir, 1); // init
if (rc != OPENPTS_RESULT_VALID) {
- ERROR("initial verification was failed, rc = %d\n", rc);
+ LOG(LOG_ERR, "initial verification was failed, rc = %d\n", rc);
+ ERROR( // TODO NLS
+ "initial verification was failed, rc = %d\n", rc);
printReason(ctx, print_pcr_hints);
retVal = RETVAL_NOTTRUSTED;
goto out_free;
retVal = RETVAL_OK_TRUSTED;
/* message */
- printf(NLS(MS_OPENPTS, OPENPTS_INIT_TARGET, "Target: %s\n"), target_hostname);
+ VERBOSE(1, NLS(MS_OPENPTS, OPENPTS_INIT_TARGET,
+ "Target: %s\n"), target_hostname);
if (ctx->target_conf != NULL) {
if (ctx->target_conf->rm_uuid != NULL) {
- printf(NLS(MS_OPENPTS, OPENPTS_INIT_MANIFEST_UUID,
+ VERBOSE(1, NLS(MS_OPENPTS, OPENPTS_INIT_MANIFEST_UUID,
"Manifest UUID: %s\n"), ctx->target_conf->rm_uuid->str);
for (i = 0; i< ctx->conf->rm_num; i ++) {
- printf(NLS(MS_OPENPTS, OPENPTS_INIT_MANIFEST,
+ VERBOSE(1, NLS(MS_OPENPTS, OPENPTS_INIT_MANIFEST,
"Manifest[%d]: %s\n"), i, ctx->target_conf->rm_filename[i]);
}
}
/* having indentation specific to one language will make the
translated versions (i.e. french, japanese) look ugly */
- printf(NLS(MS_OPENPTS, OPENPTS_INIT_COLLECTOR_UUID,
+ VERBOSE(1, NLS(MS_OPENPTS, OPENPTS_INIT_COLLECTOR_UUID,
"Collector UUID: %s\n"), ctx->target_conf->uuid->str);
- printf(NLS(MS_OPENPTS, OPENPTS_INIT_CONFIG,
+ VERBOSE(1, NLS(MS_OPENPTS, OPENPTS_INIT_CONFIG,
"Configuration: %s\n"), ctx->target_conf->config_file);
- printf(NLS(MS_OPENPTS, OPENPTS_INIT_VALIDATION,
+ VERBOSE(1, NLS(MS_OPENPTS, OPENPTS_INIT_VALIDATION,
"Validation policy: %s\n"), ctx->target_conf->policy_filename);
} else {
// TODO never happen?
- printf(NLS(MS_OPENPTS, OPENPTS_INIT_NEW_CONFIG, "Configuration: new target\n"));
+ OUTPUT(NLS(MS_OPENPTS, OPENPTS_INIT_NEW_CONFIG,
+ "Configuration: new target\n"));
}
break;
}
rc = verifier(ctx, target_hostname, ssh_username, ssh_port, conf->config_dir, 0); // normal
/* messages */
- // printf("target : %s\n", argv[0]);
- printf(NLS(MS_OPENPTS, OPENPTS_VERIFY_TARGET, "Target: %s\n"), target_hostname);
+ VERBOSE(1, NLS(MS_OPENPTS, OPENPTS_VERIFY_TARGET,
+ "Target: %s\n"), target_hostname);
if (target_conf != NULL) {
- printf(NLS(MS_OPENPTS, OPENPTS_VERIFY_COLLECTOR_UUID, "Collector UUID: %s "), target_conf->uuid->str);
+ VERBOSE(1, NLS(MS_OPENPTS, OPENPTS_VERIFY_COLLECTOR_UUID, "Collector UUID: %s "), target_conf->uuid->str);
// TODO set this when load the uuid
if (target_conf->uuid->time == NULL) {
target_conf->uuid->time = getDateTimeOfUuid(target_conf->uuid->uuid);
}
- printf(NLS(MS_OPENPTS, OPENPTS_VERIFY_DATE, "(date: %04d-%02d-%02d-%02d:%02d:%02d)\n"),
+ VERBOSE(1, NLS(MS_OPENPTS, OPENPTS_VERIFY_DATE,
+ "(date: %04d-%02d-%02d-%02d:%02d:%02d)\n"),
target_conf->uuid->time->year + 1900,
target_conf->uuid->time->mon + 1,
target_conf->uuid->time->mday,
target_conf->uuid->time->hour,
target_conf->uuid->time->min,
target_conf->uuid->time->sec);
- printf(NLS(MS_OPENPTS, OPENPTS_VERIFY_MANIFEST_UUID,
+ VERBOSE(1, NLS(MS_OPENPTS, OPENPTS_VERIFY_MANIFEST_UUID,
"Manifest UUID: %s "), target_conf->rm_uuid->str);
- printf(NLS(MS_OPENPTS, OPENPTS_VERIFY_DATE, "(date: %04d-%02d-%02d-%02d:%02d:%02d)\n"),
+ VERBOSE(1, NLS(MS_OPENPTS, OPENPTS_VERIFY_DATE,
+ "(date: %04d-%02d-%02d-%02d:%02d:%02d)\n"),
target_conf->rm_uuid->time->year + 1900,
target_conf->rm_uuid->time->mon + 1,
target_conf->rm_uuid->time->mday,
target_conf->rm_uuid->time->min,
target_conf->rm_uuid->time->sec);
- printf(NLS(MS_OPENPTS, OPENPTS_VERIFY_USERNAME, "username(ssh): %s\n"),
+ VERBOSE(1, NLS(MS_OPENPTS, OPENPTS_VERIFY_USERNAME,
+ "username(ssh): %s\n"),
conf->ssh_username ? conf->ssh_username : "default");
- printf(NLS(MS_OPENPTS, OPENPTS_VERIFY_PORT, "port(ssh): %s\n"),
+ VERBOSE(1, NLS(MS_OPENPTS, OPENPTS_VERIFY_PORT,
+ "port(ssh): %s\n"),
conf->ssh_port ? conf->ssh_port : "default");
- printf(NLS(MS_OPENPTS, OPENPTS_VERIFY_POLICY, "policy file: %s\n"), target_conf->policy_filename);
- printf(NLS(MS_OPENPTS, OPENPTS_VERIFY_PROPERTY,
+ VERBOSE(1, NLS(MS_OPENPTS, OPENPTS_VERIFY_POLICY,
+ "policy file: %s\n"), target_conf->policy_filename);
+ VERBOSE(1, NLS(MS_OPENPTS, OPENPTS_VERIFY_PROPERTY,
"property file: %s\n"), target_conf->prop_filename); // TODO property or prop
} else {
retVal = RETVAL_GLOBAL_ERROR;
}
if (rc == OPENPTS_RESULT_VALID) {
- printf(NLS(MS_OPENPTS, OPENPTS_VERIFY_VALID, "integrity: valid\n"));
+ OUTPUT(NLS(MS_OPENPTS, OPENPTS_VERIFY_VALID, "integrity: valid\n"));
retVal = RETVAL_OK_TRUSTED;
} else if (rc == OPENPTS_RESULT_INVALID ||
rc == PTS_VERIFY_FAILED ||
rc == PTS_NOT_INITIALIZED || // <-- happens when a target changed its UUID (re-init)
rc == PTS_RULE_NOT_FOUND) { // <-- happens when a target has updated its RM
// (failed selftest using -s)
- printf(NLS(MS_OPENPTS, OPENPTS_VERIFY_INVALID, "integrity: invalid\n"));
+ ERROR(NLS(MS_OPENPTS, OPENPTS_VERIFY_INVALID,
+ "integrity: invalid\n"));
printReason(ctx, print_pcr_hints);
retVal = RETVAL_NOTTRUSTED;
goto out_free;
} else if (rc == OPENPTS_RESULT_UNKNOWN) {
- printf(NLS(MS_OPENPTS, OPENPTS_VERIFY_UNKNOWN, "integrity: unknown\n"));
+ ERROR(NLS(MS_OPENPTS, OPENPTS_VERIFY_UNKNOWN,
+ "integrity: unknown\n"));
printReason(ctx, print_pcr_hints);
retVal = RETVAL_TARGET_ERROR;
goto out_free;
} else {
- printf(NLS(MS_OPENPTS, OPENPTS_VERIFY_ERROR, "integrity: unknown (INTERNAL ERROR) rc=%d\n"), rc);
+ ERROR(NLS(MS_OPENPTS, OPENPTS_VERIFY_ERROR,
+ "integrity: unknown (INTERNAL ERROR) rc=%d\n"), rc);
printReason(ctx, print_pcr_hints);
retVal = RETVAL_TARGET_ERROR;
goto out_free;
printHex(NLS(MS_OPENPTS, OPENPTS_VERIFY_NEW_UUID_LOCAL,
"NEWRM UUID (local): "), (BYTE*)target_conf->newrm_uuid->uuid, 16, "\n");
} else {
- printf(NLS(MS_OPENPTS, OPENPTS_VERIFY_NEW_UUID_MISSING, "NEWRM UUID (local): missing\n"));
+ OUTPUT(NLS(MS_OPENPTS, OPENPTS_VERIFY_NEW_UUID_MISSING,
+ "NEWRM UUID (local): missing\n"));
}
}
(BYTE*)target_conf->newrm_uuid->uuid, 16) &&
0 == isNewRmStillValid(ctx, conf->config_dir) ) {
/* HIT */
- printf("---------------------------------------------------------\n");
- printf(NLS(MS_OPENPTS, OPENPTS_VERIFY_NEW_MANIFEST_UUID,
+ OUTPUT("---------------------------------------------------------\n");
+ OUTPUT(NLS(MS_OPENPTS, OPENPTS_VERIFY_NEW_MANIFEST_UUID,
"New Manifest UUID: %s "), target_conf->newrm_uuid->str);
- printf(NLS(MS_OPENPTS, OPENPTS_VERIFY_DATE, "(date: %04d-%02d-%02d-%02d:%02d:%02d)\n"),
+ OUTPUT(NLS(MS_OPENPTS, OPENPTS_VERIFY_DATE,
+ "(date: %04d-%02d-%02d-%02d:%02d:%02d)\n"),
target_conf->newrm_uuid->time->year + 1900,
target_conf->newrm_uuid->time->mon + 1,
target_conf->newrm_uuid->time->mday,
goto out_free;
} else {
/* local is old? */
- printf(NLS(MS_OPENPTS, OPENPTS_VERIFY_NEW_MANIFEST_ALREADY_EXISTS,
+ OUTPUT(NLS(MS_OPENPTS, OPENPTS_VERIFY_NEW_MANIFEST_ALREADY_EXISTS,
"A new reference manifest has been received, but an update exists\n"));
}
}
/* msg */
- printf("---------------------------------------------------------\n");
+ OUTPUT("---------------------------------------------------------\n");
uuid_time = getDateTimeOfUuid(conf->target_newrm_uuid);
uuid_str = getStringOfUuid(conf->target_newrm_uuid);
- printf(NLS(MS_OPENPTS, OPENPTS_VERIFY_NEW_MANIFEST_UUID, "New Manifest UUID: %s "), uuid_str);
- printf(NLS(MS_OPENPTS, OPENPTS_VERIFY_DATE, "(date: %04d-%02d-%02d-%02d:%02d:%02d)\n"),
+ OUTPUT(NLS(MS_OPENPTS, OPENPTS_VERIFY_NEW_MANIFEST_UUID,
+ "New Manifest UUID: %s "), uuid_str);
+ OUTPUT(NLS(MS_OPENPTS, OPENPTS_VERIFY_DATE,
+ "(date: %04d-%02d-%02d-%02d:%02d:%02d)\n"),
uuid_time->year + 1900,
uuid_time->mon + 1,
uuid_time->mday,
if (isatty(STDIN_FILENO) && !update_by_default) {
char *lineFeed;
- printf(NLS(MS_OPENPTS, OPENPTS_VERIFY_NEW_MANIFEST_UPDATE,
+ OUTPUT(NLS(MS_OPENPTS, OPENPTS_VERIFY_NEW_MANIFEST_UPDATE,
"A new reference manifest exists. Update? [Y/n]\n"));
if ( NULL != fgets(ans, 32, stdin) ) {
// strip the ending line-feed
if (ansIsYes) {
rc = updateNewRm(ctx, target_hostname, conf->config_dir); // aru.c
if (rc == PTS_SUCCESS) {
- printf(NLS(MS_OPENPTS, OPENPTS_VERIFY_SAVE_NEW_MANIFEST, "Save new reference manifest\n"));
+ OUTPUT(NLS(MS_OPENPTS, OPENPTS_VERIFY_SAVE_NEW_MANIFEST,
+ "Save new reference manifest\n"));
// TODO UUID
retVal = RETVAL_OK_TRUSTED;
} else {
retVal = RETVAL_TARGET_ERROR;
}
} else if (ansIsNo) {
- printf(NLS(MS_OPENPTS, OPENPTS_VERIFY_KEEP_CURRENT_MANIFEST, "Keep current manifest\n"));
+ OUTPUT(NLS(MS_OPENPTS, OPENPTS_VERIFY_KEEP_CURRENT_MANIFEST,
+ "Keep current manifest\n"));
retVal = RETVAL_OK_PENDINGUPDATE;
} else {
- ERROR("Bad answer %s, exit\n", ans);
+ LOG(LOG_ERR, "Bad answer %s, exit\n", ans);
retVal = RETVAL_GLOBAL_ERROR;
goto out_free;
}
// TODO validate new RM
// TODO e.g. gen new RM by verifier and compare both
} else if (rc == PTS_RULE_NOT_FOUND) {
- printf(NLS(MS_OPENPTS, OPENPTS_VERIFY_RUN_OPENPTS,
+ OUTPUT(NLS(MS_OPENPTS, OPENPTS_VERIFY_RUN_OPENPTS,
"A new reference manifest exists. If this is expected, "
"please update the manifest with 'openpts -i -f'\n"));
retVal = RETVAL_NOTENROLLED;
}
#else
if (rc == PTS_RULE_NOT_FOUND) {
- printf(NLS(MS_OPENPTS, OPENPTS_VERIFY_RUN_OPENPTS,
+ OUTPUT(NLS(MS_OPENPTS, OPENPTS_VERIFY_RUN_OPENPTS,
"A new reference manifest exists. If this is expected, "
"please update the manifest with 'openpts -i -f'\n"));
retVal = RETVAL_NOTENROLLED;
int freePolicyChain(OPENPTS_POLICY *pol) {
/* check */
if (pol == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
/* check */
if (ctx == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
if (filename == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
/* new */
pol = xmalloc(sizeof(OPENPTS_POLICY));
if (pol == NULL) {
- ERROR("no memory");
+ LOG(LOG_ERR, "no memory");
cnt = -1; // return -1;
goto error;
}
/* check */
if (ctx == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
pol = ctx->policy_start;
/* check */
if (ctx == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
pol = ctx->policy_start;
/* check */
if (name == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return NULL;
}
if (value == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return NULL;
}
prop = (OPENPTS_PROPERTY *) xmalloc(sizeof(OPENPTS_PROPERTY));
if (prop == NULL) {
- ERROR("no memory");
+ LOG(LOG_ERR, "no memory");
return NULL;
}
memset(prop, 0, sizeof(OPENPTS_PROPERTY));
prop->name = smalloc_assert(name);
if (prop->name == NULL) {
- ERROR("no memory");
+ LOG(LOG_ERR, "no memory");
return NULL;
}
prop->value = smalloc_assert(value);
if (prop->value == NULL) {
- ERROR("no memory");
+ LOG(LOG_ERR, "no memory");
return NULL;
}
void freeProperty(OPENPTS_PROPERTY *prop) {
/* check */
if (prop == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return;
}
/* check */
if (name == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return NULL;
}
prop = ctx->prop_start;
while (prop != NULL) {
if (prop->name == NULL) {
- ERROR("getProperty(%s) fail, bad property entry exist", name);
+ LOG(LOG_ERR, "getProperty(%s) fail, bad property entry exist", name);
return NULL;
}
/* malloc new prop */
prop = newProperty(name, value);
if (prop == NULL) {
- ERROR("newProperty() fail");
+ LOG(LOG_ERR, "newProperty() fail");
return PTS_FATAL;
}
/* check */
if (ctx == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
if (name == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
if (value == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
/* check */
if (ctx == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
if (name == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
if (value == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
/* check, missing event */
if (eventWrapper == NULL) {
- ERROR("setEventProperty() - eventWrapper is NULL\n");
+ LOG(LOG_ERR, "setEventProperty() - eventWrapper is NULL\n");
return PTS_FATAL; // 0; // PTS_INTERNAL_ERROR;
}
if (eventWrapper->event == NULL) {
- ERROR("setEventProperty() - event is NULL\n");
+ LOG(LOG_ERR, "setEventProperty() - event is NULL\n");
return PTS_FATAL; // 0; // PTS_INTERNAL_ERROR;
}
if (eventWrapper->event->rgbPcrValue == NULL) {
- ERROR("setEventProperty() - rgbPcrValue is NULL\n");
+ LOG(LOG_ERR, "setEventProperty() - rgbPcrValue is NULL\n");
return PTS_FATAL; // 0; // PTS_INTERNAL_ERROR;
}
SHA1_DIGEST_SIZE,
&buf_len);
if (buf == NULL) {
- ERROR("encodeBase64 fail");
+ LOG(LOG_ERR, "encodeBase64 fail");
return PTS_FATAL;
}
rc = setProperty(ctx, name, buf);
free(buf);
if (rc != PTS_SUCCESS) {
- ERROR("setProperty() fail");
+ LOG(LOG_ERR, "setProperty() fail");
return PTS_FATAL;
}
return rc;
/* check, missing event */
if (eventWrapper == NULL) {
- ERROR("setEventProperty() - eventWrapper is NULL\n");
+ LOG(LOG_ERR, "setEventProperty() - eventWrapper is NULL\n");
return PTS_FATAL; // 0; // PTS_INTERNAL_ERROR;
}
event = eventWrapper->event;
if (event == NULL) {
- ERROR("setEventProperty() - event is NULL\n");
+ LOG(LOG_ERR, "setEventProperty() - event is NULL\n");
return PTS_FATAL; // 0; // PTS_INTERNAL_ERROR;
}
if (event->ulEventLength > 0) {
char * str;
if (event->rgbEvent == NULL) {
- ERROR("setEventProperty() - rgbEvent is NULL\n");
+ LOG(LOG_ERR, "setEventProperty() - rgbEvent is NULL\n");
return PTS_FATAL; // 0; // PTS_INTERNAL_ERROR;
}
/* get String */
str = snmalloc((char*)event->rgbEvent, event->ulEventLength);
if (str == NULL) {
- ERROR("no memory");
+ LOG(LOG_ERR, "no memory");
return PTS_INTERNAL_ERROR;
}
xfree(str);
rc = setProperty(ctx, name, str); // TODO 2011-02-03 SM implement
if (rc != PTS_SUCCESS) {
- ERROR("setProperty() fail");
+ LOG(LOG_ERR, "setProperty() fail");
return PTS_FATAL;
}
return rc;
} else {
- ERROR("missing rgbEvent");
+ LOG(LOG_ERR, "missing rgbEvent");
return PTS_INTERNAL_ERROR;
}
// NULL
if (!strcmp(value, "notexist")) {
rc = setProperty(ctx, name, value); // TODO
if (rc != PTS_SUCCESS) {
- ERROR("setProperty() fail");
+ LOG(LOG_ERR, "setProperty() fail");
return PTS_FATAL;
}
return rc;
/* others */
rc = setProperty(ctx, name, value);
if (rc != PTS_SUCCESS) {
- ERROR("setProperty() fail");
+ LOG(LOG_ERR, "setProperty() fail");
return PTS_FATAL;
}
return rc;
/* check */
if (ctx == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
if (name == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
if (value == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
if (prop == NULL) {
/* name miss? */
- ERROR("validateProperty - property %s is missing\n", name);
+ LOG(LOG_ERR, "validateProperty - property %s is missing\n", name);
rc = OPENPTS_FSM_ERROR;
} else {
/* name hit? check the value */
/* check */
if (ctx == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return;
}
/* check */
if (ctx == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
if (filename == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
/* open */
if ((fp = fopen(filename, "w")) == NULL) {
- ERROR("File %s open was failed\n", filename);
+ LOG(LOG_ERR, "File %s open was failed\n", filename);
return PTS_INTERNAL_ERROR;
}
/* get properties chain*/
prop = ctx->prop_start;
if (prop == NULL) {
- ERROR("properties is NULL\n");
+ LOG(LOG_ERR, "properties is NULL\n");
fclose(fp);
return PTS_INTERNAL_ERROR;
}
/* check */
if (conf == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
if (ctx == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
/* Init RMs */
rc = getRmSetDir(conf);
if (rc != PTS_SUCCESS) {
- ERROR("collector() - getRmSetDir() was failed\n");
+ LOG(LOG_ERR, "collector() - getRmSetDir() was failed\n");
return PTS_INTERNAL_ERROR;
}
}
- INFO("start collector (System UUID=%s, RM UUID = %s)\n",
+ LOG(LOG_INFO, "start collector (System UUID=%s, RM UUID = %s)\n",
conf->uuid->str, conf->rm_uuid->str);
/* Collector <-> Verifier - handshake loop */
/* check bad TLV */
if (read_tlv->type == 0) {
- ERROR("Bad TLV type received - quit");
+ LOG(LOG_ERR, "Bad TLV type received - quit");
break;
}
if (read_tlv->length > 0 && read_tlv->value == NULL) {
- ERROR("Malformed TLV message (ghost body) - quit");
+ LOG(LOG_ERR, "Malformed TLV message (ghost body) - quit");
break;
}
DEBUG("IF-M OPENPTS_CAPABILITIES\n");
/* check the UUID */
if (read_tlv->length != sizeof(OPENPTS_IF_M_Capability)) { // TODO use defined name
- ERROR("Bad PTS_CAPABILITIES, len = %d != %d\n",
+ LOG(LOG_ERR, "Bad PTS_CAPABILITIES, len = %d != %d\n",
read_tlv->length, sizeof(OPENPTS_IF_M_Capability));
terminate = 1;
} else {
ctx->str_uuid = getStringOfUuid(ctx->uuid);
/* syslog */
- INFO("verifier (UUID=%s)\n", ctx->str_uuid);
+ LOG(LOG_INFO, "verifier (UUID=%s)\n", ctx->str_uuid);
/* send PTS_CAPABILITIES msg. to verifier (=UUID) */
rc = writePtsTlv(ctx, STDOUT_FILENO, OPENPTS_CAPABILITIES);
if (rc < 0) {
- ERROR("Send CAPABILITY answer failed - quit");
+ LOG(LOG_ERR, "Send CAPABILITY answer failed - quit");
terminate = 1;
}
}
DEBUG("IF-M DH_NONCE_PARAMETERS_REQUEST\n");
/* check */
if (read_tlv->length != 4) {
- ERROR("Bad DH_NONCE_PARAMETERS_REQUEST, len = %d != 4\n", read_tlv->length);
+ LOG(LOG_ERR, "Bad DH_NONCE_PARAMETERS_REQUEST, len = %d != 4\n", read_tlv->length);
terminate = 1;
} else {
/* req -> res */
rc = writePtsTlv(
ctx, STDOUT_FILENO, DH_NONCE_PARAMETORS_RESPONSE);
if (rc < 0) {
- ERROR("Send NONCE answer failed - quit");
+ LOG(LOG_ERR, "Send NONCE answer failed - quit");
terminate = 1;
}
}
DEBUG("IF-M DH_NONCE_FINISH\n");
/* check */
if (read_tlv->length != 152) { // TODO how to calc this size?
- ERROR("Bad DH_NONCE_FINISH, len = %d != 152\n", read_tlv->length);
+ LOG(LOG_ERR, "Bad DH_NONCE_FINISH, len = %d != 152\n", read_tlv->length);
terminate = 1;
} else {
/* finish */
DEBUG("IF-M REQUEST_RIMM_SET\n");
/* check */
if (read_tlv->length != 0) {
- ERROR("Bad REQUEST__RIMM_SET, len = %d != 0\n", read_tlv->length);
+ LOG(LOG_ERR, "Bad REQUEST__RIMM_SET, len = %d != 0\n", read_tlv->length);
terminate = 1;
} else {
rc = writePtsTlv(
ctx, STDOUT_FILENO, RIMM_SET);
if (rc < 0) {
- ERROR("Send RIMM_SET answer failed - quit");
+ LOG(LOG_ERR, "Send RIMM_SET answer failed - quit");
terminate = 1;
}
}
DEBUG("IF-M REQUEST_NEW_RIMM_SET\n");
/* check */
if (read_tlv->length != 0) {
- ERROR("Bad REQUEST_NEW_RIMM_SET, len = %d != 0\n", read_tlv->length);
+ LOG(LOG_ERR, "Bad REQUEST_NEW_RIMM_SET, len = %d != 0\n", read_tlv->length);
terminate = 1;
} else {
rc = writePtsTlv(
DEBUG("IF-M REQUEST_INTEGRITY_REPORT\n");
/* check */
if (read_tlv->length != 0) {
- ERROR("Bad REQUEST_INTEGRITY_REPORT, len = %d != 0\n", read_tlv->length);
+ LOG(LOG_ERR, "Bad REQUEST_INTEGRITY_REPORT, len = %d != 0\n", read_tlv->length);
terminate = 1;
} else {
rc = writePtsTlv(ctx, STDOUT_FILENO, INTEGRITY_REPORT);
if (rc < 0) {
- ERROR("Send INTEGRITY_REPORT answer failed - quit");
+ LOG(LOG_ERR, "Send INTEGRITY_REPORT answer failed - quit");
terminate = 1;
}
}
break;
#ifdef CONFIG_AIDE
case REQUEST_AIDE_DATABASE:
- INFO("IF-M REQUEST_AIDE_DATABASE\n");
+ LOG(LOG_INFO, "IF-M REQUEST_AIDE_DATABASE\n");
/* check */
if (read_tlv->length != 0) {
- ERROR("Bad REQUEST_AIDE_DATABASE, len = %d != 0\n", read_tlv->length);
+ LOG(LOG_ERR, "Bad REQUEST_AIDE_DATABASE, len = %d != 0\n", read_tlv->length);
terminate = 1;
} else {
rc = writePtsTlv(ctx, STDOUT_FILENO, AIDE_DATABASE);
if (rc < 0) {
- ERROR("Send REQUEST_AIDE_DATABASE answer failed - quit");
+ LOG(LOG_ERR, "Send REQUEST_AIDE_DATABASE answer failed - quit");
terminate = 1;
}
}
case REQUEST_TPM_PUBKEY:
/* check */
if (read_tlv->length != 0) {
- ERROR("Bad REQUEST_TPM_PUBKEY, len = %d != 0\n", read_tlv->length);
+ LOG(LOG_ERR, "Bad REQUEST_TPM_PUBKEY, len = %d != 0\n", read_tlv->length);
terminate = 1;
} else {
rc = writePtsTlv(ctx, STDOUT_FILENO, TPM_PUBKEY); // ifm.c
if (rc < 0) {
- ERROR("Send TPM_PUBKEY answer failed - quit");
+ LOG(LOG_ERR, "Send TPM_PUBKEY answer failed - quit");
terminate = 1;
}
}
case NONCE:
/* check */
if (read_tlv->length != 20) {
- ERROR("Bad NONCE, len = %d != 20\n", read_tlv->length);
+ LOG(LOG_ERR, "Bad NONCE, len = %d != 20\n", read_tlv->length);
terminate = 1;
} else {
/* set nonce */
}
break;
case OPENPTS_ERROR:
- ERROR("verifier returns error, termnate\n");
+ LOG(LOG_ERR, "verifier returns error, termnate\n");
terminate = 1;
break;
default:
- ERROR("PTS IF-M type 0x%08x is not supported\n", read_tlv->type);
- INFO("send OPENPTS_ERROR msg to verifier, then terminate the conenction");
+ LOG(LOG_ERR, "PTS IF-M type 0x%08x is not supported\n", read_tlv->type);
+ LOG(LOG_INFO, "send OPENPTS_ERROR msg to verifier, then terminate the conenction");
ctx->ifm_errno = PTS_UNRECOGNIZED_COMMAND;
if (ctx->ifm_strerror != NULL) {
xfree(ctx->ifm_strerror);
* Usage
*/
void usage(void) {
- fprintf(stderr, NLS(MS_OPENPTS, OPENPTS_COLLECTOR_USAGE_1, "OpenPTS Collector\n\n"
- "Usage: ptsc [options] [command]\n\n"
- "Commands: (foreground)\n"
- " -i Initialize PTS collector\n"
- " -t Self test (attestation)\n"
- " -s Startup (selftest + timestamp)\n"
- " -u Update the RM\n"
- " -e Clear PTS collector\n"));
+ OUTPUT(NLS(MS_OPENPTS, OPENPTS_COLLECTOR_USAGE_1,
+ "OpenPTS Collector\n\n"
+ "Usage: ptsc [options] [command]\n\n"
+ "Commands: (foreground)\n"
+ " -i Initialize PTS collector\n"
+ " -t Self test (attestation)\n"
+ " -s Startup (selftest + timestamp)\n"
+ " -u Update the RM\n"
+ " -e Clear PTS collector\n"));
#ifdef CONFIG_AUTO_RM_UPDATE
- fprintf(stderr, NLS(MS_OPENPTS, OPENPTS_COLLECTOR_USAGE_2,
- " -U Update the RM (auto)\n"));
+ OUTPUT(NLS(MS_OPENPTS, OPENPTS_COLLECTOR_USAGE_2,
+ " -U Update the RM (auto)\n"));
#endif
- fprintf(stderr, NLS(MS_OPENPTS, OPENPTS_COLLECTOR_USAGE_3,
- " -D Display the configuration\n"
- " -m IF-M mode\n"
- "\n"
- "Miscellaneous:\n"
- " -h Show this help message\n"
- " -v Verbose mode. Multiple -v options increase the verbosity.\n"
- "\n"
- "Options:\n"
- " -c configfile Set configuration file. defalt is %s\n"
- " -P name=value Set properties.\n"
- " -R Remove RMs\n"
- " -z Set the SRK secret to all zeros (20 bytes of zeros)\n"), PTSC_CONFIG_FILE);
+ OUTPUT(NLS(MS_OPENPTS, OPENPTS_COLLECTOR_USAGE_3,
+ " -D Display the configuration\n"
+ " -m IF-M mode\n"
+ "\n"
+ "Miscellaneous:\n"
+ " -h Show this help message\n"
+ " -v Verbose mode. Multiple -v options increase the verbosity.\n"
+ "\n"
+ "Options:\n"
+ " -c configfile Set configuration file. defalt is %s\n"
+ " -P name=value Set properties.\n"
+ " -R Remove RMs\n"
+ " -z Set the SRK secret to all zeros (20 bytes of zeros)\n"), PTSC_CONFIG_FILE);
}
enum COMMAND {
prop = newProperty(name, value);
return prop;
} else {
- ERROR("bad property %s\n", arg);
+ LOG(LOG_ERR, "bad property %s\n", arg);
return NULL;
}
}
}
buf = xmalloc(buf_len);
if (buf == NULL) {
- ERROR("no memory");
+ LOG(LOG_ERR, "no memory");
exit(1);
}
oldmask = umask(0);
if (mkdir(LOCK_DIR, 0775) < 0 && errno != EEXIST) {
- ERROR("mkdir(%s) fail", LOCK_DIR);
+ LOG(LOG_ERR, "mkdir(%s) fail", LOCK_DIR);
exit(1);
}
if (grpent) {
}
fd = open(LOCK_FILE, O_RDWR | O_CREAT | O_TRUNC, 0660);
if (fd < 0) {
- ERROR("open(%s) fail", LOCK_DIR);
+ LOG(LOG_ERR, "open(%s) fail", LOCK_DIR);
exit(1);
}
umask(oldmask);
if (lockf(fd, F_LOCK, 0) < 0) {
- ERROR("lockf(%s) fail", LOCK_DIR);
+ LOG(LOG_ERR, "lockf(%s) fail", LOCK_DIR);
exit(1);
}
#if 0
/* check UID */
if ((ptscd_pwd = getpwnam_r(PTSCD_USER_NAME)) == NULL) {
- ERROR("Looking up for user %s", PTSCD_USER_NAME);
+ LOG(LOG_ERR, "Looking up for user %s", PTSCD_USER_NAME);
return PTS_FATAL;
}
#endif
/* check GID */
// ptsc_grp = getgrnam(PTSC_GROUP_NAME); // TODO use getgrnam_r
// if (ptsc_grp == NULL) {
- // ERROR("Looking up for group (name=%s) fail", PTSC_GROUP_NAME);
+ // LOG(LOG_ERR, "Looking up for group (name=%s) fail", PTSC_GROUP_NAME);
// return PTS_FATAL;
// }
buf_len = sysconf(_SC_GETGR_R_SIZE_MAX);
}
buf = xmalloc(buf_len);
if (buf == NULL) {
- ERROR("no memory");
+ LOG(LOG_ERR, "no memory");
return PTS_FATAL;
}
rc = getgrnam_r(PTSC_GROUP_NAME, &grp, buf, buf_len, &ptsc_grp);
if (rc != 0) {
- ERROR("getgrnam_r(%s) fail", PTSC_GROUP_NAME);
+ LOG(LOG_ERR, "getgrnam_r(%s) fail", PTSC_GROUP_NAME);
rc = PTS_FATAL;
goto free;
}
if (ptsc_grp == NULL) {
- ERROR("ptsc_grp == NULL");
+ LOG(LOG_ERR, "ptsc_grp == NULL");
rc = PTS_FATAL;
goto free;
}
rc = setgid(grp.gr_gid);
if (rc < 0) {
// TODO do not need for IF-M access (read only)
- INFO("Switching group (gid=%d) fail. %s\n", grp.gr_gid, strerror(errno));
+ LOG(LOG_INFO, "Switching group (gid=%d) fail. %s\n", grp.gr_gid, strerror(errno));
// TODO 20110927 FAIL
rc = PTS_FATAL;
goto free;
#if 0
if (setuid(ptscd_pwd->pw_uid) == -1) {
- ERROR("Switching to user %s", PTSCD_USER_NAME);
+ LOG(LOG_ERR, "Switching to user %s", PTSCD_USER_NAME);
return PTS_FATAL;
}
#endif
/* check GID */
// ptsc_grp = getgrnam(PTSC_GROUP_NAME); // TODO use getgrnam_r
// if (ptsc_grp == NULL) {
- // ERROR("Looking up for group %s", PTSC_GROUP_NAME);
+ // LOG(LOG_ERR, "Looking up for group %s", PTSC_GROUP_NAME);
// return PTS_FATAL;
// }
buf_len = sysconf(_SC_GETGR_R_SIZE_MAX);
}
buf = xmalloc(buf_len);
if (buf == NULL) {
- ERROR("no memory");
+ LOG(LOG_ERR, "no memory");
return PTS_FATAL;
}
rc = getgrnam_r(PTSC_GROUP_NAME, &grp, buf, buf_len, &ptsc_grp);
if (rc != 0) {
- ERROR("getgrnam_r");
+ LOG(LOG_ERR, "getgrnam_r");
rc = PTS_FATAL;
goto free;
}
if (ptsc_grp == NULL) {
- ERROR("ptsc_grp == NULL");
+ LOG(LOG_ERR, "ptsc_grp == NULL");
rc = PTS_FATAL;
goto free;
}
// TODO chgrp
rc = preparePriv();
if (rc != PTS_SUCCESS) {
- ERROR("preparePriv fail\n");
+ LOG(LOG_ERR, "preparePriv fail\n");
}
conf = newPtsConfig();
if (conf == NULL) {
- ERROR("internal error\n"); // TODO(munetoh)
+ LOG(LOG_ERR, "internal error\n"); // TODO(munetoh)
return -1;
}
#endif
// TODO chgrp
rc = preparePriv();
if (rc != PTS_SUCCESS) {
- INFO("preparePriv fail\n");
+ LOG(LOG_INFO, "preparePriv fail\n");
}
}
conf = newPtsConfig();
if (conf == NULL) {
- ERROR("internal error\n"); // TODO(munetoh)
+ LOG(LOG_ERR, "internal error\n"); // TODO(munetoh)
return -1;
}
-//#if 0 // TODO Renew in v0.2.6
-// /* DEBUG level, 1,2,3 */
-//#ifdef OPENPTS_DEBUG
-// setDebugFlags(DEBUG_FLAG | DEBUG_FSM_FLAG | DEBUG_IFM_FLAG);
-//#else
/* set the DEBUG level, 1,2,3 */
if (getVerbosity() > 2) {
setDebugFlags(DEBUG_FLAG | DEBUG_IFM_FLAG | DEBUG_FSM_FLAG | DEBUG_CAL_FLAG );
} else if (getVerbosity() > 0) {
setDebugFlags(DEBUG_FLAG);
}
-//#endif
-//#endif
DEBUG("VERBOSITY (%d), DEBUG mode (0x%x)\n", getVerbosity(), getDebugFlags());
}
}
- /* PTSC IF-M DEBUG MODE */
- // TODO SET BY CONF
+ /* logging */
/* Check initialization */
if (command != COMMAND_INIT) {
/* initilized? */
if (checkFile(conf->uuid->filename) != OPENPTS_FILE_EXISTS) {
// missing
- printf("ptsc is not initialized yet.\n\n");
+ LOG(LOG_ERR, "ptsc is not initialized yet");
+ ERROR( // TODO NLS
+ "ptsc is not initialized yet.\n\n");
goto free;
}
}
-
/* only do this when needed */
if (command != COMMAND_STATUS) {
/* check IR dir */
if (checkDir(conf->ir_dir) != PTS_SUCCESS) {
rc = makeDir(conf->ir_dir);
if (rc != PTS_SUCCESS) {
- ERROR("Can not create the dir to store IR, %s\n", conf->ir_dir);
+ LOG(LOG_ERR, "Can not create the dir to store IR, %s\n", conf->ir_dir);
goto free;
}
rc = chmodDir(conf->ir_dir, 1);
if (rc != PTS_SUCCESS) {
- ERROR("Can not create the dir to store IR, %s\n", conf->ir_dir);
+ LOG(LOG_ERR, "Can not create the dir to store IR, %s\n", conf->ir_dir);
goto free;
}
}
/* RM UUID */
if (conf->rm_uuid == NULL) {
- ERROR("rm_uuid is missing");
+ LOG(LOG_ERR, "rm_uuid is missing");
/* Exit */
goto free;
} else {
/* NEWRM UUID */
if (conf->newrm_uuid == NULL) {
- ERROR("newrm_uuid is missing.");
+ LOG(LOG_ERR, "newrm_uuid is missing.");
/* Exit */
goto free;
} else {
/* load RSA PUB key */
// TODO single key => multiple keys?
#ifdef CONFIG_NO_TSS
- TODO("CONFIG_NO_TSS, no TPM_PUBKEY\n");
+ LOG(LOG_TODO, "CONFIG_NO_TSS, no TPM_PUBKEY\n");
conf->pubkey_length = 0;
conf->pubkey = NULL;
#else
&conf->pubkey_length,
&conf->pubkey);
if (rc != TSS_SUCCESS) {
- ERROR("getTssPubKey() fail rc=0x%x srk password mode=%d, key =%s\n",
+ LOG(LOG_ERR, "getTssPubKey() fail rc=0x%x srk password mode=%d, key =%s\n",
rc, conf->srk_password_mode, conf->uuid->str);
OUTPUT(NLS(MS_OPENPTS, OPENPTS_TPM_TSS_COMMS_FAILURE,
"TSS communications failure. Is tcsd running?\n"));
/* update RMs */
rc = update(conf, prop_num, start, end, remove);
if (rc != PTS_SUCCESS) {
- ERROR("update was fail\n");
+ LOG(LOG_ERR, "update was fail\n");
}
break;
#endif
rc = selftest(conf, prop_num, start, end);
if (rc == OPENPTS_SELFTEST_SUCCESS) {
OUTPUT(NLS(MS_OPENPTS, OPENPTS_COLLECTOR_SUCCESS, "selftest - OK\n"));
- INFO("selftest - OK\n");
+ LOG(LOG_INFO, "selftest - OK\n");
} else if (rc == OPENPTS_SELFTEST_RENEWED) {
OUTPUT(NLS(MS_OPENPTS, OPENPTS_COLLECTOR_RENEWED, "selftest - Renewed\n"));
- INFO("selftest - Renewed\n");
+ LOG(LOG_INFO, "selftest - Renewed\n");
} else if (rc == OPENPTS_SELFTEST_FALLBACK) {
OUTPUT(NLS(MS_OPENPTS, OPENPTS_COLLECTOR_FALLBACK, "selftest - fallback\n"));
- INFO("selftest - fallback\n");
+ LOG(LOG_INFO, "selftest - fallback\n");
} else if (rc == OPENPTS_SELFTEST_FAILED) {
OUTPUT(NLS(MS_OPENPTS, OPENPTS_COLLECTOR_FAIL, "selftest - fail\n"));
- INFO("selftest - fail\n");
+ LOG(LOG_INFO, "selftest - fail\n");
} else {
- ERROR("TBD\n");
+ LOG(LOG_ERR, "TBD\n");
}
break;
case COMMAND_STARTUP:
rc = selftest(conf, prop_num, start, end);
if (rc == OPENPTS_SELFTEST_SUCCESS) {
OUTPUT(NLS(MS_OPENPTS, OPENPTS_COLLECTOR_SUCCESS, "selftest - OK\n"));
- INFO("selftest - OK\n");
+ LOG(LOG_INFO, "selftest - OK\n");
/* timestamp */
extendEvCollectorStart(conf); // collector.c
} else if (rc == OPENPTS_SELFTEST_RENEWED) {
OUTPUT(NLS(MS_OPENPTS, OPENPTS_COLLECTOR_RENEWED, "selftest - Renewed\n"));
- INFO("selftest - Renewed\n");
+ LOG(LOG_INFO, "selftest - Renewed\n");
/* timestamp */
extendEvCollectorStart(conf);
} else if (rc == OPENPTS_SELFTEST_FALLBACK) {
OUTPUT(NLS(MS_OPENPTS, OPENPTS_COLLECTOR_FALLBACK, "selftest - fallback\n"));
- INFO("selftest - fallback\n");
+ LOG(LOG_INFO, "selftest - fallback\n");
/* timestamp */
extendEvCollectorStart(conf);
} else if (rc == OPENPTS_SELFTEST_FAILED) {
OUTPUT(NLS(MS_OPENPTS, OPENPTS_COLLECTOR_FAIL, "selftest - fail\n"));
- INFO("selftest - fail\n");
+ LOG(LOG_INFO, "selftest - fail\n");
if (conf->autoupdate == 1) {
- ERROR("selftest failed, trying to generate a new manifest\n");
+ LOG(LOG_ERR, "selftest failed, trying to generate a new manifest\n");
/* del RM_UUID */
conf->rm_uuid->status = OPENPTS_UUID_FILENAME_ONLY;
if (conf->rm_uuid->uuid != NULL) freeUuid(conf->rm_uuid->uuid);
if (rc != PTS_SUCCESS) {
OUTPUT(NLS(MS_OPENPTS, OPENPTS_COLLECTOR_UPDATE_RM_FAIL,
"Failed to generated a reference manifest\n"));
- INFO("Failed to generated a reference manifest\n");
+ LOG(LOG_INFO, "Failed to generated a reference manifest\n");
goto free;
}
rc = selftest(conf, prop_num, start, end);
OUTPUT(NLS(MS_OPENPTS, OPENPTS_COLLECTOR_SUCCESS, "selftest - OK\n"));
OUTPUT(NLS(MS_OPENPTS, OPENPTS_COLLECTOR_UPDATE_RM_SUCCESS,
"Successfully generated the reference manifest\n"));
- INFO("selftest - OK\n");
- INFO("Successfully generated the reference manifest\n");
+ LOG(LOG_INFO, "selftest - OK\n");
+ LOG(LOG_INFO, "Successfully generated the reference manifest\n");
} else if (rc == OPENPTS_SELFTEST_RENEWED) {
OUTPUT(NLS(MS_OPENPTS, OPENPTS_COLLECTOR_RENEWED, "selftest - Renewed\n"));
- INFO("selftest - Renewed\n");
+ LOG(LOG_INFO, "selftest - Renewed\n");
} else {
- ERROR("TBD\n");
+ LOG(LOG_ERR, "TBD\n");
}
} else {
OUTPUT(NLS(MS_OPENPTS, OPENPTS_COLLECTOR_UPDATE_RM_WONT,
"selftest failed, keeping existing manifests as requested by configuration\n"));
- INFO("selftest failed, keeping existing manifests as requested by configuration\n");
+ LOG(LOG_INFO, "selftest failed, keeping existing manifests as requested by configuration\n");
}
} else {
- ERROR("TBD\n");
+ LOG(LOG_ERR, "TBD\n");
}
break;
case COMMAND_UPDATE:
/* gen new RM_UUID and RM */
rc = newrm(conf, prop_num, start, end);
if (rc != PTS_SUCCESS) {
- ERROR("newrm() fail\n");
+ LOG(LOG_ERR, "newrm() fail\n");
goto free;
}
VERBOSE(1, NLS(MS_OPENPTS, OPENPTS_COLLECTOR_UPDATE_RM_SUCCESS,
"Successfully generated the reference manifest\n"));
} else if (rc == OPENPTS_SELFTEST_RENEWED) {
- TODO("TBD\n");
+ LOG(LOG_TODO, "TBD\n");
} else {
- TODO("TBD\n");
+ LOG(LOG_TODO, "TBD\n");
}
break;
case COMMAND_IFM:
rc = collector2(conf);
break;
default:
- ERROR("bad command\n");
+ LOG(LOG_ERR, "bad command\n");
break;
}
vsnprintf(buf, LOGMAX, fmt, ap);
va_end(ap);
if (foreground) {
- fprintf(stderr, "%s\n", buf);
+ ERROR( // TODO NLS
+ "%s\n", buf);
fflush(stderr);
} else {
- syslog(msglevel ? LOG_INFO : LOG_CRIT, "%s", buf);
+ syslog(msglevel ? LOG_INFO : LOG_CRIT, "%s", buf); // TODO use LOG?
}
}
if (argc > 0) {
usage:
- fprintf(stderr, NLS(MS_OPENPTS, OPENPTS_PTSEVTD_USAGE,
+ OUTPUT(NLS(MS_OPENPTS, OPENPTS_PTSEVTD_USAGE,
"syntax: ptsevtd [-df] [-p port] [-c command]\n"));
exit(1);
}
void freeReason(OPENPTS_REASON *reason) {
/* check */
if (reason == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return;
}
int freeReasonChain(OPENPTS_REASON *reason) {
/* check */
if (reason == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
/* check */
if (ctx == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
reason = (OPENPTS_REASON *) xmalloc(sizeof(OPENPTS_REASON));
if (reason == NULL) {
- ERROR("no memory");
+ LOG(LOG_ERR, "no memory");
return PTS_FATAL;
}
memset(reason, 0, sizeof(OPENPTS_REASON));
reason->pcr = pcr;
reason->message = xmalloc(len +1);
if (reason->message == NULL) {
- ERROR("no memory");
+ LOG(LOG_ERR, "no memory");
xfree(reason);
return PTS_FATAL;
}
/* check */
if (ctx == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
/* check */
if (ctx == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return;
}
reason = ctx->reason_start;
ctx = (OPENPTS_RM_CONTEXT *) xmalloc(sizeof(OPENPTS_RM_CONTEXT));
if (ctx == NULL) {
- ERROR("no memory");
+ LOG(LOG_ERR, "no memory");
return NULL;
}
void freeRmContext(OPENPTS_RM_CONTEXT *ctx) {
/* check */
if (ctx == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return;
}
/* check */
if (writer == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
if (id == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
if (ctx == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
return PTS_SUCCESS;
error:
- ERROR("writeCoreComponentID - internal error\n");
+ LOG(LOG_ERR, "writeCoreComponentID - internal error\n");
return PTS_INTERNAL_ERROR;
}
/* check */
if (writer == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
if (id == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
if (event == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
return PTS_SUCCESS;
error:
- ERROR("writeCoreValues() internal error");
+ LOG(LOG_ERR, "writeCoreValues() internal error");
return PTS_INTERNAL_ERROR;
}
/* check */
if (writer == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
if (ss == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
/* Events at PCR[index] & Snapshot */
eventWrapper = ss->start;
if (eventWrapper == NULL) {
- ERROR("writeAllCoreValues() - ERROR: eventWrapper is NULL\n");
+ LOG(LOG_ERR, "writeAllCoreValues() - ERROR: eventWrapper is NULL\n");
return PTS_FATAL;
}
fsm_binary = ss->fsm_binary;
DEBUG_FSM("writeAllCoreValues - PCR[%d] event %d/%d\n", ss->pcrIndex, j + 1, ss->event_num);
if (eventWrapper == NULL) {
- ERROR("writeAllCoreValues() - eventWrapper is NULL, pcr[%d], event_num = %d count = %d\n",
+ LOG(LOG_ERR, "writeAllCoreValues() - eventWrapper is NULL, pcr[%d], event_num = %d count = %d\n",
ss->pcrIndex, ss->event_num, j);
return PTS_FATAL;
}
event = eventWrapper->event;
if (event == NULL) {
- ERROR("writeAllCoreValues() - Event is missing\n");
+ LOG(LOG_ERR, "writeAllCoreValues() - Event is missing\n");
return PTS_FATAL;
}
bin_trans = bhv_trans->link; // BHV keeps the link to BIN
if (bin_trans == NULL) { // TODO old
UINT32 i;
- ERROR("writeAllCoreValues() - BIN Trans is missing");
- ERROR("\tat the event: pcrindex=%d, eventype=%d, digest=",
+ LOG(LOG_ERR, "writeAllCoreValues() - BIN Trans is missing");
+ LOG(LOG_ERR, "\tat the event: pcrindex=%d, eventype=%d, digest=",
event->ulPcrIndex, event->eventType);
for (i = 0;i < event->ulPcrValueLength; i++)
- ERROR("%02x", event->rgbPcrValue[i]);
+ LOG(LOG_ERR, "%02x", event->rgbPcrValue[i]);
return PTS_FATAL;
}
DEBUG_FSM("LOOP, base64->real digest\n");
rc = insertFsmNew(fsm_binary, bin_trans, eventWrapper);
if (rc != PTS_SUCCESS) {
- ERROR("insertFsmNew() fail");
+ LOG(LOG_ERR, "insertFsmNew() fail");
goto error;
}
} else {
rc = writeCoreValues(writer, algtype, id, event);
if (rc != PTS_SUCCESS) {
- ERROR("writeCoreValues() fail");
+ LOG(LOG_ERR, "writeCoreValues() fail");
goto error;
}
}
} else { // NULL?
- ERROR("ERROR no trans\n");
+ LOG(LOG_ERR, "ERROR no trans\n");
rc = PTS_INTERNAL_ERROR;
goto error;
}
return PTS_SUCCESS;
error:
- ERROR("writeCoreValues ERROR\n");
+ LOG(LOG_ERR, "writeCoreValues ERROR\n");
return PTS_INTERNAL_ERROR;
}
/* check */
if (writer == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
if (sub == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
return PTS_SUCCESS;
error:
- ERROR("writeFsmSubvertex() internal error");
+ LOG(LOG_ERR, "writeFsmSubvertex() internal error");
return PTS_INTERNAL_ERROR;
}
/* check */
if (writer == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
if (trans == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
return PTS_SUCCESS;
error:
- ERROR("writeFsmTransition() internal error");
+ LOG(LOG_ERR, "writeFsmTransition() internal error");
return PTS_INTERNAL_ERROR;
}
/* check */
if (writer == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
if (fsm == NULL) {
- ERROR("writeFsmModel - FSM is NULL");
+ LOG(LOG_ERR, "writeFsmModel - FSM is NULL");
return PTS_FATAL;
}
return PTS_SUCCESS;
error:
- ERROR("writeFsmModel() internal error");
+ LOG(LOG_ERR, "writeFsmModel() internal error");
return PTS_INTERNAL_ERROR;
}
/* check */
if (writer == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
if (ss == NULL) {
- ERROR("writeValidationModel - OPENPTS_SNAPSHOT is NULL\n");
+ LOG(LOG_ERR, "writeValidationModel - OPENPTS_SNAPSHOT is NULL\n");
return PTS_FATAL;
}
// TODO(munetoh)
rc = writeFsmModel(writer, ss->fsm_binary);
if (rc < 0) {
- ERROR("writeValidationModel() pcr=%d BIN-FSM is NULL\n", ss->pcrIndex);
+ LOG(LOG_ERR, "writeValidationModel() pcr=%d BIN-FSM is NULL\n", ss->pcrIndex);
goto error;
}
return PTS_SUCCESS;
error:
- ERROR("writeValidationModel() internal error");
+ LOG(LOG_ERR, "writeValidationModel() internal error");
return PTS_INTERNAL_ERROR;
}
/* check */
if (writer == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
if (ctx == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
if ((ss != NULL) && (ss->event_num > 0)) {
rc = writeValidationModel(writer, ss);
if (rc < 0) {
- ERROR("writeCoreAssertionInfo() - pcr=%d, level=%d\n", i, level);
+ LOG(LOG_ERR, "writeCoreAssertionInfo() - pcr=%d, level=%d\n", i, level);
goto error;
}
}
return PTS_SUCCESS;
error:
- ERROR("writeCoreAssertionInfo() internal error");
+ LOG(LOG_ERR, "writeCoreAssertionInfo() internal error");
return PTS_INTERNAL_ERROR;
}
/* check */
if (ctx == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
if (file == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
/* Create a new XML buffer */
buf = xmlBufferCreate();
if (buf == NULL) {
- ERROR("Error creating the xml buffer\n");
+ LOG(LOG_ERR, "Error creating the xml buffer\n");
rc = PTS_INTERNAL_ERROR;
goto error;
}
/* Create a new XmlWriter for memory */
writer = xmlNewTextWriterMemory(buf, 0);
if (writer == NULL) {
- ERROR("Error creating the xml writer\n");
+ LOG(LOG_ERR, "Error creating the xml writer\n");
rc = PTS_INTERNAL_ERROR;
goto freexml;
}
/* indent the XML :-) */
rc = xmlTextWriterSetIndent(writer, 1); // libxml2
if (rc < 0) {
- ERROR("Error at xmlTextWriterSetIndent\n");
+ LOG(LOG_ERR, "Error at xmlTextWriterSetIndent\n");
rc = PTS_INTERNAL_ERROR;
goto free;
}
/* Start the document */
rc = xmlTextWriterStartDocument(writer, "1.0", XML_ENCODING, "no");
if (rc < 0) {
- ERROR("Error at xmlTextWriterStartDocument\n");
+ LOG(LOG_ERR, "Error at xmlTextWriterStartDocument\n");
rc = PTS_INTERNAL_ERROR;
goto free;
}
/* Start an element named "Report", the root element of the document. */
rc = xmlTextWriterStartElement(writer, BAD_CAST "Rimm");
if (rc < 0) {
- ERROR("Error at xmlTextWriterStartElement\n");
+ LOG(LOG_ERR, "Error at xmlTextWriterStartElement\n");
rc = PTS_INTERNAL_ERROR;
goto free;
}
/* new UUID */
ir_uuid = newUuid();
if (ir_uuid == NULL) {
- ERROR("UUID gen\n");
+ LOG(LOG_ERR, "UUID gen\n");
rc = PTS_INTERNAL_ERROR;
goto freexml;
}
str_ir_uuid = getStringOfUuid(ir_uuid);
if (str_ir_uuid == NULL) {
- ERROR("UUID gen\n");
+ LOG(LOG_ERR, "UUID gen\n");
xfree(ir_uuid);
rc = PTS_INTERNAL_ERROR;
goto freexml;
BAD_CAST "xmlns:core",
BAD_CAST XMLNS_CORE);
if (rc < 0) {
- ERROR("Error at xmlTextWriterWriteAttribute\n");
+ LOG(LOG_ERR, "Error at xmlTextWriterWriteAttribute\n");
rc = PTS_INTERNAL_ERROR;
goto free;
}
BAD_CAST "xmlns:stuff",
BAD_CAST XMLNS_STUFF);
if (rc < 0) {
- ERROR("Error at xmlTextWriterWriteAttribute\n");
+ LOG(LOG_ERR, "Error at xmlTextWriterWriteAttribute\n");
rc = PTS_INTERNAL_ERROR;
goto free;
}
BAD_CAST "xmlns:xsi",
BAD_CAST XMLNS_XSI);
if (rc < 0) {
- ERROR("Error at xmlTextWriterWriteAttribute\n");
+ LOG(LOG_ERR, "Error at xmlTextWriterWriteAttribute\n");
rc = PTS_INTERNAL_ERROR;
goto free;
}
BAD_CAST "xmlns",
BAD_CAST XMLNS_RIMM);
if (rc < 0) {
- ERROR("Error at xmlTextWriterWriteAttribute\n");
+ LOG(LOG_ERR, "Error at xmlTextWriterWriteAttribute\n");
rc = PTS_INTERNAL_ERROR;
goto free;
}
rc = xmlTextWriterWriteAttribute(writer, BAD_CAST "Id", BAD_CAST id);
if (rc < 0) {
- ERROR("Error at xmlTextWriterWriteAttribute\n");
+ LOG(LOG_ERR, "Error at xmlTextWriterWriteAttribute\n");
rc = PTS_INTERNAL_ERROR;
goto free;
}
// TODO(munetoh) set the level
rc = xmlTextWriterWriteAttribute(writer, BAD_CAST "RevLevel", BAD_CAST "0");
if (rc < 0) {
- ERROR("Error at xmlTextWriterWriteAttribute\n");
+ LOG(LOG_ERR, "Error at xmlTextWriterWriteAttribute\n");
rc = PTS_INTERNAL_ERROR;
goto free;
}
rc = xmlTextWriterWriteAttribute(writer,
BAD_CAST "UUID", BAD_CAST str_ir_uuid);
if (rc < 0) {
- ERROR("Error at xmlTextWriterWriteAttribute\n");
+ LOG(LOG_ERR, "Error at xmlTextWriterWriteAttribute\n");
rc = PTS_INTERNAL_ERROR;
goto free;
}
/* copy BHV-FSM to BIN-FSM */
ss->fsm_binary = copyFsm(ss->fsm_behavior);
if (ss->fsm_binary == NULL) {
- ERROR("writeRm() - copy BHV-FSM to BIN-FSM failed at pcr=%d, level=%d\n", i, level);
+ LOG(LOG_ERR, "writeRm() - copy BHV-FSM to BIN-FSM failed at pcr=%d, level=%d\n", i, level);
rc = PTS_INTERNAL_ERROR;
goto free;
}
rc = writeAllCoreValues(writer, ss);
if (rc != PTS_SUCCESS) {
// WORK NEEDED: Please use NLS for i18n
- ERROR("writeAllCoreValues() fail");
+ LOG(LOG_ERR, "writeAllCoreValues() fail");
addReason(ctx, i,
"[RM] The manifest generation was failed at pcr=%d, level=%d", i, level);
addReason(ctx, i,
// single FSM supports various (BIOS) implementations.
rc = cleanupFsm(ss->fsm_binary);
if (rc != PTS_SUCCESS) {
- ERROR("writeRm() - bad IML or FSM at pcr=%d, level=%d\n", i, level);
+ LOG(LOG_ERR, "writeRm() - bad IML or FSM at pcr=%d, level=%d\n", i, level);
rc = PTS_INTERNAL_ERROR;
goto free;
}
/* add FSMs */
rc = writeCoreAssertionInfo(writer, ctx, level);
if (rc != PTS_SUCCESS) {
- ERROR("writeRm - ERROR file %s\n", file);
+ LOG(LOG_ERR, "writeRm - ERROR file %s\n", file);
rc = PTS_INTERNAL_ERROR;
goto free;
}
rc = writeCoreComponentID(writer, id, ctx, level);
if (rc != PTS_SUCCESS) {
- ERROR("writeRm - ERROR file %s\n", file);
+ LOG(LOG_ERR, "writeRm - ERROR file %s\n", file);
rc = PTS_INTERNAL_ERROR;
goto free;
}
/* Close all elements */
rc = xmlTextWriterEndDocument(writer); // libxml2
if (rc < 0) {
- ERROR("testXmlwriterMemory: Error at xmlTextWriterEndDocument\n");
+ LOG(LOG_ERR, "testXmlwriterMemory: Error at xmlTextWriterEndDocument\n");
rc = PTS_INTERNAL_ERROR;
goto free;
}
rc = xmlTextWriterFlush(writer); // libxml2
if (rc < 0) {
- ERROR("writeRm: Error at xmlTextWriterFlush\n");
+ LOG(LOG_ERR, "writeRm: Error at xmlTextWriterFlush\n");
rc = PTS_INTERNAL_ERROR;
goto free;
}
fp = fopen(file, "w");
if (fp == NULL) {
- ERROR("writeRm - fopen fail, file, %s\n", file);
+ LOG(LOG_ERR, "writeRm - fopen fail, file, %s\n", file);
rc = PTS_INTERNAL_ERROR;
goto free;
}
if (fprintf(fp, "%s", (const char *) buf->content) <= 0) {
- ERROR("Failed to write to file %s\n", file);
+ LOG(LOG_ERR, "Failed to write to file %s\n", file);
rc = PTS_INTERNAL_ERROR;
} else {
rc = PTS_SUCCESS;
xmlBufferFree(buf);
if (rc != PTS_SUCCESS) {
- ERROR("writeRm - fail");
+ LOG(LOG_ERR, "writeRm - fail");
} else {
DEBUG_FSM("writeRm - done\n");
}
/* check */
if (ctx == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return;
}
pctx = (OPENPTS_CONTEXT *)ctx;
if (pctx == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return;
}
rm_ctx = pctx->rm_ctx;
if (rm_ctx == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return;
}
/* check */
if (ctx == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return;
}
if (name == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return;
}
if (!strcmp(type, "level")) {
int level = atoi(value);
if (level != rm_ctx->level) {
- TODO("RM level is %d not %d\n", level, rm_ctx->level);
+ LOG(LOG_TODO, "RM level is %d not %d\n", level, rm_ctx->level);
rm_ctx->level = level;
if (level < 0 || level >= MAX_RM_NUM) {
- ERROR("level found in RM (%d) is greater or equal to MAX_RM_NUM (%d)\n",
+ LOG(LOG_ERR, "level found in RM (%d) is greater or equal to MAX_RM_NUM (%d)\n",
level, MAX_RM_NUM);
return;
}
/*new SS */
rm_ctx->snapshot = getNewSnapshotFromTable(pctx->ss_table, rm_ctx->pcr_index, rm_ctx->level);
if (rm_ctx->snapshot == NULL) {
- ERROR("SS is NULL\n");
+ LOG(LOG_ERR, "SS is NULL\n");
return;
}
if (atts != NULL) {
for (i = 0; (atts[i] != NULL); i++) {
type = (char *)atts[i++];
- // printf(", %s='", type);
if (atts[i] != NULL) {
value= (char *)atts[i];
- // printf("%s'", value);
if (!strcmp(type, "xmi:type")) {
snprintf(rm_ctx->subvertex_xmitype, sizeof(rm_ctx->subvertex_xmitype),
"%s", value);
if (atts != NULL) {
for (i = 0; (atts[i] != NULL); i++) {
type = (char *)atts[i++];
- // printf(", %s='", type);
if (atts[i] != NULL) {
value= (char *)atts[i];
- // printf("%s'", value);
if (!strcmp(type, "source")) {
snprintf(rm_ctx->source_xmiid, sizeof(rm_ctx->source_xmiid), "%s", value);
}
if (atts != NULL) {
for (i = 0; (atts[i] != NULL); i++) {
type = (char *)atts[i++];
- // printf(", %s='", type);
if (atts[i] != NULL) {
value= (char *)atts[i];
- // printf("%s'", value);
if (!strcmp(type, "name")) {
snprintf(rm_ctx->doactivity_name, sizeof(rm_ctx->doactivity_name),
"%s", value);
}
}
DEBUG_SAX("doActivity %s\n", rm_ctx->doactivity_name);
- // ERROR("doActivity %s\n", rm_ctx->doactivity_name);
+ // LOG(LOG_ERR, "doActivity %s\n", rm_ctx->doactivity_name);
} else if (!strcmp((char *)name, "name")) {
// TODO(munetoh)
} else if (!strcmp((char *)name, "ownedRule")) {
} else if (strcmp(attributeName, "DiscretePatches") == 0) {
attributeValue = &pctx->compIDs[level].DiscretePatches;
} else {
- ERROR("unknown attribute for Component ID: '%s'\n", attributeName);
+ LOG(LOG_ERR, "unknown attribute for Component ID: '%s'\n", attributeName);
attrIdx++; // attribute
attrIdx++; // skip
continue;
// VendorID_Value
} else {
- ERROR("Unknown ELEMENT [%s] \n", name);
+ LOG(LOG_ERR, "Unknown ELEMENT [%s] \n", name);
rm_ctx->sax_state = RM_SAX_STATE_IDLE;
}
}
/* check*/
if (ctx == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return;
}
if (name == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return;
}
pctx = (OPENPTS_CONTEXT *)ctx;
if (pctx == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return;
}
rm_ctx = pctx->rm_ctx;
if (rm_ctx == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return;
}
rm_ctx->subvertex_name,
rm_ctx->doactivity_name);
// DEBUG
- // ERROR("doActivity %s\n", rm_ctx->doactivity_name);
+ // LOG(LOG_ERR, "doActivity %s\n", rm_ctx->doactivity_name);
} else if (!strcmp((char *)name, "transition")) {
DEBUG_SAX("add transition %s -> %s\n",
rm_ctx->source_xmiid, rm_ctx->target_xmiid);
/* check*/
if (ctx == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return;
}
if (ch == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return;
}
pctx = (OPENPTS_CONTEXT *)ctx;
if (pctx == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return;
}
rm_ctx = pctx->rm_ctx;
if (rm_ctx == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return;
}
/* check */
if (ctx == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
if (filename == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
} else {
/* use existing table */
// TODO
- // ERROR("SS TABLE exist\n");
+ // LOG(LOG_ERR, "SS TABLE exist\n");
}
/* SAX variables */
}
if (level < 0 || level >= MAX_RM_NUM) {
- ERROR("readRmFile - level (%d) is greater or equal to MAX_RM_NUM (%d)\n", level, MAX_RM_NUM);
+ LOG(LOG_ERR, "readRmFile - level (%d) is greater or equal to MAX_RM_NUM (%d)\n", level, MAX_RM_NUM);
return -1;
}
ctx->rm_ctx->level = level;
/* check*/
if (conf == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
if (lstat(buf, &st) == -1) {
/* Missing conf dir => Error */
- fprintf(stderr, NLS(MS_OPENPTS, OPENPTS_RM_CONF_DIR_MISSING,
- "The configuration directory '%s' is missing. Please initialize the collector first\n"), buf);
+ ERROR(NLS(MS_OPENPTS, OPENPTS_RM_CONF_DIR_MISSING,
+ "The configuration directory '%s' is missing. Please initialize the collector first\n"), buf);
rc = PTS_INTERNAL_ERROR;
goto end;
}
DEBUG("RM File : %s\n", conf->rm_filename[i]);
}
} else {
- TODO("getRmSetDir() - conf->rm_basedir == NULL\n");
+ LOG(LOG_TODO, "getRmSetDir() - conf->rm_basedir == NULL\n");
}
rc = PTS_SUCCESS;
/* check*/
if (conf == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
DEBUG("NEWRM File : %s\n", conf->newrm_filename[i]);
}
} else {
- TODO("getNewRmSetDir() - conf->rm_basedir == NULL\n");
+ LOG(LOG_TODO, "getNewRmSetDir() - conf->rm_basedir == NULL\n");
}
rc = PTS_SUCCESS;
/* check*/
if (conf == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
rc = makeDir(buf);
if (rc != PTS_SUCCESS) {
- ERROR("create conf directory, %s was failed\n", buf);
+ LOG(LOG_ERR, "create conf directory, %s was failed\n", buf);
rc = PTS_INTERNAL_ERROR;
goto end;
}
/* check*/
if (conf == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
* usage
*/
void usage(void) {
- fprintf(stderr, NLS(MS_OPENPTS, OPENPTS_RM2DOT_USAGE, "usage: rm2dot [options] RMfile \n"
- "\t-o output\tset output file (default is stdout)\n"
- "\t-p pcrindex\tset PCR index\n"
- "\t-l level\tset snapshot level (0 or 1)\n"
- "\t$ dot -Tpng foo.dot -o foo.png; eog foo.png\n"
- "\n"));
+ OUTPUT(NLS(MS_OPENPTS, OPENPTS_RM2DOT_USAGE,
+ "usage: rm2dot [options] RMfile \n"
+ "\t-o output\tset output file (default is stdout)\n"
+ "\t-p pcrindex\tset PCR index\n"
+ "\t-l level\tset snapshot level (0 or 1)\n"
+ "\t$ dot -Tpng foo.dot -o foo.png; eog foo.png\n"
+ "\n"));
}
/**
/* Read RM(XML) file */
if (input_filename == NULL) {
- printf(NLS(MS_OPENPTS, OPENPTS_RM2DOT_MISSING_XML_FILE, "ERROR missing XMLfile\n"));
+ ERROR(NLS(MS_OPENPTS, OPENPTS_RM2DOT_MISSING_XML_FILE,
+ "Missing XML file\n"));
usage();
return -1;
}
/* new pts context */
conf = newPtsConfig();
if (conf == NULL) {
- ERROR("ERROR\n");
+ LOG(LOG_ERR, "ERROR\n");
return -1;
}
ctx = newPtsContext(conf);
if (ctx == NULL) {
- ERROR("ERROR\n");
+ LOG(LOG_ERR, "ERROR\n");
return -1;
}
/* read RM */
rc = readRmFile(ctx, input_filename, 0);
if (rc != PTS_SUCCESS) {
- ERROR("ERROR readRmFile\n");
+ LOG(LOG_ERR, "ERROR readRmFile\n");
goto error;
}
} else if (level == 1) {
ss = getSnapshotFromTable(ctx->ss_table, pcr_index, 1);
} else {
- fprintf(stderr, NLS(MS_OPENPTS, OPENPTS_RM2DOT_BAD_LEVEL, "ERROR bad level %d\n"), level);
+ ERROR(NLS(MS_OPENPTS, OPENPTS_RM2DOT_BAD_LEVEL,
+ "Bad level %d, the level should be 0 or 1\n"), level);
goto error;
}
rc = writeDotModel(ss->fsm_binary, output_filename);
if (rc != PTS_SUCCESS) {
- ERROR("ERROR writeDotModel\n");
+ LOG(LOG_ERR, "ERROR writeDotModel\n");
goto error;
}
* \brief parse SMBIOS info
* @author Seiji Munetoh <munetoh@users.sourceforge.jp>
* @date 2010-08-29
- * cleanup 2011-01-22 SM
+ * cleanup 2012-01-03 SM
*
* SMBIOS Info in BIOS IML -> platform properties
*
/* exec dmidecode */
pid = fork();
if (pid < 0) {
- ERROR("\n");
+ LOG(LOG_ERR, "\n");
return -1;
}
if (pid == 0) {
// DEBUG("status = %d\n", status);
if (WIFEXITED(status)) {
/* 1 : OK */
- TODO("Exit status %d\n", WEXITSTATUS(status));
+ LOG(LOG_TODO, "Exit status %d\n", WEXITSTATUS(status));
return 1;
} else if (WIFSIGNALED(status)) {
- ERROR("Signal status %d\n", WIFSIGNALED(status));
+ LOG(LOG_ERR, "Signal status %d\n", WIFSIGNALED(status));
return -1;
} else {
- ERROR("Bad exit");
+ LOG(LOG_ERR, "Bad exit");
return -1;
}
}
}
if ((fp = fopen(filename, "rb")) == NULL) {
- ERROR("%s missing\n", filename);
+ LOG(LOG_ERR, "%s missing\n", filename);
rc = PTS_INTERNAL_ERROR;
goto error;
}
/* */
str_length = ptr[0x16] + (ptr[0x17]<<8);
str_num = ptr[0x1C] + (ptr[0x1D]<<8);
- printf(NLS(MS_OPENPTS, OPENPTS_SMBIOS_STRUCTURES,
- "%d structures occupying %d bytes.\n"), str_num, str_length);
eod = ptr + str_length + 32;
// SKIP Head
ptr += 32;
}
-
-
while (1) {
type = ptr[0];
len = ptr[1];
handle = ptr[2] + ptr[3]*256;
- printf(NLS(MS_OPENPTS, OPENPTS_SMBIOS_HANDLE,
- "Handle 0x%04x, DMI type %d(0x%x), %d bytes\n"), handle, type, type, len);
- printHex(NLS(MS_OPENPTS, OPENPTS_SMBIOS_HEAD, " head"), ptr, len, "\n");
if (type == 127) {
- printf(NLS(MS_OPENPTS, OPENPTS_SMBIOS_END_OF_TABLE, "End Of Table\n"));
- // printf("%ld\n", ptr - data);
+ // End Of Table
break;
}
}
if (ptr > eod) {
- printf(NLS(MS_OPENPTS, OPENPTS_SMBIOS_END_OF_TABLE, "End Of Table\n"));
+ // End Of Table
break;
}
ptr++;
ptr++;
- printHex(NLS(MS_OPENPTS, OPENPTS_SMBIOS_BODY, " body"), strings, ptr - strings, "\n");
-
-
if (ptr > eod) {
break;
}
BYTE *strings[10]; // TODO size
BYTE *eod = data + length;
int str_length;
- // int str_num;
int cnt = 0;
int scnt;
OPENPTS_CONFIG *conf = ctx->conf;
/* */
str_length = ptr[0x16] + (ptr[0x17]<<8);
// str_num = ptr[0x1C] + (ptr[0x1D]<<8);
- // printf("%d structures occupying %d bytes.\n", str_num, str_length);
eod = ptr + str_length + 32;
// SKIP Head
ptr += 32;
type = ptr[0];
len = ptr[1];
handle = ptr[2] + ptr[3]*256;
- // printf("Handle 0x%04x, DMI type %d(0x%x), %d bytes\n", handle, type,type, len);
- // printHex(" head",ptr, len, "\n");
if (type == 127) {
- // printf("End Of Table\n");
- // printf("%ld\n", ptr - data);
+ // End Of Table
break;
}
}
if (ptr > eod) {
- // printf("End Of Table\n");
break;
}
ptr++;
ptr++;
- // printHex(" body", strings[0], ptr - strings[0], "\n");
- // printf(" scnt %d\n",scnt);
- // for (i=0;i<scnt;i++) {
- // printf(" %d %s\n",i, strings[i]);
- // }
-
/* to config */
switch (type) {
case 0x0: /* BIOS Information */
ss = (OPENPTS_SNAPSHOT*) xmalloc(sizeof(OPENPTS_SNAPSHOT)); // leaked
if (ss == NULL) {
- ERROR("no memory");
+ LOG(LOG_ERR, "no memory");
return NULL;
}
memset(ss, 0, sizeof(OPENPTS_SNAPSHOT));
/* check */
if (ss == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
sst = (OPENPTS_SNAPSHOT_TABLE *) xmalloc(sizeof(OPENPTS_SNAPSHOT_TABLE)); // leaked
if (sst == NULL) {
- ERROR("no memory");
+ LOG(LOG_ERR, "no memory");
return NULL;
}
memset(sst, 0, sizeof(OPENPTS_SNAPSHOT_TABLE));
/* check */
if (sst == NULL) {
- ERROR(" OPENPTS_SNAPSHOT_TABLE was NULL\n");
+ LOG(LOG_ERR, " OPENPTS_SNAPSHOT_TABLE was NULL\n");
return PTS_FATAL;
}
int addSnapshotToTable(OPENPTS_SNAPSHOT_TABLE * sst, OPENPTS_SNAPSHOT * ss, int pcr_index, int level) {
/* check 1 */
if (sst == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
if (ss == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
if ((pcr_index < 0) || (MAX_PCRNUM <= pcr_index )) {
- ERROR("bad PCR index, %d\n", pcr_index);
+ LOG(LOG_ERR, "bad PCR index, %d\n", pcr_index);
return PTS_INTERNAL_ERROR;
}
if ((level < 0) || (MAX_SSLEVEL <= level)) {
- ERROR("bad level, %d\n", level);
+ LOG(LOG_ERR, "bad level, %d\n", level);
return PTS_INTERNAL_ERROR;
}
/* check 2 */
if (sst->snapshot[pcr_index][level] != NULL) {
- ERROR("snapshot[%d][%d] already exist", pcr_index, level);
+ LOG(LOG_ERR, "snapshot[%d][%d] already exist", pcr_index, level);
return PTS_INTERNAL_ERROR;
}
OPENPTS_SNAPSHOT *getSnapshotFromTable(OPENPTS_SNAPSHOT_TABLE * sst, int pcr_index, int level) {
/* check 1 */
if (sst == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return NULL;
}
if ((pcr_index < 0) || (MAX_PCRNUM <= pcr_index)) {
- ERROR("getSnapshotFromTable() - bad PCR index, %d\n", pcr_index);
+ LOG(LOG_ERR, "getSnapshotFromTable() - bad PCR index, %d\n", pcr_index);
return NULL;
}
if ((level < 0) || (MAX_SSLEVEL <= level)) {
- ERROR("getSnapshotFromTable() - bad level, %d\n", level);
+ LOG(LOG_ERR, "getSnapshotFromTable() - bad level, %d\n", level);
return NULL;
}
OPENPTS_SNAPSHOT *getNewSnapshotFromTable(OPENPTS_SNAPSHOT_TABLE * sst, int pcr_index, int level) {
/* check 1 */
if (sst == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return NULL;
}
if ((pcr_index < 0) || (MAX_PCRNUM <= pcr_index)) {
- ERROR("getSnapshotFromTable() - bad PCR index, %d\n", pcr_index);
+ LOG(LOG_ERR, "getSnapshotFromTable() - bad PCR index, %d\n", pcr_index);
return NULL;
}
if ((level < 0) || (MAX_SSLEVEL <= level)) {
- ERROR("getSnapshotFromTable() - bad level, %d\n", level);
+ LOG(LOG_ERR, "getSnapshotFromTable() - bad level, %d\n", level);
return NULL;
}
sst->snapshot[pcr_index][level]->pcrIndex = pcr_index;
sst->snapshot[pcr_index][level]->level = level;
} else {
- ERROR("getNewSnapshotFromTable() - SS pcr=%d,level=%d already exist\n", pcr_index, level);
+ LOG(LOG_ERR, "getNewSnapshotFromTable() - SS pcr=%d,level=%d already exist\n", pcr_index, level);
return NULL;
}
int level;
/* check 1 */
if (sst == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return NULL;
}
if ((pcr_index < 0) || (MAX_PCRNUM <= pcr_index)) {
- ERROR("getSnapshotFromTable() - bad PCR index, %d\n", pcr_index);
+ LOG(LOG_ERR, "getSnapshotFromTable() - bad PCR index, %d\n", pcr_index);
return NULL;
}
int setActiveSnapshotLevel(OPENPTS_SNAPSHOT_TABLE * sst, int pcr_index, int level) {
/* check */
if (sst == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
if ((pcr_index < 0) || (MAX_PCRNUM <= pcr_index)) {
- ERROR("setActiveSnapshotLevel() - bad PCR index, %d\n", pcr_index);
+ LOG(LOG_ERR, "setActiveSnapshotLevel() - bad PCR index, %d\n", pcr_index);
return PTS_INTERNAL_ERROR;
}
if ((level < 0) || (MAX_SSLEVEL <= level)) {
- ERROR("setActiveSnapshotLevel() - bad level, %d\n", level);
+ LOG(LOG_ERR, "setActiveSnapshotLevel() - bad level, %d\n", level);
return PTS_INTERNAL_ERROR;
}
int incActiveSnapshotLevel(OPENPTS_SNAPSHOT_TABLE * sst, int pcr_index) {
/* check */
if (sst == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
if ((pcr_index < 0) || (MAX_PCRNUM <= pcr_index)) {
- ERROR("bad PCR index, %d\n", pcr_index);
+ LOG(LOG_ERR, "bad PCR index, %d\n", pcr_index);
return PTS_INTERNAL_ERROR;
}
int getActiveSnapshotLevel(OPENPTS_SNAPSHOT_TABLE * sst, int pcr_index) {
/* check */
if (sst == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return -1;
}
if ((pcr_index < 0) || (MAX_PCRNUM <= pcr_index)) {
- ERROR("bad PCR index, %d\n", pcr_index);
+ LOG(LOG_ERR, "bad PCR index, %d\n", pcr_index);
return PTS_INTERNAL_ERROR;
}
/* check */
if (host == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return -1;
}
/* socket */
if (socketpair(AF_UNIX, SOCK_STREAM, 0, socket_pair) == -1) {
- ERROR("socketpair() fail");
+ LOG(LOG_ERR, "socketpair() fail");
goto err;
}
if ((pid = fork()) == -1) {
- ERROR("fork() fail");
+ LOG(LOG_ERR, "fork() fail");
goto err_close;
}
DEBUG("ptsc_command %s\n", ptsc_command);
execvp("ssh", arguments);
- ERROR("execvp(ssh)");
+ LOG(LOG_ERR, "execvp(ssh)");
exit(1);
}
/* check */
if (time1 == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return -1;
}
if (time2 == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return -1;
}
/* check */
if (entry == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return 0;
}
int dir_num;
struct dirent **dir_list;
int i, j;
-
char *tmp_str_uuid;
PTS_UUID *tmp_uuid;
PTS_DateTime *tmp_time;
int tmp_state;
char *tmp_dir;
-
OPENPTS_RMSET *rmset;
OPENPTS_RMSET *rmset1;
OPENPTS_RMSET *rmset2;
- // printf("Show RMs by UUID\n");
- // printf("config dir : %s\n", config_dir);
-
/* check */
if (conf == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
if (config_dir == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
/* move to config dir */
if ((chdir(conf->config_dir)) != 0) {
- fprintf(stderr, "Accessing config directory %s\n", conf->config_dir);
+ ERROR( // TODO NLS
+ "Accessing config directory %s\n", conf->config_dir);
return PTS_INTERNAL_ERROR;
}
/* scan dirs */
dir_num = scandir(".", &dir_list, &selectUuidDir, NULL);
if ( dir_num == -1 ) {
- fprintf(stderr, "no target data\n");
+ ERROR( // TODO NLS
+ "No target data.\n");
return PTS_INTERNAL_ERROR;
}
for (cnt = 0; cnt < dir_num; cnt++) {
rmset = &conf->rmsets->rmset[cnt];
if (rmset == NULL) {
- ERROR("no memory cnt=%d\n", cnt);
+ LOG(LOG_ERR, "no memory cnt=%d\n", cnt);
return PTS_INTERNAL_ERROR;
}
rmset->str_uuid = smalloc(dir_list[cnt]->d_name);
/* sort (bub) */
for (i = 0; i< dir_num - 1; i++) {
for (j = dir_num - 1; j > i; j--) {
- // printf("i=%d, j=%d\n",i,j);
rmset1 = &conf->rmsets->rmset[j-1];
rmset2 = &conf->rmsets->rmset[j];
if (cmpDateTime(rmset1->time, rmset2->time) > 0) {
- // printf("%d <-> %d\n", j-1, j);
-
tmp_str_uuid = rmset2->str_uuid;
tmp_uuid = rmset2->uuid;
tmp_time = rmset2->time;
/* check */
if (dir == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
/* check */
if (conf == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
if (conf->rmsets == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
state = rmset->state;
if (state == OPENPTS_RM_STATE_TRASH) {
- INFO(NLS(MS_OPENPTS, OPENPTS_PURGE_RENEWED_RM, " purge %s\n"), rmset->str_uuid);
+ // INFO(NLS(MS_OPENPTS, OPENPTS_PURGE_RENEWED_RM, " purge %s\n"), rmset->str_uuid);
+ LOG(LOG_INFO, " purge %s\n", rmset->str_uuid);
rc = rmRmsetDir(rmset->dir);
if (rc != PTS_SUCCESS) {
rc2 = PTS_OS_ERROR;
/* check */
if (conf == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return;
}
if (conf->rmsets == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return;
}
/* check */
if (conf == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
if (config_dir == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
if (conf->target_list != NULL) {
/* move to config dir */
if ((chdir(conf->config_dir)) != 0) {
- ERROR("Accessing config directory %s\n", conf->config_dir);
+ LOG(LOG_ERR, "Accessing config directory %s\n", conf->config_dir);
return PTS_INTERNAL_ERROR;
}
/* scan dirs */
dir_num = scandir(".", &dir_list, &selectUuidDir, NULL);
if ( dir_num == -1 ) {
- ERROR("no target data\n");
+ LOG(LOG_ERR, "no target data\n");
return PTS_INTERNAL_ERROR;
}
/* set RM UUID (Mandatory) */
rc = readOpenptsUuidFile(target_conf->rm_uuid);
if (rc != PTS_SUCCESS) {
- ERROR("getTargetList() - readOpenptsUuidFile() fail rc=%d\n", rc);
+ LOG(LOG_ERR, "getTargetList() - readOpenptsUuidFile() fail rc=%d\n", rc);
freeOpenptsUuid(target_conf->rm_uuid);
target_conf->rm_uuid = NULL;
return PTS_INTERNAL_ERROR;
/* check */
if (conf == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return NULL;
}
if (conf->hostname == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return NULL;
}
if (conf->target_list == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return NULL;
}
/* check */
if (conf == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return NULL;
}
if (conf->hostname == NULL) {
- ERROR("null hostname");
+ LOG(LOG_ERR, "null hostname");
return NULL;
}
if (conf->target_list == NULL) {
/* check */
if (conf == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return NULL;
}
if (conf->target_list == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return NULL;
}
if (uuid == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return NULL;
}
/* check */
if (conf == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return;
}
if (conf->target_list == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return;
}
num = conf->target_list->target_num;
if (num == 0) {
- printf("There is no enrolled target platform.\n");
+ OUTPUT( // TODO NLS
+ "There is no enrolled target platform.\n");
return;
}
target_conf->ssh_port ? target_conf->ssh_port : "default");
} else {
DEBUG("target[%d] is NULL, SKIP\n", cnt);
- // printf("--\n");
}
}
OUTPUT("%s%s\n", indent, SEP_LINE);
void debugPrintHex(char *head, BYTE *data, int num, char *tail) {
int i;
if (verbose > 0) {
- printf("%s", head);
+ OUTPUT("%s", head);
for (i = 0; i < num; i++) {
- printf("%02X", data[i]);
+ OUTPUT("%02X", data[i]);
}
- printf("%s", tail);
+ OUTPUT("%s", tail);
}
}
if (filename != NULL) {
/* open */
if ((fp = fopen(filename, "r")) == NULL) {
- ERROR("parseTxtStatFile - %s file is missing\n", filename);
+ LOG(LOG_ERR, "parseTxtStatFile - %s file is missing\n", filename);
return PTS_FATAL; // TODO
}
} else {
/* open */
fp = fopen(filename, "rb");
if (fp == NULL) {
- ERROR("File %s does not exist\n", filename);
+ LOG(LOG_ERR, "File %s does not exist\n", filename);
rc = PTS_FATAL;
goto error;
}
/* open */
fp = gzopen(filename, "rb");
if (fp == NULL) {
- ERROR("File %s does not exist\n", filename);
+ LOG(LOG_ERR, "File %s does not exist\n", filename);
return 0;
}
/* open */
if ((fp = fopen(filename, "r")) == NULL) {
- ERROR("parseTxtStatFile - %s file is missing\n", filename);
+ LOG(LOG_ERR, "parseTxtStatFile - %s file is missing\n", filename);
return PTS_FATAL; // TODO
}
extend(17, digest);
debugPrintHex(" mle v8 PCR17 ", &pcr[17][0], 20, "\n");
} else {
- ERROR("mle_version = %d \n", ctx->mle_version);
+ LOG(LOG_ERR, "mle_version = %d \n", ctx->mle_version);
}
extend(18, ctx->mle_hash);
/* check (within TXT-STAT) */
if (memcmp(&pcr[17][0], ctx->final_pcr17, 20) != 0) {
- ERROR("bad PCR17\n");
+ LOG(LOG_ERR, "bad PCR17\n");
printHex("PCR-17", &pcr[17][0], 20, "\n");
rc = PTS_FATAL;
}
if (memcmp(&pcr[18][0], ctx->final_pcr18, 20) != 0) {
- ERROR("bad PCR18\n");
+ LOG(LOG_ERR, "bad PCR18\n");
printHex("PCR-18", &pcr[18][0], 20, "\n");
rc = PTS_FATAL;
}
if (filename != NULL) {
/* open */
if ((fp = fopen(filename, "wb")) == NULL) {
- ERROR("generateEventlog - %s file can't open\n", filename);
+ LOG(LOG_ERR, "generateEventlog - %s file can't open\n", filename);
return PTS_FATAL; // TODO
}
} else {
} else if (ctx->mle_version == 8) {
- TODO("TBD mle_version = %d \n", ctx->mle_version);
+ LOG(LOG_TODO, "TBD mle_version = %d \n", ctx->mle_version);
} else {
- TODO("TBD mle_version = %d \n", ctx->mle_version);
+ LOG(LOG_TODO, "TBD mle_version = %d \n", ctx->mle_version);
}
module = ctx->module;
if (memcmp(module->digest, ctx->vl_pcr18, 20) != 0) {
- ERROR("Module[0] digest did not match\n");
+ LOG(LOG_ERR, "Module[0] digest did not match\n");
debugPrintHex(" TXT-STAT : ", ctx->vl_pcr18, 20, "\n");
debugPrintHex(" Calc : ", module->digest, 20, "\n");
}
module = ctx->module->next;
if (memcmp(module->digest, ctx->vl_pcr19, 20) != 0) {
- ERROR("Module[1] digest did not match\n");
+ LOG(LOG_ERR, "Module[1] digest did not match\n");
debugPrintHex(" TXT-STAT : ", ctx->vl_pcr19, 20, "\n");
debugPrintHex(" Calc : ", module->digest, 20, "\n");
}
void usage(void) {
- fprintf(stderr, "OpenPTS command\n\n");
- fprintf(stderr, "Usage: tboot2iml [options]\n\n");
- fprintf(stderr, "Options:\n");
- fprintf(stderr, " -i filename txt-stat file to read (default is STDIN)\n");
- fprintf(stderr, " -g filename grub.conf file to read (OPTION)\n");
- fprintf(stderr, " -p path grub path (OPTION)\n");
- fprintf(stderr, " -o filename Output to file (default is STDOUT)\n");
- fprintf(stderr, " -v Verbose message\n");
- fprintf(stderr, " -h Help\n");
- fprintf(stderr, "\n");
+ OUTPUT( // TODO NLS
+ "OpenPTS command\n\n"
+ "Usage: tboot2iml [options]\n\n"
+ "Options:\n"
+ " -i filename txt-stat file to read (default is STDIN)\n"
+ " -g filename grub.conf file to read (OPTION)\n"
+ " -p path grub path (OPTION)\n"
+ " -o filename Output to file (default is STDOUT)\n"
+ " -v Verbose message\n"
+ " -h Help\n"
+ "\n");
}
int main(int argc, char *argv[]) {
}
}
- // printf("tboot to IML (%s)\n", txt_stat_filename);
-
/* check */
if ((grub_conf_filename != NULL) && (grub_path == NULL)) {
- fprintf(stderr, "set the root path used by crub.conf\n");
+ ERROR( // TODO NLS
+ "set the root path used by crub.conf\n");
usage();
goto close;
}
/* parse TXT stat */
rc = parseTxtStatFile(ctx, txt_stat_filename);
if (rc != PTS_SUCCESS) {
- ERROR("parse of %s file was failed\n", txt_stat_filename);
+ LOG(LOG_ERR, "parse of %s file was failed\n", txt_stat_filename);
}
/* parse grub.conf */
/* check */
if (tctx == NULL) {
- ERROR("ERROR TPM_CONTEXT is NULL");
+ LOG(LOG_ERR, "ERROR TPM_CONTEXT is NULL");
return -1;
}
/* check */
if (tctx == NULL) {
- ERROR("ERROR TPM_CONTEXT is NULL");
+ LOG(LOG_ERR, "ERROR TPM_CONTEXT is NULL");
return -1;
}
/* check */
if (digest == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return -1;
}
/* check */
if (digest == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return;
}
/* check */
if (tctx == NULL) {
- ERROR("TPM_CONTEXT is NULL\n");
+ LOG(LOG_ERR, "TPM_CONTEXT is NULL\n");
return PTS_FATAL;
}
if (event == NULL) {
- ERROR("TSS_PCR_EVENT is NULL\n");
+ LOG(LOG_ERR, "TSS_PCR_EVENT is NULL\n");
return PTS_FATAL;
}
digest = event->rgbPcrValue;
if (digest == NULL) {
- ERROR("event->rgbPcrValue is NULL\n");
+ LOG(LOG_ERR, "event->rgbPcrValue is NULL\n");
return PTS_FATAL;
}
index = event->ulPcrIndex;
if (index >= MAX_PCRNUM) {
- ERROR("BAD PCR INDEX %d >= %d\n", index, MAX_PCRNUM);
+ LOG(LOG_ERR, "BAD PCR INDEX %d >= %d\n", index, MAX_PCRNUM);
return PTS_INTERNAL_ERROR;
}
if (index < 0) {
- ERROR("ERROR BAD PCR INDEX %d < 0\n", index);
+ LOG(LOG_ERR, "ERROR BAD PCR INDEX %d < 0\n", index);
return PTS_INTERNAL_ERROR;
}
/* check */
if (tctx == NULL) {
- ERROR("TPM_CONTEXT is NULL\n");
+ LOG(LOG_ERR, "TPM_CONTEXT is NULL\n");
return PTS_FATAL;
}
if (digest == NULL) {
- ERROR("null input\n");
+ LOG(LOG_ERR, "null input\n");
return PTS_FATAL;
}
if (index >= MAX_PCRNUM) {
- ERROR("BAD pcr index, %d >= %d", index, MAX_PCRNUM);
+ LOG(LOG_ERR, "BAD pcr index, %d >= %d", index, MAX_PCRNUM);
return PTS_INTERNAL_ERROR;
}
/* check */
if (tctx == NULL) {
- ERROR("TPM_CONTEXT is NULL\n");
+ LOG(LOG_ERR, "TPM_CONTEXT is NULL\n");
return PTS_FATAL;
}
/* check */
if (tctx == NULL) {
- ERROR("TPM_CONTEXT is NULL\n");
+ LOG(LOG_ERR, "TPM_CONTEXT is NULL\n");
return PTS_FATAL;
}
/* check */
if (tpm == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
if (digest == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
if (index >= MAX_PCRNUM) {
- ERROR("BAD PCR INDEX %d >= %d\n", index, MAX_PCRNUM);
+ LOG(LOG_ERR, "BAD PCR INDEX %d >= %d\n", index, MAX_PCRNUM);
return PTS_INTERNAL_ERROR;
}
if (index < 0) {
- ERROR("ERROR BAD PCR INDEX %d < 0\n", index);
+ LOG(LOG_ERR, "ERROR BAD PCR INDEX %d < 0\n", index);
return PTS_INTERNAL_ERROR;
}
int hex2bin(void *dest, const void *src, size_t n);
void usage() {
-//<<<<<<< HEAD
- printf(NLS(MS_OPENPTS, OPENPTS_TPM_CREATEKEY_USAGE,
+ OUTPUT(NLS(MS_OPENPTS, OPENPTS_TPM_CREATEKEY_USAGE,
"Usage: tpm_createkey [options]\n"
"\t-h Display command usage info.\n"
"\t-u Set UUID of key. Default is randum number\n"
"\t-S Use SYSTEM_PS\n"
"\t-U Use USER_PS\n"
"\t-B filename Use blob file\n"));
-//=======
-// printf("Usage: tpm_createkey [options]\n");
-// printf("\t-h\tDisplay command usage info.\n");
-// printf("\t-u\tSet UUID of key. Default is randum number\n");
-// printf("\t-N\tCreate key without auth secret\n");
-// printf("\t-a PASSWORD\tCreate key with auth secret, PASSWORD\n");
-// printf("\t-P\tUse TSS diaglog to set the authsecret\n");
-// printf("\t-C\tUse common authsecret\n");
-// printf("\t-f\tUpdate the key\n");
-// printf("\t-z\tUse the SRK secret of all zeros (20 bytes of zeros).\n");
-
-// /* Key storage */
-/// printf("\t-S\tUse SYSTEM_PS\n");
-// printf("\t-U\tUse USER_PS\n");
-// printf("\t-B\tUse blob file\n");
-//>>>>>>> 042e40b0979f3e44e75200271e4d1282ce08f72c
}
int hex2bin(void *dest, const void *src, size_t n) {
unsigned char *ussrc = (unsigned char *) src;
if (n & 0x01) {
- ERROR("ERROR: hex2bin wrong size %d\n", (int)n);
+ LOG(LOG_ERR, "ERROR: hex2bin wrong size %d\n", (int)n);
return -1;
}
switch (so) {
case 'u': /* UUID of AIK/SignKey */
if (strlen(optarg) != 32) {
- printf(NLS(MS_OPENPTS, OPENPTS_TPM_CREATEKEY_INVALID_UUID_SIZE, "ERROR invalid UUID size, %s\n"),
+ OUTPUT(NLS(MS_OPENPTS, OPENPTS_TPM_CREATEKEY_INVALID_UUID_SIZE, "ERROR invalid UUID size, %s\n"),
optarg);
usage();
return -1;
}
}
- printf("SM DEBUG\n");
-
if (noauth != 1) {
/* key needs authorization */
initFlag |= TSS_KEY_AUTHORIZATION;
}
-
/* SRK well_known = 0x00 x 20 */
if (srk_password_mode == 1) {
srk_auth = xmalloc(20);
result = Tspi_Context_Create(&hContext);
if (result != TSS_SUCCESS) {
- ERROR("ERROR: Tspi_Context_Create failed rc=0x%x\n",
+ LOG(LOG_ERR, "ERROR: Tspi_Context_Create failed rc=0x%x\n",
result);
goto close;
}
result = Tspi_Context_Connect(hContext, SERVER);
if (result != TSS_SUCCESS) {
- ERROR("ERROR: Tspi_Context_Connect failed rc=0x%x\n",
+ LOG(LOG_ERR, "ERROR: Tspi_Context_Connect failed rc=0x%x\n",
result);
goto close;
}
ppKeyHierarchy);
if (result != TSS_SUCCESS) {
- ERROR("ERROR: Tspi_Context_GetRegisteredKeysByUUID failed rc=0x%x\n",
+ LOG(LOG_ERR, "ERROR: Tspi_Context_GetRegisteredKeysByUUID failed rc=0x%x\n",
result);
} else {
int i;
TSS_KM_KEYINFO *info = ppKeyHierarchy[0];
- printf(NLS(MS_OPENPTS, OPENPTS_TPM_CREATEKEY_KEYNUM, "Key number : %d\n"), ulKeyHierarchySize);
+ OUTPUT(NLS(MS_OPENPTS, OPENPTS_TPM_CREATEKEY_KEYNUM, "Key number : %d\n"), ulKeyHierarchySize);
for (i = 0; i < (int)ulKeyHierarchySize; i++) {
- printf(NLS(MS_OPENPTS, OPENPTS_TPM_CREATEKEY_KEY, "Key %d\n"), i);
+ OUTPUT(NLS(MS_OPENPTS, OPENPTS_TPM_CREATEKEY_KEY, "Key %d\n"), i);
buf = (BYTE *) & info->versionInfo;
printHex(NLS(MS_OPENPTS, OPENPTS_TPM_CREATEKEY_VERSION, " version : "), buf, 4, "\n");
buf = (BYTE *) & info->keyUUID;
result = Tspi_Context_GetTpmObject(hContext, &hTPM);
if (result != TSS_SUCCESS) {
- ERROR("ERROR: Tspi_Context_GetTpmObject failed rc=0x%x\n",
+ LOG(LOG_ERR, "Tspi_Context_GetTpmObject failed rc=0x%x\n",
result);
goto close;
}
&hSRK);
if (result != TSS_SUCCESS) {
- ERROR("ERROR: Tspi_Context_LoadKeyByUUID (SRK) failed rc=0x%x\n",
+ LOG(LOG_ERR, "Tspi_Context_LoadKeyByUUID (SRK) failed rc=0x%x\n",
result);
if (result == 0x2020) {
- printf(NLS(MS_OPENPTS, OPENPTS_TPM_CREATEKEY_BAD_STORAGE,
+ ERROR(NLS(MS_OPENPTS, OPENPTS_TPM_CREATEKEY_BAD_STORAGE,
"The key storage for tcsd is damaged or missing.\n"));
}
goto close;
result = Tspi_GetPolicyObject(hSRK, TSS_POLICY_USAGE, &hSRKPolicy);
if (result != TSS_SUCCESS) {
- printf("ERROR: Tspi_GetPolicyObject failed rc=0x%x\n",
+ LOG(LOG_ERR, "Tspi_GetPolicyObject failed rc=0x%x\n",
result);
goto close;
}
srk_auth_len,
srk_auth);
if (result != TSS_SUCCESS) {
- printf("ERROR: Tspi_Policy_SetSecret failed rc=0x%x\n",
+ LOG(LOG_ERR, "Tspi_Policy_SetSecret failed rc=0x%x\n",
result);
goto close;
}
if (createUuid == 1) {
result = Tspi_TPM_GetRandom(hTPM, sizeof(TSS_UUID), &buf);
if (result != TSS_SUCCESS) {
- printf("ERROR: Tspi_TPM_GetRandom failed rc=0x%x\n",
+ LOG(LOG_ERR, "Tspi_TPM_GetRandom failed rc=0x%x\n",
result);
Tspi_Context_FreeMemory(hContext, NULL);
goto close;
TSS_OBJECT_TYPE_RSAKEY,
initFlag, &hKey);
if (result != TSS_SUCCESS) {
- printf("ERROR: Tspi_Context_CreateObject failed rc=0x%x\n",
+ LOG(LOG_ERR, "Tspi_Context_CreateObject failed rc=0x%x\n",
result);
goto close;
}
char *ps1;
int size0, size1;
-#if 0
- // result = Tspi_GetPolicyObject(hKey, TSS_POLICY_USAGE, &hKeyPolicy);
-
- // -a option
- result =
- Tspi_Context_CreateObject(hContext,
- TSS_OBJECT_TYPE_POLICY,
- TSS_POLICY_USAGE,
- &hKeyPolicy);
-
- if (result != TSS_SUCCESS) {
- printf
- ("ERROR: Tspi_GetPolicyObject failed rc=0x%x\n",
- result);
- goto close;
- }
-#endif
if (popup == 1) {
-#if 0
- result = Tspi_SetAttribUint32(
- hContext,
- TSS_TSPATTRIB_CONTEXT_SILENT_MODE,
- 0,
- TSS_TSPATTRIB_CONTEXT_NOT_SILENT);
-
- if (result != TSS_SUCCESS) {
- printf
- ("ERROR: Tspi_SetAttribUint32 failed rc=0x%x, TSS_TSPATTRIB_CONTEXT_NOT_SILENT\n",
- result);
- goto close;
- }
-#endif
result = Tspi_GetPolicyObject(hKey, TSS_POLICY_USAGE, &hKeyPolicy);
if (result != TSS_SUCCESS) {
- printf("ERROR: Tspi_GetPolicyObject failed rc=0x%x\n",
+ LOG(LOG_ERR, "Tspi_GetPolicyObject failed rc=0x%x\n",
result);
goto close;
}
/* popup - set message */
-#if 1
- // TODO did not work???
// char *popupMsg = "Signature Key Password";
uint16_t popupMsg[] = {
'S', 'e', 't', ' ',
'K', 'e', 'y', ' ',
'P', 'a', 's', 's', 'w', 'o', 'r', 'd'
};
- // printf("DEBUG popupMsg %s\n",popupMsg);
- // printf("POPUP\n");
result = Tspi_SetAttribData(
hKeyPolicy,
TSS_TSPATTRIB_POLICY_POPUPSTRING,
(BYTE *) popupMsg);
if (result != TSS_SUCCESS) {
- printf("ERROR: Tspi_SetAttribData failed rc=0x%x\n",
+ LOG(LOG_ERR, "Tspi_SetAttribData failed rc=0x%x\n",
result);
goto close;
}
-#endif
+
/* popup - go */
- // printf("POPUP\n");
result = Tspi_Policy_SetSecret(hKeyPolicy,
TSS_SECRET_MODE_POPUP,
0, NULL);
if (result != TSS_SUCCESS) {
- printf("ERROR: Tspi_Policy_SetSecret failed rc=0x%x @POPUP\n",
+ LOG(LOG_ERR, "Tspi_Policy_SetSecret failed rc=0x%x @POPUP\n",
result);
goto close;
}
- // printf("POPUP\n");
} else { // CUI or commandline
result =
Tspi_Context_CreateObject(hContext,
&hKeyPolicy);
if (result != TSS_SUCCESS) {
- ERROR("ERROR: Tspi_Context_CreateObject failed rc=0x%x\n",
+ LOG(LOG_ERR, "Tspi_Context_CreateObject failed rc=0x%x\n",
result);
goto close;
}
size1 = strlen(ps1);
if (size0 != size1) {
- printf(NLS(MS_OPENPTS, OPENPTS_TPM_CREATEKEY_PASSWORD_MISMATCH, "Passwords didn't match %d %d\n"),
+ ERROR(NLS(MS_OPENPTS, OPENPTS_TPM_CREATEKEY_PASSWORD_MISMATCH, "Passwords didn't match %d %d\n"),
size0, size1);
xfree(ps0);
goto close;
}
if (strncmp(ps0, ps1, size0) != 0) {
- printf(NLS(MS_OPENPTS, OPENPTS_TPM_CREATEKEY_PASSWORD_MISMATCH_2, "Passwords didn't match %d\n"),
+ ERROR(NLS(MS_OPENPTS, OPENPTS_TPM_CREATEKEY_PASSWORD_MISMATCH_2, "Passwords didn't match %d\n"),
strncmp(ps0, ps1, size0));
xfree(ps0);
goto close;
len,
(BYTE *) str);
if (result != TSS_SUCCESS) {
- ERROR("ERROR: Tspi_Policy_SetSecret failed rc=0x%x\n",
+ LOG(LOG_ERR, "Tspi_Policy_SetSecret failed rc=0x%x\n",
result);
goto close;
}
result = Tspi_Policy_AssignToObject(hKeyPolicy, hKey);
if (result != TSS_SUCCESS) {
- ERROR("ERROR: Tspi_Policy_SetSecret failed rc=0x%x\n",
+ LOG(LOG_ERR, "Tspi_Policy_SetSecret failed rc=0x%x\n",
result);
goto close;
}
TSS_POLICY_USAGE,
&hKeyPolicy);
if (result != TSS_SUCCESS) {
- printf
- ("ERROR: Tspi_Context_CreateObject failed rc=0x%x\n",
+ LOG(LOG_ERR, "Tspi_Context_CreateObject failed rc=0x%x\n",
result);
goto close;
}
strlen(TPMSIGKEY_SECRET),
(BYTE *)TPMSIGKEY_SECRET);
if (result != TSS_SUCCESS) {
- printf
- ("ERROR: Tspi_Policy_SetSecret failed rc=0x%x\n",
+ LOG(LOG_ERR, "Tspi_Policy_SetSecret failed rc=0x%x\n",
result);
goto close;
}
hKeyPolicy,
hKey);
if (result != TSS_SUCCESS) {
- printf
- ("ERROR: Tspi_Policy_SetSecret failed rc=0x%x\n",
+ LOG(LOG_ERR, "Tspi_Policy_SetSecret failed rc=0x%x\n",
result);
goto close;
}
}
}
- printf("SM DEBUG call Tspi_Key_CreateKey()\n");
-
result = Tspi_Key_CreateKey(hKey, hSRK, 0);
if (result != TSS_SUCCESS) {
- printf("ERROR: Tspi_Key_CreateKey failed rc=0x%04x\n",
+ LOG(LOG_ERR, "Tspi_Key_CreateKey failed rc=0x%04x\n",
result);
goto close;
}
/* save as blob */
fp = fopen(filename, "w");
- printf("SM DEBUG save to %s\n",filename);
result = Tspi_GetAttribData(
hKey,
TSS_TSPATTRIB_KEY_BLOB,
&keyBlob);
if (result != TSS_SUCCESS) {
- printf("ERROR: Tspi_GetAttribData failed rc=0x%04x\n",
+ LOG(LOG_ERR, "Tspi_GetAttribData failed rc=0x%04x\n",
result);
fclose(fp);
goto close;
uuid,
&hKey);
if (result != TSS_SUCCESS) {
- ERROR("ERROR: Tspi_Context_UnregisterKey failed rc=0x%x\n",
+ LOG(LOG_ERR, "ERROR: Tspi_Context_UnregisterKey failed rc=0x%x\n",
result);
} else {
/* try again */
goto regkey;
}
} else {
- printf("ERROR: Tspi_Context_RegisterKey failed rc=0x%x\n",
+ LOG(LOG_ERR, "Tspi_Context_RegisterKey failed rc=0x%x\n",
result);
- printf(" TSS_E_KEY_ALREADY_REGISTERED\n");
+ ERROR(" TSS_E_KEY_ALREADY_REGISTERED\n");
buf = (BYTE *) & uuid;
printHex(" uuid=", buf, 16, "\n");
}
} else {
- printf("ERROR: Tspi_Context_RegisterKey failed rc=0x%x\n",
+ LOG(LOG_ERR, "Tspi_Context_RegisterKey failed rc=0x%x\n",
result);
}
goto close;
unsigned char *ussrc = (unsigned char *) src;
if (n & 0x01) {
- ERROR("ERROR: hex2bin wrong size %d\n", (int)n);
+ LOG(LOG_ERR, "ERROR: hex2bin wrong size %d\n", (int)n);
return -1;
}
}
void usage(void) {
- fprintf(stderr, NLS(MS_OPENPTS, OPENPTS_TPM_EXTENDPCR_USAGE,
- "OpenPTS command\n\n"
- "Usage: tpm_extendpcr [options] filename\n\n"
- " filename file to be measured\n"
- "Options:\n"
- " -p pcr_index Set PCR index to extend\n"
- " -t event_type Set event type\n"
- " -h Help\n"
- "\n"));
+ OUTPUT(NLS(MS_OPENPTS, OPENPTS_TPM_EXTENDPCR_USAGE,
+ "OpenPTS command\n\n"
+ "Usage: tpm_extendpcr [options] filename\n\n"
+ " filename file to be measured\n"
+ "Options:\n"
+ " -p pcr_index Set PCR index to extend\n"
+ " -t event_type Set event type\n"
+ " -h Help\n"
+ "\n"));
}
filename = argv[0];
if (filename == NULL) {
- printf("ERROR: missing filename\n");
+ ERROR("Missing filename\n");
usage();
goto end;
}
/* TSS open */
result = Tspi_Context_Create(&hContext);
if (result != TSS_SUCCESS) {
- ERROR("ERROR: Tspi_Context_Create failed rc=0x%x\n",
+ LOG(LOG_ERR, "Tspi_Context_Create failed rc=0x%x\n",
result);
goto close;
}
result = Tspi_Context_Connect(hContext, SERVER);
if (result != TSS_SUCCESS) {
- ERROR("ERROR: Tspi_Context_Connect failed rc=0x%x\n",
+ LOG(LOG_ERR, "Tspi_Context_Connect failed rc=0x%x\n",
result);
goto close;
}
/* Get TPM handle */
result = Tspi_Context_GetTpmObject(hContext, &hTPM);
if (result != TSS_SUCCESS) {
- ERROR("ERROR: Tspi_Context_GetTpmObject failed rc=0x%x\n",
+ LOG(LOG_ERR, "Tspi_Context_GetTpmObject failed rc=0x%x\n",
result);
goto close;
}
&prgbRespData);
if (result != TSS_SUCCESS) {
- ERROR("ERROR: failed rc=0x%x\n", result);
+ LOG(LOG_ERR, "Tspi_TPM_GetCapability() failed, rc=0x%x\n", result);
goto close;
}
pcrnum = * (UINT32 *) prgbRespData;
if (pcrindex > (int) pcrnum) {
- fprintf(stderr, NLS(MS_OPENPTS, OPENPTS_TPM_EXTENDPCR_BAD_RANGE,
- "ERROR: pcrindex %d is out of range, this must be 0 to %d\n"),
+ ERROR(NLS(MS_OPENPTS, OPENPTS_TPM_EXTENDPCR_BAD_RANGE,
+ "pcrindex %d is out of range, this must be 0 to %d\n"),
pcrindex, pcrnum);
goto close;
}
if ((fd = open(filename, O_RDONLY)) < 0) {
- fprintf(stderr, NLS(MS_OPENPTS, OPENPTS_EXTENDPCR_OPEN_FAIL,
+ ERROR(NLS(MS_OPENPTS, OPENPTS_EXTENDPCR_OPEN_FAIL,
"Failed to open file '%s'\n"), filename);
goto close;
}
fileLength = lseek(fd, 0, SEEK_END);
if (fileLength < 0) {
// WORK NEEDED: Please use NLS for i18n
- fprintf(stderr, "file %s seek fail\n", filename);
+ ERROR("file %s seek fail\n", filename);
goto close;
}
if ((fileMap = mmap(NULL, fileLength, PROT_READ, MAP_SHARED, fd, 0)) == NULL) {
- perror("mmap");
+ ERROR("mmap fail\n");
exit(1);
}
&prgbPcrValue);
if (result != TSS_SUCCESS) {
- fprintf(stderr, NLS(MS_OPENPTS, OPENPTS_TPM_EXTENDPCR_FAILED,
+ ERROR(NLS(MS_OPENPTS, OPENPTS_TPM_EXTENDPCR_FAILED,
"Failed to extend PCR at event %d\n"), eventCount);
- fprintf(stderr, NLS(MS_OPENPTS, OPENPTS_TPM_EXTENDPCR_INDEX,
+ ERROR(NLS(MS_OPENPTS, OPENPTS_TPM_EXTENDPCR_INDEX,
" pcr index: %d\n"), pcrEvent.ulPcrIndex);
- fprintf(stderr, NLS(MS_OPENPTS, OPENPTS_TPM_EXTENDPCR_EVENT_TYPE,
+ ERROR(NLS(MS_OPENPTS, OPENPTS_TPM_EXTENDPCR_EVENT_TYPE,
" event type: 0x%x\n"), pcrEvent.eventType);
exit(1);
}
close(fd);
if (getVerbosity() > 0) {
- printf(NLS(MS_OPENPTS, OPENPTS_TPM_EXTENDPCR_FED_TPM,
+ OUTPUT(NLS(MS_OPENPTS, OPENPTS_TPM_EXTENDPCR_FED_TPM,
"Fed the TPM/log with %d events\n"), eventCount);
}
} else {
/* File => mmap */
if ((fd = open(filename, O_RDONLY)) < 0) {
- fprintf(stderr, NLS(MS_OPENPTS, OPENPTS_EXTENDPCR_OPEN_FAIL,
+ ERROR(NLS(MS_OPENPTS, OPENPTS_EXTENDPCR_OPEN_FAIL,
"Failed to open file '%s'"), filename);
goto close;
}
fileLength = lseek(fd, 0, SEEK_END);
if ((fileMap = mmap(NULL, fileLength, PROT_READ, MAP_SHARED, fd, 0)) == NULL) {
- perror("mmap");
+ ERROR("mmap fail\n");
exit(1);
}
memcpy(fscan->filename, filename, filename_len);
if (stat(filename, &stat_buf) != 0) {
- fprintf(stderr, NLS(MS_OPENPTS, OPENPTS_EXTENDPCR_STAT_FAILED,
+ ERROR(NLS(MS_OPENPTS, OPENPTS_EXTENDPCR_STAT_FAILED,
"Failed to retrieve file information for '%s'\n"), filename);
exit(1);
}
SHA1_Final(fscan->fileDigest, &sha_ctx);
if (getVerbosity() > 0) {
- printf(NLS(MS_OPENPTS, OPENPTS_TPM_EXTENDPCR_FILENAME, "Filename: %s\n"), filename);
+ OUTPUT(NLS(MS_OPENPTS, OPENPTS_TPM_EXTENDPCR_FILENAME, "Filename: %s\n"), filename);
printHex(NLS(MS_OPENPTS, OPENPTS_TPM_EXTENDPCR_DIGEST, "Digest: "), fscan->fileDigest, 20, "");
}
&ulPcrValueLength,
&rgbPcrValue);
if (result != TSS_SUCCESS) {
- ERROR("ERROR: failed rc=0x%x\n", result);
+ LOG(LOG_ERR, "ERROR: failed rc=0x%x\n", result);
goto free;
}
unsigned char *ussrc = (unsigned char *) src;
if (n & 0x01) {
- ERROR("ERROR: hex2bin wrong size %d\n", (int)n);
+ LOG(LOG_ERR, "ERROR: hex2bin wrong size %d\n", (int)n);
return -1;
}
void printhex(char *str, unsigned char *buf, int len) {
int i;
- printf("%s", str);
+ OUTPUT("%s", str);
for (i = 0; i < len; i++)
- printf("%02x", buf[i]);
- printf("\n");
+ OUTPUT("%02x", buf[i]);
+ OUTPUT("\n");
}
void fprinthex(FILE * fp, char *str, unsigned char *buf, int len) {
void usage(void) {
- fprintf(stderr, NLS(MS_OPENPTS, OPENPTS_TPM_READPCR_USAGE,
- "OpenPTS command\n\n"
- "Usage: tpm_readpcr [options]\n\n"
- "Options:\n"
- " -p pcr_index Set PCR index to read\n"
- " -a Show all PCRs value (default)\n"
- " -k Display PCR same as kernel format (/sys/class/misc/tpm0/device/pcrs)\n"
- " -o filename Output to file (default is STDOUT)\n"
- " -h Help\n"
- "\n"));
+ OUTPUT(NLS(MS_OPENPTS, OPENPTS_TPM_READPCR_USAGE,
+ "OpenPTS command\n\n"
+ "Usage: tpm_readpcr [options]\n\n"
+ "Options:\n"
+ " -p pcr_index Set PCR index to read\n"
+ " -a Show all PCRs value (default)\n"
+ " -k Display PCR same as kernel format (/sys/class/misc/tpm0/device/pcrs)\n"
+ " -o filename Output to file (default is STDOUT)\n"
+ " -h Help\n"
+ "\n"));
}
result = Tspi_Context_Create(&hContext);
if (result != TSS_SUCCESS) {
- ERROR("ERROR: Tspi_Context_Create failed rc=0x%x\n",
+ LOG(LOG_ERR, "ERROR: Tspi_Context_Create failed rc=0x%x\n",
result);
goto close;
}
result = Tspi_Context_Connect(hContext, SERVER);
if (result != TSS_SUCCESS) {
- ERROR("ERROR: Tspi_Context_Connect failed rc=0x%x\n",
+ LOG(LOG_ERR, "ERROR: Tspi_Context_Connect failed rc=0x%x\n",
result);
goto close;
}
/* Get TPM handles */
result = Tspi_Context_GetTpmObject(hContext, &hTPM);
if (result != TSS_SUCCESS) {
- ERROR("ERROR: Tspi_Context_GetTpmObject failed rc=0x%x\n",
+ LOG(LOG_ERR, "ERROR: Tspi_Context_GetTpmObject failed rc=0x%x\n",
result);
goto close;
}
pcrNum = *(UINT32 *) blob;
if (result != TSS_SUCCESS) {
- ERROR("ERROR: Tspi_TPM_GetCapability failed rc=0x%x\n", result);
+ LOG(LOG_ERR, "ERROR: Tspi_TPM_GetCapability failed rc=0x%x\n", result);
goto free;
}
&blob);
if (result != TSS_SUCCESS) {
- ERROR("ERROR: Tspi_TPM_PcrRead failed rc=0x%x\n", result);
+ LOG(LOG_ERR, "ERROR: Tspi_TPM_PcrRead failed rc=0x%x\n", result);
goto free;
}
return TSS_SUCCESS;
}
-int createTssSignKey(PTS_UUID *uuid, int key_storage_type, char *filename, int force, int srk_password_mode) {
+int createTssSignKey(
+ PTS_UUID *uuid,
+ int key_storage_type,
+ char *filename,
+ int auth_type,
+ int force,
+ int srk_password_mode)
+{
/* dummy */
return TSS_SUCCESS;
}
-int deleteTssKey(PTS_UUID *uuid, int key_storage_type, char *filename) {
+int deleteTssKey(
+ PTS_UUID *uuid,
+ int key_storage_type,
+ char *filename)
+{
/* dummy */
return TSS_SUCCESS;
}
int createAIK() {
/* dummy */
- TODO("createAIK - TBD\n");
+ LOG(LOG_TODO, "createAIK - TBD\n");
return TSS_E_FAIL;
}
int getTssPubKey(
PTS_UUID *uuid,
- int key_storage_type, int srk_password_mode,
- int resetdalock, char *filename, int *pubkey_length, BYTE **pubkey) {
+ int key_storage_type,
+ int srk_password_mode,
+ int resetdalock,
+ char *filename,
+ int auth_type,
+ int *pubkey_length, BYTE **pubkey)
+{
/* dummy */
return TSS_SUCCESS;
}
int quoteTss(
- /* Key */
- PTS_UUID *uuid,
- int key_storage_type,
- int srk_password_mode,
- char *filename,
- /* Nonce */
- BYTE *nonce,
- /* PCR selection */
- OPENPTS_PCRS *pcrs,
- /* Output */
- TSS_VALIDATION *validationData) {
+ PTS_UUID *uuid,
+ int key_storage_type,
+ int srk_password_mode,
+ char *filename,
+ int auth_type,
+ BYTE *nonce,
+ OPENPTS_PCRS *pcrs,
+ TSS_VALIDATION *validationData)
+{
/* dummy */
return TSS_SUCCESS;
}
int quote2Tss(
- /* Key */
- PTS_UUID *uuid,
- int key_storage_type,
- int srk_password_mode,
- char *filename,
- /* Nonce */
- BYTE *nonce,
- /* PCR selection */
- OPENPTS_PCRS *pcrs,
- /* Output */
- TSS_VALIDATION *validationData) {
+ PTS_UUID *uuid,
+ int key_storage_type,
+ int srk_password_mode,
+ char *filename,
+ int auth_type,
+ BYTE *nonce,
+ OPENPTS_PCRS *pcrs,
+ TSS_VALIDATION *validationData)
+{
/* dummy */
return TSS_SUCCESS;
}
/* Connect to TCSD */
result = Tspi_Context_Create(&hContext);
if (result != TSS_SUCCESS) {
- ERROR("Tspi_Context_Create failed rc=0x%x\n",
+ LOG(LOG_ERR, "Tspi_Context_Create failed rc=0x%x\n",
result);
if (result == 0x3011) {
OUTPUT(NLS(MS_OPENPTS, OPENPTS_TPM_TSS_COMMS_FAILURE, "TSS communications failure. Is tcsd running?\n"));
result = Tspi_Context_Connect(hContext, SERVER);
if (result != TSS_SUCCESS) {
- ERROR("Tspi_Context_Connect failed rc=0x%x\n",
+ LOG(LOG_ERR, "Tspi_Context_Connect failed rc=0x%x\n",
result);
goto close;
}
/* Get TPM handle */
result = Tspi_Context_GetTpmObject(hContext, &hTPM);
if (result != TSS_SUCCESS) {
- ERROR("Tspi_Context_GetTpmObject failed rc=0x%x\n",
+ LOG(LOG_ERR, "Tspi_Context_GetTpmObject failed rc=0x%x\n",
result);
goto close;
}
/* Get TPM policy */
result = Tspi_GetPolicyObject(hTPM, TSS_POLICY_USAGE, &hTPMPolicy);
if (result != TSS_SUCCESS) {
- ERROR("Tspi_GetPolicyObject failed rc=0x%x\n",
+ LOG(LOG_ERR, "Tspi_GetPolicyObject failed rc=0x%x\n",
result);
goto close;
}
tpm_auth = null_srk_auth;
tpm_auth_len = 0;
} else {
- ERROR("TPM secret\n");
+ LOG(LOG_ERR, "TPM secret\n");
result = PTS_INTERNAL_ERROR; // TODO
goto close;
}
tpm_auth_len,
tpm_auth);
if (result != TSS_SUCCESS) {
- ERROR("Tspi_Policy_SetSecret failed rc=0x%x\n",
+ LOG(LOG_ERR, "Tspi_Policy_SetSecret failed rc=0x%x\n",
result);
goto close;
}
flag,
value);
if (result != TSS_SUCCESS) {
- ERROR("Tspi_TPM_GetStatus failed rc=0x%x\n",
+ LOG(LOG_ERR, "Tspi_TPM_GetStatus failed rc=0x%x\n",
result);
goto close;
}
/* Connect to TCSD */
result = Tspi_Context_Create(&hContext);
if (result != TSS_SUCCESS) {
- ERROR("Tspi_Context_Create failed rc=0x%x\n",
+ LOG(LOG_ERR, "Tspi_Context_Create failed rc=0x%x\n",
result);
if (result == 0x3011) {
OUTPUT(NLS(MS_OPENPTS, OPENPTS_TPM_TSS_COMMS_FAILURE, "TSS communications failure. Is tcsd running?\n"));
result = Tspi_Context_Connect(hContext, SERVER);
if (result != TSS_SUCCESS) {
- ERROR("Tspi_Context_Connect failed rc=0x%x\n",
+ LOG(LOG_ERR, "Tspi_Context_Connect failed rc=0x%x\n",
result);
goto close;
}
/* Get TPM handle */
result = Tspi_Context_GetTpmObject(hContext, &hTPM);
if (result != TSS_SUCCESS) {
- ERROR("Tspi_Context_GetTpmObject failed rc=0x%x\n",
+ LOG(LOG_ERR, "Tspi_Context_GetTpmObject failed rc=0x%x\n",
result);
goto close;
}
/* Get TPM policy */
result = Tspi_GetPolicyObject(hTPM, TSS_POLICY_USAGE, &hTPMPolicy);
if (result != TSS_SUCCESS) {
- ERROR("Tspi_GetPolicyObject failed rc=0x%x\n",
+ LOG(LOG_ERR, "Tspi_GetPolicyObject failed rc=0x%x\n",
result);
goto close;
}
tpm_auth = null_srk_auth;
tpm_auth_len = 0;
} else {
- ERROR("TPM secret\n");
+ LOG(LOG_ERR, "TPM secret\n");
result = PTS_INTERNAL_ERROR; // TODO
goto close;
}
tpm_auth_len,
tpm_auth);
if (result != TSS_SUCCESS) {
- ERROR("Tspi_Policy_SetSecret failed rc=0x%x\n",
+ LOG(LOG_ERR, "Tspi_Policy_SetSecret failed rc=0x%x\n",
result);
goto close;
}
flag, // TSS_TPMSTATUS_RESETLOCK,
value);
if (result != TSS_SUCCESS) {
- ERROR("Tspi_Policy_SetSecret failed rc=0x%x\n",
+ LOG(LOG_ERR, "Tspi_Policy_SetSecret failed rc=0x%x\n",
result);
goto close;
}
/* Open TSS */
result = Tspi_Context_Create(&hContext);
if (result != TSS_SUCCESS) {
- ERROR("Tspi_Context_Create failed rc=0x%x\n",
+ LOG(LOG_ERR, "Tspi_Context_Create failed rc=0x%x\n",
result);
goto close;
}
result = Tspi_Context_Connect(hContext, SERVER);
if (result != TSS_SUCCESS) {
- ERROR("Tspi_Context_Connect failed rc=0x%x\n",
+ LOG(LOG_ERR, "Tspi_Context_Connect failed rc=0x%x\n",
result);
goto close;
}
"The key cannot be found in the persistent storage database.\n"));
goto close;
} else if (result != TSS_SUCCESS) {
- ERROR("Tspi_Context_GetRegisteredKeysByUUID failed rc=0x%x\n",
+ LOG(LOG_ERR, "Tspi_Context_GetRegisteredKeysByUUID failed rc=0x%x\n",
result);
goto close;
}
/* check */
if ((key_storage_type == OPENPTS_AIK_STORAGE_TYPE_TSS) && (uuid == NULL)) {
/* TSS */
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return TSS_E_BAD_PARAMETER; // TSS ERROR_CODE
}
if (key_storage_type == OPENPTS_AIK_STORAGE_TYPE_BLOB) {
if (filename == NULL) {
/* BLOB */
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return TSS_E_BAD_PARAMETER; // TSS ERROR_CODE
} else {
if (force != 1) {
/* check file */
if (checkFile(filename) == OPENPTS_FILE_EXISTS) {
- ERROR("Blob file already exit. %s", filename);
+ LOG(LOG_ERR, "Blob file already exit. %s", filename);
return TSS_E_KEY_ALREADY_REGISTERED;
}
}
/* Open TSS */
result = Tspi_Context_Create(&hContext);
if (result != TSS_SUCCESS) {
- ERROR("Tspi_Context_Create failed rc=0x%x\n",
+ LOG(LOG_ERR, "Tspi_Context_Create failed rc=0x%x\n",
result);
goto close;
}
result = Tspi_Context_Connect(hContext, SERVER);
if (result != TSS_SUCCESS) {
- ERROR("Tspi_Context_Connect failed rc=0x%x\n",
+ LOG(LOG_ERR, "Tspi_Context_Connect failed rc=0x%x\n",
result);
goto close;
}
/* get TPM handles */
result = Tspi_Context_GetTpmObject(hContext, &hTPM);
if (result != TSS_SUCCESS) {
- ERROR("Tspi_Context_GetTpmObject failed rc=0x%x\n",
+ LOG(LOG_ERR, "Tspi_Context_GetTpmObject failed rc=0x%x\n",
result);
goto close;
}
SRK_UUID,
&hSRK);
if (result != TSS_SUCCESS) {
- ERROR("Tspi_Context_LoadKeyByUUID (SRK) failed rc=0x%x\n",
+ LOG(LOG_ERR, "Tspi_Context_LoadKeyByUUID (SRK) failed rc=0x%x\n",
result);
if (result == 0x2020) {
- ERROR("Your key storage of tcsd is damaged or missing. \n");
+ LOG(LOG_ERR, "Your key storage of tcsd is damaged or missing. \n");
}
goto close;
}
/* SRK Policy objects */
result = Tspi_GetPolicyObject(hSRK, TSS_POLICY_USAGE, &hSRKPolicy);
if (result != TSS_SUCCESS) {
- ERROR("Tspi_GetPolicyObject failed rc=0x%x\n",
+ LOG(LOG_ERR, "Tspi_GetPolicyObject failed rc=0x%x\n",
result);
goto close;
}
srk_auth_len,
srk_auth);
if (result != TSS_SUCCESS) {
- ERROR("Tspi_Policy_SetSecret failed rc=0x%x\n",
+ LOG(LOG_ERR, "Tspi_Policy_SetSecret failed rc=0x%x\n",
result);
goto close;
}
TSS_KEY_AUTHORIZATION | TSS_KEY_SIZE_2048 | TSS_KEY_TYPE_SIGNING,
&hKey);
if (result != TSS_SUCCESS) {
- ERROR("Tspi_Context_CreateObject failed rc=0x%x\n",
+ LOG(LOG_ERR, "Tspi_Context_CreateObject failed rc=0x%x\n",
result);
goto close;
}
TSS_POLICY_USAGE,
&hKeyPolicy);
if (result != TSS_SUCCESS) {
- printf
- ("ERROR: Tspi_Context_CreateObject failed rc=0x%x\n",
- result);
+ LOG(LOG_ERR, "Tspi_Context_CreateObject failed rc=0x%x\n",
+ result);
goto close;
}
strlen(TPMSIGKEY_SECRET),
(BYTE *)TPMSIGKEY_SECRET);
if (result != TSS_SUCCESS) {
- printf
- ("ERROR: Tspi_Policy_SetSecret failed rc=0x%x\n",
- result);
+ LOG(LOG_ERR, "ERROR: Tspi_Policy_SetSecret failed rc=0x%x\n",
+ result);
goto close;
}
result = Tspi_Policy_AssignToObject(hKeyPolicy, hKey);
if (result != TSS_SUCCESS) {
- printf
- ("ERROR: Tspi_Policy_SetSecret failed rc=0x%x\n",
- result);
+ LOG(LOG_ERR, "ERROR: Tspi_Policy_SetSecret failed rc=0x%x\n",
+ result);
goto close;
}
} else {
TSS_KEY_SIZE_2048 | TSS_KEY_TYPE_SIGNING,
&hKey);
if (result != TSS_SUCCESS) {
- ERROR("Tspi_Context_CreateObject failed rc=0x%x\n",
+ LOG(LOG_ERR, "Tspi_Context_CreateObject failed rc=0x%x\n",
result);
goto close;
}
/* create Key */
result = Tspi_Key_CreateKey(hKey, hSRK, 0);
if (result != TSS_SUCCESS) {
- ERROR("Tspi_Key_CreateKey failed rc=0x%04x\n",
+ LOG(LOG_ERR, "Tspi_Key_CreateKey failed rc=0x%04x\n",
result);
if (result == 0x12) {
- ERROR("TPM_NOSRK error, take the TPM ownership before initialize ptsc");
+ LOG(LOG_ERR, "TPM_NOSRK error, take the TPM ownership before initialize ptsc");
}
goto close;
}
fp = fopen(filename, "w");
if (fp==NULL) {
- ERROR("file open fail, key blob file is %s",filename);
+ LOG(LOG_ERR, "file open fail, key blob file is %s",filename);
result = TSS_E_KEY_NOT_LOADED;
goto close;
}
&keyLength,
&keyBlob);
if (result != TSS_SUCCESS) {
- ERROR("Tspi_GetAttribData failed rc=0x%04x\n",
+ LOG(LOG_ERR, "Tspi_GetAttribData failed rc=0x%04x\n",
result);
fclose(fp);
goto close;
tss_uuid,
&hKey);
if (result != TSS_SUCCESS) {
- ERROR("Tspi_Context_UnregisterKey failed rc=0x%x\n",
+ LOG(LOG_ERR, "Tspi_Context_UnregisterKey failed rc=0x%x\n",
result);
} else {
/* try regkey again */
goto regkey;
}
} else {
- ERROR("Tspi_Context_RegisterKey failed rc=0x%x\n",
+ LOG(LOG_ERR, "Tspi_Context_RegisterKey failed rc=0x%x\n",
result);
- ERROR(" TSS_E_KEY_ALREADY_REGISTERED\n");
+ LOG(LOG_ERR, " TSS_E_KEY_ALREADY_REGISTERED\n");
}
} else {
- ERROR("spi_Context_RegisterKey failed rc=0x%x\n",
+ LOG(LOG_ERR, "spi_Context_RegisterKey failed rc=0x%x\n",
result);
// 0x3003 TEE_E_BAD_PARAMETOR
}
* Create AIK
*/
int createAIK() {
- TODO("createAIK - TBD\n");
+ LOG(LOG_TODO, "createAIK - TBD\n");
return TSS_E_FAIL;
}
/* check BLOB */
if (key_storage_type == OPENPTS_AIK_STORAGE_TYPE_BLOB) {
if (filename == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return TSS_E_BAD_PARAMETER; // TSS ERROR_CODE
} else {
/* check file */
if (checkFile(filename) != OPENPTS_FILE_EXISTS) {
- ERROR("Blob file not found. %s", filename);
+ LOG(LOG_ERR, "Blob file not found. %s", filename);
return TSS_E_BAD_PARAMETER;
}
/* delete file */
if (remove(filename) != 0) {
- ERROR("remove key blob is fail. %s", filename);
+ LOG(LOG_ERR, "remove key blob is fail. %s", filename);
return TSS_E_FAIL;
}
/* OK */
/* check TSS */
if ((key_storage_type == OPENPTS_AIK_STORAGE_TYPE_TSS) && (uuid == NULL)) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return TSS_E_BAD_PARAMETER; // TSS ERROR_CODE
}
/* Open TSS */
result = Tspi_Context_Create(&hContext);
if (result != TSS_SUCCESS) {
- ERROR("Tspi_Context_Create failed rc=0x%x\n",
+ LOG(LOG_ERR, "Tspi_Context_Create failed rc=0x%x\n",
result);
goto close;
}
result = Tspi_Context_Connect(hContext, SERVER);
if (result != TSS_SUCCESS) {
- ERROR("Tspi_Context_Connect failed rc=0x%x\n",
+ LOG(LOG_ERR, "Tspi_Context_Connect failed rc=0x%x\n",
result);
goto close;
}
tss_uuid,
&hKey);
if (result != TSS_SUCCESS) {
- ERROR("Tspi_Context_UnregisterKey failed rc=0x%x\n",
+ LOG(LOG_ERR, "Tspi_Context_UnregisterKey failed rc=0x%x\n",
result);
}
/* check */
if ((key_storage_type == OPENPTS_AIK_STORAGE_TYPE_TSS) && (uuid == NULL)) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return TSS_E_BAD_PARAMETER; // TSS ERROR_CODE
}
if ((key_storage_type == OPENPTS_AIK_STORAGE_TYPE_BLOB) && (filename == NULL)) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return TSS_E_BAD_PARAMETER; // TSS ERROR_CODE
}
/* Open TSS */
result = Tspi_Context_Create(&hContext);
if (result != TSS_SUCCESS) {
- ERROR("Tspi_Context_Create failed rc=0x%x\n",
+ LOG(LOG_ERR, "Tspi_Context_Create failed rc=0x%x\n",
result);
goto close;
}
result = Tspi_Context_Connect(hContext, SERVER);
if (result != TSS_SUCCESS) {
- ERROR("Tspi_Context_Connect failed rc=0x%x\n",
+ LOG(LOG_ERR, "Tspi_Context_Connect failed rc=0x%x\n",
result);
goto close;
}
SRK_UUID,
&hSRK);
if (result != TSS_SUCCESS) {
- ERROR("Tspi_Context_LoadKeyByUUID (SRK) failed rc=0x%x\n",
+ LOG(LOG_ERR, "Tspi_Context_LoadKeyByUUID (SRK) failed rc=0x%x\n",
result);
if (result == 0x2020) {
- ERROR(" TSS_E_PS_KEY_NOT_FOUND.\n");
- fprintf(stderr, NLS(MS_OPENPTS, OPENPTS_TSS_CHECK_SETTING,
+ LOG(LOG_ERR, " TSS_E_PS_KEY_NOT_FOUND.\n");
+ ERROR(NLS(MS_OPENPTS, OPENPTS_TSS_CHECK_SETTING,
"Please check your system_ps_file setting in /etc/security/tss/tcsd.conf. "
"(The default is /var/tss/lib/tpm/system.data)\n"
"If system_ps_file size is zero then it does not contain the SRK info\n"));
/* SRK Policy objects */
result = Tspi_GetPolicyObject(hSRK, TSS_POLICY_USAGE, &hSRKPolicy);
if (result != TSS_SUCCESS) {
- ERROR("Tspi_GetPolicyObject failed rc=0x%x\n",
+ LOG(LOG_ERR, "Tspi_GetPolicyObject failed rc=0x%x\n",
result);
goto close;
}
srk_auth_len,
srk_auth);
if (result != TSS_SUCCESS) {
- ERROR("Tspi_Policy_SetSecret failed rc=0x%x\n",
+ LOG(LOG_ERR, "Tspi_Policy_SetSecret failed rc=0x%x\n",
result);
goto close;
}
fp = fopen(filename, "r");
if (fp==NULL) {
- ERROR("file open fail, key blob file is %s",filename);
+ LOG(LOG_ERR, "file open fail, key blob file is %s",filename);
result = TSS_E_KEY_NOT_LOADED;
goto close;
}
blob,
&hKey);
if (result != TSS_SUCCESS) {
- ERROR("Tspi_Context_LoadKeyByBlob (Key) failed rc=0x%x\n",
+ LOG(LOG_ERR, "Tspi_Context_LoadKeyByBlob (Key) failed rc=0x%x\n",
result);
goto close;
}
tss_uuid,
&hKey);
if (result == 0x803) {
- fprintf(stderr, NLS(MS_OPENPTS, OPENPTS_TSS_TPM_LOCKED,
- "The TPM is locked. Please use the 'tpm_resetdalock' command to clear the lock\n"
- "For the ptscd daemon please set the flag 'tpm.resetdalock=on' in /etc/ptsc.conf\n"));
+ ERROR(NLS(MS_OPENPTS, OPENPTS_TSS_TPM_LOCKED,
+ "The TPM is locked. Please use the 'tpm_resetdalock' command to clear the lock\n"
+ "For the ptscd daemon please set the flag 'tpm.resetdalock=on' in /etc/ptsc.conf\n"));
goto close;
} else if (result != TSS_SUCCESS) {
- ERROR("Tspi_Context_LoadKeyByUUID (Key) failed rc=0x%x\n", result);
+ LOG(LOG_ERR, "Tspi_Context_LoadKeyByUUID (Key) failed rc=0x%x\n", result);
debugHex("\t\tUUID", (BYTE*)&tss_uuid, 16, "\n");
goto close;
/* Policy Object*/
result = Tspi_GetPolicyObject(hKey, TSS_POLICY_USAGE, &hKeyPolicy);
if (result != TSS_SUCCESS) {
- ERROR("Tspi_GetPolicyObject failed rc=0x%x\n",
+ LOG(LOG_ERR, "Tspi_GetPolicyObject failed rc=0x%x\n",
result);
goto close;
}
strlen(TPMSIGKEY_SECRET),
(BYTE *)TPMSIGKEY_SECRET);
if (result != TSS_SUCCESS) {
- printf("ERROR: Tspi_Policy_SetSecret failed rc=0x%x\n",
+ LOG(LOG_ERR, "Tspi_Policy_SetSecret failed rc=0x%x\n",
result);
goto close;
}
0,
key_auth);
if (result != TSS_SUCCESS) {
- printf("ERROR: Tspi_Policy_SetSecret failed rc=0x%x\n",
+ LOG(LOG_ERR, "Tspi_Policy_SetSecret failed rc=0x%x\n",
result);
goto close;
}
(UINT32 *) pubkey_length,
&buf);
if (result != TSS_SUCCESS) {
- ERROR("Tspi_GetAttribData failed rc=0x%x\n",
+ LOG(LOG_ERR, "Tspi_GetAttribData failed rc=0x%x\n",
result);
goto free;
}
/* check */
if (version == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return TSS_E_BAD_PARAMETER; // TSS ERROR_CODE
}
/* Connect to TCSD */
result = Tspi_Context_Create(&hContext);
if (result != TSS_SUCCESS) {
- ERROR("Tspi_Context_Create failed rc=0x%x\n",
+ LOG(LOG_ERR, "Tspi_Context_Create failed rc=0x%x\n",
result);
if (result == 0x3011) {
OUTPUT(NLS(MS_OPENPTS, OPENPTS_TPM_TSS_COMMS_FAILURE, "TSS communications failure. Is tcsd running?\n"));
result = Tspi_Context_Connect(hContext, SERVER);
if (result != TSS_SUCCESS) {
- ERROR("Tspi_Context_Connect failed rc=0x%x\n",
+ LOG(LOG_ERR, "Tspi_Context_Connect failed rc=0x%x\n",
result);
rc = (int)result;
goto close;
/* Get TPM handle */
result = Tspi_Context_GetTpmObject(hContext, &hTPM);
if (result != TSS_SUCCESS) {
- ERROR("Tspi_Context_GetTpmObject failed rc=0x%x\n",
+ LOG(LOG_ERR, "Tspi_Context_GetTpmObject failed rc=0x%x\n",
result);
rc = (int)result;
goto close;
&data_len,
&data);
if (result != TSS_SUCCESS) {
- ERROR("Tspi_TPM_GetCapability failed rc=0x%x\n",
+ LOG(LOG_ERR, "Tspi_TPM_GetCapability failed rc=0x%x\n",
result);
rc = (int)result;
goto close;
}
if (data_len != 4) {
- ERROR("bad TPM version\n");
+ LOG(LOG_ERR, "bad TPM version\n");
rc = TSS_E_FAIL;
goto close;
}
/* Connect to TCSD */
result = Tspi_Context_Create(&hContext);
if (result != TSS_SUCCESS) {
- ERROR("Tspi_Context_Create failed rc=0x%x\n",
+ LOG(LOG_ERR, "Tspi_Context_Create failed rc=0x%x\n",
result);
if (result == 0x3011) {
OUTPUT(NLS(MS_OPENPTS, OPENPTS_TPM_TSS_COMMS_FAILURE, "TSS communications failure. Is tcsd running?\n"));
result = Tspi_Context_Connect(hContext, SERVER);
if (result != TSS_SUCCESS) {
- ERROR("Tspi_Context_Connect failed rc=0x%x\n",
+ LOG(LOG_ERR, "Tspi_Context_Connect failed rc=0x%x\n",
result);
goto close;
}
/* Get TPM handle */
result = Tspi_Context_GetTpmObject(hContext, &hTPM);
if (result != TSS_SUCCESS) {
- ERROR("Tspi_Context_GetTpmObject failed rc=0x%x\n",
+ LOG(LOG_ERR, "Tspi_Context_GetTpmObject failed rc=0x%x\n",
result);
goto close;
}
&pulRespDataLength, &prgbRespData);
if (result != TSS_SUCCESS) {
- ERROR("Tspi_TPM_GetCapability failed rc=0x%x\n",
+ LOG(LOG_ERR, "Tspi_TPM_GetCapability failed rc=0x%x\n",
result);
goto close;
}
0,
&hPcrComposite);
if (result != TSS_SUCCESS) {
- ERROR("Tspi_Context_CreateObject failed rc=0x%x\n",
+ LOG(LOG_ERR, "Tspi_Context_CreateObject failed rc=0x%x\n",
result);
goto close;
}
hPcrComposite,
i);
if (result != TSS_SUCCESS) {
- ERROR("failed rc=0x%x\n", result);
+ LOG(LOG_ERR, "failed rc=0x%x\n", result);
goto close;
}
pcrSelectCount++;
/* check PCR */
if (pcrSelectCount == 0) {
- ERROR("No PCR is selected for quote\n");
+ LOG(LOG_ERR, "No PCR is selected for quote\n");
goto close;
}
SRK_UUID,
&hSRK);
if (result != TSS_SUCCESS) {
- ERROR("Tspi_Context_LoadKeyByUUID (SRK) failed rc=0x%x\n",
+ LOG(LOG_ERR, "Tspi_Context_LoadKeyByUUID (SRK) failed rc=0x%x\n",
result);
if (result == 0x2020) {
- ERROR(" TSS_E_PS_KEY_NOT_FOUND.\n");
- fprintf(stderr, NLS(MS_OPENPTS, OPENPTS_TSS_CHECK_SETTING,
+ LOG(LOG_ERR, " TSS_E_PS_KEY_NOT_FOUND.\n");
+ ERROR(NLS(MS_OPENPTS, OPENPTS_TSS_CHECK_SETTING,
"Please check your system_ps_file setting in /etc/tcsd.conf. "
"(The default is /var/lib/tpm/system.data)\n"
"If system_ps_file size is zero then it does not contains the SRK info\n"));
/* Get SRK Policy objects */
result = Tspi_GetPolicyObject(hSRK, TSS_POLICY_USAGE, &hSRKPolicy);
if (result != TSS_SUCCESS) {
- ERROR("Tspi_GetPolicyObject failed rc=0x%x\n",
+ LOG(LOG_ERR, "Tspi_GetPolicyObject failed rc=0x%x\n",
result);
goto close;
}
srk_auth_len,
srk_auth);
if (result != TSS_SUCCESS) {
- ERROR("Tspi_Policy_SetSecret failed rc=0x%x\n",
+ LOG(LOG_ERR, "Tspi_Policy_SetSecret failed rc=0x%x\n",
result);
goto close;
}
fp = fopen(filename, "r");
if (fp==NULL) {
- ERROR("file open fail, key blob file is %s",filename);
+ LOG(LOG_ERR, "file open fail, key blob file is %s",filename);
result = TSS_E_KEY_NOT_LOADED;
goto close;
}
blob,
&hKey);
if (result != TSS_SUCCESS) {
- ERROR("Tspi_Context_LoadKeyByBlob (Key) failed rc=0x%x\n",
+ LOG(LOG_ERR, "Tspi_Context_LoadKeyByBlob (Key) failed rc=0x%x\n",
result);
goto close;
}
tss_uuid,
&hKey);
if (result != TSS_SUCCESS) {
- ERROR("Tspi_Context_LoadKeyByUUID (Key) failed rc=0x%x\n", result);
+ LOG(LOG_ERR, "Tspi_Context_LoadKeyByUUID (Key) failed rc=0x%x\n", result);
debugHex("\t\tUUID", (BYTE*)&tss_uuid, 16, "\n");
goto close;
/* get Policy Object of Sign key */
result = Tspi_GetPolicyObject(hKey, TSS_POLICY_USAGE, &hKeyPolicy);
if (result != TSS_SUCCESS) {
- ERROR("Tspi_GetPolicyObject failed rc=0x%x\n",
+ LOG(LOG_ERR, "Tspi_GetPolicyObject failed rc=0x%x\n",
result);
goto close;
}
strlen(TPMSIGKEY_SECRET),
(BYTE *)TPMSIGKEY_SECRET);
if (result != TSS_SUCCESS) {
- printf("ERROR: Tspi_Policy_SetSecret failed rc=0x%x\n",
+ LOG(LOG_ERR, "Tspi_Policy_SetSecret failed rc=0x%x\n",
result);
goto close;
}
0,
key_auth);
if (result != TSS_SUCCESS) {
- printf("ERROR: Tspi_Policy_SetSecret failed rc=0x%x\n",
+ LOG(LOG_ERR, "Tspi_Policy_SetSecret failed rc=0x%x\n",
result);
goto close;
}
hKey, hPcrComposite, &validation_data);
if (result != TSS_SUCCESS) {
if (result == 0x01) {
- ERROR("Tspi_TPM_Quote failed rc=0x%04x\n",
+ LOG(LOG_ERR, "Tspi_TPM_Quote failed rc=0x%04x\n",
result);
- ERROR(" Authorization faild, needs valid password\n");
+ LOG(LOG_ERR, " Authorization faild, needs valid password\n");
} else {
- ERROR("Tspi_TPM_Quote failed rc=0x%04x\n",
+ LOG(LOG_ERR, "Tspi_TPM_Quote failed rc=0x%04x\n",
result);
}
goto free;
hPcrComposite, i,
&length, &data);
if (result != TSS_SUCCESS) {
- ERROR("Tspi_PcrComposite_GetPcrValue failed rc=0x%x\n",
+ LOG(LOG_ERR, "Tspi_PcrComposite_GetPcrValue failed rc=0x%x\n",
result);
goto free;
}
- // fprintf(fp, "pcr.%d=", i);
- // fprinthex(fp, "", data, length);
if (length < MAX_DIGEST_SIZE) {
memcpy(&pcrs->pcr[i], data, length);
if (isDebugFlagSet(DEBUG_FLAG)) {
debugHex(" : ", data, length, "\n");
}
} else {
- ERROR("pcr size is too big %d > %d\n", length, MAX_DIGEST_SIZE);
+ LOG(LOG_ERR, "pcr size is too big %d > %d\n", length, MAX_DIGEST_SIZE);
}
Tspi_Context_FreeMemory(hContext, data);
/* Connect to TCSD */
result = Tspi_Context_Create(&hContext);
if (result != TSS_SUCCESS) {
- ERROR("Tspi_Context_Create failed rc=0x%x\n",
+ LOG(LOG_ERR, "Tspi_Context_Create failed rc=0x%x\n",
result);
if (result == 0x3011) {
OUTPUT(NLS(MS_OPENPTS, OPENPTS_TPM_TSS_COMMS_FAILURE, "TSS communications failure. Is tcsd running?\n"));
result = Tspi_Context_Connect(hContext, SERVER);
if (result != TSS_SUCCESS) {
- ERROR("Tspi_Context_Connect failed rc=0x%x\n",
+ LOG(LOG_ERR, "Tspi_Context_Connect failed rc=0x%x\n",
result);
goto close;
}
/* Get TPM handle */
result = Tspi_Context_GetTpmObject(hContext, &hTPM);
if (result != TSS_SUCCESS) {
- ERROR("Tspi_Context_GetTpmObject failed rc=0x%x\n",
+ LOG(LOG_ERR, "Tspi_Context_GetTpmObject failed rc=0x%x\n",
result);
goto close;
}
&pulRespDataLength, &prgbRespData);
if (result != TSS_SUCCESS) {
- ERROR("Tspi_TPM_GetCapability failed rc=0x%x\n",
+ LOG(LOG_ERR, "Tspi_TPM_GetCapability failed rc=0x%x\n",
result);
goto close;
}
TSS_PCRS_STRUCT_INFO_SHORT,
&hPcrComposite);
if (result != TSS_SUCCESS) {
- ERROR("Tspi_Context_CreateObject failed rc=0x%x\n",
+ LOG(LOG_ERR, "Tspi_Context_CreateObject failed rc=0x%x\n",
result);
goto close;
}
i,
TSS_PCRS_DIRECTION_RELEASE);
if (result != TSS_SUCCESS) {
- ERROR("failed rc=0x%x\n", result);
+ LOG(LOG_ERR, "failed rc=0x%x\n", result);
goto close;
}
pcrSelectCount++;
/* check PCR */
if (pcrSelectCount == 0) {
- ERROR("No PCR is selected for quote\n");
+ LOG(LOG_ERR, "No PCR is selected for quote\n");
goto close;
}
SRK_UUID,
&hSRK);
if (result != TSS_SUCCESS) {
- ERROR("Tspi_Context_LoadKeyByUUID (SRK) failed rc=0x%x\n",
+ LOG(LOG_ERR, "Tspi_Context_LoadKeyByUUID (SRK) failed rc=0x%x\n",
result);
if (result == 0x2020) {
- ERROR(" TSS_E_PS_KEY_NOT_FOUND.\n");
- fprintf(stderr, NLS(MS_OPENPTS, OPENPTS_TSS_CHECK_SETTING,
+ LOG(LOG_ERR, " TSS_E_PS_KEY_NOT_FOUND.\n");
+ ERROR(NLS(MS_OPENPTS, OPENPTS_TSS_CHECK_SETTING,
"Please check your system_ps_file setting in /etc/tcsd.conf. "
"(The default is /var/lib/tpm/system.data)\n"
"If system_ps_file size is zero then it does not contains the SRK info\n"));
/* Get SRK Policy objects */
result = Tspi_GetPolicyObject(hSRK, TSS_POLICY_USAGE, &hSRKPolicy);
if (result != TSS_SUCCESS) {
- ERROR("Tspi_GetPolicyObject failed rc=0x%x\n",
+ LOG(LOG_ERR, "Tspi_GetPolicyObject failed rc=0x%x\n",
result);
goto close;
}
srk_auth_len,
srk_auth);
if (result != TSS_SUCCESS) {
- ERROR("Tspi_Policy_SetSecret failed rc=0x%x\n",
+ LOG(LOG_ERR, "Tspi_Policy_SetSecret failed rc=0x%x\n",
result);
goto close;
}
fp = fopen(filename, "r");
if (fp==NULL) {
- ERROR("file open fail, key blob file is %s",filename);
+ LOG(LOG_ERR, "file open fail, key blob file is %s",filename);
result = TSS_E_KEY_NOT_LOADED;
goto close;
}
blob,
&hKey);
if (result != TSS_SUCCESS) {
- ERROR("Tspi_Context_LoadKeyByBlob (Key) failed rc=0x%x\n",
+ LOG(LOG_ERR, "Tspi_Context_LoadKeyByBlob (Key) failed rc=0x%x\n",
result);
goto close;
}
tss_uuid,
&hKey);
if (result != TSS_SUCCESS) {
- ERROR("Tspi_Context_LoadKeyByUUID (Key) failed rc=0x%x\n", result);
+ LOG(LOG_ERR, "Tspi_Context_LoadKeyByUUID (Key) failed rc=0x%x\n", result);
debugHex("\t\tUUID", (BYTE*)&tss_uuid, 16, "\n");
goto close;
/* get Policy Object of Sign key */
result = Tspi_GetPolicyObject(hKey, TSS_POLICY_USAGE, &hKeyPolicy);
if (result != TSS_SUCCESS) {
- ERROR("Tspi_GetPolicyObject failed rc=0x%x\n",
+ LOG(LOG_ERR, "Tspi_GetPolicyObject failed rc=0x%x\n",
result);
goto close;
}
strlen(TPMSIGKEY_SECRET),
(BYTE *)TPMSIGKEY_SECRET);
if (result != TSS_SUCCESS) {
- printf("ERROR: Tspi_Policy_SetSecret failed rc=0x%x\n",
+ LOG(LOG_ERR, "Tspi_Policy_SetSecret failed rc=0x%x\n",
result);
goto close;
}
0,
key_auth);
if (result != TSS_SUCCESS) {
- printf("ERROR: Tspi_Policy_SetSecret failed rc=0x%x\n",
+ LOG(LOG_ERR, "Tspi_Policy_SetSecret failed rc=0x%x\n",
result);
goto close;
}
&versionInfo);
if (result != TSS_SUCCESS) {
if (result == 0x01) {
- ERROR("Tspi_TPM_Quote failed rc=0x%04x\n", result);
- fprintf(stderr, NLS(MS_OPENPTS, OPENPTS_TSS_AUTH_FAILED, "Authorization failed, needs valid password\n"));
+ LOG(LOG_ERR, "Tspi_TPM_Quote failed rc=0x%04x\n", result);
+ ERROR(NLS(MS_OPENPTS, OPENPTS_TSS_AUTH_FAILED,
+ "Authorization failed, needs valid password\n"));
} else {
- ERROR("Tspi_TPM_Quote failed rc=0x%04x\n", result);
+ LOG(LOG_ERR, "Tspi_TPM_Quote failed rc=0x%04x\n", result);
}
goto free;
}
hPcrComposite, i,
&length, &data);
if (result != TSS_SUCCESS) {
- ERROR("Tspi_PcrComposite_GetPcrValue failed rc=0x%x\n",
+ LOG(LOG_ERR, "Tspi_PcrComposite_GetPcrValue failed rc=0x%x\n",
result);
goto free;
}
result = Tspi_TPM_PcrRead(
hTPM, i, &length, &data);
if (result != TSS_SUCCESS) {
- ERROR("Tspi_TPM_PcrRead failed rc=0x%x\n", result);
+ LOG(LOG_ERR, "Tspi_TPM_PcrRead failed rc=0x%x\n", result);
goto free;
}
#endif
debugHex(" : ", data, length, "\n");
}
} else {
- fprintf(stderr, NLS(MS_OPENPTS, OPENPTS_TSS_PCR_SIZE_TOO_BIG,
+ ERROR(NLS(MS_OPENPTS, OPENPTS_TSS_PCR_SIZE_TOO_BIG,
"PCR size is too big %d > %d\n"), length, MAX_DIGEST_SIZE);
}
/* check */
if (size <= 0) {
- ERROR("bad size. %d", size);
+ LOG(LOG_ERR, "bad size. %d", size);
return TSS_E_FAIL;
}
if (out == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return TSS_E_FAIL;
}
/* Connect to TCSD */
result = Tspi_Context_Create(&hContext);
if (result != TSS_SUCCESS) {
- ERROR("Tspi_Context_Create failed rc=0x%x\n", result);
+ LOG(LOG_ERR, "Tspi_Context_Create failed rc=0x%x\n", result);
if (result == 0x3011) {
OUTPUT(NLS(MS_OPENPTS, OPENPTS_TPM_TSS_COMMS_FAILURE, "TSS communications failure. Is tcsd running?\n"));
}
result = Tspi_Context_Connect(hContext, SERVER);
if (result != TSS_SUCCESS) {
- ERROR("Tspi_Context_Connect failed rc=0x%x\n", result);
+ LOG(LOG_ERR, "Tspi_Context_Connect failed rc=0x%x\n", result);
goto close;
}
/* Get TPM handle */
result = Tspi_Context_GetTpmObject(hContext, &hTPM);
if (result != TSS_SUCCESS) {
- ERROR("Tspi_Context_GetTpmObject failed rc=0x%x\n", result);
+ LOG(LOG_ERR, "Tspi_Context_GetTpmObject failed rc=0x%x\n", result);
goto close;
}
/* get Random*/
result = Tspi_TPM_GetRandom(hTPM, size, &buf);
if (result != TSS_SUCCESS) {
- ERROR
- ("Tspi_TPM_GetRandom failed rc=0x%x\n",
+ LOG(LOG_ERR, "Tspi_TPM_GetRandom failed rc=0x%x\n",
result);
Tspi_Context_FreeMemory(hContext, NULL);
goto free;
/* Connect to TCSD */
result = Tspi_Context_Create(&hContext);
if (result != TSS_SUCCESS) {
- ERROR("Tspi_Context_Create failed rc=0x%x\n", result);
+ LOG(LOG_ERR, "Tspi_Context_Create failed rc=0x%x\n", result);
if (result == 0x3011) {
OUTPUT(NLS(MS_OPENPTS, OPENPTS_TPM_TSS_COMMS_FAILURE, "TSS communications failure. Is tcsd running?\n"));
}
result = Tspi_Context_Connect(hContext, SERVER);
if (result != TSS_SUCCESS) {
- ERROR("Tspi_Context_Connect failed rc=0x%x\n", result);
+ LOG(LOG_ERR, "Tspi_Context_Connect failed rc=0x%x\n", result);
goto close;
}
/* Get TPM handle */
result = Tspi_Context_GetTpmObject(hContext, &hTPM);
if (result != TSS_SUCCESS) {
- ERROR("Tspi_Context_GetTpmObject failed rc=0x%x\n", result);
+ LOG(LOG_ERR, "Tspi_Context_GetTpmObject failed rc=0x%x\n", result);
goto close;
}
&pcr_len,
&pcr);
if (result != TSS_SUCCESS) {
- ERROR
- ("Tspi_TPM_PcrExtend failed rc=0x%x\n",
+ LOG(LOG_ERR, "Tspi_TPM_PcrExtend failed rc=0x%x\n",
result);
// Tspi_Context_FreeMemory(hContext, NULL);
goto close;
/* Connect to TCSD */
result = Tspi_Context_Create(&hContext);
if (result != TSS_SUCCESS) {
- ERROR("Tspi_Context_Create failed rc=0x%x\n", result);
+ LOG(LOG_ERR, "Tspi_Context_Create failed rc=0x%x\n", result);
if (result == 0x3011) {
OUTPUT(NLS(MS_OPENPTS, OPENPTS_TPM_TSS_COMMS_FAILURE, "TSS communications failure. Is tcsd running?\n"));
}
result = Tspi_Context_Connect(hContext, SERVER);
if (result != TSS_SUCCESS) {
- ERROR("Tspi_Context_Connect failed rc=0x%x\n", result);
+ LOG(LOG_ERR, "Tspi_Context_Connect failed rc=0x%x\n", result);
goto close;
}
/* Get TPM handle */
result = Tspi_Context_GetTpmObject(hContext, &hTPM);
if (result != TSS_SUCCESS) {
- ERROR("Tspi_Context_GetTpmObject failed rc=0x%x\n", result);
+ LOG(LOG_ERR, "Tspi_Context_GetTpmObject failed rc=0x%x\n", result);
goto close;
}
result = Tspi_TPM_PcrRead(
hTPM, pcr_index, &data_len, &data);
if (result != TSS_SUCCESS) {
- ERROR("Tspi_TPM_PcrRead failed rc=0x%x\n", result);
+ LOG(LOG_ERR, "Tspi_TPM_PcrRead failed rc=0x%x\n", result);
goto close;
}
if (data_len != SHA1_DIGEST_SIZE) {
- ERROR("Bad PCR size %d\n", data_len);
+ LOG(LOG_ERR, "Bad PCR size %d\n", data_len);
result = PTS_INTERNAL_ERROR;
} else {
memcpy(pcr, data, SHA1_DIGEST_SIZE);
/* check */
if (pcrs == NULL) {
- ERROR("validateQuoteData - pcrs is NULL\n");
+ LOG(LOG_ERR, "validateQuoteData - pcrs is NULL\n");
return PTS_INTERNAL_ERROR;
}
if (pcrs->pubkey_length == 0) {
- ERROR("validateQuoteData - pcrs->pubkey_length is ZERO\n");
+ LOG(LOG_ERR, "validateQuoteData - pcrs->pubkey_length is ZERO\n");
return PTS_INTERNAL_ERROR;
}
if (pcrs->pubkey == NULL) {
- ERROR("validateQuoteData - pcrs->pubkey is NULL\n");
+ LOG(LOG_ERR, "validateQuoteData - pcrs->pubkey is NULL\n");
return PTS_INTERNAL_ERROR;
}
} else if (validationData->ulDataLength == 52) {
DEBUG("Quote2\n");
} else {
- ERROR("validationData->ulDataLength != 48/52, but %d\n",
+ LOG(LOG_ERR, "validationData->ulDataLength != 48/52, but %d\n",
validationData->ulDataLength);
return PTS_INTERNAL_ERROR;
}
if (validationData->ulExternalDataLength != 20) {
- ERROR("validationData->ulExternalDataLength != 20, but %d\n",
+ LOG(LOG_ERR, "validationData->ulExternalDataLength != 20, but %d\n",
validationData->ulExternalDataLength);
return PTS_INTERNAL_ERROR;
}
// memcpy(&pubkey[1],&pcrs->pubkey[28], 256);
#if 0
- TODO("\n");
+ LOG(LOG_TODO, "\n");
printHex("message :", message, message_length, "\n");
printHex("hash :", hash, hash_length, "\n");
printHex("signature :", signature, signature_length, "\n");
UINT32 e; // unsigned long
ERR_load_crypto_strings();
e = ERR_get_error();
- ERROR("RSA_verify failed, %s\n", ERR_error_string(e, NULL));
- ERROR(" %s\n", ERR_lib_error_string(e));
- ERROR(" %s\n", ERR_func_error_string(e));
- ERROR(" %s\n", ERR_reason_error_string(e));
+ LOG(LOG_ERR, "RSA_verify failed, %s\n", ERR_error_string(e, NULL));
+ LOG(LOG_ERR, " %s\n", ERR_lib_error_string(e));
+ LOG(LOG_ERR, " %s\n", ERR_func_error_string(e));
+ LOG(LOG_ERR, " %s\n", ERR_reason_error_string(e));
ERR_free_strings();
return PTS_VERIFY_FAILED;
}
/* check */
if (validationData == NULL) {
- ERROR("validationData == NULL\n");
+ LOG(LOG_ERR, "validationData == NULL\n");
return PTS_INTERNAL_ERROR;
}
if (validationData->rgbData == NULL) {
- ERROR("validationData->rgbData == NULL\n");
+ LOG(LOG_ERR, "validationData->rgbData == NULL\n");
return PTS_INTERNAL_ERROR;
}
if (validationData->ulDataLength != 48) {
- ERROR("validationData->ulDataLength != 48, but %d\n",
+ LOG(LOG_ERR, "validationData->ulDataLength != 48, but %d\n",
validationData->ulDataLength);
return PTS_INTERNAL_ERROR;
}
/* check */
if (validationData == NULL) {
- ERROR("validationData == NULL\n");
+ LOG(LOG_ERR, "validationData == NULL\n");
return PTS_INTERNAL_ERROR;
}
if (validationData->rgbData == NULL) {
- ERROR("validationData->rgbData == NULL\n");
+ LOG(LOG_ERR, "validationData->rgbData == NULL\n");
return PTS_INTERNAL_ERROR;
}
pcrsel_size = 3;
composit_hash = &validationData->rgbData[32];
} else {
- ERROR("validationData->ulDataLength != 48 or 52, but %d\n",
+ LOG(LOG_ERR, "validationData->ulDataLength != 48 or 52, but %d\n",
validationData->ulDataLength);
return PTS_INTERNAL_ERROR;
}
// TODO(munetoh) ID must be "Start"
ctx->curr_state = getSubvertex(ctx, "Start");
if (ctx->curr_state == NULL) {
- ERROR("Start state is missing\n");
+ LOG(LOG_ERR, "Start state is missing\n");
}
DEBUG_CAL("endDocument - done\n");
if (atts != NULL) {
for (i = 0; (atts[i] != NULL); i++) {
type = (char *)atts[i++];
- // printf(", %s='", type);
if (atts[i] != NULL) {
value= (char *)atts[i];
- // printf("%s'", value);
if (!strcmp(type, "xmi:type")) {
snprintf(subvertexXmiType, sizeof(subvertexXmiType),
"%s", value);
if (atts != NULL) {
for (i = 0; (atts[i] != NULL); i++) {
type = (char *)atts[i++];
- // printf(", %s='", type);
if (atts[i] != NULL) {
value= (char *)atts[i];
- // printf("%s'", value);
if (!strcmp(type, "source")) {
snprintf(sourceXmiId, sizeof(sourceXmiId), "%s", value);
}
if (atts != NULL) {
for (i = 0; (atts[i] != NULL); i++) {
type = (char *)atts[i++];
- // printf(", %s='", type);
if (atts[i] != NULL) {
value= (char *)atts[i];
- // printf("%s'", value);
if (!strcmp(type, "name")) {
snprintf(doActivityName, sizeof(doActivityName),
"%s", value);
} else if ((!strcmp((char *)name, "body")) &&
(ctx->state == UML2SAX_TRANSITION)) {
- // } else if (!strcmp((char *)name, "body")) {
- // printf("state %d ",ctx->state);
ctx->state = UML2SAX_BODY;
} else if (!strcmp((char *)name, "name")) {
//
switch (ctx->state) {
case UML2SAX_SUBVERTEX:
- // printf("PCR_INDEX [%s]\n",buf);
- // sax_pcrIndex = atoi(buf);
break;
case UML2SAX_BODY:
memcpy(charbuf, buf, FSM_BUF_SIZE);
ctx->state = 0;
- // DEBUG("Condition [%s] len=%d\n",charbuf,len);
- // sax_pcrIndex = atoi(buf);
break;
default:
// DEBUG_SAX("characters[%d]=[%s]\n", len, buf);
* usage
*/
void usage(void) {
- fprintf(stderr, NLS(MS_OPENPTS, OPENPTS_UML2DOT_USAGE,
+ OUTPUT(NLS(MS_OPENPTS, OPENPTS_UML2DOT_USAGE,
"usage: uml2dot [options] UMLfile \n"
"\t-o output\tset output file (default is stdout)\n"
"\t$ dot -Tpng foo.dot -o foo.png; eog foo.png\n"
/* Read UML(XML) file */
if (input_filename == NULL) {
- printf(NLS(MS_OPENPTS, OPENPTS_UML2DOT_MISSING_XML_FILE, "ERROR missing XMLfile\n"));
+ ERROR(NLS(MS_OPENPTS, OPENPTS_UML2DOT_MISSING_XML_FILE, "ERROR missing XMLfile\n"));
usage();
return -1;
}
rc = readUmlModel(ctx, argv[0]);
if (rc != 0) {
- ERROR("ERROR\n");
+ LOG(LOG_ERR, "ERROR\n");
goto error;
}
rc = writeDotModel(ctx, output_filename);
if (rc != 0) {
- ERROR("ERROR\n");
+ LOG(LOG_ERR, "ERROR\n");
goto error;
}
uuid = xmalloc(sizeof(OPENPTS_UUID)); // BYTE[16]
if (uuid == NULL) {
- ERROR("no memory");
+ LOG(LOG_ERR, "no memory");
return NULL;
}
memset(uuid, 0, sizeof(OPENPTS_UUID));
/* check */
if (pts_uuid == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return NULL;
}
uuid = xmalloc(sizeof(OPENPTS_UUID)); // BYTE[16]
if (uuid == NULL) {
- ERROR("no memory");
+ LOG(LOG_ERR, "no memory");
return NULL;
}
memset(uuid, 0, sizeof(OPENPTS_UUID));
/* check */
if (filename == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return NULL;
}
uuid = newOpenptsUuid();
if (uuid == NULL) {
- ERROR("no memory");
+ LOG(LOG_ERR, "no memory");
return NULL;
}
/* load the filename */
rc = readOpenptsUuidFile(uuid);
if (rc != PTS_SUCCESS) {
- ERROR("newOpenptsUuidFromFile() - readOpenptsUuidFile() fail rc=%d\n", rc);
+ LOG(LOG_ERR, "newOpenptsUuidFromFile() - readOpenptsUuidFile() fail rc=%d\n", rc);
freeOpenptsUuid(uuid);
return NULL;
}
void freeOpenptsUuid(OPENPTS_UUID *uuid) {
/* check */
if (uuid == NULL) {
- ERROR("null input\n");
+ LOG(LOG_ERR, "null input\n");
return;
}
int genOpenptsUuid(OPENPTS_UUID *uuid) {
/* check */
if (uuid == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
} else if (uuid->status == OPENPTS_UUID_FILLED) {
// TODO Re genenation happen
uuid->status = OPENPTS_UUID_CHANGED;
- ERROR("genOpenptsUuid() %s - changed\n", uuid->str);
+ LOG(LOG_ERR, "genOpenptsUuid() %s - changed\n", uuid->str);
} else if (uuid->status == OPENPTS_UUID_CHANGED) {
// TODO Re genenation happen
uuid->status = OPENPTS_UUID_CHANGED;
- ERROR("genOpenptsUuid() %s - changed again\n", uuid->str);
+ LOG(LOG_ERR, "genOpenptsUuid() %s - changed again\n", uuid->str);
} else if (uuid->status == OPENPTS_UUID_UUID_ONLY) {
// TODO Re genenation happen
uuid->status = OPENPTS_UUID_UUID_ONLY;
- ERROR("genOpenptsUuid() %s - changed again (no binding to the file)\n", uuid->str);
+ LOG(LOG_ERR, "genOpenptsUuid() %s - changed again (no binding to the file)\n", uuid->str);
} else {
- ERROR("genOpenptsUuid() - bad status\n");
+ LOG(LOG_ERR, "genOpenptsUuid() - bad status\n");
}
/* check */
if (uuid == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
if (uuid->filename == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
/* parse */
uuid->uuid = getUuidFromString(line);
if (uuid->uuid == NULL) {
- ERROR("readUuidFile() - UUID is NULL, file %s\n", uuid->filename);
+ LOG(LOG_ERR, "readUuidFile() - UUID is NULL, file %s\n", uuid->filename);
rc = PTS_INTERNAL_ERROR;
goto close;
}
uuid->str = getStringOfUuid(uuid->uuid);
if (uuid->str == NULL) {
- ERROR("readUuidFile() - STR UUID is NULL, file %s\n", uuid->filename);
+ LOG(LOG_ERR, "readUuidFile() - STR UUID is NULL, file %s\n", uuid->filename);
rc = PTS_INTERNAL_ERROR;
goto close;
}
uuid->time = getDateTimeOfUuid(uuid->uuid);
if (uuid->time == NULL) {
- ERROR("readUuidFile() - TIME UUID is NULL, file %s\n", uuid->filename);
+ LOG(LOG_ERR, "readUuidFile() - TIME UUID is NULL, file %s\n", uuid->filename);
rc = PTS_INTERNAL_ERROR;
goto close;
}
uuid->status = OPENPTS_UUID_FILLED;
} else {
- fprintf(stderr, NLS(MS_OPENPTS, OPENPTS_UUID_READ_FAILED, "Failed to read the UUID file\n"));
+ ERROR(NLS(MS_OPENPTS, OPENPTS_UUID_READ_FAILED, "Failed to read the UUID file\n"));
}
close:
/* check */
if (uuid == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
if (uuid->filename == NULL) {
- ERROR("null input\n");
+ LOG(LOG_ERR, "null input\n");
return PTS_FATAL;
}
if ((uuid->status != OPENPTS_UUID_FILLED) && (uuid->status != OPENPTS_UUID_CHANGED)) {
- ERROR("writeOpenptsUuidFile() - uuid->status = %d (!= FILLED or CHANGED)\n", uuid->status);
+ LOG(LOG_ERR, "writeOpenptsUuidFile() - uuid->status = %d (!= FILLED or CHANGED)\n", uuid->status);
// 1 => OPENPTS_UUID_FILENAME_ONLY, UUID is missing
return PTS_INTERNAL_ERROR;
}
if (uuid->str == NULL) {
- ERROR("writeOpenptsUuidFile() - uuid->str == NULL\n");
+ LOG(LOG_ERR, "writeOpenptsUuidFile() - uuid->str == NULL\n");
return PTS_INTERNAL_ERROR;
}
if (overwrite == 1) {
/* overwrite */
if ((fp = fopen(uuid->filename, "w")) == NULL) {
- fprintf(stderr, NLS(MS_OPENPTS, OPENPTS_UUID_FILE_OPEN_FAILED,
+ ERROR(NLS(MS_OPENPTS, OPENPTS_UUID_FILE_OPEN_FAILED,
"Failed to open UUID file %s\n"), uuid->filename);
return PTS_INTERNAL_ERROR;
}
if ((fd = open(uuid->filename, O_CREAT | O_EXCL | O_WRONLY, mode)) == -1) {
if (errno == EEXIST) {
/* exist, keep the current UUID file */
- fprintf(stderr, NLS(MS_OPENPTS, OPENPTS_UUID_FILE_EXISTS,
+ ERROR(NLS(MS_OPENPTS, OPENPTS_UUID_FILE_EXISTS,
"The UUID file '%s' already exists\n"), uuid->filename);
// return PTS_SUCCESS; // TODO
return OPENPTS_FILE_EXISTS;
} else {
- fprintf(stderr, NLS(MS_OPENPTS, OPENPTS_UUID_FILE_OPEN_FAILED,
+ ERROR(NLS(MS_OPENPTS, OPENPTS_UUID_FILE_OPEN_FAILED,
"Failed to open UUID file %s\n"), uuid->filename);
return PTS_INTERNAL_ERROR;
}
}
if ((fp = fdopen(fd, "w")) == NULL) {
- fprintf(stderr, NLS(MS_OPENPTS, OPENPTS_UUID_FILE_OPEN_FAILED,
+ ERROR(NLS(MS_OPENPTS, OPENPTS_UUID_FILE_OPEN_FAILED,
"Failed to open UUID file %s\n"), uuid->filename);
return PTS_INTERNAL_ERROR;
}
uuid = xmalloc(sizeof(PTS_UUID));
if (uuid == NULL) {
- ERROR("no memory");
+ LOG(LOG_ERR, "no memory");
return NULL;
}
uuid_create((uuid_p_t)uuid, &status);
if (uuid_s_ok != status) {
- fprintf(stderr, NLS(MS_OPENPTS, OPENPTS_UUID_FAILED_GEN_NEW,
+ ERROR(NLS(MS_OPENPTS, OPENPTS_UUID_FAILED_GEN_NEW,
"Failed to generate an UUID: %s\n"), uuid_s_message[status]);
xfree(uuid);
return NULL;
void freeUuid(PTS_UUID *uuid) {
/* check */
if (uuid == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return;
}
/* check */
if (str == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return NULL;
}
uuid = xmalloc(sizeof(PTS_UUID));
if (uuid == NULL) {
- ERROR("no memory");
+ LOG(LOG_ERR, "no memory");
return NULL;
}
memset(uuid, 0, UUIDSIZE);
/* cast is ok since there are only hex digits (<128) */
uuid_from_string((unsigned char *)str, (uuid_p_t)uuid, &status);
if (uuid_s_ok != status) {
- ERROR("getUuidFromString() - uuid_from_string failed UUID='%s': %s\n",
+ LOG(LOG_ERR, "getUuidFromString() - uuid_from_string failed UUID='%s': %s\n",
str, uuid_s_message[status]);
xfree(uuid);
return NULL;
/* check */
if (uuid == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return NULL;
}
str_uuid = xmalloc(UUID_STRLEN + 1);
if (str_uuid == NULL) {
- ERROR("no memory");
+ LOG(LOG_ERR, "no memory");
return NULL;
}
uuid_to_string((uuid_p_t)uuid, (unsigned char **)&str_uuid, &status);
if (uuid_s_ok != status) {
- ERROR("getStringFromUuid() - uuid_to_string failed: %s\n",
+ LOG(LOG_ERR, "getStringFromUuid() - uuid_to_string failed: %s\n",
uuid_s_message[status]);
xfree(str_uuid);
return NULL;
/* check */
if (uuid == NULL) {
- ERROR("null input\n");
+ LOG(LOG_ERR, "null input\n");
return NULL;
}
if ((uu->clock_seq_hi_and_reserved & 0xc0) != 0x80) {
- ERROR("getDateTimeOfUuid () - bad UUID variant (0x%02x) found, can't extract timestamp\n",
+ LOG(LOG_ERR, "getDateTimeOfUuid () - bad UUID variant (0x%02x) found, can't extract timestamp\n",
(uu->clock_seq_hi_and_reserved & 0xc0) >> 4);
return NULL;
}
myUUID.clock_seq_hi_and_reserved = uu[8];
if ((myUUID.clock_seq_hi_and_reserved & 0xc0) != 0x80) {
- ERROR("uuid_time() - bad UUID variant (0x%02x) found, can't extract timestamp\n",
+ LOG(LOG_ERR, "uuid_time() - bad UUID variant (0x%02x) found, can't extract timestamp\n",
(myUUID.clock_seq_hi_and_reserved & 0xc0) >> 4);
return (time_t)-1;
}
uuid = xmalloc(sizeof(PTS_UUID)); // BYTE[16]
if (uuid == NULL) {
- ERROR("no memory");
+ LOG(LOG_ERR, "no memory");
return NULL;
}
void freeUuid(PTS_UUID *uuid) {
/* check */
if (uuid == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return;
}
/* check */
if (str == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return NULL;
}
rc = uuid_parse(str, uu);
if (rc != 0) {
- ERROR("getUuidFromString() - uuid_parse fail, rc=%d, UUID='%s'",
+ LOG(LOG_ERR, "getUuidFromString() - uuid_parse fail, rc=%d, UUID='%s'",
rc, str);
return NULL;
}
uuid = xmalloc(sizeof(PTS_UUID));
if (uuid == NULL) {
- ERROR("no memory");
+ LOG(LOG_ERR, "no memory");
return NULL;
}
memcpy(uuid, uu, 16);
/* check */
if (uuid == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return NULL;
}
str_uuid = xmalloc(37);
if (str_uuid == NULL) {
- ERROR("no memory");
+ LOG(LOG_ERR, "no memory");
return NULL;
}
/* check */
if (uuid == NULL) {
- ERROR("null input\n");
+ LOG(LOG_ERR, "null input\n");
return NULL;
}
pdt = xmalloc(sizeof(PTS_DateTime));
if (pdt == NULL) {
- ERROR("no memory");
+ LOG(LOG_ERR, "no memory");
return NULL;
}
memcpy(pdt, &time, (9*4));
pdt = xmalloc(sizeof(PTS_DateTime));
if (pdt == NULL) {
- ERROR("no memory");
+ LOG(LOG_ERR, "no memory");
return NULL;
}
memcpy(pdt, &ttm, (9*4));
// TODO HOME/.openpts/rwlock is hardcoded here
home = getenv("HOME");
if (home == NULL) {
- ERROR("HOME environment variable not defined\n");
+ LOG(LOG_ERR, "HOME environment variable not defined\n");
exit(1);
}
snprintf(path, PATH_MAX, "%s/.openpts", home);
if (mkdir(path, 0700) < 0 && errno != EEXIST) {
- ERROR("Can't create dir, %s", path);
+ LOG(LOG_ERR, "Can't create dir, %s", path);
exit(1);
}
snprintf(path, PATH_MAX, "%s/.openpts/rwlock", home);
fd = open(path, O_RDWR | O_CREAT | O_TRUNC, 0666);
if (fd < 0) {
- ERROR("Can't open lock file, %s", path);
+ LOG(LOG_ERR, "Can't open lock file, %s", path);
exit(1);
}
if (fcntl(fd, F_SETLK, &fl) < 0) {
// get PID of the process holding that lock
fcntl(fd, F_GETLK, &fl);
- fprintf(stderr, "Openpts configulation is locked by other(pid=%d)\n", fl.l_pid);
+ ERROR( // TODO NLS
+ "Openpts configulation is locked by other(pid=%d)\n", fl.l_pid);
exit(1);
}
}
/* check */
if (conf == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
if (checkDir(dirpath) == PTS_SUCCESS) {
struct stat statBuf;
if (-1 == stat(conf_file, &statBuf) && ENOENT == errno) {
- ERROR("Found openpts dir '%s', but no config file - will create one.", dirpath);
+ LOG(LOG_ERR, "Found openpts dir '%s', but no config file - will create one.", dirpath);
createBasicConfig = 1;
}
configDirExists = 1;
// create and initialize the $HOME/.openpts directory
rc = mkdir(dirpath, S_IRUSR | S_IWUSR | S_IXUSR);
if (rc != 0) {
- ERROR("mkdir on %s failed (errno=%d)", dirpath, errno);
+ LOG(LOG_ERR, "mkdir on %s failed (errno=%d)", dirpath, errno);
rc=PTS_FATAL;
goto error;
}
genOpenptsUuid(conf->uuid);
rc = writeOpenptsUuidFile(conf->uuid, 1);
if (rc != PTS_SUCCESS) {
- ERROR("Can't create UUID file, %s", uuid_file);
+ LOG(LOG_ERR, "Can't create UUID file, %s", uuid_file);
rc=PTS_FATAL;
goto error;
}
/* write Conf */
rc = writeOpenptsConf(conf, conf_file);
if (rc != PTS_SUCCESS) {
- ERROR("Can't create config file, %s", conf_file);
+ LOG(LOG_ERR, "Can't create config file, %s", conf_file);
rc=PTS_FATAL;
goto error;
}
DEBUG("read conf file : %s\n", conf_file);
rc = readOpenptsConf(conf, conf_file);
if (rc != PTS_SUCCESS) {
- ERROR("readOpenptsConf() failed\n");
+ LOG(LOG_ERR, "readOpenptsConf() failed\n");
}
return rc;
if (configDirExists == 1) {
/* rollback delete conf dir? */
// TODO
- ERROR("Can't configure the openpts(verifier). "
+ LOG(LOG_ERR, "Can't configure the openpts(verifier). "
"remove the wasted dir, e.g. rm -rf %s)", dirpath);
}
/* check */
if (ctx == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
conf = ctx->conf;
if (conf == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
verifier_uuid = conf->uuid;
if (verifier_uuid == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
}
ctx->collector_uuid = newOpenptsUuid2(&cap->platform_uuid);
if (ctx->collector_uuid == NULL) {
- // ERROR("Bad collector uuid\n");
+ // LOG(LOG_ERR, "Bad collector uuid\n");
rc = PTS_INTERNAL_ERROR;
goto close;
}
}
ctx->rm_uuid = newOpenptsUuid2(&cap->manifest_uuid);
if (ctx->rm_uuid == NULL) {
- // ERROR("Bad RM uuid\n");
+ // LOG(LOG_ERR, "Bad RM uuid\n");
rc = PTS_INTERNAL_ERROR;
goto close;
}
rc = checkDir(collector_dir);
if (rc != PTS_SUCCESS) {
/* DIR is missing, unknwon collector */
- ERROR("verifier() - Unknown collector, UUID= %s dir= %s, rc=%d\n",
+ LOG(LOG_ERR, "verifier() - Unknown collector, UUID= %s dir= %s, rc=%d\n",
ctx->collector_uuid->str, collector_dir, rc);
addReason(ctx, -1, NLS(MS_OPENPTS, OPENPTS_VERIFIER_MISSING_CONFIG_2,
"Missing collector configuration"));
rc = readTargetConf(target_conf, target_conf->config_file);
if (rc != PTS_SUCCESS) {
- ERROR("verifier() - readTargetConf failed, %s\n", target_conf->config_file);
+ LOG(LOG_ERR, "verifier() - readTargetConf failed, %s\n", target_conf->config_file);
// WORK NEEDED: Please use NLS for i18n
addReason(ctx, -1, "Missing collector configuration file");
addReason(ctx, -1, NLS(MS_OPENPTS, OPENPTS_VERIFIER_COLLECTOR_HOSTNAME,
target_conf = ctx->target_conf;
if (memcmp(target_conf->uuid->uuid, ctx->collector_uuid->uuid, 16) != 0) {
/* Miss, hostname or IP address was changed? */
- ERROR("verifier() - Unexpected collector UUID= %s, must be %s\n",
+ LOG(LOG_ERR, "verifier() - Unexpected collector UUID= %s, must be %s\n",
ctx->collector_uuid->str, target_conf->uuid->uuid);
// WORK NEEDED: Please use NLS for i18n
addReason(ctx, -1, "Collector configuration was changed");
/* Save Old RM */
rc = writeOpenptsUuidFile(target_conf->oldrm_uuid, 1);
if (rc != PTS_SUCCESS) {
- ERROR("writeOpenptsUuidFile fail\n");
+ LOG(LOG_ERR, "writeOpenptsUuidFile fail\n");
}
/* Copy NEWRM to RM */
/* Save RM */
rc = writeOpenptsUuidFile(target_conf->rm_uuid, 1);
if (rc != PTS_SUCCESS) {
- ERROR("writeOpenptsUuidFile fail\n");
+ LOG(LOG_ERR, "writeOpenptsUuidFile fail\n");
}
/* Delete New RM */
(target_conf->oldrm_uuid->uuid != NULL) &&
(memcmp(target_conf->oldrm_uuid->uuid, ctx->rm_uuid->uuid, 16) == 0)) {
/* HIT - fallback ? */
- TODO("Fallback - TBD\n");
+ LOG(LOG_TODO, "Fallback - TBD\n");
rc = PTS_RULE_NOT_FOUND; // TODO
goto close;
} else {
PTS_DateTime *t0;
PTS_DateTime *t1;
- ERROR("RM changed %s -> %s (not new rm)\n",
+ LOG(LOG_ERR, "RM changed %s -> %s (not new rm)\n",
target_conf->rm_uuid->str, ctx->rm_uuid->str);
// TODO DEBUG("RM changed %s -> %s\n", target_conf->rm_uuid->str, rm_uuid->str);
rc = checkDir(rm_dir);
if (rc != PTS_SUCCESS && 0 == *currentRmOutOfDate) {
/* unknwon RM */
- ERROR("verifier() - Unknown RM, (RM dir = %s)\n", rm_dir);
+ LOG(LOG_ERR, "verifier() - Unknown RM, (RM dir = %s)\n", rm_dir);
addReason(ctx, -1, NLS(MS_OPENPTS, OPENPTS_VERIFIER_MISSING_RM,
"Missing Reference Manifest (RM)"));
addReason(ctx, -1, NLS(MS_OPENPTS, OPENPTS_VERIFIER_COLLECTOR_HOSTNAME,
for (i = 0; i< target_conf->rm_num; i++) {
struct stat st;
if (lstat(target_conf->rm_filename[i], &st) == -1) {
- ERROR("verifier - RM (%s) is missing. Get RM from target. enroll(init) first\n",
+ LOG(LOG_ERR, "verifier - RM (%s) is missing. Get RM from target. enroll(init) first\n",
target_conf->rm_filename[i]);
rc = PTS_INTERNAL_ERROR;
goto close;
/* check */
if (ctx == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
target_conf = ctx->target_conf;
if (target_conf == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
if (value == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
/* Missing rm_basedir => create */
rc = mkdir(target_conf->rm_basedir, S_IRUSR | S_IWUSR | S_IXUSR);
if (rc != 0) {
- fprintf(stderr, NLS(MS_OPENPTS, OPENPTS_VERIFIER_CONF_DIR_CREATE_FAILED,
- "Failed to create the configuration directory '%s'\n"), buf);
+ ERROR(NLS(MS_OPENPTS, OPENPTS_VERIFIER_CONF_DIR_CREATE_FAILED,
+ "Failed to create the configuration directory '%s'\n"), buf);
rc = PTS_INTERNAL_ERROR;
goto error;
}
} else if ((st.st_mode & S_IFMT) != S_IFDIR) {
- fprintf(stderr, NLS(MS_OPENPTS, OPENPTS_VERIFIER_RM_DIR_NOT_DIR,
- "The reference manifest path '%s' is not a directory\n"), buf);
+ ERROR(NLS(MS_OPENPTS, OPENPTS_VERIFIER_RM_DIR_NOT_DIR,
+ "The reference manifest path '%s' is not a directory\n"), buf);
rc = PTS_INTERNAL_ERROR;
goto close;
}
rc = saveToFile(target_conf->rm_filename[i], len, value);
if (rc != PTS_SUCCESS) {
- ERROR("enroll - save RM[%d], %s failed\n", i, target_conf->rm_filename[i]);
+ LOG(LOG_ERR, "enroll - save RM[%d], %s failed\n", i, target_conf->rm_filename[i]);
rc = PTS_INTERNAL_ERROR;
goto close;
}
rc = writeOpenptsUuidFile(target_conf->rm_uuid, 1); // TODO do not overwite?
if (rc != PTS_SUCCESS) {
- ERROR("writeOpenptsUuidFile fail\n");
+ LOG(LOG_ERR, "writeOpenptsUuidFile fail\n");
}
close:
/* check */
if (ctx == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
if (filename == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
if ((fp = fopen(filename, "w")) == NULL) {
- fprintf(stderr, NLS(MS_OPENPTS, OPENPTS_VERIFIER_OPEN_FAILED, "Failed to open policy file '%s'\n"), filename);
- return -1;
+ ERROR(NLS(MS_OPENPTS, OPENPTS_VERIFIER_OPEN_FAILED,
+ "Failed to open policy file '%s'\n"), filename);
+ return PTS_FATAL;
}
/* top */
/* check */
if (ctx == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
if (filename == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
if ((fp = fopen(filename, "w")) == NULL) {
- fprintf(stderr, NLS(MS_OPENPTS, OPENPTS_VERIFIER_OPEN_FAILED_2,
+ ERROR(NLS(MS_OPENPTS, OPENPTS_VERIFIER_OPEN_FAILED_2,
"Failed to open AIDE ignore list '%s'\n"), filename);
return -1;
}
/* top */
ss = getSnapshotFromTable(ctx->ss_table, 10, 1); // Linux-IMA, TODO define by CONF?
if (ss == NULL) {
- ERROR("Snapshot at PCR[10] level 1 is missing\n");
+ LOG(LOG_ERR, "Snapshot at PCR[10] level 1 is missing\n");
} else {
ew = ss->start;
rc = hcreate_r(HASH_TABLE_SIZE, &hd);
if (rc == 0) {
if (errno == ENOMEM) {
- ERROR("ENOMEM\n");
+ LOG(LOG_ERR, "ENOMEM\n");
cnt = -1;
goto error;
}
- ERROR("ERROR rc=%d\n", rc);
+ LOG(LOG_ERR, "ERROR rc=%d\n", rc);
// return -1;
cnt = -1;
goto error;
/* check */
if (ctx == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
target_conf = ctx->target_conf;
if (target_conf == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
if (value == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
if (rc != PTS_SUCCESS) {
DEBUG("target_conf->ir_filename, %s\n", target_conf->ir_filename);
addReason(ctx, -1, "[IMV] failed to save IR, %s)", target_conf->ir_filename);
- fprintf(stderr, NLS(MS_OPENPTS, OPENPTS_VERIFIER_SAVE_IR_FAILED,
+ ERROR(NLS(MS_OPENPTS, OPENPTS_VERIFIER_SAVE_IR_FAILED,
"[verifier] failed to save IR\n"));
rc = PTS_INTERNAL_ERROR;
goto close;
}
} else {
addReason(ctx, -1, "[IMV] failed to send IR)");
- fprintf(stderr, NLS(MS_OPENPTS, OPENPTS_VERIFIER_SEND_IR_FAILED,
+ ERROR(NLS(MS_OPENPTS, OPENPTS_VERIFIER_SEND_IR_FAILED,
"[verifier] failed to send IR\n"));
rc = PTS_INTERNAL_ERROR;
goto close;
for (i = 0; i < target_conf->rm_num; i++) {
rc = readRmFile(ctx, target_conf->rm_filename[i], i);
if (rc < 0) {
- ERROR("readRmFile fail\n");
+ LOG(LOG_ERR, "readRmFile fail\n");
rc = PTS_INTERNAL_ERROR;
goto close;
}
DEBUG("Load Policy -------------------------------- \n");
rc = loadPolicyFile(ctx, target_conf->policy_filename);
if (rc < 0) {
- ERROR("loadPolicyFile fail\n");
+ LOG(LOG_ERR, "loadPolicyFile fail\n");
rc = PTS_INTERNAL_ERROR;
goto close;
}
rc = saveProperties(ctx, target_conf->prop_filename);
if (rc != PTS_SUCCESS) {
- ERROR("saveProperties was failed %s\n", target_conf->prop_filename);
+ LOG(LOG_ERR, "saveProperties was failed %s\n", target_conf->prop_filename);
goto close;
}
} else if (mode == OPENPTS_UPDATE_MODE) {
}
#endif
} else {
- ERROR("unknown mode %d\n", mode);
+ LOG(LOG_ERR, "unknown mode %d\n", mode);
rc = PTS_INTERNAL_ERROR;
goto close;
}
/* check */
if (ctx == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_INTERNAL_ERROR;
}
if (ctx->conf == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_INTERNAL_ERROR;
}
// the target UUID may have been reseted, erase the known one
unlinkDir(target->dir);
} else if (ctx->target_conf != NULL) {
- ERROR("enroll() - target_conf of %s already exist?\n", host);
+ LOG(LOG_ERR, "enroll() - target_conf of %s already exist?\n", host);
goto out;
}
/* V->C capability (hello) */
len = writePtsTlv(ctx, sock, OPENPTS_CAPABILITIES);
if (len < 0) {
- ERROR("Failed to send capability message, rc = %d\n", len);
+ LOG(LOG_ERR, "Failed to send capability message, rc = %d\n", len);
rc = PTS_INTERNAL_ERROR;
goto close;
}
/* C->V capability (hello) */
read_tlv = readPtsTlv(sock);
if (read_tlv == NULL) {
- ERROR("Can not get the message from collector\n");
+ LOG(LOG_ERR, "Can not get the message from collector\n");
rc = PTS_INTERNAL_ERROR;
goto close;
}
if (read_tlv->type != OPENPTS_CAPABILITIES) {
- ERROR("Expected OPENPTS_CAPABILITIES reply, instead got type '%d'\n", read_tlv->type);
+ LOG(LOG_ERR, "Expected OPENPTS_CAPABILITIES reply, instead got type '%d'\n", read_tlv->type);
rc = PTS_INTERNAL_ERROR;
goto close;
}
if (read_tlv->length != sizeof(OPENPTS_IF_M_Capability)) { // TODO set name
- ERROR("UUID length = %d != 36\n", read_tlv->length);
+ LOG(LOG_ERR, "UUID length = %d != 36\n", read_tlv->length);
rc = PTS_INTERNAL_ERROR;
goto close;
}
/* V->C template RIMM req */
len = writePtsTlv(ctx, sock, REQUEST_RIMM_SET);
if (len < 0) {
- ERROR("template RIMM req was failed\n");
+ LOG(LOG_ERR, "template RIMM req was failed\n");
rc = PTS_INTERNAL_ERROR;
goto close;
}
/* C->V template RIMM (RIMM embedded to CTX) */
read_tlv = readPtsTlv(sock);
if (read_tlv == NULL) {
- ERROR("Problem receiving PTS message\n");
+ LOG(LOG_ERR, "Problem receiving PTS message\n");
rc = PTS_INTERNAL_ERROR;
goto close;
} else if (read_tlv->type == OPENPTS_ERROR) {
- ERROR("Request RIMM_SET was failed. collector returns error message");
+ LOG(LOG_ERR, "Request RIMM_SET was failed. collector returns error message");
rc = PTS_INTERNAL_ERROR;
goto close;
} else if (read_tlv->type != RIMM_SET) {
- ERROR("Bad return message, %X != %X", read_tlv->type, RIMM_SET);
+ LOG(LOG_ERR, "Bad return message, %X != %X", read_tlv->type, RIMM_SET);
rc = PTS_INTERNAL_ERROR;
goto close;
}
rc = verifierHandleRimmSet(ctx, (BYTE*) read_tlv->value);
if (rc != PTS_SUCCESS) {
- ERROR("Bad RIMM_SET?");
+ LOG(LOG_ERR, "Bad RIMM_SET?");
rc = PTS_INTERNAL_ERROR;
goto close;
}
len = writePtsTlv(ctx, sock, REQUEST_TPM_PUBKEY); // ifm.c
if (len < 0) {
- ERROR("enroll() - REQUEST_TPM_PUBKEY was failed, len=%d\n", len);
+ LOG(LOG_ERR, "enroll() - REQUEST_TPM_PUBKEY was failed, len=%d\n", len);
rc = PTS_INTERNAL_ERROR;
goto close;
}
/* C->V TPM PUBKEY */
read_tlv = readPtsTlv(sock);
if (read_tlv == NULL) {
- ERROR("Problem receiving PTS message\n");
+ LOG(LOG_ERR, "Problem receiving PTS message\n");
rc = PTS_INTERNAL_ERROR;
goto close;
} else if (read_tlv->type == OPENPTS_ERROR) {
// TODO Ignore now
- TODO("Target did not have TPM_PUBKEY");
+ LOG(LOG_TODO, "Target did not have TPM_PUBKEY");
// WORK NEEDED - Please use NLS for i18n
addReason(ctx, -1, "Target did not have TPM_PUBKEY\n");
rc = PTS_INTERNAL_ERROR;
goto close;
} else if (read_tlv->type != TPM_PUBKEY) {
- ERROR("read_tlv->type != TPM_PUBKEY, but %d", read_tlv->type);
+ LOG(LOG_ERR, "read_tlv->type != TPM_PUBKEY, but %d", read_tlv->type);
rc = PTS_INTERNAL_ERROR;
goto close;
}
#ifdef CONFIG_AIDE
- // TODO(munetoh) capability defile validation mode of collector
+ // LOG(LOG_TODO, munetoh) capability defile validation mode of collector
/* V->C AIDE_DATABASE req */
len = writePtsTlv(ctx, sock, REQUEST_AIDE_DATABASE);
if (len < 0) {
- ERROR("template RIMM req was failed\n");
+ LOG(LOG_ERR, "template RIMM req was failed\n");
rc = PTS_INTERNAL_ERROR;
goto close;
}
/* C->V AIDE DATABASE */
read_tlv = readPtsTlv(sock);
if (read_tlv == NULL) {
- ERROR("Problem receiving PTS message\n");
+ LOG(LOG_ERR, "Problem receiving PTS message\n");
rc = PTS_INTERNAL_ERROR;
goto close;
} else if (read_tlv->type != AIDE_DATABASE) {
target_conf->ima_validation_mode = OPENPTS_VALIDATION_MODE_NONE;
DEBUG("enroll - AIDE DB is missing. do not validate IMA's IMLs\n");
} else {
- ERROR("enroll - RAIDE DB req. returns unknown message type 0x%x", read_tlv->type);
+ LOG(LOG_ERR, "enroll - RAIDE DB req. returns unknown message type 0x%x", read_tlv->type);
rc = PTS_INTERNAL_ERROR;
goto close;
}
rc = saveToFile(target_conf->aide_database_filename, read_tlv->length, read_tlv->value);
if (rc < 0) {
- ERROR("enroll - save AIDE DB failed\n");
+ LOG(LOG_ERR, "enroll - save AIDE DB failed\n");
rc = PTS_INTERNAL_ERROR;
goto close;
}
ctx->conf->aide_database_filename,
ctx->conf->aide_sqlite_filename);
if (rc != PTS_SUCCESS) {
- ERROR("enroll - convert AIDE DB to SQLiteDB was failed\n");
+ LOG(LOG_ERR, "enroll - convert AIDE DB to SQLiteDB was failed\n");
rc = PTS_INTERNAL_ERROR;
goto close;
}
/* check */
if (ctx == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
conf = ctx->conf;
if (conf == NULL) {
- ERROR("null input");
+ LOG(LOG_ERR, "null input");
return PTS_FATAL;
}
&sock);
if (ssh_pid == -1) {
- ERROR("connection failed (server = %s)\n", host);
+ LOG(LOG_ERR, "connection failed (server = %s)\n", host);
addReason(ctx, -1, NLS(MS_OPENPTS, OPENPTS_VERIFIER_CONNECT_FAILED,
"Connection failed (server = %s)\n"), host);
rc = PTS_OS_ERROR;
/* V->C capability (hello) */
len = writePtsTlv(ctx, sock, OPENPTS_CAPABILITIES);
if (len < 0) {
- ERROR("Failed to send capability message\n");
+ LOG(LOG_ERR, "Failed to send capability message\n");
rc = PTS_INTERNAL_ERROR;
goto close;
}
/* C->V capability (hello) */
read_tlv = readPtsTlv(sock);
if (read_tlv == NULL) {
- ERROR("can't connect to target, %s\n", host);
+ LOG(LOG_ERR, "can't connect to target, %s\n", host);
rc = PTS_INTERNAL_ERROR;
goto close;
} else if (read_tlv->type != OPENPTS_CAPABILITIES) {
- ERROR("Expected OPENPTS_CAPABILITIES reply, instead got type '%d'\n", read_tlv->type);
+ LOG(LOG_ERR, "Expected OPENPTS_CAPABILITIES reply, instead got type '%d'\n", read_tlv->type);
rc = PTS_INTERNAL_ERROR;
goto close;
} else if (read_tlv->length != sizeof(OPENPTS_IF_M_Capability)) {
// TODO PTS_CAPABILITIES_SIZE
- ERROR("UUID length = %d != 36\n", read_tlv->length);
+ LOG(LOG_ERR, "UUID length = %d != 36\n", read_tlv->length);
rc = PTS_INTERNAL_ERROR;
goto close;
}
rc = verifierHandleCapability(ctx, conf_dir, host, cap,
¬ifiedOfPendingRm, ¤tRmOutOfDate);
if (rc != PTS_SUCCESS) {
- ERROR("Failed to exchange capabilities\n");
+ LOG(LOG_ERR, "Failed to exchange capabilities\n");
goto close;
}
/* send req */
len = writePtsTlv(ctx, sock, DH_NONCE_PARAMETERS_REQUEST);
if (len < 0) {
- ERROR("Failed to send nonce parameters request\n");
+ LOG(LOG_ERR, "Failed to send nonce parameters request\n");
rc = PTS_INTERNAL_ERROR;
goto close;
}
read_tlv = readPtsTlv(sock);
if (read_tlv == NULL) {
- ERROR("[IF-M] DH_NONCE_PARAMETERS_REQUEST was failed, check the collector");
+ LOG(LOG_ERR, "[IF-M] DH_NONCE_PARAMETERS_REQUEST was failed, check the collector");
rc = PTS_INTERNAL_ERROR;
goto close;
} else if (read_tlv->type != DH_NONCE_PARAMETORS_RESPONSE) {
- ERROR("Expected DH_NONCE_PARAMETORS_RESPONSE reply, but instead got type '%d'\n",
+ LOG(LOG_ERR, "Expected DH_NONCE_PARAMETORS_RESPONSE reply, but instead got type '%d'\n",
read_tlv->type);
rc = PTS_INTERNAL_ERROR;
goto close;
ctx->nonce->res->hash_alg_set = (read_tlv->value[6]<<8) | read_tlv->value[7];
if (ctx->nonce->res->nonce_length < MINIMUM_NONCE_LENGTH) {
- ERROR("Expected minimum nonce length of '%d', instead got '%d'\n",
+ LOG(LOG_ERR, "Expected minimum nonce length of '%d', instead got '%d'\n",
MINIMUM_NONCE_LENGTH, ctx->nonce->res->nonce_length);
rc = PTS_INTERNAL_ERROR;
goto close;
/* set pubkey length */
if ( 0 != setDhPubkeylength(ctx->nonce) ) {
- ERROR("setDhPubkeylength failed\n");
+ LOG(LOG_ERR, "setDhPubkeylength failed\n");
rc = PTS_INTERNAL_ERROR;
goto close;
}
rc = calcDh(ctx->nonce);
if (rc != 0) {
- ERROR("calcDh failed\n");
+ LOG(LOG_ERR, "calcDh failed\n");
rc = PTS_INTERNAL_ERROR;
goto close;
}
/* V->C D-H nonce finish --------------------------------------------- */
len = writePtsTlv(ctx, sock, DH_NONCE_FINISH);
if (len < 0) {
- ERROR("Failed to send nonce finish message\n");
+ LOG(LOG_ERR, "Failed to send nonce finish message\n");
rc = PTS_INTERNAL_ERROR;
goto close;
}
/* V->C IR req -------------------------------------------------------- */
len = writePtsTlv(ctx, sock, REQUEST_INTEGRITY_REPORT);
if (len < 0) {
- ERROR("Failed to send request integrity report message\n");
+ LOG(LOG_ERR, "Failed to send request integrity report message\n");
rc = PTS_INTERNAL_ERROR;
goto close;
}
read_tlv = readPtsTlv(sock);
if (read_tlv == NULL) {
- ERROR("Failed to get integrity report. Please check the collector.\n");
+ LOG(LOG_ERR, "Failed to get integrity report. Please check the collector.\n");
rc = PTS_INTERNAL_ERROR;
goto close;
} else if (read_tlv->type != INTEGRITY_REPORT) {
- ERROR("read_tlv->type != INTEGRITY_REPORT, but 0x%X (0x0F:OPENPTS_ERROR)", read_tlv->type);
+ LOG(LOG_ERR, "read_tlv->type != INTEGRITY_REPORT, but 0x%X (0x0F:OPENPTS_ERROR)", read_tlv->type);
rc = PTS_INTERNAL_ERROR;
goto close;
}
rc = verifierHandleIR(ctx, read_tlv->length, read_tlv->value, mode, &result);
if (rc != PTS_SUCCESS) {
- ERROR("verifierHandleIR fail\n");
+ LOG(LOG_ERR, "verifierHandleIR fail\n");
rc = PTS_INTERNAL_ERROR;
goto close;
}
/* V->C template RIMM req */
rc = writePtsTlv(ctx, sock, REQUEST_NEW_RIMM_SET);
if (rc < 0) {
- ERROR("writePtsTlv() fail");
+ LOG(LOG_ERR, "writePtsTlv() fail");
rc = PTS_INTERNAL_ERROR;
goto close;
}
/* V->C VR */
len = writePtsTlv(ctx, sock, VERIFICATION_RESULT);
if (len < 0) {
- ERROR("writePtsTlv() fail");
+ LOG(LOG_ERR, "writePtsTlv() fail");
rc = PTS_INTERNAL_ERROR;
goto close;
}