ItsSecurity_TestCases.ttcn3 817 KB
Newer Older
garciay's avatar
garciay committed
                    
                    v_attrs := v_at_cert.subject_attributes;
                    for (var integer v_counter := 1; v_counter < lengthof(v_attrs); v_counter := v_counter + 1 ) {
                        if (v_attrs[v_counter].type_ <= v_attrs[v_counter-1].type_) {
                            log("*** " & testcasename() & ": FAIL: AT certificate subject attributes are not arranged in ascending order ***");
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                        }
                    } // End of 'for' statement
                    
                    log("*** " & testcasename() & ": PASS: All required AT certificate subject attributes are presents and arranged in ascending order ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                    
                    // Postamble
                    f_poNeighbour();
                    f_cf01Down();
garciay's avatar
garciay committed
                } // End of testcase TC_SEC_ITSS_SND_CERT_AT_04_01_BV
garciay's avatar
garciay committed
                
                /**
                 * @desc Check that time_start_and_end is included in the AT certificate validation restrictions
garciay's avatar
garciay committed
                 *       Check that time_start_and_end is inside the AA certificate time restrictions
                 *       Check that validity restriction of AT certificate is inside the validity restriction of its issuing certificate 
garciay's avatar
garciay committed
                 * <pre>
garciay's avatar
garciay committed
                 * Pics Selection: PICS_GN_SECURITY
garciay's avatar
garciay committed
                 * Config Id: CF01
                 * with {
                 *   the IUT being in the 'authorized' state
                 *   the IUT being requested to include certificate chain in the next CAM
                 * } ensure that {
                 *    when {
                 *     the IUT is requested to send a CAM
                 *   } then {
                 *     the IUT sends a SecuredMessage
                 *       containing header_fields['signer_info'].signer {
                 *         containing type
                 *           indicating certificate_chain
garciay's avatar
garciay committed
                 *         containing certificates[last] 
garciay's avatar
garciay committed
                 *           containing subject_info.subject_type
                 *             indicating 'authorization_ticket' (1)
                 *           not containing validity_restrictions['time_end']
                 *           and not containing validity_restrictions['time_start_and_duration']
garciay's avatar
garciay committed
                 *           and containing validity_restrictions['time_start_and_end'] 
garciay's avatar
garciay committed
                 *             containing start_validity
garciay's avatar
garciay committed
                 *               indicating START_AT_VALIDITY
garciay's avatar
garciay committed
                 *             and containing end_validity
garciay's avatar
garciay committed
                 *               indicating END_AT_VALIDITY
garciay's avatar
garciay committed
                 *         and containing certificates[last-1] 
                 *           containing validity_restrictions['time_end']
                 *             containing end_validity
                 *               indicating value > AT_END_VALIDITY
                 *           or containing validity_restrictions['time_start_and_end']
                 *             containing start_validity
                 *               indicating value <= AT_START_VALIDITY
                 *             containing end_validity
                 *               indicating value > AT_END_VALIDITY
                 *           or containing validity_restrictions['time_start_and_duration']
                 *             containing start_validity
                 *               indicating X_START_VALIDITY <= AT_START_VALIDITY
                 *             and containing duration
                 *               indicating value > AT_END_VALIDITY - X_START_VALIDITY
garciay's avatar
garciay committed
                 *   }
                 * }
                 * </pre>
                 * @see         ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_SND_CERT_AT_05_01_BV
garciay's avatar
garciay committed
                 * @reference   ETSI TS 103 097 [1], clause 7.4.2
garciay's avatar
garciay committed
                 */
