Commit b31f565a authored by Yann Garcia's avatar Yann Garcia
Browse files

Add unit tests

parent 6c6c9f38
......@@ -47,17 +47,4 @@ module LibItsHttp_BinaryTemplates {
ieee1609dot2_data := p_ieee1609dot2_data
} // End of template mw_binary_body_ieee1609dot2_data
// Move to Pki
// template (present) BinaryBody mw_binary_body_innerEcRequest(
// template (present) InnerEcRequest p_innerEcRequest := ?
// ) := {
// innerEcRequest := p_innerEcRequest
// } // End of template mw_binary_body_innerEcRequest
//
// template (present) BinaryBody mw_binary_body_innerEcResponse(
// template (present) InnerEcResponse p_innerEcResponse := ?
// ) := {
// innerEcResponse := p_innerEcResponse
// } // End of template mw_binary_body_innerEcResponse
//
} // End of module LibItsHttp_BinaryTemplates
......@@ -188,13 +188,14 @@ module LibItsPki_Functions {
group ac_port {
function f_sendAcPkiPrimitive(
in charstring p_certificate,
in octetstring p_private_key,
in octetstring p_publicKeyCompressed,
in integer p_compressedMode
) runs on ItsPki {
var AcSetSecurityData v_ac_set_security_data;
v_ac_set_security_data := { PICS_TS_CERTIFICATE_ID, PICS_IUT_CERTIFICATE_ID, p_private_key, p_publicKeyCompressed, p_compressedMode };
v_ac_set_security_data := { p_certificate, PICS_IUT_CERTIFICATE_ID, p_private_key, p_publicKeyCompressed, p_compressedMode };
acPort.send(AcPkiPrimitive: { acSetSecurityData := v_ac_set_security_data });
tc_ac.start;
alt {
......@@ -278,26 +279,26 @@ module LibItsPki_Functions {
group http {
function f_http_build_enrolment_request(
function f_http_build_inner_ec_request(
out octetstring p_private_key,
out octetstring p_publicKeyX,
out octetstring p_publicKeyY,
out octetstring p_publicKeyCompressed,
out integer p_compressedMode,
out Ieee1609Dot2Data p_ieee1609dot2_signed_and_encrypted_data,
out Oct32 p_hash_inner_ec_request_signed_for_pop
) runs on ItsPkiHttp {
var octetstring v_publicKeyX;
var octetstring v_publicKeyY
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;
if (f_generate_inner_ec_request(p_private_key, p_publicKeyX, p_publicKeyY, p_publicKeyCompressed, p_compressedMode, v_inner_ec_request) == false) {
log("*** f_http_build_enrolment_request: ERROR: Failed to generate InnerEcRequest ***");
if (f_generate_inner_ec_request(p_private_key, p_publicKeyCompressed, p_compressedMode, v_inner_ec_request) == false) {
log("*** f_http_build_inner_ec_request: ERROR: Failed to generate InnerEcRequest ***");
f_selfOrClientSyncAndVerdict("error", e_error);
}
// Generate InnerEcRequestSignedForPoP
if (f_generate_inner_ec_request_signed_for_pop(p_private_key, v_inner_ec_request, v_inner_ec_request_signed_for_pop) == false) {
log("*** f_http_build_enrolment_request: ERROR: Failed to generate InnerEcRequestSignedForPop ***");
log("*** f_http_build_inner_ec_request: ERROR: Failed to generate InnerEcRequestSignedForPop ***");
f_selfOrClientSyncAndVerdict("error", e_error);
}
// Secure InnerEcRequestSignedForPoP message
......@@ -305,18 +306,16 @@ module LibItsPki_Functions {
// Prepae for getting the 16 most bytes of SHA256 of InnerEcRequestSignedForPop
p_hash_inner_ec_request_signed_for_pop := f_hashWithSha256(bit2oct(v_inner_ec_request_signed_for_pop_msg));
if (f_build_pki_secured_message(vc_eaPrivateKey, valueof(m_signerIdentifier_self), vc_eaHashedId8, p_publicKeyCompressed, p_compressedMode, bit2oct(v_inner_ec_request_signed_for_pop_msg), p_ieee1609dot2_signed_and_encrypted_data) == false) {
log("*** f_http_build_enrolment_request: ERROR: Failed to generate InnerEcRequestSignedForPop ***");
log("*** f_http_build_inner_ec_request: ERROR: Failed to generate InnerEcRequestSignedForPop ***");
f_selfOrClientSyncAndVerdict("error", e_error);
}
log("*** f_http_build_enrolment_request: DEBUG: v_inner_ec_request_signed_for_pop_msg= ", v_inner_ec_request_signed_for_pop_msg);
log("*** f_http_build_enrolment_request: DEBUG: p_ieee1609dot2_signed_and_encrypted_data= ", p_ieee1609dot2_signed_and_encrypted_data);
log("*** f_http_build_enrolment_request: DEBUG: p_hash_inner_ec_request_signed_for_pop= ", p_hash_inner_ec_request_signed_for_pop);
} // End of function f_http_build_enrolment_request
log("*** f_http_build_inner_ec_request: DEBUG: v_inner_ec_request_signed_for_pop_msg= ", v_inner_ec_request_signed_for_pop_msg);
log("*** f_http_build_inner_ec_request: DEBUG: p_ieee1609dot2_signed_and_encrypted_data= ", p_ieee1609dot2_signed_and_encrypted_data);
log("*** f_http_build_inner_ec_request: DEBUG: p_hash_inner_ec_request_signed_for_pop= ", p_hash_inner_ec_request_signed_for_pop);
} // End of function f_http_build_inner_ec_request
function f_http_build_invalid_enrolment_request(
out octetstring p_private_key,
out octetstring p_publicKeyX,
out octetstring p_publicKeyY,
out octetstring p_publicKeyCompressed,
out integer p_compressedMode,
out Ieee1609Dot2Data p_ieee1609dot2_signed_and_encrypted_data,
......@@ -326,7 +325,7 @@ module LibItsPki_Functions {
var Ieee1609Dot2Data v_inner_ec_request_signed_for_pop;
var bitstring v_inner_ec_request_signed_for_pop_msg;
if (f_generate_inner_ec_request(p_private_key, p_publicKeyX, p_publicKeyY, p_publicKeyCompressed, p_compressedMode, v_inner_ec_request) == false) {
if (f_generate_inner_ec_request(p_private_key, p_publicKeyCompressed, p_compressedMode, v_inner_ec_request) == false) {
log("*** f_http_build_invalid_enrolment_request: ERROR: Failed to generate InnerEcRequest ***");
f_selfOrClientSyncAndVerdict("error", e_error);
}
......@@ -346,6 +345,15 @@ module LibItsPki_Functions {
log("*** f_http_build_invalid_enrolment_request: DEBUG: p_ieee1609dot2_signed_and_encrypted_data = ", p_ieee1609dot2_signed_and_encrypted_data);
} // End of function f_http_build_invalid_enrolment_request
function f_http_build_authorization_validation_request(
out octetstring p_private_key,
out octetstring p_publicKeyCompressed,
out integer p_compressedMode,
out Ieee1609Dot2Data p_ieee1609dot2_signed_and_encrypted_data
) runs on ItsPkiHttp {
log("*** f_http_build_invalid_enrolment_request: DEBUG: p_ieee1609dot2_signed_and_encrypted_data = ", p_ieee1609dot2_signed_and_encrypted_data);
}
} // End of group http
group generate_certificates {
......@@ -460,18 +468,18 @@ module LibItsPki_Functions {
function f_generate_inner_ec_request(
out octetstring p_private_key,
out octetstring p_publicKeyX,
out octetstring p_publicKeyY,
out octetstring p_publicKeyCompressed,
out integer p_compressedMode,
out InnerEcRequest p_inner_ec_request
) return boolean {
// Local variables
var Oct32 v_publicKeyX;
var Oct32 v_publicKeyY;
var EccP256CurvePoint v_eccP256_curve_point;
log (">>> f_generate_inner_ec_request");
// Generate keys for the certificate to be requested
if (f_generate_key_pair_nistp256(p_private_key, p_publicKeyX, p_publicKeyY, p_publicKeyCompressed, p_compressedMode) == false) {
if (f_generate_key_pair_nistp256(p_private_key, v_publicKeyX, v_publicKeyY, p_publicKeyCompressed, p_compressedMode) == false) {
log ("f_generate_inner_ec_request: failed to generate keys");
return false;
}
......@@ -588,14 +596,14 @@ module LibItsPki_Functions {
in HashedId8 p_eaHashedId8,
in boolean p_itss_privacy,
out octetstring p_private_enc_key,
out octetstring p_publicEncKeyX,
out octetstring p_publicEncKeyY,
out octetstring p_publicEncKeyCompressed,
out integer p_compressedMode,
out InnerAtRequest p_inner_at_request,
out Ieee1609Dot2Data p_inner_at_request_data
) return boolean {
// Local variables
var octetstring public_enc_key_x;
var octetstring public_enc_key_y;
var template (value) EccP256CurvePoint v_eccP256_curve_point;
var Oct32 v_hmac_key;
var octetstring v_message_to_tag;
......@@ -607,7 +615,7 @@ module LibItsPki_Functions {
var Ieee1609Dot2Data v_signed_ec_signature;
// Generate encryption keys for the certificate to be requested
if (f_generate_key_pair_nistp256(p_private_enc_key, p_publicEncKeyX, p_publicEncKeyY, p_publicEncKeyCompressed, p_compressedMode) == false) {
if (f_generate_key_pair_nistp256(p_private_enc_key, public_enc_key_x, public_enc_key_y, p_publicEncKeyCompressed, p_compressedMode) == false) {
return false;
}
if (p_compressedMode == 0) {
......@@ -785,14 +793,16 @@ module LibItsPki_Functions {
in Certificate p_certificate,
out AuthorizationValidationRequest p_authorization_validation_request
) return boolean {
// TODO
return false;
p_authorization_validation_request.sharedAtRequest := p_inner_at_request.sharedAtRequest;
p_authorization_validation_request.ecSignature := p_inner_at_request.ecSignature;
return true;
} // End of function f_generate_authorization_validation_request
function f_generate_authorization_validation_response(
in InnerAtRequest p_inner_at_request,
in Certificate p_certificate,
out AuthorizationValidationRequest p_authorization_validation_request
out AuthorizationValidationResponse p_authorization_validation_response
) return boolean {
// TODO
return false;
......
......@@ -21,10 +21,20 @@ module LibItsPki_Pics {
modulepar charstring PICS_IUT_CERTIFICATE_ID := "CERT_IUT_A_EA";
/**
* @desc Certificate used by the Test System
* @desc Certificate used by the Test System acting as ITS-S
*/
modulepar charstring PICS_TS_CERTIFICATE_ID := "CERT_TS_A_EA";
/**
* @desc Certificate used by the Test System acting as EA
*/
modulepar charstring PICS_TS_EA_CERTIFICATE_ID := "CERT_TS_A_EA";
/**
* @desc Certificate used by the Test System acting as AA
*/
modulepar charstring PICS_TS_AA_CERTIFICATE_ID := "CERT_TS_A_EA";
/**
* @desc Certificate used by the Test System
*/
......
......@@ -78,6 +78,11 @@ module LibItsPki_Templates {
) modifies m_etsiTs103097Data_encrypted := {
} // End of template m_authorizationValidationRequestMessage
template (present) EtsiTs103097Data mw_authorizationValidationResponseMessage(
template (present) EncryptedData p_encryptedData := ?
) modifies mw_etsiTs103097Data_encrypted := {
} // End of template mw_authorizationValidationResponseMessage
template (present) EnrolmentRequestMessage mw_enrolmentRequestMessage(
template (present) EncryptedData p_encryptedData := ?
) modifies mw_etsiTs103097Data_encrypted := {
......@@ -201,7 +206,7 @@ module LibItsPki_Templates {
in template (omit) GeographicRegion p_region := omit,
in template (omit) SubjectAssurance p_assuranceLevel := omit
) := {
id := { none_ := NULL },
id := { none_ := NULL },
validityPeriod := p_validityPeriod,
region := p_region,
assuranceLevel := p_assuranceLevel,
......
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