Added tnc/tnccs-20-fail-init and tnc/tnccs-20-fail-resp scenarios

This commit is contained in:
Andreas Steffen
2015-03-27 20:56:44 +01:00
parent ef5f96366e
commit 883c11caa0
38 changed files with 582 additions and 8 deletions
@@ -31,6 +31,7 @@ libstrongswan_tnccs_20_la_SOURCES = \
messages/ietf/pb_reason_string_msg.h messages/ietf/pb_reason_string_msg.c \
messages/ietf/pb_remediation_parameters_msg.h messages/ietf/pb_remediation_parameters_msg.c \
messages/ita/pb_mutual_capability_msg.h messages/ita/pb_mutual_capability_msg.c \
messages/ita/pb_noskip_test_msg.h messages/ita/pb_noskip_test_msg.c \
messages/tcg/pb_pdp_referral_msg.h messages/tcg/pb_pdp_referral_msg.c \
state_machine/pb_tnc_state_machine.h state_machine/pb_tnc_state_machine.c
@@ -179,6 +179,7 @@ METHOD(pb_tnc_batch_t, add_msg, bool,
METHOD(pb_tnc_batch_t, build, void,
private_pb_tnc_batch_t *this)
{
u_int8_t version;
u_int32_t msg_len;
chunk_t msg_value;
enumerator_t *enumerator;
@@ -187,9 +188,14 @@ METHOD(pb_tnc_batch_t, build, void,
pb_tnc_msg_info_t *msg_infos;
bio_writer_t *writer;
/* Set wrong PB-TNC version for testing purposes to force a PB-TNC error */
version = lib->settings->get_int(lib->settings,
"%s.plugins.tnccs-20.tests.pb_tnc_version",
PB_TNC_VERSION, lib->ns);
/* build PB-TNC batch header */
writer = bio_writer_create(this->batch_len);
writer->write_uint8 (writer, PB_TNC_VERSION);
writer->write_uint8 (writer, version);
writer->write_uint8 (writer, this->is_server ?
PB_TNC_BATCH_FLAG_D : PB_TNC_BATCH_FLAG_NONE);
writer->write_uint16(writer, this->type);
@@ -310,7 +316,7 @@ METHOD(pb_tnc_batch_t, process_header, status_t,
fatal:
this->errors->insert_last(this->errors, msg);
return VERIFY_ERROR;
return FAILED;
}
static status_t process_tnc_msg(private_pb_tnc_batch_t *this)
@@ -385,12 +391,14 @@ static status_t process_tnc_msg(private_pb_tnc_batch_t *this)
msg_type_names = pb_tnc_msg_type_names;
msg_infos = pb_tnc_msg_infos;
}
else if (vendor_id == PEN_TCG && msg_type <= PB_TCG_MSG_ROOF)
else if (vendor_id == PEN_TCG && msg_type <= PB_TCG_MSG_ROOF &&
msg_type > PB_TCG_MSG_RESERVED)
{
msg_type_names = pb_tnc_tcg_msg_type_names;
msg_infos = pb_tnc_tcg_msg_infos;
}
else if (vendor_id == PEN_ITA && msg_type <= PB_ITA_MSG_ROOF)
else if (vendor_id == PEN_ITA && msg_type <= PB_ITA_MSG_ROOF &&
msg_type > PB_ITA_MSG_NOSKIP_TEST)
{
msg_type_names = pb_tnc_ita_msg_type_names;
msg_infos = pb_tnc_ita_msg_infos;
@@ -408,7 +416,7 @@ static status_t process_tnc_msg(private_pb_tnc_batch_t *this)
if (noskip_flag)
{
DBG1(DBG_TNC, "reject PB-TNC message 0x%06x/0x%08x)",
DBG1(DBG_TNC, "reject PB-TNC message (0x%06x/0x%08x)",
vendor_id, msg_type);
msg = pb_error_msg_create_with_offset(TRUE, PEN_IETF,
PB_ERROR_UNSUPPORTED_MANDATORY_MSG, this->offset);
@@ -416,7 +424,7 @@ static status_t process_tnc_msg(private_pb_tnc_batch_t *this)
}
else
{
DBG1(DBG_TNC, "ignore PB-TNC message 0x%06x/0x%08x)",
DBG1(DBG_TNC, "ignore PB-TNC message (0x%06x/0x%08x)",
vendor_id, msg_type);
this->offset += msg_len;
return SUCCESS;
@@ -0,0 +1,92 @@
/*
* Copyright (C) 2015 Andreas Steffen
* HSR Hochschule fuer Technik Rapperswil
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/
#include "pb_noskip_test_msg.h"
typedef struct private_pb_noskip_test_msg_t private_pb_noskip_test_msg_t;
/**
* Private data of a pb_noskip_test_msg_t object.
*
*/
struct private_pb_noskip_test_msg_t {
/**
* Public pb_noskip_test_msg_t interface.
*/
pb_noskip_test_msg_t public;
/**
* PB-TNC message type
*/
pen_type_t type;
/**
* Encoded message
*/
chunk_t encoding;
};
METHOD(pb_tnc_msg_t, get_type, pen_type_t,
private_pb_noskip_test_msg_t *this)
{
return this->type;
}
METHOD(pb_tnc_msg_t, get_encoding, chunk_t,
private_pb_noskip_test_msg_t *this)
{
return this->encoding;
}
METHOD(pb_tnc_msg_t, build, void,
private_pb_noskip_test_msg_t *this)
{
/* nothing to do since the message is empty */
}
METHOD(pb_tnc_msg_t, process, status_t,
private_pb_noskip_test_msg_t *this, u_int32_t *offset)
{
return SUCCESS;
}
METHOD(pb_tnc_msg_t, destroy, void,
private_pb_noskip_test_msg_t *this)
{
free(this);
}
/**
* See header
*/
pb_tnc_msg_t *pb_noskip_test_msg_create(void)
{
private_pb_noskip_test_msg_t *this;
INIT(this,
.public = {
.pb_interface = {
.get_type = _get_type,
.get_encoding = _get_encoding,
.build = _build,
.process = _process,
.destroy = _destroy,
},
},
.type = { PEN_ITA, PB_ITA_MSG_NOSKIP_TEST },
);
return &this->public.pb_interface;
}
@@ -0,0 +1,44 @@
/*
* Copyright (C) 2015 Andreas Steffen
* HSR Hochschule fuer Technik Rapperswil
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/
/**
* @defgroup pb_noskip_test_msg pb_noskip_test_msg
* @{ @ingroup tnccs_20
*/
#ifndef PB_NOSKIP_TEST_MSG_H_
#define PB_NOSKIP_TEST_MSG_H_
typedef struct pb_noskip_test_msg_t pb_noskip_test_msg_t;
#include "messages/pb_tnc_msg.h"
/**
* Class representing the PB-Noskip-Test message type.
*/
struct pb_noskip_test_msg_t {
/**
* PB-TNC Message interface
*/
pb_tnc_msg_t pb_interface;
};
/**
* Create a PB-Noskip-Test message from parameters
*/
pb_tnc_msg_t* pb_noskip_test_msg_create(void);
#endif /** PB_NOSKIP_TEST_MSG_H_ @}*/
@@ -43,8 +43,9 @@ ENUM(pb_tnc_tcg_msg_type_names, PB_TCG_MSG_PDP_REFERRAL,
"PB-PDP-Referral"
);
ENUM(pb_tnc_ita_msg_type_names, PB_ITA_MSG_MUTUAL_CAPABILITY,
ENUM(pb_tnc_ita_msg_type_names, PB_ITA_MSG_NOSKIP_TEST,
PB_ITA_MSG_MUTUAL_CAPABILITY,
"PB-Noskip-Test",
"PB-Mutual-Capability"
);
@@ -65,7 +66,7 @@ pb_tnc_msg_info_t pb_tnc_tcg_msg_infos[] = {
};
pb_tnc_msg_info_t pb_tnc_ita_msg_infos[] = {
{ 0 }, /* dummy entry because pb_tnc_ita_msg_type_t starts with 1 */
{ 12, TRUE, FALSE, TRUE },
{ 16, FALSE, FALSE, FALSE },
};
@@ -54,6 +54,7 @@ extern enum_name_t *pb_tnc_msg_type_names;
* PB-TNC Message Type defined in the TCG namespace
*/
enum pb_tnc_tcg_msg_type_t {
PB_TCG_MSG_RESERVED = 0,
PB_TCG_MSG_PDP_REFERRAL = 1,
PB_TCG_MSG_ROOF = 1
};
@@ -67,6 +68,7 @@ extern enum_name_t *pb_tnc_tcg_msg_type_names;
* PB-TNC Message Type defined in the ITA namespace
*/
enum pb_tnc_ita_msg_type_t {
PB_ITA_MSG_NOSKIP_TEST = 0,
PB_ITA_MSG_MUTUAL_CAPABILITY = 1,
PB_ITA_MSG_ROOF = 1
};
@@ -23,6 +23,7 @@
#include "messages/ietf/pb_reason_string_msg.h"
#include "messages/ietf/pb_language_preference_msg.h"
#include "messages/ita/pb_mutual_capability_msg.h"
#include "messages/ita/pb_noskip_test_msg.h"
#include "messages/tcg/pb_pdp_referral_msg.h"
#include "state_machine/pb_tnc_state_machine.h"
@@ -674,6 +675,16 @@ METHOD(tnccs_20_handler_t, begin_handshake, void,
this->send_msg = TRUE;
tnc->imcs->begin_handshake(tnc->imcs, this->connection_id);
this->send_msg = FALSE;
/* Send a PB-Noskip-Test message for testing purposes */
if (lib->settings->get_bool(lib->settings,
"%s.plugins.tnccs-20.tests.pb_tnc_noskip", FALSE, lib->ns))
{
msg = pb_noskip_test_msg_create();
this->mutex->lock(this->mutex);
this->messages->insert_last(this->messages, msg);
this->mutex->unlock(this->mutex);
}
}
METHOD(tnccs_20_handler_t, get_send_flag, bool,
@@ -23,6 +23,7 @@
#include "messages/ietf/pb_reason_string_msg.h"
#include "messages/ietf/pb_language_preference_msg.h"
#include "messages/ita/pb_mutual_capability_msg.h"
#include "messages/ita/pb_noskip_test_msg.h"
#include "messages/tcg/pb_pdp_referral_msg.h"
#include "state_machine/pb_tnc_state_machine.h"
@@ -547,6 +548,16 @@ METHOD(tnccs_20_handler_t, begin_handshake, void,
this->messages->insert_last(this->messages, msg);
this->mutex->unlock(this->mutex);
}
/* Send a PB-Noskip-Test message for testing purposes */
if (lib->settings->get_bool(lib->settings,
"%s.plugins.tnccs-20.tests.pb_tnc_noskip", FALSE, lib->ns))
{
msg = pb_noskip_test_msg_create();
this->mutex->lock(this->mutex);
this->messages->insert_last(this->messages, msg);
this->mutex->unlock(this->mutex);
}
}
METHOD(tnccs_20_handler_t, get_send_flag, bool,