garciay's avatar
garciay committed
                testcase TC_SEC_ITSS_SND_CERT_AT_05_01_BV() runs on ItsGeoNetworking system ItsSecSystem {
garciay's avatar
garciay committed
                    var CertificateChain         v_chain;
                    var Certificate              v_aa_cert, v_at_cert;
                    var ValidityRestriction      v_vr, v_aa_vr;
                    
                    // Test control
garciay's avatar
garciay committed
                    if (not(PICS_GN_SECURITY)) {
                        log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY' required for executing the TC ***");
garciay's avatar
garciay committed
                        stop;
                    }
                    
                    // Test component configuration
                    f_cf01Up();
                    
                    // Test adapter configuration
                    
                    // Preamble
                    f_prNeighbour();
                    f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                    
                    // Test Body
                    log("*** " & testcasename() & ": INFO: Request and waiting for the message containing certificate chain  ***");
                    tc_ac.start;
                    if (not f_askAndWaitForCertificateChain(v_chain, f_generateDefaultCam())) {
                        log("*** " & testcasename() & ": INCONC: Expected message not received ***");
                        f_selfOrClientSyncAndVerdictPreamble(c_tbDone, e_timeout);
                    }
                    tc_ac.stop;
                    if (lengthof(v_chain) < 2) {
                        log("*** " & testcasename() & ": FAIL: Certificate chain is too short ***");
                        f_selfOrClientSyncAndVerdictPreamble(c_tbDone, e_error);
                    }
                    v_aa_cert := v_chain[lengthof(v_chain) - 2];
                    v_at_cert := v_chain[lengthof(v_chain) - 1];
                    if (match (
                        v_at_cert.validity_restrictions, 
                        (
                            superset(
                                mw_validity_restriction_time_end,
                                mw_validity_restriction_time_start_and_duration
                            )
                        )
                    )) {
                        log("*** " & testcasename() & ": FAIL: AT certificate must not contain time_end and time_start_and_duration restrictions ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                    }
                    
                    if ( true != f_getCertificateValidityRestriction(v_at_cert, e_time_start_and_end, v_vr)) {
                        log("*** " & testcasename() & ": FAIL: AT certificate must contain time_start_and_end restrictions ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                    }
                    
                    if (v_vr.validity.time_start_and_end.start_validity > v_vr.validity.time_start_and_end.end_validity ) {
                        log("*** " & testcasename() & ": FAIL: start validity must not be greater then end validity in the validity restrictions of AT certificate ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                    }
                    
garciay's avatar
garciay committed
                    if (true == f_getCertificateValidityRestriction(v_aa_cert, e_time_start_and_end, v_aa_vr)) {
                        if (
                            (v_vr.validity.time_start_and_end.start_validity < v_aa_vr.validity.time_start_and_end.start_validity) or 
                            (v_vr.validity.time_start_and_end.end_validity > v_aa_vr.validity.time_start_and_end.end_validity)
                        ) {
                            log("*** " & testcasename() & ": FAIL: AT certificate time validity restriction must be inside the AA certificate time validity restriction ***"); 
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                        }
                    } else if (true == f_getCertificateValidityRestriction(v_aa_cert, e_time_end, v_aa_vr)) {
                        if (v_vr.validity.time_start_and_end.end_validity > v_aa_vr.validity.end_validity) {
                            log("*** " & testcasename() & ": FAIL: AT certificate time validity restriction must be inside the AA certificate time validity restriction ***"); 
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                        }
                    } else if (true == f_getCertificateValidityRestriction(v_aa_cert, e_time_start_and_duration, v_aa_vr)) {
                        var Time64 v_end := v_aa_vr.validity.time_start_and_duration.start_validity + f_duration2time(v_aa_vr.validity.time_start_and_duration.duration_);
                        if (
                            (v_vr.validity.time_start_and_end.start_validity < v_aa_vr.validity.time_start_and_duration.start_validity) or 
                            (v_vr.validity.time_start_and_end.end_validity > v_end)
                        ) {
                            log("*** " & testcasename() & ": FAIL: AT certificate time validity restriction must be inside the AA certificate time validity restriction ***"); 
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                        }
                    } else {
                        log("*** " & testcasename() & ": FAIL: Wrong AA certificate time restrictions ***");
garciay's avatar
garciay committed
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                    }
                    log("*** " & testcasename() & ": PASS: Time validity restriction of the AT certificate is good ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                    
                    // Postamble
                    f_poNeighbour();
                    f_cf01Down();
garciay's avatar
garciay committed
                } // End of testcase TC_SEC_ITSS_SND_CERT_AT_05_01_BV
garciay's avatar
garciay committed
                
                /**
garciay's avatar
garciay committed
                 * @desc Check that all AIDs containing in the its_aid_ssp_list in AT certificate are unique 
                 *       Check that all AIDs containing in the its_aid_ssp_list in AT certificate are also containing in the 
                 *       its_aid_list in the correspondent AA certificate
garciay's avatar
garciay committed
                 *       Check that the length of SSP of each AID is 31 octet maximum
garciay's avatar
garciay committed
                 * <pre>
garciay's avatar
garciay committed
                 * Pics Selection: PICS_GN_SECURITY
garciay's avatar
garciay committed
                 * Config Id: CF01
                 * with {
                 *   the IUT being in the 'authorized' state
                 *   the IUT being requested to include certificate chain in the next CAM
                 * } ensure that {
                 *    when {
                 *     the IUT is requested to send a CAM
                 *   } then {
                 *     the IUT sends a SecuredMessage
garciay's avatar
garciay committed
                 *       containing header_fields['signer_info'].signer
garciay's avatar
garciay committed
                 *         containing type
                 *           indicating certificate_chain
garciay's avatar
garciay committed
                 *         containing certificates[last-1] 
garciay's avatar
garciay committed
                 *           containing subject_info.subject_type
                 *             indicating 'authorization_authority' (2)
                 *           containing subject_attributes['its_aid_list']
                 *             containing its_aid_list[0..N]
                 *               indicating ITS_AID_LIST_AA
garciay's avatar
garciay committed
                 *         containing certificates[last] 
garciay's avatar
garciay committed
                 *           containing subject_info.subject_type
                 *             indicating 'authorization_ticket' (1)
                 *           containing subject_attributes['its_aid_ssp_list']
garciay's avatar
garciay committed
                 *             containing its_aid_ssp_list[0..N] 
                 *               containing its_aid_ssp_list[n]
garciay's avatar
garciay committed
                 *                 containing its_aid
                 *                   indicating unique value containing in the  ITS_AID_LIST_AA
                 *                 containing service_specific_permissions
                 *                   indicating length <= 31 octet
                 *   }
                 * }
                 * </pre>
                 * @see         ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_SND_CERT_AT_07_01_BV
garciay's avatar
garciay committed
                 * @reference   ETSI TS 103 097 [1], clauses 6.9 and 7.4.2
garciay's avatar
garciay committed
                 */
garciay's avatar
garciay committed
                testcase TC_SEC_ITSS_SND_CERT_AT_07_01_BV() runs on ItsGeoNetworking system ItsSecSystem {
garciay's avatar
garciay committed
                    var CertificateChain         v_chain;
                    var Certificate              v_aa_cert, v_at_cert;
                    var SubjectAttribute         v_sa;
                    var IntXs                    v_aid_list;
                    var ItsAidSsps               v_aid_ssp_list;
                    
                    // Test control
garciay's avatar
garciay committed
                    if (not(PICS_GN_SECURITY)) {
                        log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY' required for executing the TC ***");
garciay's avatar
garciay committed
                        stop;
                    }
                    
                    // Test component configuration
                    f_cf01Up();
                    
                    // Test adapter configuration
                    
                    // Preamble
                    f_prNeighbour();
                    f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                    
                    // Test Body
                    log("*** " & testcasename() & ": INFO: Request and waiting for the message containing certificate chain  ***");
                    tc_ac.start;
                    if (not f_askAndWaitForCertificateChain(v_chain, f_generateDefaultCam())) {
                        log("*** " & testcasename() & ": INCONC: Expected message not received ***");
                        f_selfOrClientSyncAndVerdictPreamble(c_tbDone, e_timeout);
                    }
                    tc_ac.stop;
                    if (lengthof(v_chain) < 2) {
                        log("*** " & testcasename() & ": FAIL: Certificate chain is too short ***");
                        f_selfOrClientSyncAndVerdictPreamble(c_tbDone, e_error);
                    }
                    v_aa_cert := v_chain[lengthof(v_chain) - 2];
                    v_at_cert := v_chain[lengthof(v_chain) - 1];
                    if (not f_getCertificateSubjectAttribute(v_aa_cert, e_its_aid_list, v_sa)) {
                        log("*** " & testcasename() & ": FAIL: AA certificate does not contain its_aid_list subject attribute ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                    }
                    v_aid_list := v_sa.attribute.its_aid_list;
                    
                    if (not f_getCertificateSubjectAttribute(v_at_cert, e_its_aid_ssp_list, v_sa)) {
                        log("*** " & testcasename() & ": FAIL: AA certificate does not contain its_aid_list subject attribute ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                    }
                    v_aid_ssp_list := v_sa.attribute.its_aid_ssp_list;
                    
                    for (var integer v_counter :=0; v_counter < lengthof(v_aid_ssp_list); v_counter := v_counter + 1) {
                        // Check unique
                        for (var integer j :=0; j < lengthof(v_aid_ssp_list); j := j + 1) {
                            if (v_counter != j and v_aid_ssp_list[v_counter].its_aid == v_aid_ssp_list[j].its_aid) {
                                log("*** " & testcasename() & ": FAIL: ITS-AID " & int2str(v_aid_ssp_list[v_counter].its_aid) & " is duplicated in AT certificate ***");
                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                            }
                        } // End of 'for' statement
garciay's avatar
garciay committed
//                        if (not match(v_aid_ssp_list[v_counter], (all from v_aid_list))) {
//                            log("*** " & testcasename() & ": FAIL: ITS-AID " & int2str(v_aid_ssp_list[v_counter].its_aid) & " is not exist in AA certificate ***");
//                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
//                        }
garciay's avatar
garciay committed
                        // TODO Not possible due to typing To be removed
garciay's avatar
garciay committed
//                        if (lengthof(v_aid_ssp_list[v_counter].service_specific_permissions.sspContainer) > 31) {
//                            log("*** " & testcasename() & ": FAIL: ITS-AID " & int2str(v_aid_ssp_list[v_counter].its_aid) & " has too long service_specific_permissions ***");
//                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
//                        }
garciay's avatar
garciay committed
                    } // End of 'for' statement
                    
                    log("*** " & testcasename() & ": PASS: The ITS_AID_SSP list of the AT certificate is good ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                    
                    // Postamble
                    f_poNeighbour();
                    f_cf01Down();
garciay's avatar
garciay committed
                } // End of testcase TC_SEC_ITSS_SND_CERT_AT_07_01_BV
garciay's avatar
garciay committed
                
                /**
                 * @desc Check that AT certificate is signed by AA cert
                 * <pre>
garciay's avatar
garciay committed
                 * Pics Selection: PICS_GN_SECURITY
garciay's avatar
garciay committed
                 * Config Id: CF01
                 * with {
                 *   the IUT being in the 'authorized' state
                 *   the IUT being requested to include certificate chain in the next CAM
                 * } ensure that {
                 *    when {
                 *     the IUT is requested to send a first CAM
                 *   } then {
                 *     the IUT sends a SecuredMessage
                 *       containing header_fields['signer_info'].signer {
                 *         containing type
                 *           indicating certificate_chain
                 *         containing certificates[last-1] (CERT_AA) {
                 *           containing subject_info.subject_type
                 *             indicating 'authorization_authority' (2)
                 *           and containing subject_attributes['verification key'] (KEY)
                 *         }
garciay's avatar
garciay committed
                 *         containing certificates[last] 
garciay's avatar
garciay committed
                 *           containing subject_info.subject_type
                 *             indicating 'authorization_ticket' (1)
                 *           }
garciay's avatar
garciay committed
                 *           and containing signer_info[0]
garciay's avatar
garciay committed
                 *             containing type
                 *               indicating 'certificate_digest_with_sha256'
                 *             containing digest
                 *               referencing to CERT_AA
                 *           }
                 *           and containing signature
                 *             verifiable using KEY
                 *   }
                 * }
                 * </pre>
                 * @see         ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_SND_CERT_AT_08_01_BV
                 * @reference   ETSI TS 103 097 [1], clause 6.3
                 */
garciay's avatar
garciay committed
                testcase TC_SEC_ITSS_SND_CERT_AT_08_01_BV() runs on ItsGeoNetworking system ItsSecSystem {
garciay's avatar
garciay committed
                    var CertificateChain         v_chain;
                    var Certificate              v_aa_cert, v_at_cert;
                    var HashedId8                v_aa_digest;
                    
                    // Test control
garciay's avatar
garciay committed
                    if (not(PICS_GN_SECURITY)) {
                        log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY' required for executing the TC ***");
garciay's avatar
garciay committed
                        stop;
                    }
                    
                    // Test component configuration
                    f_cf01Up();
                    
                    // Test adapter configuration
                    
                    // Preamble
                    f_prNeighbour();
                    f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                    
                    
                    // Test Body
                    log("*** " & testcasename() & ": INFO: Request and waiting for the message containing certificate chain  ***");
                    tc_ac.start;
                    if (not f_askAndWaitForCertificateChain(v_chain, f_generateDefaultCam())) {
                        log("*** " & testcasename() & ": INCONC: Expected message not received ***");
                        f_selfOrClientSyncAndVerdictPreamble(c_tbDone, e_timeout);
                    }
                    tc_ac.stop;
                    if (lengthof(v_chain) < 2) {
                        log("*** " & testcasename() & ": FAIL: Certificate chain is too short ***");
                        f_selfOrClientSyncAndVerdictPreamble(c_tbDone, e_error);
                    }
                    v_at_cert := v_chain[lengthof(v_chain) - 1];
                    v_aa_cert := v_chain[lengthof(v_chain) - 2];
                    v_aa_digest := f_calculateDigestFromCertificate(v_aa_cert); 
                    
                    if (not match(v_at_cert, mw_at_certificate(mw_signerInfo_digest(v_aa_digest)))) {
                        log("*** " & testcasename() & ": FAIL: AT certificate signer info doesn't reference the  AA certificate from the chain ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                    }
                    
                    if (not f_verifyCertificateSignatureWithIssuingCertificate(v_at_cert, v_aa_cert)) {
                        log("*** " & testcasename() & ": FAIL: AT certificate signature verification failed ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                    }
                    
                    log("*** " & testcasename() & ": PASS: AT certificate was signed by the AA certificate from the given chain ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                    
                    // Postamble
                    f_poNeighbour();
                    f_cf01Down();
garciay's avatar
garciay committed
                } // End of testcase TC_SEC_ITSS_SND_CERT_AT_08_01_BV
                
garciay's avatar
garciay committed
                /**
garciay's avatar
garciay committed
                 * @desc Check that all necessary validity restrictions are present and arranged in ascending order 
garciay's avatar
garciay committed
                 * <pre>
garciay's avatar
garciay committed
                 * Pics Selection: PICS_GN_SECURITY
garciay's avatar
garciay committed
                 * Config Id: CF01
                 * with {
                 *   the IUT being in the 'authorized' state
garciay's avatar
garciay committed
                 *   the IUT being requested to include certificate in the next CAM
garciay's avatar
garciay committed
                 * } ensure that {
                 *    when {
                 *     the IUT is requested to send a CAM
                 *   } then {
                 *     the IUT sends a SecuredMessage
garciay's avatar
garciay committed
                 *       containing header_fields['signer_info'].signer
garciay's avatar
garciay committed
                 *         containing type
garciay's avatar
garciay committed
                 *           indicating 'certificate'
                 *         containing certificate
                 *           containing subject_attributes [0..N]
                 *             indicating subject_attributes[n].type < subject_attributes[n+ 1].type
                 *             containing subject_attributes['verification_key']
                 *             containing subject_attributes['assurance_level']
                 *             containing subject_attributes['its_aid_ssp_list']
garciay's avatar
garciay committed
                 *   }
                 * }
                 * </pre>
garciay's avatar
garciay committed
                 * @see         ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_SND_CERT_AT_10_01_BV
                 * @reference   ETSI TS 103 097 [1], clauses 6.1
garciay's avatar
garciay committed
                 */
garciay's avatar
garciay committed
                testcase TC_SEC_ITSS_SND_CERT_AT_10_01_BV() runs on ItsGeoNetworking system ItsSecSystem {
garciay's avatar
garciay committed
                    var Certificate             v_at_cert;
                    var ValidityRestriction     v_vr;
                    var ValidityRestrictions    v_vrs;
garciay's avatar
garciay committed
                    
                    // Test control
garciay's avatar
garciay committed
                    if (not(PICS_GN_SECURITY)) {
                        log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY' required for executing the TC ***");
garciay's avatar
garciay committed
                        stop;
                    }
                    
                    // Test component configuration
                    f_cf01Up();
                    
                    // Test adapter configuration
                    
                    // Preamble
                    f_prNeighbour();
                    f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                    
                    // Test Body
garciay's avatar
garciay committed
                    log("*** " & testcasename() & ": INFO: Waiting for the message containing certificate  ***");
garciay's avatar
garciay committed
                    tc_ac.start;
garciay's avatar
garciay committed
                    if (not f_waitForCertificate(v_at_cert)) {
garciay's avatar
garciay committed
                        log("*** " & testcasename() & ": INCONC: Expected message not received ***");
                        f_selfOrClientSyncAndVerdictPreamble(c_tbDone, e_timeout);
                    }
                    tc_ac.stop;
garciay's avatar
garciay committed
                    if (not match(
                        v_at_cert, 
                            mw_at_certificate(
                                mw_signerInfo_certificate
                     ))) {
garciay's avatar
garciay committed
                    }
                    
garciay's avatar
garciay committed
                    if (true != f_getCertificateValidityRestriction(v_at_cert.signer_info.signerInfo.certificate, e_time_start_and_end, v_vr)) {
                        log("*** " & testcasename() & ": FAIL: Required 'time_start_and_end' validity_restriction attribute of AT certificate is not found ***");
garciay's avatar
garciay committed
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                    }
garciay's avatar
garciay committed
                    v_vrs := v_at_cert.signer_info.signerInfo.certificate.validity_restrictions;
                    for (var integer v_counter := 1; v_counter < lengthof(v_vrs); v_counter := v_counter + 1 ) {
                        if (v_vrs[v_counter].type_ <= v_vrs[v_counter-1].type_) {
                            log("*** " & testcasename() & ": FAIL: AT certificate subject attributes are not arranged in ascending order ***");
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                        }
                    } // End of 'for' statement
garciay's avatar
garciay committed
                    
garciay's avatar
garciay committed
                    log("*** " & testcasename() & ": PASS: All required AT certificate subject attributes are presents and arranged in ascending order ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
garciay's avatar
garciay committed
                    
                    // Postamble
                    f_poNeighbour();
                    f_cf01Down();
garciay's avatar
garciay committed
                } // End of testcase TC_SEC_ITSS_SND_CERT_AT_10_01_BV
garciay's avatar
garciay committed
                
            } // End of group AT_Certificates 
            
        } // End of group sendCertificatesProfile
    
    } // End of group sendingBehavior
    
    /**
     * @desc Receiver behaviour test cases
     * @see ETSI TS 103 096-2 V1.2.2 (2016-01) Clause 5.3 Receiver behaviour
     */
    group receiverBehavior {
        
        /**
garciay's avatar
garciay committed
         * @desc Receiving behaviour test cases for CAM profile
garciay's avatar
garciay committed
         * @see ETSI TS 103 096-2 V1.2.2 (2016-01) Clause 5.3.2 CAM Profile
         */
        group recvCamProfile {
            
            /**
             * @desc    Check that IUT accepts a well-formed Secured CAM containing certificate in signer_info
garciay's avatar
garciay committed
             * @remark  The message defined in this test purpose is used in the subsequent test purposes with the snippet name ‘MSG_SEC_RCV_CAM_01’. Only differences to this snippet are mentioned in subsequent test purposes
garciay's avatar
garciay committed
             * <pre>
             * Pics Selection: PICS_GN_SECURITY
             * Config Id: CF01
             * Initial conditions:
             *  with {
             *      the IUT being in the 'authorized' state
             *  }
             *  ensure that {
             *      when { 
             *          the IUT is receiving a SecuredMessage
             *              containing protocol_version 
             *                  indicating value '2'
             *              and containing header_fields[0]
             *                  containing type 
             *                      indicating 'signer_info'
garciay's avatar
garciay committed
             *                  and containing signer 
garciay's avatar
garciay committed
             *                      containing type
             *                          indicating 'certificate'
garciay's avatar
garciay committed
             *                      and containing certificate (CERT_TS_AT_A)
garciay's avatar
garciay committed
             *                          containing subject_info.subject_type
             *                              indicating 'authorization_ticket' (2)
             *                          and containing subject_attributes['verification key'] (KEY)
garciay's avatar
garciay committed
             *              and containing header_fields [1]
garciay's avatar
garciay committed
             *                  containing type
             *                      indicating 'generation_time'
             *                  containing generation_time
             *                      indicating CURRENT_TIME
garciay's avatar
garciay committed
             *              and containing header_fields[2] 
garciay's avatar
garciay committed
             *                  containing type
             *                      indicating 'its_aid'
             *                  containing its_aid
             *                      indicating 'AID_CAM'
             *              and not containing any other header fields
garciay's avatar
garciay committed
             *              and containing payload_field 
garciay's avatar
garciay committed
             *                  containing type
             *                      indicating 'signed'
             *                  containing data
             *                      indicating length > 0
             *                      containing CAM payload
garciay's avatar
garciay committed
             *              and containing trailer_fields 
             *                  containing single instance of type TrailerField
garciay's avatar
garciay committed
             *                      containing type
             *                          indicating 'signature'
             *                      containing signature
             *                          verifiable using KEY
             *      } then {
             *          the IUT accepts the message
             *      }
             *  }
             * </pre>
             *
             * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_RCV_CAM_01_01_BV
             * @reference    ETSI TS 103 097 [1], clause 7.1
             */
            testcase TC_SEC_ITSS_RCV_CAM_01_01_BV() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var integer i;
                var GeoNetworkingPdu v_securedGnPdu;
                var GnRawPayload v_sentRawPayload;
                
                // Test adapter configuration
                if (not(PICS_GN_SECURITY)) {
                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY' required for executing the TC ***");
                    stop;
                }
                
                //  Test component configuration
                f_cf01Up();
                
                // Test adapter configuration
                
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
garciay's avatar
garciay committed
                v_securedGnPdu := f_sendSecuredCam(cc_taCert_A, omit, e_certificate);
                v_sentRawPayload := f_adaptPayloadForUtInd_m(v_securedGnPdu.gnPacket.packet.payload);
                for (i := 0; i < lengthof(vc_utInds) and not match(vc_utInds[i].rawPayload, v_sentRawPayload); i := i + 1) {
garciay's avatar
garciay committed
                    // empty on purpose 
                }
                if (i < lengthof(vc_utInds)) {
garciay's avatar
garciay committed
                    log("*** " & testcasename() & ": PASS: GN was transmitted to upper layer ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
garciay's avatar
garciay committed
                    log("*** " & testcasename() & ": FAIL: GN was not transmitted to upper layer ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                }
                
                // Postamble
                f_poNeighbour();
                f_cf01Down();
garciay's avatar
garciay committed
            } // End of testcase TC_SEC_ITSS_RCV_CAM_01_01_BV
            
garciay's avatar
garciay committed
             * @desc    Check that IUT accepts a well-formed Secured CAM containing certificate digest of the known certificate in signer_info
garciay's avatar
garciay committed
             * @remark  The message defined in this test purpose is used in the subsequent test purposes with the snippet name ‘MSG_SEC_RCV_CAM_02’. Only differences to this snippet are mentioned in subsequent test purposes
garciay's avatar
garciay committed
             * <pre>
             * Pics Selection: PICS_GN_SECURITY
             * Config Id: CF01
             * Initial conditions:
             *  with {
             *      the IUT being in the 'authorized' state
             *      the IUT already sent a Secured message containing certificate (CERT_AT_A)
             *          containing subject_info.subject_type
             *              indicating 'authorization_ticket' (2)
             *          and containing subject_attributes['verification key'] (KEY)
             *  }
             *  ensure that {
             *      when { 
             *          the IUT is receiving a SecuredMessage
             *              containing protocol_version 
             *                  indicating value '2'
             *              and containing header_fields[0]
             *                  containing type 
             *                      indicating 'signer_info'
garciay's avatar
garciay committed
             *                  and containing signer
garciay's avatar
garciay committed
             *                      containing type
             *                          indicating 'certificate_digest_with_sha256'
             *                      and containing digest
             *                          referencing to certificate (CERT_AT_A)
garciay's avatar
garciay committed
             *              and containing header_fields [1]
garciay's avatar
garciay committed
             *                  containing type
             *                      indicating 'generation_time'
             *                  containing generation_time
             *                      indicating CURRENT_TIME
garciay's avatar
garciay committed
             *              and containing header_fields[2]
garciay's avatar
garciay committed
             *                  containing type
             *                      indicating 'its_aid'
             *                  containing its_aid
             *                      indicating 'AID_CAM'
             *              and not containing any other header fields
garciay's avatar
garciay committed
             *              and containing payload_field 
garciay's avatar
garciay committed
             *                  containing type
             *                      indicating 'signed'
             *                  containing data
             *                      indicating length > 0
             *                      containing CAM payload
garciay's avatar
garciay committed
             *              and containing trailer_fields
             *                  containing single instance of type TrailerField
garciay's avatar
garciay committed
             *                      containing type
             *                          indicating 'signature'
             *                      containing signature
             *                          verifiable using KEY
             *      } then {
             *          the IUT accepts the message
             *      }
             *  }
             * </pre>
             *
             * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_RCV_CAM_01_02_BV
             * @reference    ETSI TS 103 097 [1], clause 7.1
             */
            testcase TC_SEC_ITSS_RCV_CAM_01_02_BV() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var integer i;
                var GeoNetworkingPdu v_securedGnPdu;
                var GnRawPayload v_sentRawPayload;
                
                // Test adapter configuration
                if (not(PICS_GN_SECURITY)) {
                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY' required for executing the TC ***");
                    stop;
                }
                
                //  Test component configuration
                f_cf01Up();
                
                // Test adapter configuration
                
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
garciay's avatar
garciay committed
                v_securedGnPdu := f_sendSecuredCam(cc_taCert_A, omit, e_certificate_digest_with_sha256);
                v_sentRawPayload := f_adaptPayloadForUtInd_m(v_securedGnPdu.gnPacket.packet.payload);
                for (i := 0; i < lengthof(vc_utInds) and not match(vc_utInds[i].rawPayload, v_sentRawPayload); i := i + 1) {
garciay's avatar
garciay committed
                    // empty on purpose 
                }
                if (i < lengthof(vc_utInds)) {
garciay's avatar
garciay committed
                    log("*** " & testcasename() & ": PASS: GN was transmitted to upper layer ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
garciay's avatar
garciay committed
                    log("*** " & testcasename() & ": FAIL: GN was not transmitted to upper layer ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                }
                
                // Postamble
                f_poNeighbour();
                f_cf01Down();
garciay's avatar
garciay committed
            } // End of testcase TC_SEC_ITSS_RCV_CAM_01_02_BV
garciay's avatar
garciay committed
             * @desc    Check that IUT accepts a well-formed Secured CAM containing certificate chain in signer_info
garciay's avatar
garciay committed
             * @remark  The message defined in this test purpose is used in the subsequent test purposes with the snippet name ‘MSG_SEC_RCV_CAM_02’. Only differences to this snippet are mentioned in subsequent test purposes
garciay's avatar
garciay committed
             * <pre>
             * Pics Selection: PICS_GN_SECURITY
             * Config Id: CF01
             * Initial conditions:
             *  with {
             *      the IUT being in the 'authorized' state
             *  }
             *  ensure that {
             *      when { 
             *          the IUT is receiving a SecuredMessage
             *              containing protocol_version 
             *                  indicating value '2'
             *              and containing header_fields[0]
             *                  containing type 
             *                      indicating 'signer_info'
garciay's avatar
garciay committed
             *                  and containing signer
garciay's avatar
garciay committed
             *                      containing type
             *                          indicating 'certificate_chain'
             *                      and containing certificates
garciay's avatar
garciay committed
             *                          containing certificate (CERT_AA_A) at index 0 
garciay's avatar
garciay committed
             *                              containing subject_info.subject_type
             *                                  indicating 'authorization_authority'
             *                              and containing subject_attributes['verification key'] (KEY_AA)
garciay's avatar
garciay committed
             *                          and containing certificate (CERT_AT_A) at index 1 
garciay's avatar
garciay committed
             *                              containing subject_info.subject_type
             *                                  indicating 'authorization_ticket'
garciay's avatar
garciay committed
             *                              and containing signer_info 
garciay's avatar
garciay committed
             *                                  containing type
             *                                      indicating 'certificate_digest_with_sha256'
             *                                  containing digest
             *                                      referencing to the CERT_AA_A
             *                              and containing signature
             *                                  verifiable using KEY_AA
             *                              and containing subject_attributes['verification key'] (KEY)
garciay's avatar
garciay committed
             *              and containing header_fields [1] 
garciay's avatar
garciay committed
             *                  containing type
             *                      indicating 'generation_time'
             *                  containing generation_time
             *                      indicating CURRENT_TIME
garciay's avatar
garciay committed
             *              and containing header_fields[2] 
garciay's avatar
garciay committed
             *                  containing type
             *                      indicating 'its_aid'
             *                  containing its_aid
             *                      indicating 'AID_CAM'
             *              and not containing any other header fields
garciay's avatar
garciay committed
             *              and containing payload_field 
garciay's avatar
garciay committed
             *                  containing type
             *                      indicating 'signed'
             *                  containing data
             *                      indicating length > 0
             *                      containing CAM payload
garciay's avatar
garciay committed
             *              and containing trailer_fields 
             *                  containing single instance of type TrailerField 
garciay's avatar
garciay committed
             *                      containing type
             *                          indicating 'signature'
             *                      containing signature
             *                          verifiable using KEY
             *      } then {
             *          the IUT accepts the message
             *      }
             *  }
             * </pre>
             *
             * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_RCV_CAM_01_03_BV
             * @reference    ETSI TS 103 097 [1], clause 7.1
             */
            testcase TC_SEC_ITSS_RCV_CAM_01_03_BV() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var integer i;
                var GeoNetworkingPdu v_securedGnPdu;
                var GnRawPayload v_sentRawPayload;
                
                // Test adapter configuration
                if (not(PICS_GN_SECURITY)) {
                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY' required for executing the TC ***");
                    stop;
                }
                
                //  Test component configuration
                f_cf01Up();
                
                // Test adapter configuration
                
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
garciay's avatar
garciay committed
                v_securedGnPdu := f_sendSecuredCam(cc_taCert_A, -, e_certificate_chain);
                v_sentRawPayload := f_adaptPayloadForUtInd_m(v_securedGnPdu.gnPacket.packet.payload);
                for (i := 0; i < lengthof(vc_utInds) and not match(vc_utInds[i].rawPayload, v_sentRawPayload); i := i + 1) {
garciay's avatar
garciay committed
                    // empty on purpose 
                }
                if (i < lengthof(vc_utInds)) {
garciay's avatar
garciay committed
                    log("*** " & testcasename() & ": PASS: GN was transmitted to upper layer ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
garciay's avatar
garciay committed
                    log("*** " & testcasename() & ": FAIL: GN was not transmitted to upper layer ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
garciay's avatar
garciay committed
                 
                // Postamble
                f_poNeighbour();
                f_cf01Down();
garciay's avatar
garciay committed
            } // End of testcase TC_SEC_ITSS_RCV_CAM_01_03_BV
garciay's avatar
garciay committed
             * @desc    Check that IUT discards a Secured CAM containing protocol version set to a value less then 2
             * <pre>
             * Pics Selection: PICS_GN_SECURITY
             * Config Id: CF01
             * Initial conditions:
             *  with {
             *      the IUT being in the 'authorized' state
             *  }
             *  ensure that {
             *      when { 
garciay's avatar
garciay committed
             *          the IUT is receiving a SecuredMessage (MSG_SEC_RCV_CAM_01)
garciay's avatar
garciay committed
             *              containing protocol_version 
             *                  indicating 1
             *              containing header_fields['its_aid']
             *                  indicating 'AID_CAM'
             *      } then {
             *          the IUT discards a SecuredMessage
             *      }
             *  }
             * </pre>
             *
             * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_RCV_CAM_02_01_BO
             * @reference    ETSI TS 103 097 [1], clause 5.2
             */
            testcase TC_SEC_ITSS_RCV_CAM_02_01_BO() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var integer i;
                var GeoNetworkingPdu v_securedGnPdu;
                var GnRawPayload v_sentRawPayload;
                
                // Test adapter configuration
                if (not(PICS_GN_SECURITY)) {
                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY' required for executing the TC ***");
                    stop;
                }
                
                //  Test component configuration
                f_cf01Up();
                
                // Test adapter configuration
                
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
garciay's avatar
garciay committed
                v_securedGnPdu := f_sendSecuredCam_Bo(cc_taCert_A, PX_WRONG_PROTOCOL_VERSION);
                v_sentRawPayload := f_adaptPayloadForUtInd_m(v_securedGnPdu.gnPacket.packet.payload);
                for (i := 0; i < lengthof(vc_utInds) and not match(vc_utInds[i].rawPayload, v_sentRawPayload); i := i + 1) {
garciay's avatar
garciay committed
                    // empty on purpose 
                }
                if (i < lengthof(vc_utInds)) {
                    log("*** " & testcasename() & ": FAIL: GN was transmitted to upper layer ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                }
                else {
                    log("*** " & testcasename() & ": PASS: GN was not transmitted to upper layer ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                }
                
                // Postamble
                f_poNeighbour();
                f_cf01Down();
garciay's avatar
garciay committed
            } // End of testcase TC_SEC_ITSS_RCV_CAM_02_01_BO
garciay's avatar
garciay committed
             * @desc    Check that IUT discards a Secured CAM containing protocol version set to a value greater then 2
             * <pre>
             * Pics Selection: PICS_GN_SECURITY
             * Config Id: CF01
             * Initial conditions:
             *  with {
             *      the IUT being in the 'authorized' state
             *  }
             *  ensure that {
             *      when { 
garciay's avatar
garciay committed
             *          the IUT is receiving a SecuredMessage (MSG_SEC_RCV_CAM_01)
garciay's avatar
garciay committed
             *              containing protocol_version 
             *                  indicating 3
             *              containing header_fields['its_aid']
             *                  indicating 'AID_CAM'
             *      } then {
             *          the IUT discards a SecuredMessage
             *      }
             *  }
             * </pre>
             *
             * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_RCV_CAM_02_02_BO
             * @reference    ETSI TS 103 097 [1], clause 5.2
             */
            testcase TC_SEC_ITSS_RCV_CAM_02_02_BO() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var integer i;
                var GeoNetworkingPdu v_securedGnPdu;
                var GnRawPayload v_sentRawPayload;
                
                // Test adapter configuration
                if (not(PICS_GN_SECURITY)) {
                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY' required for executing the TC ***");
                    stop;
                }
                
                //  Test component configuration
                f_cf01Up();
                
                // Test adapter configuration
                
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
garciay's avatar
garciay committed
                v_securedGnPdu := f_sendSecuredCam_Bo(cc_taCert_A, PX_WRONG_PROTOCOL_VERSION); // Change PX_WRONG_PROTOCOL_VERSION to 3
                v_sentRawPayload := f_adaptPayloadForUtInd_m(v_securedGnPdu.gnPacket.packet.payload);
                for (i := 0; i < lengthof(vc_utInds) and not match(vc_utInds[i].rawPayload, v_sentRawPayload); i := i + 1) {
garciay's avatar
garciay committed
                    // empty on purpose 
garciay's avatar
garciay committed
                if (i < lengthof(vc_utInds)) {
                    log("*** " & testcasename() & ": FAIL: GN was transmitted to upper layer ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                }
                else {
                    log("*** " & testcasename() & ": PASS: GN was not transmitted to upper layer ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                }
garciay's avatar
garciay committed
                
                // Postamble
                f_poNeighbour();
                f_cf01Down();
garciay's avatar
garciay committed
            } // End of testcase TC_SEC_ITSS_RCV_CAM_02_02_BO
garciay's avatar
garciay committed
             * @desc    Check that IUT discards a secured CAM if the header_fields contains more than one element of header field type: signer_info
             * <pre>
             * Pics Selection: PICS_GN_SECURITY
             * Config Id: CF01
             * Initial conditions:
             * with { 
             *  the IUT being in the 'authorized' state 
             * } 
             * ensure that { 
garciay's avatar
garciay committed
             *  when { 
             *      the IUT is receiving a SecuredMessage (MSG_SEC_RCV_CAM_01) 
garciay's avatar
garciay committed
             *          containing header_fields[0].type
             *              indicating 'signer_info'
             *          and containing header_fields[1].type
             *              indicating 'signer_info'
             *          and containing header_fields[2].type
             *              indicating 'generation_time'
garciay's avatar
garciay committed
             *          and containing header_fields[3]
garciay's avatar
garciay committed
             *              containing type
             *                  indicating 'its_aid'
             *              containing its_aid
             *                  indicating 'AID_CAM'
             *          and not containing other header fields
             *  } then { 
             *      the IUT discards the message 
             *  } 
             * } 
             * </pre>
             *
             * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_RCV_CAM_04_01_BO
             * @reference    ETSI TS 103 097 [1], clause 7.1
             */
            testcase TC_SEC_ITSS_RCV_CAM_04_01_BO() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var integer i;
                var GeoNetworkingPdu v_securedGnPdu;
                var GnRawPayload v_sentRawPayload;
                
                // Test adapter configuration
                if (not(PICS_GN_SECURITY)) {
                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY' required for executing the TC ***");
                    stop;
                }
                
                //  Test component configuration
                f_cf01Up();
                
                // Test adapter configuration
                
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
garciay's avatar
garciay committed
                v_securedGnPdu := f_prepareSecuredCam(
                    cc_taCert_A, 
                    {
                        m_header_field_signer_info(
                            m_signerInfo_digest(
                                vc_atCertificate.signer_info.signerInfo.digest
                        )), 
                        m_header_field_signer_info(
                            m_signerInfo_certificate(
                                vc_aaCertificate
                        )), 
                        m_header_field_generation_time(1000 * f_getCurrentTime()), // In us
                        m_header_field_its_aid_CAM
                    }, 
                    e_certificate_digest_with_sha256,
                    false
                ); 
                f_sendGeoNetMessage(m_geoNwReq_linkLayerBroadcast(v_securedGnPdu));
                v_sentRawPayload := f_adaptPayloadForUtInd_m(v_securedGnPdu.gnPacket.packet.payload);
                for (i := 0; i < lengthof(vc_utInds) and not match(vc_utInds[i].rawPayload, v_sentRawPayload); i := i + 1) {