Commit 0c3f0de4 authored by garciay's avatar garciay
Browse files

Add first AA tests

parent c30d2e87
......@@ -6,6 +6,7 @@
#include "etsi_ts102941_types_authorization_inner_request.hh"
#include "etsi_ts102941_types_authorization_inner_response.hh"
#include "etsi_ts102941_types_authorization_shared_at_request.hh"
#include "etsi_ts102941_types_authorization_validation_request.hh"
#include "loggers.hh"
......@@ -172,4 +173,31 @@ namespace LibItsPki__EncdecDeclarations {
return 0;
}
BITSTRING fx__enc__AuthorizationValidationRequest(EtsiTs102941TypesAuthorizationValidation::AuthorizationValidationRequest const& p_shared_at) {
loggers::get_instance().log_msg(">>> fx__enc__AuthorizationValidationRequest: ", p_shared_at);
etsi_ts102941_types_authorization_validation_request codec;
OCTETSTRING os;
if (codec.encode(p_shared_at, os) == -1) {
loggers::get_instance().warning("fx__enc__AuthorizationValidationRequest: -1 result code was returned");
return int2bit(0, 1);
}
return oct2bit(os);
}
INTEGER fx__dec__AuthorizationValidationRequest(BITSTRING& b, EtsiTs102941TypesAuthorizationValidation::AuthorizationValidationRequest& p_shared_at) {
loggers::get_instance().log_msg(">>> fx__dec__AuthorizationValidationRequest: ", b);
etsi_ts102941_types_authorization_validation_request codec;
OCTETSTRING is = bit2oct(b);
if (codec.decode(is, p_shared_at) == -1) {
loggers::get_instance().warning("fx__dec__AuthorizationValidationRequest: -1 result code was returned");
return -1;
}
loggers::get_instance().log_msg("<<< fx__dec__AuthorizationValidationRequest: ", p_shared_at);
return 0;
}
} // End of namespace LibItsPki__EncdecDeclarations
......@@ -595,7 +595,7 @@ namespace LibItsSecurity__Functions
// TODO Use common function for both fx__encryptWithEciesxxx and fx__decryptWithEciesxxx function
OCTETSTRING fx__encryptWithEciesNistp256WithSha256(const OCTETSTRING& p__toBeEncryptedSecuredMessage, const OCTETSTRING& p__recipientsPublicKeyCompressed, const INTEGER& p__compressedMode, OCTETSTRING& p__publicEphemeralKeyCompressed, INTEGER& p__ephemeralCompressedMode, OCTETSTRING& p__encrypted__sym__key, OCTETSTRING& p__authentication__vector, OCTETSTRING& p__nonce) {
loggers::get_instance().log_msg(">>> fx__encryptWithEciesNistp256WithSha256: p__toBeEncryptedSecuredMessage: ", p__toBeEncryptedSecuredMessage);
loggers::get_instance().log_msg(">>> fx__encryptWithEciesNistp256WithSha256: p__recipientsPublicKeyX: ", p__recipientsPublicKeyCompressed);
loggers::get_instance().log_msg(">>> fx__encryptWithEciesNistp256WithSha256: p__recipientsPublicKeyCompressed", p__recipientsPublicKeyCompressed);
loggers::get_instance().log(">>> fx__encryptWithEciesNistp256WithSha256: p__compressedMode: %d", static_cast<int>(p__compressedMode));
// 1. Generate new Private/Public key
......
......@@ -67,19 +67,30 @@ void pki_layer::sendMsg(const EtsiTs102941TypesEnrolment::InnerEcRequest& p_inne
return;
}
loggers::get_instance().log_msg("<<< pki_layer::generate_inner_ec_request_signed_for_pop: ", etsi_ts_102941_data);
loggers::get_instance().log_msg("<<< pki_layer::sendMsg: ", etsi_ts_102941_data);
send_data(etsi_ts_102941_data, _params);
}
void pki_layer::sendMsg(const EtsiTs102941TypesEnrolment::InnerEcResponse& p_inner_ec_response, params& p_param) {
loggers::get_instance().log_msg(">>> pki_layer::sendMsg: ", p_inner_ec_response);
OCTETSTRING inner_ec_response;
_etsi_ts102941_types_enrolment_inner_response.encode(p_inner_ec_response, inner_ec_response);
// Create the EtsiTs102941Data layer
EtsiTs102941MessagesItss::EtsiTs102941Data etsi_ts_102941_data;
etsi_ts_102941_data.content().enrolmentResponse() = p_inner_ec_response;
loggers::get_instance().log_msg("pki_layer::sendMsg: InnerEcResponse: ", etsi_ts_102941_data);
// Encode it
OCTETSTRING etsi_ts_103097_data_enc;
_codec_etsi_ts102941_data.encode(etsi_ts_102941_data, etsi_ts_103097_data_enc);
if (!etsi_ts_103097_data_enc.is_bound()) {
loggers::get_instance().warning("pki_layer::sendMsg: Failed to encode InnerEcResponse");
}
loggers::get_instance().log_msg("pki_layer::sendMsg: etsi_ts_103097_data_enc: ", etsi_ts_103097_data_enc);
// Secured the EtsiTs102941Data layer
OCTETSTRING secured_inner_ec_response;
if (sign_and_encrypt_payload(inner_ec_response, secured_inner_ec_response, p_param) == 0) {
if (sign_and_encrypt_payload(etsi_ts_103097_data_enc, secured_inner_ec_response, p_param) == 0) {
send_data(secured_inner_ec_response, _params);
}
}
......@@ -92,7 +103,9 @@ void pki_layer::sendMsg(const EtsiTs102941TypesAuthorizationValidation::Authoriz
loggers::get_instance().error("pki_layer::sendMsg: Security data missing");
return;
}
// FIXME Encapsulate p_authorization_validation_request into EtsiTs102941Data first
OCTETSTRING authorization_validation_request;
_etsi_ts102941_types_authorization_validation_request.encode(p_authorization_validation_request, authorization_validation_request);
// Secured the EtsiTs102941Data layer
......
......@@ -11,7 +11,7 @@ public:
explicit etsi_ts102941_types_authorization_validation_request() : codec<EtsiTs102941TypesAuthorizationValidation::AuthorizationValidationRequest, EtsiTs102941TypesAuthorizationValidation::AuthorizationValidationRequest>() { };
virtual ~etsi_ts102941_types_authorization_validation_request() { };
virtual int encode (const EtsiTs102941TypesAuthorizationValidation::AuthorizationValidationRequest& p_validation_request, OCTETSTRING& p_data);
virtual int decode (const OCTETSTRING& p_data, EtsiTs102941TypesAuthorizationValidation::AuthorizationValidationRequest& p_validation_request, params* p_params = NULL);
virtual int encode (const EtsiTs102941TypesAuthorizationValidation::AuthorizationValidationRequest& p_authorization_validation_request, OCTETSTRING& p_data);
virtual int decode (const OCTETSTRING& p_data, EtsiTs102941TypesAuthorizationValidation::AuthorizationValidationRequest& p_authorization_validation_request, params* p_params = NULL);
}; // End of class etsi_ts102941_types_authorization_validation_request
......@@ -135,6 +135,7 @@ system.utPort.params := "UT_PKI/UDP(dst_ip=172.23.0.1,dst_port=8000)"
#ItsPki_TestCases.TC_SEC_PKI_SND_EA_BV_09
#ItsPki_TestCases.TC_SEC_PKI_SND_EA_BV_10
ItsPki_TestCases.TC_SEC_PKI_SND_EA_BV_11
#ItsPki_TestCases.TC_SEC_PKI_SND_EA_BV_12
[MAIN_CONTROLLER]
# The options herein control the behavior of MC.
......
......@@ -344,7 +344,10 @@ system.pkiPort.params := "PKI/HTTP(device_mode=1,uri=/its/inner_ec_request,host=
#TestCodec_Pki.tc_inner_ec_request_3
#TestCodec_Pki.tc_inner_ec_response_1
#TestCodec_Pki.tc_inner_ec_response_2
TestCodec_Pki.tc_inner_ec_functions_1
#TestCodec_Pki.tc_inner_ec_functions_1
#TestCodec_Pki.tc_inner_ec_functions_2
#TestCodec_Pki.tc_inner_ec_functions_3
TestCodec_Pki.tc_inner_ec_functions_4
[MAIN_CONTROLLER]
# The options herein control the behavior of MC.
......
This diff is collapsed.
Subproject commit b31f565ae97899e5bf9f80e65130b0ba177fbcc4
Subproject commit a1a1ccbca9016e26be86f0129a1f31b2252ed0dc
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment