added PTS debug class

This commit is contained in:
Andreas Steffen
2011-09-11 00:11:04 +02:00
parent 12e065eacd
commit b9d61f78d3
9 changed files with 46 additions and 41 deletions
+2 -1
View File
@@ -425,7 +425,7 @@ static void usage(const char *msg)
" [--version]\n" " [--version]\n"
" [--use-syslog]\n" " [--use-syslog]\n"
" [--debug-<type> <level>]\n" " [--debug-<type> <level>]\n"
" <type>: log context type (dmn|mgr|ike|chd|job|cfg|knl|net|enc|tnc|tls|lib)\n" " <type>: log context type (dmn|mgr|ike|chd|job|cfg|knl|net|enc|tnc|imc|imv|pts|tls|lib)\n"
" <level>: log verbosity (-1 = silent, 0 = audit, 1 = control,\n" " <level>: log verbosity (-1 = silent, 0 = audit, 1 = control,\n"
" 2 = controlmore, 3 = raw, 4 = private)\n" " 2 = controlmore, 3 = raw, 4 = private)\n"
"\n" "\n"
@@ -500,6 +500,7 @@ int main(int argc, char *argv[])
{ "debug-tnc", required_argument, &group, DBG_TNC }, { "debug-tnc", required_argument, &group, DBG_TNC },
{ "debug-imc", required_argument, &group, DBG_IMC }, { "debug-imc", required_argument, &group, DBG_IMC },
{ "debug-imv", required_argument, &group, DBG_IMV }, { "debug-imv", required_argument, &group, DBG_IMV },
{ "debug-pts", required_argument, &group, DBG_PTS },
{ "debug-tls", required_argument, &group, DBG_TLS }, { "debug-tls", required_argument, &group, DBG_TLS },
{ "debug-lib", required_argument, &group, DBG_LIB }, { "debug-lib", required_argument, &group, DBG_LIB },
{ 0,0,0,0 } { 0,0,0,0 }
+24 -24
View File
@@ -82,7 +82,7 @@ METHOD(pts_t, set_proto_caps, void,
private_pts_t *this, pts_proto_caps_flag_t flags) private_pts_t *this, pts_proto_caps_flag_t flags)
{ {
this->proto_caps = flags; this->proto_caps = flags;
DBG2(DBG_IMC, "supported PTS protocol capabilities: %s%s%s%s%s", DBG2(DBG_PTS, "supported PTS protocol capabilities: %s%s%s%s%s",
flags & PTS_PROTO_CAPS_C ? "C" : ".", flags & PTS_PROTO_CAPS_C ? "C" : ".",
flags & PTS_PROTO_CAPS_V ? "V" : ".", flags & PTS_PROTO_CAPS_V ? "V" : ".",
flags & PTS_PROTO_CAPS_D ? "D" : ".", flags & PTS_PROTO_CAPS_D ? "D" : ".",
@@ -102,7 +102,7 @@ METHOD(pts_t, set_meas_algorithm, void,
hash_algorithm_t hash_alg; hash_algorithm_t hash_alg;
hash_alg = pts_meas_to_hash_algorithm(algorithm); hash_alg = pts_meas_to_hash_algorithm(algorithm);
DBG2(DBG_IMC, "selected PTS measurement algorithm is %N", DBG2(DBG_PTS, "selected PTS measurement algorithm is %N",
hash_algorithm_names, hash_alg); hash_algorithm_names, hash_alg);
if (hash_alg != HASH_UNKNOWN) if (hash_alg != HASH_UNKNOWN)
{ {
@@ -123,12 +123,12 @@ static void print_tpm_version_info(private_pts_t *this)
this->tpm_version_info.ptr, &versionInfo); this->tpm_version_info.ptr, &versionInfo);
if (result != TSS_SUCCESS) if (result != TSS_SUCCESS)
{ {
DBG1(DBG_TNC, "could not parse tpm version info: tss error 0x%x", DBG1(DBG_PTS, "could not parse tpm version info: tss error 0x%x",
result); result);
} }
else else
{ {
DBG2(DBG_TNC, "TPM 1.2 Version Info: Chip Version: %hhu.%hhu.%hhu.%hhu," DBG2(DBG_PTS, "TPM 1.2 Version Info: Chip Version: %hhu.%hhu.%hhu.%hhu,"
" Spec Level: %hu, Errata Rev: %hhu, Vendor ID: %.4s", " Spec Level: %hu, Errata Rev: %hhu, Vendor ID: %.4s",
versionInfo.version.major, versionInfo.version.minor, versionInfo.version.major, versionInfo.version.minor,
versionInfo.version.revMajor, versionInfo.version.revMinor, versionInfo.version.revMajor, versionInfo.version.revMinor,
@@ -189,7 +189,7 @@ static void load_aik(private_pts_t *this)
cert_path, BUILD_END); cert_path, BUILD_END);
if (this->aik) if (this->aik)
{ {
DBG2(DBG_IMC, "loaded AIK certificate from '%s'", cert_path); DBG2(DBG_PTS, "loaded AIK certificate from '%s'", cert_path);
return; return;
} }
} }
@@ -200,11 +200,11 @@ static void load_aik(private_pts_t *this)
key_path, BUILD_END); key_path, BUILD_END);
if (this->aik) if (this->aik)
{ {
DBG2(DBG_IMC, "loaded AIK public key from '%s'", key_path); DBG2(DBG_PTS, "loaded AIK public key from '%s'", key_path);
return; return;
} }
} }
DBG1(DBG_IMC, "neither AIK certificate nor public key is available"); DBG1(DBG_PTS, "neither AIK certificate nor public key is available");
} }
METHOD(pts_t, get_aik, certificate_t*, METHOD(pts_t, get_aik, certificate_t*,
@@ -232,7 +232,7 @@ static bool hash_file(hasher_t *hasher, char *pathname, u_char *hash)
file = fopen(pathname, "rb"); file = fopen(pathname, "rb");
if (!file) if (!file)
{ {
DBG1(DBG_IMC," file '%s' can not be opened, %s", pathname, DBG1(DBG_PTS," file '%s' can not be opened, %s", pathname,
strerror(errno)); strerror(errno));
return FALSE; return FALSE;
} }
@@ -284,17 +284,17 @@ METHOD(pts_t, is_path_valid, bool, private_pts_t *this, char *path,
} }
else if (error == ENOENT || error == ENOTDIR) else if (error == ENOENT || error == ENOTDIR)
{ {
DBG1(DBG_IMC, "file/directory does not exist %s", path); DBG1(DBG_PTS, "file/directory does not exist %s", path);
*error_code = TCG_PTS_FILE_NOT_FOUND; *error_code = TCG_PTS_FILE_NOT_FOUND;
} }
else if (error == EFAULT) else if (error == EFAULT)
{ {
DBG1(DBG_IMC, "bad address %s", path); DBG1(DBG_PTS, "bad address %s", path);
*error_code = TCG_PTS_INVALID_PATH; *error_code = TCG_PTS_INVALID_PATH;
} }
else else
{ {
DBG1(DBG_IMC, "error: %s occured while validating path: %s", DBG1(DBG_PTS, "error: %s occured while validating path: %s",
strerror(error), path); strerror(error), path);
return FALSE; return FALSE;
} }
@@ -316,7 +316,7 @@ METHOD(pts_t, do_measurements, pts_file_meas_t*,
hasher = lib->crypto->create_hasher(lib->crypto, hash_alg); hasher = lib->crypto->create_hasher(lib->crypto, hash_alg);
if (!hasher) if (!hasher)
{ {
DBG1(DBG_IMC, " hasher %N not available", hash_algorithm_names, hash_alg); DBG1(DBG_PTS, " hasher %N not available", hash_algorithm_names, hash_alg);
return NULL; return NULL;
} }
@@ -335,7 +335,7 @@ METHOD(pts_t, do_measurements, pts_file_meas_t*,
enumerator = enumerator_create_directory(pathname); enumerator = enumerator_create_directory(pathname);
if (!enumerator) if (!enumerator)
{ {
DBG1(DBG_IMC," directory '%s' can not be opened, %s", pathname, DBG1(DBG_PTS," directory '%s' can not be opened, %s", pathname,
strerror(errno)); strerror(errno));
hasher->destroy(hasher); hasher->destroy(hasher);
measurements->destroy(measurements); measurements->destroy(measurements);
@@ -353,7 +353,7 @@ METHOD(pts_t, do_measurements, pts_file_meas_t*,
measurements->destroy(measurements); measurements->destroy(measurements);
return NULL; return NULL;
} }
DBG2(DBG_IMC, " %#B for '%s'", &measurement, rel_name); DBG2(DBG_PTS, " %#B for '%s'", &measurement, rel_name);
measurements->add(measurements, rel_name, measurement); measurements->add(measurements, rel_name, measurement);
} }
} }
@@ -370,7 +370,7 @@ METHOD(pts_t, do_measurements, pts_file_meas_t*,
return NULL; return NULL;
} }
filename = get_filename(pathname); filename = get_filename(pathname);
DBG2(DBG_IMC, " %#B for '%s'", &measurement, filename); DBG2(DBG_PTS, " %#B for '%s'", &measurement, filename);
measurements->add(measurements, filename, measurement); measurements->add(measurements, filename, measurement);
} }
hasher->destroy(hasher); hasher->destroy(hasher);
@@ -434,7 +434,7 @@ static char* extract_platform_info(void)
buf[len] = '\0'; buf[len] = '\0';
if (fread(buf, 1, len, file) != len) if (fread(buf, 1, len, file) != len)
{ {
DBG1(DBG_IMC, "failed to read file '%s'", releases[i]); DBG1(DBG_PTS, "failed to read file '%s'", releases[i]);
fclose(file); fclose(file);
return NULL; return NULL;
} }
@@ -445,7 +445,7 @@ static char* extract_platform_info(void)
pos = strstr(buf, description); pos = strstr(buf, description);
if (!pos) if (!pos)
{ {
DBG1(DBG_IMC, "failed to find begin of lsb-release " DBG1(DBG_PTS, "failed to find begin of lsb-release "
"DESCRIPTION field"); "DESCRIPTION field");
return NULL; return NULL;
} }
@@ -453,7 +453,7 @@ static char* extract_platform_info(void)
pos = strchr(value, '"'); pos = strchr(value, '"');
if (!pos) if (!pos)
{ {
DBG1(DBG_IMC, "failed to find end of lsb-release " DBG1(DBG_PTS, "failed to find end of lsb-release "
"DESCRIPTION field"); "DESCRIPTION field");
return NULL; return NULL;
} }
@@ -464,7 +464,7 @@ static char* extract_platform_info(void)
pos = strchr(value, '\n'); pos = strchr(value, '\n');
if (!pos) if (!pos)
{ {
DBG1(DBG_IMC, "failed to find end of release string"); DBG1(DBG_PTS, "failed to find end of release string");
return NULL; return NULL;
} }
} }
@@ -473,13 +473,13 @@ static char* extract_platform_info(void)
if (!value) if (!value)
{ {
DBG1(DBG_IMC, "no distribution release file found"); DBG1(DBG_PTS, "no distribution release file found");
return NULL; return NULL;
} }
if (uname(&uninfo) < 0) if (uname(&uninfo) < 0)
{ {
DBG1(DBG_IMC, "could not retrieve machine architecture"); DBG1(DBG_PTS, "could not retrieve machine architecture");
return NULL; return NULL;
} }
@@ -487,7 +487,7 @@ static char* extract_platform_info(void)
len = sizeof(buf)-1 + (pos - buf); len = sizeof(buf)-1 + (pos - buf);
strncpy(pos, uninfo.machine, len); strncpy(pos, uninfo.machine, len);
DBG1(DBG_IMC, "platform is '%s'", value); DBG1(DBG_PTS, "platform is '%s'", value);
return strdup(value); return strdup(value);
} }
@@ -504,7 +504,7 @@ static bool has_tpm(private_pts_t *this)
result = Tspi_Context_Create(&hContext); result = Tspi_Context_Create(&hContext);
if (result != TSS_SUCCESS) if (result != TSS_SUCCESS)
{ {
DBG1(DBG_IMC, "TPM context could not be created: tss error 0x%x", result); DBG1(DBG_PTS, "TPM context could not be created: tss error 0x%x", result);
return FALSE; return FALSE;
} }
result = Tspi_Context_Connect(hContext, NULL); result = Tspi_Context_Connect(hContext, NULL);
@@ -529,7 +529,7 @@ static bool has_tpm(private_pts_t *this)
return TRUE; return TRUE;
err: err:
DBG1(DBG_IMC, "TPM not available: tss error 0x%x", result); DBG1(DBG_PTS, "TPM not available: tss error 0x%x", result);
Tspi_Context_Close(hContext); Tspi_Context_Close(hContext);
return FALSE; return FALSE;
} }
+5 -5
View File
@@ -64,7 +64,7 @@ static void load_cacerts(private_pts_creds_t *this, char *path)
struct stat st; struct stat st;
char *file; char *file;
DBG1(DBG_TNC, "loading PTS ca certificates from '%s'", path); DBG1(DBG_PTS, "loading PTS ca certificates from '%s'", path);
enumerator = enumerator_create_directory(path); enumerator = enumerator_create_directory(path);
if (!enumerator) if (!enumerator)
@@ -89,20 +89,20 @@ static void load_cacerts(private_pts_creds_t *this, char *path)
if (!(x509->get_flags(x509) & X509_CA)) if (!(x509->get_flags(x509) & X509_CA))
{ {
DBG1(DBG_TNC, " ca certificate \"%Y\" lacks ca basic constraint" DBG1(DBG_PTS, " ca certificate \"%Y\" lacks ca basic constraint"
", discarded", cert->get_subject(cert)); ", discarded", cert->get_subject(cert));
cert->destroy(cert); cert->destroy(cert);
} }
else else
{ {
DBG1(DBG_TNC, " loaded ca certificate \"%Y\" from '%s'", DBG1(DBG_PTS, " loaded ca certificate \"%Y\" from '%s'",
cert->get_subject(cert), file); cert->get_subject(cert), file);
this->creds->add_cert(this->creds, TRUE, cert); this->creds->add_cert(this->creds, TRUE, cert);
} }
} }
else else
{ {
DBG1(DBG_TNC, " loading ca certificate from '%s' failed", file); DBG1(DBG_PTS, " loading ca certificate from '%s' failed", file);
} }
} }
enumerator->destroy(enumerator); enumerator->destroy(enumerator);
@@ -117,7 +117,7 @@ pts_creds_t *pts_creds_create(char *path)
if (!path) if (!path)
{ {
DBG1(DBG_TNC, "no PTS cacerts directory defined"); DBG1(DBG_PTS, "no PTS cacerts directory defined");
return NULL; return NULL;
} }
+1 -1
View File
@@ -107,7 +107,7 @@ pts_database_t *pts_database_create(char *uri)
if (!this->db) if (!this->db)
{ {
DBG1(DBG_TNC, "failed to connect to PTS file measurement database '%s'", DBG1(DBG_PTS, "failed to connect to PTS file measurement database '%s'",
uri); uri);
free(this); free(this);
return NULL; return NULL;
+3 -3
View File
@@ -133,17 +133,17 @@ METHOD(pts_file_meas_t, verify, bool,
if (!found) if (!found)
{ {
DBG1(DBG_TNC, " no measurement found for '%s'", filename); DBG1(DBG_PTS, " no measurement found for '%s'", filename);
success = FALSE; success = FALSE;
continue; continue;
} }
if (chunk_equals(measurement, entry->measurement)) if (chunk_equals(measurement, entry->measurement))
{ {
DBG2(DBG_TNC, " %#B for '%s' is ok", &measurement, filename); DBG2(DBG_PTS, " %#B for '%s' is ok", &measurement, filename);
} }
else else
{ {
DBG1(DBG_TNC, " %#B for '%s' is incorrect", &measurement, filename); DBG1(DBG_PTS, " %#B for '%s' is incorrect", &measurement, filename);
success = FALSE; success = FALSE;
} }
if (!is_dir) if (!is_dir)
+6 -6
View File
@@ -36,19 +36,19 @@ bool pts_meas_probe_algorithms(pts_meas_algorithms_t *algorithms)
if (hash_alg == HASH_SHA1) if (hash_alg == HASH_SHA1)
{ {
*algorithms |= PTS_MEAS_ALGO_SHA1; *algorithms |= PTS_MEAS_ALGO_SHA1;
DBG2(DBG_TNC, format1, "mandatory", hash_algorithm_names, hash_alg, DBG2(DBG_PTS, format1, "mandatory", hash_algorithm_names, hash_alg,
plugin_name); plugin_name);
} }
else if (hash_alg == HASH_SHA256) else if (hash_alg == HASH_SHA256)
{ {
*algorithms |= PTS_MEAS_ALGO_SHA256; *algorithms |= PTS_MEAS_ALGO_SHA256;
DBG2(DBG_TNC, format1, "mandatory", hash_algorithm_names, hash_alg, DBG2(DBG_PTS, format1, "mandatory", hash_algorithm_names, hash_alg,
plugin_name); plugin_name);
} }
else if (hash_alg == HASH_SHA384) else if (hash_alg == HASH_SHA384)
{ {
*algorithms |= PTS_MEAS_ALGO_SHA384; *algorithms |= PTS_MEAS_ALGO_SHA384;
DBG2(DBG_TNC, format1, "optional ", hash_algorithm_names, hash_alg, DBG2(DBG_PTS, format1, "optional ", hash_algorithm_names, hash_alg,
plugin_name); plugin_name);
} }
} }
@@ -56,7 +56,7 @@ bool pts_meas_probe_algorithms(pts_meas_algorithms_t *algorithms)
if (!(*algorithms & PTS_MEAS_ALGO_SHA384)) if (!(*algorithms & PTS_MEAS_ALGO_SHA384))
{ {
DBG1(DBG_TNC, format2, "optional ", hash_algorithm_names, HASH_SHA384); DBG1(DBG_PTS, format2, "optional ", hash_algorithm_names, HASH_SHA384);
} }
if ((*algorithms & PTS_MEAS_ALGO_SHA1) && if ((*algorithms & PTS_MEAS_ALGO_SHA1) &&
(*algorithms & PTS_MEAS_ALGO_SHA256)) (*algorithms & PTS_MEAS_ALGO_SHA256))
@@ -65,11 +65,11 @@ bool pts_meas_probe_algorithms(pts_meas_algorithms_t *algorithms)
} }
if (!(*algorithms & PTS_MEAS_ALGO_SHA1)) if (!(*algorithms & PTS_MEAS_ALGO_SHA1))
{ {
DBG1(DBG_TNC, format2, "mandatory", hash_algorithm_names, HASH_SHA1); DBG1(DBG_PTS, format2, "mandatory", hash_algorithm_names, HASH_SHA1);
} }
if (!(*algorithms & PTS_MEAS_ALGO_SHA256)) if (!(*algorithms & PTS_MEAS_ALGO_SHA256))
{ {
DBG1(DBG_TNC, format2, "mandatory", hash_algorithm_names, HASH_SHA256); DBG1(DBG_PTS, format2, "mandatory", hash_algorithm_names, HASH_SHA256);
} }
return FALSE; return FALSE;
} }
+2
View File
@@ -30,6 +30,7 @@ ENUM(debug_names, DBG_DMN, DBG_LIB,
"TNC", "TNC",
"IMC", "IMC",
"IMV", "IMV",
"PTS",
"TLS", "TLS",
"LIB", "LIB",
); );
@@ -47,6 +48,7 @@ ENUM(debug_lower_names, DBG_DMN, DBG_LIB,
"tnc", "tnc",
"imc", "imc",
"imv", "imv",
"pts",
"tls", "tls",
"lib", "lib",
); );
+2
View File
@@ -56,6 +56,8 @@ enum debug_t {
DBG_IMC, DBG_IMC,
/** integrity measurement verifier */ /** integrity measurement verifier */
DBG_IMV, DBG_IMV,
/** platform trust service */
DBG_PTS,
/** libtls */ /** libtls */
DBG_TLS, DBG_TLS,
/** libstrongswan */ /** libstrongswan */
+1 -1
View File
@@ -389,7 +389,7 @@ static void exit_usage(char *error)
printf(" where: START and optional END define the clients source IP\n"); printf(" where: START and optional END define the clients source IP\n");
printf(" Set loglevel for a logging type:\n"); printf(" Set loglevel for a logging type:\n");
printf(" stroke loglevel TYPE LEVEL\n"); printf(" stroke loglevel TYPE LEVEL\n");
printf(" where: TYPE is any|dmn|mgr|ike|chd|job|cfg|knl|net|enc|lib\n"); printf(" where: TYPE is any|dmn|mgr|ike|chd|job|cfg|knl|net|enc|tnc|imc|imv|pts|tls|lib\n");
printf(" LEVEL is -1|0|1|2|3|4\n"); printf(" LEVEL is -1|0|1|2|3|4\n");
printf(" Show connection status:\n"); printf(" Show connection status:\n");
printf(" stroke status\n"); printf(" stroke status\n");