Merge branch 'debug-level-build'

This fixes the build with DEBUG_LEVEL < 4, which was broken when building
from the repository since --enable-warnings was made the default.

Although, most issues only occurred with the level reduced to 0/-1.  And
while removing debug statements at compile time completely is probably
not useful in production, there might be use cases in certain benchmarking
scenarios.  Also, with the recent changes to the controller there should
only rarely be a listener registered at a higher log level so the overhead
for those higher-level DBG statements is minimal.

Anyway, reducing the log level at compile time is a documented feature and
at least DEBUG_LEVEL=3 could be useful to prevent leaking sensitive
information via logs from the outset.  So we should make sure compilation
doesn't fail.
This commit is contained in:
Tobias Brunner
2023-05-16 13:05:33 +02:00
98 changed files with 400 additions and 327 deletions
+3
View File
@@ -45,6 +45,9 @@ jobs:
- test: coverage
- test: dist
- test: nm
- test: no-dbg
- test: no-dbg
compiler: clang
- test: fuzzing
compiler: clang
monolithic: yes
+4 -1
View File
@@ -221,7 +221,7 @@ wolfssl)
printf-builtin)
CONFIG="--with-printf-hooks=builtin"
;;
all|codeql|coverage|sonarcloud)
all|codeql|coverage|sonarcloud|no-dbg)
if [ "$TEST" = "sonarcloud" ]; then
if [ -z "$SONAR_PROJECT" -o -z "$SONAR_ORGANIZATION" -o -z "$SONAR_TOKEN" ]; then
echo "The SONAR_PROJECT, SONAR_ORGANIZATION and SONAR_TOKEN" \
@@ -233,6 +233,9 @@ all|codeql|coverage|sonarcloud)
# don't run tests, only analyze built code
TARGET=
fi
if [ "$TEST" = "no-dbg" ]; then
CFLAGS="$CFLAGS -DDEBUG_LEVEL=-1"
fi
CONFIG="--enable-all --disable-android-dns --disable-android-log
--disable-kernel-pfroute --disable-keychain
--disable-lock-profiler --disable-padlock --disable-fuzzing
+3 -2
View File
@@ -48,12 +48,13 @@ METHOD(listener_t, message, bool,
if (payload->get_type(payload) == PLV2_NOTIFY)
{
notify_payload_t *notify = (notify_payload_t*)payload;
chunk_t data;
if (notify->get_notify_type(notify) == COOKIE)
{
data = notify->get_notification_data(notify);
#if DEBUG_LEVEL >= 1
chunk_t data = notify->get_notification_data(notify);
DBG1(DBG_CFG, "received COOKIE: %#B", &data);
#endif
has_cookie = TRUE;
break;
}
+4
View File
@@ -35,6 +35,7 @@ METHOD(listener_t, message, bool,
private_log_id_t *this, ike_sa_t *ike_sa, message_t *message,
bool incoming, bool plain)
{
#if DEBUG_LEVEL >= 1
if (incoming && plain)
{
enumerator_t *enumerator;
@@ -62,6 +63,9 @@ METHOD(listener_t, message, bool,
enumerator->destroy(enumerator);
}
return TRUE;
#else
return FALSE;
#endif
}
METHOD(hook_t, destroy, void,
+4
View File
@@ -35,6 +35,7 @@ METHOD(listener_t, message, bool,
private_log_ke_t *this, ike_sa_t *ike_sa, message_t *message,
bool incoming, bool plain)
{
#if DEBUG_LEVEL >= 1
if (incoming && plain)
{
enumerator_t *enumerator;
@@ -54,6 +55,9 @@ METHOD(listener_t, message, bool,
enumerator->destroy(enumerator);
}
return TRUE;
#else
return FALSE;
#endif
}
METHOD(hook_t, destroy, void,
+4
View File
@@ -35,6 +35,7 @@ METHOD(listener_t, message, bool,
private_log_ts_t *this, ike_sa_t *ike_sa, message_t *message,
bool incoming, bool plain)
{
#if DEBUG_LEVEL >= 1
if (incoming && plain)
{
enumerator_t *enumerator;
@@ -77,6 +78,9 @@ METHOD(listener_t, message, bool,
enumerator->destroy(enumerator);
}
return TRUE;
#else
return FALSE;
#endif
}
METHOD(hook_t, destroy, void,
+13 -16
View File
@@ -196,7 +196,6 @@ static linked_list_t *get_matching_ike_cfgs(private_backend_manager_t *this,
ike_version_t version)
{
ike_cfg_t *current;
char *my_addr, *other_addr;
enumerator_t *enumerator;
ike_data_t *data;
linked_list_t *configs;
@@ -218,8 +217,10 @@ static linked_list_t *get_matching_ike_cfgs(private_backend_manager_t *this,
while (enumerator->enumerate(enumerator, &current))
{
my_addr = current->get_my_addr(current);
other_addr = current->get_other_addr(current);
#if DEBUG_LEVEL >= 2
char *my_addr = current->get_my_addr(current);
char *other_addr = current->get_other_addr(current);
#endif
match = get_ike_match(current, me, other, version);
DBG3(DBG_CFG, "ike config match: %d (%s...%s %N)", match, my_addr,
other_addr, ike_version_names, current->get_version(current));
@@ -249,7 +250,6 @@ METHOD(backend_manager_t, get_ike_cfg, ike_cfg_t*,
linked_list_t *configs;
ike_match_entry_t *entry;
ike_cfg_t *found = NULL;
char *my_addr, *other_addr;
DBG2(DBG_CFG, "looking for an %N config for %H...%H", ike_version_names,
version, me, other);
@@ -258,11 +258,9 @@ METHOD(backend_manager_t, get_ike_cfg, ike_cfg_t*,
if (configs->get_first(configs, (void**)&entry) == SUCCESS)
{
found = entry->cfg->get_ref(entry->cfg);
my_addr = found->get_my_addr(found);
other_addr = found->get_other_addr(found);
DBG2(DBG_CFG, "found matching ike config: %s...%s with prio %d",
my_addr, other_addr, entry->match);
found->get_my_addr(found), found->get_other_addr(found),
entry->match);
}
ike_match_entry_list_destroy(configs);
@@ -295,8 +293,7 @@ static id_match_t get_peer_match(identification_t *id,
auth_cfg_t *auth;
identification_t *candidate;
id_match_t match = ID_MATCH_NONE;
char *where = local ? "local" : "remote";
chunk_t data;
char *where DBG_UNUSED = local ? "local" : "remote";
if (!id)
{
@@ -326,9 +323,11 @@ static id_match_t get_peer_match(identification_t *id,
}
enumerator->destroy(enumerator);
data = id->get_encoding(id);
#if DEBUG_LEVEL >= 3
chunk_t data = id->get_encoding(id);
DBG3(DBG_CFG, " %s id match: %d (%N: %#B)",
where, match, id_type_names, id->get_type(id), &data);
#endif
return match;
}
@@ -452,14 +451,12 @@ METHOD(backend_manager_t, create_peer_cfg_enumerator, enumerator_t*,
ike_cfg_match_t match_ike;
id_match_t match_peer_me, match_peer_other;
match_entry_t *entry;
char *my_addr, *other_addr;
match_ike = get_ike_match(ike_cfg, me, other, version);
my_addr = ike_cfg->get_my_addr(ike_cfg);
other_addr = ike_cfg->get_other_addr(ike_cfg);
DBG3(DBG_CFG, "peer config \"%s\", ike match: %d (%s...%s %N)",
cfg->get_name(cfg), match_ike, my_addr, other_addr,
ike_version_names, ike_cfg->get_version(ike_cfg));
cfg->get_name(cfg), match_ike, ike_cfg->get_my_addr(ike_cfg),
ike_cfg->get_other_addr(ike_cfg), ike_version_names,
ike_cfg->get_version(ike_cfg));
if (!match_ike)
{
+8 -9
View File
@@ -442,21 +442,20 @@ METHOD(generator_t, get_chunk, chunk_t,
METHOD(generator_t, generate_payload, void,
private_generator_t *this, payload_t *payload)
{
int i, offset_start, rule_count;
int i, rule_count;
encoding_rule_t *rules;
payload_type_t payload_type;
this->data_struct = payload;
payload_type = payload->get_type(payload);
offset_start = this->out_position - this->buffer;
#if DEBUG_LEVEL >= 2
int offset_start = this->out_position - this->buffer;
#endif
if (this->debug)
{
DBG2(DBG_ENC, "generating payload of type %N",
payload_type_names, payload_type);
payload_type_names, payload->get_type(payload));
}
this->data_struct = payload;
/* each payload has its own encoding rules */
rule_count = payload->get_encoding_rules(payload, &rules);
@@ -559,7 +558,7 @@ METHOD(generator_t, generate_payload, void,
if (this->debug)
{
DBG2(DBG_ENC, "generating %N payload finished",
payload_type_names, payload_type);
payload_type_names, payload->get_type(payload));
DBG3(DBG_ENC, "generated data for this payload %b",
this->buffer + offset_start,
(u_int)(this->out_position - this->buffer - offset_start));
+12 -4
View File
@@ -1270,6 +1270,7 @@ METHOD(message_t, get_notify, notify_payload_t*,
return notify;
}
#if DEBUG_LEVEL >= 1
/**
* get a string representation of the message
*/
@@ -1472,6 +1473,7 @@ static char* get_string(private_message_t *this, char *buf, int len)
snprintf(pos, len, " ]");
return buf;
}
#endif
METHOD(message_t, disable_sort, void,
private_message_t *this)
@@ -1668,7 +1670,6 @@ static status_t generate_message(private_message_t *this, keymat_t *keymat,
enumerator_t *enumerator;
aead_t *aead = NULL;
chunk_t hash = chunk_empty;
char str[BUF_LEN];
ike_header_t *ike_header;
payload_t *payload, *next;
bool encrypting = FALSE;
@@ -1739,7 +1740,10 @@ static status_t generate_message(private_message_t *this, keymat_t *keymat,
enumerator->destroy(enumerator);
}
#if DEBUG_LEVEL >= 1
char str[BUF_LEN];
DBG1(DBG_ENC, "generating %s", get_string(this, str, sizeof(str)));
#endif
if (keymat)
{
@@ -2627,7 +2631,6 @@ METHOD(message_t, parse_body, status_t,
private_message_t *this, keymat_t *keymat)
{
status_t status = SUCCESS;
char str[BUF_LEN];
DBG2(DBG_ENC, "parsing body of message, first payload is %N",
payload_type_names, this->first_payload);
@@ -2665,7 +2668,10 @@ METHOD(message_t, parse_body, status_t,
return status;
}
#if DEBUG_LEVEL >= 1
char str[BUF_LEN];
DBG1(DBG_ENC, "parsed %s", get_string(this, str, sizeof(str)));
#endif
if (keymat && keymat->get_version(keymat) == IKEV1)
{
@@ -2856,7 +2862,6 @@ METHOD(message_t, add_fragment_v2, status_t,
enumerator_t *enumerator;
chunk_t data;
uint16_t total, num;
size_t len;
status_t status;
if (!this->frag)
@@ -2938,7 +2943,8 @@ METHOD(message_t, add_fragment_v2, status_t,
/* we report the length of the complete IKE message when splitting, do the
* same here, so add the IKEv2 header len to the reassembled payload data */
len = 28;
#if DEBUG_LEVEL >= 1
size_t len = 28;
enumerator = create_payload_enumerator(this);
while (enumerator->enumerate(enumerator, &payload))
{
@@ -2948,6 +2954,8 @@ METHOD(message_t, add_fragment_v2, status_t,
DBG1(DBG_ENC, "received fragment #%hu of %hu, reassembled fragmented IKE "
"message (%zu bytes)", num, total, len);
#endif /* DEBUG_LEVEL */
return SUCCESS;
}
+3 -2
View File
@@ -304,13 +304,14 @@ static bool discover(private_dhcp_socket_t *this,
{
dhcp_option_t *option;
dhcp_t dhcp;
chunk_t mac;
int optlen;
optlen = prepare_dhcp(this, transaction, DHCP_DISCOVER, &dhcp);
mac = chunk_from_thing(dhcp.client_hw_addr);
#if DEBUG_LEVEL >= 1
chunk_t mac = chunk_from_thing(dhcp.client_hw_addr);
DBG1(DBG_CFG, "sending DHCP DISCOVER for %#B to %H", &mac, this->dst);
#endif
option = (dhcp_option_t*)&dhcp.options[optlen];
option->type = DHCP_PARAM_REQ_LIST;
@@ -118,7 +118,7 @@ static void select_method(private_eap_dynamic_t *this)
{
eap_vendor_type_t *entry;
linked_list_t *outer = this->types, *inner = this->other_types;
char *who = "peer";
char *who DBG_UNUSED = "peer";
if (this->other_types && this->prefer_peer)
{
@@ -661,6 +661,7 @@ static chunk_t utf8_to_utf16le(chunk_t utf8)
return utf16;
}
#if DEBUG_LEVEL >= 1
/**
* sanitize a string for printing
*/
@@ -678,6 +679,7 @@ static char* sanitize(char *str)
}
return str;
}
#endif /* DEBUG_LEVEL */
/**
* Returns a chunk of just the username part of the given user identity.
@@ -966,7 +968,7 @@ static status_t process_peer_failure(private_eap_mschapv2_t *this,
eap_mschapv2_header_t *eap;
chunk_t data;
char *message, *token, *msg = NULL;
int message_len, error = 0;
int message_len, error DBG_UNUSED = 0;
chunk_t challenge = chunk_empty;
data = in->get_data(in);
@@ -191,7 +191,7 @@ METHOD(tls_application_t, build, status_t,
{
chunk_t data;
eap_code_t code;
eap_type_t type;
eap_type_t type DBG_UNUSED;
pen_t vendor;
if (this->out)
@@ -343,7 +343,7 @@ METHOD(tls_application_t, build, status_t,
{
chunk_t data;
eap_code_t code;
eap_type_t type;
eap_type_t type DBG_UNUSED;
pen_t vendor;
if (!this->ph2_method && this->start_phase2 &&
@@ -334,7 +334,7 @@ static void process_filter_id(radius_message_t *msg)
{
enumerator_t *enumerator;
int type;
uint8_t tunnel_tag;
uint8_t tunnel_tag DBG_UNUSED;
uint32_t tunnel_type;
chunk_t filter_id = chunk_empty, data;
bool is_esp_tunnel = FALSE;
@@ -79,7 +79,7 @@ METHOD(tls_application_t, process, status_t,
pen_t vendor, received_vendor;
uint16_t eap_len;
size_t eap_pos = 0;
bool concatenated = FALSE;
bool concatenated DBG_UNUSED = FALSE;
do
{
@@ -239,9 +239,6 @@ METHOD(tls_application_t, build, status_t,
private_eap_ttls_peer_t *this, bio_writer_t *writer)
{
chunk_t data;
eap_code_t code;
eap_type_t type;
pen_t vendor;
if (this->method == NULL && this->start_phase2)
{
@@ -261,11 +258,13 @@ METHOD(tls_application_t, build, status_t,
if (this->out)
{
code = this->out->get_code(this->out);
type = this->out->get_type(this->out, &vendor);
#if DEBUG_LEVEL >= 1
pen_t vendor;
eap_code_t code = this->out->get_code(this->out);
eap_type_t type = this->out->get_type(this->out, &vendor);
DBG1(DBG_IKE, "sending tunneled EAP-TTLS AVP [EAP/%N/%N]",
eap_code_short_names, code, eap_type_short_names, type);
eap_code_short_names, code, eap_type_short_names, type);
#endif
/* get the raw EAP message data */
data = this->out->get_data(this->out);
this->avp->build(this->avp, writer, data);
@@ -308,9 +308,6 @@ METHOD(tls_application_t, build, status_t,
private_eap_ttls_server_t *this, bio_writer_t *writer)
{
chunk_t data;
eap_code_t code;
eap_type_t type;
pen_t vendor;
if (this->method == NULL && this->start_phase2 &&
lib->settings->get_bool(lib->settings,
@@ -333,10 +330,13 @@ METHOD(tls_application_t, build, status_t,
if (this->out)
{
code = this->out->get_code(this->out);
type = this->out->get_type(this->out, &vendor);
#if DEBUG_LEVEL >= 1
pen_t vendor;
eap_code_t code = this->out->get_code(this->out);
eap_type_t type = this->out->get_type(this->out, &vendor);
DBG1(DBG_IKE, "sending tunneled EAP-TTLS AVP [EAP/%N/%N]",
eap_code_short_names, code, eap_type_short_names, type);
eap_code_short_names, code, eap_type_short_names, type);
#endif
/* get the raw EAP message data */
data = this->out->get_data(this->out);
@@ -162,7 +162,7 @@ CALLBACK(receive_casts, bool,
struct iphdr hdr;
char data[2048];
} buf;
char *type;
char *type DBG_UNUSED;
ssize_t len;
u_int mark, origin = 0;
host_t *src, *dst;
+4 -1
View File
@@ -60,7 +60,6 @@ METHOD(listener_t, child_keys, bool,
linked_list_t *local_ts, *remote_ts;
enumerator_t *enumerator;
traffic_selector_t *ts;
u_int seg_i, seg_o;
if (this->tunnel && this->tunnel->is_sa(this->tunnel, ike_sa))
{ /* do not sync SA between nodes */
@@ -127,6 +126,9 @@ METHOD(listener_t, child_keys, bool,
}
enumerator->destroy(enumerator);
#if DEBUG_LEVEL >= 1
u_int seg_i, seg_o;
seg_i = this->kernel->get_segment_spi(this->kernel,
ike_sa->get_my_host(ike_sa), child_sa->get_spi(child_sa, TRUE));
seg_o = this->kernel->get_segment_spi(this->kernel,
@@ -136,6 +138,7 @@ METHOD(listener_t, child_keys, bool,
child_sa->get_unique_id(child_sa), local_ts, remote_ts,
seg_i, this->segments->is_active(this->segments, seg_i) ? "*" : "",
seg_o, this->segments->is_active(this->segments, seg_o) ? "*" : "");
#endif /* DEBUG_LEVEL */
local_ts->destroy(local_ts);
remote_ts->destroy(remote_ts);
+5 -2
View File
@@ -658,7 +658,6 @@ static void process_child_add(private_ha_dispatcher_t *this,
uint8_t mode = MODE_TUNNEL, ipcomp = 0;
uint16_t encr = 0, integ = 0, len = 0, dh_grp = 0;
uint16_t esn = NO_EXT_SEQ_NUMBERS;
u_int seg_i, seg_o;
chunk_t nonce_i = chunk_empty, nonce_r = chunk_empty, secret = chunk_empty;
chunk_t encr_i, integ_i, encr_r, integ_r;
linked_list_t *local_ts, *remote_ts;
@@ -858,16 +857,20 @@ static void process_child_add(private_ha_dispatcher_t *this,
return;
}
#if DEBUG_LEVEL >= 1
u_int seg_i, seg_o;
seg_i = this->kernel->get_segment_spi(this->kernel,
ike_sa->get_my_host(ike_sa), inbound_spi);
seg_o = this->kernel->get_segment_spi(this->kernel,
ike_sa->get_other_host(ike_sa), outbound_spi);
DBG1(DBG_CFG, "installed HA CHILD_SA %s{%d} %#R === %#R "
"(segment in: %d%s, out: %d%s)", child_sa->get_name(child_sa),
child_sa->get_unique_id(child_sa), local_ts, remote_ts,
seg_i, this->segments->is_active(this->segments, seg_i) ? "*" : "",
seg_o, this->segments->is_active(this->segments, seg_o) ? "*" : "");
#endif /* DEBUG_LEVEL */
child_sa->install_policies(child_sa);
local_ts->destroy_offset(local_ts, offsetof(traffic_selector_t, destroy));
remote_ts->destroy_offset(remote_ts, offsetof(traffic_selector_t, destroy));
@@ -3067,8 +3067,8 @@ METHOD(kernel_ipsec_t, add_policy, status_t,
enumerator_t *enumerator;
bool found = FALSE, update = TRUE;
char markstr[32] = "", labelstr[128] = "";
uint32_t cur_priority = 0;
int use_count;
uint32_t cur_priority DBG_UNUSED = 0;
int use_count DBG_UNUSED;
/* create a policy */
INIT(policy,
@@ -3286,7 +3286,7 @@ METHOD(kernel_ipsec_t, del_policy, status_t,
struct nlmsghdr *hdr;
struct xfrm_userpolicy_id *policy_id;
bool is_installed = TRUE;
uint32_t priority, auto_priority, cur_priority;
uint32_t priority, auto_priority, cur_priority DBG_UNUSED;
ipsec_sa_t assigned_sa = {
.src = data->src,
.dst = data->dst,
@@ -60,7 +60,7 @@ struct private_radattr_listener_t {
static void print_radius_attributes(private_radattr_listener_t *this,
message_t *message)
{
radius_attribute_type_t type;
radius_attribute_type_t type DBG_UNUSED;
enumerator_t *enumerator;
notify_payload_t *notify;
payload_t *payload;
@@ -420,7 +420,7 @@ save_keys_listener_t *save_keys_listener_create()
if (this->path && (this->ike || this->esp))
{
char *keys = "IKE";
char *keys DBG_UNUSED = "IKE";
if (this->ike && this->esp)
{
@@ -92,13 +92,14 @@ static bool equals(const void *a_pub, const void *b)
static bool install_generic_trap(ike_sa_t *ike_sa, child_sa_t *child_sa)
{
linked_list_t *local, *remote;
sec_label_t *label;
bool success;
label = child_sa->get_label(child_sa);
#if DEBUG_LEVEL >= 1
sec_label_t *label = child_sa->get_label(child_sa);
DBG1(DBG_IKE, "installing trap %s{%d} with generic security label '%s'",
child_sa->get_name(child_sa), child_sa->get_unique_id(child_sa),
label->get_string(label));
#endif
local = ike_sa_get_dynamic_hosts(ike_sa, TRUE);
remote = ike_sa_get_dynamic_hosts(ike_sa, FALSE);
@@ -169,12 +170,13 @@ METHOD(listener_t, ike_updown, bool,
{
while (array_remove(entry->traps, ARRAY_TAIL, &child_sa))
{
#if DEBUG_LEVEL >= 1
sec_label_t *label = child_sa->get_label(child_sa);
DBG1(DBG_IKE, "uninstalling trap %s{%d} with generic security "
"label '%s'", child_sa->get_name(child_sa),
child_sa->get_unique_id(child_sa),
label->get_string(label));
#endif
charon->traps->remove_external(charon->traps, child_sa);
child_sa->destroy(child_sa);
}
@@ -145,7 +145,7 @@ static job_requeue_t check_systime(private_systime_fix_plugin_t *this)
{
enumerator_t *enumerator;
ike_sa_t *ike_sa;
char *action;
char *action DBG_UNUSED;
job_t *job;
if (time(NULL) < this->threshold)
@@ -204,7 +204,7 @@ static bool load_validator(private_systime_fix_plugin_t *this)
struct tm tm = {
.tm_mday = 1,
};
char *str, *fmt, buf[32];
char *str, *fmt;
fmt = lib->settings->get_str(lib->settings,
"%s.plugins.%s.threshold_format", "%Y", lib->ns, get_name(this));
@@ -234,8 +234,11 @@ static bool load_validator(private_systime_fix_plugin_t *this)
return FALSE;
}
#if DEBUG_LEVEL >= 1
char buf[32];
DBG1(DBG_CFG, "enabling %s, threshold: %s", get_name(this),
asctime_r(&tm, buf));
#endif
this->validator = systime_fix_validator_create(this->threshold);
return TRUE;
}
@@ -54,13 +54,10 @@ METHOD(job_t, destroy, void,
METHOD(job_t, execute, job_requeue_t,
private_tnc_ifmap_renew_session_job_t *this)
{
char *session_id;
if (this->ifmap->orphaned(this->ifmap))
{
session_id = this->ifmap->get_session_id(this->ifmap);
DBG2(DBG_TNC, "removing orphaned ifmap renewSession job for '%s'",
session_id);
this->ifmap->get_session_id(this->ifmap));
return JOB_REQUEUE_NONE;
}
else
+2 -3
View File
@@ -429,12 +429,11 @@ CALLBACK(authority_li, bool,
static void log_authority_data(authority_t *authority)
{
enumerator_t *enumerator;
identification_t *subject;
bool first = TRUE;
char *uri;
subject = authority->cert->get_subject(authority->cert);
DBG2(DBG_CFG, " cacert = %Y", subject);
DBG2(DBG_CFG, " cacert = %Y",
authority->cert->get_subject(authority->cert));
enumerator = authority->crl_uris->create_enumerator(authority->crl_uris);
while (enumerator->enumerate(enumerator, &uri))
+1 -1
View File
@@ -520,7 +520,7 @@ typedef struct {
*/
static void log_child_data(child_data_t *data, char *name)
{
child_cfg_create_t *cfg = &data->cfg;
child_cfg_create_t *cfg DBG_UNUSED = &data->cfg;
#define has_opt(opt) ({ (cfg->options & (opt)) == (opt); })
DBG2(DBG_CFG, " child %s:", name);
+7 -9
View File
@@ -1541,19 +1541,17 @@ METHOD(ike_sa_t, initiate, status_t,
#endif /* ME */
)
{
char *addr;
addr = this->ike_cfg->get_other_addr(this->ike_cfg);
if (!this->retry_initiate_interval)
{
DBG1(DBG_IKE, "unable to resolve %s, initiate aborted",
addr);
this->ike_cfg->get_other_addr(this->ike_cfg));
DESTROY_IF(child_cfg);
charon->bus->alert(charon->bus, ALERT_PEER_ADDR_FAILED);
return DESTROY_ME;
}
DBG1(DBG_IKE, "unable to resolve %s, retrying in %ds",
addr, this->retry_initiate_interval);
this->ike_cfg->get_other_addr(this->ike_cfg),
this->retry_initiate_interval);
defer_initiate = TRUE;
}
@@ -1965,13 +1963,13 @@ METHOD(ike_sa_t, reauth, status_t,
if (!has_condition(this, COND_ORIGINAL_INITIATOR) &&
!ike_sa_can_reauthenticate(&this->public))
{
time_t del, now;
del = this->stats[STAT_DELETE];
now = time_monotonic(NULL);
#if DEBUG_LEVEL >= 1
time_t del = this->stats[STAT_DELETE];
time_t now = time_monotonic(NULL);
DBG1(DBG_IKE, "initiator did not reauthenticate as requested, IKE_SA "
"%s[%d] will timeout in %V", get_name(this), this->unique_id,
&now, &del);
#endif
return FAILED;
}
DBG0(DBG_IKE, "reauthenticating IKE_SA %s[%d]",
+1 -1
View File
@@ -799,7 +799,7 @@ METHOD(keymat_v1_t, get_hash_phase2, bool,
uint32_t mid, mid_n;
chunk_t data = chunk_empty, *n_i, *n_r;
bool add_message = TRUE;
char *name = "Hash";
char *name DBG_UNUSED = "Hash";
if (!this->prf)
{ /* no keys derived yet */
+2 -2
View File
@@ -335,7 +335,7 @@ static status_t build_set(private_mode_config_t *this, message_t *message)
chunk_t value;
cp_payload_t *cp;
peer_cfg_t *config;
identification_t *id;
identification_t *id DBG_UNUSED;
linked_list_t *pools, *migrated, *vips;
host_t *any4, *any6, *found;
char *name;
@@ -491,7 +491,7 @@ static status_t build_reply(private_mode_config_t *this, message_t *message)
chunk_t value;
cp_payload_t *cp;
peer_cfg_t *config;
identification_t *id;
identification_t *id DBG_UNUSED;
linked_list_t *vips, *pools, *migrated;
host_t *requested, *found;
@@ -156,7 +156,7 @@ static eap_payload_t* server_initiate_eap(private_eap_authenticator_t *this,
identification_t *id;
pen_t vendor;
eap_payload_t *out;
char *action;
char *action DBG_UNUSED;
auth = this->ike_sa->get_auth_cfg(this->ike_sa, FALSE);
@@ -641,11 +641,12 @@ METHOD(authenticator_t, process_client, status_t,
}
if (this->require_mutual && !this->method->is_mutual(this->method))
{ /* we require mutual authentication due to EAP-only */
#if DEBUG_LEVEL >= 1
pen_t vendor;
DBG1(DBG_IKE, "EAP-only authentication requires a mutual and "
"MSK deriving EAP method, but %N is not",
eap_type_names, this->method->get_type(this->method, &vendor));
#endif
return FAILED;
}
return SUCCESS;
@@ -371,11 +371,13 @@ static status_t sign_signature_auth(private_pubkey_authenticator_t *this,
{
if (params->scheme == SIGN_RSA_EMSA_PSS)
{
#if DEBUG_LEVEL >= 1
rsa_pss_params_t *pss = params->params;
DBG1(DBG_IKE, "authentication of '%Y' (myself) with %N_%N_SALT_%zd "
"%s", id, signature_scheme_names, params->scheme,
hash_algorithm_short_names_upper, pss->hash, pss->salt_len,
status == SUCCESS ? "successful" : "failed");
#endif
}
else
{
@@ -573,7 +575,7 @@ METHOD(authenticator_t, process, status_t,
key_type_t key_type = KEY_ECDSA;
signature_params_t *params;
status_t status = NOT_FOUND;
const char *reason = "unsupported";
const char *reason DBG_UNUSED = "unsupported";
bool online;
auth_payload = (auth_payload_t*)message->get_payload(message, PLV2_AUTH);
@@ -647,10 +649,12 @@ METHOD(authenticator_t, process, status_t,
}
else if (params->scheme == SIGN_RSA_EMSA_PSS)
{
#if DEBUG_LEVEL >= 1
rsa_pss_params_t *pss = params->params;
DBG1(DBG_IKE, "authentication of '%Y' with %N_%N_SALT_%zd "
"successful", id, signature_scheme_names, params->scheme,
hash_algorithm_short_names_upper, pss->hash, pss->salt_len);
#endif
}
else
{
+8 -5
View File
@@ -495,7 +495,6 @@ static status_t select_and_install(private_child_create_t *this,
bool no_dh, bool ike_auth)
{
status_t status, status_i, status_o;
child_sa_outbound_state_t out_state;
chunk_t nonce_i, nonce_r;
chunk_t encr_i = chunk_empty, encr_r = chunk_empty;
chunk_t integ_i = chunk_empty, integ_r = chunk_empty;
@@ -779,11 +778,14 @@ static status_t select_and_install(private_child_create_t *this,
charon->bus->child_keys(charon->bus, this->child_sa, this->initiator,
this->dh, nonce_i, nonce_r);
#if DEBUG_LEVEL >= 0
child_sa_outbound_state_t out_state;
out_state = this->child_sa->get_outbound_state(this->child_sa);
my_ts = linked_list_create_from_enumerator(
this->child_sa->create_ts_enumerator(this->child_sa, TRUE));
other_ts = linked_list_create_from_enumerator(
this->child_sa->create_ts_enumerator(this->child_sa, FALSE));
out_state = this->child_sa->get_outbound_state(this->child_sa);
DBG0(DBG_IKE, "%sCHILD_SA %s{%d} established "
"with SPIs %.8x_i %.8x_o and TS %#R === %#R",
@@ -796,6 +798,7 @@ static status_t select_and_install(private_child_create_t *this,
my_ts->destroy(my_ts);
other_ts->destroy(other_ts);
#endif
this->child_sa->set_state(this->child_sa, CHILD_INSTALLED);
this->ike_sa->add_child_sa(this->ike_sa, this->child_sa);
@@ -1129,13 +1132,13 @@ static bool check_for_generic_label(private_child_create_t *this)
{
if (generic_label_only(this))
{
sec_label_t *label;
label = this->config->get_label(this->config);
#if DEBUG_LEVEL >= 1
sec_label_t *label = this->config->get_label(this->config);
DBG1(DBG_IKE, "not establishing CHILD_SA %s{%d} with generic "
"label '%s'", this->child_sa->get_name(this->child_sa),
this->child_sa->get_unique_id(this->child_sa),
label->get_string(label));
#endif
return TRUE;
}
return FALSE;
+1 -1
View File
@@ -353,7 +353,7 @@ METHOD(task_t, build_r, status_t,
chunk_t value;
cp_payload_t *cp = NULL;
peer_cfg_t *config;
identification_t *id;
identification_t *id DBG_UNUSED;
linked_list_t *vips, *pools;
host_t *requested;
+1 -1
View File
@@ -1035,7 +1035,7 @@ METHOD(task_t, process_i, status_t,
case INVALID_KE_PAYLOAD:
{
chunk_t data;
key_exchange_method_t bad_group;
key_exchange_method_t bad_group DBG_UNUSED;
bad_group = this->dh_group;
data = notify->get_notification_data(notify);
+1 -1
View File
@@ -121,7 +121,7 @@ METHOD(pa_tnc_attr_t, build, void,
METHOD(pa_tnc_attr_t, process, status_t,
private_generic_attr_bool_t *this, uint32_t *offset)
{
enum_name_t *pa_attr_names;
enum_name_t *pa_attr_names DBG_UNUSED;
bio_reader_t *reader;
uint32_t status;
+1 -1
View File
@@ -96,7 +96,7 @@ METHOD(pa_tnc_attr_t, build, void,
METHOD(pa_tnc_attr_t, process, status_t,
private_generic_attr_chunk_t *this, uint32_t *offset)
{
enum_name_t *pa_attr_names;
enum_name_t *pa_attr_names DBG_UNUSED;
*offset = 0;
if (this->value.len < this->length)
+1 -1
View File
@@ -91,7 +91,7 @@ METHOD(pa_tnc_attr_t, build, void,
METHOD(pa_tnc_attr_t, process, status_t,
private_generic_attr_string_t *this, uint32_t *offset)
{
enum_name_t *pa_attr_names;
enum_name_t *pa_attr_names DBG_UNUSED;
u_char *pos;
*offset = 0;
+1 -1
View File
@@ -346,7 +346,7 @@ METHOD(imc_agent_t, create_state, TNC_Result,
{
TNC_ConnectionID conn_id;
char *tnccs_p = NULL, *tnccs_v = NULL, *t_p = NULL, *t_v = NULL;
bool has_long = FALSE, has_excl = FALSE, has_soh = FALSE;
bool has_long = FALSE, has_excl = FALSE, has_soh DBG_UNUSED = FALSE;
uint32_t max_msg_len;
conn_id = state->get_connection_id(state);
+4 -3
View File
@@ -254,7 +254,6 @@ METHOD(imc_msg_t, receive, TNC_Result,
enumerator_t *enumerator;
pa_tnc_attr_t *attr;
pen_type_t attr_type;
chunk_t msg;
bool first = TRUE;
if (this->state->has_long(this->state))
@@ -282,8 +281,10 @@ METHOD(imc_msg_t, receive, TNC_Result,
this->agent->get_name(this->agent),
this->connection_id);
}
msg = this->pa_msg->get_encoding(this->pa_msg);
#if DEBUG_LEVEL >= 3
chunk_t msg = this->pa_msg->get_encoding(this->pa_msg);
DBG3(DBG_IMC, "%B", &msg);
#endif
switch (this->pa_msg->process(this->pa_msg))
{
@@ -522,7 +523,7 @@ METHOD(imc_msg_t, receive, TNC_Result,
{
ietf_attr_remediation_instr_t *attr_cast;
pen_type_t parameters_type;
chunk_t parameters, string, lang_code;
chunk_t parameters DBG_UNUSED, string DBG_UNUSED, lang_code;
attr_cast = (ietf_attr_remediation_instr_t*)attr;
parameters_type = attr_cast->get_parameters_type(attr_cast);
+1 -1
View File
@@ -413,7 +413,7 @@ METHOD(imv_agent_t, create_state, TNC_Result,
{
TNC_ConnectionID conn_id;
char *tnccs_p = NULL, *tnccs_v = NULL, *t_p = NULL, *t_v = NULL;
bool has_long = FALSE, has_excl = FALSE, has_soh = FALSE;
bool has_long = FALSE, has_excl = FALSE, has_soh DBG_UNUSED = FALSE;
linked_list_t *ar_identities;
imv_session_t *session;
uint32_t max_msg_len;
+3 -2
View File
@@ -293,7 +293,6 @@ METHOD(imv_msg_t, receive, TNC_Result,
linked_list_t *non_fatal_types;
enumerator_t *enumerator;
pa_tnc_attr_t *attr;
chunk_t msg;
if (this->state->has_long(this->state))
{
@@ -320,8 +319,10 @@ METHOD(imv_msg_t, receive, TNC_Result,
this->agent->get_name(this->agent),
this->connection_id);
}
msg = this->pa_msg->get_encoding(this->pa_msg);
#if DEBUG_LEVEL >= 3
chunk_t msg = this->pa_msg->get_encoding(this->pa_msg);
DBG3(DBG_IMV, "%B", &msg);
#endif
switch (this->pa_msg->process(this->pa_msg))
{
+3 -1
View File
@@ -50,7 +50,6 @@ METHOD(imv_session_manager_t, add_session, imv_session_t*,
linked_list_t *ar_identities)
{
enumerator_t *enumerator;
tncif_identity_t *tnc_id;
imv_session_t *current, *session = NULL;
this->mutex->lock(this->mutex);
@@ -77,6 +76,8 @@ METHOD(imv_session_manager_t, add_session, imv_session_t*,
}
/* Output list of Access Requestor identities */
#if DEBUG_LEVEL >= 2
tncif_identity_t *tnc_id;
enumerator = ar_identities->create_enumerator(ar_identities);
while (enumerator->enumerate(enumerator, &tnc_id))
{
@@ -103,6 +104,7 @@ METHOD(imv_session_manager_t, add_session, imv_session_t*,
TNC_Authentication_names, tcg_auth_type);
}
enumerator->destroy(enumerator);
#endif /* DEBUG_LEVEL */
/* create a new session entry */
session = imv_session_create(conn_id, ar_identities);
+5 -6
View File
@@ -277,13 +277,10 @@ METHOD(pa_tnc_msg_t, process_ietf_std_errors, bool,
{
ietf_attr_pa_tnc_error_t *error_attr;
pen_type_t error_code, *non_fatal_type;
chunk_t msg_info;
uint32_t offset;
bool fatal_current_error = TRUE;
error_attr = (ietf_attr_pa_tnc_error_t*)attr;
error_code = error_attr->get_error_code(error_attr);
msg_info = error_attr->get_msg_info(error_attr);
/* skip errors from non-IETF namespaces and non PA-TNC msg errors */
if (error_code.vendor_id != PEN_IETF ||
@@ -291,15 +288,17 @@ METHOD(pa_tnc_msg_t, process_ietf_std_errors, bool,
{
continue;
}
#if DEBUG_LEVEL >= 1
chunk_t msg_info = error_attr->get_msg_info(error_attr);
DBG1(DBG_TNC, "received PA-TNC error '%N' concerning message "
"0x%08x/0x%08x", pa_tnc_error_code_names, error_code.type,
untoh32(msg_info.ptr), untoh32(msg_info.ptr + 4));
#endif
switch (error_code.type)
{
case PA_ERROR_INVALID_PARAMETER:
offset = error_attr->get_offset(error_attr);
DBG1(DBG_TNC, " occurred at offset of %u bytes", offset);
DBG1(DBG_TNC, " occurred at offset of %u bytes",
error_attr->get_offset(error_attr));
break;
case PA_ERROR_ATTR_TYPE_NOT_SUPPORTED:
unsupported_type =
@@ -174,19 +174,18 @@ static TNC_Result receive_message(imc_state_t *state, imc_msg_t *in_msg)
{
ietf_attr_pa_tnc_error_t *error_attr;
pen_type_t error_code;
chunk_t msg_info;
error_attr = (ietf_attr_pa_tnc_error_t*)attr;
error_code = error_attr->get_error_code(error_attr);
if (error_code.vendor_id == PEN_TCG)
{
msg_info = error_attr->get_msg_info(error_attr);
#if DEBUG_LEVEL >= 1
chunk_t msg_info = error_attr->get_msg_info(error_attr);
DBG1(DBG_IMC, "received TCG-PTS error '%N'",
pts_error_code_names, error_code.type);
DBG1(DBG_IMC, "error information: %B", &msg_info);
#endif /* DEBUG_LEVEL */
result = TNC_RESULT_FATAL;
}
}
+1 -1
View File
@@ -229,7 +229,7 @@ static void fulfill_request(imc_state_t *state, imc_msg_t *msg,
size_t msg_len = 64;
char error_msg[msg_len], *id_str;
bool collect_inventory = TRUE;
int items;
int items DBG_UNUSED;
collector = swima_collector_create();
id_str = sw_id_only ? " ID" : "";
+6 -6
View File
@@ -293,19 +293,19 @@ static TNC_Result receive_message(imc_state_t *state, imc_msg_t *in_msg)
}
if (attr_type.type == ITA_ATTR_COMMAND)
{
ita_attr_command_t *ita_attr;
ita_attr = (ita_attr_command_t*)attr;
#if DEBUG_LEVEL >= 1
ita_attr_command_t *ita_attr = (ita_attr_command_t*)attr;
DBG1(DBG_IMC, "received command '%s'",
ita_attr->get_command(ita_attr));
#endif
}
else if (attr_type.type == ITA_ATTR_DUMMY)
{
ita_attr_dummy_t *ita_attr;
ita_attr = (ita_attr_dummy_t*)attr;
#if DEBUG_LEVEL >= 1
ita_attr_dummy_t *ita_attr = (ita_attr_dummy_t*)attr;
DBG1(DBG_IMC, "received dummy attribute value (%d bytes)",
ita_attr->get_size(ita_attr));
#endif
}
}
enumerator->destroy(enumerator);
@@ -206,19 +206,18 @@ static TNC_Result receive_msg(private_imv_attestation_agent_t *this,
{
ietf_attr_pa_tnc_error_t *error_attr;
pen_type_t error_code;
chunk_t msg_info;
error_attr = (ietf_attr_pa_tnc_error_t*)attr;
error_code = error_attr->get_error_code(error_attr);
if (error_code.vendor_id == PEN_TCG)
{
msg_info = error_attr->get_msg_info(error_attr);
#if DEBUG_LEVEL >= 1
chunk_t msg_info = error_attr->get_msg_info(error_attr);
DBG1(DBG_IMV, "received TCG-PTS error '%N'",
pts_error_code_names, error_code.type);
DBG1(DBG_IMV, "error information: %B", &msg_info);
#endif /* DEBUG_LEVEL */
/* TPM 2.0 doesn't return TPM Version Information */
if (error_code.type != TCG_PTS_TPM_VERS_NOT_SUPPORTED)
{
@@ -228,7 +228,7 @@ bool imv_attestation_process(pa_tnc_attr_t *attr, imv_msg_t *out_msg,
TNC_IMV_Action_Recommendation rec;
tcg_pts_attr_file_meas_t *attr_cast;
uint16_t request_id;
int arg_int, file_count;
int arg_int, file_count DBG_UNUSED;
pts_meas_algorithms_t algo;
pts_file_meas_t *measurements;
imv_workitem_t *workitem, *found = NULL;
@@ -364,6 +364,7 @@ bool imv_attestation_process(pa_tnc_attr_t *attr, imv_msg_t *out_msg,
}
case TCG_PTS_UNIX_FILE_META:
{
#if DEBUG_LEVEL >= 1
tcg_pts_attr_file_meta_t *attr_cast;
int file_count;
pts_file_meta_t *metadata;
@@ -395,6 +396,7 @@ bool imv_attestation_process(pa_tnc_attr_t *attr, imv_msg_t *out_msg,
&created, utc, &modified, utc, &accessed, utc);
}
e->destroy(e);
#endif /* DEBUG_LEVEL */
break;
}
case TCG_PTS_SIMPLE_COMP_EVID:
+26 -20
View File
@@ -175,7 +175,7 @@ static TNC_Result receive_msg(private_imv_hcd_agent_t *this, imv_state_t *state,
imv_msg_t *out_msg;
imv_hcd_state_t *hcd_state;
pa_tnc_attr_t *attr;
enum_name_t *pa_subtype_names;
enum_name_t *pa_subtype_names DBG_UNUSED;
pen_type_t type, msg_type;
TNC_Result result;
bool fatal_error = FALSE, assessment = FALSE;
@@ -220,6 +220,7 @@ static TNC_Result receive_msg(private_imv_hcd_agent_t *this, imv_state_t *state,
{
case IETF_ATTR_FORWARDING_ENABLED:
{
#if DEBUG_LEVEL >= 2
ietf_attr_fwd_enabled_t *attr_cast;
os_fwd_status_t fwd_status;
@@ -227,12 +228,14 @@ static TNC_Result receive_msg(private_imv_hcd_agent_t *this, imv_state_t *state,
fwd_status = attr_cast->get_status(attr_cast);
DBG2(DBG_IMV, " %N: %N", ietf_attr_names, type.type,
os_fwd_status_names, fwd_status);
#endif /* DEBUG_LEVEL */
state->set_action_flags(state,
IMV_HCD_ATTR_FORWARDING_ENABLED);
break;
}
case IETF_ATTR_FACTORY_DEFAULT_PWD_ENABLED:
{
#if DEBUG_LEVEL >= 2
generic_attr_bool_t *attr_cast;
bool status;
@@ -240,6 +243,7 @@ static TNC_Result receive_msg(private_imv_hcd_agent_t *this, imv_state_t *state,
status = attr_cast->get_status(attr_cast);
DBG2(DBG_IMV, " %N: %s", ietf_attr_names, type.type,
status ? "yes" : "no");
#endif /* DEBUG_LEVEL */
state->set_action_flags(state,
IMV_HCD_ATTR_DEFAULT_PWD_ENABLED);
break;
@@ -265,49 +269,47 @@ static TNC_Result receive_msg(private_imv_hcd_agent_t *this, imv_state_t *state,
case PWG_HCD_USER_APP_NAME:
case PWG_HCD_USER_APP_STRING_VERSION:
{
chunk_t value;
value = attr->get_value(attr);
#if DEBUG_LEVEL >= 2
chunk_t value = attr->get_value(attr);
DBG2(DBG_IMV, " %N: %.*s", pwg_attr_names, type.type,
value.len, value.ptr);
(int)value.len, value.ptr);
#endif /* DEBUG_LEVEL */
break;
}
case PWG_HCD_FIRMWARE_PATCHES:
case PWG_HCD_RESIDENT_APP_PATCHES:
case PWG_HCD_USER_APP_PATCHES:
{
chunk_t value;
size_t len;
value = attr->get_value(attr);
len = value.len;
#if DEBUG_LEVEL >= 2
chunk_t value = attr->get_value(attr);
/* remove any trailing LF from patches string */
if (len && (value.ptr[len - 1] == '\n'))
if (value.len && (value.ptr[value.len - 1] == '\n'))
{
len--;
value.len--;
}
DBG2(DBG_IMV, " %N:%s%.*s", pwg_attr_names, type.type,
len ? "\n" : " ", len, value.ptr);
value.len ? "\n" : " ", (int)value.len, value.ptr);
#endif /* DEBUG_LEVEL */
break;
}
case PWG_HCD_FIRMWARE_VERSION:
case PWG_HCD_RESIDENT_APP_VERSION:
case PWG_HCD_USER_APP_VERSION:
{
chunk_t value;
value = attr->get_value(attr);
#if DEBUG_LEVEL >= 2
chunk_t value = attr->get_value(attr);
DBG2(DBG_IMV, " %N: %#B", pwg_attr_names, type.type, &value);
#endif /* DEBUG_LEVEL */
break;
}
case PWG_HCD_CERTIFICATION_STATE:
case PWG_HCD_CONFIGURATION_STATE:
{
chunk_t value;
value = attr->get_value(attr);
#if DEBUG_LEVEL >= 2
chunk_t value = attr->get_value(attr);
DBG2(DBG_IMV, " %N: %B", pwg_attr_names, type.type, &value);
#endif /* DEBUG_LEVEL */
break;
}
case PWG_HCD_DEFAULT_PWD_ENABLED:
@@ -332,6 +334,7 @@ static TNC_Result receive_msg(private_imv_hcd_agent_t *this, imv_state_t *state,
}
case PWG_HCD_FORWARDING_ENABLED:
{
#if DEBUG_LEVEL >= 2
ietf_attr_fwd_enabled_t *attr_cast;
os_fwd_status_t fwd_status;
@@ -339,11 +342,13 @@ static TNC_Result receive_msg(private_imv_hcd_agent_t *this, imv_state_t *state,
fwd_status = attr_cast->get_status(attr_cast);
DBG2(DBG_IMV, " %N: %N", pwg_attr_names, type.type,
os_fwd_status_names, fwd_status);
#endif /* DEBUG_LEVEL */
break;
}
case PWG_HCD_VENDOR_SMI_CODE:
{
#if DEBUG_LEVEL >= 2
pwg_attr_vendor_smi_code_t *attr_cast;
uint32_t smi_code;
@@ -351,6 +356,7 @@ static TNC_Result receive_msg(private_imv_hcd_agent_t *this, imv_state_t *state,
smi_code = attr_cast->get_vendor_smi_code(attr_cast);
DBG2(DBG_IMV, " %N: 0x%06x (%u)", pwg_attr_names, type.type,
smi_code, smi_code);
#endif /* DEBUG_LEVEL */
break;
}
default:
@@ -590,7 +596,7 @@ METHOD(imv_agent_if_t, solicit_recommendation, TNC_Result,
imv_state_t *state;
imv_hcd_state_t* hcd_state;
imv_hcd_handshake_state_t handshake_state;
enum_name_t *pa_subtype_names;
enum_name_t *pa_subtype_names DBG_UNUSED;
bool missing = FALSE;
uint32_t received;
int i;
+6 -9
View File
@@ -250,20 +250,17 @@ static TNC_Result receive_msg(private_imv_os_agent_t *this, imv_state_t *state,
}
case IETF_ATTR_OPERATIONAL_STATUS:
{
ietf_attr_op_status_t *attr_cast;
op_status_t op_status;
op_result_t op_result;
time_t last_boot;
state->set_action_flags(state,
IMV_OS_ATTR_OPERATIONAL_STATUS);
attr_cast = (ietf_attr_op_status_t*)attr;
op_status = attr_cast->get_status(attr_cast);
op_result = attr_cast->get_result(attr_cast);
last_boot = attr_cast->get_last_use(attr_cast);
#if DEBUG_LEVEL >= 1
ietf_attr_op_status_t *attr_cast = (ietf_attr_op_status_t*)attr;
op_status_t op_status = attr_cast->get_status(attr_cast);
op_result_t op_result = attr_cast->get_result(attr_cast);
time_t last_boot = attr_cast->get_last_use(attr_cast);
DBG1(DBG_IMV, "operational status: %N, result: %N",
op_status_names, op_status, op_result_names, op_result);
DBG1(DBG_IMV, "last boot: %T", &last_boot, TRUE);
#endif /* DEBUG_LEVEL */
break;
}
case IETF_ATTR_FORWARDING_ENABLED:
@@ -134,7 +134,7 @@ static TNC_Result receive_msg(private_imv_swima_agent_t *this,
enumerator = in_msg->create_attribute_enumerator(in_msg);
while (enumerator->enumerate(enumerator, &attr))
{
uint32_t request_id = 0, last_eid, eid_epoch;
uint32_t request_id = 0, last_eid DBG_UNUSED, eid_epoch;
swima_inventory_t *inventory;
swima_events_t *events;
pen_type_t type;
@@ -312,7 +312,7 @@ METHOD(imv_swima_state_t, set_inventory, void,
private_imv_swima_state_t *this, swima_inventory_t *inventory)
{
chunk_t sw_id, sw_locator;
uint32_t record_id;
uint32_t record_id DBG_UNUSED;
char *sw_id_str;
json_object *jstring;
swima_record_t *sw_record;
@@ -163,11 +163,11 @@ static TNC_Result receive_msg(private_imv_test_agent_t *this, imv_state_t *state
}
else if (attr_type.type == ITA_ATTR_DUMMY)
{
ita_attr_dummy_t *ita_attr;
ita_attr = (ita_attr_dummy_t*)attr;
#if DEBUG_LEVEL >= 1
ita_attr_dummy_t *ita_attr = (ita_attr_dummy_t*)attr;
DBG1(DBG_IMV, "received dummy attribute value (%d bytes)",
ita_attr->get_size(ita_attr));
#endif
}
}
enumerator->destroy(enumerator);
@@ -964,7 +964,7 @@ METHOD(pts_component_t, get_ref, pts_component_t*,
METHOD(pts_component_t, destroy, void,
pts_ita_comp_ima_t *this)
{
int count;
int count DBG_UNUSED;
if (ref_put(&this->ref))
{
@@ -192,8 +192,8 @@ METHOD(pts_component_t, verify, status_t,
pts_comp_evidence_t *evidence)
{
bool has_pcr_info;
uint32_t extended_pcr, vid, name;
enum_name_t *names;
uint32_t extended_pcr, vid, name DBG_UNUSED;
enum_name_t *names DBG_UNUSED;
pts_meas_algorithms_t algo;
pts_pcr_transform_t transform;
pts_pcr_t *pcrs;
@@ -312,9 +312,9 @@ METHOD(pts_component_t, get_ref, pts_component_t*,
METHOD(pts_component_t, destroy, void,
pts_ita_comp_tboot_t *this)
{
int count;
uint32_t vid, name;
enum_name_t *names;
int count DBG_UNUSED;
uint32_t vid, name DBG_UNUSED;
enum_name_t *names DBG_UNUSED;
if (ref_put(&this->ref))
{
@@ -107,7 +107,7 @@ METHOD(pts_comp_func_name_t, log_, void,
{
enum_name_t *names, *types;
char flags[8];
int type;
int type DBG_UNUSED;
names = imcv_pts_components->get_comp_func_names(imcv_pts_components,
this->vid);
+5 -4
View File
@@ -798,7 +798,6 @@ METHOD(pts_t, quote, bool,
private_pts_t *this, tpm_quote_mode_t *quote_mode,
tpm_tss_quote_info_t **quote_info, chunk_t *quote_sig)
{
chunk_t pcr_value, pcr_computed;
hash_algorithm_t hash_alg;
uint32_t pcr, pcr_sel = 0;
enumerator_t *enumerator;
@@ -810,14 +809,16 @@ METHOD(pts_t, quote, bool,
enumerator = this->pcrs->create_enumerator(this->pcrs);
while (enumerator->enumerate(enumerator, &pcr))
{
#if DEBUG_LEVEL >= 2
chunk_t pcr_value;
if (this->tpm->read_pcr(this->tpm, pcr, &pcr_value, hash_alg))
{
pcr_computed = this->pcrs->get(this->pcrs, pcr);
chunk_t pcr_computed = this->pcrs->get(this->pcrs, pcr);
DBG2(DBG_PTS, "PCR %2d %#B %s", pcr, &pcr_value,
chunk_equals(pcr_value, pcr_computed) ? "ok" : "differs");
chunk_free(&pcr_value);
};
}
#endif
/* add PCR to selection list */
pcr_sel |= (1 << pcr);
}
+27 -30
View File
@@ -26,43 +26,40 @@ bool pts_dh_group_probe(pts_dh_group_t *dh_groups, bool mandatory_dh_groups)
enumerator_t *enumerator;
key_exchange_method_t dh_group;
const char *plugin_name;
char format1[] = " %s PTS DH group %N[%s] available";
char format2[] = " %s PTS DH group %N not available";
*dh_groups = PTS_DH_GROUP_NONE;
enumerator = lib->crypto->create_ke_enumerator(lib->crypto);
while (enumerator->enumerate(enumerator, &dh_group, &plugin_name))
{
if (dh_group == MODP_1024_BIT)
pts_dh_group_t mapped = PTS_DH_GROUP_NONE;
switch (dh_group)
{
*dh_groups |= PTS_DH_GROUP_IKE2;
DBG2(DBG_PTS, format1, "optional ", key_exchange_method_names,
dh_group, plugin_name);
case MODP_1024_BIT:
mapped = PTS_DH_GROUP_IKE2;
break;
case MODP_1536_BIT:
mapped = PTS_DH_GROUP_IKE5;
break;
case MODP_2048_BIT:
mapped = PTS_DH_GROUP_IKE14;
break;
case ECP_256_BIT:
mapped = PTS_DH_GROUP_IKE19;
break;
case ECP_384_BIT:
mapped = PTS_DH_GROUP_IKE20;
break;
default:
break;
}
else if (dh_group == MODP_1536_BIT)
if (mapped != PTS_DH_GROUP_NONE)
{
*dh_groups |= PTS_DH_GROUP_IKE5;
DBG2(DBG_PTS, format1, "optional ", key_exchange_method_names,
dh_group, plugin_name);
}
else if (dh_group == MODP_2048_BIT)
{
*dh_groups |= PTS_DH_GROUP_IKE14;
DBG2(DBG_PTS, format1, "optional ", key_exchange_method_names,
dh_group, plugin_name);
}
else if (dh_group == ECP_256_BIT)
{
*dh_groups |= PTS_DH_GROUP_IKE19;
DBG2(DBG_PTS, format1, "mandatory", key_exchange_method_names,
dh_group, plugin_name);
}
else if (dh_group == ECP_384_BIT)
{
*dh_groups |= PTS_DH_GROUP_IKE20;
DBG2(DBG_PTS, format1, "optional ", key_exchange_method_names,
dh_group, plugin_name);
*dh_groups |= mapped;
DBG2(DBG_PTS, " %s PTS DH group %N[%s] available",
mapped == PTS_DH_GROUP_IKE19 ? "mandatory" : "optional ",
key_exchange_method_names, dh_group, plugin_name);
}
}
enumerator->destroy(enumerator);
@@ -79,8 +76,8 @@ bool pts_dh_group_probe(pts_dh_group_t *dh_groups, bool mandatory_dh_groups)
}
if (mandatory_dh_groups)
{
DBG1(DBG_PTS, format2, "mandatory", key_exchange_method_names,
ECP_256_BIT);
DBG1(DBG_PTS, " mandatory PTS DH group %N[%s] available",
key_exchange_method_names, ECP_256_BIT);
return FALSE;
}
+7 -7
View File
@@ -201,11 +201,10 @@ pts_ima_bios_list_t* pts_ima_bios_list_create(tpm_tss_t *tpm, char *file,
pts_meas_algorithms_t algo)
{
private_pts_ima_bios_list_t *this;
uint32_t pcr, ev_type, event_type, event_len, seek_len, count = 1;
uint32_t pcr, event_type, event_len, seek_len, count = 1;
uint32_t buf_len = 8192;
uint8_t event_buf[buf_len];
hash_algorithm_t hash_alg;
chunk_t event;
bios_entry_t *entry;
struct stat st;
ssize_t res;
@@ -276,10 +275,12 @@ pts_ima_bios_list_t* pts_ima_bios_list_create(tpm_tss_t *tpm, char *file,
{
break;
}
ev_type = (event_type < EV_EFI_EVENT_BASE) ?
event_type : event_type - EV_EFI_OFFSET;
#if DEBUG_LEVEL >= 2
uint32_t ev_type = (event_type < EV_EFI_EVENT_BASE) ?
event_type : event_type - EV_EFI_OFFSET;
DBG2(DBG_PTS, "%3u %2u %N (%u bytes)", count, pcr, event_type_names,
ev_type, event_len);
ev_type, event_len);
#endif
seek_len = (event_len > buf_len) ? event_len - buf_len : 0;
event_len -= seek_len;
@@ -310,8 +311,7 @@ pts_ima_bios_list_t* pts_ima_bios_list_create(tpm_tss_t *tpm, char *file,
default:
break;
}
event = chunk_create(event_buf, event_len);
DBG3(DBG_PTS,"%B", &event);
DBG3(DBG_PTS, "%b", event_buf, event_len);
if (seek_len > 0 && lseek(fd, seek_len, SEEK_CUR) == -1)
{
+1 -1
View File
@@ -139,7 +139,7 @@ pts_ima_event_list_t* pts_ima_event_list_create(char *file,
size_t hash_size;
char type[IMA_TYPE_LEN_MAX];
char algo_digest[IMA_ALGO_DIGEST_LEN_MAX];
char *pos, *error = "";
char *pos, *error DBG_UNUSED = "";
struct stat st;
ssize_t res;
bool ima_ng;
+31 -26
View File
@@ -34,6 +34,8 @@ ENUM_NEXT(pts_meas_algorithm_names, PTS_MEAS_ALGO_SHA1, PTS_MEAS_ALGO_SHA1,
"SHA1");
ENUM_END(pts_meas_algorithm_names, PTS_MEAS_ALGO_SHA1);
#define ALG_UNAVAIL " %s PTS measurement algorithm %N not available"
/**
* Described in header.
*/
@@ -42,48 +44,51 @@ bool pts_meas_algo_probe(pts_meas_algorithms_t *algorithms)
enumerator_t *enumerator;
hash_algorithm_t hash_alg;
const char *plugin_name;
char format1[] = " %s PTS measurement algorithm %N[%s] available";
char format2[] = " %s PTS measurement algorithm %N not available";
*algorithms = 0;
enumerator = lib->crypto->create_hasher_enumerator(lib->crypto);
while (enumerator->enumerate(enumerator, &hash_alg, &plugin_name))
{
if (hash_alg == HASH_SHA1)
pts_meas_algorithms_t mapped = 0;
bool mandatory DBG_UNUSED = FALSE;
switch (hash_alg)
{
*algorithms |= PTS_MEAS_ALGO_SHA1;
DBG2(DBG_PTS, format1, "mandatory", hash_algorithm_names, hash_alg,
plugin_name);
case HASH_SHA1:
mapped = PTS_MEAS_ALGO_SHA1;
mandatory = TRUE;
break;
case HASH_SHA256:
mapped = PTS_MEAS_ALGO_SHA256;
mandatory = TRUE;
break;
case HASH_SHA384:
mapped = PTS_MEAS_ALGO_SHA384;
break;
case HASH_SHA512:
mapped = PTS_MEAS_ALGO_SHA512;
break;
default:
break;
}
else if (hash_alg == HASH_SHA256)
if (mapped)
{
*algorithms |= PTS_MEAS_ALGO_SHA256;
DBG2(DBG_PTS, format1, "mandatory", hash_algorithm_names, hash_alg,
plugin_name);
}
else if (hash_alg == HASH_SHA384)
{
*algorithms |= PTS_MEAS_ALGO_SHA384;
DBG2(DBG_PTS, format1, "optional ", hash_algorithm_names, hash_alg,
plugin_name);
}
else if (hash_alg == HASH_SHA512)
{
*algorithms |= PTS_MEAS_ALGO_SHA512;
DBG2(DBG_PTS, format1, "optional ", hash_algorithm_names, hash_alg,
plugin_name);
*algorithms |= mapped;
DBG2(DBG_PTS, " %s PTS measurement algorithm %N[%s] available",
mandatory ? "mandatory" : "optional ", hash_algorithm_names,
hash_alg, plugin_name);
}
}
enumerator->destroy(enumerator);
if (!(*algorithms & PTS_MEAS_ALGO_SHA512))
{
DBG1(DBG_PTS, format2, "optional ", hash_algorithm_names, HASH_SHA512);
DBG1(DBG_PTS, ALG_UNAVAIL, "optional ", hash_algorithm_names, HASH_SHA512);
}
if (!(*algorithms & PTS_MEAS_ALGO_SHA384))
{
DBG1(DBG_PTS, format2, "optional ", hash_algorithm_names, HASH_SHA384);
DBG1(DBG_PTS, ALG_UNAVAIL, "optional ", hash_algorithm_names, HASH_SHA384);
}
if ((*algorithms & PTS_MEAS_ALGO_SHA1) &&
(*algorithms & PTS_MEAS_ALGO_SHA256))
@@ -92,11 +97,11 @@ bool pts_meas_algo_probe(pts_meas_algorithms_t *algorithms)
}
if (!(*algorithms & PTS_MEAS_ALGO_SHA256))
{
DBG1(DBG_PTS, format2, "mandatory", hash_algorithm_names, HASH_SHA256);
DBG1(DBG_PTS, ALG_UNAVAIL, "mandatory", hash_algorithm_names, HASH_SHA256);
}
if (!(*algorithms & PTS_MEAS_ALGO_SHA1))
{
DBG1(DBG_PTS, format2, "mandatory", hash_algorithm_names, HASH_SHA1);
DBG1(DBG_PTS, ALG_UNAVAIL, "mandatory", hash_algorithm_names, HASH_SHA1);
}
return FALSE;
}
+2 -2
View File
@@ -1000,9 +1000,9 @@ START_TEST(test_imcv_swima_sw_collector)
swima_events_t *events;
swima_record_t *sw_record;
swima_event_t *sw_event;
chunk_t sw_id, sw_locator, swid_tag;
chunk_t sw_id DBG_UNUSED, sw_locator, swid_tag DBG_UNUSED;
enumerator_t *enumerator;
uint8_t source_id;
uint8_t source_id DBG_UNUSED;
int item = 0, items;
targets = swima_inventory_create();
+5 -3
View File
@@ -185,8 +185,8 @@ static bool check_padding(chunk_t padding)
static bool remove_padding(private_esp_packet_t *this, chunk_t plaintext)
{
uint8_t next_header, pad_length;
chunk_t padding, payload;
bio_reader_t *reader;
chunk_t padding;
reader = bio_reader_create(plaintext);
if (!reader->read_uint8_end(reader, &next_header) ||
@@ -209,11 +209,13 @@ static bool remove_padding(private_esp_packet_t *this, chunk_t plaintext)
return FALSE;
}
this->next_header = next_header;
payload = this->payload->get_encoding(this->payload);
#if DEBUG_LEVEL >= 3
chunk_t encoding = this->payload->get_encoding(this->payload);
DBG3(DBG_ESP, "ESP payload:\n payload %B\n padding %B\n "
"padding length = %hhu, next header = %hhu", &payload, &padding,
"padding length = %hhu, next header = %hhu", &encoding, &padding,
pad_length, this->next_header);
#endif
return TRUE;
failed:
+3 -2
View File
@@ -84,7 +84,6 @@ METHOD(radius_client_t, request, radius_message_t*,
{
radius_socket_t *socket;
radius_message_t *res;
chunk_t data;
/* add our NAS-Identifier */
req->add(req, RAT_NAS_IDENTIFIER,
@@ -104,8 +103,10 @@ METHOD(radius_client_t, request, radius_message_t*,
DBG1(DBG_CFG, "received RADIUS %N from server '%s'",
radius_message_code_names, res->get_code(res),
this->config->get_name(this->config));
data = res->get_encoding(res);
#if DEBUG_LEVEL >= 3
chunk_t data = res->get_encoding(res);
DBG3(DBG_CFG, "%B", &data);
#endif
save_state(this, res);
if (res->get_code(res) == RMC_ACCESS_ACCEPT)
+1
View File
@@ -314,6 +314,7 @@ METHOD(simaka_manager_t, provider_get_quintuplet, bool,
this->lock->unlock(this->lock);
return TRUE;
}
tried++;
}
enumerator->destroy(enumerator);
this->lock->unlock(this->lock);
+2 -1
View File
@@ -548,9 +548,10 @@ void asn1_debug_simple_object(chunk_t object, asn1_t type, bool private)
case ASN1_UTCTIME:
case ASN1_GENERALIZEDTIME:
{
#if DEBUG_LEVEL >= 2
time_t time = asn1_to_time(&object, type);
DBG2(DBG_ASN, " '%T'", &time, TRUE);
#endif
}
return;
default:
+1 -1
View File
@@ -89,7 +89,7 @@ METHOD(asn1_parser_t, iterate, bool,
{
chunk_t *blob, *blob1, blob_ori;
u_char *start_ptr;
u_int level;
u_int level DBG_UNUSED;
asn1Object_t obj;
*object = chunk_empty;
+2 -1
View File
@@ -821,7 +821,6 @@ METHOD(auth_cfg_t, complies, bool,
signature_params_t *ike_scheme = NULL, *scheme = NULL;
u_int strength = 0;
auth_rule_t t1, t2;
char *key_type;
void *value;
e1 = constraints->create_enumerator(constraints);
@@ -1110,6 +1109,8 @@ METHOD(auth_cfg_t, complies, bool,
* public key strength */
if (success && strength)
{
char *key_type DBG_UNUSED;
e2 = create_enumerator(this);
while (e2->enumerate(e2, &t2, &strength))
{
@@ -48,7 +48,7 @@ ENUM(cert_validation_names, VALIDATION_GOOD, VALIDATION_REVOKED,
bool certificate_is_newer(certificate_t *this, certificate_t *other)
{
time_t this_update, that_update;
char *type = "certificate";
char *type DBG_UNUSED = "certificate";
bool newer;
if (this->get_type(this) == CERT_X509_CRL)
@@ -119,7 +119,7 @@ METHOD(credential_factory_t, create, void*,
void *construct = NULL;
int failures = 0;
uintptr_t level;
enum_name_t *names;
enum_name_t *names DBG_UNUSED;
switch (type)
{
+2
View File
@@ -110,6 +110,7 @@ struct private_crypto_tester_t {
int bench_size;
};
#if DEBUG_LEVEL >= 1
/**
* Get the name of a test vector, if available
*/
@@ -125,6 +126,7 @@ static const char* get_name(void *sym)
#endif
return "unknown";
}
#endif
#if defined(CLOCK_THREAD_CPUTIME_ID) && defined(HAVE_CLOCK_GETTIME)
@@ -186,7 +186,7 @@ static bool sign_bliss(private_bliss_private_key_t *this, hash_algorithm_t alg,
int32_t scalar, norm, ui;
int16_t *ud, *uz2d, *z2d, value;
int i, n;
double mean1 = 0, mean2 = 0, sigma1 = 0, sigma2 = 0;
double mean1 = 0, mean2 = 0, sigma1 DBG_UNUSED = 0, sigma2 DBG_UNUSED = 0;
bool accepted, positive, success = FALSE, use_bliss_b;
/* Initialize signature */
@@ -907,7 +907,7 @@ static bool create_secret(private_bliss_private_key_t *this, rng_t *rng,
{
uint8_t seed_buf[32];
uint8_t *f, *g;
uint32_t l2_norm, nks;
uint32_t l2_norm DBG_UNUSED, nks;
int i, n;
chunk_t seed;
size_t seed_len;
@@ -352,7 +352,7 @@ static bool has_policy(x509_t *issuer, chunk_t oid)
*/
static bool check_policy(x509_t *subject, x509_t *issuer)
{
certificate_t *cert = (certificate_t*)subject;
certificate_t *cert DBG_UNUSED = (certificate_t*)subject;
x509_policy_mapping_t *mapping;
x509_cert_policy_t *policy;
enumerator_t *enumerator;
@@ -485,7 +485,7 @@ static bool has_no_policy_mapping(linked_list_t *chain, int len)
{
enumerator_t *enumerator, *mappings;
x509_policy_mapping_t *mapping;
certificate_t *cert;
certificate_t *cert DBG_UNUSED;
x509_t *x509;
bool valid = TRUE;
@@ -514,7 +514,7 @@ static bool has_no_any_policy(linked_list_t *chain, int len)
{
enumerator_t *enumerator, *policies;
x509_cert_policy_t *policy;
certificate_t *cert;
certificate_t *cert DBG_UNUSED;
x509_t *x509;
bool valid = TRUE;
+4 -3
View File
@@ -158,7 +158,6 @@ METHOD(drbg_t, generate, bool,
private_drbg_hmac_t *this, uint32_t len, uint8_t *out)
{
size_t delta;
chunk_t output;
if (len > MAX_DRBG_BYTES)
{
@@ -179,7 +178,9 @@ METHOD(drbg_t, generate, bool,
{
return FALSE;
}
output = chunk_create(out, len);
#if DEBUG_LEVEL >= 4
chunk_t output = chunk_create(out, len);
#endif
while (len)
{
@@ -192,7 +193,7 @@ METHOD(drbg_t, generate, bool,
len -= delta;
out += delta;
}
DBG4(DBG_LIB, "HMAC_DRBG Out: %B", &output);
DBG4(DBG_LIB, "HMAC_DRBG out: %B", &output);
if (!update(this, chunk_empty))
{
@@ -405,7 +405,7 @@ static bool parse(private_pkcs7_signed_data_t *this, chunk_t content)
{
asn1_parser_t *parser;
chunk_t object;
int objectID, version;
int objectID;
signerinfo_t *info = NULL;
bool success = FALSE;
@@ -418,8 +418,7 @@ static bool parse(private_pkcs7_signed_data_t *this, chunk_t content)
switch (objectID)
{
case PKCS7_VERSION:
version = object.len ? (int)*object.ptr : 0;
DBG2(DBG_LIB, " v%d", version);
DBG2(DBG_LIB, " v%d", object.len ? (int)*object.ptr : 0);
break;
case PKCS7_CONTENT_INFO:
this->content = lib->creds->create(lib->creds,
@@ -448,8 +447,7 @@ static bool parse(private_pkcs7_signed_data_t *this, chunk_t content)
this->signerinfos->insert_last(this->signerinfos, info);
break;
case PKCS7_SIGNER_INFO_VERSION:
version = object.len ? (int)*object.ptr : 0;
DBG2(DBG_LIB, " v%d", version);
DBG2(DBG_LIB, " v%d", object.len ? (int)*object.ptr : 0);
break;
case PKCS7_ISSUER:
info->issuer = identification_create_from_encoding(
+8 -8
View File
@@ -755,10 +755,11 @@ static bool load_dependencies(private_plugin_loader_t *this,
{
bool soft = provided->feature[i].kind == FEATURE_SDEPEND;
#ifndef USE_FUZZING
#if !defined(USE_FUZZING) && DEBUG_LEVEL >= 1
char *name, *provide, *depend;
#if DEBUG_LEVEL >= 3
int indent = level * 2;
#endif
name = provided->entry->plugin->get_name(provided->entry->plugin);
provide = plugin_feature_get_string(&provided->feature[0]);
depend = plugin_feature_get_string(&provided->feature[i]);
@@ -779,7 +780,7 @@ static bool load_dependencies(private_plugin_loader_t *this,
}
free(provide);
free(depend);
#endif /* !USE_FUZZING */
#endif /* !USE_FUZZING && DEBUG_LEVEL */
if (soft)
{ /* it's ok if we can't resolve soft dependencies */
@@ -809,7 +810,7 @@ static void load_feature(private_plugin_loader_t *this,
return;
}
#ifndef USE_FUZZING
#if !defined(USE_FUZZING) && DEBUG_LEVEL >= 1
char *name, *provide;
name = provided->entry->plugin->get_name(provided->entry->plugin);
@@ -825,7 +826,7 @@ static void load_feature(private_plugin_loader_t *this,
provide, name);
}
free(provide);
#endif /* !USE_FUZZING */
#endif /* !USE_FUZZING && DEBUG_LEVEL */
}
else
{ /* TODO: we could check the current level and set a different flag when
@@ -845,13 +846,12 @@ static void load_provided(private_plugin_loader_t *this,
provided_feature_t *provided,
int level)
{
if (provided->loaded || provided->failed)
{
return;
}
#ifndef USE_FUZZING
#if !defined(USE_FUZZING) && DEBUG_LEVEL >= 3
char *name, *provide;
int indent = level * 2;
@@ -872,7 +872,7 @@ static void load_provided(private_plugin_loader_t *this,
{
return;
}
#endif /* USE_FUZZING */
#endif /* USE_FUZZING && DEBUG_LEVEL */
provided->loading = TRUE;
load_feature(this, provided, level + 1);
@@ -683,7 +683,8 @@ static cert_validation_t check_delta_crl(x509_t *subject, x509_t *issuer,
u_int timeout)
{
cert_validation_t valid = VALIDATION_SKIPPED;
certificate_t *best = NULL, *current, *cissuer = (certificate_t*)issuer;
certificate_t *best = NULL, *current;
certificate_t *cissuer DBG_UNUSED = (certificate_t*)issuer;
enumerator_t *enumerator;
identification_t *id;
x509_cdp_t *cdp;
@@ -752,7 +753,7 @@ static cert_validation_t check_crl(x509_t *subject, x509_t *issuer,
auth_cfg_t *auth, u_int timeout)
{
cert_validation_t valid = VALIDATION_SKIPPED;
certificate_t *best = NULL, *cissuer = (certificate_t*)issuer;
certificate_t *best = NULL, *cissuer DBG_UNUSED = (certificate_t*)issuer;
identification_t *id;
x509_cdp_t *cdp;
bool uri_found = FALSE;
@@ -62,7 +62,9 @@ METHOD(plugin_t, destroy, void,
plugin_t *sqlite_plugin_create()
{
private_sqlite_plugin_t *this;
#if SQLITE_VERSION_NUMBER >= 3005000 && DEBUG_LEVEL >= 2
int threadsafe = 0;
#endif
INIT(this,
.public = {
@@ -74,7 +76,7 @@ plugin_t *sqlite_plugin_create()
},
);
#if SQLITE_VERSION_NUMBER >= 3005000
#if SQLITE_VERSION_NUMBER >= 3005000 && DEBUG_LEVEL >= 2
threadsafe = sqlite3_threadsafe();
#endif
DBG2(DBG_LIB, "using SQLite %s, thread safety %d",
+2 -3
View File
@@ -429,7 +429,6 @@ static bool parse_certificate(private_x509_ac_t *this)
int extn_oid = OID_UNKNOWN;
signature_params_t sig_alg = {};
bool success = FALSE;
bool critical;
parser = asn1_parser_create(acObjects, this->encoding);
@@ -529,8 +528,8 @@ static bool parse_certificate(private_x509_ac_t *this)
extn_oid = asn1_known_oid(object);
break;
case AC_OBJ_CRITICAL:
critical = object.len && *object.ptr;
DBG2(DBG_ASN, " %s",(critical)?"TRUE":"FALSE");
DBG2(DBG_ASN, " %s",
object.len && *object.ptr ? "TRUE" : "FALSE");
break;
case AC_OBJ_EXTN_VALUE:
{
@@ -528,7 +528,6 @@ static bool parse_basicOCSPResponse(private_x509_ocsp_response_t *this,
u_int responses_level = level0;
certificate_t *cert;
bool success = FALSE;
bool critical;
parser = asn1_parser_create(basicResponseObjects, blob);
parser->set_top_level(parser, level0);
@@ -573,8 +572,8 @@ static bool parse_basicOCSPResponse(private_x509_ocsp_response_t *this,
extn_oid = asn1_known_oid(object);
break;
case BASIC_RESPONSE_CRITICAL:
critical = object.len && *object.ptr;
DBG2(DBG_ASN, " %s", critical ? "TRUE" : "FALSE");
DBG2(DBG_ASN, " %s",
object.len && *object.ptr ? "TRUE" : "FALSE");
break;
case BASIC_RESPONSE_EXT_VALUE:
if (extn_oid == OID_NONCE &&
+2 -3
View File
@@ -430,7 +430,6 @@ static bool parse_extension_request(private_x509_pkcs10_t *this, chunk_t blob, i
int objectID;
int extn_oid = OID_UNKNOWN;
bool success = FALSE;
bool critical;
parser = asn1_parser_create(extensionRequestObjects, blob);
parser->set_top_level(parser, level0);
@@ -445,8 +444,8 @@ static bool parse_extension_request(private_x509_pkcs10_t *this, chunk_t blob, i
extn_oid = asn1_known_oid(object);
break;
case PKCS10_EXTN_CRITICAL:
critical = object.len && *object.ptr;
DBG2(DBG_ASN, " %s", critical ? "TRUE" : "FALSE");
DBG2(DBG_ASN, " %s",
object.len && *object.ptr ? "TRUE" : "FALSE");
break;
case PKCS10_EXTN_VALUE:
{
+5
View File
@@ -140,6 +140,11 @@ enum level_t {
# define DBG4(...) {}
#endif
/** mark variables that are only used in DBG statements */
#ifndef DBG_UNUSED
# define DBG_UNUSED __attribute__((unused))
#endif
/** dbg function hook, uses dbg_default() by default */
extern void (*dbg) (debug_t group, level_t level, char *fmt, ...);
+1 -1
View File
@@ -210,7 +210,7 @@ static status_t build_pkt(private_tls_eap_t *this, chunk_t *out)
eap_tls_packet_t *pkt;
size_t len, reclen, msg_len_offset;
status_t status;
char *kind;
char *kind DBG_UNUSED;
if (this->is_server)
{
+3 -2
View File
@@ -230,7 +230,6 @@ static status_t process_application(private_tls_fragmentation_t *this,
while (reader->remaining(reader))
{
status_t status;
chunk_t data;
if (reader->remaining(reader) > TLS_MAX_FRAGMENT_LEN)
{
@@ -238,8 +237,10 @@ static status_t process_application(private_tls_fragmentation_t *this,
this->alert->add(this->alert, TLS_FATAL, TLS_DECODE_ERROR);
return NEED_MORE;
}
data = reader->peek(reader);
#if DEBUG_LEVEL >= 3
chunk_t data = reader->peek(reader);
DBG3(DBG_TLS, "%B", &data);
#endif
status = this->application->process(this->application, reader);
switch (status)
{
+1 -1
View File
@@ -1112,7 +1112,7 @@ static status_t process_key_update(private_tls_peer_t *this,
METHOD(tls_handshake_t, process, status_t,
private_tls_peer_t *this, tls_handshake_type_t type, bio_reader_t *reader)
{
tls_handshake_type_t expected;
tls_handshake_type_t expected DBG_UNUSED;
if (this->tls->get_version_max(this->tls) < TLS_1_3)
{
+1 -1
View File
@@ -1042,7 +1042,7 @@ static status_t process_key_update(private_tls_server_t *this,
METHOD(tls_handshake_t, process, status_t,
private_tls_server_t *this, tls_handshake_type_t type, bio_reader_t *reader)
{
tls_handshake_type_t expected;
tls_handshake_type_t expected DBG_UNUSED;
if (this->tls->get_version_max(this->tls) < TLS_1_3)
{
+5 -3
View File
@@ -277,15 +277,15 @@ static void handle_message(private_tnccs_11_t *this, tnccs_msg_t *msg)
}
case TNCCS_MSG_ERROR:
{
tnccs_error_msg_t *err_msg;
#if DEBUG_LEVEL >= 1
tnccs_error_msg_t *err_msg = (tnccs_error_msg_t*)msg;
tnccs_error_type_t error_type;
char *error_msg;
err_msg = (tnccs_error_msg_t*)msg;
error_msg = err_msg->get_message(err_msg, &error_type);
DBG1(DBG_TNC, "received '%N' TNCCS-Error: %s",
tnccs_error_type_names, error_type, error_msg);
#endif
/* we assume that all errors are fatal */
this->fatal_error = TRUE;
break;
@@ -305,6 +305,7 @@ static void handle_message(private_tnccs_11_t *this, tnccs_msg_t *msg)
}
case TNCCS_MSG_REASON_STRINGS:
{
#if DEBUG_LEVEL >= 2
tnccs_reason_strings_msg_t *reason_msg;
chunk_t reason_string, reason_lang;
@@ -314,6 +315,7 @@ static void handle_message(private_tnccs_11_t *this, tnccs_msg_t *msg)
reason_string.ptr);
DBG2(DBG_TNC, "language code is '%.*s'", (int)reason_lang.len,
reason_lang.ptr);
#endif
break;
}
default:
@@ -141,9 +141,7 @@ METHOD(pb_tnc_batch_t, get_encoding, chunk_t,
METHOD(pb_tnc_batch_t, add_msg, bool,
private_pb_tnc_batch_t *this, pb_tnc_msg_t* msg)
{
enum_name_t *msg_type_names;
chunk_t msg_value;
pen_type_t msg_type;
size_t msg_len;
msg->build(msg);
@@ -157,7 +155,10 @@ METHOD(pb_tnc_batch_t, add_msg, bool,
}
this->batch_len += msg_len;
msg_type = msg->get_type(msg);
#if DEBUG_LEVEL >= 2
pen_type_t msg_type = msg->get_type(msg);
enum_name_t *msg_type_names;
switch (msg_type.vendor_id)
{
default:
@@ -173,6 +174,7 @@ METHOD(pb_tnc_batch_t, add_msg, bool,
}
DBG2(DBG_TNC, "adding %N/%N message", pen_names, msg_type.vendor_id,
msg_type_names, msg_type.type);
#endif
this->messages->insert_last(this->messages, msg);
return TRUE;
}
@@ -329,7 +331,7 @@ static status_t process_tnc_msg(private_pb_tnc_batch_t *this)
uint32_t vendor_id, msg_type, msg_len, offset;
chunk_t data, msg_value;
bool noskip_flag;
enum_name_t *msg_type_names;
enum_name_t *msg_type_names DBG_UNUSED;
pen_type_t msg_pen_type;
status_t status;
@@ -274,6 +274,7 @@ static void handle_ietf_message(private_tnccs_20_client_t *this, pb_tnc_msg_t *m
}
case PB_MSG_ASSESSMENT_RESULT:
{
#if DEBUG_LEVEL >= 1
pb_assessment_result_msg_t *assess_msg;
uint32_t result;
@@ -281,6 +282,7 @@ static void handle_ietf_message(private_tnccs_20_client_t *this, pb_tnc_msg_t *m
result = assess_msg->get_assessment_result(assess_msg);
DBG1(DBG_TNC, "PB-TNC assessment result is '%N'",
TNC_IMV_Evaluation_Result_names, result);
#endif
break;
}
case PB_MSG_ACCESS_RECOMMENDATION:
@@ -312,7 +314,7 @@ static void handle_ietf_message(private_tnccs_20_client_t *this, pb_tnc_msg_t *m
{
pb_remediation_parameters_msg_t *rem_msg;
pen_type_t parameters_type;
chunk_t parameters, string, lang_code;
chunk_t parameters DBG_UNUSED, string DBG_UNUSED, lang_code;
rem_msg = (pb_remediation_parameters_msg_t*)msg;
parameters_type = rem_msg->get_parameters_type(rem_msg);
@@ -347,6 +349,7 @@ static void handle_ietf_message(private_tnccs_20_client_t *this, pb_tnc_msg_t *m
break;
case PB_MSG_REASON_STRING:
{
#if DEBUG_LEVEL >= 1
pb_reason_string_msg_t *reason_msg;
chunk_t reason_string, language_code;
@@ -356,6 +359,7 @@ static void handle_ietf_message(private_tnccs_20_client_t *this, pb_tnc_msg_t *m
DBG1(DBG_TNC, "reason string is '%.*s' [%.*s]",
(int)reason_string.len, reason_string.ptr,
(int)language_code.len, language_code.ptr);
#endif
break;
}
default:
+4 -3
View File
@@ -124,7 +124,6 @@ static bool initialize_context(private_tpm_tss_trousers_t *this)
uint32_t version_len;
TSS_RESULT result;
TPM_CAP_VERSION_INFO *info;
result = Tspi_Context_Create(&this->hContext);
if (result != TSS_SUCCESS)
@@ -159,12 +158,14 @@ static bool initialize_context(private_tpm_tss_trousers_t *this)
return FALSE;
}
info = (TPM_CAP_VERSION_INFO *)version_ptr;
#if DEBUG_LEVEL > 2
TPM_CAP_VERSION_INFO *info = (TPM_CAP_VERSION_INFO *)version_ptr;
DBG2(DBG_PTS, "TPM Version Info: Chip Version: %u.%u.%u.%u, "
"Spec Level: %u, Errata Rev: %u, Vendor ID: %.4s",
info->version.major, info->version.minor,
info->version.revMajor, info->version.revMinor,
untoh16(&info->specLevel), info->errataRev, info->tpmVendorID);
#endif
this->version_info = chunk_clone(chunk_create(version_ptr, version_len));
@@ -466,7 +467,7 @@ METHOD(tpm_tss_t, quote, bool,
uint32_t version_info_size, pcr;
aik_t *aik;
chunk_t aik_blob = chunk_empty;
chunk_t quote_chunk, pcr_digest;
chunk_t quote_chunk DBG_UNUSED, pcr_digest;
enumerator_t *enumerator;
bool success = FALSE;
+5 -6
View File
@@ -133,7 +133,7 @@ METHOD(tpm_tss_tss2_session_t, set_cmd_auths, bool,
hasher_t *hasher;
pseudo_random_function_t prf_alg;
prf_t *prf;
chunk_t data, cp_hash, cp_hmac, nonce_caller, nonce_tpm, session_attributes;
chunk_t data, cp_hash, nonce_caller, nonce_tpm, session_attributes;
bool success;
uint32_t rval;
@@ -233,8 +233,8 @@ METHOD(tpm_tss_tss2_session_t, set_cmd_auths, bool,
DBG1(DBG_PTS, "cpHmac computation failed");
return FALSE;
}
cp_hmac = chunk_create(cmd.auths[0].hmac.buffer, cmd.auths[0].hmac.size);
DBG2(DBG_PTS, LABEL "cpHmac: %B", &cp_hmac);
DBG2(DBG_PTS, LABEL "cpHmac: %b", cmd.auths[0].hmac.buffer,
cmd.auths[0].hmac.size);
rval = Tss2_Sys_SetCmdAuths(this->sys_context, &cmd);
if (rval != TSS2_RC_SUCCESS)
@@ -319,7 +319,7 @@ METHOD(tpm_tss_tss2_session_t, get_rsp_auths, bool,
prf_t *prf;
crypter_t *crypter;
chunk_t kdf_label = chunk_from_chars('C','F','B', 0x00);
chunk_t data, rp_hash, rp_hmac, nonce_caller, nonce_tpm, session_attributes;
chunk_t data, rp_hash, nonce_caller, nonce_tpm, session_attributes;
chunk_t key_mat, aes_key, aes_iv;
bool success;
uint32_t rval;
@@ -410,8 +410,7 @@ METHOD(tpm_tss_tss2_session_t, get_rsp_auths, bool,
DBG1(DBG_PTS, "computation of rpHmac failed");
return FALSE;
}
rp_hmac = chunk_create(rpHmac.buffer, rpHmac.size);
DBG2(DBG_PTS, LABEL "rpHMAC: %B", &rp_hmac);
DBG2(DBG_PTS, LABEL "rpHMAC: %b", rpHmac.buffer, rpHmac.size);
/* verify rpHmac */
if (!memeq(rsp.auths[0].hmac.buffer, rpHmac.buffer, rpHmac.size))
+3
View File
@@ -664,6 +664,8 @@ METHOD(tpm_tss_t, get_public, chunk_t,
DBG1(DBG_PTS, LABEL "unsupported key type");
return chunk_empty;
}
#if DEBUG_LEVEL >= 1
if (public.publicArea.objectAttributes & TPMA_OBJECT_SIGN_ENCRYPT)
{
TPMT_ASYM_SCHEME *s;
@@ -682,6 +684,7 @@ METHOD(tpm_tss_t, get_public, chunk_t,
tpm_alg_id_names, s->algorithm,
tpm_alg_id_names, s->mode, s->keyBits.sym);
}
#endif
return aik_pubkey;
}
+15 -13
View File
@@ -34,7 +34,7 @@ typedef enum {
CERT_TYPE_RA
} pki_cert_type_t;
static char *cert_type_label[] = { "Root CA", "Sub CA", "RA" };
static char *cert_type_label[] DBG_UNUSED = { "Root CA", "Sub CA", "RA" };
/**
* Determine certificate type based on X.509 certificate flags
@@ -73,7 +73,7 @@ static bool print_cert_info(certificate_t *cert, pki_cert_type_t cert_type)
char digest_buf[HASH_SIZE_SHA256];
char base64_buf[HASH_SIZE_SHA256];
chunk_t cert_digest = {digest_buf, HASH_SIZE_SHA256};
chunk_t cert_id, serial, encoding = chunk_empty;
chunk_t cert_id DBG_UNUSED, serial DBG_UNUSED, encoding = chunk_empty;
x509_t *x509;
bool success = FALSE;
@@ -207,8 +207,7 @@ static bool write_cert(certificate_t *cert, pki_cert_type_t cert_type,
bool force)
{
chunk_t encoding = chunk_empty;
time_t until;
bool written, valid;
bool written;
if (path)
{
@@ -240,12 +239,14 @@ static bool write_cert(certificate_t *cert, pki_cert_type_t cert_type,
path = "stdout";
}
valid = cert->get_validity(cert, NULL, NULL, &until);
#if DEBUG_LEVEL >= 1
time_t until;
bool valid = cert->get_validity(cert, NULL, NULL, &until);
DBG1(DBG_APP, "%s cert is %strusted, %s %T, %s'%s'",
cert_type_label[cert_type], trusted ? "" : "un",
valid ? "valid until" : "invalid since", &until, FALSE,
path ? "written to " : "", path ? path : "not written");
#endif
return TRUE;
}
@@ -466,16 +467,15 @@ bool pki_cert_extract_cert(chunk_t data, cred_encoding_type_t form)
x509_t *x509 = (x509_t*)cert;
certificate_t *cert_found = NULL;
enumerator_t *certs;
chunk_t serial;
time_t from, until;
bool trusted, valid;
bool trusted DBG_UNUSED;
if (!(x509->get_flags(x509) & X509_CA))
{
DBG1(DBG_APP, "Issued certificate \"%Y\"", cert->get_subject(cert));
serial = x509->get_serial(x509);
#if DEBUG_LEVEL >= 1
chunk_t serial = x509->get_serial(x509);
DBG1(DBG_APP, " serial: %#B", &serial);
#endif
if (stored)
{
DBG1(DBG_APP, "multiple certs received, only first stored");
@@ -490,12 +490,14 @@ bool pki_cert_extract_cert(chunk_t data, cred_encoding_type_t form)
(cert_found == cert);
certs->destroy(certs);
valid = cert->get_validity(cert, NULL, &from, &until);
#if DEBUG_LEVEL >= 1
time_t from, until;
bool valid = cert->get_validity(cert, NULL, &from, &until);
DBG1(DBG_APP, "Issued certificate is %strusted, "
"valid from %T until %T (currently %svalid)",
trusted ? "" : "not ", &from, FALSE, &until, FALSE,
valid ? "" : "not ");
#endif
if (!cert->get_encoding(cert, form, &cert_encoding))
{
DBG1(DBG_APP, "encoding certificate failed");
+3 -3
View File
@@ -38,7 +38,7 @@ static const char *operations[] = {
static const char *pkiStatus_values[] = { "0", "2", "3" };
static const char *pkiStatus_names[] = {
static const char *pkiStatus_names[] DBG_UNUSED = {
"SUCCESS",
"FAILURE",
"PENDING",
@@ -47,7 +47,7 @@ static const char *pkiStatus_names[] = {
static const char *msgType_values[] = { "3", "17", "19", "20", "21", "22" };
static const char *msgType_names[] = {
static const char *msgType_names[] DBG_UNUSED = {
"CertRep",
"RenewalReq",
"PKCSReq",
@@ -57,7 +57,7 @@ static const char *msgType_names[] = {
"Unknown"
};
static const char *failInfo_reasons[] = {
static const char *failInfo_reasons[] DBG_UNUSED = {
"badAlg - unrecognized or unsupported algorithm identifier",
"badMessageCheck - integrity check failed",
"badRequest - transaction not permitted or supported",
+1 -1
View File
@@ -173,7 +173,7 @@ static bool update_database(database_t *db, char *package, char *version,
while (e->enumerate(e, &vid, &release, &sec_flag))
{
char command[BUF_LEN];
char found_char = ' ';
char found_char DBG_UNUSED = ' ';
bool update_version = FALSE;
if (streq(version, release))
+4 -4
View File
@@ -451,7 +451,7 @@ static int list_identifiers(sw_collector_db_t *db, sw_collector_db_query_t type)
{
enumerator_t *e;
char *name, *package, *version;
uint32_t sw_id, count = 0, installed_count = 0, removed_count, installed;
uint32_t sw_id, count = 0, installed_count = 0, installed;
e = db->create_sw_enumerator(db, type, NULL);
if (!e)
@@ -467,14 +467,14 @@ static int list_identifiers(sw_collector_db_t *db, sw_collector_db_query_t type)
}
count++;
}
removed_count = count - installed_count;
e->destroy(e);
switch (type)
{
case SW_QUERY_ALL:
DBG1(DBG_IMC, "retrieved %u software identities with %u installed "
"and %u removed", count, installed_count, removed_count);
"and %u removed", count, installed_count,
count - installed_count);
break;
case SW_QUERY_INSTALLED:
DBG1(DBG_IMC, "retrieved %u installed software identities", count);
@@ -629,7 +629,7 @@ static int migrate(sw_collector_db_t *db)
char *package, *arch, *version;
char package_filter[BUF_LEN];
int res, count = 0;
int res, count DBG_UNUSED = 0;
int status = EXIT_SUCCESS;
enumerator_t *enumerator;