ItsSecurity_TestCases.ttcn3 817 KB
Newer Older
/**
 *  @author   ETSI / STF481
 *  @version  $URL$
garciay's avatar
garciay committed
 *            $Id$
 *  @desc     Testcases  file for Security Protocol
 *  @see      Draft ETSI TS 103 097 V1.1.15
 */
module ItsSecurity_TestCases {
    
    // Libcommon
    import from LibCommon_Time all;
    import from LibCommon_VerdictControl all;
    import from LibCommon_Sync all;
garciay's avatar
garciay committed
    import from LibCommon_BasicTypesAndValues all;
    
    // LibItsCommon
    import from LibItsCommon_Functions all;
    
    // LibItsSecurity
    import from LibItsSecurity_TypesAndValues all;
    import from LibItsSecurity_Templates all;
    import from LibItsSecurity_Functions all;
    import from LibItsSecurity_Pixits all;
    import from LibItsSecurity_Pics all;
    
    // LibItsGeoNetworking
    import from LibItsGeoNetworking_TestSystem all;
    import from LibItsGeoNetworking_Functions all;
    import from LibItsGeoNetworking_Templates all;
    import from LibItsGeoNetworking_TypesAndValues all;
    import from LibItsGeoNetworking_Pics all;
    import from LibItsGeoNetworking_Pixits all;

    // LibItsBtp
    import from LibItsBtp_TypesAndValues all;
    import from LibItsBtp_Templates all;

    // LibItsCam
    import from LibItsCam_Templates all;
    import from LibItsCam_Functions { group camGenerators } ;
    import from LibItsCam_Templates all;
    import from LibItsCam_Functions all;
    import from LibItsCam_TestSystem all;
    
    // LibItsDenm
    import from LibItsDenm_TypesAndValues all;
    import from LibItsDenm_Templates {
        template m_situation, m_denmLocation_zeroDelta, m_denm, m_denmMgmtCon, m_tsActionId
    };
    import from LibItsDenm_TestSystem all;
    
    // AtsSecurity
    import from AtsSecurity_TestSystem all;
    import from AtsSecurity_Functions all;
    import from AtsSecurity_Templates all;
    
garciay's avatar
garciay committed
    /**
     * @desc Sending behaviour test cases
     * @see ETSI TS 103 096-2 V1.2.2 (2016-01) Clause 5.2 Sending behaviour
     */
    group sendingBehavior {

        /**
         * @desc    Check that ITS-S sends a SecuredMessage containing protocol version set to 2
         * <pre>
garciay's avatar
garciay committed
         * Pics Selection: PICS_GN_SECURITY
         * Config Id: CF01
         * Initial conditions:
         *  with {
         *      the IUT being in the 'authorized' state
         *  }
         * Expected behaviour:
         * ensure that {
         *     when { 
         *     the IUT is requested to send a SecuredMessage
         *     } then {
         *     the IUT sends a SecuredMessage
         *         containing protocol_version 
         *         indicating value '2'
         *     }
         * }
         * </pre>
         *
garciay's avatar
garciay committed
         * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_SND_MSG_01_01_BV
         * @reference   ETSI TS 103 097 [1], clause 5.1
        testcase TC_SEC_ITSS_SND_MSG_01_01_BV() runs on ItsGeoNetworking system ItsSecSystem {
                
            // Local variables
            var LongPosVector v_longPosVectorIut;
                
            // Test control
garciay's avatar
garciay committed
            if (not(PICS_GN_SECURITY)) {
                log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY' required for executing the TC ***");
            // Test component configuration
            f_cf01Up();
            v_longPosVectorIut := f_getPosition(c_compIut);
                
            // Test adapter configuration
            // Preamble
            f_prNeighbour();
            f_acTriggerEvent(m_startPassBeaconing(m_beaconHeader(v_longPosVectorIut).beaconHeader)); // Authorize the TA to forward the received beacons
            f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
            
            // Test Body
            tc_ac.start;
            alt {
                [] geoNetworkingPort.receive(mw_geoNwInd(mw_geoNwSecPdu(mdw_securedMessage_dummy))) {
                    tc_ac.stop;
                    log("*** " & testcasename() & ": PASS: Security protocol version set to 2 ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                }
                [] tc_ac.timeout {
                    log("*** " & testcasename() & ": INCONC: Expected message not received ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                }
            } // End of 'alt' statement
            
            // Postamble
            f_acTriggerEvent(m_stopPassBeaconing);
            f_poNeighbour();
            f_cf01Down();
            
        } // End of testcase TC_SEC_ITSS_SND_MSG_01_01_BV
garciay's avatar
garciay committed
         * @desc    Check that when IUT sends the message signed with the digest, then this digest points to the AT certificate 
         * Pics Selection: PICS_GN_SECURITY
         * Config Id: CF01
         * Initial conditions:
         * with {
         *   the IUT being in the 'authorized' state
         *   and the IUT is configured to send more than one CAM per second
         *   and the IUT having sent last CAM
         *     containing header_fields['signer_info'].signer.type
         *       indicating 'certificate'
         * }
         * Expected behaviour:
         * ensure that {
         *   when {
         *     the IUT is requested to send next CAM
         *   } then {
         *     the IUT sends a SecuredMessage
         *       containing header_fields ['signer_info'] {
         *         containing signer {
         *           containing type
         *             indicating 'certificate_digest_with_sha256'
         *           containing digest
         *             referencing the certificate
         *               containing subject_info.subject_type
         *                 indicating 'authorization_ticket'
         *         }
         *       }
         *   }
         * } 
         * </pre>
         *
garciay's avatar
garciay committed
         * @see         ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_SND_MSG_04_01_BV
         * @reference   ETSI TS 103 097 [1], clause 6.3
        testcase TC_SEC_ITSS_SND_MSG_04_01_BV() runs on ItsGeoNetworking system ItsSecSystem {
            // Local variables
            var SecuredMessage v_recv;
            var Certificate v_cert;
            var LongPosVector v_longPosVectorIut;
            var ItsCam v_component;
            if (not(PICS_GN_SECURITY)) {
                log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY' required for executing the TC ***");
                stop;
            }
            
            // Test component configuration
            f_cf01Up();
            v_longPosVectorIut := f_getPosition(c_compIut);
                
            // Test adapter configuration
                
            // Preamble
            f_prNeighbour();
            v_component := f_setCamFrequencyGreatherThan1Hz();
            // execution will be stopped if cert is not received during tc_ac 
            log("*** " & testcasename() & ": INFO: Waiting for the message containing certificate  ***");
            tc_ac.start;
            f_waitForCertificate(v_cert);
            tc_ac.stop;
            if (v_cert.subject_info.subject_type != e_authorization_ticket) {
                log("*** " & testcasename() & ": FAIL: received certificate is not an AT certificate  ***");
                f_selfOrClientSyncAndVerdictTestBody(c_prDone, e_error);
            }
            f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
            
            // Test Body
            tc_ac.start;
            alt {
                [] a_securedMessageWithDigest (v_recv) {
                    var SignerInfo v_si;
                    tc_ac.stop;
                    if (f_getMsgSignerInfo(v_recv, v_si) == true) {
                        if (v_si.signerInfo.digest == f_calculateDigestFromCertificate(v_cert)) {
                            log("*** " & testcasename() & ": PASS: Digest corresponds to the AT certificate ***");
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                        } else {
                            log("*** " & testcasename() & ": FAIL: Digest corresponds to unknown certificate ***");
                            log("f_calculateDigestFromCertificate(v_cert)=", f_calculateDigestFromCertificate(v_cert));
                            log("v_si.signerInfo.digest=", v_si.signerInfo.digest);
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                        }
                    } else {
                        log("*** " & testcasename() & ": FAIL: Received message is not signed well ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                    }
                }
                [] tc_ac.timeout {
                    log("*** " & testcasename() & ": INCONC: Expected CAM not received ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                } 
            } // End of 'alt' statement
            
            // Postamble
            f_terminateCam(v_component);
            f_poNeighbour();
            f_cf01Down();
            
        } // End of testcase TC_SEC_ITSS_SND_MSG_04_01_BV
        
        /**
         * @desc    Check that IUT uses the AT certificate to sign messages
         * <pre>
         * Pics Selection: PICS_GN_SECURITY
         * Config Id: CF01
         * Initial conditions:
         * with {
         *   the IUT being in the 'authorized' state
         *   the IUT being requested to include certificate in the next CAM
         * }
         * ensure that {
         *     when {
         *         the IUT is requested to send a next CAM
         *     } then {
         *         the IUT sends a SecuredMessage
garciay's avatar
garciay committed
         *             containing header_fields ['signer_info']
         *                 containing signer
         *                     containing type
         *                         indicating 'certificate'
         *                     containing certificate
         *                         containing subject_info.subject_type
         *                             indicating 'authorization_ticket'
         *     }
         * }
         * </pre>
         *
garciay's avatar
garciay committed
         * @see         ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_SND_MSG_04_02_BV
         * @reference   ETSI TS 103 097 [1], clause 6.3
        testcase TC_SEC_ITSS_SND_MSG_04_02_BV() runs on ItsGeoNetworking system ItsSecSystem {
            // Local variables
            var SecuredMessage v_recv;
            var Certificate v_cert;
            var LongPosVector v_longPosVectorIut;
            
            // Test control
            if (not(PICS_GN_SECURITY)) {
                log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY' required for executing the TC ***");
                stop;
            }
            
            // Test component configuration
            f_cf01Up();
            v_longPosVectorIut := f_getPosition(c_compIut);
                
            // Test adapter configuration
            
            // Preamble
            f_prNeighbour();
            f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
            
            // Test Body
            tc_ac.start;
            alt {
                [] a_securedMessageWithCertificate(v_recv) {
                    var SignerInfo v_si;
                    if (f_getMsgSignerInfo(v_recv, v_si)) {  
                        v_cert :=  v_si.signerInfo.certificate;
                        if (v_cert.subject_info.subject_type != e_authorization_ticket ) {
                            log("*** " & testcasename() & ": FAIL: received certificate is not an AT certificate  ***");
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                        }
                        log("*** " & testcasename() & ": PASS: message signed with AT certificate");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                    } else {
                        log("*** " & testcasename() & ": FAIL: received message is not signed well  ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                    }
                }
                [] tc_ac.timeout {
                    log("*** " & testcasename() & ": INCONC: Expected CAM not received ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                } 
            } // End of 'alt' statement
            
            // Postamble
            f_poNeighbour();
            f_cf01Down();
        } // End of testcase TC_SEC_ITSS_SND_MSG_04_02_BV
        
        /**
         * @desc    Check that the SecuredMessage signature containes the ECC point of type set to either compressed_lsb_y_0, compressed_lsb_y_1 or x_coordinate_only
         * <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 requested to send a next CAM
         *     } then {
         *      the IUT sends a SecuredMessage 
         *          containing header_fields ['its_aid']
         *              containing its_aid
         *                  indicating 'AID_CAM'
         *          and containing trailer_fields['signature']
         *              containing signature.ecdsa_signature
         *                  containing R.type
         *                      indicating compressed_lsb_y_0
         *                      or indicating compressed_lsb_y_1 
         *                      or indicating x_coordinate_only
         *     }
         * }
         * </pre>
         *
garciay's avatar
garciay committed
         * @see         ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_SND_MSG_05_01_BV
         * @reference   ETSI TS 103 097 [1], clause 4.2.9
        testcase TC_SEC_ITSS_SND_MSG_05_01_BV() runs on ItsGeoNetworking system ItsSecSystem {
            // Local variables
            var LongPosVector v_longPosVectorIut;
            
            // Test control
            if (not(PICS_GN_SECURITY)) {
                log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY' required for executing the TC ***");
                stop;
            }
            
            // Test component configuration
            f_cf01Up();
            v_longPosVectorIut := f_getPosition(c_compIut);
                
            // Test adapter configuration
            
            // Preamble
            f_prNeighbour();
            f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
            
            // Test Body
            tc_ac.start;
            alt {
                [] geoNetworkingPort.receive(
                    mw_geoNwInd(
                        mw_geoNwSecPdu(
                            mdw_securedMessage_CAMs(
                                ?,
                                ?,
                                {
                                    mw_trailer_field_signature(
                                        mw_signature(
                                            mw_ecdsaSignature(
                                                mw_eccPointecdsa_nistp256_with_sha256_y0_coordinate_only,
                                                ?
                                            )
                                        )
                                    )
                                }
                            ),
                            ?
                ))) {
                    tc_ac.stop;
                    log("*** " & testcasename() & ": PASS: Expected CAM message containing signature with the ECC point of type set to compressed_lsb_y_0 received ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                }
                [] geoNetworkingPort.receive(
                    mw_geoNwInd(
                        mw_geoNwSecPdu(
                            mdw_securedMessage_CAMs(
                                ?,
                                ?,
                                {
                                    mw_trailer_field_signature(
                                        mw_signature(
                                            mw_ecdsaSignature(
                                                mw_eccPointecdsa_nistp256_with_sha256_y1_coordinate_only,
                                                ?
                                            )
                                        )
                                    )
                                }
                            ),
                            ?
                ))) {
                    tc_ac.stop;
                    log("*** " & testcasename() & ": PASS: Expected CAM message containing signature with the ECC point of type set to compressed_lsb_y_1 received ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                }
                [] geoNetworkingPort.receive(
                    mw_geoNwInd(
                        mw_geoNwSecPdu(
                            mdw_securedMessage_CAMs(
                                ?,
                                ?,
                                {
                                    mw_trailer_field_signature(
                                        mw_signature(
                                            mw_ecdsaSignature(
                                                mw_eccPointecdsa_nistp256_with_sha256_x_coordinate_only
                                            )
                                        )
                                    )
                                }
                            ),
                            ?
                ))) {
                    tc_ac.stop;
                    log("*** " & testcasename() & ": PASS: Expected CAM message containing signature with the ECC point of type set to x_coordinate_only received ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                }
                [] geoNetworkingPort.receive(
                    mw_geoNwInd(
                        mw_geoNwSecPdu(
                            mdw_securedMessage_CAMs
                ))) {
                    tc_ac.stop;
                    log("*** " & testcasename() & ": Failed: Expected CAM message received ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                }
                [] tc_ac.timeout {
                    log("*** " & testcasename() & ": INCONC: Expected CAM not received ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                } 
            } // End of 'alt' statement
            
            // Postamble
            f_poNeighbour();
            f_cf01Down();
        } // End of testcase TC_SEC_ITSS_SND_MSG_05_01_BV
garciay's avatar
garciay committed
        /**
         * @desc Sending behaviour test cases for CAM profile
         * @see ETSI TS 103 096-2 V1.2.2 (2016-01) Clause 5.2.4 CAM profile
         */
        group sendCAMProfile {
            
            /**
             * @desc    Check that the sent Secured CAM contains a HeaderField its_aid that is set to 'AID_CAM' 
             * <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 requested to send a CAM
             *     } then {
             *         the IUT sends a SecuredMessage
             *             and containing header_fields['its_aid']
             *                 indicating 'AID_CAM'
             *     }
             * }
             * </pre>
             *
             * @see          ETSI TS 103 096-2 v1.2.2 TC_SEC_ITSS_SND_CAM_01_01_BV
             * @reference    ETSI TS 103 097 [1], clause 5.4 and 7.1
             */
            testcase TC_SEC_ITSS_SND_CAM_01_01_BV() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var GeoNetworkingInd v_geoNwInd;
                var HeaderFields v_headersFields;
                var integer v_previousHeaderType;
                
                // 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
                tc_ac.start;
                alt {
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mdw_securedMessage(
                                    superset(
                                        ?, 
                                        ?, 
                                        mw_header_field_its_aid_CAM
                                    )
                                ), 
                                ?
                    ))) -> value v_geoNwInd {
                        tc_ac.stop;
                        log("*** " & testcasename() & ": PASS: 'its_aid' is set to 'AID_CAM'");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                    }
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: Expected CAM not received ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                    } 
                } // End of 'alt' statement
                
                // Postamble
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_ITSS_SND_CAM_01_01_BV
            
            /**
             * @desc    Check that the secured CAM contains exactly one element of these header fields: signer_info, generation_time, its_aid.
                        Check that the header fields are in the ascending order according to the numbering of the enumeration except of the signer_info, which is encoded first.
                        Check that generation_time_standard_deviation, expiration, encryption_parameters, recipient_info are not used
             * <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 requested to send a CAM
             *     } then {
             *         the IUT sends a SecuredMessage  {
             *             containing header_fields[0]
             *                 containing type 
             *                     indicating 'signer_info'
             *             and containing header_fields [n].type
             *                 indicating value < header_fields [n+1].type
             *             and containing header_fields ['generation_time']
             *             and containing header_fields['its_aid']
             *                 indicating 'AID_CAM'
             *             and not containing header_fields['generation_time_standard_deviation']
             *             and not containing header_fields['expiration']
             *             and not containing header_fields['encryption_parameters']
             *             and not containing header_fields['recipient_info']
             *         }
             *     }
             * }
             * </pre>
             *
garciay's avatar
garciay committed
             * @see         ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_SND_CAM_02_01_BV
             * @reference    ETSI TS 103 097 [1], clause 7.1
            testcase TC_SEC_ITSS_SND_CAM_02_01_BV() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var GeoNetworkingInd v_geoNwInd;
                var HeaderFields v_headersFields;
                var integer v_previousHeaderType;
                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
                tc_ac.start;
                alt {
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mdw_securedMessage(
                                    superset(
                                        mw_header_field(
                                            e_signer_info
                                        ), 
                                        mw_header_field(e_generation_time), 
                                        mw_header_field_its_aid_CAM
                                    )
                                ), 
                                mw_geoNwPduWithPayload(
                                    ?,
                                    ?,
                                    mw_secCamPayload).packet
                    ))) -> value v_geoNwInd {
                        tc_ac.stop;
                        
                        // Process header fields manually
                        v_headersFields := valueof(v_geoNwInd.msgIn.gnPacket.securedMsg.header_fields);
                        
                        // Check that signerInfo is first header
                        if ((lengthof(v_headersFields) < 1) or not match(v_headersFields[0].type_, e_signer_info)) {
                            log("*** " & testcasename() & ": FAIL: SignerInfo is not first header");
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                        }
                       
                        for (var integer v_counter := 1; v_counter < lengthof(v_headersFields); v_counter := v_counter + 1) {
                            // Check forbidden header
                            // FIXME: 'generation_time_with_confidence' does not exist. is it e_generation_time_standard_deviation ?
                            if (match(v_headersFields[v_counter].type_, e_generation_time_standard_deviation)) {
                                log("*** " & testcasename() & ": FAIL: Forbidden header present");
                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                            } 
                            if (match(v_headersFields[v_counter].type_, e_signer_info)) {
                                log("*** " & testcasename() & ": FAIL: multiple instances of signer_info header");
                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                            } 
                            
                            if (v_counter > 1 ) {
                                // Check that headers are ordered
                                if (match(v_headersFields[v_counter].type_, integer:(0..v_previousHeaderType))) {
                                    // Check that header is duplicated
                                    if (match(v_headersFields[v_counter].type_, v_previousHeaderType)) {
                                        log("*** " & testcasename() & ": FAIL: multiple instances of same header");
                                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                                    }else{
                                        log("*** " & testcasename() & ": FAIL: headers not in correct order");
                                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                                    }
                            v_previousHeaderType := enum2int(v_headersFields[v_counter].type_);
                        } // End of 'for' statement
                        
                        log("*** " & testcasename() & ": PASS: correct secured packet received");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                    }
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: Expected CAM not received ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                    } 
                } // End of 'alt' statement
                
                // Postamble
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_ITSS_SND_CAM_02_01_BV
garciay's avatar
garciay committed
            // TODO To be removed
//            /**
//             * @desc    Check that the secured CAM contains in the normal case the signer_info field of type certificate_digest_with_sha256
//             * <pre>
//             * Pics Selection: none
//             * Config Id: CF01
//             * Initial conditions:
//             *  with {
//             *      the IUT being in the 'authorized' state
//             *      and the IUT is configured to send more than one CAM per second
//             *      and the IUT having sent last CAM
//             *          containing header_fields['signer_info'].signer.type
//             *              indicating 'certificate'
//             *  }
//             *  ensure that {
//             *      when {
//             *          the IUT is requested to send next CAM
//             *  } then {
//             *          the IUT sends a SecuredMessage
//             *              containing header_fields['signer_info'] {
//             *                  containing signer
//             *                      containing type
//             *                          indicating 'certificate_digest_with_sha256'
//             *                      containing digest
//             *                  containing header_fields['its_aid']
//             *                      indicating 'AID_CAM'
//             *              }
//             *      }
//             *  }
//             * </pre>
//             *
//             * @see            FIXME - test case is not part of ETSI TS 103 096-2 v1.2.2
//             * @reference    ETSI TS 103 097 V1.1.15, clause 7.1
//             */
//            testcase TC_SEC_ITSS_SND_CAM_04_01_BV() runs on ItsGeoNetworking system ItsSecSystem {
//                
//                // Local variables
//                var integer v_cntCert   := 0;
//                var integer v_cntDigest := 0;
//                var integer v_cntTimeLimit := float2int(PX_TAC);
//                
//                var ItsCam v_component;
//                
//                // 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();
//                geoNetworkingPort.clear;
//                v_component := f_setCamFrequencyGreatherThan1Hz();
//                tc_ac.start;
//                alt {
//                    [] geoNetworkingPort.receive(
//                        mw_geoNwInd(
//                            mw_geoNwSecPdu(
//                                mdw_securedMessage_CAMs(
//                                    mw_header_field_signer_info_certificate
//                    )))) {
//                        tc_ac.stop;
//                        log("*** " & testcasename() & ": INFO: Initial conditions: First CAM message with certificate received ***");
//                        f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
//                    }
//                    [] tc_ac.timeout {
//                        log("*** " & testcasename() & ": INCONC: Initial conditions: CAM message with certificate not received ***");
//                        f_selfOrClientSyncAndVerdictPreamble("error", e_timeout);
//                    }
//                }
//                
//                // Test Body
//                tc_ac.start;
//                alt {
//                    [] geoNetworkingPort.receive(
//                        mw_geoNwInd(
//                            mw_geoNwSecPdu(
//                                mdw_securedMessage_CAMs(
//                                    mw_header_field_signer_info_certificate
//                    )))) {
//                        v_cntCert := v_cntCert + 1;
//                        repeat;
//                    }
//                    [] geoNetworkingPort.receive(
//                        mw_geoNwInd(
//                            mw_geoNwSecPdu(
//                                mdw_securedMessage_CAMs(
//                                    mw_header_field_signer_info_digest
//                    )))) {
//                        v_cntDigest := v_cntDigest + 1;
//                        repeat;
//                    }
//                    [] geoNetworkingPort.receive(
//                        mw_geoNwInd(
//                            mw_geoNwSecPdu(
//                                mdw_securedMessage_CAMs
//                    ))) {
//                        log("*** " & testcasename() & ": FAIL: Neither Certificate not Digest in received CAM ***");
//                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
//                    }
//                    [] tc_ac.timeout {
//                        if (v_cntCert + v_cntDigest == 0 ){
//                            
//                            log("*** " & testcasename() & ": INCONC: Expected CAM not received ***");
//                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
//                        
//                        }else{
//                            
//                            log("*** " & testcasename() & ": INFO: Data accumulation time finished ***");
//                            
//                            if (v_cntCert + v_cntDigest <= v_cntTimeLimit * 2 ){
//                                log("*** " & testcasename() & ": INCONC:  The CAM frequency is too small ("
//                                        & int2str((v_cntCert + v_cntDigest)/v_cntTimeLimit)
//                                        & " per sec) ***");
//                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
//                            
//                            } else if (f_abs(v_cntCert - v_cntTimeLimit) > 2){
//                                log("*** " & testcasename() & ": FAIL: Digests are not as frequant as expected ***");
//                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
//                            
//                            } else {
//                                log("*** " & testcasename() & ": OK: Digests have been sent in normal case in high CAM frequency ***");
//                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
//                            }
//                        }
//                    }
//                } // End of 'alt' statement
//
//                // Postamble
//                f_terminateCam(v_component);
//                f_poNeighbour();
//                f_cf01Down();
//            } // End of testcase TC_SEC_ITSS_SND_CAM_04_01_BV
//            
garciay's avatar
garciay committed
             * @desc    Check that the secured CAM contains the signer_info field of certificate when over the time of one 
             *          second no other SecuredMessage contained a signer_info of type certificate.
             * Pics Selection: PICS_GN_SECURITY
             * Config Id: CF01
             * Initial conditions:
             * with {
             *     the IUT being in the 'authorized' state
             *     and the IUT is configured to send more then one CAM per second
             *     and the IUT having sent a CAM
             *         containing header_fields['signer_info'].signer.type
             *             indicating 'certificate'
             *         contains header_fields['generation_time']
             *             indicating TIME_LAST
             *     }
             * ensure that {
             *     when {
             *         the IUT sends one of the next SecuredMessage
garciay's avatar
garciay committed
             *             containing header_fields['signer_info']
             *                 containing signer
             *                     containing type
             *                         indicating 'certificate'
             *                     containing certificate
             *     } then {
             *         this message
             *             contains header_fields['generation_time']
             *                 indicating TIME (TIME >= TIME_LAST + 1sec)
             *     }
             * }
             * </pre>
             *
garciay's avatar
garciay committed
             * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_SND_CAM_05_01_BV
             * @reference    ETSI TS 103 097 [1], clause 7.1
            testcase TC_SEC_ITSS_SND_CAM_05_01_BV() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                const integer c_cntTimeLimit := 10;
                const float c_certificateGenerationTime := 1.0;
                
                timer t_minTransInterval := c_certificateGenerationTime * 0.8;
                var integer v_cntTime := 0;
                var GeoNetworkingInd v_geoNwInd;
                var ItsCam v_component;
                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();
                geoNetworkingPort.clear;
                v_component := f_setCamFrequencyGreatherThan1Hz();
                tc_ac.start;
                alt {
                     [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mdw_securedMessage_CAMs(
                                    mw_header_field_signer_info_certificate
                     )))) { 
                        tc_ac.stop;
                        t_minTransInterval.start;
                        log("*** " & testcasename() & ": INFO: Initial conditions: First CAM message with certificate received ***");
                        f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                    }
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: Initial conditions: CAM message with certificate not received ***");
                        f_selfOrClientSyncAndVerdictPreamble("error", e_timeout);
                    }
                } // End of 'alt' statement
                
                // Test Body
                tc_ac.start;
                alt {
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mdw_securedMessage_CAMs(
                                    mw_header_field_signer_info_certificate
                    )))) {
                        if(t_minTransInterval.running){
                            t_minTransInterval.stop;
                            log("*** " & testcasename() & ": FAIL: CAM with certificate has been received inside 1 sec after previous one ***");
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                        }
                        v_cntTime := v_cntTime + 1;
                        if (v_cntTime == c_cntTimeLimit) { // Exit message loop
                            log("*** " & testcasename() & ": PASS: Generation of CAM messages including certificate was successful ***");
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                            // end of alt
                        }
                        else {
                            log("*** " & testcasename() & ": INFO: CAM retransmission with certificate ***"); 
                            t_minTransInterval.start;
                            repeat;
                        }
                    }
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mdw_securedMessage_CAMs(
                                    mw_header_field_signer_info_digest
                        log("*** " & testcasename() & ": INFO: CAM retransmission with digest ***"); 
                        repeat;
                    }
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mdw_securedMessage_CAMs
                    ))) {
                        log("*** " & testcasename() & ": FAIL: Neither Certificate not Digest in received CAM ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                    }
                    [] t_minTransInterval.timeout {
                        log("*** " & testcasename() & ": INFO: One of next CAMS must have a certificate ***");
                        repeat;
                    }
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: Expected CAM not received ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                    }
                } // End of 'alt' statement
                
                // Postamble
                f_terminateCam(v_component);
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_ITSS_SND_CAM_05_01_BV
garciay's avatar
garciay committed
             * @desc    Check that the secured CAM contains the signer_info field of certificate when the timeout of 1 second 
             *          has been expired after the previous CAM containing the certificate.
             * Pics Selection: PICS_GN_SECURITY
             * Config Id: CF01
             * Initial conditions:
             *  with {
             *      the IUT being in the 'authorized' state
             *      and the IUT is configured to send more than one CAM per second
             *      and the IUT having sent a CAM
             *          containing header_fields['signer_info'].signer.type
             *              indicating 'certificate'
garciay's avatar
garciay committed
             *          at TIME_LAST 
             *  }
             *  ensure that {
             *      when {
             *          the IUT is requested to send next CAM right after 1 second after the TIME_1
             *      } then {
garciay's avatar
garciay committed
             *          the IUT sends a SecuredMessage
             *              containing header_fields ['signer_info']
             *                  containing signer
             *                      containing type
             *                          indicating 'certificate'
             *                      containing certificate
             *      }
             *  }
             * </pre>
             *
garciay's avatar
garciay committed
             * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_SND_CAM_05_02_BV
             * @reference    ETSI TS 103 097 [1], clause 7.1
            testcase TC_SEC_ITSS_SND_CAM_05_02_BV() runs on ItsGeoNetworking system ItsSecSystem {
                // Local variables
                const integer c_cntTimeLimit := 10;
                const float c_certificateGenerationTime := 1.0;
                
                timer t_maxTransInterval := c_certificateGenerationTime * 1.15;
                var integer v_cntTime := 0;
                var GeoNetworkingInd v_geoNwInd;
                var ItsCam v_component;
                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();
                geoNetworkingPort.clear;
                v_component := f_setCamFrequencyGreatherThan1Hz();
                tc_ac.start;
                alt {
                     [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mdw_securedMessage_CAMs(
                                    mw_header_field_signer_info_certificate
                     )))) { 
                        t_maxTransInterval.start;
                        tc_ac.stop;
                        log("*** " & testcasename() & ": INFO: Initial conditions: First CAM message with certificate received ***");
                        f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                    }
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: Initial conditions: CAM message with certificate not received ***");
                        f_selfOrClientSyncAndVerdictPreamble("error", e_timeout);
                    }
                } // End of 'alt' statement
                
                // Test Body
                tc_ac.start;
                alt {
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mdw_securedMessage_CAMs(
                                    mw_header_field_signer_info_certificate
                    )))) {
                        t_maxTransInterval.stop;
                        v_cntTime := v_cntTime + 1;
                        if (v_cntTime == c_cntTimeLimit) { // Exit message loop
                            log("*** " & testcasename() & ": PASS: Generation of CAM messages including certificate was successful ***");
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                            // end of alt
                            t_maxTransInterval.start;
                            log("*** " & testcasename() & ": INFO: CAM retransmission with certificate ***"); 
                            repeat;
                        }
                    }
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mdw_securedMessage_CAMs(
                                    mw_header_field_signer_info_digest
                    )))) {
                        log("*** " & testcasename() & ": INFO: CAM retransmission with digest ***"); 
                        repeat;
                    [] t_maxTransInterval.timeout {
                        log("*** " & testcasename() & ": FAIL: CAM with certificate was not received in 1 sec after previous one ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                    }
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: Expected CAM not received ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                    }
                } // End of 'alt' statement
                
                // Postamble
                f_terminateCam(v_component);
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_ITSS_SND_CAM_05_02_BV
garciay's avatar
garciay committed
             * @desc    Check that ITS-S sends a Secured CAM containing the signer_info of type certificate 
             *          when the ITS-S received a CAM from an unknown ITS-S 
             * Pics Selection: PICS_GN_SECURITY
             * Config Id: CF01
             * Initial conditions:
             *  with {
             *      the IUT being in the 'authorized' state
             *      and the IUT is configured to send more than one CAM per second
             *      and the IUT having already sent CAM at TIME_1
             *          containing header_fields['signer_info'].signer.type
             *              indicating 'certificate'
garciay's avatar
garciay committed
             *      and the IUT having received a SecuredMessage at TIME_2 (TIME_1 < TIME_2 < TIME_1+ 1sec)
             *          containing header_fields['signer_info']
             *              containing signer
             *                  containing type
             *                      indicating 'certificate_digest_with_sha256'
             *                  containing digest
             *                      indicating HashedId3 value
             *                          referenced to unknown certificate
             *  }
             *  ensure that {
             *      when {
garciay's avatar
garciay committed
             *          the IUT is requested to send CAM at TIME_3 (TIME_1 < TIME_2 < TIME_3 < TIME_1 + 1sec)
garciay's avatar
garciay committed
             *          the IUT sends a SecuredMessage
             *              containing header_fields[0]
             *                  containing type 
             *                      indicating 'signer_info'
garciay's avatar
garciay committed
             *                  and containing signer
             *                      containing type
             *                          indicating 'certificate'
garciay's avatar
garciay committed
             *                      and containing certificate
garciay's avatar
garciay committed
             * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_SND_CAM_06_01_BV
             * @reference    ETSI TS 103 097 [1], clause 7.1
            testcase TC_SEC_ITSS_SND_CAM_06_01_BV() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var GeoNetworkingInd v_geoNwInd;
                var ItsCam v_component;
                timer t_maxTransInterval := 0.3;
                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();
                v_component := f_setCamFrequencyGreatherThan1Hz();
                tc_ac.start;
                alt {
                     [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mdw_securedMessage_CAMs(
                                    mw_header_field_signer_info_certificate
                     )))) { 
                        tc_ac.stop;
                        log("*** " & testcasename() & ": INFO: Initial conditions: First CAM message with certificate received ***");
                        
                        // Send secured message from unknown ITS-S
                        geoNetworkingPort.clear;
                        f_sendSecuredCam(cc_taCert_F, omit, e_certificate_digest_with_sha256);
                        
                        f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                    }
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: Initial conditions: CAM message with certificate not received ***");
                        f_selfOrClientSyncAndVerdictPreamble("error", e_timeout);
                    }
                }
                
                // Test Body
                t_maxTransInterval.start;
                tc_ac.start;
                alt {
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mdw_securedMessage_CAMs(
                                    mw_header_field_signer_info_certificate
                    )))) {
                        tc_ac.stop; 
                        t_maxTransInterval.stop;
                        log("*** " & testcasename() & ": PASS: Generation of CAM messages including certificate was successful ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                    }
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mdw_securedMessage_CAMs
                    ))) {
                        repeat;
                    }
                    [] t_maxTransInterval.timeout {
                        log("*** " & testcasename() & ": FAIL: CAM was transmited w/o unrecognized request header ***"); 
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                    }
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: Expected CAM not received ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                    }
                } // End of 'alt' statement
                
                // Postamble
                f_terminateCam(v_component);
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_ITSS_SND_CAM_06_01_BV
            
            /**
             * @desc    Check that IUT restart the certificate sending timer when the certificate has been sent
             * <pre>
             * Pics Selection: PICS_GN_SECURITY
             * Config Id: CF01
             * Initial conditions:
             *  with {
             *      the IUT being in the 'authorized' state
             *      and the IUT is configured to send more then one CAM per second
             *      and the IUT having already sent CAM at TIME_1
             *          containing header_fields['signer_info'].signer.type
             *              indicating 'certificate'
garciay's avatar
garciay committed
             *      and the IUT having received a CAM at TIME_2 (TIME_1 +0.3sec)
             *          containing header_fields['request_unrecognized_certificate']
             *              containing digests
             *                  containing HashedId3 value
             *                      referencing to the the IUT certificate
             *      and the IUT having sent CAM at TIME_3 (TIME_3 > TIME_2)
             *          containing header_fields['signer_info'].signer.type
             *              indicating 'certificate'
             *  }
             *  ensure that {
             *      when {
             *          the IUT is sending the next CAM at TIME_4
             *              containing header_fields['signer_info'].signer.type
             *                  indicating 'certificate'
             *      } then {
             *          the difference between TIME_4 and TIME_3 is about of 1sec
             *      }
             *  }
             * </pre>
             *
garciay's avatar
garciay committed
             * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_SND_CAM_07a_01_TI
             * @reference    ETSI TS 103 097 [1], clause 7.1
            testcase TC_SEC_ITSS_SND_CAM_07_01_TI() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                const float c_certificateGenerationTime := 1.0;
                
                timer t_maxTransInterval := c_certificateGenerationTime * 0.9;
                var GeoNetworkingInd v_geoNwInd;
                var SignerInfo v_signerInfo;
                var ItsCam v_component;
                var boolean v_firstCertReceived := false;
                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();
                v_component := f_setCamFrequencyGreatherThan1Hz();
                    [v_firstCertReceived == false] geoNetworkingPort.receive(
                                                    mw_geoNwInd(
                                                        mw_geoNwSecPdu(
                                                            mdw_securedMessage_CAMs(
                                                                mw_header_field_signer_info_certificate
                    )))) -> value v_geoNwInd {
                        log("*** " & testcasename() & ": INFO: Initial conditions: The first CAM with certificate is received ***");
                        v_firstCertReceived := true;
                        f_sleep(0.3);
                        // Send secured message with request for unrecognized certificate
                        f_getMsgSignerInfo(f_getSecuredMessage(v_geoNwInd.msgIn), v_signerInfo);
                        f_sendSecuredCam(
                            {
                                m_header_field_unrecognised_certificate(
                                    f_HashedId3FromHashedId8(
                                       f_calculateDigestFromCertificate(
                                           v_signerInfo.signerInfo.certificate
                                       )
                            },
                            e_certificate_digest_with_sha256
                        );
                        repeat;
                    }
                    [v_firstCertReceived == true] geoNetworkingPort.receive(
                                                    mw_geoNwInd(
                                                        mw_geoNwSecPdu(
                                                            mdw_securedMessage_CAMs(
                                                                mw_header_field_signer_info_certificate
                    )))) {
                        tc_ac.stop;
                        // start a timeout of one second to check
                        // that the next cert will be received after this timeout
                        t_maxTransInterval.start;
                        log("*** " & testcasename() & ": INFO: Initial conditions: The requested CAM with certificate is received ***");
                        f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                    }
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: Initial conditions: CAM message with certificate not received ***");
                        f_selfOrClientSyncAndVerdictPreamble("error", e_timeout);
                    }
                } // End of 'alt' statement
                
                // Test Body
                tc_ac.start;
                alt {
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mdw_securedMessage_CAMs(
                                    mw_header_field_signer_info_certificate
                    )))) {
                        tc_ac.stop;
                        t_maxTransInterval.stop;
                        log("*** " & testcasename() & ": FAIL: CAM certificate inclusion time wasn't restarted ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                    }
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mdw_securedMessage_CAMs
                    ))) {
garciay's avatar
garciay committed
                        log("*** " & testcasename() & ": INFO: CAM retransmission w/o certificate ***"); 
                    [] t_maxTransInterval.timeout {
                        tc_ac.stop;
                        log("*** " & testcasename() & ": PASS: The CAM certificate inclusion timer has been restarted ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                    }
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: Expected CAM not received ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                    }
                } // End of 'alt' statement
                
                // Postamble
                f_terminateCam(v_component);
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_ITSS_SND_CAM_07_01_TI
garciay's avatar
garciay committed
             * @desc    Check that the IUT sends the Secured CAM containing the signer_info of type certificate 
             *          when it received a CAM containing a request of unrecognized certificate that matches 
             *          with the currently used AT certificate ID of the IUT 
             * Pics Selection: PICS_GN_SECURITY
             * Config Id: CF01
             * Initial conditions:
             *  with {
             *      the IUT being in the 'authorized' state
             *      and the IUT is configured to send more than one CAM per second
             *      and the IUT having already sent CAM at TIME_1
             *          containing header_fields['signer_info'].signer.type
             *              indicating 'certificate' 
garciay's avatar
garciay committed
             *      and the IUT having received a SecuredMessage at TIME_2 (TIME_1 < TIME_2 < TIME_1 + 1sec)
             *          containing header_fields['request_unrecognized_certificate']
             *              containing digests {
             *                  containing HashedId3 value
             *                      referencing to the AT certificate
             *                  and not containing HashedId3 value
             *                      referencing to the AA certificate
             *              }
             *  }
             *  ensure that {
             *      when {
garciay's avatar
garciay committed
             *          the IUT is requested to send a CAM at TIME_3 (TIME_1 < TIME_2 < TIME_3 < TIME_1 + 1sec)
garciay's avatar
garciay committed
             *          the IUT sends a SecuredMessage
             *              containing header_fields['signer_info']
             *                  containing signer
             *                      containing type
             *                          indicating 'certificate'
             *                      containing certificate
             *                          referenced by the requested digest 
             *      }
             *  }
             * </pre>
             *
garciay's avatar
garciay committed
             * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_SND_CAM_08_01_BV
             * @reference    ETSI TS 103 097 [1], clause 7.1
            testcase TC_SEC_ITSS_SND_CAM_08_01_BV() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                const float c_certificateGenerationTime := 1.0;
                
                timer t_maxTransInterval := c_certificateGenerationTime * 0.9;
                var GeoNetworkingInd v_geoNwInd;
                var ItsCam v_component;
                var SignerInfo v_si;
                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();
                geoNetworkingPort.clear;
                v_component := f_setCamFrequencyGreatherThan1Hz();
                tc_ac.start;
                alt {
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mdw_securedMessage_CAMs(
                                    mw_header_field_signer_info_certificate
                    )))) -> value v_geoNwInd {
                        t_maxTransInterval.start;
                        
                        f_getMsgSignerInfo(f_getSecuredMessage(v_geoNwInd.msgIn),v_si);
                        
                        log("*** " & testcasename() & ": INFO: Initial conditions: First CAM message with certificate received ***");
                        
                        // Send secured message with request for unrecognized certificate
                        f_sendSecuredCam(
                                m_header_field_unrecognised_certificate(                // containing digests
                                    f_HashedId3FromHashedId8(                           // containing HashedId3 value
                                        f_calculateDigestFromCertificate(
                                            v_si.signerInfo.certificate                 //     referencing to the AT certificate
                                        )
                                    )    
                                                                                        // and not containing HashedId3 value referencing to the AA certificate
                                )
                        
                        f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                    }
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: Initial conditions: CAM message with certificate not received ***");
                        f_selfOrClientSyncAndVerdictPreamble("error", e_timeout);
                    }
                } // End of 'alt' statement
                
                // Test Body
                tc_ac.start;
                alt {
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mdw_securedMessage_CAMs(
                                    mw_header_field_signer_info_certificate(
                                        v_si.signerInfo.certificate
                                    )
                        t_maxTransInterval.stop;
                        log("*** " & testcasename() & ": PASS: Generation of CAM messages including certificate was successful ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success); 
                    }
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mdw_securedMessage_CAMs
                    ))) {
                        log("*** " & testcasename() & ": INFO: CAM retransmission w/o certificate ***"); 
                        repeat;
                    }
                    [] t_maxTransInterval.timeout {
                        tc_ac.stop; 
                        log("*** " & testcasename() & ": FAIL: Requested certificate was not received ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                    }
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: Expected CAM not received ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                    }
                } // End of 'alt' statement
                
                // Postamble
                f_terminateCam(v_component);
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_ITSS_SND_CAM_08_01_BV
garciay's avatar
garciay committed
             * @desc    Check that the sent secured CAM contains the signer_info of type certificate_chain 
             *          when the ITS-S has received a CAM containing a request of unrecognized certificate that matches 
             *          with the AA certificate ID that issued its currently used AT certificate ID of the IUT
             * Pics Selection: PICS_GN_SECURITY
             * Config Id: CF01
             * Initial conditions:
             *  with {
             *      the IUT being in the 'authorized' state
             *      and the IUT is configured to send more than one CAM per second
             *      and the IUT having already sent a CAM
             *          containing header_fields['signer_info'].signer.type
             *              indicating 'certificate'
             *          at TIME_1
             *      and the IUT having received a SecuredMessage
             *          containing header_fields['request_unrecognized_certificate'] {
             *              containing digests {
             *                  containing HashedId3 value
             *                      referencing to the AA certificate
             *              }
             *          }
             *          at TIME_2 (TIME_1 < TIME_2 < TIME_1+ 1sec)
             *  }
             *  ensure that {
             *      when {
             *          the IUT is requested to send a CAM
             *              at TIME_3 (TIME_1 < TIME_2 < TIME_3 < TIME_1+ 1sec)
             *      } then {
garciay's avatar
garciay committed
             *          the IUT sends a SecuredMessage
             *              containing header_fields['signer_info']
             *                  containing signer
             *                      containing type
             *                          indicating 'certificate_chain'
             *                      containing certificates[last]
             *                          indicating the AT certificate
             *                      containing certificates[last-1]
             *                          indicating the AA certificate
             *      }
             *  }
             * </pre>
             *
garciay's avatar
garciay committed
             * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_SND_CAM_09_01_BV
             * @reference    ETSI TS 103 097 [1], clause 7.1
            testcase TC_SEC_ITSS_SND_CAM_09_01_BV() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                const float c_certificateGenerationTime := 1.0;
                
                timer t_maxTransInterval := c_certificateGenerationTime * 0.9;
                var GeoNetworkingInd v_geoNwInd;
                var ItsCam v_component;
                var SignerInfo v_si;
                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();
                geoNetworkingPort.clear;
                v_component := f_setCamFrequencyGreatherThan1Hz();
                tc_ac.start;
                alt {
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mdw_securedMessage_CAMs(
                                    mw_header_field_signer_info_certificate
                    ))))  -> value v_geoNwInd { 
                        t_maxTransInterval.start;
                        f_getMsgSignerInfo(f_getSecuredMessage(v_geoNwInd.msgIn),v_si);
                        f_getCertificateSignerInfo(v_si.signerInfo.certificate, v_si);
                        log("*** " & testcasename() & ": INFO: Initial conditions: First CAM message with certificate received ***");
                                                
                        // Send secured message with request for unrecognized certificate
                        f_sendSecuredCam(
                            {
                                m_header_field_unrecognised_certificate(                    // containing digests
                                    f_HashedId3FromHashedId8(                               //     containing HashedId3 value
                                        v_si.signerInfo.digest                              //         referencing to the AA certificate
                                    )
                                )
                            });
                        
                        f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                    }
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: Initial conditions: CAM message with certificate not received ***");
                        f_selfOrClientSyncAndVerdictPreamble("error", e_timeout);
                    }
                } // End of 'alt' statement
                
                // Test Body
                tc_ac.start;
                alt {
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mdw_securedMessage_CAMs(
                                    mw_header_field_signer_info_certificate_chain
                    )))) -> value v_geoNwInd {
                        var SignerInfo v_signerInfo;
                        var CertificateChain v_certificates;
                        var integer v_certificateChainLength;
                        
                        t_maxTransInterval.stop;
                        // Extract certificate chain
                        f_getMsgSignerInfo(v_geoNwInd.msgIn.gnPacket.securedMsg, v_signerInfo);
                        v_certificates := v_signerInfo.signerInfo.certificates;
                        v_certificateChainLength := lengthof(v_certificates);
                        if (v_certificateChainLength >= 2) { // Check length
                            if ( // Check Content
                                not(
                                    (v_certificates[0].subject_info.subject_type == e_authorization_authority) and 
                                        // Check the certificate chain contains certificates[last] indicating the AT certificate
                                    (v_certificates[1].subject_info.subject_type == e_authorization_ticket)
                                        // Check the certificate chain contains certificates[last-1] indicating the AA certificate
                            )) {
                                log("*** " & testcasename() & ": FAIL: Unexpected certificate chain content ***");
                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error); 
                                log("*** " & testcasename() & ": PASS: Generation of CAM messages including certificate chain was successful ***");
                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                            } 
                            log("*** " & testcasename() & ": FAIL: Unexpected certificate chain content length ***");
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error); 
                        }
                    }
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mdw_securedMessage_CAMs
                    ))) {
                        log("*** " & testcasename() & ": INFO: CAM retransmission w/o certificate chain ***"); 
                        repeat;
                    }
                    [] t_maxTransInterval.timeout {
                        tc_ac.stop; 
                        log("*** " & testcasename() & ": FAIL: The certificate chain has not been received during 1 sec ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                    }
                    
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: Expected CAM not received ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                } // End of 'alt' statement
                
                // Postamble
                f_terminateCam(v_component);
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_ITSS_SND_CAM_09_01_BV
garciay's avatar
garciay committed
            /**
             * @desc    Check that the sent secured CAM contains exactly one HeaderField generation_time which is inside 
             *          the validity time of the certificate referenced by the signer_info
             * <pre>
             * Pics Selection: PICS_GN_SECURITY
             * Config Id: CF01
             * Initial conditions:
             *  with {
             *      the IUT being in the 'authorized' state
             *      the IUT being requested to include certificate in the next CAM 
             *  }
             *  ensure that {
             *      when {
             *          the IUT is requested to send CAM
             *      } then {
             *          the IUT sends a SecuredMessage {
             *              containing security_profile
             *                  indicating '1'
             *              containing header_fields ['generation_time'] {
             *                  containing generation_time
             *                      indicating TIME_1 (CUR_TIME - 5min <= TIME_1 <= CUR_TIME + 5min)
             *              }
             *              containing header_fields ['signer_info'] {
             *                  containing signer {
             *                      containing type
             *                          indicating 'certificate'
             *                      containing certificate {
             *                          not containing validity_restrictions['time_start_and_end']
             *                          or containing validity_restrictions['time_start_and_end'] {
             *                              containing start_validity
             *                                  indicating value <= TIME_1
             *                              containing end_validity
             *                                  indicating value > TIME_1
             *                          }
             *                      }
             *                  }
             *              }
             *              containing its_aid
             *                  indicating 'AID_CAM'
             *          }
             *      }
             *  }
             * </pre>
             *
             * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_SND_CAM_10_01_BV
             * @reference    ETSI TS 103 097 [1], clauses 5.4 and 7.1
             */
            testcase TC_SEC_ITSS_SND_CAM_10_01_BV() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                const integer c_timeThreshold := 1000 * 60; /** Time threshold in milliseconds */
                
                var GeoNetworkingInd v_geoNwInd;
                var SignerInfo v_signerInfo;
                var Certificate v_certificate;
                var HeaderField v_headerField;
                var Time64 v_generationTime;
                var ValidityRestriction v_validity;
                var integer v_currentTime, v_lowerBound, v_upperBound;
                
                // 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();
                
                // Test Body
                tc_ac.start;
                alt {
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mdw_securedMessage(
                                    superset(
                                        mw_header_field_generation_time, 
                                        mw_header_field_signer_info_certificate,
                                        mw_header_field_its_aid_CAM
                    ))))) -> value v_geoNwInd {
                        tc_ac.stop; 
                        log("*** " & testcasename() & ": INFO: CAM transmission with certificate ***");
                        
                        v_currentTime := f_getCurrentTime();
                        log("v_currentTime (us)=", v_currentTime * 1000);
                        v_lowerBound := (v_currentTime - c_timeThreshold) * 1000;
                        v_upperBound := (v_currentTime + c_timeThreshold) * 1000;
                        
                        // Extract generation_time
                        f_getMsgHeaderField(v_geoNwInd.msgIn.gnPacket.securedMsg, e_generation_time, v_headerField);
                        v_generationTime := v_headerField.headerField.generation_time;
                        
                        // Extract certificate
                        f_getMsgSignerInfo(v_geoNwInd.msgIn.gnPacket.securedMsg, v_signerInfo);
                        v_certificate := v_signerInfo.signerInfo.certificate;
                         
                        // Check current time 
                        if (match(v_generationTime, (v_lowerBound .. v_upperBound))) {
                            log("*** " & testcasename() & ": PASS: Generation time matches current time ***");
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success); 
                        } else {
                            log("*** " & testcasename() & ": FAIL: Generation time does not match current time " & int2str(v_currentTime) & " . ***");
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                        }   
                        
                        // Check generation_time validity
                        if (
                            not(f_getCertificateValidityRestriction(v_certificate, e_time_start_and_end, v_validity)) or 
                            (v_generationTime >= (v_validity.validity.time_start_and_end.start_validity * 1000000) and 
                            (v_generationTime < (v_validity.validity.time_start_and_end.end_validity * 1000000)))
                        ) {
                            log("*** " & testcasename() & ": PASS: Generation time within certificate validity ***");
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success); 
                        } else {
                            log ("start_validity (in us)=", v_validity.validity.time_start_and_end.start_validity * 1000000);
                            log ("end_validity (in us)  =", v_validity.validity.time_start_and_end.end_validity * 1000000);
                            log("*** " & testcasename() & ": FAIL: Generation time not within certificate validity ***");
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                        }
                    }
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mdw_securedMessage_CAMs
                    ))) {
                        log("*** " & testcasename() & ": INFO: CAM retransmission w/o certificate  ***"); 
                        repeat;
                    }
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: Expected CAM not received ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                    }
                } // End of 'alt' statement
                
                // Postamble
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_ITSS_SND_CAM_10_01_BV
            
garciay's avatar
garciay committed
            // TODO To be removed
//            /**
//             * @desc    Check that the sent Secured CAM contains exactly one HeaderField its_aid that is set to 'AID_CAM'
//             * <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 requested to send CAM
//             *      } then {
//             *          the IUT sends a SecuredMessage {
//             *              containing header_fields ['its_aid'] {
//             *                  containing its_aid
//             *                      indicating 'AID_CAM' (36)
//             *              }
//             *          }
//             *      }
//             *  }
//             * </pre>
//             *
//             * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_SND_CAM_11_01_BV
//             * @reference    ETSI TS 103 097 [1], clauses 5.4 and 7.1
//             */
//            testcase TC_SEC_ITSS_SND_CAM_11_01_BV() runs on ItsGeoNetworking system ItsSecSystem {
//                // Local variables
//                
//                // 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
//                tc_ac.start;
//                alt {
//                    [] geoNetworkingPort.receive(
//                        mw_geoNwInd(
//                            mw_geoNwSecPdu(
//                                mdw_securedMessage_CAMs,
//                                mw_geoNwPduWithPayload(
//                                    ?,
//                                    ?,
//                                    mw_secCamPayload).packet
//                    ))) {
//                        tc_ac.stop;
//                        log("*** " & testcasename() & ": PASS: CAM received as message_type 2");
//                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
//                    }
//                    [] geoNetworkingPort.receive(
//                        mw_geoNwInd(
//                            mw_geoNwSecPdu(
//                                mdw_securedMessage_dummy, 
//                                mw_geoNwPduWithPayload(
//                                    ?,
//                                    ?,
//                                    mw_secCamPayload).packet
//                    ))) {
//                        tc_ac.stop;
//                        log("*** " & testcasename() & ": FAIL: CAM received with different message_type");
//                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
//                    }
//                    [] tc_ac.timeout {
//                        log("*** " & testcasename() & ": INCONC: Expected CAM not received ***");
//                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
//                    }
//                } // End of 'alt' statement
//                
//                // Postamble
//                f_poNeighbour();
//                f_cf01Down();
//            } // End of testcase TC_SEC_ITSS_SND_CAM_11_01_BV
//            
garciay's avatar
garciay committed
             * @desc    Check that the IUT sends certificate request when it receives a message from unknown station
             * Pics Selection: PICS_GN_SECURITY
             * Config Id: CF01
             * Initial conditions:
             *  with {
             *      the IUT being in the 'authorized' state
garciay's avatar
garciay committed
             *      and the IUT has receiving a SecuredMessage
             *          containing header_fields['signer_info'].signer
             *              containing type
             *                  indicating 'certificate_digest_with_sha256'
             *              containing digest
             *                  indicating HashedId3 value DIGEST_A
             *                      referenced to unknown certificate
             *  }
             *  ensure that {
             *      when {
             *          the IUT is requested to send CAM
             *      } then {
garciay's avatar
garciay committed
             *          the IUT sends a SecuredMessage
             *              containing header_fields['request_unrecognized_certificate']
             *                  containing digests
             *                      containing HashedId3 value
             *                          indicating DIGEST_A
             *      }
             *  }
             * </pre>
             *
garciay's avatar
garciay committed
             * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_SND_CAM_12_01_BV
             * @reference    ETSI TS 103 097 [1], clause 7.1
            testcase TC_SEC_ITSS_SND_CAM_12_01_BV() runs on ItsGeoNetworking system ItsSecSystem {
                // Local variables
                var HashedId8 v_expectedHashedId8;
                var HashedId3 v_expectedHashedId3;
                var GeoNetworkingPdu v_securedGnPduToBeSent;
                
                // Test control
                if (not(PICS_GN_SECURITY)) {
                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY' required for executing the TC ***");
                    stop;
                }
                
                // Send secured message from unknown ITS-S
                // Test component configuration
                // Test adapter configuration
                
                // Preamble
                f_prNeighbour();
                
                f_getCertificateDigest(
                    cc_taCert_F,
                    v_expectedHashedId8
                );
                v_expectedHashedId3 := f_HashedId3FromHashedId8(v_expectedHashedId8);
                
                // preamble: waiting for CAM with certificate and send a CAM with unknown digest right after that
                v_securedGnPduToBeSent := f_prepareSecuredCam(cc_taCert_F);
                   
                geoNetworkingPort.clear;
                tc_ac.start;
                alt {
                    [] geoNetworkingPort.receive
                    {
                        f_sendGeoNetMessage(m_geoNwReq_linkLayerBroadcast(v_securedGnPduToBeSent));
                        tc_ac.stop;

                        log("*** " & testcasename() & ": INFO: Initial conditions: First CAM message with certificate received ***");
                        f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                    }                        
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: Initial conditions: CAM message with certificate not received ***");
                        f_selfOrClientSyncAndVerdictPreamble("error", e_timeout);
                    }
                } // End of preamble 'alt' statement

                // Test Body
                tc_ac.start;
                alt {
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mdw_securedMessage_CAMs(
                                    mw_header_field_request_unrecognized_certificate(
                                        { v_expectedHashedId3 }
                    ))))) {
                        tc_ac.stop;
                        log("*** " & testcasename() & ": PASS: CAM received with request for unrecognized certificate");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                    }
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mdw_securedMessage_CAMs
                        log("*** " & testcasename() & ": FAIL: CAM received without request for unrecognized certificate ***"); 
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                    }
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: Expected CAM not received ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                    }
                } // End of 'alt' statement
                
                // Postamble
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_ITSS_SND_CAM_12_01_BV
garciay's avatar
garciay committed
             * @desc    Check that the Secured CAM contains non-empty payload of type signed
             * Pics Selection: PICS_GN_SECURITY
             * Config Id: CF01
             * Initial conditions:
             *  with {
             *      the IUT being in the 'authorized' state
             *  }
             *  ensure that {
             *      when {
             *          the IUT is requested to send a CAM
             *      } then {
garciay's avatar
garciay committed
             *          the IUT sends a SecuredMessage
             *              containing payload_field
garciay's avatar
garciay committed
             *                  containing exactly one element of type Payload
             *                      containing type
             *                          indicating 'signed'
             *                      containing not-empty data
             *      }
             *  }
             * </pre>
             *
garciay's avatar
garciay committed
             * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_SND_CAM_14_01_BV
             * @reference    ETSI TS 103 097 [1], clause 7.1
            testcase TC_SEC_ITSS_SND_CAM_14_01_BV() runs on ItsGeoNetworking system ItsSecSystem {
                // Local variables
                // Test control
                if (not(PICS_GN_SECURITY)) {
                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY' required for executing the TC ***");
                    stop;
                }
                // Test component configuration
                // Test adapter configuration
                
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
                tc_ac.start;
                alt {
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mdw_securedMessage_CAMs(
                                    ?, 
                                    mw_payload(
                                        e_signed
                    ))))) {
                        tc_ac.stop;
                        
                        log("*** " & testcasename() & ": PASS: CAM received with exactly 1 signed payload");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                    }
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: Expected CAM not received ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                    }
                } // End of 'alt' statement
                
                // Postamble
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_ITSS_SND_CAM_14_01_BV
            
            /**
             * @desc    Check that the secured CAM contains only one TrailerField of type signature.
garciay's avatar
garciay committed
             *          Check that the signature contained in the SecuredMessage is calculated over the right fields by 
             *          cryptographically verifying the signature.
             * Pics Selection: PICS_GN_SECURITY
             * Config Id: CF01
             * Initial conditions:
             *  with {
             *      the IUT being in the 'authorized' state
             *  }
             *  ensure that {
             *      when {
             *          the IUT is requested to send a CAM
             *      } then {
garciay's avatar
garciay committed
             *          the IUT sends a SecuredMessage
            *              containing header_fields ['signer_info']
             *                  containing signer
             *                      containing type
             *                          indicating 'certificate_digest_with_sha256'
             *                      containing digest
             *                          referenced to the certificate
             *                              containing subject_info.subject_type
             *                                  indicating 'authorization_ticket' (2)
             *                              and containing subject_attributes['verification key'] (KEY)
garciay's avatar
garciay committed
             *                  or containing signer
             *                      containing type
             *                          indicating 'certificate'
             *                      containing certificate
             *                          containing subject_info.subject_type
             *                              indicating 'authorization_ticket' (2)
             *                          and containing subject_attributes['verification key'] (KEY)
garciay's avatar
garciay committed
             *              containing trailer_fields
             *                  containing single instance of type TrailerField
             *                      containing type
             *                          indicating 'signature'
             *                      containing signature
             *                          verifiable using KEY
             *      }
             *  }
             * </pre>
             *
garciay's avatar
garciay committed
             * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_SND_CAM_16_01_BV
             * @reference    ETSI TS 103 097 [1], clause 7.1
            testcase TC_SEC_ITSS_SND_CAM_16_01_BV() runs on ItsGeoNetworking system ItsSecSystem {
                
                //  Local variables
                const integer c_nbVerification := 3;
                var integer v_nbVerification := 0;
                var GeoNetworkingInd v_geoNwInd;
                var SignerInfo v_signerInfo;
                var Certificate v_certificate;
                var boolean v_certificateReceived := false;
                
                // Test control
                if (not(PICS_GN_SECURITY)) {
                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY' required for executing the TC ***");
                    stop;
                }
                
                // Test component configuration
                // Test adapter configuration
                
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
                tc_ac.start;
                alt {
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mdw_securedMessage_CAMs(
                                    mw_header_field_signer_info_certificate
                    )))) -> value v_geoNwInd { 
                        tc_ac.stop;
                        log("*** " & testcasename() & ": INFO: CAM message with certificate received ***");
                        f_getMsgSignerInfo(v_geoNwInd.msgIn.gnPacket.securedMsg, v_signerInfo);
                        v_certificate := v_signerInfo.signerInfo.certificate;
                        v_certificateReceived := true;
                        
                        if (f_verifyGnSecuredMessageSignatureWithCertificate(v_geoNwInd.msgIn.gnPacket.securedMsg, v_certificate) == false) {
                            log("*** " & testcasename() & ": FAIL: CAM received with invalide signature");
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                        }
                        
                        v_nbVerification := v_nbVerification + 1;
                        if (v_nbVerification < c_nbVerification) {
                            tc_ac.start;
                            repeat;
                        }
                    }
                    [v_certificateReceived == true] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mdw_securedMessage_CAMs(
                                    mw_header_field_signer_info_digest
                    )))) -> value v_geoNwInd {
                        tc_ac.stop;
                        
                        if (f_verifyGnSecuredMessageSignatureWithCertificate(v_geoNwInd.msgIn.gnPacket.securedMsg, v_certificate) == false) {
                            log("*** " & testcasename() & ": FAIL: CAM received with invalide signature");
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                        }
                        
                        v_nbVerification := v_nbVerification + 1;
                        if (v_nbVerification < c_nbVerification) {
                            tc_ac.start;
                            repeat;
                        }
                    }
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: Expected CAM not received ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                    }
                } // End of 'alt' statement
                log("*** " & testcasename() & ": PASS: All CAMs received with correct signature");
                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                
                // Postamble
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_ITSS_SND_CAM_16_01_BV
garciay's avatar
garciay committed
        } // End of group sendCAMProfile
garciay's avatar
garciay committed
        /**
         * @desc Sending behaviour test cases for DENM profile
         * @see ETSI TS 103 096-2 V1.2.2 (2016-01) Clause 5.2.5 DENM profile
         */
        group sendDENMProfile {
garciay's avatar
garciay committed
             * @desc   Check that the sent Secured DENM contains a HeaderField its_aid that is set to 'AID_DENM' 
             * Pics Selection: PICS_GN_SECURITY
             * Config Id: CF01
             * Initial conditions:
             * with {
             *   the IUT being in the 'authorized' state
             * }
             * ensure that {
             *   when {
             *     the IUT is requested to send DENM
             *   } then {
garciay's avatar
garciay committed
             *     the IUT sends a SecuredMessage
             *         containing header_fields ['its_aid']
             *             containing its_aid
             *                 indicating 'AID_DENM'
garciay's avatar
garciay committed
             * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_SND_DENM_01_01_BV
             * @reference    ETSI TS 103 097 [1], clause 5.4 and 7.2
garciay's avatar
garciay committed
            testcase TC_SEC_ITSS_SND_DENM_01_01_BV() runs on ItsGeoNetworking system ItsSecSystem {
                // Local variables
                var GeoNetworkingInd v_geoNwInd;
                var HeaderFields v_headersFields;
                var ItsDenm v_denmComponent;
                var integer v_previousHeaderType;
                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_denmComponent := f_triggerDenmEvent();
                tc_ac.start;
                alt {
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mdw_securedMessage(
                                    superset(
garciay's avatar
garciay committed
                                        ?, 
                                        ?, 
                                        ?, 
                                        mw_header_field_its_aid_DENM
                                    )
                                ), 
garciay's avatar
garciay committed
                                ?
                    ))) -> value v_geoNwInd {
garciay's avatar
garciay committed
                        log("*** " & testcasename() & ": PASS: 'its_aid' is set to 'AID_DENM'");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                    }
                    
                    // DENM without mandatory fields 
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mdw_securedMessage(
                                    superset(
                                        mw_header_field_its_aid_DENM
                                    )
                    )))) {
                        log("*** " & testcasename() & ": FAIL: Secured DENM doesnt contain required headers");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                    }
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: Expected DENM not received ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                    } 
                } // End of 'alt' statement
                
                // Postamble
                f_cancelDenmEvent(v_denmComponent);
                f_poNeighbour();
                f_cf01Down();
garciay's avatar
garciay committed
            } // End of testcase TC_SEC_ITSS_SND_DENM_01_01_BV
garciay's avatar
garciay committed
             * @desc   Check that the secured DENM contains exactly one element of these header fields: signer_info, generation_time, 
             *         generation_location, message_type.
             *         Check that the header fields are in the ascending order according to the numbering of the enumeration except 
             *         of the signer_info, which is encoded first.
             *         Check that generation_time_with_confidence (generation_time_standard_deviation) is not used
             * 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 requested to send DENM
garciay's avatar
garciay committed
             *     the IUT sends a SecuredMessage
             *       containing header_fields[0]
             *         containing type 
             *           indicating 'signer_info'
             *       containing header_fields [n].type
             *         indicating value less then header_fields [n+ 1].type
             *       containing header_fields ['generation_time']
             *       containing header_fields ['generation_location']
             *       not containing header_fields ['generation_time_with_confidence']
             *   }
             * }
             * </pre>
             * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_SND_DENM_02_01_BV
             * @reference    ETSI TS 103 097 [1], clause 7.2
             */
            testcase TC_SEC_ITSS_SND_DENM_02_01_BV() runs on ItsGeoNetworking system ItsSecSystem {
                // Local variables
                var GeoNetworkingInd v_geoNwInd;
                var HeaderFields v_headersFields;
                var ItsDenm v_denmComponent;
                var integer v_previousHeaderType;
                
                // 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
                v_denmComponent := f_triggerDenmEvent();
                tc_ac.start;
                alt {
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mdw_securedMessage(
                                    superset(
                                        mw_header_field( e_signer_info ), 
                                        mw_header_field( e_generation_time ), 
                                        mw_header_field( e_generation_location ), 
                                        mw_header_field_its_aid_DENM
                                    )
                                ), 
                                mw_geoNwAnyPacket_withPayload(
                                    ?
                    )))) -> value v_geoNwInd {
                        tc_ac.stop;
                        
                        // Process header fields manually
                        v_headersFields := valueof(v_geoNwInd.msgIn.gnPacket.securedMsg.header_fields);
                        
                        // Check that signerInfo is first header
                        if (lengthof(v_headersFields) < 1 or not match(v_headersFields[0].type_, e_signer_info)) {
                            log("*** " & testcasename() & ": FAIL: SignerInfo is not first header");
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);    
                        }
                       
                        v_previousHeaderType := enum2int(v_headersFields[0].type_);
                        for (var integer v_counter := 1; v_counter < lengthof(v_headersFields); v_counter := v_counter + 1) {
                            // Check forbidden header
                            // FIXME: 'generation_time_with_confidence' does not exist. is it e_generation_time_standard_deviation ?
                            if (match(v_headersFields[v_counter].type_, e_generation_time_standard_deviation)) {
                                log("*** " & testcasename() & ": FAIL: Forbidden header present");
                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                            }
                            if (match(v_headersFields[v_counter].type_, e_signer_info)) {
                                log("*** " & testcasename() & ": FAIL: multiple instances of signer_info header");
                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                            }
                            if (v_counter > 1 ) {
                                // Check that no header is duplicated
                                if (match(v_headersFields[v_counter].type_, v_previousHeaderType)) {
                                    log("*** " & testcasename() & ": FAIL: multiple instances of the same header");
                                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                                }
                                
                                // Check that headers are ordered
                                if (match(v_headersFields[v_counter].type_, integer:(0..v_previousHeaderType))) { 
                                    log("*** " & testcasename() & ": FAIL: headers are not in the correct order");
                                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                                }
                            }
                            v_previousHeaderType := enum2int(v_headersFields[v_counter].type_);
                        } // End of 'for' statement
                        
                        log("*** " & testcasename() & ": PASS: correct secured packet received");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                    }
                    
                    // DENM without mandatory fields 
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mdw_securedMessage(
                                    superset(
                                        mw_header_field_its_aid_DENM
                                    )
                    )))) {
                        log("*** " & testcasename() & ": FAIL: Secured DENM doesnt contain required headers");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                    }
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: Expected DENM not received ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                    } 
                } // End of 'alt' statement
                
                // Postamble
                f_cancelDenmEvent(v_denmComponent);
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_ITSS_SND_DENM_02_01_BV
            
            /**
             * @desc   Check that secured DENM contains the certificate as a signer_info 
             * <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 requested to send a DENM
             *   } then {
             *     the IUT sends a SecuredMessage
             *       containing header_fields['signer_info']
             *         containing signer
             *           containing type
             *             indicating 'certificate'
             *           containing certificate
             *   }
             * }
             * </pre>
             * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_SND_DENM_03_01_BV
             * @reference    ETSI TS 103 097 [1], clause 7.2
            testcase TC_SEC_ITSS_SND_DENM_03_01_BV() runs on ItsGeoNetworking system ItsSecSystem {
                // Local variables
                var GeoNetworkingInd v_geoNwInd;
                var HeaderFields v_headersFields;
                var HeaderFieldType v_previousHeaderType;
                var integer v_counter;
                var ItsDenm v_denmComponent;
                                
                // 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();
                v_denmComponent := f_triggerDenmEvent();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);    
                
                // Test Body
                tc_ac.start;
                alt {
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mdw_securedMessage_DENMs(
                                    mw_header_field_signer_info_certificate
                                ), 
                                mw_geoNwAnyPacket_withPayload(
                                    ?
                    )))) {
                        if (v_counter < 3) {
                            f_cancelDenmEvent(v_denmComponent);
                            v_counter := v_counter + 1;
                            v_denmComponent := f_triggerDenmEvent();
                            repeat;
                        } else {
                            tc_ac.stop;
                            log("*** " & testcasename() & ": PASS: DENM signed with certificate");
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                        }
                    }
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mdw_securedMessage_DENMs(
                    )))) {
                        tc_ac.stop;
                        log("*** " & testcasename() & ": FAIL: DENM signed with not a certificate");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                    }
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: Expected DENM not received ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                    }
                } // End of 'alt' statement
                
                // Postamble
                f_cancelDenmEvent(v_denmComponent);
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_ITSS_SND_DENM_03_01_BV
garciay's avatar
garciay committed
             * @desc   Check that Secured DENM generation time is inside the validity period of the signing certificate
             *         Check that generation time value is realistic 
             * Pics Selection: PICS_GN_SECURITY
             * Config Id: CF01
             * Initial conditions:
             * with {
             *   the IUT being in the 'authorized' state
             * }
             * ensure that {
             *   when {
             *     the IUT is requested to send a DENM
             *   } then {
garciay's avatar
garciay committed
             *     the IUT sends a SecuredMessage
             *       containing exactly one header_fields['generation_time'] 
             *           containing generation_time
             *               indicating TIME_1 (CUR_TIME - 10min <= TIME_1 <= CUR_TIME + 10min)
             *       containing header_fields['signer_info']
             *           containing signer {
             *               containing type
             *                   indicating 'certificate'
             *               containing certificate
             *                   containing validity_restrictions['time_end']
             *                       containing end_validity
             *                           indicating value > TIME_1
             *               or containing validity_restrictions['time_start_and_end']
             *                   containing start_validity
             *                       indicating value <= GEN_TIME
             *                   and containing end_validity
             *                       indicating value > GEN_TIME
             *               or containing validity_restrictions['time_start_and_duration']
             *                   containing start_validity (CERT_START_VALIDITY)
             *                       indicating value <= GEN_TIME
             *                   and containing duration
             *                       indicating value > GEN_TIME - CERT_START_VALIDITY
garciay's avatar
garciay committed
             * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_SND_DENM_04_01_BV
             * @reference   ETSI TS 103 097 [1], clauses 5.4 and 7.2
            testcase TC_SEC_ITSS_SND_DENM_04_01_BV() runs on ItsGeoNetworking system ItsSecSystem {
                // Local variables
                const integer        c_timeLimit := 10 * 60 * 1000000; // us
                var GeoNetworkingInd v_geoNwInd;
                var HeaderField      v_headerField;
                var Time64           v_generationTime;
                var Time64           v_curTime;
garciay's avatar
garciay committed
                var Time64           v_startTime, v_endTime, v_duration;
                var Certificate      v_cert;
                var ItsDenm          v_denmComponent;
                
                // 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
                v_denmComponent := f_triggerDenmEvent();
                tc_ac.start;
                alt {
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mdw_securedMessage(
                                    superset(
                                        mw_header_field(
                                            e_generation_time
                                        ),
                                        mw_header_field_signer_info_certificate,
                                        mw_header_field_its_aid_DENM
                                    )
                                ), 
                                mw_geoNwAnyPacket_withPayload(
                                    ?
                    )))) -> value v_geoNwInd {
                        tc_ac.stop;
                        v_curTime := f_getCurrentTime();
                        v_curTime := v_curTime * 1000; // Time64 is in microseconds 
garciay's avatar
garciay committed
                        log("v_curTime (us)=", v_curTime);
                        if (f_getMsgHeaderField(v_geoNwInd.msgIn.gnPacket.securedMsg, e_generation_time, v_headerField)) {
                            v_generationTime := v_headerField.headerField.generation_time; 
garciay's avatar
garciay committed
                            log("v_generationTime (us) = ", v_generationTime);
                            if (not match(v_generationTime, Time64:(v_curTime-c_timeLimit, v_curTime+c_timeLimit))) {
                                log("*** " & testcasename() & ": FAIL: DENM generation time is not in 10 min range");
                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                            }
                            
                            // Check that generation time is inside the certificate validation period
garciay's avatar
garciay committed
                            if (f_getMsgHeaderField(v_geoNwInd.msgIn.gnPacket.securedMsg, e_signer_info, v_headerField)) {
                                v_cert := v_headerField.headerField.signer.signerInfo.certificate;
                                
                                for (var integer v_counter := 0; v_counter < lengthof(v_cert.validity_restrictions); v_counter := v_counter + 1) {
                                    if (v_cert.validity_restrictions[v_counter].type_ == e_time_end) {
                                        v_endTime := v_cert.validity_restrictions[v_counter].validity.end_validity * 1000000;
                                        if (not match(v_generationTime, Time64:(0 .. v_endTime))){
                                            log("*** " & testcasename() & ": FAIL: DENM generation time is not inside the validity of the certificate");
                                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                                        }
garciay's avatar
garciay committed
                                    } else if (v_cert.validity_restrictions[v_counter].type_ == e_time_start_and_end) {
                                        v_endTime := v_cert.validity_restrictions[v_counter].validity.time_start_and_end.end_validity * 1000000;
                                        v_startTime := v_cert.validity_restrictions[v_counter].validity.time_start_and_end.start_validity * 1000000;
                                        if (not match(v_generationTime, Time64:(v_startTime .. v_endTime))){
                                            log("*** " & testcasename() & ": FAIL: DENM generation time is not inside the validity of the certificate");
                                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                                        }
garciay's avatar
garciay committed
                                    } else if (v_cert.validity_restrictions[v_counter].type_ == e_time_start_and_duration) {
                                        v_startTime := v_cert.validity_restrictions[v_counter].validity.time_start_and_duration.start_validity * 1000000;
garciay's avatar
garciay committed
                                        v_duration  := f_duration2time(v_cert.validity_restrictions[v_counter].validity.time_start_and_duration.duration_) * 1000000;
garciay's avatar
garciay committed
                                        if (not match(v_generationTime, Time64:(v_startTime .. v_duration))){
                                            log("*** " & testcasename() & ": FAIL: DENM generation time is not inside the validity of the certificate");
                                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                                        }
                                    } else {
                                        log("*** " & testcasename() & ": FAIL: Mal-formed the certificate");
                                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                                    }
                                } // End of 'for' statement
                                log("*** " & testcasename() & ": PASS: DENM generation time is inside the validity of the certificate");
                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                            }
                        }
                    }
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mdw_securedMessage_DENMs(
                    )))) {
                        tc_ac.stop;
                        log("*** " & testcasename() & ": FAIL: Invalid DENM received ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                    }
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: Expected DENM not received ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                    }
                } // End of 'alt' statement
                
                // Postamble
                f_cancelDenmEvent(v_denmComponent);
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_ITSS_SND_DENM_04_01_BV
garciay's avatar
garciay committed
             * @desc   Check that the secured DENM contains exactly one HeaderField generation_location 
             *         when AT certificate does not contain any region restrictions 
             * Pics Selection: PICS_GN_SECURITY and PICS_CERTIFICATE_SELECTION 
             * Config Id: CF01
             * with {
             *   the IUT has been authorized with the AT certificate (CERT_IUT_A)
             *     not containing validity_restrictions['region']
             * }
             * ensure that {
             *   when {
             *     the IUT is requested to send DENM
             *   } then {
garciay's avatar
garciay committed
             *     the IUT sends a SecuredMessage
             *       containing exactly one header_fields ['generation_location']
             *         containing generation_location
             *   }
             * }
             * </pre>
garciay's avatar
garciay committed
             * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_SND_DENM_05_01_BV
             * @reference    ETSI TS 103 097 [1], clause 7.2
            testcase TC_SEC_ITSS_SND_DENM_05_01_BV() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var ItsDenm     v_denmComponent;
                
                // Test control
                if (not(PICS_GN_SECURITY) or not(PICS_CERTIFICATE_SELECTION)) {
garciay's avatar
garciay committed
                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY and PICS_CERTIFICATE_SELECTION' required for executing the TC ***");
                // Test component configuration
                // CERT_IUT_A is the default one
                f_cf01Up();
                
                // Test adapter configuration
                
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
                v_denmComponent := f_triggerDenmEvent();
                tc_ac.start;
                alt {
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mdw_securedMessage_DENMs(
                                    mw_header_field_signer_info_certificate(
                                        mw_certificate(
                                            ?,
                                            ?,
                                            ?,
                                            superset(
                                                mw_validity_restriction_any_valid_region
                    ))))))) {
                        log("*** " & testcasename() & ": INFO: Skip DENM containing region restrictions ***");
                        repeat;
                    }
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mdw_securedMessage(
                                    superset(
                                        mw_header_field(
                                            e_generation_location
                                        ),
                                        mw_header_field_signer_info_certificate,
                                        mw_header_field_its_aid_DENM
                    ))))) {
                        // The certificate doesn't contain region restrictions because such messages was catched before 
                        tc_ac.stop;
                        log("*** " & testcasename() & ": PASS: DENM contains generation location ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                    }
                        
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mdw_securedMessage_DENMs(
                                    mw_header_field_signer_info_certificate
                    )))) {
                        // the message does not contain generation location 
                        tc_ac.stop;
                        log("*** " & testcasename() & ": PASS: DENM contains generation location ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                    }
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mdw_securedMessage_DENMs(
                    )))) {
                        tc_ac.stop;
                        log("*** " & testcasename() & ": FAIL: DENM doesn't contain generation location ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                    }
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: Expected DENM not received ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                    }
                } // End of 'alt' statement 
                
                // Postamble
                // Cancel DENM events
                f_cancelDenmEvent(v_denmComponent);
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_ITSS_SND_DENM_05_01_BV
            function f_TC_SEC_ITSS_SND_DENM_05_BV(
                                               in template GeographicRegion p_region := ?
            ) runs on ItsGeoNetworking {
                
                // Local variables
                var GeoNetworkingInd v_geoNwInd;
                var ItsDenm v_denmComponent;
                
                // Trigger DENM 
                v_denmComponent := f_triggerDenmEvent();
                tc_ac.start;
                alt {
                    // DENM contains generation location and certificate with region restrictions  
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mdw_securedMessage(
                                    superset(
                                        mw_header_field(
                                            e_generation_location
                                        ),
                                        mw_header_field_signer_info_certificate(
                                            mw_certificate(
                                                ?,
                                                ?,
                                                ?, 
                                                superset(
                                                    mw_validity_restriction_region(
                                                    )
                                                )
                                            )
                                        ),
                                        mw_header_field_its_aid_DENM
                    ))))) -> value v_geoNwInd {
                        var ValidityRestriction v_vr;
                        var HeaderField         v_hf;
                        tc_ac.stop;
                        // check that generation location is inside the circular region of the certificate
                        if (f_getMsgHeaderField(v_geoNwInd.msgIn.gnPacket.securedMsg, e_generation_location, v_hf)
                           and f_getCertificateValidityRestriction(v_geoNwInd.msgIn.gnPacket.securedMsg.header_fields[0].headerField.signer.signerInfo.certificate, e_region, v_vr)
                        ) {
                            if (f_isLocationInsideRegion(v_vr.validity.region, v_hf.headerField.generation_location)) {
                                log("*** " & testcasename() & ": PASS: DENM contains generation location inside the certificate validity region ***");
                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                            }else{
                                log("*** " & testcasename() & ": FAIL: DENM contains generation location outside the certificate validity region ***");
                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                            }
                        } else {
                            log("*** " & testcasename() & ": FAIL: IMPOSSIBLE!!! DENM generation location or certificate region restriction header field does not exist");
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                        }
                    }
                    // DENM signing certificate doesn't contains region restriction
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mdw_securedMessage(
                                    superset(
                                        mw_header_field_its_aid_DENM,
                                        mw_header_field(e_generation_location),
                                        mw_header_field_signer_info_certificate(
                                        mw_certificate(
                                            ?,
                                            ?,
                                            ?, 
                                            { } // DENM signing certificate doesn't 'contains region restriction
                        tc_ac.stop;
                        log("*** " & testcasename() & ": INCONC: DENM certificate doesn't contain region restriction");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
garciay's avatar
garciay committed
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mdw_securedMessage_DENMs(
                    )))) {
                        tc_ac.stop;
                        log("*** " & testcasename() & ": FAIL: DENM doesn't contain generation location ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                    }
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: Expected DENM not received ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                    }
                } // End of 'alt' statement
                
                f_cancelDenmEvent(v_denmComponent);
            } // End of function f_TC_SEC_ITSS_SND_DENM_05_BV
            
            /**
             * @desc   Check that the secured DENM contains exactly one HeaderField generation_location 
             *         which is inside the circular region containing in the validity restriction of the 
             *         certificate pointed by the signer_info field     
             * <pre>
             * Pics Selection: PICS_GN_SECURITY and PICS_CERTIFICATE_SELECTION and PICS_USE_CIRCULAR_REGION
             * Config Id: CF01
             * with {
             *   the IUT has been authorized with the AT certificate (CERT_IUT_B) {
             *     containing validity_restrictions ['region'] {
             *       containing region{
             *         containing region_type
             *           indicating 'circle'
             *         containing circular_region
             *           indicating REGION
             *       }
             *     }
             *   }
             * }
             * ensure that {
             *   when {
             *     the IUT is requested to send a DENM
             *   } then {
garciay's avatar
garciay committed
             *     the IUT sends a SecuredMessage
             *       containing exactly one header_fields ['generation_location']
             *         containing generation_location
             *           indicating value inside the REGION
             *     }
             *   }
             * }
             * </pre>
garciay's avatar
garciay committed
             * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_SND_DENM_05_02_BV
             * @reference    ETSI TS 103 097 [1], clause 7.2
            testcase TC_SEC_ITSS_SND_DENM_05_02_BV() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                
                // Test control
                if (not(PICS_GN_SECURITY) or not(PICS_CERTIFICATE_SELECTION) or not(PICS_USE_CIRCULAR_REGION)) {
garciay's avatar
garciay committed
                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY and PICS_CERTIFICATE_SELECTION and PICS_USE_CIRCULAR_REGION' required for executing the TC ***");
                
                // Test component configuration
                vc_hashedId8ToBeUsed := cc_iutCert_B;
                f_cf01Up();
                
                // Test adapter configuration
                
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
                f_TC_SEC_ITSS_SND_DENM_05_BV(mw_geographicRegion_circle);
                
                // Postamble
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_ITSS_SND_DENM_05_02_BV
            /**
             * @desc   Check that the secured DENM contains exactly one HeaderField generation_location 
             *         which is inside the rectangular region containing in the validity restriction 
garciay's avatar
garciay committed
             *         of the certificate pointed by the signer_info field
             * Pics Selection: PICS_GN_SECURITY and PICS_CERTIFICATE_SELECTION and PICS_USE_RECTANGULAR_REGION
             * Config Id: CF01
             * with {
garciay's avatar
garciay committed
             *   the IUT has been authorized with the AT certificate (CERT_IUT_C)
             *     containing validity_restrictions ['region']
             *       containing region
             *         containing region_type
             *           indicating 'rectangle'
             *         containing rectangular_region
             *           indicating REGION
             * }
             * ensure that {
             *   when {
             *     the IUT is requested to send a DENM
             *   } then {
garciay's avatar
garciay committed
             *     the IUT sends a SecuredMessage
             *       containing exactly one header_field ['generation_location']
             *         containing generation_location
             *           indicating value inside the REGION
             *   }
             * }
             * </pre>
garciay's avatar
garciay committed
             * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_SND_DENM_05_03_BV
             * @reference    ETSI TS 103 097 [1], clause 7.2
            testcase TC_SEC_ITSS_SND_DENM_05_03_BV() runs on ItsGeoNetworking system ItsSecSystem {
                if (not(PICS_GN_SECURITY) or not(PICS_CERTIFICATE_SELECTION) or not(PICS_USE_RECTANGULAR_REGION)) {
                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY' required for executing the TC ***");
                    stop;
                }
                
                // Test component configuration
                vc_hashedId8ToBeUsed := cc_iutCert_C;
                f_cf01Up();
                
                // Test adapter configuration
                
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);    
                
                // Test Body
                f_TC_SEC_ITSS_SND_DENM_05_BV(mw_geographicRegion_rectangular);
                
                // Postamble
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_ITSS_SND_DENM_05_03_BV
            
            /**
             * @desc   Check that the secured DENM contains exactly one HeaderField generation_location 
             *         which is inside the polygonal region containing in the validity restriction 
             *         of the certificate pointed by the signer_info field     
             * <pre>
             * Pics Selection: PICS_GN_SECURITY and PICS_CERTIFICATE_SELECTION and PICS_USE_POLYGONAL_REGION
             * Config Id: CF01
             * with {
garciay's avatar
garciay committed
             *   the IUT has been authorized with the AT certificate (CERT_IUT_D)
             *     containing validity_restrictions ['region']
             *       containing region
             *         containing region_type
             *           indicating 'polygon'
             *         containing polygonal_region
             *           indicating REGION
             * }
             * ensure that {
             *   when {
             *     the IUT is requested to send a DENM
             *   } then {
garciay's avatar
garciay committed
             *     the IUT sends a SecuredMessage
             *       containing exactly one header_field ['generation_location']
             *         containing generation_location
             *           indicating value inside the REGION
             *   }
             * }
             * </pre>
garciay's avatar
garciay committed
             * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_SND_DENM_05_04_BV
             * @reference    ETSI TS 103 097 [1], clause 7.2
            testcase TC_SEC_ITSS_SND_DENM_05_04_BV() runs on ItsGeoNetworking system ItsSecSystem {
                if (not(PICS_GN_SECURITY) or not(PICS_CERTIFICATE_SELECTION) or not(PICS_USE_POLYGONAL_REGION)) {
garciay's avatar
garciay committed
                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY and PICS_CERTIFICATE_SELECTION and PICS_USE_POLYGONAL_REGION' required for executing the TC ***");
                
                // Test component configuration
                vc_hashedId8ToBeUsed := cc_iutCert_D;
                f_cf01Up();
                
                // Test adapter configuration
                
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);    
                
                // Test Body
                f_TC_SEC_ITSS_SND_DENM_05_BV(mw_geographicRegion_polygonal);
                
                // Postamble
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_ITSS_SND_DENM_05_04_BV
            
            /**
             * @desc   Check that the secured DENM contains exactly one HeaderField generation_location 
             *         which is inside the identified region containing in the validity restriction 
             *         of the certificate pointed by the signer_info field      
             * <pre>
             * Pics Selection: PICS_GN_SECURITY and PICS_USE_IDENTIFIED_REGION and PICS_CERTIFICATE_SELECTION
             * Config Id: CF01
             * with {
garciay's avatar
garciay committed
             *   the IUT has been authorized with the AT certificate (CERT_IUT_E)
             *     containing validity_restrictions ['region']
             *       containing region
             *         containing region_type
             *           indicating 'id_region'
             *         containing identified_region
             *           indicating REGION
             * }
             * ensure that {
             *   when {
             *     the IUT is requested to send a DENM
             *   } then {
garciay's avatar
garciay committed
             *     the IUT sends a SecuredMessage 
             *          containing exactly one header_fields ['generation_location']
             *              containing generation_location
             *                  indicating value inside the REGION
             *   }
             * }
             * </pre>
garciay's avatar
garciay committed
             * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_SND_DENM_05_05_BV
             * @reference    ETSI TS 103 097 [1], clause 7.2
            testcase TC_SEC_ITSS_SND_DENM_05_05_BV() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                
                //  Test control
                if (not(PICS_GN_SECURITY) or not(PICS_USE_IDENTIFIED_REGION) or not(PICS_CERTIFICATE_SELECTION)) {
garciay's avatar
garciay committed
                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY and PICS_CERTIFICATE_SELECTION and PICS_CERTIFICATE_SELECTION' required for executing the TC ***");
                
                // Test component configuration
                vc_hashedId8ToBeUsed := cc_iutCert_E;
                f_cf01Up();
                
                // Test adapter configuration
                
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);    
                
                // Test Body
                f_TC_SEC_ITSS_SND_DENM_05_BV(mw_geographicRegion_identified);
                
                // Postamble
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_ITSS_SND_DENM_05_05_BV
            
            /**
             * @desc   Check that the secured DENM contains exactly one HeaderField generation_location 
             *         which is inside the region containing in the validity restriction 
             *         of the certificate pointed by the signer_info field
garciay's avatar
garciay committed
             * Pics Selection: PICS_GN_SECURITY and not PICS_CERTIFICATE_SELECTION
             * Config Id: CF01
             * with {
             *   the IUT being in the 'authorized' state
             * }
             * ensure that {
             *   when {
             *     the IUT is requested to send a DENM
             *   } then {
             *     the IUT sends a SecuredMessage {
             *       containing header_fields['signed_info'].certificate {
             *         containing validity_restrictions ['region']
             *         {
             *           containing region.region_type
             *             indicating 'circle'
             *           containing region.circular_region
             *             indicating REGION
             *         } or {
             *           containing region.region_type
             *             indicating 'rectangle'
             *           containing region.rectangular_region
             *             containing array of rectangles
             *               indicating REGION
             *         } or {
             *           containing region.region_type
             *             indicating 'polygonal'
             *           containing region.polygonal_region
             *             indicating REGION
             *         } or {      
             *           containing region.region_type
             *             indicating 'id_region'
             *           containing region.circular_region
             *             indicating REGION
             *         }
             *       }
             *       containing exactly one header_fields['generation_location']
             *         containing generation_location
             *           indicating location inside the REGION
             *   }
             * }
             * </pre>
garciay's avatar
garciay committed
             * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_SND_DENM_05_06_BV
             * @reference    ETSI TS 103 097 [1], clause 7.2
            testcase TC_SEC_ITSS_SND_DENM_05_06_BV() runs on ItsGeoNetworking system ItsSecSystem {
garciay's avatar
garciay committed
                if (not(PICS_GN_SECURITY) or PICS_CERTIFICATE_SELECTION) {
                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY and not PICS_CERTIFICATE_SELECTION ' required for executing the TC ***");
                
                // Test component configuration
                f_cf01Up();
                
                // Test adapter configuration
                
                // Preamble
                f_prNeighbour();
garciay's avatar
garciay committed
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success); 
                f_TC_SEC_ITSS_SND_DENM_05_BV(); // any type of regions
                
                // Postamble
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_ITSS_SND_DENM_05_06_BV
garciay's avatar
garciay committed
            // TODO To be removed
//            /**
//             * @desc   Check that the sent Secured DENM contains exactly one HeaderField its_aid that is set to 'AID_DENM' 
//             * <pre>
//             * Pics Selection: PICS_GN_SECURITY
//             * Config Id: CF01
//             * Initial conditions:
//             * with {
//             *     the IUT being in the 'authorized' state
//             * }
//             * Expected results:
//             * ensure that {
//             *     when {
//             *         the IUT is requested to send a DENM
//             *     } then {
//             *         the IUT sends a SecuredMessage {
//             *             containing header_fields ['its_aid'] {
//             *                 containing its_aid
//             *                     indicating 'AID_DENM' (37)
//             *              }
//             *         }
//             *     }
//             * }
//             * </pre>
//             * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_SND_DENM_06_01_BV
//             * @reference   ETSI TS 103 097 [1], clauses 5.4 and 7.2
//             */
//            testcase TC_SEC_ITSS_SND_DENM_06_01_BV() runs on ItsGeoNetworking system ItsSecSystem {
//                // Local variables
//                var ItsDenm v_denmComponent;
//                
//                //  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
//                v_denmComponent := f_triggerDenmEvent();
//                tc_ac.start;
//                alt {
//                    [] geoNetworkingPort.receive(
//                        mw_geoNwInd(
//                            mw_geoNwSecPdu(
//                                mdw_securedMessage_DENMs
//                    ))) {
//                        log("*** " & testcasename() & ": PASS: DENM ITS AID is right");
//                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
//                    }
//                    [] geoNetworkingPort.receive(
//                        mw_geoNwInd(
//                            mw_geoNwSecPdu(
//                                mdw_securedMessage_CAMs
//                    ))) {
//                        log("*** " & testcasename() & ": INFO: Skip CAM");
//                        repeat;
//                    }
//                    [] geoNetworkingPort.receive(
//                        mw_geoNwInd(
//                            mw_geoNwSecPdu(
//                                mdw_securedMessage
//                    ))) {
//                        log("*** " & testcasename() & ": FAIL: DENM ITS AID is wrong");
//                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
//                    }
//                    [] tc_ac.timeout {
//                        log("*** " & testcasename() & ": INCONC: Expected DENM not received ***");
//                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
//                    }
//                } // End of 'alt' statement 
//                
//                // Postamble
//                f_cancelDenmEvent(v_denmComponent);
//                f_poNeighbour();
//                f_cf01Down();
//            } // End of testcase TC_SEC_ITSS_SND_DENM_06_01_BV
//            
garciay's avatar
garciay committed
             * @desc   Check that the Secured DENM contains exactly one non-empty payload of type signed
             * Pics Selection: PICS_GN_SECURITY
             * Config Id: CF01
             * Initial conditions:
             * with {
             *     the IUT being in the 'authorized' state
             * }
             * Expected results:
             * ensure that {
             *     when {
             *         the IUT is requested to send a DENM
             *     } then {
garciay's avatar
garciay committed
             *         the IUT sends a SecuredMessage
             *             containing payload_field
             *                 containing exactly one element of type Payload
             *                     containing type
             *                         indicating 'signed'
             *                             containing not-empty data
garciay's avatar
garciay committed
             * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_SND_DENM_08_01_BV
             * @reference    ETSI TS 103 097 [1], clause 7.2
garciay's avatar
garciay committed
            testcase TC_SEC_ITSS_SND_DENM_08_01_BV() runs on ItsGeoNetworking system ItsSecSystem {
                // Local variables
                var ItsDenm v_denmComponent;
                
                //  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();
garciay's avatar
garciay committed
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
                v_denmComponent := f_triggerDenmEvent();
                tc_ac.start;
                alt {
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
garciay's avatar
garciay committed
                                mdw_securedMessage_DENMs(
                                    ?,
                                    mw_payload(e_signed)
                    )))) {
                        log("*** " & testcasename() & ": PASS: DENM payload is 'signed'");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                    }
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
garciay's avatar
garciay committed
                                mdw_securedMessage_DENMs(
                                    ?,
                                    mw_payload()
                    )))) {
                         log("*** " & testcasename() & ": FAIL: DENM payload is not 'signed'");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                    }
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
garciay's avatar
garciay committed
                                mdw_securedMessage_DENMs
garciay's avatar
garciay committed
                         log("*** " & testcasename() & ": FAIL: DENM payload is not exist");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                    }
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: Expected DENM not received ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                    }
garciay's avatar
garciay committed
                } // End of 'alt' statement
                
                // Postamble
                f_cancelDenmEvent(v_denmComponent);
                f_poNeighbour();
                f_cf01Down();
garciay's avatar
garciay committed
            } // End of testcase TC_SEC_ITSS_SND_DENM_08_01_BV
garciay's avatar
garciay committed
             * @desc   Check that the secured DENM contains only one TrailerField of type signature.
             *         Check that the signature contained in the SecuredMessage is calculated 
             *         over the right fields by cryptographically verifying the signature.     
             * Pics Selection: PICS_GN_SECURITY
             * Config Id: CF01
             * Initial conditions:
             * with {
garciay's avatar
garciay committed
             *   the IUT being in the 'authorized' state
garciay's avatar
garciay committed
             *   when {
             *     the IUT is requested to send DENM
             *   } then {
             *     the IUT sends a SecuredMessage
             *         containing header_field ['signer_info']
             *             containing signer
             *                 containing type
             *                   indicating 'certificate'
             *             containing certificate
             *                 containing subject_info.subject_type
             *                     indicating 'authorization_ticket' (2)
             *                 and containing subject_attributes['verification key'] (KEY)
             *                     containing trailer_fields
             *                         containing single instance of type TrailerField
             *                             containing type
             *                                 indicating 'signature'
             *                             and containing signature
             *                                 verifiable using KEY
             *   }
garciay's avatar
garciay committed
             * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_SND_DENM_10_01_BV
             * @reference   ETSI TS 103 097 [1], clause 7.2
garciay's avatar
garciay committed
            testcase TC_SEC_ITSS_SND_DENM_10_01_BV() runs on ItsGeoNetworking system ItsSecSystem {
                //  Local variables
                var GeoNetworkingInd v_geoNwInd;
                var SignerInfo v_signerInfo;
                var Certificate v_certificate;
                var ItsDenm v_denmComponent;
                
                //  Test control
                if (not(PICS_GN_SECURITY)) {
                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY' required for executing the TC ***");
                    stop;
                }
                
garciay's avatar
garciay committed
                //  Test component configuration
                f_cf01Up();
                
                // Preamble
                f_prNeighbour();
garciay's avatar
garciay committed
                v_denmComponent := f_triggerDenmEvent();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
                tc_ac.start;
                alt {
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mdw_securedMessage_DENMs(
garciay's avatar
garciay committed
                                    mw_header_field_signer_info_certificate
                    )))) -> value v_geoNwInd { 
                        tc_ac.stop;
                        log("*** " & testcasename() & ": INFO: DENM message with certificate received ***");
                        f_getMsgSignerInfo(v_geoNwInd.msgIn.gnPacket.securedMsg, v_signerInfo);
                        
                        if (f_verifyGnSecuredMessageSignatureWithCertificate(v_geoNwInd.msgIn.gnPacket.securedMsg, v_signerInfo.signerInfo.certificate) == false) {
                            log("*** " & testcasename() & ": FAIL: DENM received with invalide signature");
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                        }
garciay's avatar
garciay committed
                    
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mdw_securedMessage_DENMs
                    ))) {
garciay's avatar
garciay committed
                         log("*** " & testcasename() & ": FAIL: DENM doesn't contain signature");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                    }
garciay's avatar
garciay committed
                    
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: Expected DENM not received ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                    }
                } // End of 'alt' statement
garciay's avatar
garciay committed
                log("*** " & testcasename() & ": PASS: DENM received with correct signature");
                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                
                // Postamble
                f_cancelDenmEvent(v_denmComponent);
                f_poNeighbour();
                f_cf01Down();
garciay's avatar
garciay committed
            } // End of testcase TC_SEC_ITSS_SND_DENM_10_01_BV
                
        } // End of group sendDENMProfile
        
        /**
         * @desc Sending behaviour test cases for DENM profile
         * @see ETSI TS 103 096-2 V1.2.2 (2016-01) Clause 5.2.6 Generic signed message profile
         */
        group sendOtherProfile {
garciay's avatar
garciay committed
             * @desc        Check that the secured message contains of type signed 
garciay's avatar
garciay committed
             * Pics Selection: PICS_GN_SECURITY and PICS_ITS_AID_OTHER_PROFILE
             * Config Id: CF01
             * Initial conditions:
             * with {
garciay's avatar
garciay committed
             *     the IUT being in the 'authorized' state
garciay's avatar
garciay committed
             * Expected results:
garciay's avatar
garciay committed
             *     when {
             *         the IUT is requested to send a Beacon
             *     } then {
             *         the IUT sends a SecuredMessage {
             *            not containing header_field ['its_aid']
             *              indicating 'AID_CAM'
             *            not containing header_field ['its_aid']
             *              indicating 'AID_DENM'
garciay's avatar
garciay committed
             *            containing payload_fields
             *              containing exactly one element of type Payload {
             *                containing type
             *                  indicating 'signed'
             *              }
             *         }
garciay's avatar
garciay committed
             * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_SND_GENMSG_06_01_BV
             * @reference    ETSI TS 103 097 [1], clause 5.4 and 7.3
garciay's avatar
garciay committed
            testcase TC_SEC_ITSS_SND_GENMSG_01_01_BV() runs on ItsGeoNetworking system ItsSecSystem {
garciay's avatar
garciay committed
                // Local variables
                var LongPosVector v_longPosVectorIut;
                
                // Test adapter configuration
                if (not(PICS_GN_SECURITY) or not(PICS_ITS_AID_OTHER_PROFILE)) {
                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY and PICS_ITS_AID_OTHER_PROFILE' required for executing the TC ***");
garciay's avatar
garciay committed
                // Test component configuration
garciay's avatar
garciay committed
                v_longPosVectorIut := f_getPosition(c_compIut);
                
                // Test adapter configuration
                
                // Preamble
                f_prNeighbour();
garciay's avatar
garciay committed
                f_acTriggerEvent(m_startPassBeaconing(m_beaconHeader(v_longPosVectorIut).beaconHeader)); // Authorize the TA to forward the received beacons
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);    
                
                // Test Body
                tc_ac.start;
                alt {
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
garciay's avatar
garciay committed
                                mdw_securedMessage(
                                    superset(
                                        ?, 
                                        ?, 
                                        mw_header_field_its_aid_Other
                                    )
                                ), 
                                ?
garciay's avatar
garciay committed
                        tc_ac.stop;
                        log("*** " & testcasename() & ": PASS: 'its_aid' is neither set to 'AID_CAM' nor 'AID_DENM'");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                    [] tc_ac.timeout {
garciay's avatar
garciay committed
                        log("*** " & testcasename() & ": INCONC: Expected Message not received ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                    }
                } // End of 'alt' statement
                
                // Postamble
garciay's avatar
garciay committed
                f_acTriggerEvent(m_stopPassBeaconing);
                f_poNeighbour();
                f_cf01Down();
garciay's avatar
garciay committed
            } // End of testcase TC_SEC_ITSS_SND_GENMSG_01_01_BV
            
            /**
             * @desc   Check that the generic secured message contains exactly one element of these header fields: 
             *             signer_info, generation_time, generation_location.
             *         Check that the header fields are in the ascending order according to the numbering of the enumeration
             *             except of the signer_info, which is encoded first.   
             * <pre>
             * Pics Selection: PICS_GN_SECURITY and PICS_ITS_AID_OTHER_PROFILE
             * Config Id: CF01
             * Initial conditions:
             * with {
             *   the IUT being in the 'authorized' state
             * }
             * Expected Results:
             * ensure that {
             *   when {
             *     the IUT is requested to send a Beacon
             *   } then {
garciay's avatar
garciay committed
             *     the IUT sends a SecuredMessage
             *         containing header_fields [0].type
             *             indicating 'signer_info'
             *         and containing header_fields [1..n] 
             *             where header_fields [v_counter].type < header_fields [v_counter + 1].type
             *         and containing header_fields ['generation_time']
             *         and containing header_fields ['generation_location']
             *         and containing header_field ['its_aid']
garciay's avatar
garciay committed
             * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_SND_GENMSG_02_01_BV
             * @reference    ETSI TS 103 097 [1], clause 7.3
            testcase TC_SEC_ITSS_SND_GENMSG_02_01_BV() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var LongPosVector v_longPosVectorIut;
                var GeoNetworkingInd v_geoNwInd;
                var HeaderFields v_headersFields;
                var HeaderFieldType v_previousHeaderType;
                var integer v_counter;
                
                // Test control
                if (not(PICS_GN_SECURITY) or not(PICS_ITS_AID_OTHER_PROFILE)) {
                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY and PICS_ITS_AID_OTHER_PROFILE' required for executing the TC ***");
                    stop;
                }
                
                // Test component configuration
                f_cf01Up();
                v_longPosVectorIut := f_getPosition(c_compIut);
                
                // Test adapter configuration
                
                // Preamble
                f_prNeighbour();
                f_acTriggerEvent(m_startPassBeaconing(m_beaconHeader(v_longPosVectorIut).beaconHeader)); // Authorize the TA to forward the received beacons
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);    
                
                // Test Body
                tc_ac.start;
                alt {
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mdw_securedMessage(
                                    superset(
                                        mw_header_field(e_generation_time), 
                                        mw_header_field(e_generation_location),
                                        mw_header_field_its_aid_Other
                                    )
                                ), 
                                mw_geoNwBeaconPacket(
                                    ?
                    )))) -> value v_geoNwInd {
                        tc_ac.stop;
                        
                        // Process header fields manually
                        v_headersFields := valueof(v_geoNwInd.msgIn.gnPacket.securedMsg.header_fields);
                        
                        // Check that signerInfo is first header
                        if (lengthof(v_headersFields) < 1 or not match(v_headersFields[0].type_, e_signer_info)) {
                            log("*** " & testcasename() & ": FAIL: SignerInfo is not first header");
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);    
                        }
                        
                        for (v_counter := 1; v_counter < lengthof(v_headersFields); v_counter := v_counter + 1) {
                            // Check that no header is duplicated
                            if (match(v_headersFields[v_counter].type_, e_signer_info)) {
                                log("*** " & testcasename() & ": FAIL: multiple instances of signer_info");
                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                            }
                            
                            if (v_counter > 1) {
                                // Check that headers are ordered
                                if (v_headersFields[v_counter].type_ == v_previousHeaderType) {
                                    log("*** " & testcasename() & ": FAIL: multiple instances of same Header");
                                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                                }
                                if (v_headersFields[v_counter].type_  < v_previousHeaderType) {
                                    log("*** " & testcasename() & ": FAIL: headers not in correct order");
                                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                                }
                            }
                            v_previousHeaderType := v_headersFields[v_counter].type_;
                        } // End of 'for' statement
                        
                        log("*** " & testcasename() & ": PASS: correct secured packet received");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                    }
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: Expected DENM not received ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                    }
                } // End of 'alt' statement
                
                // Postamble
                f_acTriggerEvent(m_stopPassBeaconing);
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_ITSS_SND_GENMSG_02_01_BV
            
            /**
             * @desc   Check that generic secured message contains the certificate as a signer_info
             * <pre>
             * Pics Selection: PICS_GN_SECURITY and PICS_ITS_AID_OTHER_PROFILE
             * Config Id: CF01
             * Initial Conditions:
             * with {
             *   the IUT being in the 'authorized' state
             * }
             * Expected Behaviour
             * ensure that {
             *   when {
             *     the IUT is requested to send a Beacon
             *   } then {
garciay's avatar
garciay committed
             *     the IUT sends a SecuredMessage
             *         containing exactly one header_fields ['signer_info']
             *             containing signer
             *                 containing type
             *                     indicating 'certificate'
             *         and containing certificate
garciay's avatar
garciay committed
             * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_SND_GENMSG_03_01_BV
             * @reference    ETSI TS 103 097 [1], clause 7.3
            testcase TC_SEC_ITSS_SND_GENMSG_03_01_BV() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var LongPosVector v_longPosVectorIut;
                
                // Test control
                if (not(PICS_GN_SECURITY) or not(PICS_ITS_AID_OTHER_PROFILE)) {
                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY and PICS_ITS_AID_OTHER_PROFILE' required for executing the TC ***");
                    stop;
                }
                
                // Test component configuration
                f_cf01Up();
                v_longPosVectorIut := f_getPosition(c_compIut);
                
                // Test adapter configuration
                
                // Preamble
                f_prNeighbour();
                f_acTriggerEvent(m_startPassBeaconing(m_beaconHeader(v_longPosVectorIut).beaconHeader)); // Authorize the TA to forward the received beacons
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
                tc_ac.start;
                alt {
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                 mdw_securedMessage_Others(
                                    mw_header_field_signer_info_certificate
                                ), 
                                mw_geoNwBeaconPacket(
                                    ?
                    )))) { 
                        tc_ac.stop;
                        log("*** " & testcasename() & ": PASS: Beacon signed with certificate ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                    }
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mdw_securedMessage_Others(
                                    mw_header_field(
                                        e_signer_info
                                    )
                                ),
                                mw_geoNwBeaconPacket(
                                    ?
                    )))) { 
                        log("*** " & testcasename() & ": INFO: Beacon signed with digest ***");
                        repeat;
                    }
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: Expected Beacon not received ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                    }
                } // End of 'alt' statement
                
                // Postamble
                f_acTriggerEvent(m_stopPassBeaconing);
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_ITSS_SND_GENMSG_03_01_BV
            
            /**
             * @desc   Check that message generation time is inside the validity period of the signing certificate
garciay's avatar
garciay committed
             *         Check that message generation time value is realistic
             * Pics Selection: PICS_GN_SECURITY and PICS_ITS_AID_OTHER_PROFILE
             * Config Id: CF01
             * Initial conditions:
             * with {
             *   the IUT being in the 'authorized' state
             * }
             * Expected behaviour:
             * ensure that {
             *   when {
             *     the IUT is requested to send a Beacon
             *   } then {
garciay's avatar
garciay committed
             *     the IUT sends a SecuredMessage
             *       containing exactly one header_fields['generation_time']
             *           containing generation_time
             *               indicating TIME_1 (CUR_TIME - 10min <= TIME_1 <= CUR_TIME + 10min)
             *       containing header_fields['signer_info']
             *           containing signer
             *               containing type
             *                   indicating 'certificate'
             *           containing certificate
             *               containing validity_restrictions['time_end']
                                 containing end_validity
                                     indicating value > GEN_TIME
             *               and containing validity_restrictions['time_start_and_end']
             *                   containing start_validity
             *                       indicating value <= TIME_1
             *                   and containing end_validity
             *                       indicating value > TIME_1
             *               or containing validity_restrictions['time_start_and_duration']
             *                   containing start_validity (CERT_START_VALIDITY)
             *                       indicating value <= GEN_TIME
             *                   and containing duration
             *                       indicating value > GEN_TIME - CERT_START_VALIDITY
garciay's avatar
garciay committed
             * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_SND_GENMSG_04_01_BV
             * @reference    ETSI TS 103 097 [1], clauses 5.4 and 7.3
            testcase TC_SEC_ITSS_SND_GENMSG_04_01_BV() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var LongPosVector    v_longPosVectorIut;
                var GeoNetworkingInd v_geoNwInd;
                var HeaderField      v_headerField;
                var Time64           v_generationTime;
                var Time64           v_curTime;
garciay's avatar
garciay committed
                var Time64           v_startTime, v_endTime, v_duration;
                var Certificate      v_cert;
                var integer          v_counter;
                
                // Test control
                if (not(PICS_GN_SECURITY) or not(PICS_ITS_AID_OTHER_PROFILE)) {
                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY and PICS_ITS_AID_OTHER_PROFILE' required for executing the TC ***");
                    stop;
                }
                
                // Test component configuration
                f_cf01Up();
                v_longPosVectorIut := f_getPosition(c_compIut);
                
                // Test adapter configuration
                
                // Preamble
                f_prNeighbour();
                f_acTriggerEvent(m_startPassBeaconing(m_beaconHeader(v_longPosVectorIut).beaconHeader)); // Authorize the TA to forward the received beacons
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);    
                
                // Test Body
                tc_ac.start;
                alt {
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mdw_securedMessage(
                                    superset(
                                        mw_header_field(
                                            e_generation_time
                                        ),
                                        mw_header_field_signer_info_certificate,
                                        mw_header_field_its_aid_Other
                                    )
                                ), 
                                mw_geoNwBeaconPacket(
                                    ?
                                )
                            )
                    )) -> value v_geoNwInd { 
                        const integer c_deltaTime := 2 * 3600 * 1000000; // Two hours, in microsecoonds
                        
                        tc_ac.stop;
                        v_curTime := f_getCurrentTime();
                        v_curTime := v_curTime * 1000; // Clause 4.2.16 Time64: is in microseconds
                        
                        if (
                            f_getMsgHeaderField(
                                v_geoNwInd.msgIn.gnPacket.securedMsg,
                                e_generation_time, 
                                v_headerField
                        )) {
                            v_generationTime := v_headerField.headerField.generation_time;  
                            log("v_generationTime=", v_generationTime);
                            log("v_curTime=", v_curTime);
                            log("v_curTime - c_deltaTime=", v_curTime - c_deltaTime);
                            if (v_generationTime < (v_curTime - c_deltaTime)) {
                                log("*** " & testcasename() & ": FAIL: Beacon generation time is too far in the past");
                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                            }
                            
                            if (v_generationTime > (v_curTime + c_deltaTime)) {
                                log("*** " & testcasename() & ": FAIL: Beacon generation time is too far in the future");
                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                            }
                            
                            // Check that generation time is inside the certificate validation period
                            if (
                                f_getMsgHeaderField(
                                    v_geoNwInd.msgIn.gnPacket.securedMsg,
                                    e_signer_info, 
                                    v_headerField
                            )) {
                                v_cert := v_headerField.headerField.signer.signerInfo.certificate;
                                
                                for (v_counter := 0; v_counter < lengthof(v_cert.validity_restrictions); v_counter := v_counter + 1) {
                                    if (v_cert.validity_restrictions[v_counter].type_ == e_time_end) {
                                        v_endTime := v_cert.validity_restrictions[v_counter].validity.end_validity * 1000000;
                                        if (v_generationTime > v_endTime ) {
                                            log("*** " & testcasename() & ": FAIL: Beacon generation time is not inside the validity of the certificate");
                                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                                        }
                                    }
garciay's avatar
garciay committed
                                    if (v_cert.validity_restrictions[v_counter].type_ == e_time_end) {
                                        v_endTime   := v_cert.validity_restrictions[v_counter].validity.end_validity * 1000000;
                                        if (v_generationTime > v_endTime ) {
                                            log("*** " & testcasename() & ": FAIL: Beacon generation time is not inside the validity of the certificate");
                                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                                        }
                                    } else if (v_cert.validity_restrictions[v_counter].type_ == e_time_start_and_end) {
                                        v_endTime   := v_cert.validity_restrictions[v_counter].validity.time_start_and_end.end_validity   * 1000000;
                                        v_startTime := v_cert.validity_restrictions[v_counter].validity.time_start_and_end.start_validity * 1000000;
                                        if (v_generationTime < v_startTime or v_generationTime > v_endTime ) {
                                            log("*** " & testcasename() & ": FAIL: Beacon generation time is not inside the validity of the certificate");
                                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                                        }
garciay's avatar
garciay committed
                                    } else if (v_cert.validity_restrictions[v_counter].type_ == e_time_start_and_duration) {
                                        v_startTime := v_cert.validity_restrictions[v_counter].validity.time_start_and_duration.start_validity * 1000000;
garciay's avatar
garciay committed
                                        v_duration  := f_duration2time(v_cert.validity_restrictions[v_counter].validity.time_start_and_duration.duration_) * 1000000;
garciay's avatar
garciay committed
                                        if (v_generationTime < v_startTime or (v_startTime + v_duration) > v_endTime ) {
                                            log("*** " & testcasename() & ": FAIL: Beacon generation time is not inside the validity of the certificate");
                                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                                        }
                                    } else {
                                        log("*** " & testcasename() & ": FAIL: Mal-formed the certificate");
                                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                                    }
                                } // End of 'for' statement
                                log("*** " & testcasename() & ": PASS: Beacon generation time is inside the validity of the certificate");
                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                            } else {
                                log("*** " & testcasename() & ": INCONC: DENM signer info is not available");
                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                            }
                        }
                    }
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: Expected Beacon not received ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                    }
                } // End of 'alt' statement
                
                // Postamble
                f_acTriggerEvent(m_stopPassBeaconing);
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_ITSS_SND_GENMSG_04_01_BV

            /**
             * @desc   Check that the secured GN Beacon contains exactly one HeaderField generation_location
garciay's avatar
garciay committed
             *         when AT certificate does not contain any region restrictions
             * Pics Selection: PICS_GN_SECURITY and PICS_ITS_AID_OTHER_PROFILE and PICS_CERTIFICATE_SELECTION
             * Config Id: CF01
             * with {
             *   the IUT has been authorized with the AT certificate (CERT_IUT_A)
garciay's avatar
garciay committed
             *       not containing validity_restrictions['region']
             * }
             * ensure that {
             *   when {
             *     the IUT is requested to send a Beacon
             *   } then {
garciay's avatar
garciay committed
             *     the IUT sends a SecuredMessage
             *         containing exactly one header_fields ['generation_location']
             *             containing generation_location
garciay's avatar
garciay committed
             * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_SND_GENMSG_05_01_BV
             * @reference    ETSI TS 103 097 [1], clause 7.3
            testcase TC_SEC_ITSS_SND_GENMSG_05_01_BV() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var LongPosVector v_longPosVectorIut;
                
                // Test control
                if (not(PICS_GN_SECURITY) or not(PICS_ITS_AID_OTHER_PROFILE) or not(PICS_CERTIFICATE_SELECTION)) {
                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY', 'PICS_ITS_AID_OTHER_PROFILE' and 'PICS_CERTIFICATE_SELECTION' required for executing the TC ***");
                    stop;
                }
                
                // Test component configuration
                // CERT_IUT_A is the default one
                f_cf01Up();
                v_longPosVectorIut := f_getPosition(c_compIut);
                
                // Test adapter configuration
                
                // Preamble
                f_prNeighbour();
                f_acTriggerEvent(m_startPassBeaconing(m_beaconHeader(v_longPosVectorIut).beaconHeader)); // Authorize the TA to forward the received beacons
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);    
                
                // Test Body
                tc_ac.start;
                alt {
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(mw_geoNwSecPdu(
                            mdw_securedMessage_Others(
                                mw_header_field_signer_info_certificate(
                                    mw_certificate(
                                        ?,
                                        ?,
                                        ?,
                                        superset(
                                            mw_validity_restriction_any_valid_region
                    ))))))) {
                        log("*** " & testcasename() & ": INFO: Skip DENM containing region restrictions ***");
                        repeat;
                    }
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mdw_securedMessage(
                                    superset(
                                        mw_header_field(
                                            e_generation_location
                                        ),
                                        mw_header_field_signer_info_certificate,
                                        complement(
                                            mw_header_field_its_aid_CAM,
                                            mw_header_field_its_aid_DENM
                                        )
                    ))))) {
                        // The certificate doesn't contain region restrictions because such messages was catched before 
                        tc_ac.stop;
                        log("*** " & testcasename() & ": PASS: DENM contains generation location ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                    }
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mdw_securedMessage_Others(
                                    mw_header_field_signer_info_certificate
                    )))) {
                        // The message does not contain generation location 
                        tc_ac.stop;
                        log("*** " & testcasename() & ": PASS: DENM contains generation location ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                    }
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: Expected DENM not received ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                    }
                } // End of 'alt' statement
                
                // Postamble
                f_acTriggerEvent(m_stopPassBeaconing);
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_ITSS_SND_GENMSG_05_01_BV
            
            /**
             * @desc   Check that the secured GN Beacon contains exactly one HeaderField generation_location 
             *         which is inside the circular region containing in the validity restriction of the 
             *         certificate pointed by the signer_info field     
             * <pre>
             * Pics Selection: PICS_GN_SECURITY and PICS_ITS_AID_OTHER_PROFILE and PICS_CERTIFICATE_SELECTION and PICS_USE_CIRCULAR_REGION
             * Config Id: CF01
             * with {
garciay's avatar
garciay committed
             *   the IUT has been authorized with the AT certificate (CERT_IUT_B)
             *       containing validity_restrictions['region']
             *           containing region
             *               containing region_type
             *                   indicating 'circle'
             *               and containing circular_region
             *                   indicating REGION
             * }
             * ensure that {
             *   when {
             *     the IUT is requested to send a GN Beacon
             *   } then {
garciay's avatar
garciay committed
             *     the IUT sends a SecuredMessage 
             *         containing exactly one header_fields['generation_location']
             *             containing generation_location
             *                 indicating value inside the REGION
garciay's avatar
garciay committed
             * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_SND_GENMSG_05_02_BV
             * @reference    ETSI TS 103 097 [1], clause 7.3
            testcase TC_SEC_ITSS_SND_GENMSG_05_02_BV() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var LongPosVector   v_longPosVectorIut;
                
                // Test control
                if (not(PICS_GN_SECURITY) or not(PICS_ITS_AID_OTHER_PROFILE) or not(PICS_CERTIFICATE_SELECTION) or not(PICS_USE_CIRCULAR_REGION)) {
garciay's avatar
garciay committed
                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY and PICS_ITS_AID_OTHER_PROFILE and PICS_USE_CIRCULAR_REGION' required for executing the TC ***");
                
                // Test component configuration
                vc_hashedId8ToBeUsed := cc_iutCert_B; 
                f_cf01Up();
                v_longPosVectorIut := f_getPosition(c_compIut);
                
                // Test adapter configuration
                
                // Preamble
                f_prNeighbour();
                f_acTriggerEvent(m_startPassBeaconing(m_beaconHeader(v_longPosVectorIut).beaconHeader)); // Authorize the TA to forward the received beacons
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);    
                
                // Test Body
                f_TC_SEC_ITSS_SND_GENMSG_05_BV(mw_geographicRegion_circle);
                
                // Postamble
                f_acTriggerEvent(m_stopPassBeaconing);
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_ITSS_SND_GENMSG_05_02_BV
            /**
             * @desc   Check that the secured GN Beacon contains exactly one HeaderField generation_location 
             *         which is inside the rectangular region containing in the validity restriction 
             *         of the certificate pointed by the signer_info field     
             * <pre>
             * Pics Selection: PICS_GN_SECURITY and PICS_ITS_AID_OTHER_PROFILE and PICS_CERTIFICATE_SELECTION and PICS_USE_RECTANGULAR_REGION
             * Config Id: CF01
             * with {
garciay's avatar
garciay committed
             *   the IUT has been authorized with the AT certificate (CERT_IUT_C)
             *     containing validity_restrictions ['region']
             *         containing region
             *             containing region_type
             *                 indicating 'rectangle'
             *             containing rectangular_region
             *                 indicating REGION
             * }
             * ensure that {
             *   when {
             *     the IUT is requested to send a DENM
             *   } then {
garciay's avatar
garciay committed
             *     the IUT sends a SecuredMessage
             *       containing exactly one header_fields ['generation_location']
             *         containing generation_location
             *           indicating value inside the REGION
             *   }
             * }
             * </pre>
garciay's avatar
garciay committed
             * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_SND_GENMSG_05_03_BV
             * @reference    ETSI TS 103 097 [1], clause 7.3
            testcase TC_SEC_ITSS_SND_GENMSG_05_03_BV() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var LongPosVector   v_longPosVectorIut;
                
                // Test adapter configuration
                if (not(PICS_GN_SECURITY) or not(PICS_ITS_AID_OTHER_PROFILE) or not(PICS_CERTIFICATE_SELECTION) or not(PICS_USE_RECTANGULAR_REGION)) {
garciay's avatar
garciay committed
                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY and PICS_ITS_AID_OTHER_PROFILE and PICS_USE_RECTANGULAR_REGION' required for executing the TC ***");
                
                // Test component configuration
                vc_hashedId8ToBeUsed := cc_iutCert_C; // Load IUT certificate CERT_IUT_C 
                f_cf01Up();
                v_longPosVectorIut := f_getPosition(c_compIut);
                
                // Test adapter configuration
                
                // Preamble
                f_prNeighbour();
                f_acTriggerEvent(m_startPassBeaconing(m_beaconHeader(v_longPosVectorIut).beaconHeader)); // Authorize the TA to forward the received beacons
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);    
                
                // Test Body
                f_TC_SEC_ITSS_SND_GENMSG_05_BV(mw_geographicRegion_rectangular);
                
                // Postamble
                f_acTriggerEvent(m_stopPassBeaconing);
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_ITSS_SND_GENMSG_05_03_BV
            
            /**
             * @desc   Check that the secured GN Message contains exactly one HeaderField generation_location 
             *         which is inside the polygonal region containing in the validity restriction 
             *         of the certificate pointed by the signer_info field     
             * <pre>
             * Pics Selection: PICS_GN_SECURITY and PICS_ITS_AID_OTHER_PROFILE and PICS_CERTIFICATE_SELECTION and PICS_USE_POLYGONAL_REGION
             * Config Id: CF01
             * with {
garciay's avatar
garciay committed
             *   the IUT has been authorized with the AT certificate (CERT_AT_D)
             *       containing validity_restrictions ['region']
             *           containing region
             *               containing region_type
             *                   indicating 'polygon'
             *               containing polygonal_region
             *                   indicating REGION
             * }
             * ensure that {
             *   when {
             *     the IUT is requested to send a Beacon
             *   } then {
garciay's avatar
garciay committed
             *     the IUT sends a SecuredMessage
             *       containing exactly one header_fields ['generation_location']
             *         containing generation_location
             *           indicating value inside the REGION
             *   }
             * }
             * </pre>
garciay's avatar
garciay committed
             * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_SND_GENMSG_05_04_BV
             * @reference    ETSI TS 103 097 [1], clause 7.3
            testcase TC_SEC_ITSS_SND_GENMSG_05_04_BV() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var LongPosVector   v_longPosVectorIut;
                
                // Test adapter configuration
                if (not(PICS_GN_SECURITY) or not(PICS_ITS_AID_OTHER_PROFILE) or not(PICS_CERTIFICATE_SELECTION) or not(PICS_USE_POLYGONAL_REGION)) {
garciay's avatar
garciay committed
                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY and PICS_ITS_AID_OTHER_PROFILE and PICS_USE_POLYGONAL_REGION' required for executing the TC ***");
                
                // Test component configuration
                vc_hashedId8ToBeUsed := cc_iutCert_D; // Load IUT certificate CERT_IUT_D 
                f_cf01Up();
                v_longPosVectorIut := f_getPosition(c_compIut);
                
                // Test adapter configuration
                
                // Preamble
                f_prNeighbour();
                f_acTriggerEvent(m_startPassBeaconing(m_beaconHeader(v_longPosVectorIut).beaconHeader)); // Authorize the TA to forward the received beacons
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);    
                
                // Test Body
                f_TC_SEC_ITSS_SND_GENMSG_05_BV(mw_geographicRegion_polygonal);
                
                // Postamble
                f_acTriggerEvent(m_stopPassBeaconing);
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_ITSS_SND_GENMSG_05_04_BV
            
            /**
             * @desc   Check that the secured GN Message contains exactly one HeaderField generation_location 
             *         which is inside the identified region containing in the validity restriction 
garciay's avatar
garciay committed
             *         of the certificate pointed by the signer_info field
             * Pics Selection: PICS_GN_SECURITY and PICS_ITS_AID_OTHER_PROFILE and PICS_USE_IDENTIFIED_REGION and PICS_CERTIFICATE_SELECTION
             * Config Id: CF01
             * with {
garciay's avatar
garciay committed
             *   the IUT has been authorized with the AT certificate (CERT_IUT_E) 
             *       containing validity_restrictions ['region'] 
             *           containing region
             *               containing region_type
             *                   indicating 'id_region'
             *               containing identified_region
             *                   indicating REGION
             * }
             * ensure that {
             *   when {
             *     the IUT is requested to send a Beacon
             *   } then {
garciay's avatar
garciay committed
             *     the IUT sends a SecuredMessage
             *       containing exactly one header_fields ['generation_location']
             *         containing generation_location
             *           indicating value inside the REGION
             *   }
             * }
             * </pre>
garciay's avatar
garciay committed
             * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_SND_GENMSG_05_05_BV
             * @reference    ETSI TS 103 097 [1], clause 7.3
            testcase TC_SEC_ITSS_SND_GENMSG_05_05_BV() runs on ItsGeoNetworking system ItsSecSystem {
                // Local variables
                var LongPosVector   v_longPosVectorIut;
                
                // Test adapter configuration
                if (not(PICS_GN_SECURITY) or not(PICS_ITS_AID_OTHER_PROFILE) or not(PICS_CERTIFICATE_SELECTION) or not(PICS_USE_IDENTIFIED_REGION)) {
garciay's avatar
garciay committed
                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY and PICS_ITS_AID_OTHER_PROFILE and PICS_USE_IDENTIFIED_REGION' required for executing the TC ***");
                
                // Test component configuration
                vc_hashedId8ToBeUsed := cc_iutCert_E; // Load IUT certificate CERT_IUT_E 
                f_cf01Up();
                v_longPosVectorIut := f_getPosition(c_compIut);
                
                // Test adapter configuration
                
                // Preamble
                f_prNeighbour();
                f_acTriggerEvent(m_startPassBeaconing(m_beaconHeader(v_longPosVectorIut).beaconHeader)); // Authorize the TA to forward the received beacons
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);    
                
                // Test Body
                f_TC_SEC_ITSS_SND_GENMSG_05_BV(mw_geographicRegion_identified);
                
                // Postamble
                f_acTriggerEvent(m_stopPassBeaconing);
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_ITSS_SND_GENMSG_05_05_BV
            
            /**
             * @desc   Check that the secured GN Message contains exactly one HeaderField generation_location 
garciay's avatar
garciay committed
             *         which is inside the  certificate pointed by the signer_info field
garciay's avatar
garciay committed
             * Pics Selection: PICS_GN_SECURITY and PICS_ITS_AID_OTHER_PROFILE and not PICS_CERTIFICATE_SELECTION
             * Config Id: CF01
             * with {
             *   the IUT being in the 'authorized' state
             * }
             * ensure that {
             *   when {
             *     the IUT is requested to send a Beacon
             *   } then {
garciay's avatar
garciay committed
             *     the IUT sends a SecuredMessage
             *       containing header_fields['signed_info'].certificate
             *         containing validity_restrictions ['region']
             *           containing region.region_type
             *             indicating 'circle'
             *           containing region.circular_region
             *             indicating REGION
garciay's avatar
garciay committed
             *         or containing region.region_type
             *             indicating 'rectangle'
             *           containing region.rectangular_region
             *             containing array of rectangles
             *               indicating REGION
garciay's avatar
garciay committed
             *         or containing region.region_type
             *             indicating 'polygonal'
             *           containing region.polygonal_region
             *             indicating REGION
garciay's avatar
garciay committed
             *         or containing region.region_type
             *             indicating 'id_region'
             *           containing region.circular_region
             *             indicating REGION
garciay's avatar
garciay committed
             *       and containing exactly one header_fields['generation_location']
             *         containing generation_location
             *           indicating location inside the REGION
             *   }
             * }
             * </pre>
garciay's avatar
garciay committed
             * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_SND_GENMSG_05_06_BV
             * @reference    ETSI TS 103 097 [1], clause 7.3
            testcase TC_SEC_ITSS_SND_GENMSG_05_06_BV() runs on ItsGeoNetworking system ItsSecSystem {
                // Local variables
                var LongPosVector   v_longPosVectorIut;
                
                // Test adapter configuration
garciay's avatar
garciay committed
                if (not(PICS_GN_SECURITY) or not(PICS_ITS_AID_OTHER_PROFILE) or PICS_CERTIFICATE_SELECTION) {
                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY and PICS_ITS_AID_OTHER_PROFILE and not PICS_CERTIFICATE_SELECTION' required for executing the TC ***");
                
                // Test component configuration
                vc_hashedId8ToBeUsed := cc_iutCert_B; // Load IUT certificate CERT_IUT_B 
                f_cf01Up();
                v_longPosVectorIut := f_getPosition(c_compIut);
                
                // Test adapter configuration
                
                // Preamble
                f_prNeighbour();
                f_acTriggerEvent(m_startPassBeaconing(m_beaconHeader(v_longPosVectorIut).beaconHeader)); // Authorize the TA to forward the received beacons
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);    
                
                // Test Body
                f_TC_SEC_ITSS_SND_GENMSG_05_BV(); // any type of regions
                
                // Postamble
                f_acTriggerEvent(m_stopPassBeaconing);
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_ITSS_SND_GENMSG_05_06_BV
            
            group f_TC_SEC_ITSS_SND_GENMSG_05_xx {
                
                function f_TC_SEC_ITSS_SND_GENMSG_05_BV(
garciay's avatar
garciay committed
                                                        in template (present) GeographicRegion p_region := ?
                ) runs on ItsGeoNetworking {
                    
                    // Local variables
                    var GeoNetworkingInd v_geoNwInd;
                    
                    tc_ac.start;
                    alt {
                        // GN message must contain generation location and the certificate with region restrictions  
                        [] geoNetworkingPort.receive(
                            mw_geoNwInd(
                                mw_geoNwSecPdu(
                                    mdw_securedMessage(
                                        superset(
                                            mw_header_field(e_generation_location),
                                            mw_header_field_signer_info_certificate(
                                                mw_certificate(
                                                    ?,
                                                    ?,
                                                    ?, 
                                                    superset(
                                                        mw_validity_restriction_region(
                                                            p_region
                        ))))))))) -> value v_geoNwInd {
                            var ValidityRestriction v_vr;
                            var HeaderField         v_hf;
                            
                            tc_ac.stop;
                            // Check that generation location 
                            if (
                                f_getMsgHeaderField(v_geoNwInd.msgIn.gnPacket.securedMsg, e_generation_location, v_hf) and 
                                f_getCertificateValidityRestriction(v_geoNwInd.msgIn.gnPacket.securedMsg.header_fields[0].headerField.signer.signerInfo.certificate, e_region, v_vr)
                            ) {
                                if (f_isLocationInsideRegion(v_vr.validity.region, v_hf.headerField.generation_location)) {
                                    log("*** " & testcasename() & ": PASS: DENM contains generation location inside the certificate validity region ***");
                                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                                } else {
                                    log("v_vr.validity.region=", v_vr.validity.region);
                                    log("v_hf.headerField.generation_location=", v_hf.headerField.generation_location);
                                    log("*** " & testcasename() & ": FAIL: Invalid location");
                                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                                }
                            } else {
                                log("*** " & testcasename() & ": FAIL: IMPOSSIBLE!!! DENM generation location or certificate region restriction header field does not exist");
                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                            }
                        }
                        // GN message doesn't contain generation location 
                        [] geoNetworkingPort.receive(
                            mw_geoNwInd(
                                mw_geoNwSecPdu(
                                    mdw_securedMessage_Others
                        ))) -> value v_geoNwInd {
                            var HeaderField v_hf;
                            
                            tc_ac.stop;
                            
                            // Check that generation location is not present
                            f_getMsgHeaderField(v_geoNwInd.msgIn.gnPacket.securedMsg, e_generation_location, v_hf);
                            if (not isbound(v_hf)) {
                                log("*** " & testcasename() & ": FAIL: DENM doesn't contain generation location header");
                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                            }
                        }
                        // GN signing certificate doesn't contains region restriction 
                        [] geoNetworkingPort.receive(
                            mw_geoNwInd(
                                mw_geoNwSecPdu(
                                    mdw_securedMessage_Others(
                                        mw_header_field_signer_info_certificate(
                                            mw_certificate(
                                                ?,
                                                ?,
                                                ?, 
                                                { } // GN signing certificate doesn't contains region restriction
                        )))))) {
                            tc_ac.stop;
                            log("*** " & testcasename() & ": INCONC: DENM certificate doesn't contain region restriction");
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                        }
                        [] tc_ac.timeout {
                            log("*** " & testcasename() & ": INCONC: Expected DENM not received ***");
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                        }
                    } // End of 'alt' statement
                } // End of function f_TC_SEC_ITSS_SND_GENMSG_05_BV 
                
            } // End of group f_TC_SEC_ITSS_SND_GENMSG_05_xx
            
            /**
garciay's avatar
garciay committed
             * @desc        Check that the secured message contains of type signed, signed_external or signed_and_encrypted 
             * Pics Selection: PICS_GN_SECURITY and PICS_ITS_AID_OTHER_PROFILE
             * Config Id: CF01
             * Initial conditions:
             * with {
             *     the IUT being in the 'authorized' state
             * }
             * Expected results:
             * ensure that {
             *     when {
             *         the IUT is requested to send a Beacon
             *     } then {
             *         the IUT sends a SecuredMessage {
garciay's avatar
garciay committed
             *             containing payload_fields
             *                 containing exactly one element of type Payload
             *                     containing type
garciay's avatar
garciay committed
             *                         indicating 'signed' or 'signed_external' or 'signed_and_encrypted'
garciay's avatar
garciay committed
             * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_SND_GENMSG_06_01_BV
             * @reference    ETSI TS 103 097 [1], clause 7.3
            testcase TC_SEC_ITSS_SND_GENMSG_06_01_BV() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var LongPosVector v_longPosVectorIut;
                
                // Test adapter configuration
                if (not(PICS_GN_SECURITY) or not(PICS_ITS_AID_OTHER_PROFILE)) {
                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY and PICS_ITS_AID_OTHER_PROFILE' required for executing the TC ***");
                    stop;
                }
                
                // Test component configuration
                f_cf01Up();
                v_longPosVectorIut := f_getPosition(c_compIut);
                
                // Test adapter configuration
                
                // Preamble
                f_prNeighbour();
                f_acTriggerEvent(m_startPassBeaconing(m_beaconHeader(v_longPosVectorIut).beaconHeader)); // Authorize the TA to forward the received beacons
garciay's avatar
garciay committed
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
                tc_ac.start;
                alt {
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mdw_securedMessage_Others(
                                    ?, 
                                    mw_payload(
                                        e_signed
                                    ) 
                                ),
                                mw_geoNwBeaconPacket(
                                    ?
                    )))) { 
                        log("*** " & testcasename() & ": PASS: Beacon payload is 'signed'");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                    }
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mdw_securedMessage_Others(
                                    ?, 
garciay's avatar
garciay committed
                                    mw_payload(
                                        e_signed_external
                                    ) 
                                ),
                                mw_geoNwBeaconPacket(
                                    ?
                    )))) { 
garciay's avatar
garciay committed
                        log("*** " & testcasename() & ": PASS: Beacon payload is 'e_signed_external'");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                    }
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mdw_securedMessage_Others(
                                    ?, 
                                    mw_payload(
garciay's avatar
garciay committed
                                        e_signed_and_encrypted
                                    ) 
                                ),
                                mw_geoNwBeaconPacket(
                                    ?
                    )))) { 
                        log("*** " & testcasename() & ": PASS: Beacon payload is 'e_signed_and_encrypted'");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                    }
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mdw_securedMessage_Others(
                                    ?, 
                                    mw_payload
                                ),
                                mw_geoNwBeaconPacket(
                                    ?
                    )))) { 
garciay's avatar
garciay committed
                        log("*** " & testcasename() & ": FAIL: Beacon payload is not signed, signed_external or signed_and_encrypted");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                    }
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: Expected Message not received ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                    }
                } // End of 'alt' statement
                
                // Postamble
                f_acTriggerEvent(m_stopPassBeaconing);
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_ITSS_SND_GENMSG_06_01_BV
garciay's avatar
garciay committed
             * @desc   Check that the secured GN Message contains only one TrailerField of type signature ;
             *         Check that the signature contained in the SecuredMessage is calculated over the right fields by 
             *         cryptographically verifying the signature 
             * Pics Selection: PICS_GN_SECURITY and PICS_ITS_AID_OTHER_PROFILE
             * Config Id: CF01
             * Initial conditions:
             * with {
             *   the IUT being in the 'authorized' state
             * }
             * ensure that {
             *   when {
             *     the IUT is requested to send Beacon
             *   } then {
garciay's avatar
garciay committed
             *     the IUT sends a SecuredMessage
             *         containing header_fields ['signer_info']
             *             containing signer
             *                 containing type
             *                     indicating 'certificate'
             *             and containing certificate
             *                 indicating CERT
             *         and containing trailer_fields['signature']
             *             containing signature
             *                 verifiable using CERT.subject_attributes['verification_key'] 
garciay's avatar
garciay committed
             * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_SND_GENMSG_07_01_BV
             * @reference    ETSI TS 103 097 [1], clause 7.3
            testcase TC_SEC_ITSS_SND_GENMSG_07_01_BV() runs on ItsGeoNetworking system ItsSecSystem {
                
                //  Local variables
                var LongPosVector v_longPosVectorIut;
                var GeoNetworkingInd v_geoNwInd;
                var SignerInfo v_signerInfo;
                
                // Test adapter configuration
                if (not(PICS_GN_SECURITY) or not(PICS_ITS_AID_OTHER_PROFILE)) {
                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY and PICS_ITS_AID_OTHER_PROFILE' required for executing the TC ***");
                    stop;
                }
                
                //  Test component configuration
                f_cf01Up();
                v_longPosVectorIut := f_getPosition(c_compIut);
                
                // Test adapter configuration
                
                // Preamble
                f_prNeighbour();
                f_acTriggerEvent(m_startPassBeaconing(m_beaconHeader(v_longPosVectorIut).beaconHeader)); // Authorize the TA to forward the received beacons
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                    
                // Test Body
                tc_ac.start;
                alt {
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mdw_securedMessage_Others(
                                    mw_header_field_signer_info_certificate
                    )))) -> value v_geoNwInd { 
                        tc_ac.stop;
                        log("*** " & testcasename() & ": INFO: Beacon message with certificate received ***");
                        f_getMsgSignerInfo(v_geoNwInd.msgIn.gnPacket.securedMsg, v_signerInfo);
                        
                        if (f_verifyGnSecuredMessageSignatureWithCertificate(v_geoNwInd.msgIn.gnPacket.securedMsg, v_signerInfo.signerInfo.certificate) == false) {
                            log("*** " & testcasename() & ": FAIL: Beacon received with invalide signature");
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                        }
                    }
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mdw_securedMessage_Others
                    ))) { 
                        tc_ac.stop;
                        log("*** " & testcasename() & ": FAIL: Beacon message without certificate received");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                    }
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: Expected GN Message not received");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                    }
                } // End of 'alt' statement
                log("*** " & testcasename() & ": PASS: GN Message received with correct signature");
                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                
                // Postamble
                f_acTriggerEvent(m_stopPassBeaconing);
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_ITSS_SND_DENM_07_01_BV
garciay's avatar
garciay committed
        } // End of group sendOtherProfile
garciay's avatar
garciay committed
        /**
         * @desc Sending behaviour test cases for certificates profile
         * @see ETSI TS 103 096-2 V1.2.2 (2016-01) Clause 5.2.7 Profiles for certificates
         */
        group sendCertificatesProfile {
garciay's avatar
garciay committed
             * @desc    Check that AT certificate has version 2
             * Pics Selection: PICS_GN_SECURITY
             * Config Id: CF01
             * Initial conditions:
garciay's avatar
garciay committed
             * with {
             *   the IUT being in the 'authorized' state
             *   the IUT being requested to include certificate in the next CAM
             * }
             * Expected Behaviour:
             * 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 version
             *                     indicating '2'
             *   }
             * }
garciay's avatar
garciay committed
             * @see         ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_SND_CERT_01_01_BV
             * @reference   ETSI TS 103 097 [1], clauses 6.1 and 7.4.1
garciay's avatar
garciay committed
            testcase TC_SEC_ITSS_SND_CERT_01_01_BV() runs on ItsGeoNetworking system ItsSecSystem {
                // Local variables
garciay's avatar
garciay committed
                // Test control
                if (not(PICS_GN_SECURITY)) {
                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY' required for executing the TC ***");
                    stop;
                }
garciay's avatar
garciay committed
                // Test component configuration
garciay's avatar
garciay committed
                    
                // Test adapter configuration
garciay's avatar
garciay committed
                    
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
garciay's avatar
garciay committed
                tc_ac.start;
                alt {
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mdw_securedMessage(
                                    superset(
                                        mw_header_field_signer_info_certificate(
                                            mw_certificate(
                    ))))))) {
                        tc_ac.stop;
                        log("*** " & testcasename() & ": PASS: AT Certificate version set to " & int2char(c_certificate_version) & " ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                    }
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mdw_securedMessage(
                                    superset(
                                        mw_header_field_signer_info_certificate(
                                            ?
                    )))))) {
                        tc_ac.stop;
                        log("*** " & testcasename() & ": FAIL: AT Certificate version mismatch ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                    }
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: Expected message not received ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                    }
                } // End of 'alt' statement
                
                // Postamble
                f_poNeighbour();
                f_cf01Down();
garciay's avatar
garciay committed
            } // End of testcase TC_SEC_ITSS_SND_CERT_01_01_BV
garciay's avatar
garciay committed
             * @desc    Check that AA certificate has version 2
garciay's avatar
garciay committed
             * Pics Selection: PICS_GN_SECURITY and not PICS_CERTIFICATE_SELECTION
             * Config Id: CF01
             * Initial conditions:
garciay's avatar
garciay committed
             * with {
             *   the IUT being in the 'authorized' state
             *      the IUT being requested to include certificate chain in the next CAM
             * }
             * Expected Behaviour:
             * 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
             *             and containing certificates
             *                 indicating length > 0
             *                 and containing certificates[n] (0..N)
             *                     containing version
             *                         indicating '2'
             *   }
             * }
garciay's avatar
garciay committed
             * @see         ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_SND_CERT_01_02_BV
             * @reference   ETSI TS 103 097 [1], clauses 6.1 and 7.4.1
garciay's avatar
garciay committed
            testcase TC_SEC_ITSS_SND_CERT_01_02_BV() runs on ItsGeoNetworking system ItsSecSystem {
                // Local variables
garciay's avatar
garciay committed
                var SecuredMessage v_recv;
                var Certificate v_cert;
                var SignerInfo v_si;
                var HashedId8 v_digest;
garciay's avatar
garciay committed
                // Test control
                if (not(PICS_GN_SECURITY)) {
                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY' required for executing the TC ***");
                    stop;
                }
garciay's avatar
garciay committed
                    
                // Test component configuration
garciay's avatar
garciay committed
                    
                // Test adapter configuration
garciay's avatar
garciay committed
                    
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
garciay's avatar
garciay committed
                // Wait for the message with the certificate to retrieve the AA digest.
                // Ask for the chain, containing AT and AA certificate
                // Check AA Certificate
                log("*** " & testcasename() & ": INFO: Wait for certificate and ask for certificate chain  ***");
                tc_ac.start;
                f_askForCertificateChain(f_generateDefaultCam());
                tc_ac.stop;
garciay's avatar
garciay committed
                // Test Body
                tc_ac.start;
                alt {
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mdw_securedMessage(
                                    superset(
garciay's avatar
garciay committed
                                        mw_header_field_signer_info_certificate_chain
                    ))))) {
garciay's avatar
garciay committed
                        tc_ac.stop;
                        log("*** " & testcasename() & ": PASS: AA certificate version set to " & int2char(c_certificate_version) & " ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                    }
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mdw_securedMessage(
                                    superset(
                                        mw_header_field_signer_info_certificate_chain
                    ))))) {
                        tc_ac.stop;
                        log("*** " & testcasename() & ": FAIL: AA certificate version mismatch or no AA cert received***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                    }
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: Expected message not received ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                    }
                } // End of 'alt' statement
                
                // Postamble
                f_poNeighbour();
                f_cf01Down();
garciay's avatar
garciay committed
                
garciay's avatar
garciay committed
            } // End of testcase TC_SEC_ITSS_SND_CERT_01_02_BV
garciay's avatar
garciay committed
             * @desc    Check that the references in the certificate chain are valid
             *          Check that signer_info type of all certificates in the chain are 'certificate_digest_with_sha256', 
             *          'certificate_digest_with_other_algorithm' or 'self'
             * Pics Selection: PICS_GN_SECURITY
             * Config Id: CF01
             * Initial conditions:
garciay's avatar
garciay committed
             * 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
             *             and containing certificates
             *                 indicating length > 0
             *             and containing certificates[0]
             *                 containing signer_info
             *                     containing type
             *                         indicating 'certificate_digest_with_sha256'
             *                         or indicating 'certificate_digest_with_other_algorythm'
             *                     and containing digest
             *                         referenced to the trusted certificate
             *                 or containing signer_info
             *                     containing type
             *                         indicating 'self'
             *             and containing certificates[n] (1..N)
             *                 containing signer_info
             *                     containing type
             *                         indicating 'certificate_digest_with_sha256'
             *                         or indicating 'certificate_digest_with_other_algorythm'
             *                     and containing digest
             *                         referenced to the certificates[n-1]
             * }
garciay's avatar
garciay committed
             * @see         ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_SND_CERT_02_01_BV
             * @reference   ETSI TS 103 097 [1], clause 4.2.10, 6.1 and 7.4.1
garciay's avatar
garciay committed
            testcase TC_SEC_ITSS_SND_CERT_02_01_BV() runs on ItsGeoNetworking system ItsSecSystem {
garciay's avatar
garciay committed
                // Local declarations
                var CertificateChain v_chain;
                var SignerInfo v_si;
                var HashedId8 v_digest;
garciay's avatar
garciay committed
                // Test control
                if (not(PICS_GN_SECURITY)) {
                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY' required for executing the TC ***");
                    stop;
                }
garciay's avatar
garciay committed
                    
                // Test component configuration
garciay's avatar
garciay committed
                    
                // Test adapter configuration
garciay's avatar
garciay committed
                    
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
garciay's avatar
garciay committed
                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);
garciay's avatar
garciay committed
                tc_ac.stop;
                
                // Test Body
                for (var integer v_counter := lengthof(v_chain) - 1; v_counter > 1; v_counter := v_counter - 1) { // Loop on []N-1..1]
                    if (not f_getCertificateSignerInfo(v_chain[v_counter], v_si)) {
                        log("*** " & testcasename() & ": FAIL: Certificate[ " & int2str(v_counter) & "] doesn't contain signer info ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                    }
garciay's avatar
garciay committed
                    if (not match(v_si.type_, e_certificate_digest_with_sha256) and not match(v_si.type_, e_certificate_digest_with_other_algorithm)) {
garciay's avatar
garciay committed
                        log("*** " & testcasename() & ": FAIL: Certificate is not signed with digest ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                    }
                    // signer_info.type indicates 'certificate_digest_with_sha256' or 'certificate_digest_with_other_algorythm'
                    
                    v_digest := f_calculateDigestFromCertificate(v_chain[v_counter - 1]);
                    if (not match (v_si.signerInfo.digest, v_digest)) {
                        log("*** " & testcasename() & ": FAIL: Certificate chain is not valid ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                    }
                } // End of 'for' statement
                // Process certificate[0]
                if (not f_getCertificateSignerInfo(v_chain[0], v_si)) {
                    log("*** " & testcasename() & ": FAIL: Certificate[0] doesn't contain signer info ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
garciay's avatar
garciay committed
                // Process certificate[0]
                if (not match (v_si.type_, e_certificate_digest_with_sha256)) {
                    log("*** " & testcasename() & ": FAIL: Certificate[0] is not signed with digest ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                }
garciay's avatar
garciay committed
                // signer_info.type indicates 'certificate_digest_with_sha256' only
                log("*** " & testcasename() & ": PASS: Certificate chain is well signed ***");
                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                
                // Postamble
                f_poNeighbour();
                f_cf01Down();
garciay's avatar
garciay committed
                
garciay's avatar
garciay committed
            } // End of testcase TC_SEC_ITSS_SND_CERT_02_01_BV
garciay's avatar
garciay committed
             * @desc Check that the rectangular region validity restriction of the message signing certificate 
             *       contains not more than six valid rectangles; 
             *       Check that the rectangular region validity restriction of the message signing certificate is 
             *       continuous and does not contain any holes 
garciay's avatar
garciay committed
             * Pics Selection: PICS_GN_SECURITY and PICS_USE_RECTANGULAR_REGION and PICS_CERTIFICATE_SELECTION
             * Config Id: CF01
garciay's avatar
garciay committed
             * with {
             *   the IUT being in the 'authorized' state
             *   the IUT being requested to include certificate 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'
             *             containing certificate
             *                 containing validity_restrictions['region']
             *                     containing region_type
             *                         indicating 'rectangle'
             *                     and containing rectangular_region
             *                         indicating length <= 6
             *                         and containing elements of type RectangularRegion
             *                             indicating continuous region without holes
             *                             and containing northwest and southeast
             *                                 indicating northwest is on the north from southeast
             *   }
             * }
             * @remark Certificate: cc_taCert_C
garciay's avatar
garciay committed
             * @see         ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_SND_CERT_04_01_BV
             * @reference   ETSI TS 103 097 [1], clauses 4.2.20 and 4.2.23
garciay's avatar
garciay committed
            testcase TC_SEC_ITSS_SND_CERT_04_01_BV() runs on ItsGeoNetworking system ItsSecSystem {
                // Local variables
garciay's avatar
garciay committed
                var Certificate         v_cert;
                var ValidityRestriction v_vr;
                var integer             v_counter;
garciay's avatar
garciay committed
                // Test control
                if (not(PICS_GN_SECURITY) or not(PICS_USE_RECTANGULAR_REGION) or not(PICS_CERTIFICATE_SELECTION)) {
                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY and PICS_USE_RECTANGULAR_REGION and PICS_CERTIFICATE_SELECTION' required for executing the TC ***");
garciay's avatar
garciay committed
                    
                // Test component configuration
                vc_hashedId8ToBeUsed := cc_iutCert_C;
garciay's avatar
garciay committed
                    
                // Test adapter configuration
garciay's avatar
garciay committed
                    
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
garciay's avatar
garciay committed
                // Test body
                tc_ac.start;
                f_waitForCertificate(v_cert);
                tc_ac.stop;
                if (f_getCertificateValidityRestriction(v_cert, e_region, v_vr)) {
                    if (v_vr.validity.region.region_type == e_rectangle) {
                        var RectangularRegions v_rects := v_vr.validity.region.region.rectangular_region;
                        if (lengthof(v_rects) > 6) {
                            log("*** " & testcasename() & ": FAIL: Rectangular regions count is more then 6 ***");
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                        }
                        for (v_counter := 0; v_counter<lengthof(v_rects); v_counter := v_counter + 1) {
                            var RectangularRegion v_rect := v_rects[v_counter];
                            if (true != f_isValidTwoDLocation(v_rect.northwest)) {
                                log("*** " & testcasename() & ": FAIL: Northwest location is invalid in rect " & int2str(v_counter) & " ***");
                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                            }
                            if (true != f_isValidTwoDLocation(v_rect.southeast)) {
                                log("*** " & testcasename() & ": FAIL: Southeast location is invalid in rect " & int2str(v_counter) & " ***");
                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                            }
                            // Check normality of the rectangle
                            if (v_rect.northwest.latitude < v_rect.southeast.latitude) {
                                log("*** " & testcasename() & ": FAIL: Rectangular region " & int2str(v_counter) & " is not normalized ***");
                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                            }
                        } // End of 'for' statement
                        
                        // Check for continuous rectangles
                        if (lengthof(v_rects) > 1) { 
                            if (true !=  f_isContinuousRectangularRegions(v_rects)) {
                                log("*** " & testcasename() & ": FAIL: Rectangular regions are not connected all together ***");
                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                            }
                        }
                    } else {
                        log("*** " & testcasename() & ": INCONC: Certificate has other region type ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout); // to be inconc
                    }
                    
                    log("*** " & testcasename() & ": PASS: Certificate has a valid rectangular region restrictions ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                } else {
                    log("*** " & testcasename() & ": PASS: Certificate doesn't have any location restrictions ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                }
                
                // Postamble
                f_poNeighbour();
                f_cf01Down();
garciay's avatar
garciay committed
                
garciay's avatar
garciay committed
            } // End of testcase TC_SEC_ITSS_SND_CERT_04_01_BV
garciay's avatar
garciay committed
             * @desc Check that the rectangular region validity restriction of all certificates contains not more than 
             *       six valid rectangles; 
             *       Check that the rectangular region validity restriction of the AT certificate is continuous and 
             *       does not contain any holes 
             *       Check that the rectangular certificate validity region of the subordinate certificate is well formed and 
             *       inside the validity region of the issuing certificate 
garciay's avatar
garciay committed
             * Pics Selection: PICS_GN_SECURITY and PICS_USE_RECTANGULAR_REGION and PICS_CERTIFICATE_SELECTION
             * Config Id: CF01
garciay's avatar
garciay committed
             * 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'
             *             containing certificates
             *                indicating length N > 0
             *                and containing certificates [n] 0..n
             *                    containing validity_restrictions['region']
             *                        containing region_type
             *                            indicating 'rectangle'
             *                        and containing rectangular_region
             *                            indicating length <= 6
             *                        and containing elements of type RectangularRegion
             *                            containing northwest and southeast
             *                                indicating northwest  on the north from southeast
             *                            and indicating continuous region without holes
             *    }
             * }
garciay's avatar
garciay committed
             * @see         ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_SND_CERT_04_02_BV
             * @reference   ETSI TS 103 097 [1], clauses 4.2.20 and 4.2.23
garciay's avatar
garciay committed
            testcase TC_SEC_ITSS_SND_CERT_04_02_BV() runs on ItsGeoNetworking system ItsSecSystem {
                // Local variables
garciay's avatar
garciay committed
                var CertificateChain    v_chain;
                var ValidityRestriction v_vr := valueof(m_validity_restriction_unknown), v_vri := valueof(m_validity_restriction_unknown);  // current and issuing cert validity restrictions
                var boolean f_vr := false, f_vri := false;
garciay's avatar
garciay committed
                // Test control
                if (not(PICS_GN_SECURITY) or not(PICS_USE_RECTANGULAR_REGION) or not(PICS_CERTIFICATE_SELECTION)) {
                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY and PICS_USE_RECTANGULAR_REGION and PICS_CERTIFICATE_SELECTION' required for executing the TC ***");
garciay's avatar
garciay committed
                    
                // Test component configuration
                vc_hashedId8ToBeUsed := cc_iutCert_C;
garciay's avatar
garciay committed
                    
                // Test adapter configuration
garciay's avatar
garciay committed
                    
                // Preamble
                f_prNeighbour();
garciay's avatar
garciay committed
                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);
                } else {
                    f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                }
garciay's avatar
garciay committed
                tc_ac.stop;
                for (var integer v_counter := 0; v_counter < lengthof(v_chain); v_counter := v_counter + 1) {
                    v_vri := v_vr;
                    f_vri := f_vr;
                    f_vr := f_getCertificateValidityRestriction(v_chain[v_counter], e_region, v_vr);
                    log("v_chain[v_counter]=", v_chain[v_counter]);
                    if (f_vr) {
                        var RectangularRegions v_rects;
                        if (v_vr.validity.region.region_type != e_rectangle) {
                            log("*** " & testcasename() & ": INCONC: Certificate validity restriction region is not rectangular ***");
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                        }
                        v_rects := v_vr.validity.region.region.rectangular_region;
                        log("v_rects=", v_rects);
                        if (lengthof(v_rects) > 6) {
                            log("*** " & testcasename() & ": FAIL: Rectangular regions count is more then 6 ***");
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                        }
                        for (var integer j:=0; j<lengthof(v_rects); j:=j + 1) {
                            var RectangularRegion v_rect := v_rects[j];
                            if (true != f_isValidTwoDLocation(v_rect.northwest)) {
                                log("*** " & testcasename() & ": FAIL: Northwest location is invalid in rect " & int2str(v_counter) & " ***");
                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                            }
                            if (true != f_isValidTwoDLocation(v_rect.southeast)) {
                                log("*** " & testcasename() & ": FAIL: Southeast location is invalid in rect " & int2str(v_counter) & " ***");
                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                            }
                            // Check normality of the rectangle
                            if (v_rect.northwest.latitude < v_rect.southeast.latitude) {
                                log("*** " & testcasename() & ": FAIL: Rectangle " & int2str(v_counter) & " is not normalized ***");
                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                            }
                        }
                        if (f_vri) {
                            // current restrictions must be inside of the parent one
                            if (not f_isRectangularRegionsInside(v_vri.validity.region.region.rectangular_region, v_rects)) {
                                log("*** " & testcasename() & ": FAIL: Certificate validity restriction region is not inside the issuing one ***");
                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                            }
                        }
                    } else {
                        // Region validity restriction is not exist
                        if (f_vri) {
                            log("*** " & testcasename() & ": FAIL: Certificate validity restriction region must be set if thi restriction exists in the issuing certificate ***");
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                        }
                    }
                } // End of 'for' statement
                       
                log("*** " & testcasename() & ": PASS: All certificates has a valid rectangular region restrictions ***");
                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                
                // Postamble
                f_poNeighbour();
                f_cf01Down();
garciay's avatar
garciay committed
                
garciay's avatar
garciay committed
            } // End of testcase TC_SEC_ITSS_SND_CERT_04_02_BV
garciay's avatar
garciay committed
             * @desc Check that the polygonal certificate validity region contains at least three and no more than 12 points
             *       Check that the polygonal certificate validity region does not contain intersections and holes 
garciay's avatar
garciay committed
             * Pics Selection: PICS_GN_SECURITY and PICS_USE_POLYGONAL_REGION and PICS_CERTIFICATE_SELECTION
             * Config Id: CF01
garciay's avatar
garciay committed
             * with {
             *   the IUT being in the 'authorized' state
             *   the IUT being requested to include certificate 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'
             *             containing certificate
             *                 containing validity_restrictions['region']
             *                 and containing region_type
             *                     indicating 'polygon'
             *                 and containing polygonal_region 
             *                     indicating length >=3 and <=12
             *                     and indicating continuous region without holes and intersections
             *   }
             * }
garciay's avatar
garciay committed
             * @see         ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_SND_CERT_05_01_BV
             * @reference   ETSI TS 103 097 [1], clause 4.2.24
garciay's avatar
garciay committed
            testcase TC_SEC_ITSS_SND_CERT_05_01_BV() runs on ItsGeoNetworking system ItsSecSystem {
garciay's avatar
garciay committed
                var Certificate         v_cert;
                var ValidityRestriction v_vr;
                var integer             v_counter;
garciay's avatar
garciay committed
                // Test control
                if (not(PICS_GN_SECURITY) or not(PICS_USE_POLYGONAL_REGION) or not(PICS_CERTIFICATE_SELECTION)) {
                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY and PICS_USE_POLYGONAL_REGION and PICS_CERTIFICATE_SELECTION' required for executing the TC ***");
garciay's avatar
garciay committed
                    
                // Test component configuration
                vc_hashedId8ToBeUsed := cc_iutCert_D;
                // Test adapter configuration
                
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
garciay's avatar
garciay committed
                // Test body
                tc_ac.start;
                f_waitForCertificate(v_cert);
                tc_ac.stop;
                if (f_getCertificateValidityRestriction(v_cert, e_region, v_vr)) { 
                    if (v_vr.validity.region.region_type == e_polygon) {
                        var PolygonalRegion v_pr := v_vr.validity.region.region.polygonal_region;
                        var integer v_length := lengthof(v_pr);
                        if (v_length < 3) {
                            log("*** " & testcasename() & ": FAIL: Count of points in polygonal region is too small ***");
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                        }
                        if (v_length > 12) {
                            log("*** " & testcasename() & ": FAIL: Count of points in polygonal region is too big ***");
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                        }
                        if (true != f_isValidPolygonalRegion(v_pr)) {
                            log("*** " & testcasename() & ": FAIL: Polygonal region is not valid (self-intersected) ***");
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                        }
                        log("*** " & testcasename() & ": PASS: Certificate has a valid rectangular region restrictions ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                    } else {
                        log("*** " & testcasename() & ": INCONC: Certificate has other region type ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout); // to be inconc
                    }
                } else {
                    log("*** " & testcasename() & ": PASS: Certificate doesn't have any location restrictions ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                }
                
                // Postamble
                f_poNeighbour();
                f_cf01Down();
garciay's avatar
garciay committed
                
garciay's avatar
garciay committed
            } // End of testcase TC_SEC_ITSS_SND_CERT_05_01_BV
garciay's avatar
garciay committed
             * @desc Check that the polygonal certificate validity region is inside the validity region of the issuing certificate
             *       Check that the issuing polygonal certificate validity region contains at least three and no more than 12 points 
             *       Check that the issuing polygonal certificate validity region does not contain intersections and holes 
garciay's avatar
garciay committed
             * Pics Selection: PICS_GN_SECURITY and PICS_USE_POLYGONAL_REGION and not PICS_CERTIFICATE_SELECTION
             * Config Id: CF01
garciay's avatar
garciay committed
             * 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'
             *             and containing certificates
             *                 indicating length > 0
             *             and containing certificates [n] (0..n)
             *                 containing validity_restrictions['region']
             *                     containing region_type
             *                         indicating 'polygon'
             *                     and containing polygonal_region
             *                         indicating length >=3 and <=12
             *   }
             * }
             * </pre>
             * @see         ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_SND_CERT_05_02_BV
             * @reference   ETSI TS 103 097 [1], clause 4.2.24
             */
garciay's avatar
garciay committed
            testcase TC_SEC_ITSS_SND_CERT_05_02_BV() runs on ItsGeoNetworking system ItsSecSystem {
garciay's avatar
garciay committed
                // Local declarations
                var CertificateChain    v_chain;
                var ValidityRestriction v_vr := valueof(m_validity_restriction_unknown), v_vri := valueof(m_validity_restriction_unknown);  // current and issuing cert validity restrictions
                var boolean f_vr := false, f_vri := false;
                
                // Test control
                if (not(PICS_GN_SECURITY) or not(PICS_USE_POLYGONAL_REGION) or not(PICS_CERTIFICATE_SELECTION)) {
                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY and PICS_USE_POLYGONAL_REGION and PICS_CERTIFICATE_SELECTION' required for executing the TC ***");
garciay's avatar
garciay committed
                    
                // Test component configuration
                vc_hashedId8ToBeUsed := cc_iutCert_D;
                // Test adapter configuration
                
                // Preamble
                f_prNeighbour();
garciay's avatar
garciay committed
                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);
                } else {
                    f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                }
garciay's avatar
garciay committed
                f_vr := false;
                tc_ac.stop;
                for (var integer v_counter := 0; v_counter < lengthof(v_chain); v_counter := v_counter + 1) {
                    v_vri := v_vr;
                    f_vri := f_vr;
                    f_vr := f_getCertificateValidityRestriction(v_chain[v_counter], e_region, v_vr);
                    if (f_vr) {
                        var PolygonalRegion v_pr;
                        var integer v_length;
                        
                        if (v_vr.validity.region.region_type != e_polygon) {
                            log("*** " & testcasename() & ": INCONC: Certificate validity restriction region is not polygonal ***");
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                        }
                        
                        v_pr := v_vr.validity.region.region.polygonal_region;
                        v_length := lengthof(v_pr);
                        
                        if (v_length < 3) {
                            log("*** " & testcasename() & ": FAIL: Count of points in polygonal region is too small in cert " & int2str(v_counter) & " ***");
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                        }
                        
                        if (v_length > 12) {
                            log("*** " & testcasename() & ": FAIL: Count of points in polygonal region is too big  in cert " & int2str(v_counter) & "***");
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                        }
                        
                        if (true != f_isValidPolygonalRegion(v_pr)) {
                            log("*** " & testcasename() & ": FAIL: Polygonal region is not valid (self-intersected) in cert " & int2str(v_counter) & " ***");
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                        }
                        
                        if (f_vri) {
                            // current restrictions must be inside of the parent one
                            if (true != f_isPolygonalRegionInside(v_vri.validity.region.region.polygonal_region, v_pr)) {
                                log("*** " & testcasename() & ": FAIL: Certificate validity restriction region in cert " & int2str(v_counter) & " is not inside the issuing one ***");
                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                            }
                        }
                    } else {
                        // Region validity restriction is not exist
                        if (f_vri) {
                            log("*** " & testcasename() & ": FAIL: Certificate validity restriction region must be set in the certificate "  & int2str(v_counter) &
                                                                  "because this restriction exists in the issuing certificate ***");
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                        }
                    }
                } // End of 'for' statement
garciay's avatar
garciay committed
                log("*** " & testcasename() & ": PASS: All certificates has a valid polygonal region restrictions ***");
                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                
                // Postamble
                f_poNeighbour();
                f_cf01Down();
garciay's avatar
garciay committed
                
garciay's avatar
garciay committed
            } // End of testcase TC_SEC_ITSS_SND_CERT_05_02_BV
garciay's avatar
garciay committed
            
garciay's avatar
garciay committed
             * @desc Check that the identified certificate validity region contains values that correspond to numeric country codes 
             *       as defined in ISO 3166-1 or defined by United Nations Statistics Division 
garciay's avatar
garciay committed
             * Pics Selection: PICS_GN_SECURITY and PICS_USE_IDENTIFIED_REGION and PICS_CERTIFICATE_SELECTION
             * Config Id: CF01
garciay's avatar
garciay committed
             * with {
             *   the IUT being in the 'authorized' state
             *   the IUT being requested to include certificate 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'
             *             and containing certificate 
             *                 containing validity_restrictions['region']
             *                     containing region
             *                         containing region_type
             *                             indicating 'id'
             *                         and containing id_region
             *                             containing region_dictionary
             *                                 indicating 'iso_3166_1' (0)
             *                             and containing region_identifier
             *                                 indicating valid value according to 'iso_3166_1'
             *                         and containing local_region
             *                     or containing region
             *                         containing id_region
             *                             containing region_dictionary
             *                                  indicating 'un_stats'
             *                             and containing region_identifier
             *                                 indicating valid value according to UN STATS
             *                             and containing local_region
             *   }
             * }
garciay's avatar
garciay committed
             * @see         ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_SND_CERT_06_01_BV
             * @reference   ETSI TS 103 097 [1], clause 4.2.25, 4.2.26 and 7.4.1
garciay's avatar
garciay committed
            testcase TC_SEC_ITSS_SND_CERT_06_01_BV() runs on ItsGeoNetworking system ItsSecSystem {
garciay's avatar
garciay committed
                var Certificate         v_cert;
                var ValidityRestriction v_vr;
                var integer             v_counter;
garciay's avatar
garciay committed
                // Test control
                if (not(PICS_GN_SECURITY) or not(PICS_USE_IDENTIFIED_REGION) or not(PICS_CERTIFICATE_SELECTION)) {
                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY and PICS_USE_IDENTIFIED_REGION and PICS_CERTIFICATE_SELECTION' required for executing the TC ***");
garciay's avatar
garciay committed
                    
                // Test component configuration
                vc_hashedId8ToBeUsed := cc_iutCert_E;
                // Test adapter configuration
                
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
garciay's avatar
garciay committed
                // Test body
                tc_ac.start;
                f_waitForCertificate(v_cert);
                tc_ac.stop;
                if (f_getCertificateValidityRestriction(v_cert, e_region, v_vr)) {
                    if (v_vr.validity.region.region_type == e_id) {
                        if (not match (v_vr.validity.region, mw_geographicRegion_identified(mw_identifiedRegion_iso3166_any))) {
                            log("*** " & testcasename() & ": FAIL: Identified region is not conformed to ISO 3166-1 ***");
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                        } else if (not match (v_vr.validity.region, mw_geographicRegion_identified(mw_identifiedRegion_un_stats_any))) {
                            log("*** " & testcasename() & ": FAIL: Identified region is not conformed to United Nations Statistics Division ***");
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                        }
                    }
                    log("*** " & testcasename() & ": PASS: Certificate has a valid  region ID restrictions ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                } else {
                    log("*** " & testcasename() & ": FAIL: Certificate doesn't have any location restrictions ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                }
                
                // Postamble
                f_poNeighbour();
                f_cf01Down();
garciay's avatar
garciay committed
                
garciay's avatar
garciay committed
            } // End of testcase TC_SEC_ITSS_SND_CERT_06_01_BV
garciay's avatar
garciay committed
             * @desc Check that the identified certificate validity region contains values that correspond to numeric country codes 
             *       as defined in ISO 3166-1 or defined by United Nations Statistics Division
             *       Check that the identified certificate validity region contains values defining the region which is inside 
             *       the validity region of the issuing certificate 
garciay's avatar
garciay committed
             * @remark The case when signing certificate and issuing certificate contain different type of region validity restriction is not supported by this test 
garciay's avatar
garciay committed
             * Pics Selection: PICS_GN_SECURITY and PICS_USE_IDENTIFIED_REGION and PICS_CERTIFICATE_SELECTION
             * Config Id: CF01
garciay's avatar
garciay committed
             * 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'
             *             and containing certificate 
             *                 indicating length N > 1
garciay's avatar
garciay committed
             *                 and containing certificates[n] (0..N)
garciay's avatar
garciay committed
             *                     containing validity_restrictions['region']
             *                         containing region
             *                             containing region_type
             *                                 indicating 'id'
             *                             and containing id_region
             *                                     containing region_dictionary
             *                                     indicating 'iso_3166_1' (0)
             *                                 and containing region_identifier
             *                                     indicating valid value according to 'iso_3166_1'
             *                             and containing local_region
             *                         or containing region
             *                             containing id_region
             *                                 containing region_dictionary
             *                                     indicating 'un_stats'
             *                                 and containing region_identifier
             *                                     indicating valid value according to UN STATS
             *                                 and containing local_region
             *   }
             * }
garciay's avatar
garciay committed
             * @see         ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_SND_CERT_06_02_BV
             * @reference   ETSI TS 103 097 [1], clause 4.2.26
garciay's avatar
garciay committed
            testcase TC_SEC_ITSS_SND_CERT_06_02_BV() runs on ItsGeoNetworking system ItsSecSystem {
garciay's avatar
garciay committed
                var CertificateChain         v_chain;
                var ValidityRestriction v_vr := valueof(m_validity_restriction_unknown), v_vri := valueof(m_validity_restriction_unknown);  // current and issuing cert validity restrictions
                var boolean f_vr := false, f_vri := false;
garciay's avatar
garciay committed
                // Test control
                if (not(PICS_GN_SECURITY) or not(PICS_USE_IDENTIFIED_REGION) or not(PICS_CERTIFICATE_SELECTION)) {
                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY and PICS_USE_IDENTIFIED_REGION and PICS_CERTIFICATE_SELECTION' required for executing the TC ***");
garciay's avatar
garciay committed
                    
                // Test component configuration
                vc_hashedId8ToBeUsed := cc_iutCert_E;
                // Test adapter configuration
                
                // Preamble
                f_prNeighbour();
garciay's avatar
garciay committed
                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);
                } else {
                    f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                }
garciay's avatar
garciay committed
                f_vr := false;
                tc_ac.stop;
                for (var integer v_counter := 0; v_counter < lengthof(v_chain); v_counter := v_counter + 1) {
                    v_vri := v_vr;
                    f_vri := f_vr;
                    f_vr := f_getCertificateValidityRestriction(v_chain[v_counter], e_region, v_vr);
                    
                    if (f_vr) {
                        if (v_vr.validity.region.region_type == e_id) {
                            if (not match (v_vr.validity.region, mw_geographicRegion_identified(mw_identifiedRegion_iso3166_any))) {
                                log("*** " & testcasename() & ": FAIL: Identified region is not conformed to ISO 3166-1 ***");
                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                            }
                            if (not match (v_vr.validity.region, mw_geographicRegion_identified(mw_identifiedRegion_un_stats_any))) {
                                log("*** " & testcasename() & ": FAIL: Identified region is not conformed to United Nations Statistics Division ***");
                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                            }
                        }
                        
                        if (f_vri) {
                            // the region code must be the same
                            if (v_vr.validity.region.region.id_region.region_identifier !=
                               v_vri.validity.region.region.id_region.region_identifier) {
                                log("*** " & testcasename() & ": FAIL: Certificate validity restriction identified region in cert " & int2str(v_counter) & " is not the same as in the issuing one ***");
                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                            }
                            if (    v_vri.validity.region.region.id_region.local_region != 0 
                               and v_vri.validity.region.region.id_region.local_region != v_vr.validity.region.region.id_region.local_region ) {
                                log("*** " & testcasename() & ": FAIL: Certificate validity restriction local identified region in cert " & int2str(v_counter) & " is not the same as in the issuing one ***");
                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                            }
                        }
                        
                    } else {
                        // Region validity restriction is not exist
                        if (f_vri) {
                            log("*** " & testcasename() & ": FAIL: Certificate validity restriction identified region must be set in the certificate "  & int2str(v_counter) &
                                                                  "because this restriction exists in the issuing certificate ***");
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                        }
                    }
garciay's avatar
garciay committed
                log("*** " & testcasename() & ": PASS: All certificates has a valid identified regionrestrictions ***");
                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                
                // Postamble
                f_poNeighbour();
                f_cf01Down();
garciay's avatar
garciay committed
            } // End of testcase TC_SEC_ITSS_SND_CERT_06_02_BV
garciay's avatar
garciay committed
            
            // TODO To be removed
//            /**
//             * @desc Check Identified Region:
//             * Must contain value that correspond to numeric country codes as defined by United Nations Statistics Division
//             * <pre>
//             * Pics Selection: PICS_GN_SECURITY and PICS_USE_IDENTIFIED_REGION and PICS_USE_UN_STATS_REGION_DICTIONARY and PICS_CERTIFICATE_SELECTION
//             * Config Id: CF01
//             * with {
//             *   the IUT being in the 'authorized' state
//             *   the IUT being requested to include certificate 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'
//             *         containing certificate {
//             *           containing validity_restrictions['region']{
//             *             containing region_type
//             *               indicating 'id'
//             *             containing id_region {
//             *               containing region_dictionary
//             *                 indicating 'un_stats' (0)
//             *               containing region_dictionary
//             *                 indicating 'un_stats' (0)
//             *               indicating length >=3 and <=12
//             *               indicating continuous region without holes and intersections
//             *             }
//             *           }
//             *         }
//             *       }
//             *   }
//             * }
//             * </pre>
//             * @see         ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_SND_CERT_06_03_BV
//             * @reference   ETSI TS 103 097 [1], clause 4.2.26
//             */
garciay's avatar
garciay committed
//            testcase TC_SEC_ITSS_SND_CERT_06_03() runs on ItsGeoNetworking system ItsSecSystem {
garciay's avatar
garciay committed
//                var Certificate         v_cert;
//                var ValidityRestriction v_vr;
//                var integer             v_counter;
//                
//                // Test control
//                if (not(PICS_GN_SECURITY) or not(PICS_USE_IDENTIFIED_REGION) or not(PICS_USE_UN_STATS_REGION_DICTIONARY) or not(PICS_CERTIFICATE_SELECTION)) {
//                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY and PICS_USE_UN_STATS_REGION_DICTIONARY and PICS_USE_ISO31661_REGION_DICTIONARY and PICS_CERTIFICATE_SELECTION' required for executing the TC ***");
//                    stop;
//                }
//                    
//                // Test component configuration
//                vc_hashedId8ToBeUsed := cc_iutCert_E;
//                f_cf01Up();
//                
//                // Test adapter configuration
//                
//                // Preamble
//                f_prNeighbour();
//                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
//                
//                // Test body
//                tc_ac.start;
//                f_waitForCertificate(v_cert);
//                tc_ac.stop;
//                if (f_getCertificateValidityRestriction(v_cert, e_region, v_vr)) {
//                    if (v_vr.validity.region.region_type == e_id) {
//                        if (not match (v_vr.validity.region, mw_geographicRegion_identified(mw_identifiedRegion_un_stats_any))) {
//                            log("*** " & testcasename() & ": FAIL: Identified region is not the UN Stats Region Code ***");
//                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
//                        }
//                    }
//                    log("*** " & testcasename() & ": PASS: Certificate has a valid identified region restrictions ***");
//                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
//                } else {
//                    log("*** " & testcasename() & ": PASS: Certificate doesn't have any location restrictions ***");
//                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
//                }
//                
//                // Postamble
//                f_poNeighbour();
//                f_cf01Down();
garciay's avatar
garciay committed
//            } // End of testcase TC_SEC_ITSS_SND_CERT_06_03
garciay's avatar
garciay committed
//            
//            /**
//             * @desc Check Identified Region:
//             * Must contain value that correspond to numeric country codes as defined by United Nations Statistics Division 
//             * Subordinate certificate restrictions must be a subset of the issuing certificate restrictions  
//             * <pre>
//             * Pics Selection: PICS_GN_SECURITY and PICS_USE_IDENTIFIED_REGION and PICS_USE_UN_STATS_REGION_DICTIONARY and PICS_CERTIFICATE_SELECTION
//             * 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'
//             *         containing certificates
//             *           indicating CERTIFICATES {
//             *             containing CERTIFICATES[0] {
//             *               containing validity_restrictions['region'] {
//             *                 containing region_type
//             *                   indicating 'id'
//             *                 containing id_region {
//             *                   containing region_dictionary
//             *                     indicating 'un_stats' (1)
//             *                   containing region_identifier
//             *                     indicating valid value according to UnStats document
//             *                   containing local_region
//             * 
//             *                 }
//             *             }
//             *             containing CERTIFICATES[n] (1..N) {
//             *               containing no validity restriction of type region or validity_restrictions['region'] {
//             *                 containing region_type
//             *                   indicating 'id'
//             *                 containing id_region 
//             *                   containing region_dictionary
//             *                     indicating 'un_stats' (1)
//             *                   containing region_identifier
//             *                     indicating CERTIFICATES[n-1].validity_restrictions['region'].id_region.region_identifier
//             *                   containing local_region
//             *                     indicating CERTIFICATES[n-1].validity_restrictions['region'].id_region.local_region
//             *                       or any value if CERTIFICATES[n-1].validity_restrictions['region'].id_region.local_region == 0
//             *                 }
//             *               }
//             *             }
//             *           }
//             *       }
//             *   }
//             * }
//             * </pre>
//             * @see         ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_SND_CERT_06_04_BV
//             * @reference   ETSI TS 103 097 [1], clause 4.2.26
//             */
garciay's avatar
garciay committed
//            testcase TC_SEC_ITSS_SND_CERT_06_04() runs on ItsGeoNetworking system ItsSecSystem {
garciay's avatar
garciay committed
//                var CertificateChain         v_chain;
//                var ValidityRestriction v_vr := valueof(m_validity_restriction_unknown), v_vri := valueof(m_validity_restriction_unknown);  // current and issuing cert validity restrictions
//                var boolean f_vr := false, f_vri := false;
//                
//                // Test control
//                if (not(PICS_GN_SECURITY) or not(PICS_USE_IDENTIFIED_REGION) or not(PICS_USE_UN_STATS_REGION_DICTIONARY) or not(PICS_CERTIFICATE_SELECTION)) {
//                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY and PICS_USE_UN_STATS_REGION_DICTIONARY and PICS_USE_ISO31661_REGION_DICTIONARY and PICS_CERTIFICATE_SELECTION' required for executing the TC ***");
//                    stop;
//                }
//                
//                // Test component configuration
//                vc_hashedId8ToBeUsed := cc_iutCert_E;
//                f_cf01Up();
//                
//                // Test adapter configuration
//                
//                // Preamble
//                f_prNeighbour();
//                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);
//                } else {
//                    f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
//                }
//                
//                // Test Body
//                f_vr := false;
//                tc_ac.stop;
//                for (var integer v_counter := 0; v_counter < lengthof(v_chain); v_counter := v_counter + 1) {
//                    v_vri := v_vr;
//                    f_vri := f_vr;
//                    f_vr := f_getCertificateValidityRestriction(v_chain[v_counter], e_region, v_vr);
//                    
//                    if (f_vr) {
//                        if (v_vr.validity.region.region_type == e_id) {
//                            if (not match (v_vr.validity.region, mw_geographicRegion_identified(mw_identifiedRegion_un_stats_any))) {
//                                log("*** " & testcasename() & ": FAIL: Identified region is not the UN Stats Region Code ***");
//                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
//                            }
//                        }
//                        
//                        if (f_vri) {
//                            // the region code must be the same
//                            if (v_vr.validity.region.region.id_region.region_identifier !=
//                               v_vri.validity.region.region.id_region.region_identifier) {
//                                log("*** " & testcasename() & ": FAIL: Certificate validity restriction identified region in cert " & int2str(v_counter) & " is not the same as in the issuing one ***");
//                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
//                            }
//                            if (    v_vri.validity.region.region.id_region.local_region != 0 
//                               and v_vri.validity.region.region.id_region.local_region != v_vr.validity.region.region.id_region.local_region
//                               and not f_isIdentifiedRegionInside(v_vri.validity.region.region.id_region.local_region, v_vr.validity.region.region.id_region.local_region)
//                            ) {
//                                log("*** " & testcasename() & ": FAIL: Certificate validity restriction local identified region in cert " & int2str(v_counter) & " is not the subregion of the issuing one ***");
//                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
//                            }
//                        }
//                        
//                    } else {
//                        // Region validity restriction is not exist
//                        if (f_vri) {
//                            log("*** " & testcasename() & ": FAIL: Certificate validity restriction identified region must be set in the certificate "  & int2str(v_counter) &
//                                                                  "because this restriction exists in the issuing certificate ***");
//                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
//                        }
//                    }
//                }
//                log("*** " & testcasename() & ": PASS: All certificates has a valid identified region restrictions ***");
//                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
//                
//                // Postamble
//                f_poNeighbour();
//                f_cf01Down();
//                
garciay's avatar
garciay committed
//            } // End of testcase TC_SEC_ITSS_SND_CERT_06_04
garciay's avatar
garciay committed
//            
garciay's avatar
garciay committed
             * @desc Check that the region of the subordinate certificate validity restriction is inside the region of the issuing certificate validity restriction 
             * <pre>
             * Pics Selection: PICS_GN_SECURITY
             * 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'
             *             and containing certificates 
             *                 indicating length N > 1
             *                 and containing certificates[n] (0..N)
             *                     indicating certificate
             *                         not containing validity_restrictions['region']
             *                         and containing signer_info
             *                             containing digest
             *                                 referenced to the certificate
             *                                     not containing validity_restrictions['region']
             *                     or indicating certificate
             *                         containing validity_restrictions['region']
             *                             containing region.region_type
             *                                 indicating 'none'
             *                         and containing signer_info
             *                             containing digest
             *                                 referenced to the certificate
             *                                     not containing validity_restrictions['region']
             *                                     or containing validity_restrictions['region']
             *                                         containing region.region_type
             *                                             indicating 'none'
             *                     or indicating certificate
             *                         containing validity_restrictions['region']
             *                             containing region.region_type
             *                                 indicated 'circle'
             *                                 or indicated 'rectangle'
             *                                 or indicated 'polygon'
             *                                 or indicated 'id'
             *                             and containing region (X_CERT__REGION)
             *                         and containing signer_info
             *                             containing digest
             *                                 referenced to the certificate
             *                                     not containing validity_restrictions['region']
             *                                     or containing validity_restrictions['region']
             *                                         containing region.region_type
             *                                             indicating 'none'
             *                                     or containing validity_restrictions['region']
             *                                         containing region
             *                                             indicating region fully covering the X_CERT_REGION
             *   }
             * }
             * </pre>
             * @see         ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_SND_CERT_07_01_BV
             * @reference   ETSI TS 103 097 [1], clause 4.2.25, 4.2.26 and 7.4.1
             */
garciay's avatar
garciay committed
            testcase TC_SEC_ITSS_SND_CERT_07_01_BV() runs on ItsGeoNetworking system ItsSecSystem {
garciay's avatar
garciay committed
                var CertificateChain    v_chain;
                var Certificate         v_cert, v_cert_issuer;
                var SignerInfo          v_si;
                var UInt8               v_counter;
                var HashedId8           v_digest;
                var CertificatesCaching v_certificatesCaching;
                var FncRetCode          v_result_status := e_success;
                
                // Test control
                if (not(PICS_GN_SECURITY)) {
                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY' required for executing the TC ***");
                    stop;
                }
                    
                // Test component configuration
//                vc_hashedId8ToBeUsed := cc_iutCert_E;
                f_cf01Up();
                
                // Test adapter configuration
                
                // Preamble
                f_prNeighbour();
                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);
                } else {
                    f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                }
                
                // Test Body
                // 1. Create a cache of certificates
                f_createCertificatesCaching(v_chain, v_certificatesCaching);
                // 2. Process the certificates
                v_counter := f_getCertificatesCachingItemSize(v_certificatesCaching) - 1;
                while (v_counter != 0) {
                    // Get the first certificate
                    if (f_getCertificatesCachingItem(v_certificatesCaching, v_counter, v_cert) == false) {
                        v_result_status := e_error;
                        break;
                    }
                    // Retrive SigneInfo field
                    if (not f_getCertificateSignerInfo(v_cert, v_si)) {
                        log("*** " & testcasename() & ": FAIL: Certificate " & int2str(v_counter) & " doesn't have a signer info ***");
                        v_result_status := e_error;
                        break;
                    }
                    if (not match (v_si.type_, e_certificate_digest_with_sha256)) {
                        log("*** " & testcasename() & ": FAIL: Certificate is not signed with digest ***");
                        v_result_status := e_error;
                        break;
                    }
                    // Get issuer
                    if (f_getCertificateFromCaching(v_certificatesCaching, v_si.signerInfo.digest, v_cert_issuer) == false) {
                        log("*** " & testcasename() & ": FAIL: Certificate is not signed with digest ***");
                        v_result_status := e_error;
                        break;
                    }
                    // Check that cert is signed by issuing cert
                    v_digest := f_calculateDigestFromCertificate(v_cert_issuer);
                    if (not match (v_si.signerInfo.digest, v_si.signerInfo.digest)) {
                        log("*** " & testcasename() & ": FAIL: Certificate chain is not valid ***");
                        v_result_status := e_error;
                        break;
                    }
                    // Check that the region of the subordinate certificate validity restriction is inside the region of the issuing certificate validity restriction 
                    if (f_checkRegionValidityRestiction(v_cert, v_cert_issuer) == false) {
                        v_result_status := e_error;
                        break;
                    }
                    
                    // Prepare next loop
                    v_counter := v_counter - 1;
                    
                } // End of 'while' statement
                if (v_result_status == e_success) {
                    log("*** " & testcasename() & ": PASS: All certificates has a valid identified region restrictions ***");
                }
                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, v_result_status);
                
                // Postamble
                f_poNeighbour();
                f_cf01Down();
garciay's avatar
garciay committed
            } // End of testcase TC_SEC_ITSS_SND_CERT_07_01_BV
garciay's avatar
garciay committed
            
            /**
             * @desc Check that the region of the subordinate certificate validity restriction is inside the region of the issuing certificate validity restriction
             * <pre>
             * Pics Selection: PICS_GN_SECURITY and PICS_USE_IDENTIFIED_REGION
             * Config Id: CF01
             * with {
             *   the IUT being in the 'authorized' state
             *   the IUT being requested to include certificate chain in the next CAM
             *   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'
             *             and containing certificates 
             *                 indicating length N > 1
             *                 and containing certificates[n] (0..N)
             *                     indicating certificate
             *                         containing validity_restrictions['region']
             *                             containing region.region_type
             *                                 indicated 'id'
             *                             and containing id_region
             *                                 containing region_dictionary
             *                                     indicating 'iso_3166_1' 
             *                                     or indicating 'un_stat' 
             *                                 and containing region_identifier (X_CERT_REGION_ID)
             *                                     indicating valid value according to 'iso_3166_1' or 'un_stat' 
             *                                 and containing local_region (X_CERT_LOCAL_REGION)
             *                         and containing signer_info
             *                             containing digest
             *                                 referenced to the certificate
             *                                     containing validity_restrictions['region']
             *                                         containing region
             *                                             indicated 'id'
             *                                         and containing id_region
             *                                             containing region_dictionary
             *                                                 indicating 'iso_3166_1' 
             *                                                 or indicating 'un_stat' 
             *                                             and containing region_identifier
             *                                                 indicating value == X_CERT_REGION_ID
             *                                             and containing local_region
             *                                                 indicating value == X_CERT_LOCAL_REGION
             *                                                 or indicating 0
             *                                             or containing id_region
             *                                                 containing region_dictionary
             *                                                    indicating 'un_stats'
             *                                                 and containing region_identifier
             *                                                     indicating region fully covering the X_CERT_REGION
             *   }
             * }
             * </pre>
             * @see         ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_SND_CERT_07_02_BV
             * @reference   ETSI TS 103 097 [1], clause 4.2.25, 4.2.26 and 7.4.1
             */
garciay's avatar
garciay committed
            testcase TC_SEC_ITSS_SND_CERT_07_02_BV() runs on ItsGeoNetworking system ItsSecSystem {
garciay's avatar
garciay committed
                var CertificateChain    v_chain;
                var Certificate         v_cert, v_cert_issuer;
                var SignerInfo          v_si;
                var UInt8               v_counter;
                var HashedId8           v_digest;
                var CertificatesCaching v_certificatesCaching;
                var FncRetCode          v_result_status := e_success;
                
                // Test control
                if (not(PICS_GN_SECURITY) or not(PICS_USE_IDENTIFIED_REGION)) {
                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY and PICS_USE_IDENTIFIED_REGION' required for executing the TC ***");
                    stop;
                }
                    
                // Test component configuration
//                vc_hashedId8ToBeUsed := cc_iutCert_E;
                f_cf01Up();
                
                // Test adapter configuration
                
                // Preamble
                f_prNeighbour();
                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);
                } else {
                    f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                }
                
                // Test Body
                // 1. Create a cache of certificates
                f_createCertificatesCaching(v_chain, v_certificatesCaching);
                // 2. Process the certificates
                v_counter := f_getCertificatesCachingItemSize(v_certificatesCaching) - 1;
                while (v_counter != 0) {
                    // Get the first certificate
                    if (f_getCertificatesCachingItem(v_certificatesCaching, v_counter, v_cert) == false) {
                        v_result_status := e_error;
                        break;
                    }
                    // Retrive SigneInfo field
                    if (not f_getCertificateSignerInfo(v_cert, v_si)) {
                        log("*** " & testcasename() & ": FAIL: Certificate " & int2str(v_counter) & " doesn't have a signer info ***");
                        v_result_status := e_error;
                        break;
                    }
                    if (not match (v_si.type_, e_certificate_digest_with_sha256)) {
                        log("*** " & testcasename() & ": FAIL: Certificate is not signed with digest ***");
                        v_result_status := e_error;
                        break;
                    }
                    // Get issuer
                    if (f_getCertificateFromCaching(v_certificatesCaching, v_si.signerInfo.digest, v_cert_issuer) == false) {
                        log("*** " & testcasename() & ": FAIL: Certificate is not signed with digest ***");
                        v_result_status := e_error;
                        break;
                    }
                    // Check that cert is signed by issuing cert
                    v_digest := f_calculateDigestFromCertificate(v_cert_issuer);
                    if (not match (v_si.signerInfo.digest, v_si.signerInfo.digest)) {
                        log("*** " & testcasename() & ": FAIL: Certificate chain is not valid ***");
                        v_result_status := e_error;
                        break;
                    }
                    // Check that the region of the subordinate certificate validity restriction is inside the region of the issuing certificate validity restriction 
                    if (f_checkRegionValidityRestiction(v_cert, v_cert_issuer) == false) {
                        v_result_status := e_error;
                        break;
                    }
                    
                    // Prepare next loop
                    v_counter := v_counter - 1;
                    
                } // End of 'while' statement
                if (v_result_status == e_success) {
                    log("*** " & testcasename() & ": PASS: All certificates has a valid identified region restrictions ***");
                }
                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, v_result_status);
                
                // Postamble
                f_poNeighbour();
                f_cf01Down();
garciay's avatar
garciay committed
            } // End of testcase TC_SEC_ITSS_SND_CERT_02_01_BV
garciay's avatar
garciay committed
            
            /**
             * @desc Check that time_start_and_end is included in the AA certificate validation restrictions
             *       Check that end_validity is later then start_validity
             *       Check that validity restriction of AA certificate is inside the validity restriction of its issuing certificate 
             * <pre>
             * Pics Selection: PICS_GN_SECURITY
             * 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
             *             containing certificates
             *                 containing certificates[last-1]
             *                     containing validity_restrictions
             *                         containing validity_restrictions['time_start_and_end']
             *                             containing start_validity
             *                                 indicating START_AA_VALIDITY
             *                             containing end_validity
             *                                 indicating END_AA_VALIDITY >= START_AA_VALIDITY
             *                     and containing signer_info
             *                         containing digest
             *                             referenced to the trusted certificate
             *                                 containing validity_restrictions['time_end']
             *                                     containing end_validity
             *                                         indicating value > AA_END_VALIDITY
             *                                 or containing validity_restrictions['time_start_and_end']
             *                                     containing start_validity
             *                                         indicating value <= AA_START_VALIDITY
             *                                      and containing end_validity
             *                                         indicating value > AA_END_VALIDITY
             *                                 or containing validity_restrictions['time_start_and_duration']
             *                                     containing start_validity
             *                                         indicating X_START_VALIDITY <= AA_START_VALIDITY
             *                                     and containing duration
             *                                         indicating value > AA_END_VALIDITY - X_START_VALIDITY
             *   }
             * }
             * </pre>
             * @see         ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_SND_CERT_08_01_BV
             * @reference   ETSI TS 103 097 [1], clauses 7.4.4
             */
garciay's avatar
garciay committed
            testcase TC_SEC_ITSS_SND_CERT_08_01_BV() runs on ItsGeoNetworking system ItsSecSystem {
garciay's avatar
garciay committed
                var CertificateChain         v_chain;
                var Certificate              v_aa_cert;
                var ValidityRestriction      v_vr;
                var SignerInfo               v_si;
                var Time64                   v_generationTime;
                var Time64                   v_curTime;
                var Time64                   v_startTime, v_endTime, v_duration;
                
                // 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_aa_cert := v_chain[lengthof(v_chain) - 1];
                if (match (v_aa_cert.validity_restrictions, (superset(mw_validity_restriction_time_end,
                                                                      mw_validity_restriction_time_start_and_duration)))
                ) {
                    log("*** " & testcasename() & ": FAIL: AA certificate must not contain time_end and time_start_and_duration restrictions ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                }
                
                if ( true != f_getCertificateValidityRestriction(v_aa_cert, e_time_start_and_end, v_vr)) {
                    log("*** " & testcasename() & ": FAIL: AA 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 mus not be greater then end validity in the validity restrictions of AA certificate ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                }
                
                // Process signerInfo field
                if ( true != f_getCertificateSignerInfo(v_aa_cert, v_si)) {
                    log("*** " & testcasename() & ": FAIL: AA certificate must contain SignerInfo fields ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                }
                if (v_si.type_ == e_certificate) {
                    log("*** " & testcasename() & ": FAIL: AA certificate must contain SignerInfo field containing a certificate ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                }
                for (var integer v_counter := 0; v_counter < lengthof(v_si.signerInfo.certificate.validity_restrictions); v_counter := v_counter + 1) {
                    if (v_si.signerInfo.certificate.validity_restrictions[v_counter].type_ == e_time_end) {
                        v_endTime := v_si.signerInfo.certificate.validity_restrictions[v_counter].validity.end_validity * 1000000;
                        if (not match(v_generationTime, Time64:(0 .. v_endTime))){
                            log("*** " & testcasename() & ": FAIL: DENM generation time is not inside the validity of the certificate");
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                        }
                    } else if (v_si.signerInfo.certificate.validity_restrictions[v_counter].type_ == e_time_start_and_end) {
                        v_endTime := v_si.signerInfo.certificate.validity_restrictions[v_counter].validity.time_start_and_end.end_validity * 1000000;
                        v_startTime := v_si.signerInfo.certificate.validity_restrictions[v_counter].validity.time_start_and_end.start_validity * 1000000;
                        if (not match(v_generationTime, Time64:(v_startTime .. v_endTime))){
                            log("*** " & testcasename() & ": FAIL: DENM generation time is not inside the validity of the certificate");
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                        }
                    } else if (v_si.signerInfo.certificate.validity_restrictions[v_counter].type_ == e_time_start_and_duration) {
                        v_startTime := v_si.signerInfo.certificate.validity_restrictions[v_counter].validity.time_start_and_duration.start_validity * 1000000;
                        v_duration  := f_duration2time(v_si.signerInfo.certificate.validity_restrictions[v_counter].validity.time_start_and_duration.duration_) * 1000000;
                        if (not match(v_generationTime, Time64:(v_startTime .. v_duration))){
                            log("*** " & testcasename() & ": FAIL: DENM generation time is not inside the validity of the certificate");
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                        }
                    } else {
                        log("*** " & testcasename() & ": FAIL: Mal-formed the certificate");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                    }
                } // End of 'for' statement
                
                log("*** " & testcasename() & ": PASS: Time validity restriction of the AA 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_08_01_BV
garciay's avatar
garciay committed
            
            /**
             * @desc    Check that the certificate signature contains ECC point of type set to either compressed_lsb_y_0, compressed_lsb_y_1 
             *          or x_coordinate_only
             * Pics Selection: PICS_GN_SECURITY
             * Config Id: CF01
             * Initial conditions:
garciay's avatar
garciay committed
             * with {
             *   the IUT being in the 'authorized' state
             *      the IUT being requested to include certificate in the next CAM
             * }
             * Expected Behaviour:
             * 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 signature.ecdsa_signature
             *                 containing R.type
             *                     indicating compressed_lsb_y_0
             *                     or indicating compressed_lsb_y_1 
             *                     or indicating x_coordinate_only
             *         }
garciay's avatar
garciay committed
             *   }
             * }
garciay's avatar
garciay committed
             * @see         ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_SND_CERT_09_01_BV
garciay's avatar
garciay committed
             * @reference   ETSI TS 103 097 [1], clause 4.2.9
garciay's avatar
garciay committed
            testcase TC_SEC_ITSS_SND_CERT_09_01_BV() runs on ItsGeoNetworking system ItsSecSystem {
garciay's avatar
garciay committed
                // Test control
                if (not(PICS_GN_SECURITY)) {
                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY' required for executing the TC ***");
                    stop;
                }
garciay's avatar
garciay committed
                // Test component configuration
                // Test adapter configuration
                
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
garciay's avatar
garciay committed
                tc_ac.start;
                alt {
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mdw_securedMessage(
                                    superset(
                                        mw_header_field_signer_info_certificate(
                                            mw_at_certificate(
                                                ?,
                                                ?,
                                                ?,
                                                mw_signature(
                                                    mw_ecdsaSignature(
                                                        mw_eccPointecdsa_nistp256_with_sha256_y0_coordinate_only
                    ))))))))) {
                        tc_ac.stop;
                        log("*** " & testcasename() & ": PASS: AT certificate contains signature with the ECC point of type set to compressed_lsb_y_0 received ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                    }
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mdw_securedMessage(
                                    superset(
                                        mw_header_field_signer_info_certificate(
                                            mw_at_certificate(
                                                ?,
                                                ?,
                                                ?,
                                                mw_signature(
                                                    mw_ecdsaSignature(
                                                        mw_eccPointecdsa_nistp256_with_sha256_y1_coordinate_only
                    ))))))))) {
                        tc_ac.stop;
                        log("*** " & testcasename() & ": PASS: AT certificate contains signature with the ECC point of type set to compressed_lsb_y_1 received ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                    }
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mdw_securedMessage(
                                    superset(
                                        mw_header_field_signer_info_certificate(
                                            mw_at_certificate(
                                                ?,
                                                ?,
                                                ?,
                                                mw_signature(
                                                    mw_ecdsaSignature(
                                                        mw_eccPointecdsa_nistp256_with_sha256_x_coordinate_only
                    ))))))))) {
                        tc_ac.stop;
                        log("*** " & testcasename() & ": PASS: AT certificate contains signature with the ECC point of type set to x_coordinate_only received ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                    }
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mdw_securedMessage(
                                    superset(
                                        mw_header_field_signer_info_certificate(
                                            mw_at_certificate
                    )))))) {
                        tc_ac.stop;
                        log("*** " & testcasename() & ": FAIL: AT certificate signature mismatch ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                    }
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: Expected message not received ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                    }
                } // End of 'alt' statement
                
                // Postamble
                f_poNeighbour();
                f_cf01Down();
garciay's avatar
garciay committed
                
garciay's avatar
garciay committed
            } // End of testcase TC_SEC_ITSS_SND_CERT_09_01_BV
garciay's avatar
garciay committed
             * @desc    Check that the all certificates in a chain have signatures contains ECC point of type set to either compressed_lsb_y_0, compressed_lsb_y_1 
             *          or x_coordinate_only
             * Pics Selection: PICS_GN_SECURITY
             * Config Id: CF01
             * Initial conditions:
garciay's avatar
garciay committed
             * 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
             * }
             * Expected Behaviour:
             * 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
             *             containing type
             *                 indicating 'certificate_chain'
             *             containing certificates
             *                 indicating length N > 1
             *                 and indicating certificates[n] (0..N)
             *                     containing signature.ecdsa_signature
             *                         containing R.type
             *                             indicating compressed_lsb_y_0
             *                             or indicating compressed_lsb_y_1 
             *                             or indicating x_coordinate_only 
garciay's avatar
garciay committed
             *   }
             * }
garciay's avatar
garciay committed
             * @see         ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_SND_CERT_09_02_BV
             * @reference   ETSI TS 103 097 [1], clause 4.2.9
garciay's avatar
garciay committed
            testcase TC_SEC_ITSS_SND_CERT_09_02_BV() runs on ItsGeoNetworking system ItsSecSystem {
garciay's avatar
garciay committed
                // Local variables
                var GeoNetworkingInd v_geoNwInd;
                var SignerInfo       v_si;
                var CertificateChain v_chain;
                var integer          v_counter;
garciay's avatar
garciay committed
                // Test control
                if (not(PICS_GN_SECURITY)) {
                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY' required for executing the TC ***");
                    stop;
                }
garciay's avatar
garciay committed
                // Test component configuration
                // Test adapter configuration
                
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
garciay's avatar
garciay committed
                tc_ac.start;
                alt {
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mdw_securedMessage(
                                    superset(
garciay's avatar
garciay committed
                                        mw_header_field_signer_info_certificate_chain
                    ))))) -> value v_geoNwInd {
garciay's avatar
garciay committed
                        tc_ac.stop;
garciay's avatar
garciay committed
                        // Check certificate chain
                        if (f_getMsgSignerInfo(f_getSecuredMessage(v_geoNwInd.msgIn), v_si)) {
                            v_chain  :=  v_si.signerInfo.certificates;
                            for (v_counter := lengthof(v_chain) - 1; v_counter > 0; v_counter := v_counter - 1 ) {
                                if (v_chain[v_counter].signature_.algorithm != e_ecdsa_nistp256_with_sha256) {
                                    log("*** " & testcasename() & ": FAIL: Wrong signature algorithm ***");
                                    f_selfOrClientSyncAndVerdictPreamble(c_tbDone, e_error);
                                } else if (
                                    (v_chain[v_counter].signature_.signature_.ecdsa_signature.r.type_ != e_x_coordinate_only) and 
                                    (v_chain[v_counter].signature_.signature_.ecdsa_signature.r.type_ != e_compressed_lsb_y_0) and 
                                    (v_chain[v_counter].signature_.signature_.ecdsa_signature.r.type_ != e_compressed_lsb_y_1) 
                                ) {
                                    log("*** " & testcasename() & ": FAIL: Wrong ECDSA R type ***");
                                    f_selfOrClientSyncAndVerdictPreamble(c_tbDone, e_error);
                                }
                            } // End of 'for' statement
                        }
                        log("*** " & testcasename() & ": PASS: All certificates in a chain have the correct signature type ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                    }
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: Expected message not received ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                    }
                } // End of 'alt' statement
                
                // Postamble
                f_poNeighbour();
                f_cf01Down();
                
garciay's avatar
garciay committed
            } // End of testcase TC_SEC_ITSS_SND_CERT_09_02_BV
garciay's avatar
garciay committed
            
            /**
             * @desc    Check that the certificate verification key contains ECC point of type set to either compressed_lsb_y_0, compressed_lsb_y_1 
             *          or uncompressed
             * <pre>
             * Pics Selection: PICS_GN_SECURITY
             * Config Id: CF01
             * Initial conditions:
             * with {
             *   the IUT being in the 'authorized' state
             *   the IUT being requested to include certificate in the next CAM
             * }
             * Expected Behaviour:
             * 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 subject_attributes['verification_key']
             *                 containing key.public_key.type
             *                     indicating compressed_lsb_y_0
             *                     or indicating compressed_lsb_y_1 
             *                     or indicating x_coordinate_only
             *   }
             * }
             * </pre>
             * @see         ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_SND_CERT_10_01_BV
             * @reference   ETSI TS 103 097 [1], clause 4.2.4
             */
garciay's avatar
garciay committed
            testcase TC_SEC_ITSS_SND_CERT_10_01_BV() runs on ItsGeoNetworking system ItsSecSystem {
garciay's avatar
garciay committed
                
                // 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
                tc_ac.start;
                alt {
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mdw_securedMessage(
                                    superset(
                                        mw_header_field_signer_info_certificate(
                                            mw_at_certificate(
                                                ?,
                                                superset(
                                                    mw_subject_attribute_verification_key(
                                                        mw_publicKey_eccPoint_compressed_lsb_y_0
                                                    )
                                                ),
                                                ?,
                                                mw_signature
                    ))))))) {
                        tc_ac.stop;
                        log("*** " & testcasename() & ": PASS: AT certificate contains verification key with the ECC point of type set to compressed_lsb_y_0 received ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                    }
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
garciay's avatar
garciay committed
                                mdw_securedMessage(
                                    superset(
                                        mw_header_field_signer_info_certificate(
                                            mw_at_certificate(
                                                ?,
                                                superset(
                                                    mw_subject_attribute_verification_key(
                                                        mw_publicKey_eccPoint_compressed_lsb_y_1
                                                    )
                                                ),
                                                ?,
garciay's avatar
garciay committed
                                                mw_signature
garciay's avatar
garciay committed
                    ))))))) {
                        tc_ac.stop;
garciay's avatar
garciay committed
                        log("*** " & testcasename() & ": PASS: AT certificate contains verification key with the ECC point of type set to compressed_lsb_y_1 received ***");
garciay's avatar
garciay committed
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                    }
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mdw_securedMessage(
                                    superset(
                                        mw_header_field_signer_info_certificate(
                                            mw_at_certificate(
                                                ?,
                                                superset(
                                                    mw_subject_attribute_verification_key(
                                                        mw_publicKey_eccPoint_uncompressed
                                                    )
                                                ),
                                                ?,
garciay's avatar
garciay committed
                                                mw_signature
garciay's avatar
garciay committed
                    ))))))) {
                        tc_ac.stop;
garciay's avatar
garciay committed
                        log("*** " & testcasename() & ": PASS: AT certificate contains verification key with the ECC point of type set to uncompressed received ***");
garciay's avatar
garciay committed
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                    }
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mdw_securedMessage(
                                    superset(
                                        mw_header_field_signer_info_certificate(
                                            mw_at_certificate
                    )))))) {
                        tc_ac.stop;
                        log("*** " & testcasename() & ": FAIL: AT certificate signature mismatch ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                    }
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: Expected message not received ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                    }
                } // End of 'alt' statement
                
                // Postamble
                f_poNeighbour();
                f_cf01Down();
                
garciay's avatar
garciay committed
            } // End of testcase TC_SEC_ITSS_SND_CERT_10_01_BV
garciay's avatar
garciay committed
            
            /**
             * @desc    Check that  all certificate in a chain have verification keys contains ECC point of type set to either compressed_lsb_y_0, compressed_lsb_y_1 
             *          or uncompressed
             * <pre>
             * Pics Selection: PICS_GN_SECURITY
             * Config Id: CF01
             * Initial conditions:
             * with {
             *   the IUT being in the 'authorized' state
             *   the IUT being requested to include certificate in the next CAM
             * }
             * Expected Behaviour:
             * 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
             *                 indicating length N > 1
             *                 and indicating certificates[n] (0..N)
             *                     containing signature.ecdsa_signature
             *                         containing subject_attributes['verification_key']
             *                             indicating compressed_lsb_y_0
             *                             or indicating compressed_lsb_y_1 
             *                             or indicating uncompressed 
             *   }
             * }
             * </pre>
             * @see         ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_SND_CERT_10_02_BV
             * @reference   ETSI TS 103 097 [1], clause 4.2.4
             */
garciay's avatar
garciay committed
            testcase TC_SEC_ITSS_SND_CERT_10_02_BV() runs on ItsGeoNetworking system ItsSecSystem {
garciay's avatar
garciay committed
                // Local variables
                var GeoNetworkingInd v_geoNwInd;
                var SignerInfo       v_si;
                var CertificateChain v_chain;
                var integer          v_counter;
                                
                // 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
                tc_ac.start;
                alt {
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mdw_securedMessage(
                                    superset(
                                        mw_header_field_signer_info_certificate_chain
                    ))))) {
                        tc_ac.stop;
                        // Check certificate chain
                        if (f_getMsgSignerInfo(f_getSecuredMessage(v_geoNwInd.msgIn), v_si)) {
                            v_chain  :=  v_si.signerInfo.certificates;
                            for (v_counter := lengthof(v_chain) - 1; v_counter > 0; v_counter := v_counter - 1 ) {
                                if (
                                    (not match(v_chain[v_counter], mw_certificate(?, ?, superset(mw_subject_attribute_verification_key(mw_publicKey_eccPoint_compressed_lsb_y_0))))) and
                                    (not match(v_chain[v_counter], mw_certificate(?, ?, superset(mw_subject_attribute_verification_key(mw_publicKey_eccPoint_compressed_lsb_y_1))))) and
                                    (not match(v_chain[v_counter], mw_certificate(?, ?, superset(mw_subject_attribute_verification_key(mw_publicKey_eccPoint_uncompressed)))))
                                ) {
                                    log("*** " & testcasename() & ": FAIL: Wrong verification key algorithm ***");
                                    f_selfOrClientSyncAndVerdictPreamble(c_tbDone, e_error);
                                }
                            } // End of 'for' statement
                        }
                        log("*** " & testcasename() & ": PASS: All certificates in a chain have the correct verification key ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                    }
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: Expected message not received ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                    }
                } // End of 'alt' statement
                
                // Postamble
                f_poNeighbour();
                f_cf01Down();
                
garciay's avatar
garciay committed
            } // End of testcase TC_SEC_ITSS_SND_CERT_10_02_BV
garciay's avatar
garciay committed
            
            /**
             * @desc Check the certificate signature 
             * <pre>
             * Pics Selection: PICS_GN_SECURITY
             * Config Id: CF01
             * Initial conditions:
garciay's avatar
garciay committed
             * with {
             *   the IUT being in the 'authorized' state
             *   the IUT being requested to include certificate 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'
garciay's avatar
garciay committed
             *         ND containing certificate
             *           containing signer_info
garciay's avatar
garciay committed
             *             containing type
             *               indicating 'certificate_digest_with_sha256'
             *             containing digest
             *               referenced to the certificate CERT
garciay's avatar
garciay committed
             *           and containing signature
garciay's avatar
garciay committed
             *             verifiable using CERT.subject_attributes['verification_key'].key
             *   }
             * }
garciay's avatar
garciay committed
             * @see         ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_SND_CERT_09_01_BV
garciay's avatar
garciay committed
             * @reference   ETSI TS 103 097 [1], clauses 6.1 and 7.4.1
garciay's avatar
garciay committed
            testcase TC_SEC_ITSS_SND_CERT_11_01_BV() runs on ItsGeoNetworking system ItsSecSystem {
garciay's avatar
garciay committed
                // Local declarations
                var GeoNetworkingInd v_geoNwInd;
                var Certificate      v_at_cert;
                var Certificate      v_aa_cert;
                var HashedId8        v_aa_digest;
                var SignerInfo       v_si;
                var integer          v_counter;
garciay's avatar
garciay committed
                // Test control
                if (not(PICS_GN_SECURITY)) {
                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY' required for executing the TC ***");
                    stop;
                }
garciay's avatar
garciay committed
                    
                // Test component configuration
                // Test adapter configuration
                
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
garciay's avatar
garciay committed
                // Wait for the message with the certificate to get the AA cert digest.
                // Ask for the chain, containing AT and AA certificate
                // Check that the AT cert in the first message is signed with the AA cert
                log("*** " & testcasename() & ": INFO: Waiting for the message containing certificate  ***");
                tc_ac.start;
                f_waitForCertificate(v_at_cert);
                tc_ac.stop;
garciay's avatar
garciay committed
                if (true != f_getCertificateSignerInfo(v_at_cert, v_si)) {
                    log("*** " & testcasename() & ": FAIL: AT Certificate signer info is unknown ***");
                    f_selfOrClientSyncAndVerdictPreamble(c_tbDone, e_error);
garciay's avatar
garciay committed
                if (not match (v_si.type_, e_certificate_digest_with_sha256)) {
                    log("*** " & testcasename() & ": FAIL: AT Certificate is not signed well ***");
                    f_selfOrClientSyncAndVerdictPreamble(c_tbDone, e_error);
garciay's avatar
garciay committed
                v_aa_digest := v_si.signerInfo.digest;
                
                // Send a certificate request to the IUT 
                f_sendCertificateRequest(v_aa_digest, f_generateDefaultCam());
                    
                // Test Body
                tc_ac.start;
                alt {
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mdw_securedMessage(
                                    superset(
                                        mw_header_field_signer_info_certificate_chain
                    ))))) -> value v_geoNwInd {
                        var SecuredMessage v_secMsg;
                        var integer v_chainLength;
                        tc_ac.stop;
                        // Check certificate chain
                        
                        if (f_getMsgSignerInfo(f_getSecuredMessage(v_geoNwInd.msgIn), v_si)) {
                            v_chainLength := lengthof(v_si.signerInfo.certificates);
                            if (v_chainLength < 2 ) {
                                log("*** " & testcasename() & ": FAIL: Certificate chain doesn't contain the AA cert ***");
                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                            }
                            // get aa cert
                            v_aa_cert := v_si.signerInfo.certificates[v_chainLength-2];
                            if (not match (v_aa_digest, f_calculateDigestFromCertificate(v_aa_cert))) {
                                log("*** " & testcasename() & ": FAIL: AT certificate was not signed with the given AA cert ***");
                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                            }
                            
                            // Check that at cert is signed with aa cert
                            if (false == f_verifyCertificateSignatureWithIssuingCertificate(v_at_cert, v_aa_cert)) {
                                log("*** " & testcasename() & ": FAIL: AT certificate signature error ***");
                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                            }
                            
                            log("*** " & testcasename() & ": PASS: AT certificate was well signed with AA certificate ***");
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                        } else {
                            log("*** " & testcasename() & ": FAIL: The message signer info is unknown ***");
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                        }
                    }
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: Expected message not received ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                    }
                } // End of 'alt' statement
                
                // Postamble
                f_poNeighbour();
                f_cf01Down();
garciay's avatar
garciay committed
                
garciay's avatar
garciay committed
            } // End of testcase TC_SEC_ITSS_SND_CERT_11_01_BV
garciay's avatar
garciay committed
             * @desc Check the signatures of the certificates in the chain 
             * Pics Selection: PICS_GN_SECURITY
             * Config Id: CF01
             * Initial conditions:
garciay's avatar
garciay committed
             * 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
             *           containing type
             *               indicating 'certificate_chain'
             *         and containing certificates
             *             indicating length N > 1
             *             and containing certificate[0]
             *                 containing signer_info
             *                     containing type
             *                         indicating 'certificate_digest_with_sha256'
             *                     and containing digest
             *                         referenced to the trusted certificate (CERT_ROOT)
             *                 and containing signature
             *                     verifiable using CERTIFICATES[N-1].subject_attributes['verification_key'].key
             *             and containing certificates[n] (1..N)
             *                 containing signer_info {
             *                     containing type
             *                         indicating 'certificate_digest_with_sha256'
             *                     and containing digest
             *                         referenced to the certificates[n-1]
             *                 and containing signature
             *                     verifiable using certificates[n-1].subject_attributes['verification_key'].key
garciay's avatar
garciay committed
             *   }
             * }
garciay's avatar
garciay committed
             * @see         ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_SND_CERT_09_02_BV
garciay's avatar
garciay committed
             * @reference   ETSI TS 103 097 [1], clauses 6.1 and 7.4.1
garciay's avatar
garciay committed
            testcase TC_SEC_ITSS_SND_CERT_11_02_BV() runs on ItsGeoNetworking system ItsSecSystem {
garciay's avatar
garciay committed
                // Local declarations
                var GeoNetworkingInd v_geoNwInd;
                var Certificate      v_cert;
                var CertificateChain v_chain;
                var SignerInfo       v_si;
                var HashedId8        v_digest;
                var integer          v_counter;
garciay's avatar
garciay committed
                // Test control
                if (not(PICS_GN_SECURITY)) {
                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY' required for executing the TC ***");
                    stop;
                }
                
garciay's avatar
garciay committed
                // Test component configuration
                // Test adapter configuration
                
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
garciay's avatar
garciay committed
                // Wait for the message with the certificate to get the AA cert digest.
                // Ask for the chain, containing AT and AA certificate
                // Check that the AT cert in the first message is signed with the AA cert
                log("*** " & testcasename() & ": INFO: Waiting for the message containing certificate and ask for a certificate chain ***");
                tc_ac.start;
                f_askForCertificateChain(f_generateDefaultCam());
                tc_ac.stop;
                    
garciay's avatar
garciay committed
                tc_ac.start;
                alt {
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mdw_securedMessage(
                                    superset(
                                        mw_header_field_signer_info_certificate_chain
                    ))))) -> value v_geoNwInd {
                        var SecuredMessage v_secMsg;
                        var integer v_chainLength;
                        tc_ac.stop;
                        // Check certificate chain
                        if (f_getMsgSignerInfo(f_getSecuredMessage(v_geoNwInd.msgIn), v_si)) {
                            v_chain  :=  v_si.signerInfo.certificates;
                            for (v_counter := lengthof(v_chain) - 1; v_counter > 0; v_counter := v_counter - 1 ) {
                                if (not f_getCertificateSignerInfo(v_chain[v_counter], v_si)) {
                                    log("*** " & testcasename() & ": FAIL: Certificate "&int2str(v_counter) & " doesn't have a signer info ***");
                                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                                }
                                if (not match (v_si.type_, e_certificate_digest_with_sha256)) {
                                    log("*** " & testcasename() & ": FAIL: Certificate is not signed with digest ***");
                                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                                }
                                // Check that cert is signed by issuing cert
                                v_digest := f_calculateDigestFromCertificate(v_chain[v_counter - 1]);
                                if (not match (v_si.signerInfo.digest, v_digest)) {
                                    log("*** " & testcasename() & ": FAIL: Certificate chain is not valid ***");
                                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                                }
                                // Check that the signature is valid
                                if (false == f_verifyCertificateSignatureWithIssuingCertificate(v_chain[v_counter], v_chain[v_counter - 1])) {
                                    log("*** " & testcasename() & ": FAIL: AT certificate signature error ***");
                                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                                }
                            } // End of 'for' statement
                            
                            log("*** " & testcasename() & ": PASS: All certificates in the chain signed by it's issuing certs ***");
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                        } else {
                            log("*** " & testcasename() & ": FAIL: The message signer info is unknown ***");
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                        }
                    }
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: Expected message not received ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                    }
                }
                
                // Postamble
                f_poNeighbour();
                f_cf01Down();
garciay's avatar
garciay committed
                
garciay's avatar
garciay committed
            } // End of testcase TC_SEC_ITSS_SND_CERT_11_02_BV
            
            /**
             * @desc Check that the assurance level of the subordinate certificate is equal to or less than the assurance level of the issuing certificate
             * <pre>
             * Pics Selection: PICS_GN_SECURITY and PICS_CERTIFICATE_SELECTION
             * 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
             *         containing certificates
             *           indicating length N > 1
             *           and containing certificates[n](0..N)
             *             containing subject_attributes ['assurance_level']
             *               containig assurance_level
             *                 containing bits [5-7]
             *                   indicating assurance level CERT_AL
             *             and containing signer_info
             *               containing digest
             *                 referenced to the certificate
             *                   containing subject_attributes ['assurance_level']
             *                     containing assurance_level
             *                       containing bits [5-7]
             *                         indicating value <= CERT_AL
             *   }
             * }
             * </pre>
             * @see         ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_SND_CERT_12_01_BV
             * @reference   ETSI TS 103 097 [1], clause 7.4
             */
            testcase TC_SEC_ITSS_SND_CERT_12_01_BV() runs on ItsGeoNetworking system ItsSecSystem {
                var CertificateChain         v_chain;
                var Certificate              v_aa_cert, v_at_cert;
                var SubjectAttribute         v_sa;
                var SubjectAssurance         v_aa_assurance_level, v_at_assurance_level;
                
                // 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_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_assurance_level, v_sa)) {
                    log("*** " & testcasename() & ": FAIL: AA certificate does not contain its_aid_list subject attribute ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                }
                v_aa_assurance_level := v_sa.attribute.assurance_level;
                
                if (not f_getCertificateSubjectAttribute(v_at_cert, e_assurance_level, v_sa)) {
                    log("*** " & testcasename() & ": FAIL: AA certificate does not contain its_aid_list subject attribute ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                }
                v_at_assurance_level := v_sa.attribute.assurance_level;
                
                if (bit2int(v_aa_assurance_level.levels) < bit2int(v_at_assurance_level.levels)) {
                    log("*** " & testcasename() & ": FAIL: The assurence levels mismatch ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                } else {
                    log("*** " & testcasename() & ": PASS: The assurence levels match ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                }
                
                // Postamble
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_ITSS_SND_CERT_12_01_BV
garciay's avatar
garciay committed
             * @desc Sending behaviour test cases for AA certificate profil
             * @see ETSI TS 103 096-2 V1.2.2 (2016-01) Clause 5.2.7.7 AA certificate profile
             */
            group AA_Certificates {
                
                /**
garciay's avatar
garciay committed
                 * @desc Check that the subject_type of the AA certificate is set to authorization_authority
garciay's avatar
garciay committed
                 * <pre>
                 * Pics Selection: PICS_GN_SECURITY
                 * 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
garciay's avatar
garciay committed
                 *           indicating 'certificate_chain'
garciay's avatar
garciay committed
                 *         containing certificates[last-1] {
                 *           containing subject_info.subject_type
                 *             indicating 'authorization_authority' (2)
                 *         }
                 *       }
                 *   }
                 * }
                 * </pre>
                 * @see         ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_SND_CERT_AA_01_01_BV
                 * @reference   ETSI TS 103 097 [1], clause 7.4.3
                 */
garciay's avatar
garciay committed
                testcase TC_SEC_ITSS_SND_CERT_AA_01_01_BV() runs on ItsGeoNetworking system ItsSecSystem {
garciay's avatar
garciay committed
                    var CertificateChain         v_chain;
                    
                    // 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);
                    }
                    if (not match(v_chain[lengthof(v_chain) - 2], mw_aa_certificate)) {
                        log("*** " & testcasename() & ": FAIL: AA certificate not found in the chain[last-1] ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                    }
                    log("*** " & testcasename() & ": PASS: AA certificate was found in the chain ***");
                    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_AA_01_01_BV
garciay's avatar
garciay committed
                
                /**
garciay's avatar
garciay committed
                 * @desc The AA certificsate subject_name variable-length vector shall have a maximum length of 32 bytes
garciay's avatar
garciay committed
                 * <pre>
                 * Pics Selection: PICS_GN_SECURITY
                 * 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_name
                 *             indicating length <= 32 bytes
                 *   }
                 * }
                 * </pre>
                 * @see         ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_SND_CERT_AA_02_01_BV
                 * @reference   ETSI TS 103 097 [1], clause 6.2
                 */
garciay's avatar
garciay committed
                testcase TC_SEC_ITSS_SND_CERT_AA_02_01_BV() runs on ItsGeoNetworking system ItsSecSystem {
garciay's avatar
garciay committed
                    var CertificateChain         v_chain;
                    
                    // 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);
                    }
                    // Verified automatically on decoding
                    if (lengthof(v_chain[lengthof(v_chain) - 2].subject_info.subject_name) > 32 ) {
                        log("*** " & testcasename() & ": FAIL: Subject name of the AA certificate is too long ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                    }
                    log("*** " & testcasename() & ": PASS: Subject name of the AA 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_AA_02_01_BV
garciay's avatar
garciay committed
                
                /**
garciay's avatar
garciay committed
                 * @desc Check that signer_info type of AA certificates is set to 'certificate_digest_with_sha256'
garciay's avatar
garciay committed
                 * <pre>
                 * Pics Selection: PICS_GN_SECURITY
                 * 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]
                 *           containing signer_info
garciay's avatar
garciay committed
                 *             containing type
                 *               indicating 'certificate_digest_with_sha256'
                 *             containing digest
                 *   }
                 * }
                 * </pre>
garciay's avatar
garciay committed
                 * @see         ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_SND_CERT_AA_03_01_BV
                 * @reference   ETSI TS 103 097 [1], clause 7.4.4
garciay's avatar
garciay committed
                 */
garciay's avatar
garciay committed
                testcase TC_SEC_ITSS_SND_CERT_AA_03_01_BV() runs on ItsGeoNetworking system ItsSecSystem {
garciay's avatar
garciay committed
                    var CertificateChain         v_chain;
                    var Certificate              v_aa_cert;
                    
                    // 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_aa_cert := v_chain[lengthof(v_chain) - 2];
                    if (not match(v_aa_cert, mw_aa_certificate(mw_signerInfo_digest))) {
                        log("*** " & testcasename() & ": FAIL: AA certificate not signed by digest ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                    }
                    log("*** " & testcasename() & ": PASS: AA certificate is signed by digest ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                    
                    // Postamble
                    f_poNeighbour();
                    f_cf01Down();
garciay's avatar
garciay committed
                } // End of testcase TC_SEC_ITSS_SND_CERT_AA_03_01_BV
                
                // TODO Add TC_SEC_ITSS_SND_CERT_AA_04_01_BV
garciay's avatar
garciay committed
                
                /**
garciay's avatar
garciay committed
                 * @desc Check that all neccesary subject attributes are present and arranged in accesing order
garciay's avatar
garciay committed
                 * <pre>
                 * Pics Selection: PICS_GN_SECURITY
                 * 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]
                 *           containing subject_attributes [0..N]
garciay's avatar
garciay committed
                 *             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_list']
                 *   }
                 * }
                 * </pre>
                 * @see         ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_SND_CERT_AA_05_01_BV
garciay's avatar
garciay committed
                 * @reference   ETSI TS 103 097 [1], clauses 6.1, 7.4.1 and 7.4.3
garciay's avatar
garciay committed
                 */
garciay's avatar
garciay committed
                testcase TC_SEC_ITSS_SND_CERT_AA_05_01_BV() runs on ItsGeoNetworking system ItsSecSystem {
garciay's avatar
garciay committed
                    var CertificateChain         v_chain;
                    var SubjectAttributes        v_attrs;
                    
                    // 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);
                    }
                    if (not match(v_chain[lengthof(v_chain) - 2], 
                                 mw_aa_certificate(?,
                                        superset(mw_subject_attribute_verification_key,
                                                 mw_subject_attribute_assurance_level,
                                                 mw_subject_attribute_its_aid_list)))
                     ) {
                        log("*** " & testcasename() & ": FAIL: Required subject attribute of AA certificate is not found ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                    }
                    
                    v_attrs := v_chain[lengthof(v_chain) - 2].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: AA certificate subject attributes are not arranged in accening order ***");
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                        }
                    }
                    
                    log("*** " & testcasename() & ": PASS: All required AA certificate subject attributes are presents ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                    
                    // Postamble
                    f_poNeighbour();
                    f_cf01Down();
garciay's avatar
garciay committed
                } // End of testcase TC_SEC_ITSS_SND_CERT_AA_05_01_BV
garciay's avatar
garciay committed
                
                /**
garciay's avatar
garciay committed
                 * @desc Check that all AIDs containing in the its_aid_list in AA certificate are unique
garciay's avatar
garciay committed
                 *       Check that AID list contains not more then 31 items       
garciay's avatar
garciay committed
                 * <pre>
                 * Pics Selection: PICS_GN_SECURITY
                 * 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]
                 *           containing subject_attributes['its_aid_list']
                 *             containing its_aid_list[0..N]
                 *               containing no more then 31 unique item
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_AA_08_01_BV
                 * @reference   ETSI TS 103 097 [1], clauses 6.9 and 7.4.3
garciay's avatar
garciay committed
                 */
garciay's avatar
garciay committed
                testcase TC_SEC_ITSS_SND_CERT_AA_08_01_BV() runs on ItsGeoNetworking system ItsSecSystem {
garciay's avatar
garciay committed
                    var CertificateChain         v_chain;
                    var Certificate              v_aa_cert;
garciay's avatar
garciay committed
                    var SubjectAttribute         v_sa;
garciay's avatar
garciay committed
                    
                    // 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_aa_cert := v_chain[lengthof(v_chain) - 2];
garciay's avatar
garciay committed
                    if (f_getCertificateSubjectAttribute(v_aa_cert, e_its_aid_list, v_sa)) {
                        
                        if (lengthof(v_sa.attribute.its_aid_list) > 31) {
                            log("*** " & testcasename() & ": FAIL: ITS-AID list contains " & int2str(lengthof(v_sa.attribute.its_aid_list)) & " items (>31) ***");
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                        }
                        
                        for (var integer v_counter :=0; v_counter < lengthof(v_sa.attribute.its_aid_list); v_counter := v_counter + 1) {
                            for (var integer j :=0; j < lengthof(v_sa.attribute.its_aid_list); j := j + 1) {
                                if (v_counter != j and v_sa.attribute.its_aid_list[v_counter] == v_sa.attribute.its_aid_list[j]) {
                                    log("*** " & testcasename() & ": FAIL: ITS-AID " & int2str(v_sa.attribute.its_aid_list[j]) & " is duplicated in AA certificate ***");
                                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                                }
                            }
                        } // End of 'for' statement
                    } else {
                        log("*** " & testcasename() & ": FAIL: AA certificate does not contain its_aid_list subject attribute ***");
garciay's avatar
garciay committed
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                    }
                    
                    log("*** " & testcasename() & ": PASS: Time validity restriction of the AA 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_AA_08_01_BV
garciay's avatar
garciay committed
                
                /**
garciay's avatar
garciay committed
                 * @desc Check that all mandatory validity restrictions are present and arranged in ascending order
garciay's avatar
garciay committed
                 * <pre>
                 * Pics Selection: PICS_GN_SECURITY
                 * 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
                 *           containing type
                 *               indicating 'certificate_chain'
                 *           and containing certificates
                 *               containing certificates[last-1]
                 *                   containing validity_restrictions[0..N]
                 *                       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']
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_AA_10_01_BV
                 * @reference   ETSI TS 103 097 [1], clauses 6.7, 6.74 and 7.4.1
garciay's avatar
garciay committed
                 */
garciay's avatar
garciay committed
                testcase TC_SEC_ITSS_SND_CERT_AA_10_01_BV() runs on ItsGeoNetworking system ItsSecSystem {
garciay's avatar
garciay committed
                
                    // Local variables
                    var GeoNetworkingInd v_geoNwInd;
                    var HeaderFields v_headersFields;
                    var integer v_previousHeaderType;
garciay's avatar
garciay committed
                    
                    // 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
                    tc_ac.start;
garciay's avatar
garciay committed
                    alt {
                        [] geoNetworkingPort.receive(
                            mw_geoNwInd(
                                mw_geoNwSecPdu(
                                    mdw_securedMessage(
                                        superset(
                                            ?, 
                                            mw_header_field(e_generation_time), 
                                            ?
                                        )
                                    ), 
                                    ?
                        ))) -> value v_geoNwInd {
                            tc_ac.stop;
garciay's avatar
garciay committed
                        
garciay's avatar
garciay committed
                            // Process header fields manually
                            v_headersFields := valueof(v_geoNwInd.msgIn.gnPacket.securedMsg.header_fields);
                            
                            // Check that signerInfo is first header
                            if ((lengthof(v_headersFields) < 1) or not match(v_headersFields[0].type_, e_signer_info)) {
                                log("*** " & testcasename() & ": FAIL: SignerInfo is not first header");
                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                            }
                            
                            for (var integer v_counter := 1; v_counter < lengthof(v_headersFields); v_counter := v_counter + 1) {
                                // Check forbidden header
                                if (not match(v_headersFields[v_counter].type_, e_time_start_and_end)) { // FIXME To be reviewed
                                    log("*** " & testcasename() & ": FAIL: Forbidden header present");
garciay's avatar
garciay committed
                                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
garciay's avatar
garciay committed
                                } 
                                
                                if (v_counter > 1 ) {
                                    // Check that headers are ordered
                                    if (match(v_headersFields[v_counter].type_, integer:(0..v_previousHeaderType))) {
                                        // Check that header is duplicated
                                        if (match(v_headersFields[v_counter].type_, v_previousHeaderType)) {
                                            log("*** " & testcasename() & ": FAIL: multiple instances of same header");
                                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                                        }else{
                                            log("*** " & testcasename() & ": FAIL: headers not in correct order");
                                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                                        }
                                    }
garciay's avatar
garciay committed
                                }
garciay's avatar
garciay committed
                                v_previousHeaderType := enum2int(v_headersFields[v_counter].type_);
                            } // End of 'for' statement
                            
                            log("*** " & testcasename() & ": PASS: correct secured packet received");
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                        }
                        [] tc_ac.timeout {
                            log("*** " & testcasename() & ": INCONC: Expected CAM not received ***");
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                        } 
                    } // End of 'alt' statement
garciay's avatar
garciay committed
                    
                    // Postamble
                    f_poNeighbour();
                    f_cf01Down();
garciay's avatar
garciay committed
                } // End of testcase TC_SEC_ITSS_SND_CERT_AA_10_01_BV
garciay's avatar
garciay committed
                
                /**
garciay's avatar
garciay committed
                 * @desc Check that time_start_and_end is included in the AA certificate validation restrictions;
                 *       Check that end_validity is greater than start_validity
                 *       Check that validity restriction of AA certificate is inside the validity restriction of its issuing certificate
garciay's avatar
garciay committed
                 * <pre>
                 * Pics Selection: PICS_GN_SECURITY
                 * 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
                 *         containing certificates[last-1] {
                 *           containing validity_restrictions
garciay's avatar
garciay committed
                 *             containing validity_restrictions['time_start_and_end']
                 *               containing start_validity
                 *                 indicating START_AA_VALIDITY
                 *               containing end_validity
                 *                 indicating END_AA_VALIDITY >=START_AA_VALIDITY
                 *             and containing signer_info
                 *               containing digest
                 *                 referenced to the trusted certificate
                 *                   containing validity_restrictions['time_end']
                 *                     containing end_validity
                 *                       indicating value > AA_END_VALIDITY
                 *                   or containing validity_restrictions['time_start_and_end']
                 *                     containing start_validity
                 *                       indicating value <= AA_START_VALIDITY
                 *                     and containing end_validity
                 *                       indicating value > AA_END_VALIDITY
                 *                   or containing validity_restrictions['time_start_and_duration']
                 *                     containing start_validity
                 *                       indicating X_START_VALIDITY <= AA_START_VALIDITY
                 *                     and containing duration
                 *                       indicating value > AA_END_VALIDITY - X_START_VALIDITY
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_AA_11_01_BV
                 * @reference   ETSI TS 103 097 [1], clauses 7.4.4
garciay's avatar
garciay committed
                 */
garciay's avatar
garciay committed
                testcase TC_SEC_ITSS_SND_CERT_AA_11_01_BV() runs on ItsGeoNetworking system ItsSecSystem {
garciay's avatar
garciay committed
                    var CertificateChain         v_chain;
                    var Certificate              v_aa_cert;
                    var ValidityRestriction      v_vr;
                    
                    // 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_aa_cert := v_chain[lengthof(v_chain) - 2];
                    if (match (v_aa_cert.validity_restrictions, (superset(mw_validity_restriction_time_end,
                                                                          mw_validity_restriction_time_start_and_duration)))
                    ) {
                        log("*** " & testcasename() & ": FAIL: AA certificate must not contain time_end and time_start_and_duration restrictions ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                    }
                    
                    if ( true != f_getCertificateValidityRestriction(v_aa_cert, e_time_start_and_end, v_vr)) {
                        log("*** " & testcasename() & ": FAIL: AA 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 mus not be greater then end validity in the validity restrictions of AA certificate ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                    }
                    
                    log("*** " & testcasename() & ": PASS: Time validity restriction of the AA 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_AA_11_01_BV
garciay's avatar
garciay committed
                
            } // End of group AA_Certificates 
garciay's avatar
garciay committed
             * @desc Sending behaviour test cases for AT certificate profil
             * @see ETSI TS 103 096-2 V1.2.2 (2016-01) Clause 5.2.7.8 AT certificate profile
             */
            group AT_Certificates {
                
                /**
garciay's avatar
garciay committed
                 * @desc Check that the subject_type of the AT certificate is set to 'authorization_ticket'
garciay's avatar
garciay committed
                 * <pre>
                 * Pics Selection: PICS_GN_SECURITY
                 * Config Id: CF01
                 * with {
                 *   the IUT being in the 'authorized' state
                 *   the IUT being requested to include certificate 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'
garciay's avatar
garciay committed
                 *         containing certificate
garciay's avatar
garciay committed
                 *           containing subject_info.subject_type
                 *             indicating 'authorization_ticket' (1)
                 *   }
                 * }
                 * </pre>
                 * @see         ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_SND_CERT_AT_01_01_BV
                 * @reference   ETSI TS 103 097 [1], clause 7.4.1
                 */
garciay's avatar
garciay committed
                testcase TC_SEC_ITSS_SND_CERT_AT_01_01_BV() runs on ItsGeoNetworking system ItsSecSystem {
garciay's avatar
garciay committed
                    var Certificate         v_at_cert;
                    
                    // 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)) {
                        log("*** " & testcasename() & ": FAIL: Message wasn't signed by AT certificate ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                    }
                    log("*** " & testcasename() & ": PASS: AT certificate has the 'authorization_ticket' subject_type  ***");
                    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_01_01_BV
garciay's avatar
garciay committed
                
                /**
garciay's avatar
garciay committed
                 * @desc Check that the subject_name variable-length vector is empty for AT certificates
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 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'
garciay's avatar
garciay committed
                 *         containing certificates
                 *           containing subject_info.subject_name
                 *             indicating length = 0
garciay's avatar
garciay committed
                 *   }
                 * }
                 * </pre>
                 * @see         ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_SND_CERT_AT_02_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_02_01_BV() runs on ItsGeoNetworking system ItsSecSystem {
garciay's avatar
garciay committed
                    var Certificate         v_at_cert;
                    
                    // 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: 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;
garciay's avatar
garciay committed
                    if (0 != lengthof(v_at_cert.subject_info.subject_name)) {
                        log("*** " & testcasename() & ": FAIL: Subject name of the AT certificate is not empty ***");
garciay's avatar
garciay committed
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                    }
garciay's avatar
garciay committed
                    log("*** " & testcasename() & ": PASS: Subject name of the AT certificate is empty ***");
garciay's avatar
garciay committed
                    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_02_01_BV
garciay's avatar
garciay committed
                
                /**
garciay's avatar
garciay committed
                 * @desc Check that signer_info type of AT certificates is set to 'certificate_digest_with_sha256' 
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 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'
garciay's avatar
garciay committed
                 *         containing certificate
                 *           containing signer_info
                 *             containing type
                 *               indicating 'certificate_digest_with_sha256'
                 *             containing digest
garciay's avatar
garciay committed
                 *   }
                 * }
                 * </pre>
                 * @see         ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_SND_CERT_AT_03_01_BV
garciay's avatar
garciay committed
                 * @reference   ETSI TS 103 097 [1], clauses 6.1, 7.4 and 7.4.1
garciay's avatar
garciay committed
                 */
garciay's avatar
garciay committed
                testcase TC_SEC_ITSS_SND_CERT_AT_03_01_BV() runs on ItsGeoNetworking system ItsSecSystem {
garciay's avatar
garciay committed
                    var Certificate         v_at_cert;
                    
                    // 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: 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;
garciay's avatar
garciay committed
                    if (
                        not match(v_at_cert, mw_certificate(mw_signerInfo_digest))
                    ) {
                        log("*** " & testcasename() & ": FAIL: AT certificate doesn't contain a digest of issuing cert ***");
garciay's avatar
garciay committed
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                    }
garciay's avatar
garciay committed
                    log("*** " & testcasename() & ": PASS: The signer info of AT certificate is a digest ***");
garciay's avatar
garciay committed
                    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_02_03_BV
garciay's avatar
garciay committed
                
                /**
garciay's avatar
garciay committed
                 * @desc Check that all neccesary subject attributes of AT certificate are present and arranged in accesing 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
                 *   the IUT being requested to include certificate 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'
garciay's avatar
garciay committed
                 *         containing certificate
                 *           containing subject_attributes [0..N]
garciay's avatar
garciay committed
                 *             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']
                 *   }
                 * }
                 * </pre>
                 * @see         ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_SND_CERT_AT_04_01_BV
garciay's avatar
garciay committed
                 * @reference   ETSI TS 103 097 [1], clauses 7.4.1 and 7.4.2
garciay's avatar
garciay committed
                 */
garciay's avatar
garciay committed
                testcase TC_SEC_ITSS_SND_CERT_AT_04_01_BV() runs on ItsGeoNetworking system ItsSecSystem {
garciay's avatar
garciay committed
                    var Certificate         v_at_cert;
                    var SubjectAttributes   v_attrs;
                    
                    // 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: 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(
                                ?,
                                superset(
                                    mw_subject_attribute_verification_key,
                                    mw_subject_attribute_assurance_level,
                                    mw_subject_attribute_its_aid_ssp_list
                     )))) {
                        log("*** " & testcasename() & ": FAIL: Required subject attribute of AT certificate is not found ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                    }
                    
                    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) {
garciay's avatar
garciay committed
                    // 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);
                }
garciay's avatar
garciay committed
                
                // Postamble
                f_poNeighbour();
                f_cf01Down();
garciay's avatar
garciay committed
            } // End of testcase TC_SEC_ITSS_RCV_CAM_04_01_BO
            
garciay's avatar
garciay committed
             * @desc    Check that IUT discards a secured CAM if the header_fields does not contain the 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 { 
             *  when {  
garciay's avatar
garciay committed
             *      the IUT is receiving a SecuredMessage (MSG_SEC_RCV_CAM_01) 
garciay's avatar
garciay committed
             *          containing header_fields[0].type
             *              indicating 'generation_time'
garciay's avatar
garciay committed
             *          and containing header_fields[1]
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_02_BO
             * @reference    ETSI TS 103 097 [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();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
garciay's avatar
garciay committed
                v_securedGnPdu := f_prepareSecuredCam(
garciay's avatar
garciay committed
                    {
                        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) {
garciay's avatar
garciay committed
                    // 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);
garciay's avatar
garciay committed
                    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_04_02_BO
            
garciay's avatar
garciay committed
             * @desc    Check that IUT is able to receive a secured CAM if the signer_info header field is not encoded first
             * <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 header_fields[0].type
             *        indicating 'signer_info'
             *      and containing header_fields[1].type
             *        indicating 'generation_time'
             *      and containing header_fields[2].type
             *        indicating 'signer_info'
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_03_BO
             * @reference    ETSI TS 103 097 [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(
garciay's avatar
garciay committed
                    {
garciay's avatar
garciay committed
9158 9159 9160 9161 9162 9163 9164 9165 9166 9167 9168 9169 9170 9171 9172 9173 9174 9175 9176 9177 9178 9179 9180 9181 9182 9183 9184 9185 9186 9187 9188 9189 9190 9191 9192 9193 9194 9195 9196 9197 9198 9199 9200 9201 9202 9203 9204 9205 9206 9207 9208 9209 9210 9211 9212 9213 9214 9215 9216 9217 9218 9219 9220 9221 9222 9223 9224 9225 9226 9227 9228 9229 9230 9231 9232 9233 9234 9235 9236 9237 9238 9239 9240 9241 9242 9243 9244 9245 9246 9247 9248 9249 9250 9251 9252 9253 9254 9255 9256 9257 9258 9259 9260 9261 9262 9263 9264 9265 9266 9267 9268 9269 9270 9271 9272 9273 9274 9275 9276 9277 9278 9279 9280 9281 9282 9283 9284 9285 9286 9287 9288 9289 9290 9291 9292 9293 9294 9295 9296 9297 9298 9299 9300 9301 9302 9303 9304 9305 9306 9307 9308 9309 9310 9311 9312 9313 9314 9315 9316 9317 9318 9319 9320 9321 9322 9323 9324 9325 9326 9327 9328 9329 9330 9331 9332 9333 9334 9335 9336 9337 9338 9339 9340 9341 9342 9343 9344 9345 9346 9347 9348 9349 9350 9351 9352 9353 9354 9355 9356 9357 9358 9359 9360 9361 9362 9363 9364 9365 9366 9367 9368 9369 9370 9371 9372 9373 9374 9375 9376 9377 9378 9379 9380 9381 9382 9383 9384 9385 9386 9387 9388 9389 9390 9391 9392 9393 9394 9395 9396 9397 9398 9399 9400 9401 9402 9403 9404 9405 9406 9407 9408 9409 9410 9411 9412 9413 9414 9415 9416 9417 9418 9419 9420 9421 9422 9423 9424 9425 9426 9427 9428 9429 9430 9431 9432 9433 9434 9435 9436 9437 9438 9439 9440 9441 9442 9443 9444 9445 9446 9447 9448 9449 9450 9451 9452 9453 9454 9455 9456 9457 9458 9459 9460 9461 9462 9463 9464 9465 9466 9467 9468 9469 9470 9471 9472 9473 9474 9475 9476 9477 9478 9479 9480 9481 9482 9483 9484 9485 9486 9487 9488 9489 9490 9491 9492 9493 9494 9495 9496 9497 9498 9499 9500 9501 9502 9503 9504 9505 9506 9507 9508 9509 9510 9511 9512 9513 9514 9515 9516 9517 9518 9519 9520 9521 9522 9523 9524 9525 9526 9527 9528 9529 9530 9531 9532 9533 9534 9535 9536 9537 9538 9539 9540 9541 9542 9543 9544 9545 9546 9547 9548 9549 9550 9551 9552 9553 9554 9555 9556 9557 9558 9559 9560 9561 9562 9563 9564 9565 9566 9567 9568 9569 9570 9571 9572 9573 9574 9575 9576 9577 9578 9579 9580 9581 9582 9583 9584 9585 9586 9587 9588 9589 9590 9591 9592 9593 9594 9595 9596 9597 9598 9599 9600 9601 9602 9603 9604 9605 9606 9607 9608 9609 9610 9611 9612 9613 9614 9615 9616 9617 9618 9619 9620 9621 9622 9623 9624 9625 9626 9627 9628 9629 9630 9631 9632 9633 9634 9635 9636 9637 9638 9639 9640 9641 9642 9643 9644 9645 9646 9647 9648 9649 9650 9651 9652 9653 9654 9655 9656 9657 9658 9659 9660 9661 9662 9663 9664 9665 9666 9667 9668 9669 9670 9671 9672 9673 9674 9675 9676 9677 9678 9679 9680 9681 9682 9683 9684 9685 9686 9687 9688 9689 9690 9691 9692 9693 9694 9695 9696 9697 9698 9699 9700 9701 9702 9703 9704 9705 9706 9707 9708 9709 9710 9711 9712 9713 9714 9715 9716 9717 9718 9719 9720 9721 9722 9723 9724 9725 9726 9727 9728 9729 9730 9731 9732 9733 9734 9735 9736 9737 9738 9739 9740 9741 9742 9743 9744 9745 9746 9747 9748 9749 9750 9751 9752 9753 9754 9755 9756 9757 9758 9759 9760 9761 9762 9763 9764 9765 9766 9767 9768 9769 9770 9771 9772 9773 9774 9775 9776 9777 9778 9779 9780 9781 9782 9783 9784 9785 9786 9787 9788 9789 9790 9791 9792 9793 9794 9795 9796 9797 9798 9799 9800 9801 9802 9803 9804 9805 9806 9807 9808 9809 9810 9811 9812 9813 9814 9815 9816 9817 9818 9819 9820 9821 9822 9823 9824 9825 9826 9827 9828 9829 9830 9831 9832 9833 9834 9835 9836 9837 9838 9839 9840 9841 9842 9843 9844 9845 9846 9847 9848 9849 9850 9851 9852 9853 9854 9855 9856 9857 9858 9859 9860 9861 9862 9863 9864 9865 9866 9867 9868 9869 9870 9871 9872 9873 9874 9875 9876 9877 9878 9879 9880 9881 9882 9883 9884 9885 9886 9887 9888 9889 9890 9891 9892 9893 9894 9895 9896 9897 9898 9899 9900 9901 9902 9903 9904 9905 9906 9907 9908 9909 9910
                        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_EB
            
            /**
             * @desc    Check that IUT discards a secured CAM if the header_fields doesn't contain the element of header field of type: generation_time
             * <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 (MSG_SEC_RCV_CAM_01)
             *          containing header_fields[0].type
             *              indicating 'signer_info'
             *          and containing header_fields[1]
             *              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_04_BO
             * @reference    ETSI TS 103 097 [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
            
            /**
             * @desc    Check that IUT discards a secured CAM if the header_fields does not contain the header field type: generation_time
             * <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 (MSG_SEC_RCV_CAM_01) 
             *          containing header_fields[0].type
             *              indicating 'signer_info'
             *          and containing header_fields[1]
             *              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_05_BO
             * @reference    ETSI TS 103 097 [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
                
                // 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_05_BO
            
            /**
             * @desc    Check that IUT discards a secured CAM if the header_fields contain more than one element of header field of type: its_aid
             * <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 (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]
             *              containing type
             *                  indicating 'its_aid'
             *              containing its_aid
             *                  indicating 'AID_CAM'
             *          and containing header_fields[3]
             *              containing type
             *                  indicating 'its_aid'
             *              containing its_aid
             *                  indicating 'AID_DENM'
             *       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_06_BO
             * @reference    ETSI TS 103 097 [1], clause 7.1
             */
            testcase TC_SEC_ITSS_RCV_CAM_04_06_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_generation_time(1000 * f_getCurrentTime()), // In us
                        m_header_field_its_aid_CAM,
                        m_header_field_its_aid_DENM
                    }, 
                    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_06_BO
            
            /**
             * @desc    Check that IUT discards a secured CAM if the header fields are not in the ascending order according to the numbering of the enumeration
             * <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 (MSG_SEC_RCV_CAM_01)
             *          containing header_fields[0].type
             *              indicating 'signer_info'
             *          and containing header_fields[1]
             *              containing type
             *                  indicating 'its_aid'
             *              containing its_aid
             *                  indicating 'AID_CAM'
             *          and containing header_fields[2].type
             *              indicating 'generation_time'
             *       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_07_BO
             * @reference    ETSI TS 103 097 [1], clause 7.1
             */
            testcase TC_SEC_ITSS_RCV_CAM_04_07_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,
                        m_header_field_generation_time(1000 * f_getCurrentTime()) // In us
                    }, 
                    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_07_BO
            
            /**
             * @desc    Check that IUT ignores the HeaderFields generation_time_standard_deviation of received Secured CAM
             * <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 (MSG_SEC_RCV_CAM_01)
             *          containing header_fields[0].type
             *              indicating 'signer_info'
             *          and containing header_fields[1].type
             *              indicating 'generation_time'
             *                  indicating TIME_1 inside the validity period of the signer certificate
             *          and containing header_fields[2].type
             *              indicating 'generation_time_with_standard_deviation'
             *                  indicating TIME_2 inside the validity period of the signer certificate
             *          and containing header_fields[3]
             *              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_08_BO
             * @reference    ETSI TS 103 097 [1], clause 7.1
             */
            testcase TC_SEC_ITSS_RCV_CAM_04_08_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_generation_time(1000 * f_getCurrentTime()), // In us
                        m_header_field_generation_time_with_standard_deviation(
                            m_time64WithStandardDeviation(
                                1000, // In us
                                0
                        )), 
                        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_08_BO
            
            /**
             * @desc    Check that IUT ignores the HeaderFields generation_time_standard_deviation of received Secured CAM
             * <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 (MSG_SEC_RCV_CAM_01)
             *          containing header_fields[0].type
             *              indicating 'signer_info'
             *          and containing header_fields[1].type
             *              indicating 'generation_time'
             *                  indicating TIME_1 outside the validity period of the signer certificate
             *          and containing header_fields[2].type
             *              indicating 'generation_time_with_standard_deviation'
             *                  indicating TIME_2 inside the validity period of the signer certificate
             *          and containing header_fields[3]
             *              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_09_BO
             * @reference    ETSI TS 103 097 [1], clause 7.1
             */
            testcase TC_SEC_ITSS_RCV_CAM_04_09_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_generation_time(1000 * f_getCurrentTime()), // In us
                        m_header_field_generation_time_with_standard_deviation(
                            m_time64WithStandardDeviation(
                                1000 * f_getCurrentTime(), // In us
                                0
                        )), 
                        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_09_BO
            
            /**
             * @desc    Check that IUT discards the Secured CAM containing the expiry_time HeaderField
             * <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 (MSG_SEC_RCV_CAM_01)
             *          containing header_fields[0].type
             *              indicating 'signer_info'
             *          and containing header_fields[1].type
             *              indicating 'generation_time'
             *                  indicating CURRENT_TIME
             *          and containing header_fields[2]
             *              containing type
             *                  indicating 'expiration'
             *              and containing expiry_time
             *                  indicating CURRENT_TIME + 1h
             *          and containing header_fields[3]
             *              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_10_BO
             * @reference    ETSI TS 103 097 [1], clause 7.1
             */
            testcase TC_SEC_ITSS_RCV_CAM_04_10_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_generation_time(
                            1000 * f_getCurrentTime()
                        ), // In us
                        m_header_field_expiry_time(
                            f_getCurrentTime() - 3600/*1h*/
                        ), 
                        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_10_BO
            
            /**
             * @desc    Check that IUT ignores the HeaderFields generation_location of received Secured CAM
             * <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 (MSG_SEC_RCV_CAM_01)
             *          containing header_fields[0].type
             *              indicating 'signer_info'
             *              and containing signer
             *                  containing type
             *                      indicating certificate
             *                  and containing certificate (CERT_TS_AT_B)
             *                      containing validity_restrictions['region']
             *                          containing region (X_CERT_REGION)
             *          and containing header_fields[1].type
             *              indicating 'generation_time'
             *          and containing header_fields[2]
             *              containing type
             *                  indicating 'generation_location'
             *              and containing generation_location
             *                  indicating position outside of the validity restriction of X_CERT_REGION
             *          and containing header_fields[3]
             *              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_11_BO
             * @reference    ETSI TS 103 097 [1], clause 7.1
             */
            testcase TC_SEC_ITSS_RCV_CAM_04_11_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_B, 
                    {
                        m_header_field_generation_time(1000 * (f_getCurrentTime())), // In us
                        m_header_field_generation_location(
                            m_threeDLocation(
                                PX_WGSLONGITUDE,
                                PX_WGSLATITUDE,
                                int2oct(0, 2)
                            )
                        ), 
                        m_header_field_its_aid_CAM
garciay's avatar
garciay committed
                    }, 
garciay's avatar
garciay committed
                    e_certificate,
                    true
garciay's avatar
garciay committed
                ); 
                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) {
garciay's avatar
garciay committed
                    // 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);
garciay's avatar
garciay committed
                    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_04_11_BO
garciay's avatar
garciay committed
             * @desc    Check that IUT discards a secured CAM if the header_fields contains a signer of type 'self'
             * Pics Selection: PICS_GN_SECURITY
             * Config Id: CF01
             * Initial conditions:
garciay's avatar
garciay committed
             * 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'
garciay's avatar
garciay committed
             *                  containing signer.type
             *                      indicating 'self'
garciay's avatar
garciay committed
             *  } then { 
             *      the IUT discards the message 
garciay's avatar
garciay committed
             *  } 
garciay's avatar
garciay committed
             * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_RCV_CAM_05_01_BO
garciay's avatar
garciay committed
             * @reference    ETSI TS 103 097 [1], clause 7.1
garciay's avatar
garciay committed
            testcase TC_SEC_ITSS_RCV_CAM_05_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(
garciay's avatar
garciay committed
                    cc_taCert_A, 
garciay's avatar
garciay committed
                        m_header_field_signer_info(
garciay's avatar
garciay committed
                            m_signerInfo_self
                        ), 
                        m_header_field_generation_time(1000 * f_getCurrentTime()), // In us
                        m_header_field_its_aid_CAM
                    }, 
garciay's avatar
garciay committed
                    e_self,
garciay's avatar
garciay committed
                    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();
garciay's avatar
garciay committed
            } // End of testcase TC_SEC_ITSS_RCV_CAM_05_01_BO
garciay's avatar
garciay committed
             * @desc    Check that IUT discards a secured CAM if the header_fields contains a signer of type certificate_digest_with_other_algorithm
             * Pics Selection: PICS_GN_SECURITY
             * Config Id: CF01
             * Initial conditions:
garciay's avatar
garciay committed
             * with { 
             *  the IUT being in the 'authorized' state 
garciay's avatar
garciay committed
             * ensure that { 
garciay's avatar
garciay committed
             *  when { 
             *      the IUT is receiving a SecuredMessage (MSG_SEC_RCV_CAM_02) 
garciay's avatar
garciay committed
             *          containing header_fields[0].type
             *              indicating 'signer_info'
garciay's avatar
garciay committed
             *                  containing signer.type
             *                      indicating 'certificate_digest_with_other_algorithm'
garciay's avatar
garciay committed
             *  } then { 
             *      the IUT discards the message 
             *  } 
             * } 
             * </pre>
garciay's avatar
garciay committed
             * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_RCV_CAM_05_02_BO
garciay's avatar
garciay committed
             * @reference    ETSI TS 103 097 [1], clause 7.1
garciay's avatar
garciay committed
            testcase TC_SEC_ITSS_RCV_CAM_05_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();
                
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
                v_securedGnPdu := f_prepareSecuredCam(
garciay's avatar
garciay committed
                    cc_taCert_A, 
garciay's avatar
garciay committed
                        m_header_field_signer_info(
garciay's avatar
garciay committed
                            m_signerInfo_other_certificates(
                                m_certificateWithAlgo_ecdsa(
                                    PX_OTHER_CERT_DIGEST
                        ))), 
                        m_header_field_generation_time(1000 * f_getCurrentTime()), // In us
garciay's avatar
garciay committed
                        m_header_field_its_aid_CAM
garciay's avatar
garciay committed
                    e_certificate_digest_with_other_algorithm,
garciay's avatar
garciay committed
                    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();
garciay's avatar
garciay committed
            } // End of testcase TC_SEC_ITSS_RCV_CAM_05_02_BO
garciay's avatar
garciay committed
             * @desc    Check that IUT discards a secured CAM if the header_fields contains a signer of type certificate_chain and the chain is empty
             * Pics Selection: PICS_GN_SECURITY
             * Config Id: CF01
garciay's avatar
garciay committed
             * 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_02) 
garciay's avatar
garciay committed
             *          containing header_fields[0].type
             *              indicating 'signer_info'
garciay's avatar
garciay committed
             *                  containing signer.type
             *                      indicating 'certificate_chain'
             *                  and containing certificates
             *                      indicating length = 0
garciay's avatar
garciay committed
             *  } then { 
             *      the IUT discards the message 
             *  } 
             * } 
garciay's avatar
garciay committed
             *
garciay's avatar
garciay committed
             * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_RCV_CAM_05_03_BO
garciay's avatar
garciay committed
             * @reference    ETSI TS 103 097 [1], clause 7.1
garciay's avatar
garciay committed
            testcase TC_SEC_ITSS_RCV_CAM_05_03_BO() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var integer i;
                var GeoNetworkingPdu v_securedGnPdu;
                var GnRawPayload v_sentRawPayload;
                
garciay's avatar
garciay committed
                // 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();
                
                // 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(
garciay's avatar
garciay committed
                            m_signerInfo_certificates(
                                { vc_atCertificate }
garciay's avatar
garciay committed
                        )), 
                        m_header_field_generation_time(1000 * f_getCurrentTime()), // In us
                        m_header_field_its_aid_CAM
                    }, 
garciay's avatar
garciay committed
                    e_certificate_chain,
garciay's avatar
garciay committed
                    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 
garciay's avatar
garciay committed
                } // End of 'for' statement
                if (i < lengthof(vc_utInds)) {
garciay's avatar
garciay committed
                    log("*** " & testcasename() & ": FAIL: GN was transmitted to upper layer ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
garciay's avatar
garciay committed
                    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_05_03_BO
garciay's avatar
garciay committed
             * @desc    Check that IUT discards a secured CAM if the header_fields contains a signer of type certificate_chain and the chain contains only one certificate
             * Pics Selection: PICS_GN_SECURITY
             * Config Id: CF01
garciay's avatar
garciay committed
             * 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_03) 
garciay's avatar
garciay committed
             *          containing header_fields[0].type
             *              indicating 'signer_info'
garciay's avatar
garciay committed
             *                  containing signer.type
             *                      indicating 'certificate_chain'
             *                  and containing certificates
garciay's avatar
garciay committed
             *                      indicating length = 1
garciay's avatar
garciay committed
             *  } then { 
             *      the IUT discards the message 
             *  } 
             * } 
garciay's avatar
garciay committed
             *
garciay's avatar
garciay committed
             * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_RCV_CAM_05_04_BO
garciay's avatar
garciay committed
             * @reference    ETSI TS 103 097 [1], clause 7.1
garciay's avatar
garciay committed
            testcase TC_SEC_ITSS_RCV_CAM_05_04_BO() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var integer i;
                var GeoNetworkingPdu v_securedGnPdu;
                var GnRawPayload v_sentRawPayload;
                
garciay's avatar
garciay committed
                // 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();
                
                // 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(
garciay's avatar
garciay committed
                            m_signerInfo_certificates(
                                { }
garciay's avatar
garciay committed
                        )), 
                        m_header_field_generation_time(1000 * f_getCurrentTime()), // In us
                        m_header_field_its_aid_CAM
                    }, 
garciay's avatar
garciay committed
                    e_certificate_chain,
garciay's avatar
garciay committed
                    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 
garciay's avatar
garciay committed
                } // End of 'for' statement
                if (i < lengthof(vc_utInds)) {
garciay's avatar
garciay committed
                    log("*** " & testcasename() & ": FAIL: GN was transmitted to upper layer ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
garciay's avatar
garciay committed
                    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_05_04_BO
garciay's avatar
garciay committed
             * @desc    Check that IUT discards secured CAM when its_aid value is not AID_CAM
             * Pics Selection: PICS_GN_SECURITY
             * Config Id: CF01
garciay's avatar
garciay committed
             * 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 header_fields['its_aid'] 
             *                 indicating AID_DENM 
             *             and containing payload_field { 
             *                 containing type 
             *                     indicating 'signed' 
             *                 containing data 
             *                     containing CAM payload 
             *             } 
             *     } then { 
             *         the IUT discards the message 
             *     } 
             * } 
garciay's avatar
garciay committed
             *
             * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_RCV_CAM_07_01_BO
             * @reference    ETSI TS 103 097 [1], clause 7.1
garciay's avatar
garciay committed
            testcase TC_SEC_ITSS_RCV_CAM_07_01_BO() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var integer i;
                var GeoNetworkingPdu v_securedGnPdu;
                var GnRawPayload v_sentRawPayload;
                
garciay's avatar
garciay committed
                // 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();
                
                // 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_its_aid_DENM
                    },
                    e_certificate
                ); 
                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 
garciay's avatar
garciay committed
                } // End of 'for' statement
                if (i < lengthof(vc_utInds)) {
garciay's avatar
garciay committed
                    log("*** " & testcasename() & ": FAIL: GN was transmitted to upper layer ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
garciay's avatar
garciay committed
                    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_07_01a_EB
garciay's avatar
garciay committed
            * @desc    Check that IUT discards the Secured CAM containing empty payload of type 'signed'.
            * <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
garciay's avatar
garciay committed
            *              and containing header_fields['its_aid']
            *                  indicating 'AID_CAM'
garciay's avatar
garciay committed
            *               and containing payload_field
garciay's avatar
garciay committed
            *                   containing type
            *                       indicating 'signed'
            *                   containing data
            *                       indicating length 0
            *       } then {
            *           the IUT discards the message
            *       }
            *   }
            * </pre>
            *
            * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_RCV_CAM_09_02_BO
            * @reference    ETSI TS 103 097 [1], clause 7.1
            */
            testcase TC_SEC_ITSS_RCV_CAM_09_02_BO() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var integer i;
                var GeoNetworkingPdu v_securedGnPdu;
garciay's avatar
garciay committed
                var GnNonSecuredPacket v_gnNonSecuredPacket;
                var octetstring v_gnPayload;
                var template (value) SecuredMessage v_securedMessage;
                var GnRawPayload v_sentRawPayload;
                
garciay's avatar
garciay committed
                // 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();
                
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
garciay's avatar
garciay committed
                v_gnNonSecuredPacket := valueof(m_geoNwShbPacket(f_getPosition(c_compNodeC)));
                v_gnNonSecuredPacket.payload := valueof(
                    f_adaptPayload_m(
                        bit2oct(
                            encvalue(
                                m_camReq(
                                    m_camMsg_vehicle_HF_BV(
                                        f_getTsStationId(),
                                        f_getCurrentTime() mod 65536, // See ETSI EN 302 637-2 V1.3.0 - Clause B.3 generationDelatTime
                                        LibItsCam_Templates.m_tsPosition
                ))))));
                v_gnPayload := bit2oct(encvalue(v_gnNonSecuredPacket));
                f_buildGnSecuredCam(
                    v_securedMessage,
                    m_payload_signed(
                        ''O
                    )
                );
                v_securedGnPdu := valueof(m_geoNwSecPdu(v_gnNonSecuredPacket, v_securedMessage));
                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
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);
                }
garciay's avatar
garciay committed
                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_09_02_EB
garciay's avatar
garciay committed
            * @desc    Check that IUT discards the Secured CAM containing non-empty payload of type 'unsecured'
            * <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
garciay's avatar
garciay committed
            *              and containing header_fields['its_aid']
            *                  indicating 'AID_CAM'
garciay's avatar
garciay committed
            *               and containing payload_field
garciay's avatar
garciay committed
            *                   containing type
            *                       indicating 'unsecured'
            *       } then {
            *           the IUT discards the message
            *       }
            *   }
            * </pre>
            *
            * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_RCV_CAM_09_03_BO
            * @reference    ETSI TS 103 097 [1], clause 7.1
            */
            testcase TC_SEC_ITSS_RCV_CAM_09_03_BO() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var integer i;
                var GeoNetworkingPdu v_securedGnPdu;
garciay's avatar
garciay committed
                var GnNonSecuredPacket v_gnNonSecuredPacket;
                var octetstring v_gnPayload;
                var template (value) SecuredMessage v_securedMessage;
                var GnRawPayload v_sentRawPayload;
                
garciay's avatar
garciay committed
                // 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();
                
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
garciay's avatar
garciay committed
                v_gnNonSecuredPacket := valueof(m_geoNwShbPacket(f_getPosition(c_compNodeC)));
                v_gnNonSecuredPacket.payload := valueof(
                    f_adaptPayload_m(
                        bit2oct(
                            encvalue(
                                m_camReq(
                                    m_camMsg_vehicle_HF_BV(
                                        f_getTsStationId(),
                                        f_getCurrentTime() mod 65536, // See ETSI EN 302 637-2 V1.3.0 - Clause B.3 generationDelatTime
                                        LibItsCam_Templates.m_tsPosition
                ))))));
                v_gnPayload := bit2oct(encvalue(v_gnNonSecuredPacket));
                f_buildGnSecuredCam(
                    v_securedMessage,
                    m_payload_unsecured(
                        v_gnPayload
                    )
                );
                v_securedGnPdu := valueof(m_geoNwSecPdu(v_gnNonSecuredPacket, v_securedMessage));
                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) {
garciay's avatar
garciay committed
                    // empty on purpose
                }
                if (i < lengthof(vc_utInds)) {
garciay's avatar
garciay committed
                    log("*** " & testcasename() & ": FAIL: GN was transmitted to upper layer ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
garciay's avatar
garciay committed
                    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_09_03_EB

garciay's avatar
garciay committed
            * @desc    Check that IUT discards the Secured CAM containing non-empty payload of type 'encrypted'
            * <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
garciay's avatar
garciay committed
            *              and containing header_fields['its_aid']
            *                  indicating 'AID_CAM'
garciay's avatar
garciay committed
            *               and containing payload_field
garciay's avatar
garciay committed
            *                   containing type
            *                       indicating 'encrypted'
            *       } then {
            *           the IUT discards the message
            *       }
            *   }
            * </pre>
            *
            * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_RCV_CAM_09_04_BO
            * @reference    ETSI TS 103 097 [1], clause 7.1
            */
            testcase TC_SEC_ITSS_RCV_CAM_09_04_BO() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var integer i;
                var GeoNetworkingPdu v_securedGnPdu;
garciay's avatar
garciay committed
                var GnNonSecuredPacket v_gnNonSecuredPacket;
                var octetstring v_gnPayload;
                var template (value) SecuredMessage v_securedMessage;
                var GnRawPayload v_sentRawPayload;
                
garciay's avatar
garciay committed
                // 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();
                
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
garciay's avatar
garciay committed
                v_gnNonSecuredPacket := valueof(m_geoNwShbPacket(f_getPosition(c_compNodeC)));
                v_gnNonSecuredPacket.payload := valueof(
                    f_adaptPayload_m(
                        bit2oct(
                            encvalue(
                                m_camReq(
                                    m_camMsg_vehicle_HF_BV(
                                        f_getTsStationId(),
                                        f_getCurrentTime() mod 65536, // See ETSI EN 302 637-2 V1.3.0 - Clause B.3 generationDelatTime
                                        LibItsCam_Templates.m_tsPosition
                ))))));
                v_gnPayload := bit2oct(encvalue(v_gnNonSecuredPacket));
                f_buildGnSecuredCam(
                    v_securedMessage,
                    m_payload_encrypted(
                        v_gnPayload
                    )
                );
                v_securedGnPdu := valueof(m_geoNwSecPdu(v_gnNonSecuredPacket, v_securedMessage));
                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) {
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_09_04_EB
garciay's avatar
garciay committed
            * @desc    Check that IUT discards the Secured CAM containing exactly one non-empty payload of type 'signed_external'
            * <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
garciay's avatar
garciay committed
            *              and containing header_fields['its_aid']
            *                  indicating 'AID_CAM'
garciay's avatar
garciay committed
            *               and containing payload_field
garciay's avatar
garciay committed
            *                   containing type
            *                       indicating 'signed_external'
            *       } then {
            *           the IUT discards the message
            *       }
            *   }
            * </pre>
            *
            * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_RCV_CAM_09_05_BO
            * @reference    ETSI TS 103 097 [1], clause 7.1
            */
            testcase TC_SEC_ITSS_RCV_CAM_09_05_BO() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var integer i;
                var GeoNetworkingPdu v_securedGnPdu;
garciay's avatar
garciay committed
                var GnNonSecuredPacket v_gnNonSecuredPacket;
                var octetstring v_gnPayload;
                var template (value) SecuredMessage v_securedMessage;
                var GnRawPayload v_sentRawPayload;
                
garciay's avatar
garciay committed
                // 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();
                
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
garciay's avatar
garciay committed
                v_gnNonSecuredPacket := valueof(m_geoNwShbPacket(f_getPosition(c_compNodeC)));
                v_gnNonSecuredPacket.payload := valueof(
                    f_adaptPayload_m(
                        bit2oct(
                            encvalue(
                                m_camReq(
                                    m_camMsg_vehicle_HF_BV(
                                        f_getTsStationId(),
                                        f_getCurrentTime() mod 65536, // See ETSI EN 302 637-2 V1.3.0 - Clause B.3 generationDelatTime
                                        LibItsCam_Templates.m_tsPosition
                ))))));
                v_gnPayload := bit2oct(encvalue(v_gnNonSecuredPacket));
                f_buildGnSecuredCam(
                    v_securedMessage,
                    m_payload_signed_external(
                        v_gnPayload
                    )
                );
                v_securedGnPdu := valueof(m_geoNwSecPdu(v_gnNonSecuredPacket, v_securedMessage));
                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) {
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_09_05_EB
garciay's avatar
garciay committed
            * @desc    Check that IUT discards the Secured CAM containing non-empty payload of type 'signed_and_encrypted'
            * <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
garciay's avatar
garciay committed
            *              and containing header_fields['its_aid']
            *                  indicating 'AID_CAM'
garciay's avatar
garciay committed
            *               and containing payload_field
garciay's avatar
garciay committed
            *                   containing type
            *                       indicating 'signed_and_encrypted'
            *       } then {
            *           the IUT discards the message
            *       }
            *   }
            * </pre>
            *
            * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_RCV_CAM_09_06_BO
            * @reference    ETSI TS 103 097 [1], clause 7.1
            */
            testcase TC_SEC_ITSS_RCV_CAM_09_06_BO() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var integer i;
                var GeoNetworkingPdu v_securedGnPdu;
garciay's avatar
garciay committed
                var GnNonSecuredPacket v_gnNonSecuredPacket;
                var octetstring v_gnPayload;
                var template (value) SecuredMessage v_securedMessage;
                var GnRawPayload v_sentRawPayload;
                
garciay's avatar
garciay committed
                // 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();
                
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
garciay's avatar
garciay committed
                v_gnNonSecuredPacket := valueof(m_geoNwShbPacket(f_getPosition(c_compNodeC)));
                v_gnNonSecuredPacket.payload := valueof(
                    f_adaptPayload_m(
                        bit2oct(
                            encvalue(
                                m_camReq(
                                    m_camMsg_vehicle_HF_BV(
                                        f_getTsStationId(),
                                        f_getCurrentTime() mod 65536, // See ETSI EN 302 637-2 V1.3.0 - Clause B.3 generationDelatTime
                                        LibItsCam_Templates.m_tsPosition
                ))))));
                v_gnPayload := bit2oct(encvalue(v_gnNonSecuredPacket));
                f_buildGnSecuredCam(
                    v_securedMessage,
                    m_payload_signed_and_encrypted(
                        v_gnPayload
                    )
                );
                v_securedGnPdu := valueof(m_geoNwSecPdu(v_gnNonSecuredPacket, v_securedMessage));
                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) {
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_09_06_EB
garciay's avatar
garciay committed
            * @desc    Check that IUT discards the Secured CAM doesn't containing the TrailerField of type 'signature'
            * <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
            *                containing trailer_fields
            *                    not containing any instance of type TrailerField
garciay's avatar
garciay committed
            *                        containing type
            *                            indicating 'signature'
            *        } then {
            *            the IUT discards the message
            *        }
            *    }
            * </pre>
            *
            * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_RCV_CAM_10_01_BO
            * @reference    ETSI TS 103 097 [1], clause 7.1
            */
            testcase TC_SEC_ITSS_RCV_CAM_10_01_BO() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var integer i;
                var GeoNetworkingPdu v_securedGnPdu;
                var GnRawPayload v_sentRawPayload;
                
garciay's avatar
garciay committed
                // 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();
                
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
garciay's avatar
garciay committed
                v_securedGnPdu := f_sendSecuredCam_Bo(cc_taCert_A, -, 0); 
                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);
                }
garciay's avatar
garciay committed
                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_10_01_EB
garciay's avatar
garciay committed
            * @desc    Check that IUT discards the Secured CAM containing more then one instance of TrailerField of type 'signature'
            * <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
garciay's avatar
garciay committed
            *              and containing trailer_fields[0].type
garciay's avatar
garciay committed
            *                  containing type
            *                      indicating 'signature'
garciay's avatar
garciay committed
            *              and containing trailer_fields[1].type
garciay's avatar
garciay committed
            *                  containing type
            *                      indicating 'signature'
garciay's avatar
garciay committed
            *       } then {
            *           the IUT discards the message
            *       }
            *   }
            * </pre>
            *
            * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_RCV_CAM_10_02_BO
            * @reference    ETSI TS 103 097 [1], clause 7.1
            */
            testcase TC_SEC_ITSS_RCV_CAM_10_02_BO() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var integer i;
                var GeoNetworkingPdu v_securedGnPdu;
                var GnRawPayload v_sentRawPayload;
                
garciay's avatar
garciay committed
                // 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();
                
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
garciay's avatar
garciay committed
                v_securedGnPdu := f_sendSecuredCam_Bo(cc_taCert_A, -, 2); 
                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 {
garciay's avatar
garciay committed
                    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_10_02_EB

garciay's avatar
garciay committed
            * @desc    Check that the IUT discards Secured message containing signature that is not verified using the 
garciay's avatar
garciay committed
            *          verification key from the certificate contained in the message's signer info
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 {
garciay's avatar
garciay committed
            *           the IUT is receiving a SecuredMessage (MSG_SEC_RCV_CAM_01)
            *               containing header_fields ['signer_info']
            *                   containing certificate
            *                       containing subject_attributes['verification key'] (KEY)
            *               and containing trailer_fields[0]
            *                   containing type
            *                       indicating 'signature'
            *                   and containing signature
            *                       NOT verifiable using KEY
garciay's avatar
garciay committed
            *       } then {
            *           the IUT discards the message
            *       }
            *   }
            * </pre>
            *
            * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_RCV_CAM_11_01_BO
            * @reference    ETSI TS 103 097 [1], clause 7.1
            */
            testcase TC_SEC_ITSS_RCV_CAM_11_01_BO() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var integer i;
                var GeoNetworkingPdu v_securedGnPdu;
                var GnRawPayload v_sentRawPayload;
                
garciay's avatar
garciay committed
                // 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();
                
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
garciay's avatar
garciay committed
                v_securedGnPdu := f_prepareSecuredCam_Bo(
                    cc_taCert_A, 
                    -, 
                    1, 
                    -, 
                    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_error);
                }
                else {
                    log("*** " & testcasename() & ": FAIL: 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_11_01_EB
            
            /**
            * @desc    Check that the IUT discards Secured message containing signature that is not verified using the 
            *          verification key from the certificate, referenced by the digest contained in the message's signer info
            * <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 (MSG_SEC_RCV_CAM_02)
            *               containing header_fields ['signer_info'].signer {
            *                   containing digest
            *                       referencing to the certificate (CERT_TS_AT_A)
            *                           containing subject_attributes['verification key'] (KEY)
            *               and containing trailer_fields[0]
            *                   containing type
            *                       indicating 'signature'
            *                   and containing signature
            *                       NOT verifiable using KEY
            *       } then {
            *           the IUT discards the message
            *       }
            *   }
            * </pre>
            *
            * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_RCV_CAM_11_02_BO
            * @reference    ETSI TS 103 097 [1], clause 7.1
            */
            testcase TC_SEC_ITSS_RCV_CAM_11_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_prepareSecuredCam(
                    cc_taCert_A, 
                    omit, 
                    e_certificate_digest_with_sha256
                );
                v_securedGnPdu.gnPacket.securedMsg.trailer_fields[0].trailerField.signature_.signature_.ecdsa_signature.s
                    := not4b(v_securedGnPdu.gnPacket.securedMsg.trailer_fields[0].trailerField.signature_.signature_.ecdsa_signature.s);
                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
                }
                if(i < lengthof(vc_utInds)) {
                    log("*** " & testcasename() & ": PASS: GN was transmitted to upper layer ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                }
                else {
                    log("*** " & testcasename() & ": FAIL: 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_11_02_EB
            
            /**
             * @desc    Check that IUT discards a Secured CAM if the signer certificate of the message contains the subject type 'enrolment_credential'
             * <pre>
             * Pics Selection: PICS_GN_SECURITY
             * Config Id: CF01
             * Initial conditions:
             * with {
             *   the IUT being in the 'authorized' state
             * Expected behaviour:
             * ensure that {
             *   when {
             *      the IUT is receiving a SecuredMessage (MSG_SEC_RCV_CAM_01)
             *          containing header_fields['signer_info']
             *              containing signer
             *                  containing type
             *                      indicating 'certificate'
             *                  containing certificate (CERT_TS_EC_A)
             *                      containing subject_info.subject_type
             *                          indicating 'enrolment_credentials'
             *   } then { 
             *      the IUT discards the message 
             *   }
             * } 
             * </pre>
             *
             * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_RCV_CAM_12_01_BO
             * @reference    ETSI TS 103 097 [1], clauses 7.1 and 7.4
             */
            testcase TC_SEC_ITSS_RCV_CAM_12_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_EC, 
                    {
                        m_header_field_generation_time(1000 * f_getCurrentTime()), // In us
                        m_header_field_its_aid_CAM
                    }, 
                    e_certificate,
                    true
                ); 
                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) {
garciay's avatar
garciay committed
                    // 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);
                }
garciay's avatar
garciay committed
                else {
garciay's avatar
garciay committed
                    log("*** " & testcasename() & ": PASS: GN was not transmitted to upper layer ***");
garciay's avatar
garciay committed
                    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_12_01_EB
            
garciay's avatar
garciay committed
            /**
garciay's avatar
garciay committed
             * @desc    Check that IUT discards a Secured CAM if the signer certificate of the message contains the subject type 'authorization_authority'
             * <pre>
             * Pics Selection: PICS_GN_SECURITY
             * Config Id: CF01
             * Initial conditions:
             * with {
             *   the IUT being in the 'authorized' state
             * Expected behaviour:
             * ensure that {
             *   when {
             *      the IUT is receiving a SecuredMessage (MSG_SEC_RCV_CAM_01)
             *          containing header_fields['signer_info']
             *              containing signer
             *                  containing type
             *                      indicating 'certificate'
             *                  containing certificate (CERT_TS_AA_A)
             *                      containing subject_info.subject_type
             *                          indicating 'authorization_authority'
             *   } then { 
             *      the IUT discards the message 
             *   }
             * } 
             * </pre>
             *
             * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_RCV_CAM_12_02_BO
             * @reference    ETSI TS 103 097 [1], clauses 7.1 and 7.4
             */
            testcase TC_SEC_ITSS_RCV_CAM_12_02_BO() runs on ItsGeoNetworking system ItsSecSystem {
garciay's avatar
garciay committed
                // Local variables
                var integer i;
                var GeoNetworkingPdu v_securedGnPdu;
                var GnRawPayload v_sentRawPayload;
garciay's avatar
garciay committed
                // Test adapter configuration
                if (not(PICS_GN_SECURITY)) {
                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY' required for executing the TC ***");
                    stop;
garciay's avatar
garciay committed
                
                //  Test component configuration
                f_cf01Up();
                
                // Test adapter configuration
                
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
                v_securedGnPdu := f_prepareSecuredCam(
garciay's avatar
garciay committed
                    cc_taCert_AA, 
                    {
                        m_header_field_generation_time(1000 * f_getCurrentTime()), // In us
                        m_header_field_its_aid_CAM
                    }, 
                    e_certificate,
                    true
                ); 
garciay's avatar
garciay committed
                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) {
garciay's avatar
garciay committed
                    // empty on purpose 
                } // End of 'for' statement
                if (i < lengthof(vc_utInds)) {
                    log("*** " & testcasename() & ": FAIL: GN was transmitted to upper layer ***");
garciay's avatar
garciay committed
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                }
                else {
garciay's avatar
garciay committed
                    log("*** " & testcasename() & ": PASS: GN was not transmitted to upper layer ***");
garciay's avatar
garciay committed
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                }
                
                // Postamble
                f_poNeighbour();
                f_cf01Down();
garciay's avatar
garciay committed
            } // End of testcase TC_SEC_ITSS_RCV_CAM_12_02_EB
garciay's avatar
garciay committed
             * @desc    Check that IUT discards a Secured CAM if the signer certificate of the message contains the subject type 'enrolment_authority'
             * Pics Selection: PICS_GN_SECURITY
             * Config Id: CF01
garciay's avatar
garciay committed
             * Initial conditions:
             * with {
             *   the IUT being in the 'authorized' state
garciay's avatar
garciay committed
             * Expected behaviour:
             * ensure that {
             *   when {
garciay's avatar
garciay committed
             *      the IUT is receiving a SecuredMessage (MSG_SEC_RCV_CAM_01)
             *          containing header_fields['signer_info']
             *              containing signer
             *                  containing type
             *                      indicating 'certificate'
             *              and certificate (CERT_TS_EA_A)
             *                  containing subject_info.subject_type
             *                      indicating 'enrolment_authority'
garciay's avatar
garciay committed
             *   } then { 
             *      the IUT discards the message 
garciay's avatar
garciay committed
             * } 
garciay's avatar
garciay committed
             *
garciay's avatar
garciay committed
             * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_RCV_CAM_12_03_BO
garciay's avatar
garciay committed
             * @reference    ETSI TS 103 097 [1], clauses 7.1 and 7.4
garciay's avatar
garciay committed
            testcase TC_SEC_ITSS_RCV_CAM_12_03_BO() runs on ItsGeoNetworking system ItsSecSystem {
garciay's avatar
garciay committed
                // 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;
                }
                
garciay's avatar
garciay committed
                //  Test component configuration
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
garciay's avatar
garciay committed
                v_securedGnPdu := f_prepareSecuredCam(
garciay's avatar
garciay committed
                    cc_taCert_EA, 
garciay's avatar
garciay committed
                    {
                        m_header_field_generation_time(1000 * f_getCurrentTime()), // In us
                        m_header_field_its_aid_CAM
                    }, 
                    e_certificate,
                    true
                ); 
                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);
                }
garciay's avatar
garciay committed
                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_12_03_EB
garciay's avatar
garciay committed
             * @desc    Check that IUT discards a Secured CAM if the signer certificate of the message contains the subject type 'root_ca'
             * Pics Selection: PICS_GN_SECURITY
             * Config Id: CF01
garciay's avatar
garciay committed
             * Initial conditions:
             * with {
             *   the IUT being in the 'authorized' state
garciay's avatar
garciay committed
             * Expected behaviour:
             * ensure that {
             *   when {
garciay's avatar
garciay committed
             *      the IUT is receiving a SecuredMessage (MSG_SEC_RCV_CAM_01)
             *          containing header_fields['signer_info']
             *              containing signer
             *                  containing type
             *                      indicating 'certificate'
             *              and certificate (CERT_TS_ROOT)
             *                  containing subject_info.subject_type
             *                      indicating 'root_ca'
garciay's avatar
garciay committed
             *   } then { 
             *      the IUT discards the message 
garciay's avatar
garciay committed
             * } 
garciay's avatar
garciay committed
             *
garciay's avatar
garciay committed
             * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_RCV_CAM_12_04_BO
garciay's avatar
garciay committed
             * @reference    ETSI TS 103 097 [1], clauses 7.1 and 7.4
garciay's avatar
garciay committed
            testcase TC_SEC_ITSS_RCV_CAM_12_04_BO() runs on ItsGeoNetworking system ItsSecSystem {
garciay's avatar
garciay committed
                // 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;
                }
                
garciay's avatar
garciay committed
                //  Test component configuration
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
garciay's avatar
garciay committed
                v_securedGnPdu := f_prepareSecuredCam(
garciay's avatar
garciay committed
                    cc_taCert_CA, 
garciay's avatar
garciay committed
                    {
                        m_header_field_generation_time(1000 * f_getCurrentTime()), // In us
                        m_header_field_its_aid_CAM
                    }, 
                    e_certificate,
                    true
                ); 
                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);
                }
garciay's avatar
garciay committed
                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_12_04_EB
garciay's avatar
garciay committed
            
        } // End of group recvCamProfile
        
        /**
garciay's avatar
garciay committed
         * @desc Receiving behaviour test cases for DENM profile
garciay's avatar
garciay committed
         * @see ETSI TS 103 096-2 V1.2.2 (2016-01) Clause 5.3.3 DENM Profile
         */
        group recvDenmProfile {
garciay's avatar
garciay committed
             * @desc    Check that IUT accepts a well-formed Secured DENM signed with the certificate without region validity restriction
             * Pics Selection: PICS_GN_SECURITY
             * Config Id: CF01
garciay's avatar
garciay committed
             * Expected behavior:
             * with {
             *   the IUT being in the 'authorized' state
garciay's avatar
garciay committed
             * }
             * ensure that {
             *   when {
             *     the IUT is receiving a SecuredMessage
             *          containing header_fields[0]
             *              containing type 
             *                  indicating 'signer_info'
             *              and containing signer {
             *                  containing type
             *                      indicating 'certificate'
             *                  and containing certificate (CERT_AT_A) {
             *                      containing subject_info.subject_type
             *                          indicating 'authorization_ticket' (2)
             *                      and containing subject_attributes['verification key'] (KEY)
             *             and not containing validity_restrictions['region']
             *                  }
             *              }
             *       and containing header_fields [1]
             *         containing type 
             *           indicating 'generation_time'
             *              containing generation_time
             *                  indicating CURRENT_TIME
             *       and containing header_fields [2]
             *         containing type 
             *           indicating 'generation_location'
             *              containing generation_location
             *       and containing header_fields[3]
             *         containing type 
             *           indicating 'its_aid'
             *         containing its_aid
             *              indicating 'AID_DENM'
             *          and containing payload_field {
             *              containing type
             *                  indicating 'signed'
             *              containing data
             *                  indicating length > 0
             *                  containing DENM payload
             *          }
             *          and containing trailer_fields {
             *              containing single instance of type TrailerField {
             *                  containing type
             *                      indicating 'signature'
             *                  containing signature
             *                      verifiable using KEY
             *              }
             *          }
garciay's avatar
garciay committed
             *     the IUT accepts the message
garciay's avatar
garciay committed
             * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_RCV_DENM_01_01_BV
             * @reference    ETSI TS 103 097 [1], clause 7.2
garciay's avatar
garciay committed
            testcase TC_SEC_ITSS_RCV_DENM_01_01_BV() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var integer i;
                var GeoNetworkingPdu v_securedGnPdu;
                var GnRawPayload v_sentRawPayload;
                // Test control
                if (not(PICS_GN_SECURITY)) {
                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY' required for executing the TC ***");
                    stop;
                }
                
garciay's avatar
garciay committed
                //  Test component configuration
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
garciay's avatar
garciay committed
                v_securedGnPdu := f_sendSecuredDenm(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 
garciay's avatar
garciay committed
                if (i < lengthof(vc_utInds)) {
                    log("*** " & testcasename() & ": PASS: DENM was transmitted to upper layer ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
garciay's avatar
garciay committed
                else {
                    log("*** " & testcasename() & ": FAIL: DENM 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_DENM_01_01_BV
garciay's avatar
garciay committed
             * @desc    Check that IUT accepts a well-formed Secured DENM signe with the certificate with a circular region validity restriction
             * Pics Selection: PICS_GN_SECURITY
             * Config Id: CF01
garciay's avatar
garciay committed
             * Expected behavior:
             * with {
             *   the IUT being in the 'authorized' state
garciay's avatar
garciay committed
             * }
             * ensure that {
             *   when {
             *     the IUT is receiving a SecuredMessage
             *       and containing header_fields[0]
             *              containing type 
             *                  indicating 'signer_info'
             *              and containing signer {
             *                  containing type
             *                      indicating 'certificate'
             *                  and containing certificate (CERT_AT_B) {
             *                      containing subject_info.subject_type
             *                          indicating 'authorization_ticket' (2)
             *                      and containing subject_attributes['verification key'] (KEY)
             *                      and containing validity_restrictions['region'] {
             *                          containing region{
             *                              containing region_type
             *                                  indicating 'circle'
             *                              and containing circular_region
             *                                  indicating REGION
             *                          }
             *                      }
             *                  }
             *       and containing header_fields [1]
             *         containing type 
             *           indicating 'generation_time'
             *              containing generation_time
             *                  indicating CURRENT_TIME
             *       and containing header_fields [2]
             *         containing type 
             *           indicating 'generation_location'
             *              containing generation_location
             *                  indicating position inside the REGION
             *       and containing header_fields[3]
             *         containing type 
             *           indicating 'its_aid'
             *         containing its_aid
             *              indicating 'AID_DENM'
             *       and not containing any other header_fields
             *       and containing payload_fields {
             *              containing type
             *                  indicating 'signed'
             *              containing data
             *                  indicating length > 0
             *                  containing DENM payload
             *          }
             *          and containing trailer_fields {
             *              containing single instance of type TrailerField {
             *                  containing type
             *                      indicating 'signature'
             *                  containing signature
             *                      verifiable using KEY
             *              }
             *          }
garciay's avatar
garciay committed
             *     the IUT accepts the message
garciay's avatar
garciay committed
             * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_RCV_DENM_01_02_BV
             * @reference    ETSI TS 103 097 [1], clause 7.2
garciay's avatar
garciay committed
            testcase TC_SEC_ITSS_RCV_DENM_01_02_BV() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var integer i;
                var GeoNetworkingPdu v_securedGnPdu;
                var GnRawPayload v_sentRawPayload;
                // Test control
                if (not(PICS_GN_SECURITY)) {
                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY' required for executing the TC ***");
                    stop;
                }
                
garciay's avatar
garciay committed
                //  Test component configuration
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
garciay's avatar
garciay committed
                v_securedGnPdu := f_sendSecuredDenm(cc_taCert_B, 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 
garciay's avatar
garciay committed
                if (i < lengthof(vc_utInds)) {
                    log("*** " & testcasename() & ": PASS: DENM was transmitted to upper layer ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
garciay's avatar
garciay committed
                else {
                    log("*** " & testcasename() & ": FAIL: DENM 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_DENM_01_02_BV
garciay's avatar
garciay committed
             * @desc    Check that IUT accepts a well-formed Secured DENM signe with the certificate with a rectangular region validity restriction
             * Pics Selection: PICS_GN_SECURITY
             * Config Id: CF01
garciay's avatar
garciay committed
             * Expected Behavior:
             * with {
             *   the IUT being in the 'authorized' state
garciay's avatar
garciay committed
             * }
             * 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_AT_C) {
             *                      containing subject_info.subject_type
             *                          indicating 'authorization_ticket' (2)
             *                      and containing subject_attributes['verification key'] (KEY)
             *                      and containing validity_restrictions['region'] {
             *                          containing region{
             *                              containing region_type
             *                                  indicating 'rectangle'
             *                              and containing rectangular_regions
             *                                  indicating REGIONS
             *                          }
             *                      }
             *                  }
             *       and containing header_fields [1]
             *         containing type 
             *           indicating 'generation_time'
             *              containing generation_time
             *                  indicating CURRENT_TIME
             *       and containing header_fields [2]
             *         containing type 
             *           indicating 'generation_location'
             *              containing generation_location
             *           indicating position inside the REGION
             *       and containing header_fields[3]
             *         containing type 
             *           indicating 'its_aid'
             *         containing its_aid
             *              indicating 'AID_DENM'
             *       and not containing any other header_fields
             *          and containing payload_field {
             *              containing type
             *                  indicating 'signed'
             *              containing data
             *                  indicating length > 0
             *                  containing DENM payload
             *          }
             *          and containing trailer_fields {
             *              containing single instance of type TrailerField {
             *                  containing type
             *                      indicating 'signature'
             *                  containing signature
             *                      verifiable using KEY
             *              }
             *          }
garciay's avatar
garciay committed
             *     the IUT accepts the message
garciay's avatar
garciay committed
             * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_RCV_DENM_01_03_BV
             * @reference    ETSI TS 103 097 [1], clause 7.2
garciay's avatar
garciay committed
            testcase TC_SEC_ITSS_RCV_DENM_01_03_BV() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var integer i;
                var GeoNetworkingPdu v_securedGnPdu;
                var GnRawPayload v_sentRawPayload;
                // Test control
                if (not(PICS_GN_SECURITY)) {
                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY' required for executing the TC ***");
                    stop;
                }
                
garciay's avatar
garciay committed
                //  Test component configuration
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
garciay's avatar
garciay committed
                v_securedGnPdu := f_sendSecuredDenm(cc_taCert_C, 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 
garciay's avatar
garciay committed
                if (i < lengthof(vc_utInds)) {
                    log("*** " & testcasename() & ": PASS: DENM was transmitted to upper layer ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
garciay's avatar
garciay committed
                else {
                    log("*** " & testcasename() & ": FAIL: DENM 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_DENM_01_03_BV
garciay's avatar
garciay committed
             * @desc    Check that IUT accepts a well-formed Secured DENM signe with the certificate with a polygonal region validity restriction 
             * Pics Selection: PICS_GN_SECURITY
             * Config Id: CF01
garciay's avatar
garciay committed
             * Expected Behavior:
             * with {
             *   the IUT being in the 'authorized' state
garciay's avatar
garciay committed
             * }
             * 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_AT_D) {
             *                      containing subject_info.subject_type
             *                          indicating 'authorization_ticket' (2)
             *                      and containing subject_attributes['verification key'] (KEY)
             *                      and containing validity_restrictions['region'] {
             *                          containing region{
             *                              containing region_type
             *                                  indicating 'polygon'
             *                              and containing polygonal_region
             *                   indicating REGION
             *                          }
             *                      }
             *                  }
             *       and containing header_fields [1]
             *         containing type 
             *           indicating 'generation_time'
             *              containing generation_time
             *                  indicating CURRENT_TIME
             *       and containing header_fields [2]
             *         containing type 
             *           indicating 'generation_location'
             *              containing generation_location
             *           indicating position inside the REGION
             *       and containing header_fields[3]
             *         containing type 
             *           indicating 'its_aid'
             *         containing its_aid
             *              indicating 'AID_DENM'
             *       and not containing any other header_fields
             *          and containing payload_field {
             *              containing type
             *                  indicating 'signed'
             *              containing data
             *                  indicating length > 0
             *                  containing DENM payload
             *          }
             *          and containing trailer_fields {
             *              containing single instance of type TrailerField {
             *                  containing type
             *                      indicating 'signature'
             *                  containing signature
             *                      verifiable using KEY
             *              }
             *          }
garciay's avatar
garciay committed
             *     the IUT accepts the message
garciay's avatar
garciay committed
             * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_RCV_DENM_01_04_BV
             * @reference    ETSI TS 103 097 [1], clause 7.2
garciay's avatar
garciay committed
            testcase TC_SEC_ITSS_RCV_DENM_01_04_BV() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var integer i;
                var GeoNetworkingPdu v_securedGnPdu;
                var GnRawPayload v_sentRawPayload;
                // Test control
                if (not(PICS_GN_SECURITY)) {
                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY' required for executing the TC ***");
                    stop;
                }
                
garciay's avatar
garciay committed
                //  Test component configuration
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
garciay's avatar
garciay committed
                v_securedGnPdu := f_sendSecuredDenm(cc_taCert_D, 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 
garciay's avatar
garciay committed
                if (i < lengthof(vc_utInds)) {
                    log("*** " & testcasename() & ": PASS: DENM was transmitted to upper layer ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
garciay's avatar
garciay committed
                else {
                    log("*** " & testcasename() & ": FAIL: DENM 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_DENM_01_04_BV
garciay's avatar
garciay committed
             * @desc    Check that IUT accepts a well-formed Secured DENM signe with the certificate with a identified region validity restriction 
             * Pics Selection: PICS_GN_SECURITY
             * Config Id: CF01
garciay's avatar
garciay committed
             * Expected Behavior:
             * with {
             *   the IUT being in the 'authorized' state
garciay's avatar
garciay committed
             * }
             * 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_AT_E) {
             *                      containing subject_info.subject_type
             *                          indicating 'authorization_ticket' (2)
             *                      and containing subject_attributes['verification key'] (KEY)
             *                      and containing validity_restrictions['region'] {
             *                          containing region{
             *                              containing region_type
             *                                  indicating 'id_region'
             *                              and containing identified_region
             *                                  indicating REGION
             *                          }
             *                      }
             *                  }
             *       and containing header_fields [1]
             *         containing type 
             *           indicating 'generation_time'
             *              containing generation_time
             *                  indicating CURRENT_TIME
             *       and containing header_fields [2]
             *         containing type 
             *           indicating 'generation_location'
             *              containing generation_location
             *                  indicating position inside the REGION
             *       and containing header_fields[3]
             *         containing type 
             *           indicating 'its_aid'
             *         containing its_aid
             *              indicating 'AID_DENM'
             *       and not containing any other header_fields
             *          and containing payload_field {
             *              containing type
             *                  indicating 'signed'
             *              containing data
             *                  indicating length > 0
             *                  containing DENM payload
             *          }
             *          and containing trailer_fields {
             *              containing single instance of type TrailerField {
             *                  containing type
             *                      indicating 'signature'
             *                  containing signature
             *                      verifiable using KEY
             *              }
             *          }
garciay's avatar
garciay committed
             *     the IUT accepts the message
garciay's avatar
garciay committed
             * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_RCV_DENM_01_05_BV
             * @reference    ETSI TS 103 097 [1], clause 7.2
garciay's avatar
garciay committed
            testcase TC_SEC_ITSS_RCV_DENM_01_05_BV() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var integer i;
                var GeoNetworkingPdu v_securedGnPdu;
                var GnRawPayload v_sentRawPayload;
                // Test control
                if (not(PICS_GN_SECURITY)) {
                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY' required for executing the TC ***");
                    stop;
                }
                
garciay's avatar
garciay committed
                //  Test component configuration
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
garciay's avatar
garciay committed
                v_securedGnPdu := f_sendSecuredDenm(cc_taCert_D, 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 
garciay's avatar
garciay committed
                if (i < lengthof(vc_utInds)) {
                    log("*** " & testcasename() & ": PASS: DENM was transmitted to upper layer ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                }
                else {
                    log("*** " & testcasename() & ": FAIL: DENM 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_DENM_01_05_BV
garciay's avatar
garciay committed
             * @desc    Check that IUT discards a Secured DENM containing protocol version set to a value less then 2
garciay's avatar
garciay committed
             * Pics Selection: PICS_GN_SECURITY
             * Config Id: CF01
garciay's avatar
garciay committed
             * Initial conditions:
             *  with {
             *      the IUT being in the 'authorized' state
             *  }
             *  ensure that {
             *      when { 
             *          the IUT is receiving a SecuredMessage (DENM)
             *              containing protocol_version 
             *                  indicating 1
             *              containing header_fields['its_aid']
             *                  indicating 'AID_DENM'
             *      } then {
             *          the IUT discards a SecuredMessage
             *      }
             *  }
garciay's avatar
garciay committed
             *
             * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_RCV_DENM_02_01_BO
             * @reference    ETSI TS 103 097 [1], clause 5.2
garciay's avatar
garciay committed
            testcase TC_SEC_ITSS_RCV_DENM_02_01_BO() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var integer i;
                var GeoNetworkingPdu v_securedGnPdu;
                var GnRawPayload v_sentRawPayload;
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
                //  Test component configuration
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
garciay's avatar
garciay committed
                v_securedGnPdu := f_sendSecuredDenm_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 
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);
                }
garciay's avatar
garciay committed
                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_DENM_02_01_BO
garciay's avatar
garciay committed
             * @desc    Check that IUT discards a Secured DENM containing protocol version set to a value greater then 2
garciay's avatar
garciay committed
             * Pics Selection: PICS_GN_SECURITY
             * Config Id: CF01
garciay's avatar
garciay committed
             * Initial conditions:
             *  with {
             *      the IUT being in the 'authorized' state
             *  }
             *  ensure that {
             *      when { 
             *          the IUT is receiving a SecuredMessage (DENM)
             *              containing protocol_version 
             *                  indicating 3
             *              containing header_fields['its_aid']
             *                  indicating 'AID_DENM'
             *      } then {
             *          the IUT discards a SecuredMessage
             *      }
             *  }
garciay's avatar
garciay committed
             *
             * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_RCV_DENM_02_02_BO
             * @reference    ETSI TS 103 097 [1], clause 5.2
garciay's avatar
garciay committed
            testcase TC_SEC_ITSS_RCV_DENM_02_02_BO() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var integer i;
                var GeoNetworkingPdu v_securedGnPdu;
                var GnRawPayload v_sentRawPayload;
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
                //  Test component configuration
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
garciay's avatar
garciay committed
                v_securedGnPdu := f_sendSecuredDenm_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 
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);
                }
garciay's avatar
garciay committed
                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_DENM_02_02_BO
garciay's avatar
garciay committed
             * @desc  Check that IUT discards secured DENM when its_aid value is not equal to AID_DENM
garciay's avatar
garciay committed
             * Pics Selection: PICS_GN_SECURITY
             * Config Id: CF01
garciay's avatar
garciay committed
             * Initial conditions:
             *  with {
             *      the IUT being in the 'authorized' state
             *  }
             *  ensure that {
             *      when { 
             *          the IUT is receiving a SecuredMessage
             *              containing header_fields['its_aid']
             *                  indicating 'AID_CAM'
             *              and containing payload_field {
             *                  containing type    
             *                    indicating 'signed'    
             *                  containing data    
             *                    containing DENM payload    
             *              }    
             *      } then {
             *          the IUT discards the DENM
             *      }
             *  }
garciay's avatar
garciay committed
             * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_RCV_DENM_07_01_BO
             * @reference    ETSI TS 103 097 [1], clause 7.2
garciay's avatar
garciay committed
            testcase TC_SEC_ITSS_RCV_DENM_07_01_BO() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var integer i;
                var GeoNetworkingPdu v_securedGnPdu;
                var GnRawPayload v_sentRawPayload;
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
                //  Test component configuration
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
garciay's avatar
garciay committed
                v_securedGnPdu := f_prepareSecuredDenm(
                    cc_taCert_A, 
                    {
                        m_header_field_its_aid_CAM
garciay's avatar
garciay committed
                ); 
                f_sendGeoNetMessage(m_geoNwReq_linkLayerBroadcast(v_securedGnPdu));
garciay's avatar
garciay committed
                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();
garciay's avatar
garciay committed
            } // End of testcase TC_SEC_ITSS_RCV_DENM_07_01a_EB
garciay's avatar
garciay committed
             * @desc   Check that IUT discards Secured DENM if the HeaderField generation_location is outside of the circular validity region of the signing certificate
garciay's avatar
garciay committed
             * Pics Selection: PICS_GN_SECURITY
             * Config Id: CF01
garciay's avatar
garciay committed
             * Initial conditions:
             * with {
             *   the IUT being in the 'authorized' state
garciay's avatar
garciay committed
             * }
             * ensure that {
             *   when {
             *     the IUT is requested to send DENM
garciay's avatar
garciay committed
             *     the IUT is receiving a SecuredMessage {
             *          containing header_fields['signer_info'].type
             *              indicating 'certificate'
             *          and containing  header_fields ['signer_info'].certificate (CERT_AT_B)
             *              containing validity_restrictions['region'] {
             *                  containing region{
             *                      containing region_type
             *                          indicating 'circle'
             *                      and containing circular_region
             *                          indicating REGION
             *                  }
             *              }
             *          and containing header_fields ['generation_location']
             *              containing generation_location
             *                  indicating position outside the REGION
             *          and containing header_fields['its_aid']
             *              indicating 'AID_DENM'
garciay's avatar
garciay committed
             * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_RCV_DENM_08_01_BO
             * @reference    ETSI TS 103 097 [1], clause 7.2
garciay's avatar
garciay committed
            testcase TC_SEC_ITSS_RCV_DENM_08_01_BO() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var integer i;
                var GeoNetworkingPdu v_securedGnPdu;
                var GnRawPayload v_sentRawPayload;
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
                //  Test component configuration
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
garciay's avatar
garciay committed
                v_securedGnPdu := f_sendSecuredDenm(cc_taCert_B_BO, omit, e_certificate);
garciay's avatar
garciay committed
                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() & ": PASS: DENM was dropped by the IUT ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
garciay's avatar
garciay committed
                else {
                    log("*** " & testcasename() & ": FAIL: DENM was 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_DENM_08_01_BO
garciay's avatar
garciay committed
             * @desc    Check that IUT discards Secured DENM if the HeaderField generation_location is outside of the rectangilar validity region of the signing certificate
garciay's avatar
garciay committed
             * Pics Selection: PICS_GN_SECURITY
             * Config Id: CF01
garciay's avatar
garciay committed
             * Initial conditions:
             * with {
             *   the IUT being in the 'authorized' state
garciay's avatar
garciay committed
             * }
             * ensure that {
             *   when {
             *     the IUT is requested to send DENM
garciay's avatar
garciay committed
             *     the IUT is receiving a SecuredMessage {
             *          containing header_fields['signer_info'].type
             *              indicating 'certificate'
             *          and containing  header_fields ['signer_info'].certificate (CERT_AT_C)
             *              containing validity_restrictions['region'] {
             *                  containing region{
             *                      containing region_type
             *                          indicating 'rectangle'
             *                      and containing rectangular_regions
             *                          indicating REGION
             *                  }
             *              }
             *          and containing header_fields ['generation_location']
             *              containing generation_location
             *                  indicating position outside the REGION
             *          and containing header_fields['its_aid']
             *              indicating 'AID_DENM'
garciay's avatar
garciay committed
             * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_RCV_DENM_08_02_BO
             * @reference    ETSI TS 103 097 [1], clause 7.2
garciay's avatar
garciay committed
            testcase TC_SEC_ITSS_RCV_DENM_08_02_BO() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var integer i;
                var GeoNetworkingPdu v_securedGnPdu;
                var GnRawPayload v_sentRawPayload;
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
                //  Test component configuration
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
garciay's avatar
garciay committed
                v_securedGnPdu := f_sendSecuredDenm(cc_taCert_C_BO, omit, e_certificate);
garciay's avatar
garciay committed
                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() & ": PASS: DENM was dropped by the IUT ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                }
                else {
                    log("*** " & testcasename() & ": FAIL: DENM was 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_DENM_08_02_BO
garciay's avatar
garciay committed
             * @desc    Check that IUT discards Secured DENM if the HeaderField generation_location is outside of the polygonal validity region of the signing certificate    
garciay's avatar
garciay committed
             * Pics Selection: PICS_GN_SECURITY
             * Config Id: CF01
garciay's avatar
garciay committed
             * Initial conditions:
             * with {
             *   the IUT being in the 'authorized' state
garciay's avatar
garciay committed
             * }
             * ensure that {
             *   when {
             *     the IUT is requested to send DENM
garciay's avatar
garciay committed
             *     the IUT is receiving a SecuredMessage {
             *          containing header_fields['signer_info'].type
             *              indicating 'certificate'
             *          and containing  header_fields ['signer_info'].certificate (CERT_AT_D)
             *              containing validity_restrictions['region'] {
             *                  containing region{
             *                      containing region_type
             *                          indicating 'polygon'
             *                      and containing polygonal_region
             *                          indicating REGION
             *                  }
             *              }
             *          and containing header_fields ['generation_location']
             *              containing generation_location
             *                  indicating position outside the REGION
             *          and containing header_fields['its_aid']
             *              indicating 'AID_DENM'
garciay's avatar
garciay committed
             * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_RCV_DENM_08_03_BO
             * @reference    ETSI TS 103 097 [1], clause 7.2
garciay's avatar
garciay committed
            testcase TC_SEC_ITSS_RCV_DENM_08_03_BO() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var integer i;
                var GeoNetworkingPdu v_securedGnPdu;
                var GnRawPayload v_sentRawPayload;
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
                //  Test component configuration
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
garciay's avatar
garciay committed
                v_securedGnPdu := f_sendSecuredDenm(cc_taCert_D_BO, omit, e_certificate);
garciay's avatar
garciay committed
                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() & ": PASS: DENM was dropped by the IUT ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
garciay's avatar
garciay committed
                else {
                    log("*** " & testcasename() & ": FAIL: DENM was 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_DENM_08_03_BO
garciay's avatar
garciay committed
             * @desc    Check that IUT discards Secured DENM if the HeaderField generation_location is outside of the identified validity region of the signing certificate 
garciay's avatar
garciay committed
             * Pics Selection: PICS_GN_SECURITY
             * Config Id: CF01
garciay's avatar
garciay committed
             * Initial conditions:
             * with {
             *   the IUT being in the 'authorized' state
garciay's avatar
garciay committed
             * }
             * ensure that {
             *   when {
             *     the IUT is requested to send DENM
garciay's avatar
garciay committed
             *     the IUT is receiving a SecuredMessage {
             *          containing header_fields['signer_info'].type
             *              indicating 'certificate'
             *          and containing  header_fields ['signer_info'].certificate (CERT_AT_E)
             *              containing validity_restrictions['region'] {
             *                  containing region{
             *                      containing region_type
             *                          indicating 'id_region'
             *                      and containing identified_region
             *                          indicating REGION
             *                  }
             *              }
             *          and containing header_fields ['generation_location']
             *              containing generation_location
             *                  indicating position outside the REGION
             *          and containing header_fields['its_aid']
             *              indicating 'AID_DENM'
garciay's avatar
garciay committed
             * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_RCV_DENM_08_04_BO
             * @reference    ETSI TS 103 097 [1], clause 7.2
garciay's avatar
garciay committed
            testcase TC_SEC_ITSS_RCV_DENM_08_04_BO() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var integer i;
                var GeoNetworkingPdu v_securedGnPdu;
                var GnRawPayload v_sentRawPayload;
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
                //  Test component configuration
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
garciay's avatar
garciay committed
                v_securedGnPdu := f_sendSecuredDenm(cc_taCert_E_BO, omit, e_certificate);
garciay's avatar
garciay committed
                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() & ": PASS: DENM was dropped by the IUT ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
garciay's avatar
garciay committed
                else {
                    log("*** " & testcasename() & ": FAIL: DENM was 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_DENM_08_04_BO
            
        } // End of group recvDenmProfile
        
        /**
         * @desc Receiving behaviour test cases for Other profile
         * @see ETSI TS 103 096-2 V1.2.2 (2016-01) Clause 5.3.4 Generic Signed Message Profile
         */
        group recvOtherProfile {
            
garciay's avatar
garciay committed
            /**
             * @desc Function used to verify the IUT has forwarded or discarded the received secured message sent by the TA
             */
garciay's avatar
garciay committed
            group commonFunctions {
                
                /**
garciay's avatar
garciay committed
                 * @desc    Behavior function for NodeD in case of forwarding is expected
                 * @see     TC_GEONW_PON_GBC_BV_01
garciay's avatar
garciay committed
                 */
                function f_TC_SEC_ITSS_RCV_GENMSG_xxx_BV_nodeD() runs on ItsGeoNetworking {
                    
                    // Local variables
garciay's avatar
garciay committed
                    var LongPosVector v_longPosVectorNodeB := f_getPosition(c_compNodeB); // Use NodeB
garciay's avatar
garciay committed
                    
                    // Preamble
                    f_prNeighbour();
                    f_selfOrClientSyncAndVerdict(c_prDone, e_success);
                    
                    // Test Body
                    tc_ac.start;
                    alt {
                        [] geoNetworkingPort.receive(
                            mw_geoNwInd(
                                mw_geoNwSecPdu(
                                    mdw_securedMessage_dummy, 
                                    mw_geoNwBroadcastPacketWithArea(
                                        mw_longPosVectorPosition_withDelta(
garciay's avatar
garciay committed
                                            v_longPosVectorNodeB
garciay's avatar
garciay committed
                                        ),
                                        ?,
                                        f_getGeoBroadcastArea(c_area1)
                        )))) {
                            tc_ac.stop;
                            log("*** " & testcasename() & ": PASS: Beacon message was forwarded ***");
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                        }
                        [] geoNetworkingPort.receive(
                            mw_geoNwInd(
                                mw_geoNwSecPdu(
                                    mdw_securedMessage_dummy
                        ))) {
                            // Do not restart tc_ac timer
                            log("*** " & testcasename() & ": INFO: Unexpected GN message ignored ***");
                            repeat;
                        }
                        [] tc_ac.timeout {
                            log("*** " & testcasename() & ": FAIL: GBC message not received ***");
                            f_selfOrClientSyncAndVerdict(c_tbDone, e_error);
                        }
                    }
                    
                    // Postamble
                    f_poNeighbour();
                    
                } // End of function f_TC_SEC_ITSS_RCV_GENMSG_xxx_BV_nodeD
                
garciay's avatar
garciay committed
                /**
                 * @desc    Behavior function for NodeD in case of forwarding is not expected
                 * @see     TC_GEONW_PON_GBC_BV_01
                 */
                function f_TC_SEC_ITSS_RCV_GENMSG_xxx_BO_nodeD() runs on ItsGeoNetworking {
                    
                    // Local variables
                    var LongPosVector v_longPosVectorIut := f_getPosition(c_compIut);
                    
                    // Preamble
                    f_prNeighbour();
                    f_selfOrClientSyncAndVerdict(c_prDone, e_success);
                    
                    // Test Body
                    tc_noac.start;
                    alt {
                        [] geoNetworkingPort.receive(
                            mw_geoNwInd(
                                mw_geoNwSecPdu(
                                    mdw_securedMessage_dummy, 
                                    mw_geoNwBroadcastPacketWithArea(
                                        mw_longPosVectorPosition_withDelta(
                                            v_longPosVectorIut
                                        ),
                                        ?,
                                        f_getGeoBroadcastArea(c_area1)
                        )))) {
                            tc_noac.stop;
                            log("*** " & testcasename() & ": FAIL: Beacon message shall ot be forwarded ***");
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                        }
                        [] geoNetworkingPort.receive(
                            mw_geoNwInd(
                                mw_geoNwSecPdu(
                                    mdw_securedMessage_dummy
                        ))) {
                            // Do not restart tc_ac timer
                            log("*** " & testcasename() & ": INFO: Unexpected GN message ignored ***");
                            repeat;
                        }
                        [] tc_noac.timeout {
                            log("*** " & testcasename() & ": PASS: Secured message was discarded ***");
                            f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
                        }
                    }
                    
                    // Postamble
                    f_poNeighbour();
                    
                } // End of function f_TC_SEC_ITSS_RCV_GENMSG_xxx_BO_nodeD
                
garciay's avatar
garciay committed
            } // End of goup commonFunctions
            
            /**
garciay's avatar
garciay committed
             * @desc    Check that IUT accepts a well-formed Secured GN Beacon signed with the certificate without region validity restriction
garciay's avatar
garciay committed
             * <pre>
garciay's avatar
garciay committed
             * Pics Selection: PICS_GN_SECURITY and PICS_GN_GBC_SRC
garciay's avatar
garciay committed
             * Config Id: CF01
             * Expected behavior:
             * with {
             *   the IUT being in the 'authorized' state
garciay's avatar
garciay committed
             *   and the IUT current time is inside the time validity period of CERT_TS_A_AT
garciay's avatar
garciay committed
             * }
             * ensure that {
             *   when {
             *     the IUT is receiving a SecuredMessage
             *          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_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 validity_restrictions['time_start_and_end']
             *                          indicating CERT_TS_AT_TIME_VALIDITY
garciay's avatar
garciay committed
             *             and not containing validity_restrictions['region']
             *       and containing header_fields [1]
             *         containing type 
             *           indicating 'generation_time'
             *              containing generation_time
             *                  indicating CURRENT_TIME
garciay's avatar
garciay committed
             *                      inside CERT_TS_AT_TIME_VALIDITY
garciay's avatar
garciay committed
             *       and containing header_fields [2]
garciay's avatar
garciay committed
             *           containing type 
             *               indicating 'generation_location'
             *                   containing generation_location
             *           and containing generation_location
garciay's avatar
garciay committed
             *       and containing header_fields[3]
garciay's avatar
garciay committed
             *           containing type 
             *               indicating 'its_aid'
             *           and containing its_aid
garciay's avatar
garciay committed
             *              indicating 'AID_BEACON'
garciay's avatar
garciay committed
             *          and containing payload_field 
             *               containing type
garciay's avatar
garciay committed
             *                  indicating 'signed'
             *              containing data
             *                  indicating length > 0
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_GENMSG_01_01_BV
             * @reference    ETSI TS 103 097 [1], clause 7.2
             */
            testcase TC_SEC_ITSS_RCV_GENMSG_01_01_BV() runs on ItsMtc system ItsSecSystem {
                
                // Local variables
                var ItsGeoNetworking v_nodeB;
                var ItsGeoNetworking v_nodeD;
                
                // Test control
garciay's avatar
garciay committed
                if (not(PICS_GN_SECURITY) or not(PICS_GN_GBC_SRC)) {
                    log("*** " & testcasename() & ": 'PICS_GN_SECURITY' and PICS_GN_GBC_SRC' required for executing the TC ***");
garciay's avatar
garciay committed
                    setverdict(inconc);
                    stop;
                }
                
                // Test component configuration
                f_cf02Up();
                
                // Preamble
                
                // Start components
                v_nodeB := f_getComponent(c_compNodeB);
                v_nodeD := f_getComponent(c_compNodeD);
garciay's avatar
garciay committed
                v_nodeB.start(f_TC_SEC_ITSS_RCV_GENMSG_01_0x_BV_nodeB(cc_taCert_A));
garciay's avatar
garciay committed
                v_nodeD.start(f_TC_SEC_ITSS_RCV_GENMSG_xxx_BV_nodeD());
                
                // Synchronization
                f_serverSync2ClientsAndStop({c_prDone, c_tbDone, c_poDone});
                
                // Cleanup
                f_cf02Down();
                
            } // End of testcase TC_SEC_ITSS_RCV_GENMSG_01_01_BV
            
garciay's avatar
garciay committed
            /**
             * @desc    Check that IUT accepts a well-formed Secured GN Beacon signed with the certificate with a circular region validity restriction
             * <pre>
             * Pics Selection: PICS_GN_SECURITY and PICS_GN_GBC_SRC
             * Config Id: CF01
             * Expected behavior:
             * with {
             *   the IUT being in the 'authorized' state
             *   and the IUT current time is inside the time validity period of CERT_TS_B_AT
             *   and the IUT current location is inside the region validity period of CERT_TS_B_AT
             * }
             * 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_B_AT)
             *                      containing subject_info.subject_type
             *                          indicating 'authorization_ticket' (2)
             *                      and containing subject_attributes['verification key'] (KEY)
             *                      and containing validity_restrictions['time_start_and_end']
             *                          indicating CERT_TS_AT_TIME_VALIDITY
             *                      and containing validity_restrictions['region']
             *                          containing region
             *                              containing region_type
             *                                  indicating 'circle'
             *                              and containing circular_region
             *                                  indicating REGION
             *       and containing header_fields [1]
             *         containing type 
             *           indicating 'generation_time'
             *              containing generation_time
             *                  indicating CURRENT_TIME
             *       and containing header_fields [2]
             *           containing type 
             *               indicating 'generation_location'
             *           and containing generation_location
             *       and containing header_fields[3]
             *           containing type 
             *               indicating 'its_aid'
             *           and containing its_aid
             *               indicating 'AID_BEACON'
             *          and containing payload_field 
             *               containing type
             *                  indicating 'signed'
             *              containing data
             *                  indicating length > 0
             *          and containing trailer_fields 
             *              containing single instance of type TrailerField 
             *                  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_GENMSG_01_02_BV
             * @reference    ETSI TS 103 097 [1], clause 7.2
             */
            testcase TC_SEC_ITSS_RCV_GENMSG_01_02_BV() runs on ItsMtc system ItsSecSystem {
garciay's avatar
garciay committed
                
garciay's avatar
garciay committed
                // Local variables
                var ItsGeoNetworking v_nodeB;
                var ItsGeoNetworking v_nodeD;
garciay's avatar
garciay committed
                
garciay's avatar
garciay committed
                // Test control
                if (not(PICS_GN_SECURITY) or not(PICS_GN_GBC_SRC)) {
                    log("*** " & testcasename() & ": 'PICS_GN_SECURITY' and PICS_GN_GBC_SRC' required for executing the TC ***");
                    setverdict(inconc);
                    stop;
                }
                
                // Test component configuration
                f_cf02Up();
                
                // Preamble
                
                // Start components
                v_nodeB := f_getComponent(c_compNodeB);
                v_nodeD := f_getComponent(c_compNodeD);
                v_nodeB.start(f_TC_SEC_ITSS_RCV_GENMSG_01_0x_BV_nodeB(cc_taCert_B));
                v_nodeD.start(f_TC_SEC_ITSS_RCV_GENMSG_xxx_BV_nodeD());
                
                // Synchronization
                f_serverSync2ClientsAndStop({c_prDone, c_tbDone, c_poDone});
                
                // Cleanup
                f_cf02Down();
                
            } // End of testcase TC_SEC_ITSS_RCV_GENMSG_01_02_BV
garciay's avatar
garciay committed
            
garciay's avatar
garciay committed
            /**
             * @desc    Check that IUT accepts a well-formed Secured GN Beacon signed with the certificate with a rectangular region validity restriction
             * <pre>
             * Pics Selection: PICS_GN_SECURITY and PICS_GN_GBC_SRC
             * Config Id: CF01
             * Expected behavior:
             * with {
             *   the IUT being in the 'authorized' state
             *   and the IUT current time is inside the time validity period of CERT_TS_C_AT
             *   and the IUT current location is inside the region validity period of CERT_TS_C_AT
             * }
             * 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_C_AT)
             *                      containing subject_info.subject_type
             *                          indicating 'authorization_ticket' (2)
             *                      and containing subject_attributes['verification key'] (KEY)
             *                      and containing validity_restrictions['time_start_and_end']
             *                          indicating CERT_TS_AT_TIME_VALIDITY
             *                      and containing validity_restrictions['region']
             *                          containing region
             *                              containing region_type
             *                                  indicating 'rectangle'
             *                              and containing rectangular_region
             *                                  indicating REGION
             *       and containing header_fields [1]
             *         containing type 
             *           indicating 'generation_time'
             *              containing generation_time
             *                  indicating CURRENT_TIME
             *       and containing header_fields [2]
             *           containing type 
             *               indicating 'generation_location'
             *           and containing generation_location
             *       and containing header_fields[3]
             *           containing type 
             *               indicating 'its_aid'
             *           and containing its_aid
             *               indicating 'AID_BEACON'
             *          and containing payload_field 
             *               containing type
             *                  indicating 'signed'
             *              containing data
             *                  indicating length > 0
             *          and containing trailer_fields 
             *              containing single instance of type TrailerField 
             *                  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_GENMSG_01_03_BV
             * @reference    ETSI TS 103 097 [1], clause 7.2
             */
            testcase TC_SEC_ITSS_RCV_GENMSG_01_03_BV() runs on ItsMtc system ItsSecSystem {
                
                // Local variables
                var ItsGeoNetworking v_nodeB;
                var ItsGeoNetworking v_nodeD;
                
                // Test control
                if (not(PICS_GN_SECURITY) or not(PICS_GN_GBC_SRC)) {
                    log("*** " & testcasename() & ": 'PICS_GN_SECURITY' and PICS_GN_GBC_SRC' required for executing the TC ***");
                    setverdict(inconc);
                    stop;
                }
                
                // Test component configuration
                f_cf02Up();
                
                // Preamble
                
                // Start components
                v_nodeB := f_getComponent(c_compNodeB);
                v_nodeD := f_getComponent(c_compNodeD);
                v_nodeB.start(f_TC_SEC_ITSS_RCV_GENMSG_01_0x_BV_nodeB(cc_taCert_C));
                v_nodeD.start(f_TC_SEC_ITSS_RCV_GENMSG_xxx_BV_nodeD());
                
                // Synchronization
                f_serverSync2ClientsAndStop({c_prDone, c_tbDone, c_poDone});
                
                // Cleanup
                f_cf02Down();
                
            } // End of testcase TC_SEC_ITSS_RCV_GENMSG_01_03_BV
garciay's avatar
garciay committed
            
garciay's avatar
garciay committed
12956 12957 12958 12959 12960 12961 12962 12963 12964 12965 12966 12967 12968 12969 12970 12971 12972 12973 12974 12975 12976 12977 12978 12979 12980 12981 12982 12983 12984 12985 12986 12987 12988 12989 12990 12991 12992 12993 12994 12995 12996 12997 12998 12999 13000 13001 13002 13003 13004 13005 13006 13007 13008 13009 13010 13011 13012 13013 13014 13015 13016 13017 13018 13019 13020 13021 13022 13023 13024 13025 13026 13027 13028 13029 13030 13031 13032 13033 13034 13035 13036 13037 13038 13039 13040 13041 13042 13043 13044 13045 13046 13047 13048 13049 13050 13051 13052 13053 13054 13055 13056 13057 13058 13059 13060 13061 13062 13063 13064 13065 13066 13067 13068 13069 13070 13071 13072 13073 13074 13075 13076 13077 13078 13079 13080 13081 13082 13083 13084 13085 13086 13087 13088 13089 13090 13091 13092 13093 13094 13095 13096 13097 13098 13099 13100 13101 13102 13103 13104 13105 13106 13107 13108 13109 13110 13111 13112 13113 13114 13115 13116 13117 13118 13119 13120 13121 13122 13123 13124 13125 13126 13127 13128 13129 13130 13131 13132 13133 13134 13135 13136 13137 13138 13139 13140 13141 13142 13143 13144 13145 13146 13147 13148 13149 13150 13151 13152 13153 13154 13155 13156 13157 13158 13159 13160 13161 13162 13163 13164 13165 13166 13167 13168 13169 13170 13171 13172 13173 13174 13175 13176 13177 13178 13179 13180 13181 13182 13183 13184 13185 13186 13187 13188 13189 13190 13191 13192 13193 13194 13195 13196 13197 13198 13199 13200 13201 13202 13203 13204 13205 13206 13207 13208 13209 13210 13211 13212 13213 13214 13215 13216 13217 13218 13219 13220 13221 13222 13223 13224 13225 13226 13227 13228 13229 13230 13231 13232 13233 13234 13235 13236 13237 13238 13239 13240 13241 13242 13243 13244 13245 13246 13247 13248 13249 13250 13251 13252 13253 13254 13255 13256 13257 13258 13259 13260 13261 13262 13263 13264 13265 13266 13267 13268 13269 13270 13271 13272 13273 13274 13275 13276 13277 13278 13279 13280 13281 13282 13283 13284 13285 13286 13287 13288 13289 13290 13291 13292 13293 13294 13295 13296 13297 13298 13299 13300 13301 13302 13303 13304 13305 13306 13307 13308 13309 13310 13311 13312 13313 13314 13315 13316 13317 13318 13319 13320 13321 13322 13323 13324 13325 13326 13327 13328 13329 13330 13331 13332 13333 13334 13335 13336 13337 13338 13339 13340 13341 13342 13343 13344 13345 13346 13347 13348 13349 13350 13351 13352 13353 13354 13355 13356 13357 13358 13359 13360 13361 13362 13363 13364 13365 13366 13367 13368 13369 13370 13371 13372 13373 13374 13375 13376 13377 13378 13379 13380 13381 13382 13383 13384 13385 13386 13387 13388 13389 13390 13391 13392 13393 13394 13395 13396 13397 13398 13399 13400 13401 13402 13403 13404 13405 13406 13407 13408 13409 13410 13411 13412 13413 13414 13415 13416 13417 13418 13419 13420 13421 13422 13423 13424 13425 13426 13427 13428 13429 13430 13431 13432 13433 13434 13435 13436 13437 13438 13439 13440 13441 13442 13443 13444 13445 13446 13447 13448 13449 13450 13451 13452 13453 13454 13455 13456 13457 13458 13459 13460 13461 13462 13463 13464 13465 13466 13467 13468 13469 13470 13471 13472 13473 13474 13475 13476 13477 13478 13479 13480 13481 13482 13483 13484 13485 13486 13487 13488 13489 13490 13491 13492 13493 13494 13495 13496 13497 13498 13499 13500 13501 13502 13503 13504 13505 13506 13507 13508 13509 13510 13511 13512 13513 13514 13515 13516 13517 13518 13519 13520 13521 13522 13523 13524 13525 13526 13527 13528 13529 13530 13531 13532 13533 13534 13535 13536 13537 13538 13539 13540 13541 13542 13543 13544 13545 13546 13547 13548 13549 13550 13551 13552 13553 13554 13555 13556 13557 13558 13559 13560 13561 13562 13563 13564 13565 13566 13567 13568 13569 13570 13571 13572 13573 13574 13575 13576 13577 13578 13579 13580 13581 13582 13583 13584 13585 13586 13587 13588 13589 13590 13591 13592 13593 13594 13595 13596 13597 13598 13599 13600 13601 13602 13603 13604 13605 13606 13607 13608 13609 13610 13611 13612 13613 13614 13615 13616 13617 13618 13619 13620 13621 13622 13623 13624 13625 13626 13627 13628 13629 13630 13631 13632 13633 13634 13635 13636 13637 13638 13639 13640 13641 13642 13643 13644 13645 13646 13647 13648 13649 13650 13651 13652 13653 13654 13655 13656 13657 13658 13659 13660 13661 13662 13663 13664 13665 13666 13667 13668 13669 13670 13671 13672 13673 13674 13675 13676 13677 13678 13679 13680 13681 13682 13683 13684 13685 13686 13687 13688 13689 13690 13691 13692 13693 13694 13695 13696 13697 13698 13699 13700 13701 13702 13703 13704 13705 13706 13707 13708 13709 13710 13711 13712 13713 13714 13715 13716 13717 13718 13719 13720 13721 13722 13723 13724 13725 13726 13727 13728 13729 13730 13731 13732 13733 13734 13735 13736 13737 13738 13739 13740 13741 13742 13743 13744 13745 13746 13747 13748 13749 13750 13751 13752 13753 13754 13755 13756 13757 13758 13759 13760 13761 13762 13763 13764 13765 13766 13767 13768 13769 13770 13771 13772 13773 13774 13775 13776 13777 13778 13779 13780 13781 13782 13783 13784 13785 13786 13787 13788 13789 13790 13791 13792 13793 13794 13795 13796 13797 13798 13799 13800 13801 13802 13803 13804 13805 13806 13807 13808 13809 13810 13811 13812 13813 13814 13815 13816 13817 13818 13819 13820 13821 13822 13823 13824 13825 13826 13827 13828 13829 13830 13831 13832 13833 13834 13835 13836 13837 13838 13839 13840 13841 13842 13843 13844 13845 13846 13847 13848 13849 13850 13851 13852 13853 13854 13855 13856 13857 13858 13859 13860 13861 13862 13863 13864 13865 13866 13867 13868 13869 13870 13871 13872 13873 13874 13875 13876 13877 13878 13879 13880 13881 13882 13883 13884 13885 13886 13887 13888 13889 13890 13891 13892 13893 13894 13895 13896 13897 13898 13899 13900 13901 13902 13903 13904 13905 13906 13907 13908 13909 13910 13911 13912 13913 13914 13915 13916 13917 13918 13919 13920 13921 13922 13923 13924 13925 13926 13927 13928 13929 13930 13931 13932 13933 13934 13935 13936 13937 13938 13939 13940 13941 13942 13943 13944 13945 13946 13947 13948 13949 13950 13951 13952 13953 13954 13955 13956 13957 13958 13959 13960 13961 13962 13963 13964 13965 13966 13967 13968 13969 13970 13971 13972 13973 13974 13975 13976 13977 13978 13979 13980 13981 13982 13983 13984 13985 13986 13987 13988 13989 13990 13991 13992 13993 13994 13995 13996 13997 13998 13999 14000 14001 14002 14003 14004 14005 14006 14007 14008 14009 14010 14011 14012 14013 14014 14015 14016 14017 14018 14019 14020 14021 14022 14023 14024 14025 14026 14027 14028 14029 14030 14031 14032 14033 14034 14035 14036 14037 14038 14039 14040 14041 14042 14043 14044 14045 14046 14047 14048 14049 14050 14051 14052 14053 14054 14055 14056 14057 14058 14059 14060 14061 14062 14063 14064 14065 14066 14067 14068 14069 14070 14071 14072 14073 14074 14075 14076 14077 14078 14079 14080 14081 14082 14083 14084 14085 14086 14087 14088 14089 14090 14091 14092 14093 14094 14095 14096 14097 14098 14099 14100 14101 14102 14103 14104 14105 14106 14107 14108 14109 14110 14111 14112 14113 14114 14115 14116 14117 14118 14119 14120 14121 14122 14123 14124 14125 14126 14127 14128 14129 14130 14131 14132 14133 14134 14135 14136 14137 14138 14139 14140 14141 14142 14143 14144 14145 14146 14147 14148 14149 14150 14151 14152 14153 14154 14155 14156 14157 14158 14159 14160 14161 14162 14163 14164 14165 14166 14167 14168 14169 14170 14171 14172 14173 14174 14175 14176 14177 14178 14179 14180 14181 14182 14183 14184 14185 14186 14187 14188 14189 14190 14191 14192 14193 14194 14195 14196 14197 14198 14199 14200 14201 14202 14203 14204 14205 14206 14207 14208 14209 14210 14211 14212 14213 14214 14215 14216 14217 14218 14219 14220 14221 14222 14223 14224 14225 14226 14227 14228 14229 14230 14231 14232 14233 14234 14235 14236 14237 14238 14239 14240 14241 14242 14243 14244 14245 14246 14247 14248 14249 14250 14251 14252 14253 14254 14255 14256 14257 14258 14259 14260 14261 14262 14263 14264 14265 14266 14267 14268 14269 14270 14271 14272 14273 14274 14275 14276 14277 14278 14279 14280 14281 14282 14283 14284 14285 14286 14287 14288 14289 14290 14291 14292 14293 14294 14295 14296 14297 14298 14299 14300 14301 14302 14303 14304 14305 14306 14307 14308 14309 14310 14311 14312 14313 14314 14315 14316 14317 14318 14319 14320 14321 14322 14323 14324 14325 14326 14327 14328 14329 14330 14331 14332 14333 14334 14335 14336 14337 14338 14339 14340 14341 14342 14343 14344 14345 14346 14347 14348 14349 14350 14351 14352 14353 14354 14355 14356 14357 14358 14359 14360 14361 14362 14363 14364 14365 14366 14367 14368 14369 14370 14371 14372 14373 14374 14375 14376 14377 14378 14379 14380 14381 14382 14383 14384 14385 14386 14387 14388 14389 14390 14391 14392 14393 14394 14395 14396 14397 14398 14399 14400 14401 14402 14403 14404 14405 14406 14407 14408 14409 14410 14411 14412 14413 14414 14415 14416 14417 14418 14419 14420 14421 14422 14423 14424 14425 14426 14427 14428 14429 14430 14431 14432 14433 14434 14435 14436 14437 14438 14439 14440 14441 14442 14443 14444 14445 14446 14447 14448 14449 14450 14451 14452 14453 14454 14455 14456 14457 14458 14459 14460 14461 14462 14463 14464 14465 14466 14467 14468 14469 14470 14471 14472 14473 14474 14475 14476 14477 14478 14479 14480 14481 14482 14483 14484 14485 14486 14487 14488 14489 14490 14491 14492 14493 14494 14495 14496 14497 14498 14499 14500 14501 14502 14503 14504 14505 14506 14507 14508 14509 14510 14511 14512 14513 14514 14515 14516 14517 14518 14519 14520 14521 14522 14523 14524 14525 14526 14527 14528 14529 14530 14531 14532 14533 14534 14535 14536 14537 14538 14539 14540 14541 14542 14543 14544 14545 14546 14547 14548 14549 14550 14551 14552 14553 14554 14555 14556 14557 14558 14559 14560 14561 14562 14563 14564 14565 14566 14567 14568 14569 14570 14571 14572 14573 14574 14575 14576 14577 14578 14579 14580 14581 14582 14583 14584 14585 14586 14587 14588 14589 14590 14591 14592 14593 14594 14595 14596 14597 14598 14599 14600 14601 14602 14603 14604 14605 14606 14607 14608 14609 14610 14611 14612 14613 14614 14615 14616 14617 14618 14619 14620 14621 14622 14623 14624 14625 14626 14627 14628 14629 14630 14631 14632 14633 14634 14635 14636 14637 14638 14639 14640 14641 14642 14643 14644 14645 14646 14647 14648 14649 14650 14651 14652 14653 14654 14655 14656 14657 14658 14659 14660 14661 14662 14663 14664 14665 14666 14667 14668 14669 14670 14671 14672 14673 14674 14675 14676 14677 14678 14679 14680 14681 14682 14683 14684 14685 14686 14687 14688 14689 14690 14691 14692 14693 14694 14695 14696 14697 14698 14699 14700 14701 14702 14703 14704 14705 14706 14707 14708 14709 14710 14711 14712 14713 14714 14715 14716 14717 14718 14719 14720 14721 14722 14723 14724 14725 14726 14727 14728 14729 14730 14731 14732 14733 14734 14735 14736 14737 14738 14739 14740 14741 14742 14743 14744 14745 14746 14747 14748 14749 14750 14751 14752 14753 14754 14755 14756 14757 14758 14759 14760 14761 14762 14763 14764 14765 14766 14767 14768 14769 14770 14771 14772 14773 14774 14775 14776 14777 14778 14779 14780 14781 14782 14783 14784 14785 14786 14787 14788 14789 14790 14791 14792 14793 14794 14795 14796 14797 14798 14799 14800 14801 14802 14803 14804 14805 14806 14807 14808 14809 14810 14811 14812 14813 14814 14815 14816 14817 14818 14819 14820 14821 14822 14823 14824 14825 14826 14827 14828 14829 14830 14831 14832 14833 14834 14835 14836 14837 14838 14839 14840 14841 14842 14843 14844 14845 14846 14847 14848 14849 14850 14851 14852 14853 14854 14855 14856 14857 14858 14859 14860 14861 14862 14863 14864 14865 14866 14867 14868 14869 14870 14871 14872 14873 14874 14875 14876 14877 14878 14879 14880 14881 14882 14883 14884 14885 14886 14887 14888 14889 14890 14891 14892 14893 14894 14895 14896 14897 14898 14899 14900 14901 14902 14903 14904 14905 14906 14907 14908 14909 14910 14911 14912 14913 14914 14915 14916 14917 14918 14919 14920 14921 14922 14923 14924 14925 14926 14927 14928 14929 14930 14931 14932 14933 14934 14935 14936 14937 14938 14939 14940 14941 14942 14943 14944 14945 14946 14947 14948 14949 14950 14951 14952 14953 14954 14955 14956 14957 14958 14959 14960 14961 14962 14963 14964 14965 14966 14967 14968 14969 14970 14971 14972 14973 14974 14975 14976 14977 14978 14979 14980 14981 14982 14983 14984 14985 14986 14987 14988 14989 14990 14991 14992 14993 14994 14995 14996 14997 14998 14999 15000 15001 15002 15003 15004 15005 15006 15007 15008 15009 15010 15011 15012 15013 15014 15015 15016 15017 15018 15019 15020 15021 15022 15023 15024 15025 15026 15027 15028 15029 15030 15031 15032 15033 15034 15035 15036 15037 15038 15039 15040 15041 15042 15043 15044 15045 15046 15047 15048 15049 15050 15051 15052 15053 15054 15055 15056 15057 15058 15059 15060 15061 15062 15063 15064 15065 15066 15067 15068 15069 15070 15071 15072 15073 15074 15075 15076 15077 15078 15079 15080 15081 15082 15083 15084 15085 15086 15087 15088 15089 15090 15091 15092 15093 15094 15095 15096 15097 15098 15099 15100 15101 15102 15103 15104 15105 15106 15107 15108 15109 15110 15111 15112 15113 15114 15115 15116 15117 15118 15119 15120 15121 15122 15123 15124 15125 15126 15127 15128 15129 15130 15131 15132 15133 15134 15135 15136 15137 15138 15139 15140 15141 15142 15143 15144 15145 15146 15147 15148 15149 15150 15151 15152 15153 15154 15155 15156 15157 15158 15159 15160 15161 15162 15163 15164 15165 15166 15167 15168 15169 15170 15171 15172 15173 15174 15175 15176 15177 15178 15179 15180 15181 15182 15183 15184 15185 15186 15187 15188 15189 15190 15191 15192 15193 15194 15195 15196 15197 15198 15199 15200 15201 15202 15203 15204 15205 15206 15207 15208 15209 15210 15211 15212 15213 15214 15215 15216 15217 15218 15219 15220 15221 15222 15223 15224 15225 15226 15227 15228 15229 15230 15231 15232 15233 15234 15235 15236 15237 15238 15239 15240 15241 15242 15243 15244 15245 15246 15247 15248 15249 15250 15251 15252 15253 15254 15255 15256 15257 15258 15259 15260 15261 15262 15263 15264 15265 15266 15267 15268 15269 15270 15271 15272 15273 15274 15275 15276 15277 15278 15279 15280 15281 15282 15283 15284 15285 15286 15287 15288 15289 15290 15291 15292 15293 15294 15295 15296 15297 15298 15299 15300 15301 15302 15303 15304 15305 15306 15307 15308 15309 15310 15311 15312 15313 15314 15315 15316 15317 15318 15319 15320 15321 15322 15323 15324 15325 15326 15327 15328 15329 15330 15331 15332 15333 15334 15335 15336 15337 15338 15339 15340 15341 15342 15343 15344 15345 15346 15347 15348 15349 15350 15351 15352 15353 15354 15355 15356 15357 15358 15359 15360 15361 15362 15363 15364 15365 15366 15367 15368 15369 15370 15371 15372 15373 15374 15375 15376 15377 15378 15379 15380 15381 15382 15383 15384 15385 15386 15387 15388 15389 15390 15391 15392 15393 15394 15395 15396 15397 15398 15399 15400 15401 15402 15403 15404 15405 15406 15407 15408 15409 15410 15411 15412 15413 15414 15415 15416 15417 15418 15419 15420 15421 15422 15423 15424 15425 15426 15427 15428 15429 15430 15431 15432 15433 15434 15435 15436 15437 15438 15439 15440 15441 15442 15443 15444 15445 15446 15447 15448 15449 15450 15451 15452 15453 15454 15455 15456 15457 15458 15459 15460 15461 15462 15463 15464 15465 15466 15467 15468 15469 15470 15471 15472 15473 15474 15475 15476 15477 15478 15479 15480 15481 15482 15483 15484 15485 15486 15487 15488 15489 15490 15491 15492 15493 15494 15495 15496 15497 15498 15499 15500 15501 15502 15503 15504 15505 15506 15507 15508 15509 15510 15511 15512 15513 15514 15515 15516 15517 15518 15519 15520 15521 15522 15523 15524 15525 15526 15527 15528 15529 15530 15531 15532 15533 15534 15535 15536 15537 15538 15539 15540 15541 15542 15543 15544 15545 15546 15547 15548 15549 15550 15551 15552 15553 15554 15555 15556 15557 15558 15559 15560 15561 15562 15563 15564 15565 15566 15567 15568 15569 15570 15571 15572 15573 15574 15575 15576 15577 15578 15579 15580 15581 15582 15583 15584 15585 15586 15587 15588 15589 15590 15591 15592 15593 15594 15595 15596 15597 15598 15599 15600 15601 15602 15603 15604 15605 15606 15607 15608 15609 15610 15611 15612 15613 15614 15615 15616 15617 15618 15619 15620 15621 15622 15623 15624 15625 15626 15627 15628 15629 15630 15631 15632 15633 15634 15635 15636 15637 15638 15639 15640 15641 15642 15643 15644 15645 15646 15647 15648 15649 15650 15651 15652 15653 15654 15655 15656 15657 15658 15659 15660 15661 15662 15663 15664 15665 15666 15667 15668 15669 15670 15671 15672 15673 15674 15675 15676 15677 15678 15679 15680 15681 15682 15683 15684 15685 15686 15687 15688 15689 15690 15691 15692 15693 15694 15695 15696 15697 15698 15699 15700 15701 15702 15703 15704 15705 15706 15707 15708 15709 15710 15711 15712 15713 15714 15715 15716 15717 15718 15719 15720 15721 15722 15723 15724 15725 15726 15727 15728 15729 15730 15731 15732 15733 15734 15735 15736 15737 15738 15739 15740 15741 15742 15743 15744 15745 15746 15747 15748 15749 15750 15751 15752 15753 15754 15755 15756 15757 15758 15759 15760 15761 15762 15763 15764 15765 15766 15767 15768 15769 15770 15771 15772 15773 15774 15775 15776 15777 15778 15779 15780 15781 15782 15783 15784 15785 15786 15787 15788 15789 15790 15791 15792 15793 15794 15795 15796 15797 15798 15799 15800 15801 15802 15803 15804 15805 15806 15807 15808 15809 15810 15811 15812 15813 15814 15815 15816 15817 15818 15819 15820 15821 15822 15823 15824 15825 15826 15827 15828 15829 15830 15831 15832 15833 15834 15835 15836 15837 15838 15839 15840 15841 15842 15843 15844 15845 15846 15847 15848 15849 15850 15851 15852 15853 15854 15855 15856 15857 15858 15859 15860 15861 15862 15863 15864 15865 15866 15867 15868 15869 15870 15871 15872 15873 15874 15875 15876 15877 15878 15879 15880 15881 15882 15883 15884 15885 15886 15887 15888 15889 15890 15891 15892 15893 15894 15895 15896 15897 15898 15899 15900 15901 15902 15903 15904 15905 15906 15907 15908 15909 15910 15911 15912 15913 15914 15915 15916 15917 15918 15919 15920 15921 15922 15923 15924 15925 15926 15927 15928 15929 15930 15931 15932 15933 15934 15935 15936 15937 15938 15939 15940 15941 15942 15943 15944 15945 15946 15947 15948 15949 15950 15951 15952 15953 15954 15955 15956 15957 15958 15959 15960 15961 15962 15963 15964 15965 15966 15967 15968 15969 15970 15971 15972 15973 15974 15975 15976 15977 15978 15979 15980 15981 15982 15983 15984 15985 15986 15987 15988 15989 15990 15991 15992 15993 15994 15995 15996 15997 15998 15999 16000 16001 16002 16003 16004 16005 16006 16007 16008 16009 16010 16011 16012 16013 16014 16015 16016 16017 16018 16019 16020 16021 16022 16023 16024 16025 16026 16027 16028 16029 16030 16031 16032 16033 16034 16035 16036 16037 16038 16039 16040 16041 16042 16043 16044 16045 16046 16047 16048 16049 16050 16051 16052 16053 16054 16055 16056 16057 16058 16059 16060 16061 16062 16063 16064 16065 16066 16067 16068 16069 16070 16071 16072 16073 16074 16075 16076 16077 16078 16079 16080 16081 16082 16083 16084 16085 16086 16087 16088 16089 16090 16091 16092 16093 16094 16095 16096 16097 16098 16099 16100 16101 16102 16103 16104 16105 16106 16107 16108 16109 16110 16111 16112 16113 16114 16115 16116 16117 16118 16119 16120 16121 16122 16123 16124 16125 16126 16127 16128 16129 16130 16131 16132 16133 16134 16135 16136 16137 16138 16139 16140 16141 16142 16143 16144 16145 16146 16147 16148 16149 16150 16151 16152 16153 16154 16155 16156 16157 16158 16159 16160 16161 16162 16163 16164 16165 16166 16167 16168 16169 16170 16171 16172 16173 16174 16175 16176 16177 16178 16179 16180 16181 16182 16183 16184 16185 16186 16187 16188 16189 16190 16191 16192 16193 16194 16195 16196 16197 16198 16199 16200 16201 16202 16203 16204 16205 16206 16207 16208 16209 16210 16211 16212 16213 16214 16215 16216 16217 16218 16219 16220 16221 16222 16223 16224 16225 16226 16227 16228 16229 16230 16231 16232 16233 16234 16235 16236 16237 16238 16239 16240 16241 16242 16243 16244 16245 16246 16247 16248 16249 16250 16251 16252 16253 16254 16255 16256 16257 16258 16259 16260 16261 16262 16263 16264 16265 16266 16267 16268 16269 16270 16271 16272 16273 16274 16275 16276 16277 16278 16279 16280 16281 16282 16283 16284 16285 16286 16287 16288 16289 16290 16291 16292 16293 16294 16295 16296 16297 16298 16299 16300 16301 16302 16303 16304 16305 16306 16307 16308 16309 16310 16311 16312 16313 16314 16315 16316 16317 16318 16319 16320 16321 16322 16323 16324 16325 16326 16327 16328 16329 16330 16331 16332 16333 16334 16335 16336 16337 16338 16339 16340 16341 16342 16343 16344 16345 16346 16347 16348 16349 16350 16351 16352 16353 16354 16355 16356 16357 16358 16359 16360 16361 16362 16363 16364 16365 16366 16367 16368 16369 16370 16371 16372 16373 16374 16375 16376 16377 16378 16379 16380 16381 16382 16383 16384 16385 16386 16387 16388 16389 16390 16391 16392 16393 16394 16395 16396 16397 16398 16399 16400 16401 16402 16403 16404 16405 16406 16407 16408 16409 16410 16411 16412 16413 16414 16415 16416 16417 16418 16419 16420 16421 16422 16423 16424 16425 16426 16427 16428 16429 16430 16431 16432 16433 16434 16435 16436 16437 16438 16439 16440 16441 16442 16443 16444 16445 16446 16447 16448 16449 16450 16451 16452 16453 16454 16455 16456 16457 16458 16459 16460 16461 16462 16463 16464 16465 16466 16467 16468 16469 16470 16471 16472 16473 16474 16475 16476 16477 16478 16479 16480 16481 16482 16483 16484 16485 16486 16487 16488 16489 16490 16491 16492 16493 16494 16495 16496 16497 16498 16499 16500 16501 16502 16503 16504 16505 16506 16507 16508 16509 16510 16511 16512 16513 16514 16515 16516 16517 16518 16519 16520 16521 16522 16523 16524 16525 16526 16527 16528 16529 16530 16531 16532 16533 16534 16535 16536 16537 16538 16539 16540 16541 16542 16543 16544 16545 16546 16547 16548 16549 16550 16551 16552 16553 16554 16555 16556 16557 16558 16559 16560 16561 16562 16563 16564 16565 16566 16567 16568 16569 16570 16571 16572 16573 16574 16575 16576 16577 16578 16579 16580 16581 16582 16583 16584 16585 16586 16587 16588 16589 16590 16591 16592 16593 16594 16595 16596 16597 16598 16599 16600 16601 16602 16603 16604 16605 16606 16607 16608 16609 16610 16611 16612 16613 16614 16615 16616 16617 16618 16619 16620 16621 16622 16623 16624 16625 16626 16627 16628 16629 16630 16631 16632 16633 16634 16635 16636 16637 16638 16639 16640 16641 16642 16643 16644 16645 16646 16647 16648 16649 16650 16651 16652 16653 16654 16655 16656 16657 16658 16659 16660 16661 16662 16663 16664 16665 16666 16667 16668 16669 16670 16671 16672 16673 16674 16675 16676 16677 16678 16679 16680 16681 16682 16683 16684 16685 16686 16687 16688 16689 16690 16691 16692 16693 16694 16695 16696 16697 16698 16699 16700 16701 16702 16703 16704 16705 16706 16707 16708 16709 16710 16711 16712 16713 16714 16715 16716 16717 16718 16719 16720 16721 16722 16723 16724 16725 16726 16727 16728 16729 16730 16731 16732 16733 16734 16735 16736 16737 16738 16739 16740 16741 16742 16743 16744 16745 16746 16747 16748 16749 16750 16751 16752 16753 16754 16755 16756 16757 16758 16759 16760 16761 16762 16763 16764 16765 16766 16767 16768 16769 16770 16771 16772 16773 16774 16775 16776 16777 16778 16779 16780 16781 16782 16783 16784 16785 16786 16787 16788 16789 16790 16791 16792 16793 16794 16795 16796 16797 16798 16799 16800 16801 16802 16803 16804 16805 16806 16807 16808 16809 16810 16811 16812 16813 16814 16815 16816 16817 16818 16819 16820 16821 16822 16823 16824 16825 16826 16827 16828 16829 16830 16831 16832 16833 16834 16835 16836 16837
            /**
             * @desc    Check that IUT accepts a well-formed Secured GN Beacon signed with the certificate with a rectangular region validity restriction
             * <pre>
             * Pics Selection: PICS_GN_SECURITY and PICS_GN_GBC_SRC
             * Config Id: CF01
             * Expected behavior:
             * with {
             *   the IUT being in the 'authorized' state
             *   and the IUT current time is inside the time validity period of CERT_TS_D_AT
             *   and the IUT current location is inside the region validity period of CERT_TS_D_AT
             * }
             * 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_D_AT)
             *                      containing subject_info.subject_type
             *                          indicating 'authorization_ticket' (2)
             *                      and containing subject_attributes['verification key'] (KEY)
             *                      and containing validity_restrictions['time_start_and_end']
             *                          indicating CERT_TS_AT_TIME_VALIDITY
             *                      and containing validity_restrictions['region']
             *                          containing region
             *                              containing region_type
             *                                  indicating 'polygon'
             *                              and containing polygonal_region
             *                                  indicating REGION
             *       and containing header_fields [1]
             *         containing type 
             *           indicating 'generation_time'
             *              containing generation_time
             *                  indicating CURRENT_TIME
             *       and containing header_fields [2]
             *           containing type 
             *               indicating 'generation_location'
             *           and containing generation_location
             *       and containing header_fields[3]
             *           containing type 
             *               indicating 'its_aid'
             *           and containing its_aid
             *               indicating 'AID_BEACON'
             *          and containing payload_field 
             *               containing type
             *                  indicating 'signed'
             *              containing data
             *                  indicating length > 0
             *          and containing trailer_fields 
             *              containing single instance of type TrailerField 
             *                  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_GENMSG_01_04_BV
             * @reference    ETSI TS 103 097 [1], clause 7.2
             */
            testcase TC_SEC_ITSS_RCV_GENMSG_01_04_BV() runs on ItsMtc system ItsSecSystem {
                
                // Local variables
                var ItsGeoNetworking v_nodeB;
                var ItsGeoNetworking v_nodeD;
                
                // Test control
                if (not(PICS_GN_SECURITY) or not(PICS_GN_GBC_SRC)) {
                    log("*** " & testcasename() & ": 'PICS_GN_SECURITY' and PICS_GN_GBC_SRC' required for executing the TC ***");
                    setverdict(inconc);
                    stop;
                }
                
                // Test component configuration
                f_cf02Up();
                
                // Preamble
                
                // Start components
                v_nodeB := f_getComponent(c_compNodeB);
                v_nodeD := f_getComponent(c_compNodeD);
                v_nodeB.start(f_TC_SEC_ITSS_RCV_GENMSG_01_0x_BV_nodeB(cc_taCert_D));
                v_nodeD.start(f_TC_SEC_ITSS_RCV_GENMSG_xxx_BV_nodeD());
                
                // Synchronization
                f_serverSync2ClientsAndStop({c_prDone, c_tbDone, c_poDone});
                
                // Cleanup
                f_cf02Down();
                
            } // End of testcase TC_SEC_ITSS_RCV_GENMSG_01_04_BV
            
            /**
             * @desc    Check that IUT accepts a well-formed Secured GN Beacon signed with the certificate with a rectangular region validity restriction
             * <pre>
             * Pics Selection: PICS_GN_SECURITY and PICS_GN_GBC_SRC
             * Config Id: CF01
             * Expected behavior:
             * with {
             *   the IUT being in the 'authorized' state
             *   and the IUT current time is inside the time validity period of CERT_TS_E_AT
             *   and the IUT current location is inside the region validity period of CERT_TS_E_AT
             * }
             * 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_E_AT)
             *                      containing subject_info.subject_type
             *                          indicating 'authorization_ticket' (2)
             *                      and containing subject_attributes['verification key'] (KEY)
             *                      and containing validity_restrictions['time_start_and_end']
             *                          indicating CERT_TS_AT_TIME_VALIDITY
             *                      and containing validity_restrictions['region']
             *                          containing region
             *                              containing region_type
             *                                  indicating 'id_region'
             *                              and containing id_region
             *                                  indicating REGION
             *       and containing header_fields [1]
             *         containing type 
             *           indicating 'generation_time'
             *              containing generation_time
             *                  indicating CURRENT_TIME
             *       and containing header_fields [2]
             *           containing type 
             *               indicating 'generation_location'
             *           and containing generation_location
             *       and containing header_fields[3]
             *           containing type 
             *               indicating 'its_aid'
             *           and containing its_aid
             *               indicating 'AID_BEACON'
             *          and containing payload_field 
             *               containing type
             *                  indicating 'signed'
             *              containing data
             *                  indicating length > 0
             *          and containing trailer_fields 
             *              containing single instance of type TrailerField 
             *                  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_GENMSG_01_05_BV
             * @reference    ETSI TS 103 097 [1], clause 7.2
             */
            testcase TC_SEC_ITSS_RCV_GENMSG_01_05_BV() runs on ItsMtc system ItsSecSystem {
                
                // Local variables
                var ItsGeoNetworking v_nodeB;
                var ItsGeoNetworking v_nodeD;
                
                // Test control
                if (not(PICS_GN_SECURITY) or not(PICS_GN_GBC_SRC)) {
                    log("*** " & testcasename() & ": 'PICS_GN_SECURITY' and PICS_GN_GBC_SRC' required for executing the TC ***");
                    setverdict(inconc);
                    stop;
                }
                
                // Test component configuration
                f_cf02Up();
                
                // Preamble
                
                // Start components
                v_nodeB := f_getComponent(c_compNodeB);
                v_nodeD := f_getComponent(c_compNodeD);
                v_nodeB.start(f_TC_SEC_ITSS_RCV_GENMSG_01_0x_BV_nodeB(cc_taCert_E));
                v_nodeD.start(f_TC_SEC_ITSS_RCV_GENMSG_xxx_BV_nodeD());
                
                // Synchronization
                f_serverSync2ClientsAndStop({c_prDone, c_tbDone, c_poDone});
                
                // Cleanup
                f_cf02Down();
                
            } // End of testcase TC_SEC_ITSS_RCV_GENMSG_01_05_BV
            
            group g_TC_SEC_ITSS_RCV_GENMSG_01_0x_BV {
                
                /**
                 * @desc    Behavior function for NodeB (TC_GEONW_PON_GBC_BV_01)
                 */
                function f_TC_SEC_ITSS_RCV_GENMSG_01_0x_BV_nodeB(
                                                                 in charstring p_taCert
                ) runs on ItsGeoNetworking {
                    
                    // Local variables
                    var GeoNetworkingPdu v_securedGnPdu;
                    
                    // Preamble
                    f_selfOrClientSyncAndVerdict(c_prDone, e_success);
                    
                    // Test Body
                    v_securedGnPdu := f_sendSecuredBeacon(p_taCert, omit, e_certificate);
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                    
                    // Postamble
                    f_selfOrClientSyncAndVerdict(c_poDone, e_success);
                    
                } // End of function f_TC_SEC_ITSS_RCV_GENMSG_01_0x_BV_nodeB
                
            } // End of group g_TC_SEC_ITSS_RCV_GENMSG_01_0x_BV
            
            /**
             * @desc    Check that IUT discards a Secured GN Message containing protocol version set to a value less than 2
             * <pre>
             * Pics Selection: PICS_GN_SECURITY and PICS_GN_GBC_SRC
             * Config Id: CF01
             * Expected behavior:
             * with {
             *   the IUT being in the 'authorized' state
             *   and the IUT current time is inside the time validity period of CERT_TS_A_AT
             * }
             * ensure that {
             *   when {
             *     the IUT is receiving a SecuredMessage
             *         containing protocol_version 
             *             indicating 1
             *   } then {
             *     the IUT discards the message
             *   }
             * }
             * </pre>
             * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_RCV_GENMSG_02_01_BO
             * @reference    ETSI TS 103 097 [1], clause 7.2
             */
            testcase TC_SEC_ITSS_RCV_GENMSG_02_01_BO() runs on ItsMtc system ItsSecSystem {
                
                // Local variables
                var ItsGeoNetworking v_nodeB;
                var ItsGeoNetworking v_nodeD;
                
                // Test control
                if (not(PICS_GN_SECURITY) or not(PICS_GN_GBC_SRC)) {
                    log("*** " & testcasename() & ": 'PICS_GN_SECURITY' and PICS_GN_GBC_SRC' required for executing the TC ***");
                    setverdict(inconc);
                    stop;
                }
                
                // Test component configuration
                f_cf02Up();
                
                // Preamble
                
                // Start components
                v_nodeB := f_getComponent(c_compNodeB);
                v_nodeD := f_getComponent(c_compNodeD);
                v_nodeB.start(f_TC_SEC_ITSS_RCV_GENMSG_02_0x_BO_nodeB(c_protocol_version - 1));
                v_nodeD.start(f_TC_SEC_ITSS_RCV_GENMSG_xxx_BO_nodeD());
                
                // Synchronization
                f_serverSync2ClientsAndStop({c_prDone, c_tbDone, c_poDone});
                
                // Cleanup
                f_cf02Down();
                
            } // End of testcase TC_SEC_ITSS_RCV_GENMSG_02_01_BO
            
            /**
             * @desc    Check that IUT discards a Secured GN Message containing protocol version set to a value greater than 2
             * <pre>
             * Pics Selection: PICS_GN_SECURITY and PICS_GN_GBC_SRC
             * Config Id: CF01
             * Expected behavior:
             * with {
             *   the IUT being in the 'authorized' state
             *   and the IUT current time is inside the time validity period of CERT_TS_A_AT
             * }
             * ensure that {
             *   when {
             *     the IUT is receiving a SecuredMessage
             *         containing protocol_version 
             *             indicating 3
             *   } then {
             *     the IUT discards the message
             *   }
             * }
             * </pre>
             * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_RCV_GENMSG_02_02_BO
             * @reference    ETSI TS 103 097 [1], clause 7.2
             */
            testcase TC_SEC_ITSS_RCV_GENMSG_02_02_BO() runs on ItsMtc system ItsSecSystem {
                
                // Local variables
                var ItsGeoNetworking v_nodeB;
                var ItsGeoNetworking v_nodeD;
                
                // Test control
                if (not(PICS_GN_SECURITY) or not(PICS_GN_GBC_SRC)) {
                    log("*** " & testcasename() & ": 'PICS_GN_SECURITY' and PICS_GN_GBC_SRC' required for executing the TC ***");
                    setverdict(inconc);
                    stop;
                }
                
                // Test component configuration
                f_cf02Up();
                
                // Preamble
                
                // Start components
                v_nodeB := f_getComponent(c_compNodeB);
                v_nodeD := f_getComponent(c_compNodeD);
                v_nodeB.start(f_TC_SEC_ITSS_RCV_GENMSG_02_0x_BO_nodeB(c_protocol_version + 1));
                v_nodeD.start(f_TC_SEC_ITSS_RCV_GENMSG_xxx_BO_nodeD());
                
                // Synchronization
                f_serverSync2ClientsAndStop({c_prDone, c_tbDone, c_poDone});
                
                // Cleanup
                f_cf02Down();
                
            } // End of testcase TC_SEC_ITSS_RCV_GENMSG_02_02_BO
            
            group g_TC_SEC_ITSS_RCV_GENMSG_02_0x_BO {
                
                /**
                 * @desc    Behavior function for NodeB (TC_GEONW_PON_GBC_BV_01)
                 */
                function f_TC_SEC_ITSS_RCV_GENMSG_02_0x_BO_nodeB(
                                                                 in integer p_protocolVersion
                ) runs on ItsGeoNetworking {
                    
                    // Local variables
                    var GeoNetworkingPdu v_securedGnPdu;
                    
                    // Preamble
                    f_selfOrClientSyncAndVerdict(c_prDone, e_success);
                    
                    // Test Body
                    v_securedGnPdu := f_sendSecuredBeacon_Bo(cc_taCert_A, p_protocolVersion);
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                    
                    // Postamble
                    f_selfOrClientSyncAndVerdict(c_poDone, e_success);
                    
                } // End of function f_TC_SEC_ITSS_RCV_GENMSG_02_0x_BO_nodeB
                
            } // End of group g_TC_SEC_ITSS_RCV_GENMSG_02_0x_BV
            
            /**
             * @desc    Check that IUT discards a secured GN Message if the header_fields contains more than one header field of type 'signer_info'
             * <pre>
             * Pics Selection: PICS_GN_SECURITY and PICS_GN_GBC_SRC
             * Config Id: CF01
             * Initial conditions:
             * with { 
             *    the IUT being in the 'authorized' state 
             *    and the IUT current time is inside the time validity period of CERT_TS_A_AT
             * } 
             * ensure that { 
             *  when { 
             *      the IUT is receiving a SecuredMessage ((MSG_SEC_RCV_GENMSG_A)) 
             *          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 ''generation_location''
             *          and containing header_fields[4].type
             *              containing its_aid
             *                  indicating 'AID_BEACON'
             *          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_GENMSG_04_01_BO
             * @reference    ETSI TS 103 097 [1], clause 7.1
             */
            testcase TC_SEC_ITSS_RCV_GENMSG_04_01_BO() runs on ItsMtc system ItsSecSystem {
                
                // Local variables
                var ItsGeoNetworking v_nodeB;
                var ItsGeoNetworking v_nodeD;
                
                // Test control
                if (not(PICS_GN_SECURITY) or not(PICS_GN_GBC_SRC)) {
                    log("*** " & testcasename() & ": 'PICS_GN_SECURITY' and PICS_GN_GBC_SRC' required for executing the TC ***");
                    setverdict(inconc);
                    stop;
                }
                
                // Test component configuration
                f_cf02Up();
                
                // Preamble
                
                // Start components
                v_nodeB := f_getComponent(c_compNodeB);
                v_nodeD := f_getComponent(c_compNodeD);
                v_nodeB.start(f_TC_SEC_ITSS_RCV_GENMSG_04_01_BO());
                v_nodeD.start(f_TC_SEC_ITSS_RCV_GENMSG_xxx_BO_nodeD());
                
                // Synchronization
                f_serverSync2ClientsAndStop({c_prDone, c_tbDone, c_poDone});
                
                // Cleanup
                f_cf02Down();
                
            } // End of testcase TC_SEC_ITSS_RCV_GENMSG_04_01_BO
            
            group g_TC_SEC_ITSS_RCV_GENMSG_04_01_BO {
                
                    /**
                     * @desc    Behavior function for NodeB (TC_GEONW_PON_GBC_BV_01)
                     */
                function f_TC_SEC_ITSS_RCV_GENMSG_04_01_BO() runs on ItsGeoNetworking {
                    
                    // Local variables
                    var GeoNetworkingPdu v_securedGnPdu;
                    var LongPosVector v_longPosVectorNodeB := f_getPosition(c_compNodeB); // Use NodeB
                    
                    //  Test component configuration
                    f_cf01Up();
                    
                    // Test adapter configuration
                    
                    // Preamble
                    f_prNeighbour();
                    f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                    
                    // Test Body
                    v_securedGnPdu := f_prepareSecuredBeacon(
                        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_generation_location(
                                valueof(m_threeDLocation(
                                    v_longPosVectorNodeB.latitude,
                                    v_longPosVectorNodeB.longitude,
                                    '0000'O
                                ))
                            ),
                            m_header_field_its_aid_Other
                        }, 
                        e_certificate_digest_with_sha256,
                        false
                    ); 
                    f_sendGeoNetMessage(m_geoNwReq_linkLayerBroadcast(v_securedGnPdu));
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                    
                    // Postamble
                    f_selfOrClientSyncAndVerdict(c_poDone, e_success);
                    
                } // End of testcase f_TC_SEC_ITSS_RCV_GENMSG_04_01_BO
                
            } // End of group g_TC_SEC_ITSS_RCV_GENMSG_04_01_BO 
            
            /**
             * @desc    Check that IUT discards a secured GN Message if the header_fields does not contain the header field of type 'signer_info'
             * <pre>
             * Pics Selection: PICS_GN_SECURITY and PICS_GN_GBC_SRC
             * Config Id: CF01
             * Initial conditions:
             * with { 
             *    the IUT being in the 'authorized' state 
             *    and the IUT current time is inside the time validity period of CERT_TS_A_AT
             * } 
             * ensure that { 
             *  when { 
             *      the IUT is receiving a SecuredMessage ((MSG_SEC_RCV_GENMSG_A)) 
             *          and containing header_fields[0].type
             *              indicating 'generation_time'
             *          and containing header_fields[1].type
             *              indicating 'generation_location'
             *          and containing header_fields[2].type
             *              indicating 'signer_info'
             *          and containing header_fields[3].type
             *              containing its_aid
             *                  indicating 'AID_BEACON'
             *          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_GENMSG_04_02_BO
             * @reference    ETSI TS 103 097 [1], clause 7.1
             */
            testcase TC_SEC_ITSS_RCV_GENMSG_04_02_BO() runs on ItsMtc system ItsSecSystem {
                
                // Local variables
                var ItsGeoNetworking v_nodeB;
                var ItsGeoNetworking v_nodeD;
                
                // Test control
                if (not(PICS_GN_SECURITY) or not(PICS_GN_GBC_SRC)) {
                    log("*** " & testcasename() & ": 'PICS_GN_SECURITY' and PICS_GN_GBC_SRC' required for executing the TC ***");
                    setverdict(inconc);
                    stop;
                }
                
                // Test component configuration
                f_cf02Up();
                
                // Preamble
                
                // Start components
                v_nodeB := f_getComponent(c_compNodeB);
                v_nodeD := f_getComponent(c_compNodeD);
                v_nodeB.start(f_TC_SEC_ITSS_RCV_GENMSG_04_02_BO());
                v_nodeD.start(f_TC_SEC_ITSS_RCV_GENMSG_xxx_BO_nodeD());
                
                // Synchronization
                f_serverSync2ClientsAndStop({c_prDone, c_tbDone, c_poDone});
                
                // Cleanup
                f_cf02Down();
                
            } // End of testcase TC_SEC_ITSS_RCV_GENMSG_04_02_BO
            
            group g_TC_SEC_ITSS_RCV_GENMSG_04_02_BO {
                
                    /**
                     * @desc    Behavior function for NodeB (TC_GEONW_PON_GBC_BV_01)
                     */
                function f_TC_SEC_ITSS_RCV_GENMSG_04_02_BO() runs on ItsGeoNetworking {
                    
                    // Local variables
                    var GeoNetworkingPdu v_securedGnPdu;
                    var LongPosVector v_longPosVectorNodeB := f_getPosition(c_compNodeB); // Use NodeB
                    
                    //  Test component configuration
                    f_cf01Up();
                    
                    // Test adapter configuration
                    
                    // Preamble
                    f_prNeighbour();
                    f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                    
                    // Test Body
                    v_securedGnPdu := f_prepareSecuredBeacon(
                        cc_taCert_A, 
                        {
                            m_header_field_generation_time(1000 * f_getCurrentTime()), // In us
                            m_header_field_generation_location(
                                valueof(m_threeDLocation(
                                    v_longPosVectorNodeB.latitude,
                                    v_longPosVectorNodeB.longitude,
                                    '0000'O
                                ))
                            ),
                            m_header_field_its_aid_Other
                        }, 
                        e_certificate_digest_with_sha256,
                        false
                    ); 
                    f_sendGeoNetMessage(m_geoNwReq_linkLayerBroadcast(v_securedGnPdu));
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                    
                    // Postamble
                    f_selfOrClientSyncAndVerdict(c_poDone, e_success);
                    
                } // End of testcase f_TC_SEC_ITSS_RCV_GENMSG_04_02_BO
                
            } // End of group g_TC_SEC_ITSS_RCV_GENMSG_04_02_BO 
            
            /**
             * @desc    Check that IUT is able to receive a secured GN Message if the signer_info header field is not encoded first.
             * <pre>
             * Pics Selection: PICS_GN_SECURITY and PICS_GN_GBC_SRC
             * Config Id: CF01
             * Initial conditions:
             * with { 
             *    the IUT being in the 'authorized' state 
             *    and the IUT current time is inside the time validity period of CERT_TS_A_AT
             * } 
             * ensure that { 
             *  when { 
             *      the IUT is receiving a SecuredMessage ((MSG_SEC_RCV_GENMSG_A)) 
             *          and containing header_fields[0].type
             *              indicating 'generation_time'
             *          and containing header_fields[1].type
             *              indicating 'generation_location'
             *          and containing header_fields[2].type
             *              containing its_aid
             *                  indicating 'AID_BEACON'
             *          and containing header_fields[3].type
             *              indicating 'signer_info'
             *          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_GENMSG_04_03_BO
             * @reference    ETSI TS 103 097 [1], clause 7.1
             */
            testcase TC_SEC_ITSS_RCV_GENMSG_04_03_BO() runs on ItsMtc system ItsSecSystem {
                
                // Local variables
                var ItsGeoNetworking v_nodeB;
                var ItsGeoNetworking v_nodeD;
                
                // Test control
                if (not(PICS_GN_SECURITY) or not(PICS_GN_GBC_SRC)) {
                    log("*** " & testcasename() & ": 'PICS_GN_SECURITY' and PICS_GN_GBC_SRC' required for executing the TC ***");
                    setverdict(inconc);
                    stop;
                }
                
                // Test component configuration
                f_cf02Up();
                
                // Preamble
                
                // Start components
                v_nodeB := f_getComponent(c_compNodeB);
                v_nodeD := f_getComponent(c_compNodeD);
                v_nodeB.start(f_TC_SEC_ITSS_RCV_GENMSG_04_03_BO());
                v_nodeD.start(f_TC_SEC_ITSS_RCV_GENMSG_xxx_BO_nodeD());
                
                // Synchronization
                f_serverSync2ClientsAndStop({c_prDone, c_tbDone, c_poDone});
                
                // Cleanup
                f_cf02Down();
                
            } // End of testcase TC_SEC_ITSS_RCV_GENMSG_04_03_BO
            
            group g_TC_SEC_ITSS_RCV_GENMSG_04_03_BO {
                
                    /**
                     * @desc    Behavior function for NodeB (TC_GEONW_PON_GBC_BV_01)
                     */
                function f_TC_SEC_ITSS_RCV_GENMSG_04_03_BO() runs on ItsGeoNetworking {
                    
                    // Local variables
                    var GeoNetworkingPdu v_securedGnPdu;
                    var LongPosVector v_longPosVectorNodeB := f_getPosition(c_compNodeB); // Use NodeB
                    
                    //  Test component configuration
                    f_cf01Up();
                    
                    // Test adapter configuration
                    
                    // Preamble
                    f_prNeighbour();
                    f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                    
                    // Test Body
                    v_securedGnPdu := f_prepareSecuredBeacon(
                        cc_taCert_A, 
                        {
                            m_header_field_generation_time(1000 * f_getCurrentTime()), // In us
                            m_header_field_generation_location(
                                valueof(m_threeDLocation(
                                    v_longPosVectorNodeB.latitude,
                                    v_longPosVectorNodeB.longitude,
                                    '0000'O
                                ))
                            ),
                            m_header_field_its_aid_Other,
                            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_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                    
                    // Postamble
                    f_selfOrClientSyncAndVerdict(c_poDone, e_success);
                    
                } // End of testcase f_TC_SEC_ITSS_RCV_GENMSG_04_03_BO
                
            } // End of group g_TC_SEC_ITSS_RCV_GENMSG_04_03_BO 
            
            /**
             * @desc    Check that IUT discards a secured GN Message if the message contains more than one header field of type 'generation_time'
             * <pre>
             * Pics Selection: PICS_GN_SECURITY and PICS_GN_GBC_SRC
             * Config Id: CF01
             * Initial conditions:
             * with { 
             *    the IUT being in the 'authorized' state 
             *    and the IUT current time is inside the time validity period of CERT_TS_A_AT
             * } 
             * ensure that { 
             *  when { 
             *      the IUT is receiving a SecuredMessage ((MSG_SEC_RCV_GENMSG_A)) 
             *          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 'generation_time'
             *          and containing header_fields[4].type
             *              containing its_aid
             *                  indicating 'AID_BEACON'
             *          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_GENMSG_04_04_BO
             * @reference    ETSI TS 103 097 [1], clause 7.1
             */
            testcase TC_SEC_ITSS_RCV_GENMSG_04_04_BO() runs on ItsMtc system ItsSecSystem {
                
                // Local variables
                var ItsGeoNetworking v_nodeB;
                var ItsGeoNetworking v_nodeD;
                
                // Test control
                if (not(PICS_GN_SECURITY) or not(PICS_GN_GBC_SRC)) {
                    log("*** " & testcasename() & ": 'PICS_GN_SECURITY' and PICS_GN_GBC_SRC' required for executing the TC ***");
                    setverdict(inconc);
                    stop;
                }
                
                // Test component configuration
                f_cf02Up();
                
                // Preamble
                
                // Start components
                v_nodeB := f_getComponent(c_compNodeB);
                v_nodeD := f_getComponent(c_compNodeD);
                v_nodeB.start(f_TC_SEC_ITSS_RCV_GENMSG_04_04_BO());
                v_nodeD.start(f_TC_SEC_ITSS_RCV_GENMSG_xxx_BO_nodeD());
                
                // Synchronization
                f_serverSync2ClientsAndStop({c_prDone, c_tbDone, c_poDone});
                
                // Cleanup
                f_cf02Down();
                
            } // End of testcase TC_SEC_ITSS_RCV_GENMSG_04_04_BO
            
            group g_TC_SEC_ITSS_RCV_GENMSG_04_04_BO {
                
                    /**
                     * @desc    Behavior function for NodeB (TC_GEONW_PON_GBC_BV_01)
                     */
                function f_TC_SEC_ITSS_RCV_GENMSG_04_04_BO() runs on ItsGeoNetworking {
                    
                    // Local variables
                    var GeoNetworkingPdu v_securedGnPdu;
                    var LongPosVector v_longPosVectorNodeB := f_getPosition(c_compNodeB); // Use NodeB
                    
                    //  Test component configuration
                    f_cf01Up();
                    
                    // Test adapter configuration
                    
                    // Preamble
                    f_prNeighbour();
                    f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                    
                    // Test Body
                    v_securedGnPdu := f_prepareSecuredBeacon(
                        cc_taCert_A, 
                        {
                            m_header_field_signer_info(
                                m_signerInfo_digest(
                                    vc_atCertificate.signer_info.signerInfo.digest
                            )),
                            m_header_field_generation_time(1000 * f_getCurrentTime()), // In us
                            m_header_field_generation_time(1000 * f_getCurrentTime() - 1), // In us
                            m_header_field_generation_location(
                                valueof(m_threeDLocation(
                                    v_longPosVectorNodeB.latitude,
                                    v_longPosVectorNodeB.longitude,
                                    '0000'O
                                ))
                            ),
                            m_header_field_its_aid_Other
                        }, 
                        e_certificate_digest_with_sha256,
                        false
                    ); 
                    f_sendGeoNetMessage(m_geoNwReq_linkLayerBroadcast(v_securedGnPdu));
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                    
                    // Postamble
                    f_selfOrClientSyncAndVerdict(c_poDone, e_success);
                    
                } // End of testcase f_TC_SEC_ITSS_RCV_GENMSG_04_04_BO
                
            } // End of group g_TC_SEC_ITSS_RCV_GENMSG_04_04_BO 
            
            /**
             * @desc    Check that IUT discards a secured GN Message if the message does not contain the header field of type 'generation_time'
             * <pre>
             * Pics Selection: PICS_GN_SECURITY and PICS_GN_GBC_SRC
             * Config Id: CF01
             * Initial conditions:
             * with { 
             *    the IUT being in the 'authorized' state 
             *    and the IUT current time is inside the time validity period of CERT_TS_A_AT
             * } 
             * ensure that { 
             *  when { 
             *      the IUT is receiving a SecuredMessage ((MSG_SEC_RCV_GENMSG_A)) 
             *          containing header_fields[0].type
             *              indicating 'signer_info'
             *          and containing header_fields[1].type
             *              indicating 'generation_time'
             *          and containing header_fields[2].type
             *              containing its_aid
             *                  indicating 'AID_BEACON'
             *          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_GENMSG_04_05_BO
             * @reference    ETSI TS 103 097 [1], clause 7.1
             */
            testcase TC_SEC_ITSS_RCV_GENMSG_04_05_BO() runs on ItsMtc system ItsSecSystem {
                
                // Local variables
                var ItsGeoNetworking v_nodeB;
                var ItsGeoNetworking v_nodeD;
                
                // Test control
                if (not(PICS_GN_SECURITY) or not(PICS_GN_GBC_SRC)) {
                    log("*** " & testcasename() & ": 'PICS_GN_SECURITY' and PICS_GN_GBC_SRC' required for executing the TC ***");
                    setverdict(inconc);
                    stop;
                }
                
                // Test component configuration
                f_cf02Up();
                
                // Preamble
                
                // Start components
                v_nodeB := f_getComponent(c_compNodeB);
                v_nodeD := f_getComponent(c_compNodeD);
                v_nodeB.start(f_TC_SEC_ITSS_RCV_GENMSG_04_05_BO());
                v_nodeD.start(f_TC_SEC_ITSS_RCV_GENMSG_xxx_BO_nodeD());
                
                // Synchronization
                f_serverSync2ClientsAndStop({c_prDone, c_tbDone, c_poDone});
                
                // Cleanup
                f_cf02Down();
                
            } // End of testcase TC_SEC_ITSS_RCV_GENMSG_04_05_BO
            
            group g_TC_SEC_ITSS_RCV_GENMSG_04_05_BO {
                
                    /**
                     * @desc    Behavior function for NodeB (TC_GEONW_PON_GBC_BV_01)
                     */
                function f_TC_SEC_ITSS_RCV_GENMSG_04_05_BO() runs on ItsGeoNetworking {
                    
                    // Local variables
                    var GeoNetworkingPdu v_securedGnPdu;
                    var LongPosVector v_longPosVectorNodeB := f_getPosition(c_compNodeB); // Use NodeB
                    
                    //  Test component configuration
                    f_cf01Up();
                    
                    // Test adapter configuration
                    
                    // Preamble
                    f_prNeighbour();
                    f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                    
                    // Test Body
                    v_securedGnPdu := f_prepareSecuredBeacon(
                        cc_taCert_A, 
                        {
                            m_header_field_signer_info(
                                m_signerInfo_digest(
                                    vc_atCertificate.signer_info.signerInfo.digest
                            )),
                            m_header_field_generation_location(
                                valueof(m_threeDLocation(
                                    v_longPosVectorNodeB.latitude,
                                    v_longPosVectorNodeB.longitude,
                                    '0000'O
                                ))
                            ),
                            m_header_field_its_aid_Other
                        }, 
                        e_certificate_digest_with_sha256,
                        false
                    ); 
                    f_sendGeoNetMessage(m_geoNwReq_linkLayerBroadcast(v_securedGnPdu));
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                    
                    // Postamble
                    f_selfOrClientSyncAndVerdict(c_poDone, e_success);
                    
                } // End of testcase f_TC_SEC_ITSS_RCV_GENMSG_04_05_BO
                
            } // End of group g_TC_SEC_ITSS_RCV_GENMSG_04_05_BO 
            
            /**
             * @desc    Check that IUT discards a Secured GN Message if the message contains more than one header field of type 'its_aid'
             * <pre>
             * Pics Selection: PICS_GN_SECURITY and PICS_GN_GBC_SRC
             * Config Id: CF01
             * Initial conditions:
             * with { 
             *    the IUT being in the 'authorized' state 
             *    and the IUT current time is inside the time validity period of CERT_TS_A_AT
             * } 
             * ensure that { 
             *  when { 
             *      the IUT is receiving a SecuredMessage ((MSG_SEC_RCV_GENMSG_A)) 
             *          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_location'
             *          and containing header_fields[3]
             *              containing type
             *                  indicating 'its_aid'
             *              containing its_aid
             *                  indicating 'AID_BEACON'
             *          and containing header_fields[4].type
             *              containing its_aid
             *                  indicating 'AID_BEACON'
             *          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_GENMSG_04_06_BO
             * @reference    ETSI TS 103 097 [1], clause 7.1
             */
            testcase TC_SEC_ITSS_RCV_GENMSG_04_06_BO() runs on ItsMtc system ItsSecSystem {
                
                // Local variables
                var ItsGeoNetworking v_nodeB;
                var ItsGeoNetworking v_nodeD;
                
                // Test control
                if (not(PICS_GN_SECURITY) or not(PICS_GN_GBC_SRC)) {
                    log("*** " & testcasename() & ": 'PICS_GN_SECURITY' and PICS_GN_GBC_SRC' required for executing the TC ***");
                    setverdict(inconc);
                    stop;
                }
                
                // Test component configuration
                f_cf02Up();
                
                // Preamble
                
                // Start components
                v_nodeB := f_getComponent(c_compNodeB);
                v_nodeD := f_getComponent(c_compNodeD);
                v_nodeB.start(f_TC_SEC_ITSS_RCV_GENMSG_04_06_BO());
                v_nodeD.start(f_TC_SEC_ITSS_RCV_GENMSG_xxx_BO_nodeD());
                
                // Synchronization
                f_serverSync2ClientsAndStop({c_prDone, c_tbDone, c_poDone});
                
                // Cleanup
                f_cf02Down();
                
            } // End of testcase TC_SEC_ITSS_RCV_GENMSG_04_06_BO
            
            group g_TC_SEC_ITSS_RCV_GENMSG_04_06_BO {
                
                    /**
                     * @desc    Behavior function for NodeB (TC_GEONW_PON_GBC_BV_01)
                     */
                function f_TC_SEC_ITSS_RCV_GENMSG_04_06_BO() runs on ItsGeoNetworking {
                    
                    // Local variables
                    var GeoNetworkingPdu v_securedGnPdu;
                    var LongPosVector v_longPosVectorNodeB := f_getPosition(c_compNodeB); // Use NodeB
                    
                    //  Test component configuration
                    f_cf01Up();
                    
                    // Test adapter configuration
                    
                    // Preamble
                    f_prNeighbour();
                    f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                    
                    // Test Body
                    v_securedGnPdu := f_prepareSecuredBeacon(
                        cc_taCert_A, 
                        {
                            m_header_field_signer_info(
                                m_signerInfo_digest(
                                    vc_atCertificate.signer_info.signerInfo.digest
                            )),
                            m_header_field_generation_time(1000 * f_getCurrentTime()), // In us
                            m_header_field_generation_location(
                                valueof(m_threeDLocation(
                                    v_longPosVectorNodeB.latitude,
                                    v_longPosVectorNodeB.longitude,
                                    '0000'O
                                ))
                            ),
                            m_header_field_its_aid_Other,
                            m_header_field_its_aid_Other
                        }, 
                        e_certificate_digest_with_sha256,
                        false
                    ); 
                    f_sendGeoNetMessage(m_geoNwReq_linkLayerBroadcast(v_securedGnPdu));
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                    
                    // Postamble
                    f_selfOrClientSyncAndVerdict(c_poDone, e_success);
                    
                } // End of testcase f_TC_SEC_ITSS_RCV_GENMSG_04_06_BO
                
            } // End of group g_TC_SEC_ITSS_RCV_GENMSG_04_06_BO 
            
            /**
             * @desc    Check that IUT discards a secured GN Message if the message contains more than one header field of type 'generation_location'
             * <pre>
             * Pics Selection: PICS_GN_SECURITY and PICS_GN_GBC_SRC
             * Config Id: CF01
             * Initial conditions:
             * with { 
             *    the IUT being in the 'authorized' state 
             *    and the IUT current time is inside the time validity period of CERT_TS_A_AT
             * } 
             * ensure that { 
             *  when { 
             *      the IUT is receiving a SecuredMessage ((MSG_SEC_RCV_GENMSG_A)) 
             *          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_location'
             *          and containing header_fields[3].type
             *              indicating 'generation_location'
             *          and containing header_fields[4]
             *              containing type
             *                  indicating 'its_aid'
             *              containing its_aid
             *                  indicating 'AID_BEACON'
             *          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_GENMSG_04_07_BO
             * @reference    ETSI TS 103 097 [1], clause 7.1
             */
            testcase TC_SEC_ITSS_RCV_GENMSG_04_07_BO() runs on ItsMtc system ItsSecSystem {
                
                // Local variables
                var ItsGeoNetworking v_nodeB;
                var ItsGeoNetworking v_nodeD;
                
                // Test control
                if (not(PICS_GN_SECURITY) or not(PICS_GN_GBC_SRC)) {
                    log("*** " & testcasename() & ": 'PICS_GN_SECURITY' and PICS_GN_GBC_SRC' required for executing the TC ***");
                    setverdict(inconc);
                    stop;
                }
                
                // Test component configuration
                f_cf02Up();
                
                // Preamble
                
                // Start components
                v_nodeB := f_getComponent(c_compNodeB);
                v_nodeD := f_getComponent(c_compNodeD);
                v_nodeB.start(f_TC_SEC_ITSS_RCV_GENMSG_04_07_BO());
                v_nodeD.start(f_TC_SEC_ITSS_RCV_GENMSG_xxx_BO_nodeD());
                
                // Synchronization
                f_serverSync2ClientsAndStop({c_prDone, c_tbDone, c_poDone});
                
                // Cleanup
                f_cf02Down();
                
            } // End of testcase TC_SEC_ITSS_RCV_GENMSG_04_07_BO
            
            group g_TC_SEC_ITSS_RCV_GENMSG_04_07_BO {
                
                    /**
                     * @desc    Behavior function for NodeB (TC_GEONW_PON_GBC_BV_01)
                     */
                function f_TC_SEC_ITSS_RCV_GENMSG_04_07_BO() runs on ItsGeoNetworking {
                    
                    // Local variables
                    var GeoNetworkingPdu v_securedGnPdu;
                    var LongPosVector v_longPosVectorNodeB := f_getPosition(c_compNodeB); // Use NodeB
                    
                    //  Test component configuration
                    f_cf01Up();
                    
                    // Test adapter configuration
                    
                    // Preamble
                    f_prNeighbour();
                    f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                    
                    // Test Body
                    v_securedGnPdu := f_prepareSecuredBeacon(
                        cc_taCert_A, 
                        {
                            m_header_field_signer_info(
                                m_signerInfo_digest(
                                    vc_atCertificate.signer_info.signerInfo.digest
                            )),
                            m_header_field_generation_time(1000 * f_getCurrentTime()), // In us
                            m_header_field_generation_location(
                                valueof(m_threeDLocation(
                                    v_longPosVectorNodeB.latitude,
                                    v_longPosVectorNodeB.longitude,
                                    '0000'O
                                ))
                            ),
                            m_header_field_generation_location(
                                valueof(m_threeDLocation(
                                    v_longPosVectorNodeB.latitude,
                                    v_longPosVectorNodeB.longitude,
                                    '0100'O
                                ))
                            ),
                            m_header_field_its_aid_Other
                        }, 
                        e_certificate_digest_with_sha256,
                        false
                    ); 
                    f_sendGeoNetMessage(m_geoNwReq_linkLayerBroadcast(v_securedGnPdu));
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                    
                    // Postamble
                    f_selfOrClientSyncAndVerdict(c_poDone, e_success);
                    
                } // End of testcase f_TC_SEC_ITSS_RCV_GENMSG_04_07_BO
                
            } // End of group g_TC_SEC_ITSS_RCV_GENMSG_04_07_BO 
            
            /**
             * @desc    Check that IUT discards a secured GN Message if the message contains more than one header field of type 'generation_location'
             * <pre>
             * Pics Selection: PICS_GN_SECURITY and PICS_GN_GBC_SRC
             * Config Id: CF01
             * Initial conditions:
             * with { 
             *    the IUT being in the 'authorized' state 
             *    and the IUT current time is inside the time validity period of CERT_TS_A_AT
             * } 
             * ensure that { 
             *  when { 
             *      the IUT is receiving a SecuredMessage ((MSG_SEC_RCV_GENMSG_A)) 
             *          containing header_fields[0].type
             *              indicating 'signer_info'
             *          and containing header_fields[1].type
             *              indicating 'generation_time'
             *          and containing header_fields[2].type
             *          and containing header_fields[4].type
             *              indicating 'its_aid'
             *                  containing its_aid
             *                      indicating 'AID_BEACON'
             *          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_GENMSG_04_08_BO
             * @reference    ETSI TS 103 097 [1], clause 7.1
             */
            testcase TC_SEC_ITSS_RCV_GENMSG_04_08_BO() runs on ItsMtc system ItsSecSystem {
                
                // Local variables
                var ItsGeoNetworking v_nodeB;
                var ItsGeoNetworking v_nodeD;
                
                // Test control
                if (not(PICS_GN_SECURITY) or not(PICS_GN_GBC_SRC)) {
                    log("*** " & testcasename() & ": 'PICS_GN_SECURITY' and PICS_GN_GBC_SRC' required for executing the TC ***");
                    setverdict(inconc);
                    stop;
                }
                
                // Test component configuration
                f_cf02Up();
                
                // Preamble
                
                // Start components
                v_nodeB := f_getComponent(c_compNodeB);
                v_nodeD := f_getComponent(c_compNodeD);
                v_nodeB.start(f_TC_SEC_ITSS_RCV_GENMSG_04_08_BO());
                v_nodeD.start(f_TC_SEC_ITSS_RCV_GENMSG_xxx_BO_nodeD());
                
                // Synchronization
                f_serverSync2ClientsAndStop({c_prDone, c_tbDone, c_poDone});
                
                // Cleanup
                f_cf02Down();
                
            } // End of testcase TC_SEC_ITSS_RCV_GENMSG_04_08_BO
            
            group g_TC_SEC_ITSS_RCV_GENMSG_04_08_BO {
                
                    /**
                     * @desc    Behavior function for NodeB (TC_GEONW_PON_GBC_BV_01)
                     */
                function f_TC_SEC_ITSS_RCV_GENMSG_04_08_BO() runs on ItsGeoNetworking {
                    
                    // Local variables
                    var GeoNetworkingPdu v_securedGnPdu;
                    var LongPosVector v_longPosVectorNodeB := f_getPosition(c_compNodeB); // Use NodeB
                    
                    //  Test component configuration
                    f_cf01Up();
                    
                    // Test adapter configuration
                    
                    // Preamble
                    f_prNeighbour();
                    f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                    
                    // Test Body
                    v_securedGnPdu := f_prepareSecuredBeacon(
                        cc_taCert_A, 
                        {
                            m_header_field_signer_info(
                                m_signerInfo_digest(
                                    vc_atCertificate.signer_info.signerInfo.digest
                            )),
                            m_header_field_generation_time(1000 * f_getCurrentTime()), // In us
                            m_header_field_its_aid_Other
                        }, 
                        e_certificate_digest_with_sha256,
                        false
                    ); 
                    f_sendGeoNetMessage(m_geoNwReq_linkLayerBroadcast(v_securedGnPdu));
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                    
                    // Postamble
                    f_selfOrClientSyncAndVerdict(c_poDone, e_success);
                    
                } // End of testcase f_TC_SEC_ITSS_RCV_GENMSG_04_08_BO
                
            } // End of group g_TC_SEC_ITSS_RCV_GENMSG_04_08_BO 
            
            /**
             * @desc    Check that IUT discards a secured GN Beacon if the header_fields contains a signer of type 'self'
             * <pre>
             * Pics Selection: PICS_GN_SECURITY and PICS_GN_GBC_SRC
             * Config Id: CF01
             * Initial conditions:
             * with { 
             *    the IUT being in the 'authorized' state 
             *    and the IUT current time is inside the time validity period of CERT_TS_A_AT
             * } 
             * ensure that { 
             *  when { 
             *      the IUT is receiving a SecuredMessage ((MSG_SEC_RCV_GENMSG_A)) 
             *          containing header_fields['signer_info']
             *              containing signer.type
             *                  indicating 'self''
             *  } then { 
             *      the IUT discards the message 
             *  } 
             * } 
             * </pre>
             *
             * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_RCV_GENMSG_05_01_BO
             * @reference    ETSI TS 103 097 [1], clause 7.1
             */
            testcase TC_SEC_ITSS_RCV_GENMSG_05_01_BO() runs on ItsMtc system ItsSecSystem {
                
                // Local variables
                var ItsGeoNetworking v_nodeB;
                var ItsGeoNetworking v_nodeD;
                
                // Test control
                if (not(PICS_GN_SECURITY) or not(PICS_GN_GBC_SRC)) {
                    log("*** " & testcasename() & ": 'PICS_GN_SECURITY' and PICS_GN_GBC_SRC' required for executing the TC ***");
                    setverdict(inconc);
                    stop;
                }
                
                // Test component configuration
                f_cf02Up();
                
                // Preamble
                
                // Start components
                v_nodeB := f_getComponent(c_compNodeB);
                v_nodeD := f_getComponent(c_compNodeD);
                v_nodeB.start(f_TC_SEC_ITSS_RCV_GENMSG_05_01_BO());
                v_nodeD.start(f_TC_SEC_ITSS_RCV_GENMSG_xxx_BO_nodeD());
                
                // Synchronization
                f_serverSync2ClientsAndStop({c_prDone, c_tbDone, c_poDone});
                
                // Cleanup
                f_cf02Down();
                
            } // End of testcase TC_SEC_ITSS_RCV_GENMSG_05_01_BO
            
            group g_TC_SEC_ITSS_RCV_GENMSG_05_01_BO {
                
                    /**
                     * @desc    Behavior function for NodeB (TC_GEONW_PON_GBC_BV_01)
                     */
                function f_TC_SEC_ITSS_RCV_GENMSG_05_01_BO() runs on ItsGeoNetworking {
                    
                    // Local variables
                    var GeoNetworkingPdu v_securedGnPdu;
                    var LongPosVector v_longPosVectorNodeB := f_getPosition(c_compNodeB); // Use NodeB
                    
                    //  Test component configuration
                    f_cf01Up();
                    
                    // Test adapter configuration
                    
                    // Preamble
                    f_prNeighbour();
                    f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                    
                    // Test Body
                    v_securedGnPdu := f_prepareSecuredBeacon(
                        cc_taCert_A, 
                        {
                            m_header_field_signer_info(
                                m_signerInfo_self
                            ), 
                            m_header_field_generation_time(1000 * f_getCurrentTime()), // In us
                            m_header_field_generation_location(
                                valueof(m_threeDLocation(
                                    v_longPosVectorNodeB.latitude,
                                    v_longPosVectorNodeB.longitude,
                                    '0000'O
                                ))
                            ),
                            m_header_field_its_aid_Other
                        }, 
                        e_self,
                        false
                    ); 
                    f_sendGeoNetMessage(m_geoNwReq_linkLayerBroadcast(v_securedGnPdu));
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                    
                    // Postamble
                    f_selfOrClientSyncAndVerdict(c_poDone, e_success);
                    
                } // End of testcase f_TC_SEC_ITSS_RCV_GENMSG_05_01_BO
                
            } // End of group g_TC_SEC_ITSS_RCV_GENMSG_05_01_BO 
            
            /**
             * @desc    Check that IUT discards a secured GN Beacon if the header_fields contains a signer of type 'certificate_digest_with_other_algorithm'
             * <pre>
             * Pics Selection: PICS_GN_SECURITY and PICS_GN_GBC_SRC
             * Config Id: CF01
             * Initial conditions:
             * with { 
             *    the IUT being in the 'authorized' state 
             *    and the IUT current time is inside the time validity period of CERT_TS_A_AT
             * } 
             * ensure that { 
             *  when { 
             *      the IUT is receiving a SecuredMessage ((MSG_SEC_RCV_GENMSG_A)) 
             *          containing header_fields['signer_info']
             *              containing signer.type
             *                  indicating 'certificate_digest_with_other_algorithm'
             *  } then { 
             *      the IUT discards the message 
             *  } 
             * } 
             * </pre>
             *
             * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_RCV_GENMSG_05_02_BO
             * @reference    ETSI TS 103 097 [1], clause 7.1
             */
            testcase TC_SEC_ITSS_RCV_GENMSG_05_02_BO() runs on ItsMtc system ItsSecSystem {
                
                // Local variables
                var ItsGeoNetworking v_nodeB;
                var ItsGeoNetworking v_nodeD;
                
                // Test control
                if (not(PICS_GN_SECURITY) or not(PICS_GN_GBC_SRC)) {
                    log("*** " & testcasename() & ": 'PICS_GN_SECURITY' and PICS_GN_GBC_SRC' required for executing the TC ***");
                    setverdict(inconc);
                    stop;
                }
                
                // Test component configuration
                f_cf02Up();
                
                // Preamble
                
                // Start components
                v_nodeB := f_getComponent(c_compNodeB);
                v_nodeD := f_getComponent(c_compNodeD);
                v_nodeB.start(f_TC_SEC_ITSS_RCV_GENMSG_05_02_BO());
                v_nodeD.start(f_TC_SEC_ITSS_RCV_GENMSG_xxx_BO_nodeD());
                
                // Synchronization
                f_serverSync2ClientsAndStop({c_prDone, c_tbDone, c_poDone});
                
                // Cleanup
                f_cf02Down();
                
            } // End of testcase TC_SEC_ITSS_RCV_GENMSG_05_02_BO
            
            group g_TC_SEC_ITSS_RCV_GENMSG_05_02_BO {
                
                    /**
                     * @desc    Behavior function for NodeB (TC_GEONW_PON_GBC_BV_01)
                     */
                function f_TC_SEC_ITSS_RCV_GENMSG_05_02_BO() runs on ItsGeoNetworking {
                    
                    // Local variables
                    var GeoNetworkingPdu v_securedGnPdu;
                    var LongPosVector v_longPosVectorNodeB := f_getPosition(c_compNodeB); // Use NodeB
                    
                    //  Test component configuration
                    f_cf01Up();
                    
                    // Test adapter configuration
                    
                    // Preamble
                    f_prNeighbour();
                    f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                    
                    // Test Body
                    v_securedGnPdu := f_prepareSecuredBeacon(
                        cc_taCert_A, 
                        {
                            m_header_field_signer_info(
                                m_signerInfo_other_certificates(
                                    m_certificateWithAlgo_ecdsa(
                                        PX_OTHER_CERT_DIGEST
                            ))), 
                            m_header_field_generation_time(1000 * f_getCurrentTime()), // In us
                            m_header_field_generation_location(
                                valueof(m_threeDLocation(
                                    v_longPosVectorNodeB.latitude,
                                    v_longPosVectorNodeB.longitude,
                                    '0000'O
                                ))
                            ),
                            m_header_field_its_aid_Other
                        }, 
                        e_self,
                        false
                    ); 
                    f_sendGeoNetMessage(m_geoNwReq_linkLayerBroadcast(v_securedGnPdu));
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                    
                    // Postamble
                    f_selfOrClientSyncAndVerdict(c_poDone, e_success);
                    
                } // End of testcase f_TC_SEC_ITSS_RCV_GENMSG_05_02_BO
                
            } // End of group g_TC_SEC_ITSS_RCV_GENMSG_05_02_BO 
            
            /**
             * @desc    Check that IUT discards a secured GN Beacon if the header_fields contains a signer of type 'certificate_chain'
             * <pre>
             * Pics Selection: PICS_GN_SECURITY and PICS_GN_GBC_SRC
             * Config Id: CF01
             * Initial conditions:
             * with { 
             *    the IUT being in the 'authorized' state 
             *    and the IUT current time is inside the time validity period of CERT_TS_A_AT
             * } 
             * ensure that { 
             *  when { 
             *      the IUT is receiving a SecuredMessage ((MSG_SEC_RCV_GENMSG_A)) 
             *          containing header_fields['signer_info']
             *              containing signer.type
             *                  indicating 'certificate_chain'
             *  } then { 
             *      the IUT discards the message 
             *  } 
             * } 
             * </pre>
             *
             * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_RCV_GENMSG_05_03_BO
             * @reference    ETSI TS 103 097 [1], clause 7.1
             */
            testcase TC_SEC_ITSS_RCV_GENMSG_05_03_BO() runs on ItsMtc system ItsSecSystem {
                
                // Local variables
                var ItsGeoNetworking v_nodeB;
                var ItsGeoNetworking v_nodeD;
                
                // Test control
                if (not(PICS_GN_SECURITY) or not(PICS_GN_GBC_SRC)) {
                    log("*** " & testcasename() & ": 'PICS_GN_SECURITY' and PICS_GN_GBC_SRC' required for executing the TC ***");
                    setverdict(inconc);
                    stop;
                }
                
                // Test component configuration
                f_cf02Up();
                
                // Preamble
                
                // Start components
                v_nodeB := f_getComponent(c_compNodeB);
                v_nodeD := f_getComponent(c_compNodeD);
                v_nodeB.start(f_TC_SEC_ITSS_RCV_GENMSG_05_03_BO());
                v_nodeD.start(f_TC_SEC_ITSS_RCV_GENMSG_xxx_BO_nodeD());
                
                // Synchronization
                f_serverSync2ClientsAndStop({c_prDone, c_tbDone, c_poDone});
                
                // Cleanup
                f_cf02Down();
                
            } // End of testcase TC_SEC_ITSS_RCV_GENMSG_05_03_BO
            
            group g_TC_SEC_ITSS_RCV_GENMSG_05_03_BO {
                
                    /**
                     * @desc    Behavior function for NodeB (TC_GEONW_PON_GBC_BV_01)
                     */
                function f_TC_SEC_ITSS_RCV_GENMSG_05_03_BO() runs on ItsGeoNetworking {
                    
                    // Local variables
                    var GeoNetworkingPdu v_securedGnPdu;
                    var LongPosVector v_longPosVectorNodeB := f_getPosition(c_compNodeB); // Use NodeB
                    
                    //  Test component configuration
                    f_cf01Up();
                    
                    // Test adapter configuration
                    
                    // Preamble
                    f_prNeighbour();
                    f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                    
                    // Test Body
                    v_securedGnPdu := f_prepareSecuredBeacon(
                        cc_taCert_A, 
                        {
                            m_header_field_signer_info(
                                m_signerInfo_certificates(
                                    { vc_atCertificate }
                            )), 
                            m_header_field_generation_time(1000 * f_getCurrentTime()), // In us
                            m_header_field_generation_location(
                                valueof(m_threeDLocation(
                                    v_longPosVectorNodeB.latitude,
                                    v_longPosVectorNodeB.longitude,
                                    '0000'O
                                ))
                            ),
                            m_header_field_its_aid_Other
                        }, 
                        e_self,
                        false
                    ); 
                    f_sendGeoNetMessage(m_geoNwReq_linkLayerBroadcast(v_securedGnPdu));
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                    
                    // Postamble
                    f_selfOrClientSyncAndVerdict(c_poDone, e_success);
                    
                } // End of testcase f_TC_SEC_ITSS_RCV_GENMSG_05_03_BO
                
            } // End of group g_TC_SEC_ITSS_RCV_GENMSG_05_03_BO 
            
            /**
             * @desc    Check that IUT discards a secured GN Message containing generation_time before the message signing certificate validity period
             * <pre>
             * Pics Selection: PICS_GN_SECURITY and PICS_GN_GBC_SRC
             * Config Id: CF01
             * Initial conditions:
             * with { 
             *    the IUT being in the 'authorized' state 
             *    and the IUT current time is inside the time validity period of CERT_TS_A_AT
             * } 
             * ensure that { 
             *  when { 
             *      the IUT is receiving a SecuredMessage ((MSG_SEC_RCV_GENMSG_A)) 
             *          containing header_fields[0].type
             *              indicating 'signer_info'
             *                  containing certificate (CERT_TS_A_AT)
             *                      containing validity_restrictions['time_start_and_end']
             *                          containing start_validity
             *                              indicating TIME_CERT_TS_AT_START
             *                          and containing end_validity
             *                              indicating TIME_CERT_TS_E_ATND
             *                  and containing header_fields ['generation_time']
             *                      containing generation_time
             *                          indicating GEN_TIME < TIME_CERT_TS_AT_START
             *  } then { 
             *      the IUT discards the message 
             *  } 
             * } 
             * </pre>
             *
             * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_RCV_GENMSG_06_01_BO
             * @reference    ETSI TS 103 097 [1], clause 7.1
             */
            testcase TC_SEC_ITSS_RCV_GENMSG_06_01_BO() runs on ItsMtc system ItsSecSystem {
                
                // Local variables
                var ItsGeoNetworking v_nodeB;
                var ItsGeoNetworking v_nodeD;
                
                // Test control
                if (not(PICS_GN_SECURITY) or not(PICS_GN_GBC_SRC)) {
                    log("*** " & testcasename() & ": 'PICS_GN_SECURITY' and PICS_GN_GBC_SRC' required for executing the TC ***");
                    setverdict(inconc);
                    stop;
                }
                
                // Test component configuration
                f_cf02Up();
                
                // Preamble
                
                // Start components
                v_nodeB := f_getComponent(c_compNodeB);
                v_nodeD := f_getComponent(c_compNodeD);
                v_nodeB.start(f_TC_SEC_ITSS_RCV_GENMSG_06_01_BO());
                v_nodeD.start(f_TC_SEC_ITSS_RCV_GENMSG_xxx_BO_nodeD());
                
                // Synchronization
                f_serverSync2ClientsAndStop({c_prDone, c_tbDone, c_poDone});
                
                // Cleanup
                f_cf02Down();
                
            } // End of testcase TC_SEC_ITSS_RCV_GENMSG_06_01_BO
            
            group g_TC_SEC_ITSS_RCV_GENMSG_06_01_BO {
                
                    /**
                     * @desc    Behavior function for NodeB (TC_GEONW_PON_GBC_BV_01)
                     */
                function f_TC_SEC_ITSS_RCV_GENMSG_06_01_BO() runs on ItsGeoNetworking {
                    
                    // Local variables
                    var GeoNetworkingPdu v_securedGnPdu;
                    var LongPosVector v_longPosVectorNodeB := f_getPosition(c_compNodeB); // Use NodeB
                    
                    //  Test component configuration
                    f_cf01Up();
                    
                    // Test adapter configuration
                    
                    // Preamble
                    f_prNeighbour();
                    f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                    
                    // Test Body
                    v_securedGnPdu := f_prepareSecuredBeacon(
                        cc_taCert_A, 
                        {
                            m_header_field_signer_info(
                                m_signerInfo_digest(
                                    vc_atCertificate.signer_info.signerInfo.digest
                            )), 
                            m_header_field_generation_time( // TODO Try to refine access to the certificate validity_restrictions['time_start_and_end'] field access
                                (vc_atCertificate.signer_info.signerInfo.certificate.validity_restrictions[0].validity.time_start_and_end.start_validity - 3600) * 1000
                            ), // In us
                            m_header_field_generation_location(
                                valueof(m_threeDLocation(
                                    v_longPosVectorNodeB.latitude,
                                    v_longPosVectorNodeB.longitude,
                                    '0000'O
                                ))
                            ),
                            m_header_field_its_aid_Other
                        }, 
                        e_certificate_digest_with_sha256,
                        false
                    ); 
                    f_sendGeoNetMessage(m_geoNwReq_linkLayerBroadcast(v_securedGnPdu));
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                    
                    // Postamble
                    f_selfOrClientSyncAndVerdict(c_poDone, e_success);
                    
                } // End of testcase f_TC_SEC_ITSS_RCV_GENMSG_06_01_BO
                
            } // End of group g_TC_SEC_ITSS_RCV_GENMSG_06_01_BO 
            
            /**
             * @desc    Check that IUT discards the secured GN Message containing generation_time after the message signing certificate validity period
             * <pre>
             * Pics Selection: PICS_GN_SECURITY and PICS_GN_GBC_SRC
             * Config Id: CF01
             * Initial conditions:
             * with { 
             *    the IUT being in the 'authorized' state 
             *    and the IUT current time is inside the time validity period of CERT_TS_A_AT
             * } 
             * ensure that { 
             *  when { 
             *      the IUT is receiving a SecuredMessage ((MSG_SEC_RCV_GENMSG_A)) 
             *          containing header_fields[0].type
             *              indicating 'signer_info'
             *                  containing certificate (CERT_TS_A_AT)
             *                      containing validity_restrictions['time_start_and_end']
             *                          containing start_validity
             *                              indicating TIME_CERT_TS_AT_START
             *                          and containing end_validity
             *                              indicating TIME_CERT_TS_E_ATND
             *                  and containing header_fields ['generation_time']
             *                      containing generation_time
             *                          indicating GEN_TIME > TIME_CERT_TS_E_ATND
             *  } then { 
             *      the IUT discards the message 
             *  } 
             * } 
             * </pre>
             *
             * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_RCV_GENMSG_06_02_BO
             * @reference    ETSI TS 103 097 [1], clause 7.1
             */
            testcase TC_SEC_ITSS_RCV_GENMSG_06_02_BO() runs on ItsMtc system ItsSecSystem {
                
                // Local variables
                var ItsGeoNetworking v_nodeB;
                var ItsGeoNetworking v_nodeD;
                
                // Test control
                if (not(PICS_GN_SECURITY) or not(PICS_GN_GBC_SRC)) {
                    log("*** " & testcasename() & ": 'PICS_GN_SECURITY' and PICS_GN_GBC_SRC' required for executing the TC ***");
                    setverdict(inconc);
                    stop;
                }
                
                // Test component configuration
                f_cf02Up();
                
                // Preamble
                
                // Start components
                v_nodeB := f_getComponent(c_compNodeB);
                v_nodeD := f_getComponent(c_compNodeD);
                v_nodeB.start(f_TC_SEC_ITSS_RCV_GENMSG_06_02_BO());
                v_nodeD.start(f_TC_SEC_ITSS_RCV_GENMSG_xxx_BO_nodeD());
                
                // Synchronization
                f_serverSync2ClientsAndStop({c_prDone, c_tbDone, c_poDone});
                
                // Cleanup
                f_cf02Down();
                
            } // End of testcase TC_SEC_ITSS_RCV_GENMSG_06_02_BO
            
            group g_TC_SEC_ITSS_RCV_GENMSG_06_02_BO {
                
                    /**
                     * @desc    Behavior function for NodeB (TC_GEONW_PON_GBC_BV_01)
                     */
                function f_TC_SEC_ITSS_RCV_GENMSG_06_02_BO() runs on ItsGeoNetworking {
                    
                    // Local variables
                    var GeoNetworkingPdu v_securedGnPdu;
                    var LongPosVector v_longPosVectorNodeB := f_getPosition(c_compNodeB); // Use NodeB
                    
                    //  Test component configuration
                    f_cf01Up();
                    
                    // Test adapter configuration
                    
                    // Preamble
                    f_prNeighbour();
                    f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                    
                    // Test Body
                    v_securedGnPdu := f_prepareSecuredBeacon(
                        cc_taCert_A, 
                        {
                            m_header_field_signer_info(
                                m_signerInfo_digest(
                                    vc_atCertificate.signer_info.signerInfo.digest
                            )), 
                            m_header_field_generation_time( // TODO Try to refine access to the certificate validity_restrictions['time_start_and_end'] field access
                                (vc_atCertificate.signer_info.signerInfo.certificate.validity_restrictions[0].validity.time_start_and_end.end_validity + 3600) * 1000
                            ), // In us
                            m_header_field_generation_location(
                                valueof(m_threeDLocation(
                                    v_longPosVectorNodeB.latitude,
                                    v_longPosVectorNodeB.longitude,
                                    '0000'O
                                ))
                            ),
                            m_header_field_its_aid_Other
                        }, 
                        e_certificate_digest_with_sha256,
                        false
                    ); 
                    f_sendGeoNetMessage(m_geoNwReq_linkLayerBroadcast(v_securedGnPdu));
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                    
                    // Postamble
                    f_selfOrClientSyncAndVerdict(c_poDone, e_success);
                    
                } // End of testcase f_TC_SEC_ITSS_RCV_GENMSG_06_02_BO
                
            } // End of group g_TC_SEC_ITSS_RCV_GENMSG_06_02_BO 
            
            /**
             * @desc    Check that IUT discards Secured GN Message if the HeaderField generation_location is outside of the circular validity region of the signing certificate
             * <pre>
             * Pics Selection: PICS_GN_SECURITY and PICS_GN_GBC_SRC
             * Config Id: CF01
             * Initial conditions:
             * with { 
             *    the IUT being in the 'authorized' state 
             *    and the IUT current time is inside the time validity period of CERT_TS_B_AT
             *    and the IUT current location is inside the validiti region of CERT_TS_B_AT
             * } 
             * ensure that { 
             *  when { 
             *      the IUT is receiving a SecuredMessage ((MSG_SEC_RCV_GENMSG_B)) 
             *          containing header_fields[0].type
             *              indicating 'signer_info'
             *                  containing certificate (CERT_TS_B_AT)
             *                      containing validity_restrictions ['region']
             *                          containing region
             *                              containing region_type
             *                                  indicating 'circle'
             *                              and containing circular_region
             *                                  indicating REGION
             *          and containing header_fields ['generation_location']
             *              indicating location outside of the REGION
             *  } then { 
             *      the IUT discards the message 
             *  } 
             * } 
             * </pre>
             *
             * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_RCV_GENMSG_08_01_BO
             * @reference    ETSI TS 103 097 [1], clause 7.1
             */
            testcase TC_SEC_ITSS_RCV_GENMSG_08_01_BO() runs on ItsMtc system ItsSecSystem {
                
                // Local variables
                var ItsGeoNetworking v_nodeB;
                var ItsGeoNetworking v_nodeD;
                
                // Test control
                if (not(PICS_GN_SECURITY) or not(PICS_GN_GBC_SRC)) {
                    log("*** " & testcasename() & ": 'PICS_GN_SECURITY' and PICS_GN_GBC_SRC' required for executing the TC ***");
                    setverdict(inconc);
                    stop;
                }
                
                // Test component configuration
                f_cf02Up();
                
                // Preamble
                
                // Start components
                v_nodeB := f_getComponent(c_compNodeB);
                v_nodeD := f_getComponent(c_compNodeD);
                v_nodeB.start(f_TC_SEC_ITSS_RCV_GENMSG_08_xx_BO(cc_taCert_B));
                v_nodeD.start(f_TC_SEC_ITSS_RCV_GENMSG_xxx_BO_nodeD());
                
                // Synchronization
                f_serverSync2ClientsAndStop({c_prDone, c_tbDone, c_poDone});
                
                // Cleanup
                f_cf02Down();
                
            } // End of testcase TC_SEC_ITSS_RCV_GENMSG_08_01_BO
            
            /**
             * @desc    Check that IUT discards Secured GN Message if the HeaderField generation_location is outside of the rectangular validity region of the signing certificate
             * <pre>
             * Pics Selection: PICS_GN_SECURITY and PICS_GN_GBC_SRC
             * Config Id: CF01
             * Initial conditions:
             * with { 
             *    the IUT being in the 'authorized' state 
             *    and the IUT current time is inside the time validity period of CERT_TS_C_AT
             *    and the IUT current location is inside the validiti region of CERT_TS_C_AT
             * } 
             * ensure that { 
             *  when { 
             *      the IUT is receiving a SecuredMessage ((MSG_SEC_RCV_GENMSG_C)) 
             *          containing header_fields[0].type
             *              indicating 'signer_info'
             *                  containing certificate (CERT_TS_C_AT)
             *                      containing validity_restrictions ['region']
             *                          containing region
             *                              containing region_type
             *                                  indicating 'rectangle'
             *                              and containing rectanglar_region
             *                                  indicating REGION
             *          and containing header_fields ['generation_location']
             *              indicating location outside of the REGION
             *  } then { 
             *      the IUT discards the message 
             *  } 
             * } 
             * </pre>
             *
             * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_RCV_GENMSG_08_02_BO
             * @reference    ETSI TS 103 097 [1], clause 7.1
             */
            testcase TC_SEC_ITSS_RCV_GENMSG_08_02_BO() runs on ItsMtc system ItsSecSystem {
                
                // Local variables
                var ItsGeoNetworking v_nodeB;
                var ItsGeoNetworking v_nodeD;
                
                // Test control
                if (not(PICS_GN_SECURITY) or not(PICS_GN_GBC_SRC)) {
                    log("*** " & testcasename() & ": 'PICS_GN_SECURITY' and PICS_GN_GBC_SRC' required for executing the TC ***");
                    setverdict(inconc);
                    stop;
                }
                
                // Test component configuration
                f_cf02Up();
                
                // Preamble
                
                // Start components
                v_nodeB := f_getComponent(c_compNodeB);
                v_nodeD := f_getComponent(c_compNodeD);
                v_nodeB.start(f_TC_SEC_ITSS_RCV_GENMSG_08_xx_BO(cc_taCert_C));
                v_nodeD.start(f_TC_SEC_ITSS_RCV_GENMSG_xxx_BO_nodeD());
                
                // Synchronization
                f_serverSync2ClientsAndStop({c_prDone, c_tbDone, c_poDone});
                
                // Cleanup
                f_cf02Down();
                
            } // End of testcase TC_SEC_ITSS_RCV_GENMSG_08_02_BO
            
            /**
             * @desc    Check that IUT discards Secured GN Message if the HeaderField generation_location is outside of the rectangular validity region of the signing certificate
             * <pre>
             * Pics Selection: PICS_GN_SECURITY and PICS_GN_GBC_SRC
             * Config Id: CF01
             * Initial conditions:
             * with { 
             *    the IUT being in the 'authorized' state 
             *    and the IUT current time is inside the time validity period of CERT_TS_D_AT
             *    and the IUT current location is inside the validiti region of CERT_TS_D_AT
             * } 
             * ensure that { 
             *  when { 
             *      the IUT is receiving a SecuredMessage ((MSG_SEC_RCV_GENMSG_D)) 
             *          containing header_fields[0].type
             *              indicating 'signer_info'
             *                  containing certificate (CERT_TS_D_AT)
             *                      containing validity_restrictions ['region']
             *                          containing region
             *                              containing region_type
             *                                  indicating 'polygon'
             *                              and containing polygonal_region
             *                                  indicating REGION
             *          and containing header_fields ['generation_location']
             *              indicating location outside of the REGION
             *  } then { 
             *      the IUT discards the message 
             *  } 
             * } 
             * </pre>
             *
             * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_RCV_GENMSG_08_03_BO
             * @reference    ETSI TS 103 097 [1], clause 7.1
             */
            testcase TC_SEC_ITSS_RCV_GENMSG_08_03_BO() runs on ItsMtc system ItsSecSystem {
                
                // Local variables
                var ItsGeoNetworking v_nodeB;
                var ItsGeoNetworking v_nodeD;
                
                // Test control
                if (not(PICS_GN_SECURITY) or not(PICS_GN_GBC_SRC)) {
                    log("*** " & testcasename() & ": 'PICS_GN_SECURITY' and PICS_GN_GBC_SRC' required for executing the TC ***");
                    setverdict(inconc);
                    stop;
                }
                
                // Test component configuration
                f_cf02Up();
                
                // Preamble
                
                // Start components
                v_nodeB := f_getComponent(c_compNodeB);
                v_nodeD := f_getComponent(c_compNodeD);
                v_nodeB.start(f_TC_SEC_ITSS_RCV_GENMSG_08_xx_BO(cc_taCert_D));
                v_nodeD.start(f_TC_SEC_ITSS_RCV_GENMSG_xxx_BO_nodeD());
                
                // Synchronization
                f_serverSync2ClientsAndStop({c_prDone, c_tbDone, c_poDone});
                
                // Cleanup
                f_cf02Down();
                
            } // End of testcase TC_SEC_ITSS_RCV_GENMSG_08_03_BO
            
            /**
             * @desc    Check that IUT discards Secured GN Message if the optional HeaderField generation_location is outside of the identified validity region of the signing certificate
             * <pre>
             * Pics Selection: PICS_GN_SECURITY and PICS_GN_GBC_SRC
             * Config Id: CF01
             * Initial conditions:
             * with { 
             *    the IUT being in the 'authorized' state 
             *    and the IUT current time is inside the time validity period of CERT_TS_E_AT
             *    and the IUT current location is inside the validiti region of CERT_TS_E_AT
             * } 
             * ensure that { 
             *  when { 
             *      the IUT is receiving a SecuredMessage ((MSG_SEC_RCV_GENMSG_E)) 
             *          containing header_fields[0].type
             *              indicating 'signer_info'
             *                  containing certificate (CERT_TS_E_AT)
             *                      containing validity_restrictions ['region']
             *                          containing region
             *                              containing region_type
             *                                  indicating 'id_region'
             *                              and containing identified_region
             *                                  indicating REGION
             *          and containing header_fields ['generation_location']
             *              indicating location outside of the REGION
             *  } then { 
             *      the IUT discards the message 
             *  } 
             * } 
             * </pre>
             *
             * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_RCV_GENMSG_08_04_BO
             * @reference    ETSI TS 103 097 [1], clause 7.1
             */
            testcase TC_SEC_ITSS_RCV_GENMSG_08_04_BO() runs on ItsMtc system ItsSecSystem {
                
                // Local variables
                var ItsGeoNetworking v_nodeB;
                var ItsGeoNetworking v_nodeD;
                
                // Test control
                if (not(PICS_GN_SECURITY) or not(PICS_GN_GBC_SRC)) {
                    log("*** " & testcasename() & ": 'PICS_GN_SECURITY' and PICS_GN_GBC_SRC' required for executing the TC ***");
                    setverdict(inconc);
                    stop;
                }
                
                // Test component configuration
                f_cf02Up();
                
                // Preamble
                
                // Start components
                v_nodeB := f_getComponent(c_compNodeB);
                v_nodeD := f_getComponent(c_compNodeD);
                v_nodeB.start(f_TC_SEC_ITSS_RCV_GENMSG_08_xx_BO(cc_taCert_E));
                v_nodeD.start(f_TC_SEC_ITSS_RCV_GENMSG_xxx_BO_nodeD());
                
                // Synchronization
                f_serverSync2ClientsAndStop({c_prDone, c_tbDone, c_poDone});
                
                // Cleanup
                f_cf02Down();
                
            } // End of testcase TC_SEC_ITSS_RCV_GENMSG_08_04_BO
            
            group g_TC_SEC_ITSS_RCV_GENMSG_08_xx_BO {
                
                    /**
                     * @desc    Behavior function for NodeB (TC_GEONW_PON_GBC_BV_01)
                     */
                function f_TC_SEC_ITSS_RCV_GENMSG_08_xx_BO(
                                                           in charstring p_taCert
                ) runs on ItsGeoNetworking {
                    
                    // Local variables
                    var GeoNetworkingPdu v_securedGnPdu;
                    var LongPosVector v_longPosVectorNodeB := f_getPosition(c_compNodeB); // Use NodeB
                    
                    //  Test component configuration
                    f_cf01Up();
                    
                    // Test adapter configuration
                    
                    // Preamble
                    f_prNeighbour();
                    f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                    
                    // Test Body
                    v_securedGnPdu := f_prepareSecuredBeacon(
                        p_taCert, 
                        {
                            m_header_field_signer_info(
                                m_signerInfo_digest(
                                    vc_atCertificate.signer_info.signerInfo.digest
                            )), 
                            m_header_field_generation_time(1000 * f_getCurrentTime()), // In us
                            m_header_field_generation_location(
                                valueof(m_threeDLocation(
                                    PX_WGSLATITUDE,
                                    PX_WGSLONGITUDE,
                                    '0000'O
                                ))
                            ),
                            m_header_field_its_aid_Other
                        }, 
                        e_certificate_digest_with_sha256,
                        false
                    ); 
                    f_sendGeoNetMessage(m_geoNwReq_linkLayerBroadcast(v_securedGnPdu));
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                    
                    // Postamble
                    f_selfOrClientSyncAndVerdict(c_poDone, e_success);
                    
                } // End of testcase f_TC_SEC_ITSS_RCV_GENMSG_08_xx_BO
                
            } // End of group g_TC_SEC_ITSS_RCV_GENMSG_08_xx_BO 
            
            /**
             * @desc    Check that IUT discards the Secured GN Message containing empty payload of type 'signed'
             * <pre>
             * Pics Selection: PICS_GN_SECURITY and PICS_GN_GBC_SRC
             * Config Id: CF01
             * Initial conditions:
             * with { 
             *    the IUT being in the 'authorized' state 
             *    and the IUT current time is inside the time validity period of CERT_TS_A_AT
             * } 
             * ensure that { 
             *  when { 
             *      the IUT is receiving a SecuredMessage ((MSG_SEC_RCV_GENMSG_A)) 
             *          containing payload_field
             *              containing type
             *                  indicating 'signed'
             *              and containing data
             *                  indicating length 0
             *  } then { 
             *      the IUT discards the message 
             *  } 
             * } 
             * </pre>
             *
             * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_RCV_GENMSG_09_02_BO
             * @reference    ETSI TS 103 097 [1], clause 7.1
             */
            testcase TC_SEC_ITSS_RCV_GENMSG_09_02_BO() runs on ItsMtc system ItsSecSystem {
                
                // Local variables
                var ItsGeoNetworking v_nodeB;
                var ItsGeoNetworking v_nodeD;
                
                // Test control
                if (not(PICS_GN_SECURITY) or not(PICS_GN_GBC_SRC)) {
                    log("*** " & testcasename() & ": 'PICS_GN_SECURITY' and PICS_GN_GBC_SRC' required for executing the TC ***");
                    setverdict(inconc);
                    stop;
                }
                
                // Test component configuration
                f_cf02Up();
                
                // Preamble
                
                // Start components
                v_nodeB := f_getComponent(c_compNodeB);
                v_nodeD := f_getComponent(c_compNodeD);
                v_nodeB.start(f_TC_SEC_ITSS_RCV_GENMSG_09_02_BO());
                v_nodeD.start(f_TC_SEC_ITSS_RCV_GENMSG_xxx_BO_nodeD());
                
                // Synchronization
                f_serverSync2ClientsAndStop({c_prDone, c_tbDone, c_poDone});
                
                // Cleanup
                f_cf02Down();
                
            } // End of testcase TC_SEC_ITSS_RCV_GENMSG_09_02_BO
            
            group g_TC_SEC_ITSS_RCV_GENMSG_09_02_BO {
                
                    /**
                     * @desc    Behavior function for NodeB (TC_GEONW_PON_GBC_BV_01)
                     */
                function f_TC_SEC_ITSS_RCV_GENMSG_09_02_BO() runs on ItsGeoNetworking {
                    
                    // Local variables
                    var GnNonSecuredPacket v_gnNonSecuredPacket;
                    var octetstring v_gnPayload;
                    var LongPosVector v_longPosVectorNodeB := f_getPosition(c_compNodeB); // Use NodeB
                    var template (value) SecuredMessage v_securedMessage;
                    var GeoNetworkingPdu v_securedGnPdu;
                    
                    //  Test component configuration
                    f_cf01Up();
                    
                    // Test adapter configuration
                    
                    // Preamble
                    f_prNeighbour();
                    f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                    
                    // Test Body
                    v_gnNonSecuredPacket := valueof(
                        m_geoNwBroadcastPacket(
                            v_longPosVectorNodeB,
                            vc_localSeqNumber,
                            f_getGeoBroadcastArea(
                                c_area1                 // Select area1 (see ETSI TS 102 871-2 Clause 4.2 Configuration 1)
                    )));
                    
                    // Encode it
                    v_gnPayload := bit2oct(
                        encvalue(
                            v_gnNonSecuredPacket
                        )
                    );
                    f_buildGnSecuredOtherMessage(
                        v_securedMessage,
                        m_payload_signed(
                            ''O
                        ),
                        e_certificate_digest_with_sha256,
                        valueof(m_threeDLocation(
                            v_longPosVectorNodeB.latitude,
                            v_longPosVectorNodeB.longitude,
                            '0000'O
                        ))
                    );
                    v_securedGnPdu := valueof(m_geoNwSecPdu(v_gnNonSecuredPacket, v_securedMessage));
                    f_sendGeoNetMessage(m_geoNwReq_linkLayerBroadcast(v_securedGnPdu));
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                    
                    // Postamble
                    f_selfOrClientSyncAndVerdict(c_poDone, e_success);
                    
                } // End of testcase f_TC_SEC_ITSS_RCV_GENMSG_09_02_BO
                
            } // End of group g_TC_SEC_ITSS_RCV_GENMSG_09_02_BO 
            
            /**
             * @desc    Check that IUT discards the Secured GN Message containing payload element of type 'unsecured'
             * <pre>
             * Pics Selection: PICS_GN_SECURITY and PICS_GN_GBC_SRC
             * Config Id: CF01
             * Initial conditions:
             * with { 
             *    the IUT being in the 'authorized' state 
             *    and the IUT current time is inside the time validity period of CERT_TS_A_AT
             * } 
             * ensure that { 
             *  when { 
             *      the IUT is receiving a SecuredMessage ((MSG_SEC_RCV_GENMSG_A)) 
             *          containing payload_field
             *              containing type
             *                  indicating 'unsecured'
             *              and containing data
             *                  indicating length > 0
             *  } then { 
             *      the IUT discards the message 
             *  } 
             * } 
             * </pre>
             *
             * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_RCV_GENMSG_09_03_BO
             * @reference    ETSI TS 103 097 [1], clause 7.1
             */
            testcase TC_SEC_ITSS_RCV_GENMSG_09_03_BO() runs on ItsMtc system ItsSecSystem {
                
                // Local variables
                var ItsGeoNetworking v_nodeB;
                var ItsGeoNetworking v_nodeD;
                
                // Test control
                if (not(PICS_GN_SECURITY) or not(PICS_GN_GBC_SRC)) {
                    log("*** " & testcasename() & ": 'PICS_GN_SECURITY' and PICS_GN_GBC_SRC' required for executing the TC ***");
                    setverdict(inconc);
                    stop;
                }
                
                // Test component configuration
                f_cf02Up();
                
                // Preamble
                
                // Start components
                v_nodeB := f_getComponent(c_compNodeB);
                v_nodeD := f_getComponent(c_compNodeD);
                v_nodeB.start(f_TC_SEC_ITSS_RCV_GENMSG_09_03_BO());
                v_nodeD.start(f_TC_SEC_ITSS_RCV_GENMSG_xxx_BO_nodeD());
                
                // Synchronization
                f_serverSync2ClientsAndStop({c_prDone, c_tbDone, c_poDone});
                
                // Cleanup
                f_cf02Down();
                
            } // End of testcase TC_SEC_ITSS_RCV_GENMSG_09_03_BO
            
            group g_TC_SEC_ITSS_RCV_GENMSG_09_03_BO {
                
                    /**
                     * @desc    Behavior function for NodeB (TC_GEONW_PON_GBC_BV_01)
                     */
                function f_TC_SEC_ITSS_RCV_GENMSG_09_03_BO() runs on ItsGeoNetworking {
                    
                    // Local variables
                    var GnNonSecuredPacket v_gnNonSecuredPacket;
                    var octetstring v_gnPayload;
                    var LongPosVector v_longPosVectorNodeB := f_getPosition(c_compNodeB); // Use NodeB
                    var template (value) SecuredMessage v_securedMessage;
                    var GeoNetworkingPdu v_securedGnPdu;
                    
                    //  Test component configuration
                    f_cf01Up();
                    
                    // Test adapter configuration
                    
                    // Preamble
                    f_prNeighbour();
                    f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                    
                    // Test Body
                    v_gnNonSecuredPacket := valueof(
                        m_geoNwBroadcastPacket(
                            v_longPosVectorNodeB,
                            vc_localSeqNumber,
                            f_getGeoBroadcastArea(
                                c_area1                 // Select area1 (see ETSI TS 102 871-2 Clause 4.2 Configuration 1)
                    )));
                    
                    // Encode it
                    v_gnPayload := bit2oct(
                        encvalue(
                            v_gnNonSecuredPacket
                        )
                    );
                    f_buildGnSecuredOtherMessage(
                        v_securedMessage,
                            m_payload_unsecured(
                                v_gnPayload
                        ),
                        e_certificate_digest_with_sha256,
                        valueof(m_threeDLocation(
                            v_longPosVectorNodeB.latitude,
                            v_longPosVectorNodeB.longitude,
                            '0000'O
                        ))
                    );
                    v_securedGnPdu := valueof(m_geoNwSecPdu(v_gnNonSecuredPacket, v_securedMessage));
                    f_sendGeoNetMessage(m_geoNwReq_linkLayerBroadcast(v_securedGnPdu));
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                    
                    // Postamble
                    f_selfOrClientSyncAndVerdict(c_poDone, e_success);
                    
                } // End of testcase f_TC_SEC_ITSS_RCV_GENMSG_09_03_BO
                
            } // End of group g_TC_SEC_ITSS_RCV_GENMSG_09_03_BO 
            
            /**
             * @desc    Check that IUT discards the Secured GN Message containing payload element of type 'encrypted'
             * <pre>
             * Pics Selection: PICS_GN_SECURITY and PICS_GN_GBC_SRC
             * Config Id: CF01
             * Initial conditions:
             * with { 
             *    the IUT being in the 'authorized' state 
             *    and the IUT current time is inside the time validity period of CERT_TS_A_AT
             * } 
             * ensure that { 
             *  when { 
             *      the IUT is receiving a SecuredMessage ((MSG_SEC_RCV_GENMSG_A)) 
             *          containing payload_field
             *              containing type
             *                  indicating 'encrypted'
             *              and containing data
             *                  indicating length > 0
             *  } then { 
             *      the IUT discards the message 
             *  } 
             * } 
             * </pre>
             *
             * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_RCV_GENMSG_09_04_BO
             * @reference    ETSI TS 103 097 [1], clause 7.1
             */
            testcase TC_SEC_ITSS_RCV_GENMSG_09_04_BO() runs on ItsMtc system ItsSecSystem {
                
                // Local variables
                var ItsGeoNetworking v_nodeB;
                var ItsGeoNetworking v_nodeD;
                
                // Test control
                if (not(PICS_GN_SECURITY) or not(PICS_GN_GBC_SRC)) {
                    log("*** " & testcasename() & ": 'PICS_GN_SECURITY' and PICS_GN_GBC_SRC' required for executing the TC ***");
                    setverdict(inconc);
                    stop;
                }
                
                // Test component configuration
                f_cf02Up();
                
                // Preamble
                
                // Start components
                v_nodeB := f_getComponent(c_compNodeB);
                v_nodeD := f_getComponent(c_compNodeD);
                v_nodeB.start(f_TC_SEC_ITSS_RCV_GENMSG_09_04_BO());
                v_nodeD.start(f_TC_SEC_ITSS_RCV_GENMSG_xxx_BO_nodeD());
                
                // Synchronization
                f_serverSync2ClientsAndStop({c_prDone, c_tbDone, c_poDone});
                
                // Cleanup
                f_cf02Down();
                
            } // End of testcase TC_SEC_ITSS_RCV_GENMSG_09_04_BO
            
            group g_TC_SEC_ITSS_RCV_GENMSG_09_04_BO {
                
                    /**
                     * @desc    Behavior function for NodeB (TC_GEONW_PON_GBC_BV_01)
                     */
                function f_TC_SEC_ITSS_RCV_GENMSG_09_04_BO() runs on ItsGeoNetworking {
                    
                    // Local variables
                    var GnNonSecuredPacket v_gnNonSecuredPacket;
                    var octetstring v_gnPayload;
                    var LongPosVector v_longPosVectorNodeB := f_getPosition(c_compNodeB); // Use NodeB
                    var template (value) SecuredMessage v_securedMessage;
                    var GeoNetworkingPdu v_securedGnPdu;
                    
                    //  Test component configuration
                    f_cf01Up();
                    
                    // Test adapter configuration
                    
                    // Preamble
                    f_prNeighbour();
                    f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                    
                    // Test Body
                    v_gnNonSecuredPacket := valueof(
                        m_geoNwBroadcastPacket(
                            v_longPosVectorNodeB,
                            vc_localSeqNumber,
                            f_getGeoBroadcastArea(
                                c_area1                 // Select area1 (see ETSI TS 102 871-2 Clause 4.2 Configuration 1)
                    )));
                    
                    // Encode it
                    v_gnPayload := bit2oct(
                        encvalue(
                            v_gnNonSecuredPacket
                        )
                    );
                    f_buildGnSecuredOtherMessage(
                        v_securedMessage,
                            m_payload_encrypted(
                                v_gnPayload
                        ),
                        e_certificate_digest_with_sha256,
                        valueof(m_threeDLocation(
                            v_longPosVectorNodeB.latitude,
                            v_longPosVectorNodeB.longitude,
                            '0000'O
                        ))
                    );
                    v_securedGnPdu := valueof(m_geoNwSecPdu(v_gnNonSecuredPacket, v_securedMessage));
                    f_sendGeoNetMessage(m_geoNwReq_linkLayerBroadcast(v_securedGnPdu));
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                    
                    // Postamble
                    f_selfOrClientSyncAndVerdict(c_poDone, e_success);
                    
                } // End of testcase f_TC_SEC_ITSS_RCV_GENMSG_09_04_BO
                
            } // End of group g_TC_SEC_ITSS_RCV_GENMSG_09_04_BO 
            
            /**
             * @desc    Check that IUT discards the Secured GN Message if the message does not contain the trailer field of type 'signature' 
             * <pre>
             * Pics Selection: PICS_GN_SECURITY and PICS_GN_GBC_SRC
             * Config Id: CF01
             * Expected behavior:
             * with {
             *   the IUT being in the 'authorized' state
             *   and the IUT current time is inside the time validity period of CERT_TS_A_AT
             * }
             * ensure that {
             *   when {
             *     the IUT is receiving a SecuredMessage
             *         containing trailer_fields
             *             not containing trailer_fields['signature']
             *   } then {
             *     the IUT discards the message
             *   }
             * }
             * </pre>
             * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_RCV_GENMSG_10_01_BO
             * @reference    ETSI TS 103 097 [1], clause 7.2
             */
            testcase TC_SEC_ITSS_RCV_GENMSG_10_01_BO() runs on ItsMtc system ItsSecSystem {
                
                // Local variables
                var ItsGeoNetworking v_nodeB;
                var ItsGeoNetworking v_nodeD;
                
                // Test control
                if (not(PICS_GN_SECURITY) or not(PICS_GN_GBC_SRC)) {
                    log("*** " & testcasename() & ": 'PICS_GN_SECURITY' and PICS_GN_GBC_SRC' required for executing the TC ***");
                    setverdict(inconc);
                    stop;
                }
                
                // Test component configuration
                f_cf02Up();
                
                // Preamble
                
                // Start components
                v_nodeB := f_getComponent(c_compNodeB);
                v_nodeD := f_getComponent(c_compNodeD);
                v_nodeB.start(f_TC_SEC_ITSS_RCV_GENMSG_10_0x_BO_nodeB(0));
                v_nodeD.start(f_TC_SEC_ITSS_RCV_GENMSG_xxx_BO_nodeD());
                
                // Synchronization
                f_serverSync2ClientsAndStop({c_prDone, c_tbDone, c_poDone});
                
                // Cleanup
                f_cf02Down();
                
            } // End of testcase TC_SEC_ITSS_RCV_GENMSG_10_01_BO
            
            /**
             * @desc    Check that IUT discards the Secured GN Message containing more than one instance of TrailerField of type 'signature'
             * <pre>
             * Pics Selection: PICS_GN_SECURITY and PICS_GN_GBC_SRC
             * Config Id: CF01
             * Expected behavior:
             * with {
             *   the IUT being in the 'authorized' state
             *   and the IUT current time is inside the time validity period of CERT_TS_A_AT
             * }
             * ensure that {
             *   when {
             *     the IUT is receiving a SecuredMessage
             *         containing trailer_fields[0]
             *             containing type
             *                 indicating 'signature'
             *             and containing trailer_fields[1]
             *                 containing type
             *                     indicating 'signature'
             *   } then {
             *     the IUT discards the message
             *   }
             * }
             * </pre>
             * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_RCV_GENMSG_10_02_BO
             * @reference    ETSI TS 103 097 [1], clause 7.2
             */
            testcase TC_SEC_ITSS_RCV_GENMSG_10_02_BO() runs on ItsMtc system ItsSecSystem {
                
                // Local variables
                var ItsGeoNetworking v_nodeB;
                var ItsGeoNetworking v_nodeD;
                
                // Test control
                if (not(PICS_GN_SECURITY) or not(PICS_GN_GBC_SRC)) {
                    log("*** " & testcasename() & ": 'PICS_GN_SECURITY' and PICS_GN_GBC_SRC' required for executing the TC ***");
                    setverdict(inconc);
                    stop;
                }
                
                // Test component configuration
                f_cf02Up();
                
                // Preamble
                
                // Start components
                v_nodeB := f_getComponent(c_compNodeB);
                v_nodeD := f_getComponent(c_compNodeD);
                v_nodeB.start(f_TC_SEC_ITSS_RCV_GENMSG_10_0x_BO_nodeB(2));
                v_nodeD.start(f_TC_SEC_ITSS_RCV_GENMSG_xxx_BO_nodeD());
                
                // Synchronization
                f_serverSync2ClientsAndStop({c_prDone, c_tbDone, c_poDone});
                
                // Cleanup
                f_cf02Down();
                
            } // End of testcase TC_SEC_ITSS_RCV_GENMSG_10_02_BO
            
            group g_TC_SEC_ITSS_RCV_GENMSG_10_0x_BO {
                
                /**
                 * @desc    Behavior function for NodeB (TC_GEONW_PON_GBC_BV_01)
                 */
                function f_TC_SEC_ITSS_RCV_GENMSG_10_0x_BO_nodeB(
                                                                 in integer p_trailerStatus
                ) runs on ItsGeoNetworking {
                    
                    // Local variables
                    var GeoNetworkingPdu v_securedGnPdu;
                    
                    // Preamble
                    f_selfOrClientSyncAndVerdict(c_prDone, e_success);
                    
                    // Test Body
                    v_securedGnPdu := f_sendSecuredBeacon_Bo(cc_taCert_A, -, p_trailerStatus);
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                    
                    // Postamble
                    f_selfOrClientSyncAndVerdict(c_poDone, e_success);
                    
                } // End of function f_TC_SEC_ITSS_RCV_GENMSG_10_0x_BO_nodeB
                
            } // End of group g_TC_SEC_ITSS_RCV_GENMSG_10_0x_BV
            
            /**
             * @desc    Check that the IUT discards Secured GN Message containing signature that is not verified using the verification key from the certificate contained in the message's signer info
             * <pre>
             * Pics Selection: PICS_GN_SECURITY and PICS_GN_GBC_SRC
             * Config Id: CF01
             * Expected behavior:
             * with {
             *   the IUT being in the 'authorized' state
             *   and the IUT current time is inside the time validity period of CERT_TS_A_AT
             * }
             * ensure that {
             *   when {
             *       the IUT is receiving a SecuredMessage
            *            the IUT is receiving a SecuredMessage ((MSG_SEC_RCV_GENMSG_A))
            *                containing header_fields ['signer_info']
            *                    containing certificate
            *                        containing subject_attributes['verification key'] 
            *                            containing key (KEY)
            *                and containing trailer_fields[0]
            *                    containing type
            *                        indicating 'signature'
            *                    and containing signature
            *                        NOT verifiable using KEY
             *   } then {
             *       the IUT discards the message
             *   }
             * }
             * </pre>
             * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_RCV_GENMSG_11_01_BO
             * @reference    ETSI TS 103 097 [1], clause 7.2
             */
            testcase TC_SEC_ITSS_RCV_GENMSG_11_01_BO() runs on ItsMtc system ItsSecSystem {
                
                // Local variables
                var ItsGeoNetworking v_nodeB;
                var ItsGeoNetworking v_nodeD;
                
                // Test control
                if (not(PICS_GN_SECURITY) or not(PICS_GN_GBC_SRC)) {
                    log("*** " & testcasename() & ": 'PICS_GN_SECURITY' and PICS_GN_GBC_SRC' required for executing the TC ***");
                    setverdict(inconc);
                    stop;
                }
                
                // Test component configuration
                f_cf02Up();
                
                // Preamble
                
                // Start components
                v_nodeB := f_getComponent(c_compNodeB);
                v_nodeD := f_getComponent(c_compNodeD);
                v_nodeB.start(f_TC_SEC_ITSS_RCV_GENMSG_11_0x_BO_nodeB());
                v_nodeD.start(f_TC_SEC_ITSS_RCV_GENMSG_xxx_BO_nodeD());
                
                // Synchronization
                f_serverSync2ClientsAndStop({c_prDone, c_tbDone, c_poDone});
                
                // Cleanup
                f_cf02Down();
                
            } // End of testcase TC_SEC_ITSS_RCV_GENMSG_11_01_BO
            
            group g_TC_SEC_ITSS_RCV_GENMSG_11_0x_BO {
                
                /**
                 * @desc    Behavior function for NodeB (TC_GEONW_PON_GBC_BV_01)
                 */
                function f_TC_SEC_ITSS_RCV_GENMSG_11_0x_BO_nodeB() runs on ItsGeoNetworking {
                    
                    // Local variables
                    var GeoNetworkingPdu v_securedGnPdu;
                    
                    // Preamble
                    f_selfOrClientSyncAndVerdict(c_prDone, e_success);
                    
                    // Test Body
                    v_securedGnPdu := f_sendSecuredBeacon_Bo(
                        cc_taCert_A, 
                        -, 
                        1, 
                        -, 
                        e_certificate
                    );
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                    
                    // Postamble
                    f_selfOrClientSyncAndVerdict(c_poDone, e_success);
                    
                } // End of function f_TC_SEC_ITSS_RCV_GENMSG_11_0x_BO_nodeB
                
            } // End of group g_TC_SEC_ITSS_RCV_GENMSG_11_0x_BV
            
            /**
             * @desc    Check that IUT discards a Secured GN Message if the signer certificate of the message contains the subject type 'enrolment_credential'
             * <pre>
             * Pics Selection: PICS_GN_SECURITY and PICS_GN_GBC_SRC
             * Config Id: CF01
             * Expected behavior:
             * with {
             *   the IUT being in the 'authorized' state
             *   and the IUT current time is inside the time validity period of CERT_TS_A_AT
             * }
             * ensure that {
             *   when {
             *       the IUT is receiving a SecuredMessage (MSG_SEC_RCV_GENMSG_A)
             *          containing header_fields['signer_info']
             *              containing signer
             *                  containing type
             *                      indicating 'certificate'
             *                  containing certificate (CERT_TS_EC_A)
             *                      containing subject_info.subject_type
             *                          indicating 'enrolment_credentials'
             *   } then {
             *       the IUT discards the message
             *   }
             * }
             * </pre>
             * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_RCV_GENMSG_12_01_BO
             * @reference    ETSI TS 103 097 [1], clause 7.2
             */
            testcase TC_SEC_ITSS_RCV_GENMSG_12_01_BO() runs on ItsMtc system ItsSecSystem {
                
                // Local variables
                var ItsGeoNetworking v_nodeB;
                var ItsGeoNetworking v_nodeD;
                
                // Test control
                if (not(PICS_GN_SECURITY) or not(PICS_GN_GBC_SRC)) {
                    log("*** " & testcasename() & ": 'PICS_GN_SECURITY' and PICS_GN_GBC_SRC' required for executing the TC ***");
                    setverdict(inconc);
                    stop;
                }
                
                // Test component configuration
                f_cf02Up();
                
                // Preamble
                
                // Start components
                v_nodeB := f_getComponent(c_compNodeB);
                v_nodeD := f_getComponent(c_compNodeD);
                v_nodeB.start(f_TC_SEC_ITSS_RCV_GENMSG_12_0x_BO_nodeB(cc_taCert_EC));
                v_nodeD.start(f_TC_SEC_ITSS_RCV_GENMSG_xxx_BO_nodeD());
                
                // Synchronization
                f_serverSync2ClientsAndStop({c_prDone, c_tbDone, c_poDone});
                
                // Cleanup
                f_cf02Down();
                
            } // End of testcase TC_SEC_ITSS_RCV_GENMSG_12_01_BO
            
            /**
             * @desc    Check that IUT discards a Secured GN Message if the signer certificate of the message contains the subject type 'authorization_authority'
             * <pre>
             * Pics Selection: PICS_GN_SECURITY and PICS_GN_GBC_SRC
             * Config Id: CF01
             * Expected behavior:
             * with {
             *   the IUT being in the 'authorized' state
             *   and the IUT current time is inside the time validity period of CERT_TS_A_AT
             * }
             * ensure that {
             *   when {
             *       the IUT is receiving a SecuredMessage (MSG_SEC_RCV_GENMSG_A)
             *          containing header_fields['signer_info']
             *              containing signer
             *                  containing type
             *                      indicating 'certificate'
             *                  containing certificate (CERT_TS_A_AA)
             *                      containing subject_info.subject_type
             *                          indicating 'enrolment_credentials'
             *   } then {
             *       the IUT discards the message
             *   }
             * }
             * </pre>
             * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_RCV_GENMSG_12_02_BO
             * @reference    ETSI TS 103 097 [1], clause 7.2
             */
            testcase TC_SEC_ITSS_RCV_GENMSG_12_02_BO() runs on ItsMtc system ItsSecSystem {
                
                // Local variables
                var ItsGeoNetworking v_nodeB;
                var ItsGeoNetworking v_nodeD;
                
                // Test control
                if (not(PICS_GN_SECURITY) or not(PICS_GN_GBC_SRC)) {
                    log("*** " & testcasename() & ": 'PICS_GN_SECURITY' and PICS_GN_GBC_SRC' required for executing the TC ***");
                    setverdict(inconc);
                    stop;
                }
                
                // Test component configuration
                f_cf02Up();
                
                // Preamble
                
                // Start components
                v_nodeB := f_getComponent(c_compNodeB);
                v_nodeD := f_getComponent(c_compNodeD);
                v_nodeB.start(f_TC_SEC_ITSS_RCV_GENMSG_12_0x_BO_nodeB(cc_taCert_AA));
                v_nodeD.start(f_TC_SEC_ITSS_RCV_GENMSG_xxx_BO_nodeD());
                
                // Synchronization
                f_serverSync2ClientsAndStop({c_prDone, c_tbDone, c_poDone});
                
                // Cleanup
                f_cf02Down();
                
            } // End of testcase TC_SEC_ITSS_RCV_GENMSG_12_02_BO
            
            /**
             * @desc    Check that IUT discards a Secured GN Message if the signer certificate of the message contains the subject type 'enrolment_authority'
             * <pre>
             * Pics Selection: PICS_GN_SECURITY and PICS_GN_GBC_SRC
             * Config Id: CF01
             * Expected behavior:
             * with {
             *   the IUT being in the 'authorized' state
             *   and the IUT current time is inside the time validity period of CERT_TS_A_AT
             * }
             * ensure that {
             *   when {
             *       the IUT is receiving a SecuredMessage (MSG_SEC_RCV_GENMSG_A)
             *          containing header_fields['signer_info']
             *              containing signer
             *                  containing type
             *                      indicating 'certificate'
             *                  containing certificate (CERT_TS_A_EA)
             *                      containing subject_info.subject_type
             *                          indicating 'enrolment_credentials'
             *   } then {
             *       the IUT discards the message
             *   }
             * }
             * </pre>
             * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_RCV_GENMSG_12_03_BO
             * @reference    ETSI TS 103 097 [1], clause 7.2
             */
            testcase TC_SEC_ITSS_RCV_GENMSG_12_03_BO() runs on ItsMtc system ItsSecSystem {
                
                // Local variables
                var ItsGeoNetworking v_nodeB;
                var ItsGeoNetworking v_nodeD;
                
                // Test control
                if (not(PICS_GN_SECURITY) or not(PICS_GN_GBC_SRC)) {
                    log("*** " & testcasename() & ": 'PICS_GN_SECURITY' and PICS_GN_GBC_SRC' required for executing the TC ***");
                    setverdict(inconc);
                    stop;
                }
                
                // Test component configuration
                f_cf02Up();
                
                // Preamble
                
                // Start components
                v_nodeB := f_getComponent(c_compNodeB);
                v_nodeD := f_getComponent(c_compNodeD);
                v_nodeB.start(f_TC_SEC_ITSS_RCV_GENMSG_12_0x_BO_nodeB(cc_taCert_EA));
                v_nodeD.start(f_TC_SEC_ITSS_RCV_GENMSG_xxx_BO_nodeD());
                
                // Synchronization
                f_serverSync2ClientsAndStop({c_prDone, c_tbDone, c_poDone});
                
                // Cleanup
                f_cf02Down();
                
            } // End of testcase TC_SEC_ITSS_RCV_GENMSG_12_03_BO
            
            /**
             * @desc    Check that IUT discards a Secured GN Message if the signer certificate of the message contains the subject type 'root_ca'
             * <pre>
             * Pics Selection: PICS_GN_SECURITY and PICS_GN_GBC_SRC
             * Config Id: CF01
             * Expected behavior:
             * with {
             *   the IUT being in the 'authorized' state
             *   and the IUT current time is inside the time validity period of CERT_TS_A_AT
             * }
             * ensure that {
             *   when {
             *       the IUT is receiving a SecuredMessage (MSG_SEC_RCV_GENMSG_A)
             *          containing header_fields['signer_info']
             *              containing signer
             *                  containing type
             *                      indicating 'certificate'
             *                  containing certificate (CERT_TS_A_CA)
             *                      containing subject_info.subject_type
             *                          indicating 'enrolment_credentials'
             *   } then {
             *       the IUT discards the message
             *   }
             * }
             * </pre>
             * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_RCV_GENMSG_12_04_BO
             * @reference    ETSI TS 103 097 [1], clause 7.2
             */
            testcase TC_SEC_ITSS_RCV_GENMSG_12_04_BO() runs on ItsMtc system ItsSecSystem {
                
                // Local variables
                var ItsGeoNetworking v_nodeB;
                var ItsGeoNetworking v_nodeD;
                
                // Test control
                if (not(PICS_GN_SECURITY) or not(PICS_GN_GBC_SRC)) {
                    log("*** " & testcasename() & ": 'PICS_GN_SECURITY' and PICS_GN_GBC_SRC' required for executing the TC ***");
                    setverdict(inconc);
                    stop;
                }
                
                // Test component configuration
                f_cf02Up();
                
                // Preamble
                
                // Start components
                v_nodeB := f_getComponent(c_compNodeB);
                v_nodeD := f_getComponent(c_compNodeD);
                v_nodeB.start(f_TC_SEC_ITSS_RCV_GENMSG_12_0x_BO_nodeB(cc_taCert_CA));
                v_nodeD.start(f_TC_SEC_ITSS_RCV_GENMSG_xxx_BO_nodeD());
                
                // Synchronization
                f_serverSync2ClientsAndStop({c_prDone, c_tbDone, c_poDone});
                
                // Cleanup
                f_cf02Down();
                
            } // End of testcase TC_SEC_ITSS_RCV_GENMSG_12_04_BO
            
            group g_TC_SEC_ITSS_RCV_GENMSG_12_0x_BO {
                
                /**
                 * @desc    Behavior function for NodeB (TC_GEONW_PON_GBC_BV_01)
                 */
                function f_TC_SEC_ITSS_RCV_GENMSG_12_0x_BO_nodeB(
                                                                 in charstring p_taCert
                ) runs on ItsGeoNetworking {
                    
                    // Local variables
                    var GeoNetworkingPdu v_securedGnPdu;
                    var LongPosVector v_longPosVectorNodeB := f_getPosition(c_compNodeB); // Use NodeB
                    
                    // Preamble
                    f_selfOrClientSyncAndVerdict(c_prDone, e_success);
                    
                    // Test Body
                    v_securedGnPdu := f_prepareSecuredBeacon(
                        p_taCert, 
                        {
                            m_header_field_signer_info(
                                m_signerInfo_digest(
                                    vc_atCertificate.signer_info.signerInfo.digest
                            )), 
                            m_header_field_generation_time(1000 * f_getCurrentTime()), // In us
                            m_header_field_generation_location(
                                valueof(m_threeDLocation(
                                    PX_WGSLATITUDE,
                                    PX_WGSLONGITUDE,
                                    '0000'O
                                ))
                            ),
                            m_header_field_its_aid_Other
                        }, 
                        e_certificate,
                        true
                    ); 
                    f_sendGeoNetMessage(m_geoNwReq_linkLayerBroadcast(v_securedGnPdu));
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                    
                    // Postamble
                    f_selfOrClientSyncAndVerdict(c_poDone, e_success);
                    
                } // End of function f_TC_SEC_ITSS_RCV_GENMSG_12_0x_BO_nodeB
                
            } // End of group g_TC_SEC_ITSS_RCV_GENMSG_12_0x_BV
            
        } // End of group recvOtherProfile
        
        /**
         * @desc Receiving behaviour test cases for certificates profile
         * @see ETSI TS 103 096-2 V1.2.2 (2016-01) Clause 5.3.5 Profiles for certificates
         */
        group recvCertificatesProfile {
            
            /**
             * @desc    Check that IUT discards the AT certificate with version 3
             * <pre>
             * Pics Selection: PICS_GN_SECURITY
             * Config Id: CF01
             * Initial conditions:
             *  with {
             *      the IUT being in the 'authorized' state
             *      and the IUT current time is inside the time validity period of CERT_TS_01_01_BO_AT
             *  }
             *  ensure that {
             *      when { 
             *          the IUT is receiving a SecuredMessage
             *              containing header_fields['signer_info'].signer
             *                  containing type
             *                      indicating 'certificate'
             *                  and containing certificate (CERT_TS_01_01_BO_AT)
             *                      containing  version
             *                          indicating '2'
             *      } then {
             *          the IUT discards  the message
             *      }
             *  }
             * </pre>
             *
             * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_RCV_CERT_01_01_BO
             * @reference    ETSI TS 103 097 [1], clause 7.1
             */
            testcase TC_SEC_ITSS_RCV_CERT_01_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(cc_taCert0101_BO, 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() & ": 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_CERT_01_01_BO
            
            /**
             * @desc    Check that IUT discards the AT certificate with version 1
             * <pre>
             * Pics Selection: PICS_GN_SECURITY
             * Config Id: CF01
             * Initial conditions:
             *  with {
             *      the IUT being in the 'authorized' state
             *      and the IUT current time is inside the time validity period of CERT_TS_01_02_BO_AT
             *  }
             *  ensure that {
             *      when { 
             *          the IUT is receiving a SecuredMessage
             *              containing header_fields['signer_info'].signer
             *                  containing type
             *                      indicating 'certificate'
             *                  and containing certificate (CERT_TS_01_02_BO_AT)
             *                      containing  version
             *                          indicating '2'
             *      } then {
             *          the IUT discards  the message
             *      }
             *  }
             * </pre>
             *
             * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_RCV_CERT_01_02_BO
             * @reference    ETSI TS 103 097 [1], clause 7.1
             */
            testcase TC_SEC_ITSS_RCV_CERT_01_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(cc_taCert0102_BO, 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() & ": 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_CERT_01_02_BO
            
            /**
             * @desc    Check that IUT discards the AA certificate with version 3
             * <pre>
             * Pics Selection: PICS_GN_SECURITY
             * Config Id: CF01
             * Initial conditions:
             *  with {
             *      the IUT being in the 'authorized' state
             *      and the IUT current time is inside the time validity period of CERT_TS_01_03_BO_AT
             *  }
             *  ensure that {
             *      when { 
             *          the IUT is receiving a SecuredMessage
             *              containing header_fields['signer_info'].signer
             *                  containing type
             *                      indicating 'certificate_chain'
             *                  and containing certificate[0] (CERT_TS_01_03_BO_AA)
             *                      containing  version
             *                          indicating '3'
             *                  and containing certificate[1] (CERT_TS_01_03_BO_AT)
             *                      containing signer_info.type
             *                          indicating 'certificate_digest_with_sha256'
             *                      and containing signer_info.digest
             *                          referencing to CERT_TS_01_03_BO_AA
             *      } then {
             *          the IUT discards  the message
             *      }
             *  }
             * </pre>
             *
             * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_RCV_CERT_01_03_BO
             * @reference    ETSI TS 103 097 [1], clause 7.1
             */
            testcase TC_SEC_ITSS_RCV_CERT_01_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_sendSecuredCam(cc_taCert0103_BO, -, 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() & ": 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_CERT_01_03_BO
            
            /**
             * @desc    Check that IUT discards the AA certificate with version 1
             * <pre>
             * Pics Selection: PICS_GN_SECURITY
             * Config Id: CF01
             * Initial conditions:
             *  with {
             *      the IUT being in the 'authorized' state
             *      and the IUT current time is inside the time validity period of CERT_TS_01_04_BO_AT
             *  }
             *  ensure that {
             *      when { 
             *          the IUT is receiving a SecuredMessage
             *              containing header_fields['signer_info'].signer
             *                  containing type
             *                      indicating 'certificate_chain'
             *                  and containing certificate[0] (CERT_TS_01_04_BO_AA)
             *                      containing  version
             *                          indicating '1'
             *                  and containing certificate[1] (CERT_TS_01_04_BO_AT)
             *                      and containing signer_info.digest
             *                          referencing to CERT_TS_01_04_BO_AA
             *      } then {
             *          the IUT discards the message
             *      }
             *  }
             * </pre>
             *
             * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_RCV_CERT_01_04_BO
             * @reference    ETSI TS 103 097 [1], clause 7.1
             */
            testcase TC_SEC_ITSS_RCV_CERT_01_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_sendSecuredCam(cc_taCert0104_BO, -, 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() & ": 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_CERT_01_04_BO
            
            /**
             * @desc    Check that IUT discards a SecuredMessage if the issuer certificate of the authorization ticket certificate contains the subject type 'enrolment_credential'
             * <pre>
             * Pics Selection: PICS_GN_SECURITY
             * Config Id: CF01
             * Initial conditions:
             *  with {
             *      the IUT being in the 'authorized' state
             *      and the IUT current time is inside the time validity period of CERT_TS_02_01_BO_AT
             *  }
             *  ensure that {
             *      when { 
             *          the IUT is receiving a SecuredMessage
             *              containing header_fields['signer_info'].signer
             *                  containing type
             *                      indicating 'certificate'
             *                  and containing certificate (CERT_TS_02_01_BO_AT)
             *                      containing signer_info.type
             *                          indicating 'certificate_digest_with_sha256'
             *                      and containing signer_info.digest
             *                          referencing to certificate (CERT_TS_A_EC)
             *                              containing subject_info.subject_type
             *                                 indicating 'enrolment_credential'
             *      } then {
             *          the IUT discards the message
             *      }
             *  }
             * </pre>
             *
             * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_RCV_CERT_02_01_BO
             * @reference    ETSI TS 103 097 [1], clause 7.1
             */
            testcase TC_SEC_ITSS_RCV_CERT_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(cc_taCert0201_BO, 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() & ": 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_CERT_02_01_BO
            
            /**
             * @desc    Check that IUT discards a SecuredMessage if the issuer certificate of the authorization authority certificate contains the subject type 'enrolment_credential'
             * <pre>
             * Pics Selection: PICS_GN_SECURITY
             * Config Id: CF01
             * Initial conditions:
             *  with {
             *      the IUT being in the 'authorized' state
             *      and the IUT current time is inside the time validity period of CERT_TS_02_02_BO_AT
             *  }
             *  ensure that {
             *      when { 
             *          the IUT is receiving a SecuredMessage
             *              containing header_fields['signer_info'].signer
             *                  containing type
             *                      indicating 'certificate_chain'
             *                  and containing certificates[0] (CERT_TS_02_02_BO_AA)
             *                      containing signer_info.digest
             *                          referencing to certificate CERT_TS_A_EC
             *                              containing subject_info.subject_type
             *                                  indicating 'enrolment_credential'
             *                  and containing certificates[1] (CERT_TS_02_02_BO_AT)
             *                      containing signer_info.digest
             *                          referencing to CERT_TS_02_02_BO_AA
             *      } then {
             *          the IUT discards the message
             *      }
             *  }
             * </pre>
             *
             * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_RCV_CERT_02_02_BO
             * @reference    ETSI TS 103 097 [1], clause 7.1
             */
            testcase TC_SEC_ITSS_RCV_CERT_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(cc_taCert0202_BO, omit, 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() & ": 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_CERT_02_02_BO
            
            /**
             * @desc    Check that IUT discards a SecuredMessage if the issuer certificate of the authorization ticket certificate contains the subject type 'enrolment_authority'
             * <pre>
             * Pics Selection: PICS_GN_SECURITY
             * Config Id: CF01
             * Initial conditions:
             *  with {
             *      the IUT being in the 'authorized' state
             *      and the IUT current time is inside the time validity period of CERT_TS_02_03_BO_AT
             *  }
             *  ensure that {
             *      when { 
             *          the IUT is receiving a SecuredMessage
             *              containing header_fields['signer_info'].signer
             *                  containing type
             *                      indicating 'certificate'
             *                  and containing certificate (CERT_TS_02_03_BO_AT)
             *                      containing signer_info.type
             *                          indicating 'certificate_digest_with_sha256'
             *                  and containing signer_info.digest
             *                          referencing to certificate (CERT_TS_A_EA)
             *                              containing subject_info.subject_type
             *                                  indicating 'enrolment_authority'
             *      } then {
             *          the IUT discards the message
             *      }
             *  }
             * </pre>
             *
             * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_RCV_CERT_02_03_BO
             * @reference    ETSI TS 103 097 [1], clause 7.1
             */
            testcase TC_SEC_ITSS_RCV_CERT_02_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_sendSecuredCam(cc_taCert0203_BO, 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() & ": 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_CERT_02_03_BO
            
            /**
             * @desc    Check that IUT discards a SecuredMessage if the issuer certificate of the authorization authority certificate contains the subject type 'enrolment_authority'
             * <pre>
             * Pics Selection: PICS_GN_SECURITY
             * Config Id: CF01
             * Initial conditions:
             *  with {
             *      the IUT being in the 'authorized' state
             *      and the IUT current time is inside the time validity period of CERT_TS_02_04_BO_AT
             *  }
             *  ensure that {
             *      when { 
             *          the IUT is receiving a SecuredMessage
             *              containing header_fields['signer_info'].signer
             *                  containing type
             *                      indicating 'certificate_chain'
             *                  and containing certificates[0] (CERT_TS_02_04_BO_AA)
             *                      containing signer_info.digest
             *                          referencing to certificate CERT_TS_A_EA
             *                              containing subject_info.subject_type
             *                                  indicating 'enrolment_authority'
             *                  and containing certificates[1] (CERT_TS_02_04_BO_AT)
             *                      containing signer_info.digest
             *                          referencing to CERT_TS_02_04_BO_AA
             *      } then {
             *          the IUT discards the message
             *      }
             *  }
             * </pre>
             *
             * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_RCV_CERT_02_04_BO
             * @reference    ETSI TS 103 097 [1], clause 7.1
             */
            testcase TC_SEC_ITSS_RCV_CERT_02_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_sendSecuredCam(cc_taCert0204_BO, omit, 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() & ": 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_CERT_02_04_BO
            
            /**
             * @desc    Check that IUT discards a SecuredMessage if the issuer certificate of the authorization ticket certificate contains the subject type 'authorization_ticket'
             * <pre>
             * Pics Selection: PICS_GN_SECURITY
             * Config Id: CF01
             * Initial conditions:
             *  with {
             *      the IUT being in the 'authorized' state
             *      and the IUT current time is inside the time validity period of CERT_TS_03_01_BO_AT
             *  }
             *  ensure that {
             *      when { 
             *          the IUT is receiving a SecuredMessage
             *              containing header_fields ['signer_info'].signer
             *                  containing certificate (CERT_TS_03_01_BO_AT)
             *                      containing signer_info.digest
             *                          referencing to CERT_TS_03_BO_CA
             *                              containing subject_info.subject_type
             *                                  indicating 'authorization_ticket'
             *      } then {
             *          the IUT discards the message
             *      }
             *  }
             * </pre>
             *
             * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_RCV_CERT_03_01_BO
             * @reference    ETSI TS 103 097 [1], clause 7.1
             */
            testcase TC_SEC_ITSS_RCV_CERT_03_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(cc_taCert0301_BO, 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() & ": 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_CERT_03_01_BO
            
            /**
             * @desc    Check that IUT discards a SecuredMessage if the issuer certificate of the authorization authority certificate contains the subject type 'authorization_ticket'
             * <pre>
             * Pics Selection: PICS_GN_SECURITY
             * Config Id: CF01
             * Initial conditions:
             *  with {
             *      the IUT being in the 'authorized' state
             *      and the IUT current time is inside the time validity period of CERT_TS_03_02_BO_AT
             *  }
             *  ensure that {
             *      when { 
             *          the IUT is receiving a SecuredMessage
             *              containing header_fields ['signer_info'].signer
             *                  containing type
             *                      indicating 'certificate_chain'
             *                  and containing certificates[0] (CERT_TS_03_02_BO_AA)
             *                      containing signer_info.digest
             *                          referencing to CERT_TS_03_BO_CA
             *                              containing subject_info.subject_type
             *                                  indicating 'authorization_ticket'
             *                  and containing certificates[1] (CERT_TS_03_02_BO_AT)
             *                      containing signer_info.digest
             *                      referencing to CERT_TS_03_02_BO_AA
             *      } then {
             *          the IUT discards the message
             *      }
             *  }
             * </pre>
             *
             * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_RCV_CERT_03_02_BO
             * @reference    ETSI TS 103 097 [1], clause 7.1
             */
            testcase TC_SEC_ITSS_RCV_CERT_03_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(cc_taCert0302_BO, omit, 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() & ": 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_CERT_03_02_BO
            
            /**
             * @desc    Check that IUT discards a SecuredMessage if the issuer certificate of the AA certificate contains the subject type 'authorization_authority'
             * <pre>
             * Pics Selection: PICS_GN_SECURITY
             * Config Id: CF01
             * Initial conditions:
             *  with {
             *      the IUT being in the 'authorized' state
             *      and the IUT current time is inside the time validity period of CERT_TS_04_01_BO_AT
             *  }
             *  ensure that {
             *      when { 
             *          the IUT is receiving a SecuredMessage
             *              containing header_fields ['signer_info'].signer
             *                  containing type
             *                      indicating 'certificate_chain'
             *                  and containing certificates[0] (CERT_TS_04_01_BO_AA)
             *                      containing signer_info.digest
             *                          referencing to CERT_TS_A_AA
             *                  and containing certificates[1] (CERT_TS_04_01_BO_AT)
             *                      containing signer_info.digest
             *                      referencing to CERT_TS_04_01_BO_AA
             *      } then {
             *          the IUT discards the message
             *      }
             *  }
             * </pre>
             *
             * @see          ETSI TS 103 096-2 v1.2.2 TP_SEC_ITSS_RCV_CERT_04_01_BO
             * @reference    ETSI TS 103 097 [1], clause 7.1
             */
            testcase TC_SEC_ITSS_RCV_CERT_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_sendSecuredCam(cc_taCert0402_BO, omit, 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() & ": 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_CERT_04_01_BO
garciay's avatar
garciay committed
        } // End of group recvCertificatesProfile
garciay's avatar
garciay committed
    } // End of group receiverbehavior
    
} // End of module ItsSecurity_TestCase