ItsSecurity_TestCases.ttcn 1.35 MB
Newer Older
filatov's avatar
filatov committed
                 * Initial conditions:
                 *   with
                 *     the IUT being in the 'authorized' state
                 *     the IUT being requested to include certificate chain in the next CAM
                 * Expected results:
                 *   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
                 *           containing certificates[last-1] (CERT_AA)
                 *             containing subject_info.subject_type
                 *               indicating 'authorization_authority'
                 *             and containing subject_attributes['verification key'] (KEY)
                 *           containing certificates[last]
                 *             containing subject_info.subject_type
                 *               indicating 'authorization_ticket'
                 *             and containing signer_info
                 *               containing type
                 *                 indicating 'certificate_digest_with_ecdsap256'
                 *               and containing digest
                 *                 referencing to CERT_AA
                 *             and containing signature
                 *               verifiable using KEY
filatov's avatar
filatov committed
                 * @see         ETSI TS 103 096-2 v1.3.1 TP_SEC_ITSS_SND_CERT_AT_08_01_BV
                 * @reference   ETSI TS 103 097 v1.2.1, clause 6.3
                 */
                testcase TC_SEC_ITSS_SND_CERT_AT_08_01_BV() runs on ItsGeoNetworking system ItsSecSystem {
                    var CertificateChain         v_chain;
                    var Certificate              v_aa_cert, v_at_cert;
                    var HashedId8                v_aa_digest;
                    
                    // Test control
                    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
                    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();
                } // End of testcase TC_SEC_ITSS_SND_CERT_AT_08_01_BV
                
                /**
filatov's avatar
filatov committed
                 * @desc  Check that all necessary validity restrictions are present and arranged in ascending order
                 * <pre>
                 * Pics Selection: PICS_GN_SECURITY
                 * Config Id: CF01
filatov's avatar
filatov committed
                 * Initial conditions:
                 *   with
                 *     the IUT being in the 'authorized' state
                 *     the IUT being requested to include certificate in the next CAM
                 * Expected results:
                 *   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'
                 *           containing certificate
                 *             containing validity_restrictions
                 *               indicating validity_restrictions[n].type < validity_restrictions[n+1].type
                 *               and containing validity_restrictions['time_start_and_end']
                 *               and not containing validity_restrictions['time_end']
                 *               and not containing validity_restrictions['time_start_and_duration']
filatov's avatar
filatov committed
                 * @see         ETSI TS 103 096-2 v1.3.1 TP_SEC_ITSS_SND_CERT_AT_10_01_BV
                 * @reference   ETSI TS 103 097 v1.2.1, clauses 6.1
                 */
                testcase TC_SEC_ITSS_SND_CERT_AT_10_01_BV() runs on ItsGeoNetworking system ItsSecSystem {
                    var Certificate             v_at_cert;
                    var ValidityRestriction     v_vr;
                    var ValidityRestrictions    v_vrs;
                    
                    // Test control
                    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
                    log("*** " & testcasename() & ": INFO: Waiting for the message containing certificate  ***");
                    tc_ac.start;
                    if (not f_waitForCertificate(v_at_cert)) {
                        log("*** " & testcasename() & ": INCONC: Expected message not received ***");
                        f_selfOrClientSyncAndVerdictPreamble(c_tbDone, e_timeout);
                    }
                    tc_ac.stop;
                    if (not match(
                        v_at_cert, 
                            mw_at_certificate(
                                mw_signerInfo_certificate
                     ))) {
                    }
                    
                    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 ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                    }
                    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
                    
                    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();
                } // End of testcase TC_SEC_ITSS_SND_CERT_AT_10_01_BV
                
            } // 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 {
        
        /**
         * @desc Receiving behaviour test cases for CAM profile
         * @see ETSI TS 103 096-2 V1.2.2 (2016-01) Clause 5.3.2 CAM Profile
         */
        group recvCamProfile {
            
            /**
filatov's avatar
filatov committed
             * @desc  Check that IUT accepts a well-formed Secured CAM containing certificate in signer_info
             * <pre>
             * Pics Selection: PICS_GN_SECURITY
             * Config Id: CF01
             * Initial conditions:
filatov's avatar
filatov committed
             *   with
             *     the IUT being in the 'authorized' state
             *     and the IUT current time is inside the time validity period of CERT_TS_A_AT
             * Expected results:
             *   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'
             *           and containing signer
             *             containing type
             *               indicating 'certificate'
             *             and containing certificate (CERT_TS_A_AT)
             *               containing subject_info.subject_type
             *                 indicating 'authorization_ticket'
             *               and containing subject_attributes['verification key'] (KEY)
             *         and containing header_fields [1]
             *           containing type
             *             indicating 'generation_time'
             *           and containing generation_time
             *             indicating CURRENT_TIME
             *         and containing header_fields[2]
             *           containing type
             *             indicating 'its_aid'
             *           and containing its_aid
             *             indicating 'AID_CAM'
             *         and containing payload_field
             *           containing type
             *             indicating 'signed'
             *           and containing data
             *             indicating length > 0
             *             containing CAM payload
             *         and containing trailer_fields
             *           containing trailer_fields[0]
             *             containing type
             *               indicating 'signature'
             *             containing signature
             *               verifiable using KEY
             *     then
             *       the IUT accepts the message
             * </pre>
filatov's avatar
filatov committed
             * @see         ETSI TS 103 096-2 v1.3.1 TP_SEC_ITSS_RCV_CAM_01_01_BV
             * @reference   ETSI TS 103 097 v1.2.1, clause 7.1
filatov's avatar
filatov committed
             */
            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
                v_securedGnPdu := f_sendSecuredCam(cc_taCert_A, omit, e_certificate);
                
                f_sleep(PX_TNOAC);
                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) {
                    // Empty on purpose 
                }
                if (i < lengthof(vc_utInds)) {
                    log("*** " & testcasename() & ": PASS: GN was transmitted to upper layer ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                }
                else {
                    log("*** " & testcasename() & ": FAIL: GN was not transmitted to upper layer ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                }
                
                // Postamble
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_ITSS_RCV_CAM_01_01_BV
            
            /**
filatov's avatar
filatov committed
             * @desc  Check that IUT accepts a well-formed Secured CAM containing certificate digest of the known certificate in signer_info
             * <pre>
             * Pics Selection: PICS_GN_SECURITY
             * Config Id: CF01
             * Initial conditions:
filatov's avatar
filatov committed
             *   with
             *     the IUT being in the 'authorized' state
             *     and the IUT current time is inside the time validity period of CERT_TS_A_AT
             *     and the IUT already received a Secured message containing certificate (CERT_TS_A_AT)
             *       containing subject_info.subject_type
             *         indicating 'authorization_ticket'
             *       and containing subject_attributes['verification key'] (KEY)
             * Expected results:
             *   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'
             *           and containing signer
             *             containing type
             *               indicating 'certificate_digest_with_sha256'
             *             and containing digest
             *               referencing to certificate (CERT_TS_A_AT)
             *         and containing header_fields [1]
             *           containing type
             *             indicating 'generation_time'
             *           and containing generation_time
             *             indicating CURRENT_TIME
             *         and containing header_fields[2]
             *           containing type
             *             indicating 'its_aid'
             *           and containing its_aid
             *             indicating 'AID_CAM'
             *         and containing payload_field
             *           containing type
             *             indicating 'signed'
             *           and containing data
             *             indicating length > 0
             *             containing CAM payload
             *         and containing trailer_fields
             *           containing trailer_fields[0]
             *             containing type
             *               indicating 'signature'
             *             containing signature
             *               verifiable using KEY
             *     then
             *       the IUT accepts the message
             * </pre>
filatov's avatar
filatov committed
             * @see         ETSI TS 103 096-2 v1.3.1 TP_SEC_ITSS_RCV_CAM_01_02_BV
             * @reference   ETSI TS 103 097 v1.2.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
                v_securedGnPdu := f_sendSecuredCam(cc_taCert_A, omit, e_certificate_digest_with_sha256);
                
                f_sleep(PX_TNOAC);
                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) {
                    // Empty on purpose 
                }
                if (i < lengthof(vc_utInds)) {
                    log("*** " & testcasename() & ": PASS: GN was transmitted to upper layer ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                }
                else {
                    log("*** " & testcasename() & ": FAIL: GN was not transmitted to upper layer ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                }
                
                // Postamble
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_ITSS_RCV_CAM_01_02_BV
            
            /**
filatov's avatar
filatov committed
             * @desc  Check that IUT accepts a well-formed Secured CAM containing certificate chain in signer_info
             * <pre>
             * Pics Selection: PICS_GN_SECURITY
             * Config Id: CF01
             * Initial conditions:
filatov's avatar
filatov committed
             *   with
             *     the IUT being in the 'authorized' state
             *     and the IUT current time is inside the time validity period of CERT_TS_A_AT
             * Expected results:
             *   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'
             *           and containing signer
             *             containing type
             *               indicating 'certificate_chain'
             *             and containing certificates
             *               containing certificates[0] (CERT_TS_A_AA)
             *                 containing subject_info.subject_type
             *                   indicating 'authorization_authority'
             *                 and containing subject_attributes['verification key'] (KEY_TS_AA)
             *               and containing certificates[1] (CERT_TS_A_AT)
             *                 containing subject_info.subject_type
             *                   indicating 'authorization_ticket'
             *                 and containing signer_info
             *                   containing type
             *                     indicating 'certificate_digest_with_sha256'
             *                   and containing digest
             *                     referencing to the CERT_TS_A_AA
             *                 and containing signature
             *                   verifiable using KEY_TS_AA
             *                 and containing subject_attributes['verification key'] (KEY_TS_AT)
             *         and containing header_fields [1]
             *           containing type
             *             indicating 'generation_time'
             *           and containing generation_time
             *             indicating CURRENT_TIME
             *         and containing header_fields[2]
             *           containing type
             *             indicating 'its_aid'
             *           and containing its_aid
             *             indicating 'AID_CAM'
             *         and containing payload_field
             *           containing type
             *             indicating 'signed'
             *           and containing data
             *             indicating length > 0
             *             containing CAM payload
             *         and containing trailer_fields
             *           containing trailer_fields[0]
             *             containing type
             *               indicating 'signature'
             *             and containing signature
             *               verifiable using KEY_TC_AT
             *     then
             *       the IUT accepts the message
             * </pre>
filatov's avatar
filatov committed
             * @see         ETSI TS 103 096-2 v1.3.1 TP_SEC_ITSS_RCV_CAM_01_03_BV
             * @reference   ETSI TS 103 097 v1.2.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
                v_securedGnPdu := f_sendSecuredCam(cc_taCert_A, -, e_certificate_chain);
                
                f_sleep(PX_TNOAC);
                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) {
                    // Empty on purpose 
                }
                if (i < lengthof(vc_utInds)) {
                    log("*** " & testcasename() & ": PASS: GN was transmitted to upper layer ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                }
                else {
                    log("*** " & testcasename() & ": FAIL: GN was not transmitted to upper layer ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                }
                 
                // Postamble
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_ITSS_RCV_CAM_01_03_BV
            
            /**
filatov's avatar
filatov committed
             * @desc  Check that IUT discards a Secured CAM containing protocol version set to a value less than 2
             * <pre>
             * Pics Selection: PICS_GN_SECURITY
             * Config Id: CF01
             * Initial conditions:
filatov's avatar
filatov committed
             *   with
             *     the IUT being in the 'authorized' state
             *     and the IUT current time is inside the time validity period of CERT_TS_A_AT
             * Expected results:
             *   ensure that
             *     when
             *       the IUT is receiving a SecuredMessage (MSG_SEC_RCV_CAM_01)
             *         containing protocol_version
             *           indicating 1
             *     then
             *       the IUT discards a SecuredMessage
             * </pre>
filatov's avatar
filatov committed
             * @see         ETSI TS 103 096-2 v1.3.1 TP_SEC_ITSS_RCV_CAM_02_01_BO
             * @reference   ETSI TS 103 097 v1.2.1, clause 5.1
             */
            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
                v_securedGnPdu := f_sendSecuredCam_Bo(cc_taCert_A, PX_WRONG_PROTOCOL_VERSION);
                
                f_sleep(PX_TNOAC);
                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) {
                    // 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();
            } // End of testcase TC_SEC_ITSS_RCV_CAM_02_01_BO
            
            /**
filatov's avatar
filatov committed
             * @desc  Check that IUT discards a Secured CAM containing protocol version set to a value greater than 2
             * <pre>
             * Pics Selection: PICS_GN_SECURITY
             * Config Id: CF01
             * Initial conditions:
filatov's avatar
filatov committed
             *   with
             *     the IUT being in the 'authorized' state
             *     and the IUT current time is inside the time validity period of CERT_TS_A_AT
             * Expected results:
             *   ensure that
             *     when
             *       the IUT is receiving a SecuredMessage (MSG_SEC_RCV_CAM_01)
             *         containing protocol_version
             *           indicating 3
             *     then
             *       the IUT discards a SecuredMessage
             * </pre>
filatov's avatar
filatov committed
             * @see         ETSI TS 103 096-2 v1.3.1 TP_SEC_ITSS_RCV_CAM_02_02_BO
             * @reference   ETSI TS 103 097 v1.2.1, clause 5.1
             */
            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
                v_securedGnPdu := f_sendSecuredCam_Bo(cc_taCert_A, PX_WRONG_PROTOCOL_VERSION); // Change PX_WRONG_PROTOCOL_VERSION to 3
                
                f_sleep(PX_TNOAC);
                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) {
                    // 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();
            } // End of testcase TC_SEC_ITSS_RCV_CAM_02_02_BO
            
            /**
filatov's avatar
filatov committed
             * @desc  Check that IUT discards a secured CAM if the header_fields contains more than header field 'signer_info'
             * <pre>
             * Pics Selection: PICS_GN_SECURITY
             * Config Id: CF01
             * Initial conditions:
filatov's avatar
filatov committed
             *   with
             *     the IUT being in the 'authorized' state
             *     and the IUT current time is inside the time validity period of CERT_TS_A_AT
             * Expected results:
             *   ensure that
             *     when
             *       the IUT is receiving a SecuredMessage (MSG_SEC_RCV_CAM_01)
             *         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'
             *         and containing header_fields[3].type
             *           indicating 'its_aid'
             *         and not containing other header fields
             *     then
             *       the IUT discards a SecuredMessage
             * </pre>
filatov's avatar
filatov committed
             * @see         ETSI TS 103 096-2 v1.3.1 TP_SEC_ITSS_RCV_CAM_04_01_BO
             * @reference   ETSI TS 103 097 v1.2.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
                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_atCertificate
                        )), 
                        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));
                
                f_sleep(PX_TNOAC);
                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) {
                    // Empty on purpose 
                } // End of 'for' statement
                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();
            } // End of testcase TC_SEC_ITSS_RCV_CAM_04_01_BO
            
            /**
filatov's avatar
filatov committed
             * @desc  Check that IUT discards a secured CAM if the header_fields does not contain the header 'signer_info'
             * <pre>
             * Pics Selection: PICS_GN_SECURITY
             * Config Id: CF01
             * Initial conditions:
filatov's avatar
filatov committed
             *   with
             *     the IUT being in the 'authorized' state
             *     and the IUT current time is inside the time validity period of CERT_TS_A_AT
             * Expected results:
             *   ensure that
             *     when
             *       the IUT is receiving a SecuredMessage (MSG_SEC_RCV_CAM_01)
             *         containing header_fields[0].type
             *           indicating 'generation_time'
             *         and containing header_fields[1].type
             *           indicating 'its_aid'
             *         and not containing other header fields
             *     then
             *       the IUT discards a SecuredMessage
             * </pre>
filatov's avatar
filatov committed
             * @see         ETSI TS 103 096-2 v1.3.1 TP_SEC_ITSS_RCV_CAM_04_02_BO
             * @reference   ETSI TS 103 097 v1.2.1, clause 7.1
             */
            testcase TC_SEC_ITSS_RCV_CAM_04_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();
                if (PICS_DEBUG_ADDON) {
                    f_sendCertificateAndWaitForCertificateChainRequest(cc_taCert_F, f_generateDefaultCam());
                }
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
                v_securedGnPdu := f_prepareSecuredCam(
                    cc_taCert_A, 
                    {
                        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));
                
                f_sleep(PX_TNOAC);
                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) {
                    // Empty on purpose 
                } // End of 'for' statement
                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();
            } // End of testcase TC_SEC_ITSS_RCV_CAM_04_02_BO
            
            /**
filatov's avatar
filatov committed
             * @desc  Check that IUT is able to receive a secured CAM where the header fields 'signer_info' is not encoded first
             * <pre>
             * Pics Selection: PICS_GN_SECURITY
             * Config Id: CF01
             * Initial conditions:
filatov's avatar
filatov committed
             *   with
             *     the IUT being in the 'authorized' state
             *     and the IUT current time is inside the time validity period of CERT_TS_A_AT
             *     and the IUT is sending CAMs
             * Expected results:
             *   ensure that
             *     when
             *       the IUT is receiving a SecuredMessage (MSG_SEC_RCV_CAM_01)
             *         containing header_fields[0].type
             *           indicating 'generation_time'
             *         and containing header_fields[1].type
             *           indicating 'its_aid'
             *         and containing header_fields[2].type
             *           indicating 'signer_info'
             *         and not containing other header fields
             *     then
             *       the IUT discards the SecuredMessage
             * </pre>
filatov's avatar
filatov committed
             * @see         ETSI TS 103 096-2 v1.3.1 TP_SEC_ITSS_RCV_CAM_04_03_BO
             * @reference   ETSI TS 103 097 v1.2.1, clause 7.1
             */
            testcase TC_SEC_ITSS_RCV_CAM_04_03_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
                v_securedGnPdu := f_prepareSecuredCam(
                    cc_taCert_A, 
                    {
                        m_header_field_generation_time(1000 * f_getCurrentTime()), // In us
                        m_header_field_its_aid_CAM,
                        m_header_field_signer_info(
                            m_signerInfo_digest(
                                vc_atCertificate.signer_info.signerInfo.digest
                        ))
                    }, 
                    e_certificate_digest_with_sha256,
                    false
                ); 
                f_sendGeoNetMessage(m_geoNwReq_linkLayerBroadcast(v_securedGnPdu));
                
                f_sleep(PX_TNOAC);
                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) {
                    // Empty on purpose 
                } // End of 'for' statement
                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();
            } // End of testcase TC_SEC_ITSS_RCV_CAM_04_03_BO
            
            /**
filatov's avatar
filatov committed
             * @desc  Check that IUT discards a secured CAM if the header_fields contains more than one header field 'generation_time'
             * <pre>
             * Pics Selection: PICS_GN_SECURITY
             * Config Id: CF01
             * Initial conditions:
filatov's avatar
filatov committed
             *   with
             *     the IUT being in the 'authorized' state
             *     and the IUT current time is inside the time validity period of CERT_TS_A_AT
             * Expected results:
             *   ensure that
             *     when
             *       the IUT is receiving a SecuredMessage (MSG_SEC_RCV_CAM_01)
             *         containing header_fields[0].type
             *           indicating 'signer_info'
             *         and containing header_fields[1].type
             *           indicating 'generation_time'
             *         and containing header_fields[2].type
             *           indicating 'generation_time'
             *         and containing header_fields[3].type
             *           indicating 'its_aid'
             *         and not containing other header fields
             *     then
             *       the IUT discards a SecuredMessage
             * </pre>
filatov's avatar
filatov committed
             * @see         ETSI TS 103 096-2 v1.3.1 TP_SEC_ITSS_RCV_CAM_04_04_BO
             * @reference   ETSI TS 103 097 v1.2.1, clause 7.1
             */
            testcase TC_SEC_ITSS_RCV_CAM_04_04_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
                v_securedGnPdu := f_prepareSecuredCam(
                    cc_taCert_A, 
                    {
                        m_header_field_signer_info(
                            m_signerInfo_digest(
                                vc_atCertificate.signer_info.signerInfo.digest
                        )), 
                        m_header_field_its_aid_CAM
                    }, 
                    e_certificate_digest_with_sha256,
                    false
                ); 
                f_sendGeoNetMessage(m_geoNwReq_linkLayerBroadcast(v_securedGnPdu));
                
                f_sleep(PX_TNOAC);
                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) {
                    // Empty on purpose 
                } // End of 'for' statement
                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();
            } // End of testcase TC_SEC_ITSS_RCV_CAM_04_04_BO
            
            /**
filatov's avatar
filatov committed
             * @desc  Check that IUT discards a secured CAM if the header_fields does not contain the header field 'generation_time'
             * <pre>
             * Pics Selection: PICS_GN_SECURITY
             * Config Id: CF01
             * Initial conditions:
filatov's avatar
filatov committed
             *   with
             *     the IUT being in the 'authorized' state
             *     and the IUT current time is inside the time validity period of CERT_TS_A_AT
             * Expected results:
             *   ensure that
             *     when
             *       the IUT is receiving a SecuredMessage (MSG_SEC_RCV_CAM_01)
             *         containing header_fields[0].type
             *           indicating 'signer_info'
             *         and containing header_fields[1].type
             *           indicating 'its_aid'
             *         and not containing other header fields
             *     then
             *       the IUT discards a SecuredMessage
             * </pre>
filatov's avatar
filatov committed
             * @see         ETSI TS 103 096-2 v1.3.1 TP_SEC_ITSS_RCV_CAM_04_05_BO
             * @reference   ETSI TS 103 097 v1.2.1, clause 7.1
             */
            testcase TC_SEC_ITSS_RCV_CAM_04_05_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