Commit 92df19e3 authored by garciay's avatar garciay
Browse files

STF545: Execute first EA tests

parent 7fd2a03a
#include "LibItsPki_EncdecDeclarations.hh"
#include "etsi_ts102941_data.hh"
#include "etsi_ts102941_types_enrolment_inner_request.hh"
#include "etsi_ts102941_types_enrolment_inner_response.hh"
......@@ -7,6 +8,32 @@
namespace LibItsPki__EncdecDeclarations {
BITSTRING fx__enc__EtsiTs102941Data(const EtsiTs102941MessagesItss::EtsiTs102941Data& p_etsi_ts_102941_data) {
loggers::get_instance().log_msg(">>> fx__enc__EtsiTs102941Data: ", p_etsi_ts_102941_data);
etsi_ts102941_data codec;
OCTETSTRING os;
if (codec.encode(p_etsi_ts_102941_data, os) == -1) {
loggers::get_instance().warning("fx__enc__EtsiTs102941Data: -1 result code was returned");
return int2bit(0, 1);
}
return oct2bit(os);
}
INTEGER fx__dec__EtsiTs102941Data(BITSTRING& b, EtsiTs102941MessagesItss::EtsiTs102941Data& p_etsi_ts_102941_data) {
loggers::get_instance().log_msg(">>> fx__dec__EtsiTs102941Data: ", b);
etsi_ts102941_data codec;
OCTETSTRING is = bit2oct(b);
if (codec.decode(is, p_etsi_ts_102941_data) == -1) {
loggers::get_instance().warning("fx__dec__EtsiTs102941Data: -1 result code was returned");
return -1;
}
return 0;
}
BITSTRING fx__enc__InnerEcRequest(const EtsiTs102941TypesEnrolment::InnerEcRequest& p_inner_request) {
loggers::get_instance().log_msg(">>> fx_enc_InnerEcRequest: ", p_inner_request);
......
#include "LibItsCommon_Functions.hh"
#include <chrono>
#include <math.h>
#include "base_time.hh"
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
......@@ -16,13 +17,8 @@ namespace LibItsCommon__Functions
*/
INTEGER fx__getCurrentTime(
) {
unsigned long long ms = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count() - 1072911600000L; // TODO Add a global method such as its_tme() & its_time_mod() beacuse it is used also in geonetworking_layer
/*unsigned long long its_ref_time = 1072911600000L;
struct timeval tv;
gettimeofday(&tv, NULL);
unsigned long long ms = tv.tv_sec * 1000 + tv.tv_usec / 1000;*/
INTEGER i;
i.set_long_long_val(ms);
i.set_long_long_val(base_time::get_instance().get_its_current_time());
return i;
}
/**
......
......@@ -29,6 +29,8 @@ private:
public:
static registration<TItem>& get_instance();
virtual ~registration() { if (_instance != nullptr) delete _instance; };
public:
void add_item(const std::string& type, TItem* f);
TItem * get_item(const std::string& type);
......
#include <thread>
#include <chrono>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/wait.h>
......@@ -13,6 +12,8 @@
#include "security_services.hh"
#include "base_time.hh"
#include "converter.hh"
using namespace LibItsGeoNetworking__TypesAndValues;
......@@ -286,8 +287,7 @@ void geonetworking_layer::receive_data(OCTETSTRING& data, params& params) {
eh->lsReplyHeader().dstPosVector().latitude() = sopv->latitude();
eh->lsReplyHeader().dstPosVector().longitude() = sopv->longitude();
// Update timestamp
unsigned long long ms = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count() - 1072911600000L; // TODO Add method such as its_tme() & its_time_mod() beacuse it is used also in LibItsCommon_externals
eh->lsReplyHeader().srcPosVector().timestamp__().set_long_long_val(ms);
eh->lsReplyHeader().srcPosVector().timestamp__().set_long_long_val(base_time::get_instance().get_its_current_time());
eh->lsReplyHeader().dstPosVector().timestamp__() = eh->lsReplyHeader().srcPosVector().timestamp__();
loggers::get_instance().log_msg("geonetworking_layer::receive_data: ", *_ls_reply);
......@@ -485,8 +485,7 @@ void geonetworking_layer::send_beacon() {
loggers::get_instance().error("geonetworking_layer::send_beacon: Wrong cast");
}
// Update timestamp
unsigned long long ms = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count() - 1072911600000L; // TODO Add method such as its_time() & its_time_mod()
eh->beaconHeader().srcPosVector().timestamp__().set_long_long_val((unsigned int)ms);
eh->beaconHeader().srcPosVector().timestamp__().set_long_long_val((unsigned int)base_time::get_instance().get_its_current_time());
//loggers::get_instance().log_msg("geonetworking_layer::send_beacon: ", *_beacon);
// Encode message using TITAN because of payload in omited
TTCN_Buffer encoding_buffer;
......@@ -943,8 +942,7 @@ int geonetworking_layer::build_geonetworking_pdu(OCTETSTRING& data, params& para
_shb_packet->gnPacket().packet().commonHeader().plLength() = data.lengthof();
_shb_packet->gnPacket().packet().payload() = OPTIONAL<OCTETSTRING>(data);
// Update timestamp
unsigned long long ms = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count() - 1072911600000L; // TODO Add method such as its_tme() & its_time_mod()
eh->shbHeader().srcPosVector().timestamp__().set_long_long_val(static_cast<unsigned int>(ms));
eh->shbHeader().srcPosVector().timestamp__().set_long_long_val(static_cast<unsigned int>(base_time::get_instance().get_its_current_time()));
loggers::get_instance().log_msg("geonetworking_layer::build_geonetworking_pdu: shb: ", *_shb_packet);
// Encode GeoNetworking PDU
......@@ -970,8 +968,7 @@ int geonetworking_layer::build_geonetworking_pdu(OCTETSTRING& data, params& para
_tsb_packet->gnPacket().packet().commonHeader().plLength() = data.lengthof();
_tsb_packet->gnPacket().packet().payload() = OPTIONAL<OCTETSTRING>(data);
// Update timestamp
unsigned long long ms = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count() - 1072911600000L; // TODO Add method such as its_tme() & its_time_mod()
eh->tsbHeader().srcPosVector().timestamp__().set_long_long_val(static_cast<unsigned int>(ms));
eh->tsbHeader().srcPosVector().timestamp__().set_long_long_val(static_cast<unsigned int>(base_time::get_instance().get_its_current_time()));
loggers::get_instance().log_msg("geonetworking_layer::build_geonetworking_pdu: tsb: ", *_tsb_packet);
// Encode GeoNetworking PDU
......@@ -999,8 +996,7 @@ int geonetworking_layer::build_geonetworking_pdu(OCTETSTRING& data, params& para
_gbc_packet->gnPacket().packet().commonHeader().plLength() = data.lengthof();
_gbc_packet->gnPacket().packet().payload() = OPTIONAL<OCTETSTRING>(data);
// Update timestamp
unsigned long long ms = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count() - 1072911600000L; // TODO Add method such as its_tme() & its_time_mod()
eh->geoBroadcastHeader().srcPosVector().timestamp__().set_long_long_val(static_cast<unsigned int>(ms));
eh->geoBroadcastHeader().srcPosVector().timestamp__().set_long_long_val(static_cast<unsigned int>(base_time::get_instance().get_its_current_time()));
loggers::get_instance().log_msg("geonetworking_layer::build_geonetworking_pdu: gbc: ", *_gbc_packet);
......
......@@ -82,7 +82,7 @@ int http_codec::decode (const OCTETSTRING& data, LibItsHttp__TypesAndValues::Htt
response.header() = headers;
loggers::get_instance().log_to_hexa("Before decoding Body: ", decoding_buffer);
LibItsHttp__MessageBodyTypes::HttpMessageBody body;
if (decode_body(decoding_buffer, body) == -1) {
if (decode_body(decoding_buffer, body, std::string("application/x-its-request"/*TODO Add Content-Type*/)) == -1) {
response.body().set_to_omit();
} else {
response.body() = OPTIONAL<LibItsHttp__MessageBodyTypes::HttpMessageBody>(body);
......@@ -106,7 +106,7 @@ int http_codec::decode (const OCTETSTRING& data, LibItsHttp__TypesAndValues::Htt
request.header() = headers;
OPTIONAL<LibItsHttp__MessageBodyTypes::HttpMessageBody> body;
body.set_to_omit();
if (decode_body(decoding_buffer, body) == -1) {
if (decode_body(decoding_buffer, body, std::string("application/x-its-request"/*TODO Add Content-Type*/)) == -1) {
request.body().set_to_omit();
} else {
request.body() = body;
......@@ -375,6 +375,7 @@ int http_codec::decode_header(CHARSTRING& header_line, LibItsHttp__TypesAndValue
int http_codec::encode_body(const LibItsHttp__MessageBodyTypes::HttpMessageBody& p_message_body, OCTETSTRING& p_encoding_buffer, const std::string& p_content_type) {
loggers::get_instance().log_msg(">>> http_codec::encode_body: ", (const Base_Type&)p_message_body);
loggers::get_instance().log("http_codec::encode_body: # of codecs=%d - %p", _codecs.size(), this);
// Sanity check
if (p_content_type.empty()) {
......@@ -446,15 +447,20 @@ int http_codec::encode_body(const LibItsHttp__MessageBodyTypes::HttpMessageBody&
return 0;
}
int http_codec::decode_body(TTCN_Buffer& decoding_buffer, LibItsHttp__MessageBodyTypes::HttpMessageBody& message_body) {
int http_codec::decode_body(TTCN_Buffer& decoding_buffer, LibItsHttp__MessageBodyTypes::HttpMessageBody& message_body, const std::string& p_content_type) {
loggers::get_instance().log(">>> http_codec::decode_body");
loggers::get_instance().log_to_hexa("http_codec::decode_body", decoding_buffer);
loggers::get_instance().log("http_codec::decode_body: # of codecs=%d", _codecs.size());
loggers::get_instance().log("http_codec::decode_body: Content-Type=%s", p_content_type.c_str());
loggers::get_instance().log("http_codec::decode_body: # of codecs=%d - %p", _codecs.size(), this);
// Sanity check
// Sanity checks
if (decoding_buffer.get_len() - decoding_buffer.get_pos() <= 0) {
return -1;
}
/* TODO Uncommentif (p_content_type.empty()) {
loggers::get_instance().warning("http_codec::encode_body: Failed to select a codec for HTTP body payload");
return -1;
}*/
OCTETSTRING s(decoding_buffer.get_len() - decoding_buffer.get_pos(), decoding_buffer.get_data() + decoding_buffer.get_pos());
loggers::get_instance().log_msg("http_codec::decode_body: raw body=", s);
......@@ -497,8 +503,29 @@ int http_codec::decode_body(TTCN_Buffer& decoding_buffer, LibItsHttp__MessageBod
LibItsHttp__MessageBodyTypes::HttpMessageBody v;
if (_dc.is_binary == 0x01) {
LibItsHttp__BinaryMessageBodyTypes::BinaryBody bb;
bb.raw() = body;
message_body.binary__body() = bb;
bool processed = false;
// TODO To be refined adding a string identifier to check which codec to use. E.g. held_code.id() returns "xmlns=\"urn:ietf:params:xml:ns:geopriv:held\">"
if (p_content_type.find("x-its") != std::string::npos) {
loggers::get_instance().log("http_codec::decode_body: Find 'x-its'");
/*std::for_each(
_codecs.cbegin(),
_codecs.cend(),
[](const std::pair<const std::string, std::unique_ptr<codec<Record_Type, Record_Type> > >& p)
{
loggers::get_instance().log("http_codec::decode_body: Key='%s', %p", p.first.c_str(), p.second.get());
}
);*/
if (_codecs["http_its"].get() != nullptr) { // TODO Use params
loggers::get_instance().log("http_codec::decode_body: Call 'http_etsi_ieee1609dot2_codec'");
_codecs["http_its"]->decode(body, bb.ieee1609dot2__data());
processed = true;
}
} // TODO Add new HTTP message codec here
if (!processed) {
loggers::get_instance().warning("http_codec::decode_body: Unsupported HTTP codec, use raw field as default");
bb.raw() = body;
message_body.binary__body() = bb;
}
} else {
// Convert into string
params p;
......
......@@ -60,7 +60,7 @@ private:
int decode_headers(TTCN_Buffer& decoding_buffer, LibItsHttp__TypesAndValues::HeaderLines& headers);
int decode_header(CHARSTRING& header_line, LibItsHttp__TypesAndValues::HeaderLine& header);
int decode_body(TTCN_Buffer& decoding_buffer, LibItsHttp__MessageBodyTypes::HttpMessageBody& message_body);
int decode_body(TTCN_Buffer& decoding_buffer, LibItsHttp__MessageBodyTypes::HttpMessageBody& message_body, const std::string& p_content_type);
int get_line(TTCN_Buffer& buffer, CHARSTRING& to, const bool concatenate_header_lines = false);
}; // End of class http_codec
#include <TTCN3.hh>
#include <chrono>
#include <cmath>
#include "security_services.hh"
......@@ -14,6 +13,8 @@ using namespace std; // Required for isnan()
#include "sha256.hh"
#include "sha384.hh"
#include "base_time.hh"
#include "params.hh"
#include "loggers.hh"
......@@ -156,9 +157,9 @@ int security_services::process_ieee_1609_dot2_signed_data(const IEEE1609dot2::Si
}
} else {
const OPTIONAL<INTEGER>& v = dynamic_cast<const OPTIONAL<INTEGER>& >(header_info.generationTime());
unsigned long long gt = ((INTEGER&)(*v.get_opt_value())).get_long_long_val() * 1000 - 1072911600000L;
unsigned long long gt = ((INTEGER&)(*v.get_opt_value())).get_long_long_val() * 1000 - base_time::get_instance().get_its_base_time();
// Get current time timestamp
unsigned long long ms = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count() - 1072911600000L; // TODO Add method such as its_tme() & its_time_mod() beacuse it is used also in LibItsCommon_externals
unsigned long long ms = base_time::get_instance().get_its_current_time();
loggers::get_instance().log("security_services::process_ieee_1609_dot2_signed_data: generation time check %ld / %ld", header_info.generationTime(), ms);
if (abs((double)gt - (double)ms) >= 5.0) { // TODO Use a params for generation_time_epsilon
loggers::get_instance().warning("security_services::process_ieee_1609_dot2_signed_data: Invalid generation time, discard it");
......@@ -453,7 +454,7 @@ int security_services::sign_payload(const OCTETSTRING& p_unsecured_gn_payload, O
loggers::get_instance().log("security_services::sign_payload: Payload type not set");
// Noting to do
}
unsigned long long ms = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count() - 1072911600000L; // TODO Add method such as its_tme() & its_time_mod() beacuse it is used also in LibItsCommon_externals
unsigned long long ms = base_time::get_instance().get_its_current_time();
INTEGER i;
i.set_long_long_val((unsigned int)ms);
header_info.generationTime() = OPTIONAL<INTEGER>(i);
......
......@@ -7,7 +7,7 @@ LibItsCommon_Pixits.PX_IUT_STATION_ID := 2533729309
LibItsGeoNetworking_Pixits.PX_GN_UPPER_LAYER := e_btpB
LibItsHttp_Pics.PICS_HEADER_HOST := "ptsv2.com"
LibItsHttp_Pics.PICS_HEADER_HOST := "127.0.0.1" #"ptsv2.com"
LibItsHttp_Pics.PICS_HEADER_CONTENT_TYPE := "application/x-its-request"
# Enable Security support
......@@ -106,8 +106,8 @@ LogEventTypes:= Yes
# Single GeoNetworking component port
#system.camPort.params := "CAM(next_header=btpB,header_type=tsb,header_sub_type=sh)/BTP/GN(ll_address=4C5E0C14D2EA,latitude=43551050,longitude=10298730,distanceA=1500,distanceB=1500,angle=0,device_mode=1,beaconing=!)/ETH(mac_src=080027500f9b)/PCAP(mac_src=080027500f9b,nic=eth2,filter=and ether proto 0x8947)"
#system.httpPort.params := "HTTP(codecs=http_its:http_etsi_ieee1609dot2_codec)/TCP(debug=1,server=ptsv2.com,use_ssl=0)"
system.httpPort.params := "HTTP(codecs=http_its:http_etsi_ieee1609dot2_codec)/TCP(server=ptsv2.com)"
system.pkiPort.params := "PKI(certificate=CERT_TS_A_EA,peer_certificate=CERT_IUT_A_EA)/HTTP/TCP(server=ptsv2.com)"
system.httpPort.params := "HTTP(codecs=http_its:http_etsi_ieee1609dot2_codec)/TCP(server=127.0.0.1,port=8000,use_ssl=0)"
system.pkiPort.params := "PKI(certificate=CERT_TS_A_EA,peer_certificate=CERT_IUT_A_EA)/HTTP/TCP(server=127.0.0.1,port=8000,use_ssl=0)"
# GeoNetworking UpperTester port based on UDP
system.utPort.params := "UT_CAM/UDP(dst_ip=172.23.0.1,dst_port=8000)"
......
......@@ -334,9 +334,10 @@ system.httpPort.params := "HTTP(codecs=etsi_ieee1609dot2:etsi_ts102941_codec)/TC
#TestCodec_SignedAndEncryptedMessages.tc_decrypted_signed_message_4
# Pki
#TestCodec_Pki.tc_inner_ec_request_1
TestCodec_Pki.tc_inner_ec_request_2
TestCodec_Pki.tc_inner_ec_request_3
#TestCodec_Pki.tc_inner_ec_request_2
#TestCodec_Pki.tc_inner_ec_request_3
#TestCodec_Pki.tc_inner_ec_response_1
TestCodec_Pki.tc_inner_ec_response_2
[MAIN_CONTROLLER]
# The options herein control the behavior of MC.
......
https://github.com/eclipse/titan.core.git
https://github.com/eclipse/titan.TestPorts.Common_Components.Abstract_Socket.git
https://github.com/eclipse/titan.TestPorts.HTTPmsg.git
https://github.com/eclipse/titan.TestPorts.LANL2asp.git
https://github.com/eclipse/titan.TestPorts.PCAPasp.git
https://github.com/eclipse/titan.TestPorts.PIPEasp.git
https://github.com/eclipse/titan.TestPorts.SCTPasp.git
https://github.com/eclipse/titan.TestPorts.SIPmsg.git
https://github.com/eclipse/titan.TestPorts.SQLasp.git
https://github.com/eclipse/titan.TestPorts.TCPasp.git
https://github.com/eclipse/titan.TestPorts.TELNETasp.git
https://github.com/eclipse/titan.TestPorts.UDPasp.git
......@@ -18,64 +16,25 @@ https://github.com/eclipse/titan.ProtocolModules.DNS.git
https://github.com/eclipse/titan.ProtocolModules.ICMP.git
https://github.com/eclipse/titan.ProtocolModules.ICMPv6.git
https://github.com/eclipse/titan.ProtocolModules.IP.git
https://github.com/eclipse/titan.ProtocolModules.RTP.git
https://github.com/eclipse/titan.ProtocolModules.RTSP.git
https://github.com/eclipse/titan.ProtocolModules.SMPP.git
https://github.com/eclipse/titan.ProtocolModules.SMTP.git
https://github.com/eclipse/titan.ProtocolModules.SNMP.git
https://github.com/eclipse/titan.ProtocolModules.TCP.git
https://github.com/eclipse/titan.ProtocolModules.UDP.git
https://github.com/eclipse/titan.ProtocolModules.XMPP.git
https://github.com/eclipse/titan.EclipsePlug-ins.git
https://github.com/eclipse/titan.misc.git
https://github.com/eclipse/titan.TestPorts.LDAPasp_RFC4511.git
https://github.com/eclipse/titan.TestPorts.LDAPmsg.git
https://github.com/eclipse/titan.TestPorts.Common_Components.Socket-API.git
https://github.com/eclipse/titan.TestPorts.SSHCLIENTasp.git
https://github.com/eclipse/titan.TestPorts.STDINOUTmsg.git
https://github.com/eclipse/titan.TestPorts.SUNRPCasp.git
https://github.com/eclipse/titan.TestPorts.UNIX_DOMAIN_SOCKETasp.git
https://github.com/eclipse/titan.TestPorts.IPL4asp.git
https://github.com/eclipse/titan.ProtocolModules.FrameRelay.git
https://github.com/eclipse/titan.ProtocolModules.H248_v2.git
https://github.com/eclipse/titan.ProtocolModules.IMAP_4rev1.git
https://github.com/eclipse/titan.ProtocolModules.ICAP.git
https://github.com/eclipse/titan.ProtocolModules.IKEv2.git
https://github.com/eclipse/titan.ProtocolModules.IPsec.git
https://github.com/eclipse/titan.ProtocolModules.IUA.git
https://github.com/eclipse/titan.ProtocolModules.JSON_v07_2006.git
https://github.com/eclipse/titan.ProtocolModules.L2TP.git
https://github.com/eclipse/titan.ProtocolModules.M3UA.git
https://github.com/eclipse/titan.ProtocolModules.MIME.git
https://github.com/eclipse/titan.ProtocolModules.MSRP.git
https://github.com/eclipse/titan.ProtocolModules.PPP.git
https://github.com/eclipse/titan.ProtocolModules.ProtoBuff.git
https://github.com/eclipse/titan.ProtocolModules.RADIUS_ProtocolModule_Generator.git
https://github.com/eclipse/titan.ProtocolModules.SRTP.git
https://github.com/eclipse/titan.ProtocolModules.WebSocket.git
https://github.com/eclipse/titan.ProtocolModules.HTTP2.0.git
https://github.com/eclipse/titan.Libraries.TCCUsefulFunctions.git
git://git.eclipse.org/gitroot/titan/titan.ProtocolModules.CoAP.git
git://git.eclipse.org/gitroot/titan/titan.ProtocolModules.DSS1_ETSI.git
git://git.eclipse.org/gitroot/titan/titan.ProtocolModules.DUA.git
git://git.eclipse.org/gitroot/titan/titan.ProtocolModules.EAP.git
git://git.eclipse.org/gitroot/titan/titan.ProtocolModules.GRE.git
git://git.eclipse.org/gitroot/titan/titan.ProtocolModules.M2PA.git
git://git.eclipse.org/gitroot/titan/titan.ProtocolModules.M2UA.git
git://git.eclipse.org/gitroot/titan/titan.ProtocolModules.MobileL3_v13.4.0.git
git://git.eclipse.org/gitroot/titan/titan.ProtocolModules.MongoDB.git
git://git.eclipse.org/gitroot/titan/titan.ProtocolModules.MQTT.git
git://git.eclipse.org/gitroot/titan/titan.ProtocolModules.NDP.git
git://git.eclipse.org/gitroot/titan/titan.ProtocolModules.NTAF.git
git://git.eclipse.org/gitroot/titan/titan.ProtocolModules.ROSE.git
git://git.eclipse.org/gitroot/titan/titan.ProtocolModules.SCTP.git
git://git.eclipse.org/gitroot/titan/titan.ProtocolModules.SDP.git
git://git.eclipse.org/gitroot/titan/titan.ProtocolModules.SNDCP_v7.0.0.git
git://git.eclipse.org/gitroot/titan/titan.ProtocolModules.STOMP.git
git://git.eclipse.org/gitroot/titan/titan.ProtocolModules.STUN_RFC5389.git
git://git.eclipse.org/gitroot/titan/titan.ProtocolModules.SUA.git
git://git.eclipse.org/gitroot/titan/titan.ProtocolModules.TLS.git
git://git.eclipse.org/gitroot/titan/titan.ProtocolModules.WTP.git
git://git.eclipse.org/gitroot/titan/titan.TestPorts.GPIO.git
git://git.eclipse.org/gitroot/titan/titan.TestPorts.MTP3asp.git
git://git.eclipse.org/gitroot/titan/titan.TestPorts.Serial.git
......@@ -297,8 +297,9 @@ module ItsPki_TestCases {
// Test adapter configuration
// Preamble
if (f_generate_innerEcRequestSignedForPop(v_private_key, v_publicKeyX, v_publicKeyY, v_publicKeyCompressed, v_compressedMode, v_inner_ec_request) == false) {
log("*** " & testcasename() & ": FAIL: Failed to setup InnerEcRequestPoP message ***")
// Generate InnerEcRequest
if (f_generate_inner_ec_request(v_private_key, v_publicKeyX, v_publicKeyY, v_publicKeyCompressed, v_compressedMode, v_inner_ec_request) == false) {
log("*** " & testcasename() & ": FAIL: Failed to setup InnerEcRequest message ***")
f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_error);
stop;
}
......@@ -374,9 +375,10 @@ module ItsPki_TestCases {
var Oct32 v_publicKeyCompressed;
var integer v_compressedMode;
var InnerEcRequest v_inner_ec_request;
var Ieee1609Dot2Data v_inner_ec_request_signed_for_pop;
var bitstring v_inner_ec_request_signed_for_pop_msg;
var Ieee1609Dot2Data v_ieee1609dot2_signed_and_encrypted_data;
var HeaderLines v_headers;
var HeaderLines v_headers;
// Test control
......@@ -386,12 +388,21 @@ module ItsPki_TestCases {
// Test adapter configuration
// Preamble
if (f_generate_innerEcRequestSignedForPop(v_private_key, v_publicKeyX, v_publicKeyY, v_publicKeyCompressed, v_compressedMode, v_inner_ec_request) == false) {
// Generate InnerEcRequest
if (f_generate_inner_ec_request(v_private_key, v_publicKeyX, v_publicKeyY, v_publicKeyCompressed, v_compressedMode, v_inner_ec_request) == false) {
log("*** " & testcasename() & ": FAIL: Failed to setup InnerEcRequestPoP message ***")
f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_error);
stop;
}
// Generate InnerEcRequestSignedForPoP
if (f_generate_inner_ec_request_signed_for_pop(v_private_key, v_inner_ec_request, v_inner_ec_request_signed_for_pop) == false) {
log("*** " & testcasename() & ": FAIL: Failed to setup InnerEcRequestPoP message ***")
f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_error);
stop;
}
if (f_buildPkiSecuredinnerEcRequestSignedForPop(v_private_key, v_publicKeyCompressed, v_compressedMode, v_inner_ec_request, v_ieee1609dot2_signed_and_encrypted_data) == false) {
// Secure InnerEcRequestSignedForPoP message
v_inner_ec_request_signed_for_pop_msg := encvalue(v_inner_ec_request_signed_for_pop);
if (f_build_pki_secured_message(v_private_key, v_publicKeyCompressed, v_compressedMode, bit2oct(v_inner_ec_request_signed_for_pop_msg), v_ieee1609dot2_signed_and_encrypted_data) == false) {
log("*** " & testcasename() & ": FAIL: Failed to seucure InnerEcRequestPoP message ***")
f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_error);
stop;
......@@ -403,13 +414,13 @@ module ItsPki_TestCases {
// Test Body
httpPort.send(
m_http_request(
m_http_request_post(
"/",
v_headers,
m_http_message_body_binary(
m_binary_body_ieee1609dot2_data(
v_ieee1609dot2_signed_and_encrypted_data
)))));
m_http_request_get(
"/its/inner_ec_request",
v_headers,
m_http_message_body_binary(
m_binary_body_ieee1609dot2_data(
v_ieee1609dot2_signed_and_encrypted_data
)))));
tc_ac.start;
alt {
[] httpPort.receive(
......
......@@ -114,7 +114,117 @@ module TestCodec_Pki {
setverdict(pass, "Encoding passed.");
} // End of testcase tc_inner_ec_request_1
testcase tc_inner_ec_request_2() runs on ItsPki system ItsPkiSystem {
testcase tc_inner_ec_request_2() runs on TCType system TCType {
var Oct32 v_private_key;
var Oct32 v_publicKeyX;
var Oct32 v_publicKeyY;
var Oct32 v_publicKeyCompressed;
var integer v_compressedMode;
var InnerEcRequest v_inner_ec_request;
var Ieee1609Dot2Data v_inner_ec_request_signed_for_pop;
var bitstring v_inner_ec_request_signed_for_pop_msg;
var Ieee1609Dot2Data v_dec_inner_ec_request_signed_for_pop;
var InnerEcRequest v_dec_inner_ec_request;
var bitstring v_dec_inner_ec_request_msg;
var bitstring v_tbs;
var Ieee1609Dot2Data v_ieee1609dot2_signed_and_encrypted_data;
var Ieee1609Dot2Data v_dec_ieee1609dot2_signed_and_encrypted_data;
var Ieee1609Dot2Data v_dec_ieee1609dot2_signed_data;
var bitstring v_ieee1609dot2_signed_and_encrypted_data_msg;
var integer v_result;
if (not(PICS_SEC_FIXED_KEYS)) {
setverdict(inconc, "Please set PICS_SEC_FIXED_KEYS to true");
stop;
}
// Generate InnerEcRequest
if (f_generate_inner_ec_request(v_private_key, v_publicKeyX, v_publicKeyY, v_publicKeyCompressed, v_compressedMode, v_inner_ec_request) == false) {
setverdict(fail, "Failed to generate InnerEcRequest message");
stop;
}
// Generate InnerEcRequestSignedForPoP
if (f_generate_inner_ec_request_signed_for_pop(v_private_key, v_inner_ec_request, v_inner_ec_request_signed_for_pop) == false) {
setverdict(fail, "Failed to setup InnerEcRequestSignedForPoP message");
stop;
}
// Secure InnerEcRequestSignedForPoP message
v_inner_ec_request_signed_for_pop_msg := encvalue(m_etsiTs102941Data_inner_ec_request_signed_for_pop(v_inner_ec_request_signed_for_pop));
if (f_build_pki_secured_message(v_private_key, v_publicKeyCompressed, v_compressedMode, bit2oct(v_inner_ec_request_signed_for_pop_msg), v_ieee1609dot2_signed_and_encrypted_data) == false) {
setverdict(fail, "Failed to secure InnerEcRequest message");
stop;
}
// Encode it
log("To be encoded message: ", v_ieee1609dot2_signed_and_encrypted_data);
v_ieee1609dot2_signed_and_encrypted_data_msg := encvalue(v_ieee1609dot2_signed_and_encrypted_data);
log("Encoded message: ", v_ieee1609dot2_signed_and_encrypted_data_msg);
setverdict(pass, "Encoded succeed");
// Decode encrypted InnerEcRequest
v_result := decvalue(v_ieee1609dot2_signed_and_encrypted_data_msg, v_dec_ieee1609dot2_signed_and_encrypted_data);
if (v_result == 0) {
log("Decoded message: ", v_dec_ieee1609dot2_signed_and_encrypted_data);
setverdict(pass, "Decoded succeed");
if (match(v_dec_ieee1609dot2_signed_and_encrypted_data, v_ieee1609dot2_signed_and_encrypted_data)) {
setverdict(pass, "Decoded match succeed");
} else {
setverdict(fail, "Decoded match failed");
stop;
}
} else {
setverdict(fail, "Decoding failed");
stop;
}
// Decrypt InnerEcRequest
f_decrypt(v_private_key, v_dec_ieee1609dot2_signed_and_encrypted_data, v_dec_ieee1609dot2_signed_data);
log("v_dec_ieee1609dot2_signed_data= ", v_dec_ieee1609dot2_signed_data);
// Verify signature
v_tbs := encvalue(v_dec_ieee1609dot2_signed_data.content.signedData.tbsData);
if (fx_verifyWithEcdsaNistp256WithSha256(
bit2oct(v_tbs),
int2oct(0, 32),
v_dec_ieee1609dot2_signed_data.content.signedData.signature_.ecdsaNistP256Signature.rSig.x_only & v_dec_ieee1609dot2_signed_data.content.signedData.signature_.ecdsaNistP256Signature.sSig,
v_publicKeyCompressed,
v_compressedMode) == true) {
setverdict(pass, "Check signature succeed");
} else {
setverdict(fail, "Check signature failed");
stop;
}
// Extract InnerEcRequestSignedForPop
v_dec_inner_ec_request_msg := oct2bit(v_dec_ieee1609dot2_signed_data.content.signedData.tbsData.payload.data.content.unsecuredData);
v_result := decvalue(v_dec_inner_ec_request_msg, v_dec_inner_ec_request_signed_for_pop);
if (v_result == 0) {
log("Decoded InnerEcRequestSignedForPop: ", v_dec_inner_ec_request_signed_for_pop);
setverdict(pass, "Decoded succeed");
} else {
setverdict(fail, "Decoding failed");
stop;
}
// Extract InnerEcRequest
v_dec_inner_ec_request_msg := oct2bit(v_dec_inner_ec_request_signed_for_pop.content.signedData.tbsData.payload.data.content.unsecuredData);
v_result := decvalue(v_dec_inner_ec_request_msg, v_dec_inner_ec_request);
if (v_result == 0) {
log("Decode InnerEcRequest: ", v_dec_inner_ec_request);
setverdict(pass, "Decoded succeed");
if (match(v_dec_inner_ec_request, v_inner_ec_request)) {
setverdict(pass, "Decoded match succeed");
} else {
setverdict(fail, "Decoded match failed");
stop;
}
} else {
setverdict(fail, "Decoding failed");
stop;
}
} // End of testcase tc_inner_ec_request_2
testcase tc_inner_ec_request_3() runs on ItsPki system ItsPkiSystem {
// Local variables
var Oct32 v_private_key;
var Oct32 v_publicKeyX;
......@@ -127,13 +237,15 @@ module TestCodec_Pki {
setverdict(inconc, "Please set PICS_SEC_FIXED_KEYS to true");
stop;
}
map(self:pkiPort, system:pkiPort);
// Create PKI InnerEcRequest request
if (f_generate_innerEcRequestSignedForPop(v_private_key, v_publicKeyX, v_publicKeyY, v_publicKeyCompressed, v_compressedMode, v_inner_ec_request) == false) {
setverdict(fail, "Failed to setup InnerEcRequestPoP message");
if (f_generate_inner_ec_request(v_private_key, v_publicKeyX, v_publicKeyY, v_publicKeyCompressed, v_compressedMode, v_inner_ec_request) == false) {
setverdict(fail, "Failed to setup InnerEcRequest message");
stop;
}
// Send message
pkiPort.send(v_inner_ec_request);
tc_ac.start;
......@@ -149,19 +261,26 @@ module TestCodec_Pki {
unmap(self:pkiPort, system:pkiPort);
} // End of testcase tc_inner_ec_request_2
} // End of testcase tc_inner_ec_request_3
testcase tc_inner_ec_request_3() runs on TCType system TCType {
testcase tc_inner_ec_response_1() runs on TCType system TCType {
var Oct32 v_private_key;
var Oct32 v_publicKeyX;
var Oct32 v_publicKeyY;
var Oct32 v_publicKeyCompressed;
var integer v_compressedMode;
var bitstring v_ieee1609dot2_signed_and_encrypted_data_msg := oct2bit('03820101837DA6A4D546B31E7B80835BE58FC39F42EB634104671FAF87C3B2C95193D88B0A8F68857C11227C01E908809ED0C1BB8223D5DA6E0B57FA978B23F273E0877B4780EEB550658E2AAF9245804DB1820F92F84641C310A5FD81DCCBA65FA91EB27DC56B378446A44D68AB3754A8555F2061BFD1CD0E39DB425D703FDE7C8237C29FDCB723A6EBAEAB689C359A30CFA282D29BFFF4973AA0D46CBAB91D30AC88FA50422F4366A38287BF5E12FEF76B9B792C49676E872DBCB41B339ECD3DB9739776421F8B1A96B209896B6BDB3C7902BABB74BB883066756B5BD8C19ACEDA91D6A28341BF98A357BCE602A0825BF254B1A15F5DF32D3CA874CC983D2AC23A2A6B79F5BB1B3CE8B8E4BA25DEF4B7D7ED1FCB2264E17838F5662059CA389D23E1F7DC507365297C7CCE31A818BE0328C1BCCC8E6DC4AF70'O);