ItsSecurity_TestCases.ttcn3 462 KB
Newer Older
/**
 *  @author   ETSI / STF481
 *  @version  $URL$
 *        $Id$
 *  @desc     Testcases  file for Security Protocol
 *  @see      Draft ETSI TS 103 097 V1.1.14
 */
module ItsSecurity_TestCases {
    
    // Libcommon
    import from LibCommon_Time all;
    import from LibCommon_VerdictControl all;
    import from LibCommon_Sync all;
    
    // LibItsCommon
//    import from LibItsCommon_TypesAndValues all;
    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;
    
    // 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 } ;
    
    // 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;
    
    group g_SecuredMessages {

        /**
         * @desc    Check that ITS-S sends a SecuredMessage containing protocol version set to 2
         * <pre>
         * Pics Selection: none
         * 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>
         *
         * @see     Draft ETSI TS 103 097 V1.1.14 Clause 5.1    SecuredMessage 
         * @reference   EN 302 636-4-1 [1], clauses 9.3.2 , 8.6.2 and Annex G
         */
        testcase TC_SEC_ITSS_SND_MSG_01() 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_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
        
        /**
         * @desc    Check that IUT sends the message signed with the digest pointing to the AT certificate
         * <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 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>
         *
         * @see     ETSI TS 103 097 V1.1.14, clause 6.3 
         * @reference   EN 302 636-4-1 [1], clauses 9.3.2 , 8.6.2 and Annex G
         */
        testcase TC_SEC_ITSS_SND_MSG_04_01() 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_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_poNeighbour();
            f_cf01Down();
            
        } // End of testcase TC_SEC_ITSS_SND_MSG_04_01
        
        /**
         * @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
         *             containing header_fields ['signer_info'] {
         *                 containing signer {
         *                     containing type
         *                         indicating 'certificate'
         *                     containing certificate
         *                         containing subject_info.subject_type
         *                             indicating 'authorization_ticket'
         *                 }
         *             }
         *     }
         * }
         * </pre>
         *
         * @see
         * @reference   ETSI TS 103 097 V1.1.14, clause 6.3
         */
        testcase TC_SEC_ITSS_SND_MSG_04_02() 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
        
        /**
         * @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>
         *
         * @see
         * @reference   ETSI TS 103 097 V1.1.14, clause 6.3
         */
        testcase TC_SEC_ITSS_SND_MSG_05_01() 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
        
        group secCAMProfile {
            
            /**
             * @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>
             *
             * @see
             * @reference ETSI TS 103 097 V1.1.14, clause 7.1
             */
            testcase TC_SEC_ITSS_SND_CAM_02_01() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var GeoNetworkingInd v_geoNwInd;
                var HeaderFields v_headersFields;
                var HeaderFieldType 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(
                                            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 no header is duplicated
                                if (v_headersFields[v_counter].type_ == v_previousHeaderType) {
                                    log("*** " & testcasename() & ": FAIL: multiple instances of same header");
                                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                                }
                                
                                // Check that headers are ordered
                                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 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
            
            /**
             * @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
             * @reference ETSI TS 103 097 V1.1.14, clause 7.1
             */
            testcase TC_SEC_ITSS_SND_CAM_05_01() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                const integer c_cntTimeLimit := 10;
                const float c_certificateGenerationTime := 1.0;
                
                timer t_minTransInterval := c_certificateGenerationTime * 0.95;
                var integer v_cntTime := 0;
                var GeoNetworkingInd v_geoNwInd;
                var boolean v_nextCamWithCertificate := false;
                
                // 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_setCamFrequencyGreatherThan1Hz();
                geoNetworkingPort.clear;
                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);
                    }
                }
                
                // Test Body
                tc_ac.start;
                alt {
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mdw_securedMessage_CAMs(
                                    mw_header_field_signer_info_certificate
                    )))) {
                        tc_ac.stop; 
                        if (v_nextCamWithCertificate == true) {
                            v_cntTime := v_cntTime + 1;
                            if (v_cntTime == c_cntTimeLimit) { // Exit message loop
                                log("*** " & testcasename() & ": INFO: The subset of CAM messages including certificate was received ***");
                            }
                            else {
                                log("*** " & testcasename() & ": INFO: CAM retransmission with certificate ***"); 
                                tc_ac.start;
                                t_minTransInterval.start;
                                v_nextCamWithCertificate := false;
                                repeat;
                            }
                        } else {
                            t_minTransInterval.stop;
                            log("*** " & testcasename() & ": FAIL: Certificate in received CAM ***");
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                        }
                    }
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mdw_securedMessage_CAMs(
                                    mw_header_field_signer_info_digest
                    )))) {
                        tc_ac.stop;
                        log("*** " & testcasename() & ": INFO: CAM retransmission w/o certificate ***"); 
                        tc_ac.start;
                        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 {
                        v_nextCamWithCertificate := true;
                        log("*** " & testcasename() & ": INFO: Next CAM shall contain certificate ***");
                        repeat;  
                    }
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: Expected CAM not received ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                    }                    
                } // End of 'alt' statement
                log("*** " & testcasename() & ": PASS: Generation of CAM messages including certificate was successful ***");
                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);  
                
                // Postamble
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_ITSS_SND_CAM_05_01
            
            /**
             * @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..
             * <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 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
             *             containing header_fields['signer_info'] {
             *                 containing signer {
             *                     containing type
             *                         indicating 'certificate'
             *                     containing certificate
             *                 }
             *             containing header_fields['its_aid']
             *                indicating 'AID_CAM'
             *             }
             *     } then {
             *         this message
             *             contains header_fields['generation_time']
             *                 indicating TIME (TIME >= TIME_LAST + 1sec)
             *     }
             * }
             * </pre>
             *
             * @see
             * @reference ETSI TS 103 097 V1.1.14, clause 7.1
             */
            testcase TC_SEC_ITSS_SND_CAM_06_01() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                const integer c_cntTimeLimit := 10;
                const float c_certificateGenerationTime := 1.0;
                
                timer t_minTransInterval := c_certificateGenerationTime * 1.05;
                var integer v_cntTime := 0;
                var GeoNetworkingInd v_geoNwInd;
                var boolean v_nextCamWithCertificate := false;
                
                // 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_setCamFrequencyGreatherThan1Hz();
                geoNetworkingPort.clear;
                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
                    )))) {
                        tc_ac.stop; 
                        v_cntTime := v_cntTime + 1;
                        if (v_cntTime == c_cntTimeLimit) { // Exit message loop
                            log("*** " & testcasename() & ": INFO: The subset of CAM messages including certificate was received ***");
                        }
                        else {
                            log("*** " & testcasename() & ": INFO: CAM retransmission with certificate ***"); 
                            tc_ac.start;
                            t_minTransInterval.start;
                            v_nextCamWithCertificate := false;
                            repeat;
                        }
                    }
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mdw_securedMessage_CAMs(
                                    mw_header_field_signer_info_certificate
                    )))) {
                        tc_ac.stop;
                        if (v_nextCamWithCertificate == true) {
                            log("*** " & testcasename() & ": FAIL: No Certificate in received CAM ***");
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                        } else {
                            log("*** " & testcasename() & ": INFO: CAM retransmission w/o certificate ***"); 
                            tc_ac.start;
                            repeat;
                        }
                    }
                    [] t_minTransInterval.timeout {
                        v_nextCamWithCertificate := true;
                        log("*** " & testcasename() & ": INFO: Next CAM shall contain certificate ***");
                        repeat;  
                    }
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: Expected CAM not received ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                    }
                } // End of 'alt' statement
                log("*** " & testcasename() & ": PASS: Generation of CAM messages including certificate was successful ***");
                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);  
                
                // Postamble
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_ITSS_SND_CAM_06_01
            
            /**
             * @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'
             *          at TIME_1 
             *  }
             *  ensure that {
             *      when {
             *          the IUT is requested to send next CAM right after 1 second after the TIME_1
             *      } then {
             *          the IUT sends a SecuredMessage {
             *              containing header_fields ['signer_info'] {
             *                  containing signer {
             *                      containing type
             *                          indicating 'certificate'
             *                      containing certificate
             *                  }
             *              }
             *              containing header_fields['its_aid']
             *                  indicating 'AID_CAM'
             *          }
             *      }
             *  }
             * </pre>
             *
             * @see
             * @reference ETSI TS 103 097 V1.1.14, clause 7.1
             */
            testcase TC_SEC_ITSS_SND_CAM_06_02() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                const integer c_cntTimeLimit := 10;
                const float c_certificateGenerationTime := 1.0;
                
                timer t_minTransInterval := c_certificateGenerationTime * 1.05;
                var integer v_cntTime := 0;
                var GeoNetworkingInd v_geoNwInd;
                var boolean v_nextCamWithCertificate := false;
                
                // 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_setCamFrequencyGreatherThan1Hz();
                geoNetworkingPort.clear;
                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
                    )))) {
                        tc_ac.stop; 
                        v_cntTime := v_cntTime + 1;
                        if (v_cntTime == c_cntTimeLimit) { // Exit message loop
                            log("*** " & testcasename() & ": INFO: The subset of CAM messages including certificate was received ***");
                        }
                        else {
                            log("*** " & testcasename() & ": INFO: CAM retransmission with certificate ***"); 
                            tc_ac.start;
                            t_minTransInterval.start;
                            v_nextCamWithCertificate := false;
                            repeat;
                        }
                    }
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mdw_securedMessage_CAMs
                    ))) {
                        tc_ac.stop;
                        if (v_nextCamWithCertificate == true) {
                            log("*** " & testcasename() & ": FAIL: No Certificate in received CAM ***");
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                        } else {
                            log("*** " & testcasename() & ": INFO: CAM retransmission w/o certificate ***"); 
                            tc_ac.start;
                            repeat;
                        }
                    }
                    [] t_minTransInterval.timeout {
                        v_nextCamWithCertificate := true;
                        log("*** " & testcasename() & ": INFO: Next CAM shall contain certificate ***");
                        repeat;  
                    }
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: Expected CAM not received ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                    }
                } // End of 'alt' statement
                log("*** " & testcasename() & ": PASS: Generation of CAM messages including certificate was successful ***");
                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);  
                
                // Postamble
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_ITSS_SND_CAM_06_02
            
            /**
             * @desc    Check that SUT send certificate to unknown ITS-S
             * <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 than one CAM per second
             *      and the IUT having already sent CAM at TIME_1
             *          containing header_fields['signer_info'].signer.type
             *              indicating 'certificate'
             *      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
             *          }
             *          containing header_fields['its_aid']
             *              indicating 'AID_CAM'
             *  }
             *  ensure that {
             *      when {
             *          the IUT is requested to send CAM
             *                      at TIME_3 (TIME_1 < TIME_2 < TIME_3 < TIME_1 + 1sec)
             *      } then {
             *          the IUT sends a SecuredMessage {
             *              containing header_fields[0] {
             *                  containing type 
             *                      indicating 'signer_info'
             *                  containing signer {
             *                      containing type
             *                          indicating 'certificate'
             *                      containing certificate
             *                  }
             *              }
             *              containing header_fields['its_aid']
             *                  indicating 'AID_CAM'
             *          }
             *      }
             *  }
             * </pre>
             *
             * @see
             * @reference ETSI TS 103 097 V1.1.14, clause 7.1
             */
            testcase TC_SEC_ITSS_SND_CAM_07_01() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                const float c_certificateGenerationTime := 1.0;
                
                timer t_minTransInterval := c_certificateGenerationTime * 0.95;
                var GeoNetworkingInd v_geoNwInd;
                
                // 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_setCamFrequencyGreatherThan1Hz();
                geoNetworkingPort.clear;
                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 ***");
                        
                        // Send secured message from unknown ITS-S
                        f_sendSecuredCam(cc_taCert_B);
                        
                        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
                    )))) {
                        tc_ac.stop; 
                        log("*** " & testcasename() & ": INFO: CAM retransmission with certificate ***"); 
                        if (t_minTransInterval.running) {
                            log("*** " & testcasename() & ": PASS: Generation of CAM messages including certificate was successful ***");
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success); 
                        }
                        else {
                            log("*** " & testcasename() & ": INCONC: CAM with certificate received after 1s... ***");
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                        }   
                    }
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mdw_securedMessage_CAMs
                    ))) {
                        tc_ac.stop;
                        log("*** " & testcasename() & ": INFO: CAM retransmission w/o certificate ***"); 
                        tc_ac.start;
                        repeat;
                    }
                    [] t_minTransInterval.timeout {
                        log("*** " & testcasename() & ": INFO: Next CAM shall contain 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_07_01
            
            /**
             * @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'
             *      and the IUT having received a CAM
             *                              at TIME_2 (TIME_1 + 0.3sec) {
             *          containing header_fields['signer_info'].signer.type
             *              indicating 'certificate_digest_with_sha256'
             *          containing header_fields['signer_info'].signer.digest
             *              referenced to unknown 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>
             *
             * @see
             * @reference ETSI TS 103 097 V1.1.14, clause 7.1
             */
            testcase TC_SEC_ITSS_SND_CAM_07a_01() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                const float c_certificateGenerationTime := 1.0;
                
                timer t_minTransInterval := c_certificateGenerationTime * 0.95;
                var GeoNetworkingInd v_geoNwInd;
                
                // 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_setCamFrequencyGreatherThan1Hz();
                geoNetworkingPort.clear;
                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 ***");
                        
                        // Send secured message with request for unrecognized certificate
                        f_sendSecuredCam(
                            {
                                m_header_field_unrecognised_certificate(
                                    f_HashedId3FromHashedId8(
                                        vc_atCertificate.signer_info.signerInfo.digest
                                    )
                                )
                            } );
                        
                        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; 
                        log("*** " & testcasename() & ": INFO: CAM retransmission with certificate ***"); 
                        if (t_minTransInterval.running) {
                            log("*** " & testcasename() & ": PASS: Generation of CAM messages including certificate was successful ***");
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success); 
                        } else {
                            log("*** " & testcasename() & ": INCONC: CAM with certificate received after 1s... ***");
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                        }
                    }
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mdw_securedMessage_CAMs
                    ))) {
                        tc_ac.stop;
                        log("*** " & testcasename() & ": INFO: CAM retransmission w/o certificate ***"); 
                        tc_ac.start;
                        repeat;
                    }
                    [] t_minTransInterval.timeout {
                        log("*** " & testcasename() & ": INFO: Next CAM shall contain 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_07a_01
            
            /**
             * @desc    Check that SUT send certificate when requested
             * <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 than one CAM per second
             *      and the IUT having already sent CAM at TIME_1
             *          containing header_fields['signer_info'].signer.type
             *              indicating 'certificate' 
             *      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 {
             *          the IUT is requested to send a CAM
             *                  at TIME_3 (TIME_1 < TIME_2 < TIME_3 < TIME_1 + 1sec)
             *      } then {
             *          the IUT sends a SecuredMessage {
             *              containing header_fields['signer_info'] {
             *                  containing signer {
             *                      containing type
             *                          indicating 'certificate'
             *                      containing certificate
             *                          referenced by the requested digest 
             *                  }
             *              }
             *              containing header_fields['its_aid']
             *                  indicating 'AID_CAM'
             *          }
             *      }
             *  }
             * </pre>
             *
             * @see
             * @reference ETSI TS 103 097 V1.1.14, clause 7.1
             */
            testcase TC_SEC_ITSS_SND_CAM_08_01() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                const float c_certificateGenerationTime := 1.0;
                
                timer t_minTransInterval := c_certificateGenerationTime * 0.95;
                var GeoNetworkingInd v_geoNwInd;
                
                // 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_setCamFrequencyGreatherThan1Hz();
                geoNetworkingPort.clear;
                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 ***");
                        
                        // Send secured message with request for unrecognized certificate
                        f_sendSecuredCam(
                            {
                                m_header_field_unrecognised_certificate(                                                              // containing digests
                                    f_HashedId3FromHashedId8(                           // containing HashedId3 value
                                        vc_atCertificate.signer_info.signerInfo.digest  //  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
                    )))) {
                        tc_ac.stop; 
                        log("*** " & testcasename() & ": INFO: CAM retransmission with certificate ***"); 
                        if (t_minTransInterval.running) {
                            log("*** " & testcasename() & ": PASS: Generation of CAM messages including certificate was successful ***");
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success); 
                        } else {
                            log("*** " & testcasename() & ": INCONC: CAM with certificate received after 1s... ***");
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                        }
                    }
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mdw_securedMessage_CAMs
                    ))) {
                        tc_ac.stop;
                        log("*** " & testcasename() & ": INFO: CAM retransmission w/o certificate ***"); 
                        tc_ac.start;
                        repeat;
                    }
                    [] t_minTransInterval.timeout {
                        log("*** " & testcasename() & ": INFO: Next CAM shall contain 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_08_01
            
            /**
             * @desc    Check that SUT send certificate_chain when requested
             * <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 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 {
             *          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
             *                  }
             *              }
             *              containing header_fields['its_aid']
             *                  indicating 'AID_CAM'
             *          }
             *      }
             *  }
             * </pre>
             *
             * @see
             * @reference ETSI TS 103 097 V1.1.14, clause 7.1
             */
            testcase TC_SEC_ITSS_SND_CAM_09_01() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                const float c_certificateGenerationTime := 1.0;
                
                timer t_minTransInterval := c_certificateGenerationTime * 0.95;
                var GeoNetworkingInd v_geoNwInd;
                
                // 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_setCamFrequencyGreatherThan1Hz();
                geoNetworkingPort.clear;
                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 ***");
                        
                        // Send secured message with request for unrecognized certificate
                        f_sendSecuredCam(
                            {
                                m_header_field_unrecognised_certificate(                    // containing digests
                                    f_HashedId3FromHashedId8(                               //     containing HashedId3 value
                                        vc_aaCertificate.signer_info.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 {
                        tc_ac.stop; 
                        log("*** " & testcasename() & ": INFO: CAM retransmission with certificate ***"); 
                        if (t_minTransInterval.running) {
                            var SignerInfo v_signerInfo;
                            var CertificateChain v_certificates;
                            var integer v_certificateChainLength;
                            
                            // 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[v_certificateChainLength - 1].subject_info.subject_type == e_authorization_authority) and 
                                            // Check the certificate chain contains certificates[last] indicating the AT certificate
                                        (v_certificates[v_certificateChainLength - 2].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_success); 
                                } else {
                                    log("*** " & testcasename() & ": PASS: Generation of CAM messages including certificate chain was successful ***");
                                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                                } 
                            } else {
                                log("*** " & testcasename() & ": FAIL: Unexpected certificate chain content length ***");
                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success); 
                            }
                        } else {
                            log("*** " & testcasename() & ": INCONC: CAM with certificate chain received after 1s... ***");
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                        }   
                    }
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mdw_securedMessage_CAMs
                    ))) {
                        tc_ac.stop;
                        log("*** " & testcasename() & ": INFO: CAM retransmission w/o certificate chain ***"); 
                        tc_ac.start;
                        repeat;
                    }
                    [] t_minTransInterval.timeout {
                        log("*** " & testcasename() & ": INFO: Next CAM shall contain certificate chain ***");
                        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_09_01
            
            /**
             * @desc    Check that message generation time is inside the validity period of the signing certificate
             * <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
             * @reference ETSI TS 103 097 V1.1.14, clause 7.1
             */
            testcase TC_SEC_ITSS_SND_CAM_10_01() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                const integer c_timeThreshold := 5000; /** 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();
                        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. ***");
                            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
                    ))) {
                        tc_ac.stop;
                        log("*** " & testcasename() & ": INFO: CAM retransmission w/o certificate  ***"); 
                        tc_ac.start;
                        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
            
            /**
             * @desc    Check secured CAM its_aid value
             * <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' (16512)
             *              }
             *          }
             *      }
             *  }
             * </pre>
             *
             * @see
             * @reference ETSI TS 103 097 V1.1.14, clause 7.1
             */
            testcase TC_SEC_ITSS_SND_CAM_11_01() 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_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
            
            /**
             * @desc    Check that the IUT sends certificate request when it receives a message from unknown station
             * <pre>
             * Pics Selection: PICS_GN_SECURITY
             * Config Id: CF01
             * Initial conditions:
             *  with {
             *      the IUT being in the 'authorized' state
             *      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 {
             *          the IUT sends a SecuredMessage {
             *              containing header_fields['request_unrecognized_certificate'] {
             *                  containing digests
             *                      containing HashedId3 value
             *                          indicating DIGEST_A
             *              }
             *              containing header_fields ['its_aid'] {
             *                  containing its_aid
             *                      indicating 'AID_CAM'
             *          }
             *      }
             *  }
             * </pre>
             *
             * @see
             * @reference ETSI TS 103 097 V1.1.14, clause 7.1
             */
            testcase TC_SEC_ITSS_SND_CAM_12_01() 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();
                // Send secured message from unknown ITS-S
                f_sendSecuredCam(cc_taCert_B);
                geoNetworkingPort.clear;
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
                tc_ac.start;
                alt {
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mdw_securedMessage_CAMs(
                                    mw_header_field_request_unrecognized_certificate(
                                        {
                                            f_HashedId3FromHashedId8(
                                                vc_lastAtCertificateUsed.signer_info.signerInfo.digest
                                            )
                                        } // End of list
                    ))))) {
                        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_dummy
                    ))) {
                        tc_ac.stop;
                        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
            
            /**
             * @desc    Check that the Secured CAM contains exactly one non-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 {
             *          the IUT is requested to send a CAM
             *      } then {
             *          the IUT sends a SecuredMessage {
             *              containing header_fields ['its_aid'] {
             *                  containing its_aid
             *                      indicating 'AID_CAM' (16512)
             *              }
             *              containing payload_field
             *                  containing exactly one element of type Payload {
             *                      containing type
             *                          indicating 'signed'
             *                      containing not-empty data
             *                  }
             *          }
             *      }
             *  }
             * </pre>
             *
             * @see
             * @reference ETSI TS 103 097 V1.1.14, clause 7.1
             */
            testcase TC_SEC_ITSS_SND_CAM_14_01() 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
            
            /**
             * @desc    Check that the secured CAM 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.
             * <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 ['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)
             *                  }
             *                  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)
             *                  }
             *              }
             *              containing header_fields ['its_aid'] {
             *                  containing its_aid
             *                      indicating 'AID_CAM'
             *              }
             *              containing trailer_fields {
             *                  containing single instance of type TrailerField {
             *                      containing type
             *                          indicating 'signature'
             *                      containing signature
             *                          verifiable using KEY
             *                  }
             *              }
             *          }
             *      }
             *  }
             * </pre>
             *
             * @see
             * @reference ETSI TS 103 097 V1.1.14, clause 7.1
             */
            testcase TC_SEC_ITSS_SND_CAM_16_01() 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
                
2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533
                // 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
            
        } // End of group secCAMProfile
        
        group secDENMProfile {
            
            /**
             * @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  
             * <pre>
             * Pics Selection: none
             * Config Id: CF01
             * Initial conditions:
             * with {
             *   the IUT being in the 'authorized' state
             * }
             * ensure that {
             *   when {
             *     the IUT is requested to send DENM
             *   } then {
             *     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']
             *       containing header_fields ['its_aid'] {
             *          containing its_aid
             *              indicating 'AID_DENM'
             *       }
             *       not containing header_fields ['generation_time_with_confidence']
             *     }
             *   }
             * }
             * </pre>
             * @see
             * @reference ETSI TS 103 097 V1.1.14, clause 7.2
             */
            testcase TC_SEC_ITSS_SND_DENM_02_01() runs on ItsGeoNetworking system ItsSecSystem {
                // Local variables
                var GeoNetworkingInd v_geoNwInd;
                var HeaderFields v_headersFields;
                var HeaderFieldType v_previousHeaderType;
                var ItsDenm v_denmComponent;
                
                // Test control
                
                // 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(
                                            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 := 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 (v_headersFields[v_counter].type_ == v_previousHeaderType) {
                                    log("*** " & testcasename() & ": FAIL: multiple instances of same header");
                                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                                }
                                
                                // Check that headers are ordered
                                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_cancelDenmEvent(v_denmComponent);
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_ITSS_SND_DENM_02_01
            
            /**
             * @desc   Check that secured DENM contains the certificate as a signer_info   
             * <pre>
             * Pics Selection: none
             * 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
             * @reference ETSI TS 103 097 V1.1.14, clause 7.2
             */
            testcase TC_SEC_ITSS_SND_DENM_03_01() 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
                
                // 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(
                                    mw_header_field_signer_info_certificate
                                ), 
                                mw_geoNwAnyPacket_withPayload(
                                    ?
                    )))) {
                        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(
                                    mw_header_field(
                                        e_signer_info
                                    )
                                ), 
                                mw_geoNwAnyPacket_withPayload(
                                    ?
                    )))) {
                        tc_ac.stop;
                        log("*** " & testcasename() & ": FAIL: DENM signed with digest");
                        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();
            }
            
            /**
             * @desc   Check that message generation time is inside the validity period of the signing certificate
             *         Check that message generation time value is realistic (according to values proposed in C2C SEC12)    
             * <pre>
             * Pics Selection: none
             * 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 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_start_and_end'] {
             *               containing start_validity
             *                 indicating value <= TIME_1
             *               containing end_validity
             *                 indicating value > TIME_1
             *             }
             *             or not containing validity_restrictions['time_start_and_end']
             *           }
             *         }
             *       }
             *     }
             *   }
             * }
             * </pre>
             * @see
             * @reference   ETSI TS 103 097 V1.1.14, clauses 5.4, 7.2
             */
            testcase TC_SEC_ITSS_SND_DENM_04_01() runs on ItsGeoNetworking system ItsSecSystem {
                // Local variables
                var GeoNetworkingInd v_geoNwInd;
                var HeaderField      v_headerField;
                var Time64           v_generationTime;
                var Time64           v_curTime;
                var Time64           v_startTime, v_endTime;
                var Certificate      v_cert;
                var ItsDenm          v_denmComponent;
                
                // Test control
                
                // 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 
                         
                        if (f_getMsgHeaderField(v_geoNwInd.msgIn.gnPacket.securedMsg,
                                               e_generation_time, v_headerField)) {
                            v_generationTime := v_headerField.headerField.generation_time; 
                            if (v_generationTime < v_curTime - (10*60*3600)) {
                                log("*** " & testcasename() & ": FAIL: DENM generation time is too far in the past");
                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                            }
                            
                            if (v_generationTime > v_curTime + (10*60*3600)) {
                                log("*** " & testcasename() & ": FAIL: DENM 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 (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 (v_generationTime > v_endTime ) {
                                            log("*** " & testcasename() & ": FAIL: DENM generation time is not inside the validity of the certificate");
                                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                                        }
                                    }
                                    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: DENM generation time is not inside the validity of 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);
                            } else {
                                log("*** " & testcasename() & ": INCONC: DENM signer info is not available");
                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                            }
                        } else {
                            log("*** " & testcasename() & ": FAIL: DENM doesn't contain generation time header");
                            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
            
            /**
             * @desc   Check that the secured DENM contains exactly one HeaderField generation_location
             *         when AT certificate does not contain any region restrictions
             * <pre>
             * Pics Selection: none
             * Config Id: CF01
             * with {
             *   the IUT has been authorized with the AT certificate (CERT_AT_A)
             *     not containing validity_restrictions['region']
             * }
             * ensure that {
             *   when {
             *     the IUT is requested to send DENM
             *   } then {
             *     the IUT sends a SecuredMessage {
             *       containing exactly one header_fields ['generation_location']
             *         containing generation_location
             *       containing header_fields ['its_aid'] {
             *          containing its_aid
             *              indicating 'AID_DENM'
             *       }
             *     }
             *   }
             * }
             * </pre>
             * @reference       ETSI TS 103 097 V1.1.14, clause 7.2
             */
            testcase TC_SEC_ITSS_SND_DENM_05_01() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var Certificate v_atCertificate;
                var ItsDenm     v_denmComponent;
                
                // Test component configuration
                f_cf01Up();
                
                // Test adapter configuration
                
                // Preamble
                f_prNeighbour();
                // Load IUT certificate IUT_CERT_A 
                f_readCertificate("IUT_CERT_A.AT_CERT", v_atCertificate);
                // TODO: Push Certificate IUT_CERT_A
                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_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);
                    }
                    [] 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
            
            function f_TC_SEC_ITSS_SND_DENM_05(
                                           in template GeographicRegion pmw_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(
                                                        pmw_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: IMPOSSIBLE!!! DENM generation location or certificate region restriction header field does not exist");
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                        }
                    }
                    // DENM doesn't 'contains generation location and certificate with region restrictions 
                    // FIXME Not possible, generation_location field is mandatory for DENM
//                    [] geoNetworkingPort.receive(
//                        mw_geoNwInd(
//                            mw_geoNwSecPdu(
//                                mdw_securedMessage_DENMs(
//                                    complement( // FIXME Cannot work !!!
//                                        superset(
//                                            mw_header_field(
//                                                e_generation_location
//                    ))))))) {
//                        tc_ac.stop;
//                        log("*** " & testcasename() & ": FAIL: DENM doesn't contain generation location header");
//                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
//                    }
                    // DENM signing certificate doesn't 'contains region restriction
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mdw_securedMessage_DENMs(
                                    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_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
            
            /**
             * @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: none
             * Config Id: CF01
             * with {
             *   the IUT has been authorized with the AT certificate (CERT_AT_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 {
             *     the IUT sends a SecuredMessage {
             *       containing exactly one header_fields ['generation_location']
             *         containing generation_location
             *           indicating value inside the REGION
             *       containing header_fields ['its_aid'] {
             *          containing its_aid
             *              indicating 'AID_DENM'
             *       }
             *     }
             *   }
             * }
             * </pre>
             * @reference       ETSI TS 103 097 V1.1.14, clause 7.2
             */
            testcase TC_SEC_ITSS_SND_DENM_05_02() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var Certificate v_atCertificate;
                
                // Test control
                
                // Test component configuration
                f_cf01Up();
                
                // Test adapter configuration
                
                // Preamble
                f_prNeighbour();
                // Load IUT certificate IUT_CERT_B
                f_readCertificate("IUT_CERT_B.AT_CERT", v_atCertificate);
                // TODO: Push Certificate IUT_CERT_B 
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
                f_TC_SEC_ITSS_SND_DENM_05(mw_geographicRegion_circle);
                
                // Postamble
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_ITSS_SND_DENM_05_02

            /**
             * @desc   Check that the secured DENM 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: none
             * Config Id: CF01
             * with {
             *   the IUT has been authorized with the AT certificate (CERT_AT_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 {
             *     the IUT sends a SecuredMessage {
             *       containing exactly one header_field ['generation_location']
             *         containing generation_location
             *           indicating value inside the REGION
             *       containing header_field ['its_aid'] {
             *          containing its_aid
             *              indicating 'AID_DENM'
             *       }
             *     }
             *   }
             * }
             * </pre>
             * @reference       ETSI TS 103 097 V1.1.14, clause 7.2
             */
            testcase TC_SEC_ITSS_SND_DENM_05_03() runs on ItsGeoNetworking system ItsSecSystem {
                // Test control
                var Certificate v_atCertificate;
                
                // Test component configuration
                f_cf01Up();
                
                // Test adapter configuration
                
                // Load IUT certificate IUT_CERT_C 
                f_readCertificate("IUT_CERT_C.AT_CERT", v_atCertificate);
                // TODO: Push Certificate IUT_CERT_C
                
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);    
                
                // Test Body
                f_TC_SEC_ITSS_SND_DENM_05(mw_geographicRegion_rectangular);
                
                // Postamble
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_ITSS_SND_DENM_05_03
            
            /**
             * @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: none
             * Config Id: CF01
             * with {
             *   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 DENM
             *   } then {
             *     the IUT sends a SecuredMessage {
             *       containing exactly one header_field ['generation_location']
             *         containing generation_location
             *           indicating value inside the REGION
             *       containing header_field ['its_aid'] {
             *          containing its_aid
             *              indicating 'AID_DENM'
             *       }
             *     }
             *   }
             * }
             * </pre>
             * @reference       ETSI TS 103 097 V1.1.14, clause 7.2
             */
            testcase TC_SEC_ITSS_SND_DENM_05_04() runs on ItsGeoNetworking system ItsSecSystem {
                // Test control
                var Certificate v_atCertificate;
                
                // Test component configuration
                f_cf01Up();
                
                // Test adapter configuration
                
                // Load IUT certificate IUT_CERT_D 
                f_readCertificate("IUT_CERT_D.AT_CERT", v_atCertificate);
                // TODO: Push Certificate IUT_CERT_D
                
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);    
                
                // Test Body
                f_TC_SEC_ITSS_SND_DENM_05(mw_geographicRegion_polygonal);
                
                // Postamble
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_ITSS_SND_DENM_05_04
            
            /**
             * @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: none
             * Config Id: CF01
             * with {
             *   the IUT has been authorized with the AT certificate (CERT_AT_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 {
             *     the IUT sends a SecuredMessage {
             *          containing exactly one header_fields ['generation_location'] {
             *              containing generation_location
             *                  indicating value inside the REGION
             *              containing header_fields ['its_aid'] {
             *                  containing its_aid
             *                      indicating 'AID_DENM'
             *              }
             *          }
             *     }
             *   }
             * }
             * </pre>
             * @reference       ETSI TS 103 097 V1.1.14, clause 7.2
             */
            testcase TC_SEC_ITSS_SND_DENM_05_05() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var Certificate v_atCertificate;
                
                //  Test control
                
                // Test component configuration
                f_cf01Up();
                
                // Test adapter configuration
                
                // Load IUT certificate IUT_CERT_E 
                f_readCertificate("IUT_CERT_E.AT_CERT", v_atCertificate);
                // TODO: Push Certificate IUT_CERT_E
                
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);    
                
                // Test Body
                f_TC_SEC_ITSS_SND_DENM_05(mw_geographicRegion_identified);
                
                // Postamble
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_ITSS_SND_DENM_05_05
            
            /**
             * @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     
             * <pre>
             * Pics Selection: none
             * 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
             *       containing header_fields ['its_aid'] {
             *          containing its_aid
             *              indicating 'AID_DENM'
             *       }
             *     }
             *   }
             * }
             * </pre>
             * @reference       ETSI TS 103 097 V1.1.14, clause 7.2
             */
            testcase TC_SEC_ITSS_SND_DENM_05_06() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var Certificate v_atCertificate;
                
                // Test control
                
                // Test component configuration
                f_cf01Up();
                
                // Test adapter configuration
                
                // Load IUT certificate IUT_CERT_B 
                f_readCertificate("IUT_CERT_B.AT_CERT", v_atCertificate);
                // TODO: Push Certificate IUT_CERT_B
                
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);    
                
                // Test Body
                f_TC_SEC_ITSS_SND_DENM_05(); // any type of regions
                
                // Postamble
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_ITSS_SND_DENM_05_06
            
            /**
             * @desc   Check secured DENM message type    
             * <pre>
             * Pics Selection: none
             * 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' (16513)
             *              }
             *         }
             *     }
             * }
             * </pre>
             * @see
             * @reference   ETSI TS 103 097 V1.1.14, clause 7.2
             */
            testcase TC_SEC_ITSS_SND_DENM_06_01() runs on ItsGeoNetworking system ItsSecSystem {
                // Local variables
                var ItsDenm v_denmComponent;
                
                // Test control
                
                // 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(
                                    mw_header_field_its_aid_CAM
                    )))) {
                        log("*** " & testcasename() & ": PASS: DENM message type is set to '1'");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                    }
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mdw_securedMessage_DENMs
                    ))) {
                        log("*** " & testcasename() & ": FAIL: DENM message type is not '1'");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                    }
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mdw_securedMessage_DENMs
                    ))) {
                        log("*** " & testcasename() & ": FAIL: DENM message type header field does not exist");
                        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
            
            /**
             * @desc   Check secured DENM message type
             * <pre>
             * Pics Selection: none
             * 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'
             *             }
             *             containing payload_field
             *                 containing exactly one element of type Payload {
             *                     containing type
             *                         indicating 'signed'
             *                             containing not-empty data
             *             }
             *         }
             *     }
             * }
             * </pre>
             * @see
             * @reference   ETSI TS 103 097 V1.1.14, clause 7.2
             */
            testcase TC_SEC_ITSS_SND_DENM_08_01() runs on ItsGeoNetworking system ItsSecSystem {
                // Local variables
                var ItsDenm v_denmComponent;
                
                // 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(
                                    ?,
                                    mw_payload(e_signed)
                    )))) {
                        log("*** " & testcasename() & ": PASS: DENM payload is 'signed'");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                    }
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                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(
                                mdw_securedMessage_DENMs
                    ))) {
                         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);
                    }
                } // End of 'alt' statement
                
                // Postamble
                f_cancelDenmEvent(v_denmComponent);
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_ITSS_SND_DENM_08_01
            
            /**
             * @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.     
             * <pre>
             * Pics Selection: none
             * Config Id: CF01
             * Initial conditions:
             * with {
             *   the IUT being in the 'authorized' state
             * }
             * ensure that {
             *   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 header_field ['its_aid'] {
             *          containing its_aid
             *              indicating 'AID_DENM'
             *       }
             *       containing trailer_fields {
             *         containing single instance of type TrailerField {
             *           containing type
             *             indicating 'signature'
             *           containing signature
             *             verifiable using KEY
             *           }
             *       }
             *     }
             *   }
             * }
             * </pre>
             * @see
             * @reference   ETSI TS 103 097 V1.1.14, clause 7.2
             */
            testcase TC_SEC_ITSS_SND_DENM_10_01() runs on ItsGeoNetworking system ItsSecSystem {
                //  Local variables
                var GeoNetworkingInd v_geoNwInd;
                var SignerInfo v_signerInfo;
                var Certificate v_certificate;
                var ItsDenm v_denmComponent;
                
                //  Test component configuration
                f_cf01Up();
                
                // 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
                    )))) -> 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);
                        }
                    }
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: Expected DENM not received ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                    }
                } // End of 'alt' statement
                log("*** " & testcasename() & ": PASS: DENM received with correct signature");
                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                
                // Postamble
                f_cancelDenmEvent(v_denmComponent);
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_ITSS_SND_DENM_10_01
                
        } // End of group secDENMProfile
        
        group secOtherProfile {
            
            /**
             * @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: none
             * 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 {
             *       containing header_fields [0].type
             *         indicating 'signer_info'
             *       containing header_fields [1..n] 
             *         where header_fields [v_counter].type < header_fields [v_counter + 1].type
             *       containing header_fields ['generation_time']
             *       containing header_fields ['generation_location']
             *       not containing header_field ['its_aid']
             *         indicating 'AID_CAM'
             *       not containing header_field ['its_aid']
             *         indicating 'AID_DENM'
             *     }
             *   }  
             * }
             * </pre>
             * @see
             * @reference ETSI TS 103 097 V1.1.14, clause 7.3
             */
            testcase TC_SEC_ITSS_SND_GENMSG_02_01() 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
                
                // 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),
                                        complement(
                                            mw_header_field_its_aid_CAM,
                                            mw_header_field_its_aid_DENM
                                        )
                                    )
                                ), 
                                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
            
            /**
             * @desc   Check that generic secured message contains the certificate as a signer_info
             * <pre>
             * Pics Selection: none
             * 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 {
             *     the IUT sends a SecuredMessage {
             *       containing exactly one header_fields ['signer_info'] {
             *         containing signer {
             *           containing type
             *             indicating 'certificate'
             *           containing certificate
             *         }
             *       }
             *       not containing header_field ['its_aid']
             *         indicating 'AID_CAM'
             *       not containing header_field ['its_aid']
             *         indicating 'AID_DENM'
             *     }
             *   }
             * }
             * </pre>
             * @see
             * @reference ETSI TS 103 097 V1.1.14, clause 7.3
             */
            testcase TC_SEC_ITSS_SND_GENMSG_03_01() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var LongPosVector v_longPosVectorIut;
                
                // Test control
                
                // 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
            
            /**
             * @desc   Check that message generation time is inside the validity period of the signing certificate
             *         Check that message generation time value is realistic (according to values proposed in C2C SEC12)    
             * <pre>
             * Pics Selection: none
             * 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 {
             *     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_start_and_end'] {
             *               containing start_validity
             *                 indicating value <= TIME_1
             *               containing end_validity
             *                 indicating value > TIME_1
             *             }
             *             or not containing validity_restrictions['time_start_and_end']
             *           }
             *         }
             *       }
             *     }
             *   }
             * }
             * </pre>
             * @see
             * @reference   ETSI TS 103 097 V1.1.14, clauses 5.4, 7.3
             */
            testcase TC_SEC_ITSS_SND_GENMSG_04_01() 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;
                var Time64           v_startTime, v_endTime;
                var Certificate      v_cert;
                var integer          v_counter;
                
                // Test control
                
                // 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,
                                        complement(
                                            mw_header_field_its_aid_CAM,
                                            mw_header_field_its_aid_DENM
                                        )
                                    )
                                ), 
                                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);
                                        }
                                    }
                                    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);
                                        }
                                    }
                                } // 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

            /**
             * @desc   Check that the secured GN Beacon contains exactly one HeaderField generation_location
             *         when AT certificate does not contain any region restrictions    
             * <pre>
             * Pics Selection: none
             * Config Id: CF01
             * with {
             *   the IUT has been authorized with the AT certificate (CERT_AT_A)
             *     not containing validity_restrictions['region']
             * }
             * ensure that {
             *   when {
             *     the IUT is requested to send a Beacon
             *   } then {
             *     the IUT sends a SecuredMessage {
             *       containing exactly one header_fields ['generation_location']
             *         containing generation_location
             *       not containing header_field ['its_aid']
             *         indicating 'AID_CAM'
             *       not containing header_field ['its_aid']
             *         indicating 'AID_DENM'
             *     }
             *   }
             * }
             * </pre>
             * @reference       ETSI TS 103 097 V1.1.14, clause 7.2
             */
            testcase TC_SEC_ITSS_SND_GENMSG_05_01() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var LongPosVector v_longPosVectorIut;
                
                // 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_certificate(
                                        ?,
                                        ?,
                                        ?,
                                        superset(
                                            mw_validity_restriction_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
            
            /**
             * @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: none
             * Config Id: CF01
             * with {
             *   the IUT has been authorized with the AT certificate (CERT_AT_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 GN Beacon
             *   } then {
             *     the IUT sends a SecuredMessage {
             *       containing exactly one header_fields ['generation_location']
             *         containing generation_location
             *           indicating value inside the REGION
             *       not containing header_field ['its_aid']
             *         indicating 'AID_CAM'
             *       not containing header_field ['its_aid']
             *         indicating 'AID_DENM'
             *     }
             *   }
             * }
             * </pre>
             * @reference       ETSI TS 103 097 V1.1.14, clause 7.2
             */
            testcase TC_SEC_ITSS_SND_GENMSG_05_02() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var LongPosVector   v_longPosVectorIut;
                var Certificate     v_atCertificate;
                
                // Test control
                
                // Test component configuration
                f_cf01Up();
                v_longPosVectorIut := f_getPosition(c_compIut);
                
                // Test adapter configuration
                
                // Load IUT certificate IUT_CERT_B 
                f_readCertificate("IUT_CERT_B.AT_CERT", v_atCertificate);
                // TODO: Push Certificate IUT_CERT_B
                
                // 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(mw_geographicRegion_circle);
                
                // Postamble
                f_acTriggerEvent(m_stopPassBeaconing);
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_ITSS_SND_GENMSG_05_02

            /**
             * @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: none
             * Config Id: CF01
             * with {
             *   the IUT has been authorized with the AT certificate (CERT_AT_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 {
             *     the IUT sends a SecuredMessage {
             *       containing exactly one header_fields ['generation_location']
             *         containing generation_location
             *           indicating value inside the REGION
             *       not containing header_field ['its_aid']
             *         indicating 'AID_CAM'
             *       not containing header_field ['its_aid']
             *         indicating 'AID_DENM'
             *     }
             *   }
             * }
             * </pre>
             * @reference       ETSI TS 103 097 V1.1.14, clause 7.2
             */
            testcase TC_SEC_ITSS_SND_GENMSG_05_03() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var LongPosVector   v_longPosVectorIut;
                var Certificate     v_atCertificate;
                
                // Test component configuration
                f_cf01Up();
                v_longPosVectorIut := f_getPosition(c_compIut);
                
                // Test adapter configuration
                
                // Load IUT certificate IUT_CERT_C 
                f_readCertificate("IUT_CERT_C.AT_CERT", v_atCertificate);
                // TODO: Push Certificate IUT_CERT_C
                
                // 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(mw_geographicRegion_rectangular);
                
                // Postamble
                f_acTriggerEvent(m_stopPassBeaconing);
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_ITSS_SND_GENMSG_05_03
            
            /**
             * @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: none
             * Config Id: CF01
             * with {
             *   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 {
             *     the IUT sends a SecuredMessage {
             *       containing exactly one header_fields ['generation_location']
             *         containing generation_location
             *           indicating value inside the REGION
             *       not containing header_field ['its_aid']
             *         indicating 'AID_CAM'
             *       not containing header_field ['its_aid']
             *         indicating 'AID_DENM'
             *     }
             *   }
             * }
             * </pre>
             * @reference       ETSI TS 103 097 V1.1.14, clause 7.2
             */
            testcase TC_SEC_ITSS_SND_GENMSG_05_04() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var LongPosVector   v_longPosVectorIut;
                var Certificate     v_atCertificate;
                
                // Test component configuration
                f_cf01Up();
                v_longPosVectorIut := f_getPosition(c_compIut);
                
                // Test adapter configuration
                
                // Load IUT certificate IUT_CERT_D 
                f_readCertificate("IUT_CERT_D.AT_CERT", v_atCertificate);
                // TODO: Push Certificate IUT_CERT_D
                
                // 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(mw_geographicRegion_polygonal);
                
                // Postamble
                f_acTriggerEvent(m_stopPassBeaconing);
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_ITSS_SND_GENMSG_05_04
            
            /**
             * @desc   Check that the secured GN Message 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: none
             * Config Id: CF01
             * with {
             *   the IUT has been authorized with the AT certificate (CERT_AT_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 {
             *     the IUT sends a SecuredMessage {
             *       containing exactly one header_fields ['generation_location']
             *         containing generation_location
             *           indicating value inside the REGION
             *       not containing header_field ['its_aid']
             *         indicating 'AID_CAM'
             *       not containing header_field ['its_aid']
             *         indicating 'AID_DENM'
             *     }
             *   }
             * }
             * </pre>
             * @reference       ETSI TS 103 097 V1.1.14, clause 7.2
             */
            testcase TC_SEC_ITSS_SND_GENMSG_05_05() runs on ItsGeoNetworking system ItsSecSystem {
                // Local variables
                var LongPosVector   v_longPosVectorIut;
                var Certificate     v_atCertificate;
                
                // Test component configuration
                f_cf01Up();
                v_longPosVectorIut := f_getPosition(c_compIut);
                
                // Test adapter configuration
                
                // Load IUT certificate IUT_CERT_E 
                f_readCertificate("IUT_CERT_E.AT_CERT", v_atCertificate);
                // TODO: Push Certificate IUT_CERT_E
                
                // 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(mw_geographicRegion_identified);
                
                // Postamble
                f_acTriggerEvent(m_stopPassBeaconing);
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_ITSS_SND_GENMSG_05_05
            
            /**
             * @desc   Check that the secured GN Message 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     
             * <pre>
             * Pics Selection: none
             * Config Id: CF01
             * with {
             *   the IUT being in the 'authorized' state
             * }
             * ensure that {
             *   when {
             *     the IUT is requested to send a Beacon
             *   } 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
             *       not containing header_field ['its_aid']
             *         indicating 'AID_CAM'
             *       not containing header_field ['its_aid']
             *         indicating 'AID_DENM'
             *     }
             *   }
             * }
             * </pre>
             * @reference       ETSI TS 103 097 V1.1.14, clause 7.2
             */
            testcase TC_SEC_ITSS_SND_GENMSG_05_06() runs on ItsGeoNetworking system ItsSecSystem {
                // Local variables
                var LongPosVector   v_longPosVectorIut;
                var Certificate     v_atCertificate;
                
                // Test component configuration
                f_cf01Up();
                v_longPosVectorIut := f_getPosition(c_compIut);
                
                // Test adapter configuration
                
                // Load IUT certificate IUT_CERT_B 
                f_readCertificate("IUT_CERT_B.AT_CERT", v_atCertificate);
                // TODO: Push Certificate IUT_CERT_B
                
                // 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(); // any type of regions
                
                // Postamble
                f_acTriggerEvent(m_stopPassBeaconing);
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_ITSS_SND_GENMSG_05_06
            
            group f_TC_SEC_ITSS_SND_GENMSG_05_xx {
                
                function f_TC_SEC_ITSS_SND_GENMSG_05(
                                                       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 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: 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 
                
            } // End of group f_TC_SEC_ITSS_SND_GENMSG_05_xx
            
            /**
             * @desc        Check that the secured message contains exactly one payload of type signed     
             * <pre>
             * Pics Selection: none
             * 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 {
             *            not containing header_field ['its_aid']
             *              indicating 'AID_CAM'
             *            not containing header_field ['its_aid']
             *              indicating 'AID_DENM'
             *            containing payload_fields
             *              containing exactly one element of type Payload {
             *                containing type
             *                  indicating 'signed'
             *                containing not-empty data
             *              }
             *         }
             *     }
             * }
             * </pre>
             * @see
             * @reference   ETSI TS 103 097 V1.1.14, clause 7.3
             */
            testcase TC_SEC_ITSS_SND_GENMSG_06_01() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var LongPosVector v_longPosVectorIut;
                
                // 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_geoNwBeaconPacket(
                                    ?
                    )))) { 
                        log("*** " & testcasename() & ": FAIL: Beacon multiple payloads");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                    }
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mdw_securedMessage_Others(
                                    ? 
                                    //omit // FIXME Not possible due to SecuredMessage typing
                                ),
                                mw_geoNwBeaconPacket(
                                    ?
                    )))) { 
                        log("*** " & testcasename() & ": FAIL: Beacon payload is ommited");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                    }
                    [] 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(
                                    ?, 
                                    mw_payload
                                ),
                                mw_geoNwBeaconPacket(
                                    ?
                    )))) { 
                        log("*** " & testcasename() & ": FAIL: Beacon payload is not 'signed'");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                    }
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mdw_securedMessage_Others(
                                    ?, 
                                    mw_payload(
                                        e_signed, 
                                        ? length(0) // TODO ''O ?????
                                    )
                                ),
                                mw_geoNwBeaconPacket(
                                    ?
                    )))) { 
                        log("*** " & testcasename() & ": FAIL: Beacon payload data is empty");
                        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
            
            /**
             * @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.     
             * <pre>
             * Pics Selection: none
             * Config Id: CF01
             * Initial conditions:
             * with {
             *   the IUT being in the 'authorized' state
             * }
             * ensure that {
             *   when {
             *     the IUT is requested to send Beacon
             *   } then {
             *     the IUT sends a SecuredMessage {
             *       containing header_fields ['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)
             *         }
             *       }
             *       not containing header_field ['its_aid']
             *         indicating 'AID_CAM'
             *       not containing header_field ['its_aid']
             *         indicating 'AID_DENM'
             *       containing trailer_fields {
             *         containing single instance of type TrailerField {
             *           containing type
             *             indicating 'signature'
             *           containing signature
             *             verifiable using KEY        }
             *       }
             *     }
             *   }
             * }
             * </pre>
             * @see
             * @reference   ETSI TS 103 097 V1.1.14, clause 7.3
             */
            testcase TC_SEC_ITSS_SND_GENMSG_07_01() runs on ItsGeoNetworking system ItsSecSystem {
                
                //  Local variables
                var LongPosVector v_longPosVectorIut;
                var GeoNetworkingInd v_geoNwInd;
                var SignerInfo v_signerInfo;
                
                //  Test component configuration
                f_cf01Up();
                v_longPosVectorIut := f_getPosition(c_compIut);
                
                // 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_10_01
            
        } // End of group secOtherProfile
        
    } // End of group g_SecuredMessages
    
    group g_receiverBehavior {
        
        group g_recvCamProfile {
            
            /**
             * @desc    Check that IUT accepts a well-formed Secured CAM containing certificate in signer_info
             * <pre>
             * Pics Selection: none
             * 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'
             *                  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 containing header_fields [1] {
             *                  containing type
             *                      indicating 'generation_time'
             *                  containing generation_time
             *                      indicating CURRENT_TIME
             *              }
             *              and containing header_fields[2] {
             *                  containing type
             *                      indicating 'its_aid'
             *                  containing its_aid
             *                      indicating 'AID_CAM'
             *              }
             *              and not containing any other header fields
             *              and containing payload_field {
             *                  containing type
             *                      indicating 'signed'
             *                  containing data
             *                      indicating length > 0
             *                      containing CAM payload
             *              }
             *              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
             * @reference ETSI TS 103 097 V1.1.14, clause 7.1
             */
            testcase TC_SEC_ITSS_RCV_CAM_01_01_NB() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var integer i;
                var GeoNetworkingPdu v_securedGnPdu;
                
                //  Test component configuration
                f_cf01Up();
                
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
                v_securedGnPdu := f_sendSecuredCam(cc_taCert_A, omit, e_certificate);
                
                f_sleep(PX_TAC);
                for (i := 0; i < lengthof(vc_utInds) and not match(vc_utInds[i].rawPayload, v_securedGnPdu.gnPacket.packet.payload.rawPayload); i := i + 1) {
                    // empty on purpose 
                }
                if (i < lengthof(vc_utInds)) {
                    log("*** " & testcasename() & ": PASS: GN was transmitted to upper layer ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                }
                else {
                    log("*** " & testcasename() & ": FAIL: GN was not transmitted to upper layer ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                }
                
                // Postamble
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_ITSS_RCV_CAM_01_01_NB
            
            /**
             * @desc    Check that IUT accepts a well-formed Secured CAM containing certificate digest of the known certificate in signer_info
             * <pre>
             * Pics Selection: none
             * 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'
             *                  and containing signer {
             *                      containing type
             *                          indicating 'certificate_digest_with_sha256'
             *                      and containing digest
             *                          referencing to certificate (CERT_AT_A)
             *                  }
             *              and containing header_fields [1] {
             *                  containing type
             *                      indicating 'generation_time'
             *                  containing generation_time
             *                      indicating CURRENT_TIME
             *              }
             *              and containing header_fields[2] {
             *                  containing type
             *                      indicating 'its_aid'
             *                  containing its_aid
             *                      indicating 'AID_CAM'
             *              }
             *              and not containing any other header fields
             *              and containing payload_field {
             *                  containing type
             *                      indicating 'signed'
             *                  containing data
             *                      indicating length > 0
             *                      containing CAM payload
             *              }
             *              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
             * @reference ETSI TS 103 097 V1.1.14, clause 7.1
             */
            testcase TC_SEC_ITSS_RCV_CAM_01_02_NB() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var integer i;
                var GeoNetworkingPdu v_securedGnPdu;
                
                //  Test component configuration
                f_cf01Up();
                
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
                v_securedGnPdu := f_sendSecuredCam(cc_taCert_A, omit, e_certificate_digest_with_sha256);
                
                f_sleep(PX_TAC);
                for (i := 0; i < lengthof(vc_utInds) and not match(vc_utInds[i].rawPayload, v_securedGnPdu.gnPacket.packet.payload.rawPayload); i := i + 1) {
                    // empty on purpose 
                }
                if (i < lengthof(vc_utInds)) {
                    log("*** " & testcasename() & ": PASS: GN was transmitted to upper layer ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                }
                else {
                    log("*** " & testcasename() & ": FAIL: GN was not transmitted to upper layer ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                }
                
                // Postamble
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_ITSS_RCV_CAM_01_02_NB
            
            /**
             * @desc    Check that IUT accepts a well-formed Secured CAM containing certificate chain in signer_info
             * <pre>
             * Pics Selection: none
             * 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'
             *                  and containing signer {
             *                      containing type
             *                          indicating 'certificate_chain'
             *                      and containing certificates
             *                          containing certificate (CERT_AA_A) at index 0 {
             *                              containing subject_info.subject_type
             *                                  indicating 'authorization_authority'
             *                              and containing subject_attributes['verification key'] (KEY_AA)
             *                          }
             *                          and containing certificate (CERT_AT_A) at index 1 {
             *                              containing subject_info.subject_type
             *                                  indicating 'authorization_ticket'
             *                              and containing signer_info {
             *                                  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)
             *                          }
             *                  }
             *              and containing header_fields [1] {
             *                  containing type
             *                      indicating 'generation_time'
             *                  containing generation_time
             *                      indicating CURRENT_TIME
             *              }
             *              and containing header_fields[2] {
             *                  containing type
             *                      indicating 'its_aid'
             *                  containing its_aid
             *                      indicating 'AID_CAM'
             *              }
             *              and not containing any other header fields
             *              and containing payload_field {
             *                  containing type
             *                      indicating 'signed'
             *                  containing data
             *                      indicating length > 0
             *                      containing CAM payload
             *              }
             *              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
             * @reference ETSI TS 103 097 V1.1.14, clause 7.1
             */
            testcase TC_SEC_ITSS_RCV_CAM_01_03_NB() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var integer i;
                var GeoNetworkingPdu v_securedGnPdu;
                
                //  Test component configuration
                f_cf01Up();
                
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
                v_securedGnPdu := f_sendSecuredCam(cc_taCert_A, omit, e_certificate_chain);
                
                f_sleep(PX_TAC);
                for (i := 0; i < lengthof(vc_utInds) and not match(vc_utInds[i].rawPayload, v_securedGnPdu.gnPacket.packet.payload.rawPayload); i := i + 1) {
                    // empty on purpose 
                }
                if (i < lengthof(vc_utInds)) {
                    log("*** " & testcasename() & ": PASS: GN was transmitted to upper layer ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                }
                else {
                    log("*** " & testcasename() & ": FAIL: GN was not transmitted to upper layer ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                }
                 
                // Postamble
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_ITSS_RCV_CAM_01_03_NB
            
            /**
             * @desc    Check that IUT discards a Secured CAM containing protocol version set to a value less then 2
             * <pre>
             * Pics Selection: none
             * Config Id: CF01
             * Initial conditions:
             *  with {
             *      the IUT being in the 'authorized' state
             *  }
             *  ensure that {
             *      when { 
             *          the IUT is receiving a SecuredMessage (CAM)
             *              containing protocol_version 
             *                  indicating 1
             *              containing header_fields['its_aid']
             *                  indicating 'AID_CAM'
             *      } then {
             *          the IUT discards a SecuredMessage
             *      }
             *  }
             * </pre>
             *
             * @see
             * @reference ETSI TS 103 097 V1.1.14, clause 7.1
             */
            testcase TC_SEC_ITSS_RCV_CAM_02_01a_EB() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var integer i;
                var GeoNetworkingPdu v_securedGnPdu;
                
                //  Test component configuration
                f_cf01Up();
                
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
                v_securedGnPdu := f_prepareSecuredCam(cc_taCert_A);
                v_securedGnPdu.gnPacket.securedMsg.protocol_version := 1;
                f_sendGeoNetMessage(m_geoNwReq_linkLayerBroadcast(v_securedGnPdu));
                
                f_sleep(PX_TNOAC);
                for (i := 0; i < lengthof(vc_utInds) and not match(vc_utInds[i].rawPayload, v_securedGnPdu.gnPacket.packet.payload.rawPayload); i := i + 1) {
                    // empty on purpose 
                }
                if (i < lengthof(vc_utInds)) {
                    log("*** " & testcasename() & ": FAIL: GN was transmitted to upper layer ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                }
                else {
                    log("*** " & testcasename() & ": PASS: GN was not transmitted to upper layer ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                }
                
                // Postamble
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_ITSS_RCV_CAM_02_01a_EB
            
            /**
             * @desc    Check that IUT discards a Secured CAM containing protocol version set to a value greater then 2
             * <pre>
             * Pics Selection: none
             * Config Id: CF01
             * Initial conditions:
             *  with {
             *      the IUT being in the 'authorized' state
             *  }
             *  ensure that {
             *      when { 
             *          the IUT is receiving a SecuredMessage (CAM)
             *              containing protocol_version 
             *                  indicating 3
             *              containing header_fields['its_aid']
             *                  indicating 'AID_CAM'
             *      } then {
             *          the IUT discards a SecuredMessage
             *      }
             *  }
             * </pre>
             *
             * @see
             * @reference ETSI TS 103 097 V1.1.14, clause 7.1
             */
            testcase TC_SEC_ITSS_RCV_CAM_02_01b_EB() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var integer i;
                var GeoNetworkingPdu v_securedGnPdu;
                
                //  Test component configuration
                f_cf01Up();
                
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
                v_securedGnPdu := f_prepareSecuredCam(cc_taCert_A); 
                v_securedGnPdu.gnPacket.securedMsg.protocol_version := 3;
                f_sendGeoNetMessage(m_geoNwReq_linkLayerBroadcast(v_securedGnPdu));
                
                f_sleep(PX_TNOAC);
                for (i := 0; i < lengthof(vc_utInds) and not match(vc_utInds[i].rawPayload, v_securedGnPdu.gnPacket.packet.payload.rawPayload); i := i + 1) {
                    // empty on purpose 
                }
                if (i < lengthof(vc_utInds)) {
                    log("*** " & testcasename() & ": FAIL: GN was transmitted to upper layer ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                }
                else {
                    log("*** " & testcasename() & ": PASS: GN was not transmitted to upper layer ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                }
                
                // Postamble
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_ITSS_RCV_CAM_02_01b_EB
            
            /**
             * @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: none
             * Config Id: CF01
             * Initial conditions:
             * with { 
             *  the IUT being in the 'authorized' state 
             * } 
             * ensure that { 
             *  when {  
             *      the IUT is receiving a SecuredMessage (CAM) 
             *          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] {
             *              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
             * @reference ETSI TS 103 097 V1.1.14, clause 7.1
             */
            testcase TC_SEC_ITSS_RCV_CAM_04_01a_EB() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var integer i;
                var GeoNetworkingPdu v_securedGnPdu;
                
                //  Test component configuration
                f_cf01Up();
                
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
                v_securedGnPdu := f_prepareSecuredCam(
                    {
                        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));
                
                f_sleep(PX_TNOAC);
                for (i := 0; i < lengthof(vc_utInds) and not match(vc_utInds[i].rawPayload, v_securedGnPdu.gnPacket.packet.payload.rawPayload); 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_01a_EB
            
            /**
             * @desc    Check that IUT discards a secured CAM if the header_fields does not contain the header field type: signer_info
             * <pre>
             * Pics Selection: none
             * Config Id: CF01
             * Initial conditions:
             * with { 
             *  the IUT being in the 'authorized' state 
             * } 
             * ensure that { 
             *  when {  
             *      the IUT is receiving a SecuredMessage (CAM) 
             *          containing header_fields[0].type
             *              indicating 'generation_time'
             *          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
             * @reference ETSI TS 103 097 V1.1.14, clause 7.1
             */
            testcase TC_SEC_ITSS_RCV_CAM_04_01b_EB() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var integer i;
                var GeoNetworkingPdu v_securedGnPdu;
                
                //  Test component configuration
                f_cf01Up();
                
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
                v_securedGnPdu := f_prepareSecuredCam(
                    {
                        m_header_field_generation_time(1000 * f_getCurrentTime()), // In us
                        m_header_field_its_aid_CAM
                    }, 
                    e_certificate_digest_with_sha256,
                    false
                ); 
                f_sendGeoNetMessage(m_geoNwReq_linkLayerBroadcast(v_securedGnPdu));
                
                f_sleep(PX_TNOAC);
                for (i := 0; i < lengthof(vc_utInds) and not match(vc_utInds[i].rawPayload, v_securedGnPdu.gnPacket.packet.payload.rawPayload); 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_01b_EB
            
            /**
             * @desc    Check that IUT is able to receive a secured CAM if the signer_info header field is not encoded first
             * <pre>
             * Pics Selection: none
             * Config Id: CF01
             * Initial conditions:
             * with { 
             *  the IUT being in the 'authorized' state 
             * } 
             * ensure that { 
             *  when {  
             *      TODO
             *  } then { 
             *      the IUT discards the message 
             *  } 
             * } 
             * </pre>
             *
             * @see
             * @reference ETSI TS 103 097 V1.1.14, clause 7.1
             */
            testcase TC_SEC_ITSS_RCV_CAM_04_01c_EB() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var integer i;
                var GeoNetworkingPdu v_securedGnPdu;
                
                //  Test component configuration
                f_cf01Up();
                
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
                v_securedGnPdu := f_prepareSecuredCam(
                    {
                        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);
                for (i := 0; i < lengthof(vc_utInds) and not match(vc_utInds[i].rawPayload, v_securedGnPdu.gnPacket.packet.payload.rawPayload); 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_01c_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: none
             * Config Id: CF01
             * Initial conditions:
             * with { 
             *  the IUT being in the 'authorized' state 
             * } 
             * ensure that { 
             *  when {  
             *      the IUT is receiving a SecuredMessage (CAM)
             *          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
             * @reference ETSI TS 103 097 V1.1.14, clause 7.1
             */
            testcase TC_SEC_ITSS_RCV_CAM_04_02a_EB() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var integer i;
                var GeoNetworkingPdu v_securedGnPdu;
                
                //  Test component configuration
                f_cf01Up();
                
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
                v_securedGnPdu := f_prepareSecuredCam(
                    {
                        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);
                for (i := 0; i < lengthof(vc_utInds) and not match(vc_utInds[i].rawPayload, v_securedGnPdu.gnPacket.packet.payload.rawPayload); 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_02a_EB
            
            /**
             * @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: none
             * Config Id: CF01
             * Initial conditions:
             * with { 
             *  the IUT being in the 'authorized' state 
             * } 
             * ensure that { 
             *  when {  
             *      the IUT is receiving a SecuredMessage (CAM)
             *          containing header_fields[0].type
             *              indicating 'signer_info'
             *          and containing header_fields[1].type
             *              indicating 'generation_time'
             *          and and containing header_fields[2] {
             *              containing type
             *                  indicating 'its_aid'
             *              containing its_aid
             *                  indicating 'AID_CAM'
             *          and 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
             * @reference ETSI TS 103 097 V1.1.14, clause 7.1
             */
            testcase TC_SEC_ITSS_RCV_CAM_04_03a_EB() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var integer i;
                var GeoNetworkingPdu v_securedGnPdu;
                
                //  Test component configuration
                f_cf01Up();
                
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
                v_securedGnPdu := f_prepareSecuredCam(
                    {
                        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);
                for (i := 0; i < lengthof(vc_utInds) and not match(vc_utInds[i].rawPayload, v_securedGnPdu.gnPacket.packet.payload.rawPayload); 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_03a_EB
            
            /**
             * @desc    Check that IUT ignores the HeaderFields generation_time_standard_deviation of received Secured CAM
             * <pre>
             * Pics Selection: none
             * Config Id: CF01
             * Initial conditions:
             * with { 
             *  the IUT being in the 'authorized' state 
             * } 
             * ensure that { 
             *  when {  
             *      the IUT is receiving a SecuredMessage (CAM)
             *          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 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
             * @reference ETSI TS 103 097 V1.1.14, clause 7.1
             */
            testcase TC_SEC_ITSS_RCV_CAM_04_05a_EB() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var integer i;
                var GeoNetworkingPdu v_securedGnPdu;
                
                //  Test component configuration
                f_cf01Up();
                
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
                v_securedGnPdu := f_prepareSecuredCam(
                    {
                        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);
                for (i := 0; i < lengthof(vc_utInds) and not match(vc_utInds[i].rawPayload, v_securedGnPdu.gnPacket.packet.payload.rawPayload); 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_05a_EB
            
            /**
             * @desc    Check that IUT ignores the HeaderFields generation_time_standard_deviation of received Secured CAM
             * <pre>
             * Pics Selection: none
             * Config Id: CF01
             * Initial conditions:
             * with { 
             *  the IUT being in the 'authorized' state 
             * } 
             * ensure that { 
             *  when {  
             *      the IUT is receiving a SecuredMessage (CAM)
             *          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 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
             * @reference ETSI TS 103 097 V1.1.14, clause 7.1
             */
            testcase TC_SEC_ITSS_RCV_CAM_04_05b_EB() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var integer i;
                var GeoNetworkingPdu v_securedGnPdu;
                
                //  Test component configuration
                f_cf01Up();
                
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
                v_securedGnPdu := f_prepareSecuredCam(
                    {
                        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);
                for (i := 0; i < lengthof(vc_utInds) and not match(vc_utInds[i].rawPayload, v_securedGnPdu.gnPacket.packet.payload.rawPayload); 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_05b_EB
            
            /**
             * @desc    Check that IUT discards secured CAM when its_aid value is not equal to 16512
             * <pre>
             * Pics Selection: none
             * Config Id: CF01
             * Initial conditions:
             * with { 
             *  the IUT being in the 'authorized' state 
             * } 
             * ensure that { 
             *     when {  
             *         the IUT is receiving a SecuredMessage (CAM) 
             *             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 
             *     } 
             * } 
             * </pre>
             *
             * @see
             * @reference ETSI TS 103 097 V1.1.14, clause 7.1
             */
            testcase TC_SEC_ITSS_RCV_CAM_07_01_EB() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var integer i;
                var GeoNetworkingPdu v_securedGnPdu;
                                
                //  Test component configuration
                f_cf01Up();
                
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
                v_securedGnPdu := f_prepareSecuredCam(
5491 5492 5493 5494 5495 5496 5497 5498 5499 5500 5501 5502 5503 5504 5505 5506 5507 5508 5509 5510 5511 5512 5513 5514 5515 5516 5517 5518 5519 5520 5521 5522 5523 5524 5525 5526 5527 5528 5529 5530 5531 5532 5533 5534 5535 5536 5537 5538 5539 5540 5541 5542 5543 5544 5545 5546 5547 5548 5549 5550 5551 5552 5553 5554 5555 5556 5557 5558 5559 5560 5561 5562 5563 5564 5565 5566 5567 5568 5569 5570 5571 5572 5573 5574 5575 5576 5577 5578 5579 5580 5581 5582 5583 5584 5585 5586 5587 5588 5589 5590 5591 5592 5593 5594 5595 5596 5597 5598 5599 5600 5601 5602 5603 5604 5605 5606 5607 5608 5609 5610 5611 5612 5613 5614 5615 5616 5617 5618 5619 5620 5621 5622 5623 5624 5625 5626 5627 5628 5629 5630 5631 5632 5633 5634 5635 5636 5637 5638 5639 5640 5641 5642 5643 5644 5645 5646 5647 5648 5649 5650 5651 5652 5653 5654 5655 5656 5657 5658 5659 5660 5661 5662 5663 5664 5665 5666 5667 5668 5669 5670 5671 5672 5673 5674 5675 5676 5677 5678 5679 5680 5681 5682 5683 5684 5685 5686 5687 5688 5689 5690 5691 5692 5693 5694 5695 5696 5697 5698 5699 5700 5701 5702 5703 5704 5705 5706 5707 5708 5709 5710 5711 5712 5713 5714 5715 5716 5717 5718 5719 5720 5721 5722 5723 5724 5725 5726 5727 5728 5729 5730 5731 5732 5733 5734 5735 5736 5737 5738 5739 5740 5741 5742 5743 5744 5745 5746 5747 5748 5749 5750 5751 5752 5753 5754 5755 5756 5757 5758 5759 5760 5761 5762 5763 5764 5765 5766 5767 5768 5769 5770 5771 5772 5773 5774 5775 5776 5777 5778 5779 5780 5781 5782 5783 5784 5785 5786 5787 5788 5789 5790 5791 5792 5793 5794 5795 5796 5797 5798 5799 5800 5801 5802 5803 5804 5805 5806 5807 5808 5809 5810 5811 5812 5813 5814 5815 5816 5817 5818 5819 5820 5821 5822 5823 5824 5825 5826 5827 5828 5829 5830 5831 5832 5833 5834 5835 5836 5837 5838 5839 5840 5841 5842 5843 5844 5845 5846 5847 5848 5849 5850 5851 5852 5853 5854 5855 5856 5857 5858 5859 5860 5861 5862 5863 5864 5865 5866 5867 5868 5869 5870 5871 5872 5873 5874 5875 5876 5877 5878 5879 5880 5881 5882 5883 5884 5885 5886 5887 5888 5889 5890 5891 5892 5893 5894 5895 5896 5897 5898 5899 5900 5901 5902 5903 5904 5905 5906 5907 5908 5909 5910 5911 5912 5913 5914 5915 5916 5917 5918 5919 5920 5921 5922 5923 5924 5925 5926 5927 5928 5929 5930 5931 5932 5933 5934 5935 5936 5937 5938 5939 5940 5941 5942 5943 5944 5945 5946 5947 5948 5949 5950 5951 5952 5953 5954 5955 5956 5957 5958 5959 5960 5961 5962 5963 5964 5965 5966 5967 5968 5969 5970 5971 5972
                    {
                        m_header_field_its_aid_DENM
                    }
                ); 
                f_sendGeoNetMessage(m_geoNwReq_linkLayerBroadcast(v_securedGnPdu));
                
                f_sleep(PX_TNOAC);
                for (i := 0; i < lengthof(vc_utInds) and not match(vc_utInds[i].rawPayload, v_securedGnPdu.gnPacket.packet.payload.rawPayload); 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_07_01a_EB
            
            /**
            * @desc    Check that IUT discards the Secured CAM containing empty payload of type 'signed'.
            * <pre>
            * Pics Selection: none
            * Config Id: CF01
            * Initial conditions:
            *   with {
            *       the IUT being in the 'authorized' state
            *   }
            *   ensure that {
            *       when {
            *           the IUT is receiving a SecuredMessage {
            *              and containing header_fields['its_aid']
            *                  indicating 'AID_CAM'
            *               and containing payload_field {
            *                   containing type
            *                       indicating 'signed'
            *                   containing data
            *                       indicating length 0
            *               }
            *           }
            *       } then {
            *           the IUT discards the message
            *       }
            *   }
            * </pre>
            *
            * @see
            * @reference ETSI TS 103 097 V1.1.14, clause 7.1
            */
            testcase TC_SEC_ITSS_RCV_CAM_09_02_EB() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var integer i;
                var GeoNetworkingPdu v_securedGnPdu;
                var GnNonSecuredPacket v_gnNonSecuredPacket;
                var octetstring v_gnPayload;
                var template (value) SecuredMessage v_securedMessage;
                
                //  Test component configuration
                f_cf01Up();
                
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
                v_gnNonSecuredPacket := valueof(m_geoNwShbPacket(f_getPosition(c_compNodeC)));
                v_gnNonSecuredPacket.payload.rawPayload := ''O;
                v_gnPayload := bit2oct(encvalue(v_gnNonSecuredPacket));
                f_buildGnSecuredCam(
                    v_securedMessage,
                    m_payload_signed(
                        v_gnPayload
                    )
                );
                v_securedGnPdu := valueof(m_geoNwSecPdu(v_gnNonSecuredPacket, v_securedMessage));
                f_sendGeoNetMessage(m_geoNwReq_linkLayerBroadcast(v_securedGnPdu));
                
                f_sleep(PX_TNOAC);
                for (i := 0; i < lengthof(vc_utInds) and not match(vc_utInds[i].rawPayload, v_securedGnPdu.gnPacket.packet.payload.rawPayload); i := i + 1) {
                    // empty on purpose
                }
                if (i < lengthof(vc_utInds)) {
                    log("*** " & testcasename() & ": FAIL: GN was transmitted to upper layer ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                }
                else {
                    log("*** " & testcasename() & ": PASS: GN was not transmitted to upper layer ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                }
                                
                // Postamble
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_ITSS_RCV_CAM_09_02_EB
            
            /**
            * @desc    Check that IUT discards the Secured CAM containing non-empty payload of type 'unsecured'
            * <pre>
            * Pics Selection: none
            * Config Id: CF01
            * Initial conditions:
            *   with {
            *       the IUT being in the 'authorized' state
            *   }
            *   ensure that {
            *       when {
            *           the IUT is receiving a SecuredMessage {
            *              and containing header_fields['its_aid']
            *                  indicating 'AID_CAM'
            *               and containing payload_field {
            *                   containing type
            *                       indicating 'unsecured'
            *               }
            *           }
            *       } then {
            *           the IUT discards the message
            *       }
            *   }
            * </pre>
            *
            * @see
            * @reference ETSI TS 103 097 V1.1.14, clause 7.1
            */
            testcase TC_SEC_ITSS_RCV_CAM_09_03_EB() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var integer i;
                var GeoNetworkingPdu v_securedGnPdu;
                var GnNonSecuredPacket v_gnNonSecuredPacket;
                var octetstring v_gnPayload;
                var template (value) SecuredMessage v_securedMessage;
                
                //  Test component configuration
                f_cf01Up();
                
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
                v_gnNonSecuredPacket := valueof(m_geoNwShbPacket(f_getPosition(c_compNodeC)));
                v_gnNonSecuredPacket.payload := valueof(f_adaptPayload_m(
                    bit2oct(
                        encvalue(
                            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);
                for (i := 0; i < lengthof(vc_utInds) and not match(vc_utInds[i].rawPayload, v_securedGnPdu.gnPacket.packet.payload.rawPayload); i := i + 1) {
                    // empty on purpose
                }
                if (i < lengthof(vc_utInds)) {
                    log("*** " & testcasename() & ": FAIL: GN was transmitted to upper layer ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                }
                else {
                    log("*** " & testcasename() & ": PASS: GN was not transmitted to upper layer ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                }
                
                // Postamble
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_ITSS_RCV_CAM_09_03_EB

            /**
            * @desc    Check that IUT discards the Secured CAM containing non-empty payload of type 'encrypted'
            * <pre>
            * Pics Selection: none
            * Config Id: CF01
            * Initial conditions:
            *   with {
            *       the IUT being in the 'authorized' state
            *   }
            *   ensure that {
            *       when {
            *           the IUT is receiving a SecuredMessage {
            *              and containing header_fields['its_aid']
            *                  indicating 'AID_CAM'
            *               and containing payload_field {
            *                   containing type
            *                       indicating 'encrypted'
            *               }
            *           }
            *       } then {
            *           the IUT discards the message
            *       }
            *   }
            * </pre>
            *
            * @see
            * @reference ETSI TS 103 097 V1.1.14, clause 7.1
            */
            testcase TC_SEC_ITSS_RCV_CAM_09_04_EB() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var integer i;
                var GeoNetworkingPdu v_securedGnPdu;
                var GnNonSecuredPacket v_gnNonSecuredPacket;
                var octetstring v_gnPayload;
                var template (value) SecuredMessage v_securedMessage;
                
                //  Test component configuration
                f_cf01Up();
                
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
                v_gnNonSecuredPacket := valueof(m_geoNwShbPacket(f_getPosition(c_compNodeC)));
                v_gnNonSecuredPacket.payload := valueof(f_adaptPayload_m(
                    bit2oct(
                        encvalue(
                            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));
                
                f_sleep(PX_TNOAC);
                for (i := 0; i < lengthof(vc_utInds) and not match(vc_utInds[i].rawPayload, v_securedGnPdu.gnPacket.packet.payload.rawPayload); i := i + 1) {
                    // empty on purpose
                }
                if (i < lengthof(vc_utInds)) {
                    log("*** " & testcasename() & ": FAIL: GN was transmitted to upper layer ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                }
                else {
                    log("*** " & testcasename() & ": PASS: GN was not transmitted to upper layer ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                }
                
                // Postamble
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_ITSS_RCV_CAM_09_04_EB
            
            /**
            * @desc    Check that IUT discards the Secured CAM containing exactly one non-empty payload of type 'signed_external'
            * <pre>
            * Pics Selection: none
            * Config Id: CF01
            * Initial conditions:
            *   with {
            *       the IUT being in the 'authorized' state
            *   }
            *   ensure that {
            *       when {
            *           the IUT is receiving a SecuredMessage {
            *              and containing header_fields['its_aid']
            *                  indicating 'AID_CAM'
            *               and containing payload_field {
            *                   containing type
            *                       indicating 'signed_external'
            *               }
            *           }
            *       } then {
            *           the IUT discards the message
            *       }
            *   }
            * </pre>
            *
            * @see
            * @reference ETSI TS 103 097 V1.1.14, clause 7.1
            */
            testcase TC_SEC_ITSS_RCV_CAM_09_05_EB() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var integer i;
                var GeoNetworkingPdu v_securedGnPdu;
                var GnNonSecuredPacket v_gnNonSecuredPacket;
                var octetstring v_gnPayload;
                var template (value) SecuredMessage v_securedMessage;
                
                //  Test component configuration
                f_cf01Up();
                
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
                v_gnNonSecuredPacket := valueof(m_geoNwShbPacket(f_getPosition(c_compNodeC)));
                v_gnNonSecuredPacket.payload := valueof(f_adaptPayload_m(
                    bit2oct(
                        encvalue(
                            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_securedGnPdu := valueof(m_geoNwSecPdu(v_gnNonSecuredPacket, v_securedMessage));
                f_sendGeoNetMessage(m_geoNwReq_linkLayerBroadcast(v_securedGnPdu));
                
                f_sleep(PX_TNOAC);
                for (i := 0; i < lengthof(vc_utInds) and not match(vc_utInds[i].rawPayload, v_securedGnPdu.gnPacket.packet.payload.rawPayload); i := i + 1) {
                    // empty on purpose
                }
                if (i < lengthof(vc_utInds)) {
                    log("*** " & testcasename() & ": FAIL: GN was transmitted to upper layer ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                }
                else {
                    log("*** " & testcasename() & ": PASS: GN was not transmitted to upper layer ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                }
                
                // Postamble
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_ITSS_RCV_CAM_09_05_EB
            
            /**
            * @desc    Check that IUT discards the Secured CAM containing non-empty payload of type 'signed_and_encrypted'
            * <pre>
            * Pics Selection: none
            * Config Id: CF01
            * Initial conditions:
            *   with {
            *       the IUT being in the 'authorized' state
            *   }
            *   ensure that {
            *       when {
            *           the IUT is receiving a SecuredMessage {
            *              and containing header_fields['its_aid']
            *                  indicating 'AID_CAM'
            *               and containing payload_field {
            *                   containing type
            *                       indicating 'signed_and_encrypted'
            *               }
            *           }
            *       } then {
            *           the IUT discards the message
            *       }
            *   }
            * </pre>
            *
            * @see
            * @reference ETSI TS 103 097 V1.1.14, clause 7.1
            */
            testcase TC_SEC_ITSS_RCV_CAM_09_06_EB() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var integer i;
                var GeoNetworkingPdu v_securedGnPdu;
                var GnNonSecuredPacket v_gnNonSecuredPacket;
                var octetstring v_gnPayload;
                var template (value) SecuredMessage v_securedMessage;
                
                //  Test component configuration
                f_cf01Up();
                
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
                v_gnNonSecuredPacket := valueof(m_geoNwShbPacket(f_getPosition(c_compNodeC)));
                v_gnNonSecuredPacket.payload := valueof(f_adaptPayload_m(
                    bit2oct(
                        encvalue(
                            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);
                for (i := 0; i < lengthof(vc_utInds) and not match(vc_utInds[i].rawPayload, v_securedGnPdu.gnPacket.packet.payload.rawPayload); i := i + 1) {
                    // empty on purpose
                }
                if (i < lengthof(vc_utInds)) {
                    log("*** " & testcasename() & ": FAIL: GN was transmitted to upper layer ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                }
                else {
                    log("*** " & testcasename() & ": PASS: GN was not transmitted to upper layer ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                }
                
                // Postamble
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_ITSS_RCV_CAM_09_06_EB
            
            /**
            * @desc    Check that IUT discards the Secured CAM doesn't containing the TrailerField of type 'signature'
            * <pre>
            * Pics Selection: none
            * Config Id: CF01
            * Initial conditions:
            *    with {
            *        the IUT being in the 'authorized' state
            *    }
            *    ensure that {
            *        when {
            *            the IUT is receiving a SecuredMessage {
            *              and containing header_fields['its_aid']
            *                  indicating 'AID_CAM'
            *                and containing trailer_fields
            *                    not containing any instance of type TrailerField {
            *                        containing type
            *                            indicating 'signature'
            *                    }
            *            }
            *        } then {
            *            the IUT discards the message
            *        }
            *    }
            * </pre>
            *
            * @see
            * @reference ETSI TS 103 097 V1.1.14, clause 7.1
            */
            testcase TC_SEC_ITSS_RCV_CAM_10_01_EB() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var integer i;
                var GeoNetworkingPdu v_securedGnPdu;
                                
                //  Test component configuration
                f_cf01Up();
                
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
                v_securedGnPdu := f_prepareSecuredCam(cc_taCert_A); 
                v_securedGnPdu.gnPacket.securedMsg.trailer_fields := {};
                f_sendGeoNetMessage(m_geoNwReq_linkLayerBroadcast(v_securedGnPdu));
                
                f_sleep(PX_TNOAC);
                for(i:=0; i < lengthof(vc_utInds) and not match(vc_utInds[i].rawPayload, v_securedGnPdu.gnPacket.packet.payload.rawPayload); i:=i+1) {
                // empty on purpose
                }
                if(i < lengthof(vc_utInds)) {
                    log("*** " & testcasename() & ": FAIL: GN was transmitted to upper layer ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                }
                else {
                    log("*** " & testcasename() & ": PASS: GN was not transmitted to upper layer ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                }
                                
                // Postamble
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_ITSS_RCV_CAM_10_01_EB
            
            /**
            * @desc    Check that IUT discards the Secured CAM containing more then one instance of TrailerField of type 'signature'
            * <pre>
            * Pics Selection: none
            * Config Id: CF01
            * Initial conditions:
            *   with {
            *       the IUT being in the 'authorized' state
            *   }
            *   ensure that {
            *       when {
            *           the IUT is receiving a SecuredMessage {
            *              and containing header_fields['its_aid']
            *                  indicating 'AID_CAM'
            *              and containing trailer_fields[0].type
            *                           indicating 'signature'
            *              and containing trailer_fields[1].type
            *                  indicating 'signature'
            *                   }
            *       } then {
            *           the IUT discards the message
            *       }
            *   }
            * </pre>
            *
            * @see
            * @reference ETSI TS 103 097 V1.1.14, clause 7.1
            */
            testcase TC_SEC_ITSS_RCV_CAM_10_02_EB() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var integer i;
                var GeoNetworkingPdu v_securedGnPdu;
                                
                //  Test component configuration
                f_cf01Up();
                
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
                v_securedGnPdu := f_prepareSecuredCam(cc_taCert_A); 
                v_securedGnPdu.gnPacket.securedMsg.trailer_fields[1] := v_securedGnPdu.gnPacket.securedMsg.trailer_fields[0];
                f_sendGeoNetMessage(m_geoNwReq_linkLayerBroadcast(v_securedGnPdu));
                
                f_sleep(PX_TNOAC);
                for(i:=0; i < lengthof(vc_utInds) and not match(vc_utInds[i].rawPayload, v_securedGnPdu.gnPacket.packet.payload.rawPayload); i:=i+1) {
                // empty on purpose
                }
                if(i < lengthof(vc_utInds)) {
                    log("*** " & testcasename() & ": FAIL: GN was transmitted to upper layer ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                }
                else {
                    log("*** " & testcasename() & ": PASS: GN was not transmitted to upper layer ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                }
                                
                // Postamble
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_ITSS_RCV_CAM_10_02_EB

            /**
            * @desc    Check that the IUT discards Secured message containing signature that is not verified using the 
            *        verification key from the certificate contained in the message's signer info
            * <pre>
            * Pics Selection: none
            * Config Id: CF01
            * Initial conditions:
            *   with {
            *       the IUT being in the 'authorized' state
            *   }
            *   ensure that {
            *       when {
            *           the IUT is receiving a SecuredMessage {
            *               containing header_fields ['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 header_fields['its_aid']
            *                   indicating 'AID_CAM'
            *               containing trailer_fields {
            *                   containing single instance of type TrailerField {
            *                       containing type
            *                           indicating 'signature'
            *                       containing signature
            *                           NOT verifiable using KEY
            *                   }
            *               }
            *           }
            *       } then {
            *           the IUT discards the message
            *       }
            *   }
            * </pre>
            *
            * @see
            * @reference ETSI TS 103 097 V1.1.14, clause 7.1
            */
            testcase TC_SEC_ITSS_RCV_CAM_11_01_EB() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var integer i;
                var GeoNetworkingPdu v_securedGnPdu;
                
                //  Test component configuration
                f_cf01Up();
                
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
                v_securedGnPdu := f_prepareSecuredCam(
                    omit, 
                    e_certificate
                );
                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);
                for(i:=0; i < lengthof(vc_utInds) and not match(vc_utInds[i].rawPayload, v_securedGnPdu.gnPacket.packet.payload.rawPayload); i:=i+1) {
                // empty on purpose
                }
                if(i < lengthof(vc_utInds)) {
                    log("*** " & testcasename() & ": PASS: GN was transmitted to upper layer ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                }
                else {
                    log("*** " & testcasename() & ": FAIL: GN was not transmitted to upper layer ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                }
                              
                // Postamble
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_ITSS_RCV_CAM_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: none
            * Config Id: CF01
            * Initial conditions:
            *   with {
            *       the IUT being in the 'authorized' state
            *   }
            *   ensure that {
            *       when {
            *           the IUT is receiving a SecuredMessage {
            *               containing header_fields ['signer_info'] {
            *                   containing signer {
            *                       containing type
            *                           indicating 'certificate_digest_with_sha256'
            *                       containing digest
            *                           referencing to the certificate
            *                               containing subject_info.subject_type
            *                                   indicating 'authorization_ticket' (2)
            *                               and containing subject_attributes['verification key'] (KEY)
            *                   }
            *               }
            *               containing header_fields['its_aid']
            *                   indicating 'AID_CAM'
            *               containing trailer_fields {
            *                   containing single instance of type TrailerField {
            *                       containing type
            *                           indicating 'signature'
            *                       containing signature
            *                           NOT verifiable using KEY
            *                   }
            *               }
            *           }
            *       } then {
            *           the IUT discards the message
            *       }
            *   }
            * </pre>
            *
            * @see
            * @reference ETSI TS 103 097 V1.1.14, clause 7.1
            */
            testcase TC_SEC_ITSS_RCV_CAM_11_02_EB() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var integer i;
                var GeoNetworkingPdu v_securedGnPdu;
                
                //  Test component configuration
                f_cf01Up();
                
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
                v_securedGnPdu := f_prepareSecuredCam(
                    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);
                for(i:=0; i < lengthof(vc_utInds) and not match(vc_utInds[i].rawPayload, v_securedGnPdu.gnPacket.packet.payload.rawPayload); i:=i+1) {
                // empty on purpose
                }
                if(i < lengthof(vc_utInds)) {
                    log("*** " & testcasename() & ": PASS: GN was transmitted to upper layer ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                }
                else {
                    log("*** " & testcasename() & ": FAIL: GN was not transmitted to upper layer ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                }
                
                // Postamble
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_ITSS_RCV_CAM_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: none
             * Config Id: CF01
             * Initial conditions:
             * with {
             *   the IUT being in the 'authorized' state
             * Expected behaviour:
             * ensure that {
             *   when {
             *      the IUT is receiving a SecuredMessage (CAM)
             *          containing header_field 'signer_info'
             *              containing signer_info.type
             *                  indicating 'certificate'
             *              containing signer.certificate.subject_info.subject_type
             *                  indicating 'enrolment_credentials'
             *          and containing header_field 'its_aid'
             *              indicating 'AID_CAM'
             *       }
             *       and not containing other header fields
             *   } then { 
             *      the IUT discards the message 
             *   }
             * } 
             * </pre>
             *
             * @see     ETSI TS 103 097 V1.1.14, clause 6.3 
             * @reference   EN 302 636-4-1 [1], clauses 9.3.2 , 8.6.2 and Annex G
             */
            testcase TC_SEC_ITSS_RCV_CAM_12_01_EB() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var integer i;
                var GeoNetworkingPdu v_securedGnPdu;
                
                //  Test component configuration
                f_cf01Up();
                
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
                v_securedGnPdu := f_prepareSecuredCam(
                    {
                        m_header_field_signer_info(
                            m_signerInfo_certificate(
                                vc_atCertificate
                        )), 
                        m_header_field_generation_time(1000 * f_getCurrentTime()), // In us
                        m_header_field_its_aid_CAM
                    }, 
                    e_certificate,
                    false
                ); 
                f_sendGeoNetMessage(m_geoNwReq_linkLayerBroadcast(v_securedGnPdu));
                
                f_sleep(PX_TNOAC);
                for (i := 0; i < lengthof(vc_utInds) and not match(vc_utInds[i].rawPayload, v_securedGnPdu.gnPacket.packet.payload.rawPayload); 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_12_01_EB
            
            /**
             * @desc    Check that IUT discards a Secured CAM if the signer certificate of the message contains the subject type "authorization_authority"
             * <pre>
             * Pics Selection: none
             * Config Id: CF01
             * Initial conditions:
             * with {
             *   the IUT being in the 'authorized' state
             * Expected behaviour:
             * ensure that {
             *   when {
             *      the IUT is receiving a SecuredMessage (CAM)
             *          containing header_field 'signer_info'
             *              containing signer_info.type
             *                  indicating 'certificate'
             *              containing signer.certificate.subject_info.subject_type
             *                  indicating 'authorization_authority'
             *          and containing header_field 'its_aid'
             *              indicating 'AID_CAM'
             *       }
             *       and not containing other header fields
             *   } then { 
             *      the IUT discards the message 
             *   }
             * } 
             * </pre>
             *
             * @see     ETSI TS 103 097 V1.1.14, clause 6.3 
             * @reference   EN 302 636-4-1 [1], clauses 9.3.2 , 8.6.2 and Annex G
             */
            testcase TC_SEC_ITSS_RCV_CAM_12_02_EB() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var integer i;
                var GeoNetworkingPdu v_securedGnPdu;
                
                //  Test component configuration
                f_cf01Up();
                
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
                v_securedGnPdu := f_prepareSecuredCam(
                    {
                        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,
                    false
                ); 
                f_sendGeoNetMessage(m_geoNwReq_linkLayerBroadcast(v_securedGnPdu));
                
                f_sleep(PX_TNOAC);
                for (i := 0; i < lengthof(vc_utInds) and not match(vc_utInds[i].rawPayload, v_securedGnPdu.gnPacket.packet.payload.rawPayload); 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_12_02_EB
            
        } // End of group g_recvCamProfile
        
        group g_recvDenmProfile {
            
            /**
             * @desc    Check that IUT accepts a well-formed Secured DENM signed with the certificate without region validity restriction
             * <pre>
             * Pics Selection: none
             * Config Id: CF01
             * Expected behavior:
             * with {
             *   the IUT being in the 'authorized' state
             * }
             * 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
             *              }
             *          }
             *   } then {
             *     the IUT accepts the message
             *   }
             * }
             * </pre>
             * @see
             * @reference ETSI TS 103 097 V1.1.14, clause 7.2
             */
            testcase TC_SEC_ITSS_RCV_DENM_01_01a_NB() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var integer i;
                var GeoNetworkingPdu v_securedGnPdu;
                
                //  Test component configuration
                f_cf01Up();
                
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
                v_securedGnPdu := f_sendSecuredDenm(cc_taCert_A, omit, e_certificate);
                
                f_sleep(PX_TAC);
                for (i := 0; i < lengthof(vc_utInds) and not match(vc_utInds[i].rawPayload, v_securedGnPdu.gnPacket.packet.payload.rawPayload); i := i + 1) {
                    // empty on purpose 
                }
                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();
            } // End of testcase TC_SEC_ITSS_RCV_DENM_01_01a_NB
            
            /**
             * @desc    Check that IUT accepts a well-formed Secured DENM signe with the certificate with a circular region validity restriction
             * <pre>
             * Pics Selection: none
             * Config Id: CF01
             * Expected behavior:
             * with {
             *   the IUT being in the 'authorized' state
             * }
             * 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
             *              }
             *          }
             *   } then {
             *     the IUT accepts the message
             *   }
             * }
             * </pre>
             * @see
             * @reference ETSI TS 103 097 V1.1.14, clause 7.2
             */
            testcase TC_SEC_ITSS_RCV_DENM_01_01b_NB() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var integer i;
                var GeoNetworkingPdu v_securedGnPdu;
                
                //  Test component configuration
                f_cf01Up();
                
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
                v_securedGnPdu := f_sendSecuredDenm(cc_taCert_B, omit, e_certificate);
                
                f_sleep(PX_TAC);
                for (i := 0; i < lengthof(vc_utInds) and not match(vc_utInds[i].rawPayload, v_securedGnPdu.gnPacket.packet.payload.rawPayload); i := i + 1) {
                    // empty on purpose 
                }
                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();
            } // End of testcase TC_SEC_ITSS_RCV_DENM_01_01b_NB
            
            /**
             * @desc    Check that IUT accepts a well-formed Secured DENM signe with the certificate with a rectangular region validity restriction
             * <pre>
             * Pics Selection: none
             * Config Id: CF01
             * Expected Behavior:
             * 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'
             *              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
             *              }
             *          }
             *   } then {
             *     the IUT accepts the message
             *   }
             * }
             * </pre>
             * @see
             * @reference ETSI TS 103 097 V1.1.14, clause 7.2
             */
            testcase TC_SEC_ITSS_RCV_DENM_01_01c_NB() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var integer i;
                var GeoNetworkingPdu v_securedGnPdu;
                
                //  Test component configuration
                f_cf01Up();
                
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
                v_securedGnPdu := f_sendSecuredDenm(cc_taCert_C, omit, e_certificate);
                
                f_sleep(PX_TAC);
                for (i := 0; i < lengthof(vc_utInds) and not match(vc_utInds[i].rawPayload, v_securedGnPdu.gnPacket.packet.payload.rawPayload); i := i + 1) {
                    // empty on purpose 
                }
                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();
            } // End of testcase TC_SEC_ITSS_RCV_DENM_01_01c_NB
            
            /**
             * @desc    Check that IUT accepts a well-formed Secured DENM signe with the certificate with a polygonal region validity restriction 
             * <pre>
             * Pics Selection: none
             * Config Id: CF01
             * Expected Behavior:
             * 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'
             *              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
             *              }
             *          }
             *   } then {
             *     the IUT accepts the message
             *   }
             * }
             * </pre>
             * @see
             * @reference ETSI TS 103 097 V1.1.14, clause 7.2
             */
            testcase TC_SEC_ITSS_RCV_DENM_01_01d_NB() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var integer i;
                var GeoNetworkingPdu v_securedGnPdu;
                
                //  Test component configuration
                f_cf01Up();
                
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
                v_securedGnPdu := f_sendSecuredDenm(cc_taCert_D, omit, e_certificate);
                
                f_sleep(PX_TAC);
                for (i := 0; i < lengthof(vc_utInds) and not match(vc_utInds[i].rawPayload, v_securedGnPdu.gnPacket.packet.payload.rawPayload); i := i + 1) {
                    // empty on purpose 
                }
                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();
            } // End of testcase TC_SEC_ITSS_RCV_DENM_01_01d_NB
            
            /**
             * @desc    Check that IUT accepts a well-formed Secured DENM signe with the certificate with a identified region validity restriction 
             * <pre>
             * Pics Selection: none
             * Config Id: CF01
             * Expected Behavior:
             * 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'
             *              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
             *              }
             *          }
             *   } then {
             *     the IUT accepts the message
             *   }
             * }
             * </pre>
             * @see
             * @reference ETSI TS 103 097 V1.1.14, clause 7.2
             */
            testcase TC_SEC_ITSS_RCV_DENM_01_01e_NB() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var integer i;
                var GeoNetworkingPdu v_securedGnPdu;
                
                //  Test component configuration
                f_cf01Up();
                
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
                v_securedGnPdu := f_sendSecuredDenm(cc_taCert_D, omit, e_certificate);
                
                f_sleep(PX_TAC);
                for (i := 0; i < lengthof(vc_utInds) and not match(vc_utInds[i].rawPayload, v_securedGnPdu.gnPacket.packet.payload.rawPayload); i := i + 1) {
                    // empty on purpose 
                }
                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();
            } // End of testcase TC_SEC_ITSS_RCV_DENM_01_01e_NB
            
            /**
             * @desc    Check that IUT discards a Secured DENM containing protocol version set to a value less then 2
             * <pre>
             * Pics Selection: none
             * Config Id: CF01
             * 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
             *      }
             *  }
             * </pre>
             *
             * @see
             * @reference ETSI TS 103 097 V1.1.14, clause 7.2
             */
            testcase TC_SEC_ITSS_RCV_DENM_02_01a_EB() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var integer i;
                var GeoNetworkingPdu v_securedGnPdu;
                
                //  Test component configuration
                f_cf01Up();
                
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
                v_securedGnPdu := f_prepareSecuredDenm(cc_taCert_A);
                v_securedGnPdu.gnPacket.securedMsg.protocol_version := 1;
                f_sendGeoNetMessage(m_geoNwReq_linkLayerBroadcast(v_securedGnPdu));
                
                f_sleep(PX_TNOAC);
                for (i := 0; i < lengthof(vc_utInds) and not match(vc_utInds[i].rawPayload, v_securedGnPdu.gnPacket.packet.payload.rawPayload); 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_DENM_02_01a_EB
            
            /**
             * @desc    Check that IUT discards a Secured DENM containing protocol version set to a value greater then 2
             * <pre>
             * Pics Selection: none
             * Config Id: CF01
             * 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
             *      }
             *  }
             * </pre>
             *
             * @see
             * @reference ETSI TS 103 097 V1.1.14, clause 7.2
             */
            testcase TC_SEC_ITSS_RCV_DENM_02_01b_EB() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var integer i;
                var GeoNetworkingPdu v_securedGnPdu;
                
                //  Test component configuration
                f_cf01Up();
                
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
                v_securedGnPdu := f_prepareSecuredDenm(cc_taCert_A);
                v_securedGnPdu.gnPacket.securedMsg.protocol_version := 1;
                f_sendGeoNetMessage(m_geoNwReq_linkLayerBroadcast(v_securedGnPdu));
                
                f_sleep(PX_TNOAC);
                for (i := 0; i < lengthof(vc_utInds) and not match(vc_utInds[i].rawPayload, v_securedGnPdu.gnPacket.packet.payload.rawPayload); 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_DENM_02_01b_EB
            
            /**
             * @desc  Check that IUT discards secured DENM when its_aid value is not equal to 16513
             * <pre>
             * Pics Selection: none
             * Config Id: CF01
             * 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
             *      }
             *  }
             * </pre>
             * @see
             * @reference ETSI TS 103 097 V1.1.14, clause 7.1
             */
            testcase TC_SEC_ITSS_RCV_DENM_07_01a_EB() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var integer i;
                var GeoNetworkingPdu v_securedGnPdu;
                                
                //  Test component configuration
                f_cf01Up();
                
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
                v_securedGnPdu := f_prepareSecuredDenm(
                    {
                        m_header_field_its_aid_CAM
                    }
                ); 
                f_sendGeoNetMessage(m_geoNwReq_linkLayerBroadcast(v_securedGnPdu));
                
                f_sleep(PX_TNOAC);
                for (i := 0; i < lengthof(vc_utInds) and not match(vc_utInds[i].rawPayload, v_securedGnPdu.gnPacket.packet.payload.rawPayload); 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_DENM_07_01a_EB
            
            /**
             * @desc   Check that IUT discards Secured DENM if the HeaderField generation_location is outside of the circular validity region of the signing certificate
             * <pre>
             * Pics Selection: none
             * Config Id: CF01
             * Initial conditions:
             * with {
             *   the IUT being in the 'authorized' state
             * }
             * ensure that {
             *   when {
             *     the IUT is requested to send DENM
             *   } then {
             *     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'
             *   }
             * }
             * </pre>
             * @see
             * @reference ETSI TS 103 097 V1.1.14, clause 7.2
             */
            testcase TC_SEC_ITSS_RCV_DENM_08_01a_EB() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var integer i;
                var GeoNetworkingPdu v_securedGnPdu;
                
                //  Test component configuration
                f_cf01Up();
                
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
                v_securedGnPdu := f_sendSecuredDenm(cc_taCert_B, omit, e_certificate);
                
                f_sleep(PX_TNOAC);
                if (lengthof(vc_utInds) == 0) {
                    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();
            } // End of testcase TC_SEC_ITSS_RCV_DENM_08_01a_EB
            
            /**
             * @desc    Check that IUT discards Secured DENM if the HeaderField generation_location is outside of the rectangilar validity region of the signing certificate
             * <pre>
             * Pics Selection: none
             * Config Id: CF01
             * Initial conditions:
             * with {
             *   the IUT being in the 'authorized' state
             * }
             * ensure that {
             *   when {
             *     the IUT is requested to send DENM
             *   } then {
             *     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'
             *   }
             * }
             * </pre>
             * @see
             * @reference ETSI TS 103 097 V1.1.14, clause 7.2
             */
            testcase TC_SEC_ITSS_RCV_DENM_08_01b_EB() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var integer i;
                var GeoNetworkingPdu v_securedGnPdu;
                
                //  Test component configuration
                f_cf01Up();
                
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
                v_securedGnPdu := f_sendSecuredDenm(cc_taCert_C, omit, e_certificate);
                
                f_sleep(PX_TNOAC);
                if (lengthof(vc_utInds) == 0) {
                    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();
            } // End of testcase TC_SEC_ITSS_RCV_DENM_08_01b_EB
            
            /**
             * @desc    Check that IUT discards Secured DENM if the HeaderField generation_location is outside of the polygonal validity region of the signing certificate    
             * <pre>
             * Pics Selection: none
             * Config Id: CF01
             * Initial conditions:
             * with {
             *   the IUT being in the 'authorized' state
             * }
             * ensure that {
             *   when {
             *     the IUT is requested to send DENM
             *   } then {
             *     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'
             *   }
             * }
             * </pre>
             * @see
             * @reference ETSI TS 103 097 V1.1.14, clause 7.2
             */
            testcase TC_SEC_ITSS_RCV_DENM_08_01c_EB() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var integer i;
                var GeoNetworkingPdu v_securedGnPdu;
                
                //  Test component configuration
                f_cf01Up();
                
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
                v_securedGnPdu := f_sendSecuredDenm(cc_taCert_D, omit, e_certificate);
                
                f_sleep(PX_TNOAC);
                if (lengthof(vc_utInds) == 0) {
                    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();
            } // End of testcase TC_SEC_ITSS_RCV_DENM_08_01c_EB
            
            /**
             * @desc    Check that IUT discards Secured DENM if the HeaderField generation_location is outside of the identified validity region of the signing certificate 
             * <pre>
             * Pics Selection: none
             * Config Id: CF01
             * Initial conditions:
             * with {
             *   the IUT being in the 'authorized' state
             * }
             * ensure that {
             *   when {
             *     the IUT is requested to send DENM
             *   } then {
             *     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'
             *   }
             * }
             * </pre>
             * @see
             * @reference ETSI TS 103 097 V1.1.14, clause 7.2
             */
            testcase TC_SEC_ITSS_RCV_DENM_08_01d_EB() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var integer i;
                var GeoNetworkingPdu v_securedGnPdu;
                
                //  Test component configuration
                f_cf01Up();
                
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
                v_securedGnPdu := f_sendSecuredDenm(cc_taCert_E, omit, e_certificate);
                
                f_sleep(PX_TNOAC);
                if (lengthof(vc_utInds) == 0) {
                    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();
            } // End of testcase TC_SEC_ITSS_RCV_DENM_08_01d_EB
            
        } // End of group g_recvDenmProfile
        
    } // End of group g_receiverbehavior
    
    group g_Certificates {
        
        /**
         * @desc    Check that AT certificate has version 2
         * <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 version
         *             indicating '2'
         *         }
         *       }
         *   }
         * }
         * </pre>
         * @reference ETSI TS 103 097 V1.1.14, clause 6.1
         */
        testcase TC_SEC_SND_CERT_01_01() 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(
                                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();
        } // End of testcase TC_SEC_SND_CERT_01_01
        
        /**
         * @desc    Check that AA certificate has version 2
         * <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 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
         *         containing certificates.length >1
         *         containing certificates[last-1] {
         *           containing version
         *             indicating '2'
         *         }
         *       }
         *   }
         * }
         * </pre>
         * @reference ETSI TS 103 097 V1.1.14, clause 6.1
         */
        testcase TC_SEC_SND_CERT_01_02() runs on ItsGeoNetworking system ItsSecSystem {
            // Local variables
            var SecuredMessage v_recv;
            var Certificate v_cert;
            var SignerInfo v_si;
            var HashedId8 v_digest;
            
            // Test control
            if (not(PICS_GN_SECURITY)) {
                log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY' required for executing the TC ***");
                stop;
            }
                
            // Test component configuration
            f_cf01Up();
                
            // Test adapter configuration
                
            // Preamble
            f_prNeighbour();
            f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
            
            // 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;
            
            // Test Body
            tc_ac.start;
            alt {
                [] geoNetworkingPort.receive(
                    mw_geoNwInd(
                        mw_geoNwSecPdu(
                            mdw_securedMessage(
                                superset(
                                    mw_header_field_signer_info_certificate_chain(
                                        superset(
                                            mw_aa_certificate
                ))))))) {
                    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();
            
        } // End of testcase TC_SEC_SND_CERT_01_02
        
        /**
         * @desc    Check that the certificate chain is valid: Check 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 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[N] {
         *           containing signer_info {
         *             containing type
         *               indicating 'certificate_digest_with_sha256'
         *             containing digest
         *               referenced to the certificates[N-1]
         *           }
         *         }
         *       }
         *   }
         * }
         * </pre>
         * @reference ETSI TS 103 097 V1.1.14, clause 6.1
         */
        testcase TC_SEC_SND_CERT_02_01() runs on ItsGeoNetworking system ItsSecSystem {
            // TODO: This TC is fully covered by TC_SEC_SND_CERT_09_02 
            // Local declarations
            var CertificateChain v_chain;
            var SignerInfo v_si;
            var HashedId8 v_digest;
            
            // Test control
            if (not(PICS_GN_SECURITY)) {
                log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY' required for executing the TC ***");
                stop;
            }
                
            // Test component configuration
            f_cf01Up();
                
            // Test adapter configuration
                
            // Preamble
            f_prNeighbour();
            f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
            
            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;
            
            // Test Body
            for (var integer 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 contain 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);
                }
                
                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
            log("*** " & testcasename() & ": PASS: Certificate chain is well signed ***");
            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
            
            // Postamble
            f_poNeighbour();
            f_cf01Down();
            
        } // End of testcase TC_SEC_SND_CERT_02_01
        
        /**
         * @desc Check that the length of the vector of rectangles is less then 6.
         *       Check that region is continuous and does not contain any holes.
         *       Check that the rectangles are valid  
         * <pre>
         * Pics Selection: PIC_UseRectangularRegion
         * 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 no validity restriction or validity_restrictions['region']{
         *             containing region_type
         *               indicating 'rectangle'
         *             containing rectangular_region {
         *               indicating length <= 6
         *               containing elements of type RectangularRegion
         *                 indicating continuous region without holes
         *                 containing northwest and southeast
         *                   indicating northwest is on the north from southeast
         *             }
         *           }
         *         }
         *       }
         *   }
         * }
         * @remark Certificate: cc_taCert_C
         * </pre>
         * @reference ETSI TS 103 097 V1.1.14, clauses 4.2.21, 4.2.24
         */
        testcase TC_SEC_SND_CERT_04_01() runs on ItsGeoNetworking system ItsSecSystem {
            // Local variables
            var Certificate         v_cert;
            var ValidityRestriction v_vr;
            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
            vc_hashedId8ToBeUsed := cc_iutCert_C;
                
            // 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_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();
            
        } // End of testcase TC_SEC_SND_CERT_04_01
        
        /**
         * @desc Check that the rectangular region of the subordinate certificate is well formed 
         *       and inside the validity restrictions of the issuing certificate.  
         * <pre>
         * Pics Selection: PIC_UseRectangularRegion
         * 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[N] {
         *               containing validity_restrictions['region'] {
         *                 containing region_type
         *                   indicating 'rectangle'
         *                 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
         *                     which is inside the CERTIFICATES[N-1].validity_restrictions['region'] if region validity restriction is containted in certificate CERTIFICATES[N-1]
         *                    }
         *                  }
         *             }
         *           }
         *       }
         *       }
         * }
         * </pre>
         * @reference ETSI TS 103 097 V1.1.14, clauses 4.2.21, 4.2.24
         */
        testcase TC_SEC_SND_CERT_04_02() runs on ItsGeoNetworking system ItsSecSystem {
            // Local variables
            var CertificateChain    v_chain;
            var ValidityRestriction v_vr, v_vri;  // current and issuing cert validity restrictions
            var boolean f_vr, f_vri;
            
            // 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
                
7809 7810 7811 7812 7813 7814 7815 7816 7817 7818 7819 7820 7821 7822 7823 7824 7825 7826 7827 7828 7829 7830 7831 7832 7833 7834 7835 7836 7837 7838 7839 7840 7841 7842 7843 7844 7845 7846 7847 7848 7849 7850 7851 7852 7853 7854 7855 7856 7857 7858 7859 7860 7861 7862 7863 7864 7865 7866 7867 7868 7869 7870 7871 7872 7873 7874 7875 7876 7877 7878 7879 7880 7881 7882 7883 7884 7885 7886 7887 7888 7889 7890 7891 7892 7893 7894 7895 7896 7897 7898 7899 7900 7901 7902 7903 7904 7905 7906 7907 7908 7909 7910 7911 7912 7913 7914 7915 7916 7917 7918 7919 7920 7921 7922 7923 7924 7925 7926 7927 7928 7929 7930 7931 7932 7933 7934 7935 7936 7937 7938 7939 7940 7941 7942 7943 7944 7945 7946 7947 7948 7949 7950 7951 7952 7953 7954 7955 7956 7957 7958 7959 7960 7961 7962 7963 7964 7965 7966 7967 7968 7969 7970 7971 7972 7973 7974 7975 7976 7977 7978 7979 7980 7981 7982 7983 7984 7985 7986 7987 7988 7989 7990 7991 7992 7993 7994 7995 7996 7997 7998 7999 8000 8001 8002 8003 8004 8005 8006 8007 8008 8009 8010 8011 8012 8013 8014 8015 8016 8017 8018 8019 8020 8021 8022 8023 8024 8025 8026 8027 8028 8029 8030 8031 8032 8033 8034 8035 8036 8037 8038 8039 8040 8041 8042 8043 8044 8045 8046 8047 8048 8049 8050 8051 8052 8053 8054 8055 8056 8057 8058 8059 8060 8061 8062 8063 8064 8065 8066 8067 8068 8069 8070 8071 8072 8073 8074 8075 8076 8077 8078 8079 8080 8081 8082 8083 8084 8085 8086 8087 8088 8089 8090 8091 8092 8093 8094 8095 8096 8097 8098 8099 8100 8101 8102 8103 8104 8105 8106 8107 8108 8109 8110 8111 8112 8113 8114 8115 8116 8117 8118 8119 8120 8121 8122 8123 8124 8125 8126 8127 8128 8129 8130 8131 8132 8133 8134 8135 8136 8137 8138 8139 8140 8141 8142 8143 8144 8145 8146 8147 8148 8149 8150 8151 8152 8153 8154 8155 8156 8157 8158 8159 8160 8161 8162 8163 8164 8165 8166 8167 8168 8169 8170 8171 8172 8173 8174 8175 8176 8177 8178 8179 8180 8181 8182 8183 8184 8185 8186 8187 8188 8189 8190 8191 8192 8193 8194 8195 8196 8197 8198 8199 8200 8201 8202 8203 8204 8205 8206 8207 8208 8209 8210 8211 8212 8213 8214 8215 8216 8217 8218 8219 8220 8221 8222 8223 8224 8225 8226 8227 8228 8229 8230 8231 8232 8233 8234 8235 8236 8237 8238 8239 8240 8241 8242 8243 8244 8245 8246 8247 8248 8249 8250 8251 8252 8253 8254 8255 8256 8257 8258 8259 8260 8261 8262 8263 8264 8265 8266 8267 8268 8269 8270 8271 8272 8273 8274 8275 8276 8277 8278 8279 8280 8281 8282 8283 8284 8285 8286 8287 8288 8289 8290 8291 8292 8293 8294 8295 8296 8297 8298 8299 8300 8301 8302 8303 8304 8305 8306 8307 8308 8309 8310 8311 8312 8313 8314 8315 8316 8317 8318 8319 8320 8321 8322 8323 8324 8325 8326 8327 8328 8329 8330 8331 8332 8333 8334 8335 8336 8337 8338 8339 8340 8341 8342 8343 8344 8345 8346 8347 8348 8349 8350 8351 8352 8353 8354 8355 8356 8357 8358 8359 8360 8361 8362 8363 8364 8365 8366 8367 8368 8369 8370 8371 8372 8373 8374 8375 8376 8377 8378 8379 8380 8381 8382 8383 8384 8385 8386 8387 8388 8389 8390 8391 8392 8393 8394 8395 8396 8397 8398 8399 8400 8401 8402 8403 8404 8405 8406 8407 8408 8409 8410 8411 8412 8413 8414 8415 8416 8417 8418 8419 8420 8421 8422 8423 8424 8425 8426 8427 8428 8429 8430 8431 8432 8433 8434 8435 8436 8437 8438 8439 8440 8441 8442 8443 8444 8445 8446 8447 8448 8449 8450 8451 8452 8453 8454 8455 8456 8457 8458 8459 8460 8461 8462 8463 8464 8465 8466 8467 8468 8469 8470 8471 8472 8473 8474 8475 8476 8477 8478 8479 8480 8481 8482 8483 8484 8485 8486 8487 8488 8489 8490 8491 8492 8493 8494 8495 8496 8497 8498 8499 8500 8501 8502 8503 8504 8505 8506 8507 8508 8509 8510 8511 8512 8513 8514 8515 8516 8517 8518 8519 8520 8521 8522 8523 8524 8525 8526 8527 8528 8529 8530 8531 8532 8533 8534 8535 8536 8537 8538 8539 8540 8541 8542 8543 8544 8545 8546 8547 8548 8549 8550 8551 8552 8553 8554 8555 8556 8557 8558 8559 8560 8561 8562 8563 8564 8565 8566 8567 8568 8569 8570 8571 8572 8573 8574 8575 8576 8577 8578 8579 8580 8581 8582 8583 8584 8585 8586 8587 8588 8589 8590 8591 8592 8593 8594 8595 8596 8597 8598 8599 8600 8601 8602 8603 8604 8605 8606 8607 8608 8609 8610 8611 8612 8613 8614 8615 8616 8617 8618 8619 8620 8621 8622 8623 8624 8625 8626 8627 8628 8629 8630 8631 8632 8633 8634 8635 8636 8637 8638 8639 8640 8641 8642 8643 8644 8645 8646 8647 8648 8649 8650 8651 8652 8653 8654 8655 8656 8657 8658 8659 8660 8661 8662 8663 8664 8665 8666 8667 8668 8669 8670 8671 8672 8673 8674 8675 8676 8677 8678 8679 8680 8681 8682 8683 8684 8685 8686 8687 8688 8689 8690 8691 8692 8693 8694 8695 8696 8697 8698 8699 8700 8701 8702 8703 8704 8705 8706 8707 8708 8709 8710 8711 8712 8713 8714 8715 8716 8717 8718 8719 8720 8721 8722 8723 8724 8725 8726 8727 8728 8729 8730 8731 8732 8733 8734 8735 8736 8737 8738 8739 8740 8741 8742 8743 8744 8745 8746 8747 8748 8749 8750 8751 8752 8753 8754 8755 8756 8757 8758 8759 8760 8761 8762 8763 8764 8765 8766 8767 8768 8769 8770 8771 8772 8773 8774 8775 8776 8777 8778 8779 8780 8781 8782 8783 8784 8785 8786 8787 8788 8789 8790 8791 8792 8793 8794 8795 8796 8797 8798 8799 8800 8801 8802 8803 8804 8805 8806 8807 8808 8809 8810 8811 8812 8813 8814 8815 8816 8817 8818 8819 8820 8821 8822 8823 8824 8825 8826 8827 8828 8829 8830 8831 8832 8833 8834 8835 8836 8837 8838 8839 8840 8841 8842 8843 8844 8845 8846 8847 8848 8849 8850 8851 8852 8853 8854 8855 8856 8857 8858 8859 8860 8861 8862 8863 8864 8865 8866 8867 8868 8869 8870 8871 8872 8873 8874 8875 8876 8877 8878 8879 8880 8881 8882 8883 8884 8885 8886 8887 8888 8889 8890 8891 8892 8893 8894 8895 8896 8897 8898 8899 8900 8901 8902 8903 8904 8905 8906 8907 8908 8909 8910 8911 8912 8913 8914 8915 8916 8917 8918 8919 8920 8921 8922 8923 8924 8925 8926 8927 8928 8929 8930 8931 8932 8933 8934 8935 8936 8937 8938 8939 8940 8941 8942 8943 8944 8945 8946 8947 8948 8949 8950 8951 8952 8953 8954 8955 8956 8957 8958 8959 8960 8961 8962 8963 8964 8965 8966 8967 8968 8969 8970 8971 8972 8973 8974 8975 8976 8977 8978 8979 8980 8981 8982 8983 8984 8985 8986 8987 8988 8989 8990 8991 8992 8993 8994 8995 8996 8997 8998 8999 9000 9001 9002 9003 9004 9005 9006 9007 9008 9009 9010 9011 9012 9013 9014 9015 9016 9017 9018 9019 9020 9021 9022 9023 9024 9025 9026 9027 9028 9029 9030 9031 9032 9033 9034 9035 9036 9037 9038 9039 9040 9041 9042 9043 9044 9045 9046 9047 9048 9049 9050 9051 9052 9053 9054 9055 9056 9057 9058 9059 9060 9061 9062 9063 9064 9065 9066 9067 9068 9069 9070 9071 9072 9073 9074 9075 9076 9077 9078 9079 9080 9081 9082 9083 9084 9085 9086 9087 9088 9089 9090 9091 9092 9093 9094 9095 9096 9097 9098 9099 9100 9101 9102 9103 9104 9105 9106 9107 9108 9109 9110 9111 9112 9113 9114 9115 9116 9117 9118 9119 9120 9121 9122 9123 9124 9125 9126 9127 9128 9129 9130 9131 9132 9133 9134 9135 9136 9137 9138 9139 9140 9141 9142 9143 9144 9145 9146 9147 9148 9149 9150 9151 9152 9153 9154 9155 9156 9157 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
            // Preamble
            f_prNeighbour();
            f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
            
            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;
            
            // Test Body
            f_vr := false;
            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 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;
                    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();
            
        } // End of testcase TC_SEC_SND_CERT_04_02
        
        /**
         * @desc Check Polygonal Region:
         * Must contain at least 3 and no more then 12 points
         * Intersections and holes are not permited
         * <pre>
         * Pics Selection: PIC_UsePolygonalRegion
         * 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 'polygon'
         *             containing polygonal_region {
         *               indicating length >=3 and <=12
         *               indicating continuous region without holes and intersections
         *             }
         *           }
         *         }
         *       }
         *   }
         * }
         * </pre>
         * @reference ETSI TS 103 097 V1.1.14, clauses 4.2.25
         */
        testcase TC_SEC_SND_CERT_05_01() runs on ItsGeoNetworking system ItsSecSystem {
            var Certificate         v_cert;
            var ValidityRestriction v_vr;
            var integer             v_counter;
            
            // Test component configuration
            f_cf01Up();
            
            // 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_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();
            
        } // End of testcase TC_SEC_SND_CERT_05_01

        /**
         * @desc Check Polygonal Region:
         * Must contain at least 3 and no more then 12 points.
         * Intersections and holes are not permited.
         * The region must be inside the issuing certificate restrictions.  
         * <pre>
         * Pics Selection: PIC_UsePolygonalRegion
         * 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[N] {
         *               containing validity_restrictions['region'] {
         *                 containing region_type
         *                   indicating 'polygon'
         *                 containing polygonal_region {
         *                   indicating length >=3 and <=12
         *                   indicating continuous region without holes and intersections
         *                     which is inside the CERTIFICATES[N-1].validity_restrictions['region'].polygonal_region 
         *                       if region validity restriction is containted in certificate CERTIFICATES[N-1]
         *                 }
         *               }
         *             }
         *           }
         *       }
         *   }
         * }
         * </pre>
         * @reference ETSI TS 103 097 V1.1.14, clauses 4.2.25
         */
        testcase TC_SEC_SND_CERT_05_02() runs on ItsGeoNetworking system ItsSecSystem {
            // Local declarations
            var CertificateChain    v_chain;
            var ValidityRestriction v_vr, v_vri;  // current and issuing cert validity restrictions
            var boolean f_vr, f_vri;
            
            // Test component configuration
            f_cf01Up();
            
            // 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;
            f_vr := false;
            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
            
            log("*** " & testcasename() & ": PASS: All certificates has a valid polygonal region restrictions ***");
            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
            
            // Postamble
            f_poNeighbour();
            f_cf01Down();
            
        } // End of testcase TC_SEC_SND_CERT_05_02

        /**
         * @desc Check Identified Region:
         * Must contain value that correspond to numeric country codes as defined in ISO 3166-1 
         * <pre>
         * Pics Selection: PIC_UseIdentifiedRegion, PIC_UseISO31661RegionDictionary
         * 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 'iso_3166_1' (0)
         *               containing region_identifier
         *                 indicating valid value according to 'iso_3166_1'
         *               containing local_region
         *             }
         *           }
         *         }
         *       }
         *   }
         * }
         * </pre>
         * @reference ETSI TS 103 097 V1.1.14, clauses 4.2.27
         */
        testcase TC_SEC_SND_CERT_06_01() runs on ItsGeoNetworking system ItsSecSystem {
            var Certificate         v_cert;
            var ValidityRestriction v_vr;
            var integer             v_counter;
            
            // Test component configuration
            f_cf01Up();
            
            // 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_iso3166_any))) {
                        log("*** " & testcasename() & ": FAIL: Identified region is not conformed to ISO 3166-1 ***");
                        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() & ": PASS: Certificate doesn't have any location restrictions ***");
                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
            }
            
            // Postamble
            f_poNeighbour();
            f_cf01Down();
            
        } // End of testcase TC_SEC_SND_CERT_06_01
        
        /**
         * @desc Check Identified Region:
         * Must contain value that correspond to numeric country codes as defined in ISO 3166-1
         * Subordinate certificate restrictions must be a subset of the issuing certificate restrictions  
         * <pre>
         * Pics Selection: PIC_UseIdentifiedRegion, PIC_UseISO31661RegionDictionary
         * 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 'iso_3166_1' (0)
         *                   containing region_identifier
         *                     indicating valid value according to 'iso_3166_1'
         *                   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 'iso_3166_1' (0)
         *                   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>
         * @reference ETSI TS 103 097 V1.1.14, clauses 4.2.27
         */
        testcase TC_SEC_SND_CERT_06_02() runs on ItsGeoNetworking system ItsSecSystem {
            var CertificateChain         v_chain;
            var ValidityRestriction v_vr, v_vri;  // current and issuing cert validity restrictions
            var boolean f_vr, f_vri;
            
            // Test component configuration
            f_cf01Up();
            
            // 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 (f_askAndWaitForCertificateChain(v_chain, f_generateDefaultCam())) {
                log("*** " & testcasename() & ": INCONC: Expected message not received ***");
                f_selfOrClientSyncAndVerdictPreamble(c_tbDone, e_timeout);
            }
            tc_ac.stop;
            f_vr := false;
            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 (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);
                    }
                }
            }
            
            // Postamble
            f_poNeighbour();
            f_cf01Down();
        } // End of testcase TC_SEC_SND_CERT_06_02
        
        /**
         * @desc Check Identified Region:
         * Must contain value that correspond to numeric country codes as defined by United Nations Statistics Division
         * <pre>
         * Pics Selection: PIC_UseIdentifiedRegion, PIC_UseUnStatsRegionDictionary
         * 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>
         * @reference ETSI TS 103 097 V1.1.14, clauses 4.2.27
         */
        testcase TC_SEC_SND_CERT_06_03() runs on ItsGeoNetworking system ItsSecSystem {
            var Certificate         v_cert;
            var ValidityRestriction v_vr;
            var integer             v_counter;
            
            // Test component configuration
            f_cf01Up();
            
            // 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();
        } // End of testcase TC_SEC_SND_CERT_06_03
        
        /**
         * @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: PIC_UseIdentifiedRegion, PIC_UseUnStatsRegionDictionary
         * 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>
         * @reference ETSI TS 103 097 V1.1.14, clauses 4.2.27
         */
        testcase TC_SEC_SND_CERT_06_04() runs on ItsGeoNetworking system ItsSecSystem {
            var CertificateChain         v_chain;
            var ValidityRestriction v_vr, v_vri;  // current and issuing cert validity restrictions
            var boolean f_vr, f_vri;
            
            // Test component configuration
            f_cf01Up();
            
            // 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 (f_askAndWaitForCertificateChain(v_chain, f_generateDefaultCam())) {
                log("*** " & testcasename() & ": INCONC: Expected message not received ***");
                f_selfOrClientSyncAndVerdictPreamble(c_tbDone, e_timeout);
            }
            tc_ac.stop;
            f_vr := false;
            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);
                    }
                }
            }
            
            // Postamble
            f_poNeighbour();
            f_cf01Down();
            
        } // End of testcase TC_SEC_SND_CERT_06_04
        
        /**
         * @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
         * <pre>
         * Pics Selection: none
         * 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 signature.ecdsa_signature
         *                 containing R.type
         *                     indicating compressed_lsb_y_0
         *                     or indicating compressed_lsb_y_1 
         *                     or indicating x_coordinate_only
         *         }
         *       }
         *   }
         * }
         * </pre>
         * @reference ETSI TS 103 097 V1.1.14, clause 6.1
         */
        testcase TC_SEC_SND_CERT_07_01() runs on ItsGeoNetworking system ItsSecSystem {
            
            // Test component configuration
            f_cf01Up();
            
            // 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(
                                            ?,
                                            ?,
                                            ?,
                                            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();
            
        } // End of testcase TC_SEC_SND_CERT_07_01
        
        /**
         * @desc Check the certificate signature 
         * <pre>
         * Pics Selection: none
         * 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 CAM
         *   } then {
         *     the IUT sends a SecuredMessage
         *       containing header_fields['signer_info'].signer {
         *         containing type
         *           indicating 'certificate'
         *         containing certificate {
         *           containing signer_info[0] {
         *             containing type
         *               indicating 'certificate_digest_with_sha256'
         *             containing digest
         *               referenced to the certificate CERT
         *           }
         *           containing signature
         *             verifiable using CERT.subject_attributes['verification_key'].key
         *         }
         *       }
         *   }
         * }
         * </pre>
         * @reference ETSI TS 103 097 V1.1.14, clause 7.4
         */
        testcase TC_SEC_SND_CERT_09_01() runs on ItsGeoNetworking system ItsSecSystem {
            // 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;
            
            // Test component configuration
            f_cf01Up();
            
            // Preamble
            f_prNeighbour();
            f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
            
            // 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;
            
            if (true != f_getCertificateSignerInfo(v_at_cert, v_si)) {
                log("*** " & testcasename() & ": FAIL: AT Certificate signer info is unknown ***");
                f_selfOrClientSyncAndVerdictPreamble(c_tbDone, e_error);
            }
            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);
            }
            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();
            
        } // End of testcase TC_SEC_SND_CERT_09_01
        
        /**
         * @desc Check the signatures of the certificates in the chain 
         * <pre>
         * Pics Selection: none
         * Config Id: CF01
         * Initial conditions:
         * 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[N] {
         *               containing signer_info[0] {
         *                 containing type
         *                   indicating 'certificate_digest_with_sha256'
         *                 containing digest
         *                   referenced to the certificate CERTIFICATES[N-1]
         *               }
         *               containing signature
         *                 verifiable using CERTIFICATES[N-1].subject_attributes['verification_key'].key
         *             }
         *         }
         *       }
         *   }
         * }
         * </pre>
         * @reference ETSI TS 103 097 V1.1.14, clause 7.4
         */
        testcase TC_SEC_SND_CERT_09_02() runs on ItsGeoNetworking system ItsSecSystem {
            // 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;
            
            // Test component configuration
            f_cf01Up();
            
            // Preamble
            f_prNeighbour();
            f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
            
            // 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;
                
            // 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_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();
            
        } // End of testcase TC_SEC_SND_CERT_09_02
        
        group g_AA_Certificates {
            
            /**
             * @desc Check that the subject_type of the AA certificate is set to authorization_authority   
             * <pre>
             * Pics 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[last-1] {
             *           containing subject_info.subject_type
             *             indicating 'authorization_authority' (2)
             *         }
             *       }
             *   }
             * }
             * </pre>
             * @reference ETSI TS 103 097 V1.1.14, clauses 7.4.3
             */
            testcase TC_SEC_SND_CERT_AA_01_01() runs on ItsGeoNetworking system ItsSecSystem {
                var CertificateChain         v_chain;
                
                // Test component configuration
                f_cf01Up();
                
                // 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 (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);
                
                // Postamble
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_SND_CERT_AA_01_01
            
            /**
             * @desc Check that the subject_name variable-length vector shall have a maximum length of 32 bytes.    
             * <pre>
             * Pics 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[last-1] {
             *           containing subject_info.subject_name
             *             indicating length <= 32 bytes
             *         }
             *       }
             *   }
             * }
             * </pre>
             * @reference ETSI TS 103 097 V1.1.14, clauses 7.4.3
             */
            testcase TC_SEC_SND_CERT_AA_02_01() runs on ItsGeoNetworking system ItsSecSystem {
                var CertificateChain         v_chain;
                
                // Test component configuration
                f_cf01Up();
                
                // 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 (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();
            } // End of testcase TC_SEC_SND_CERT_AA_02_01
            
            /**
             * @desc Check that signer info of the AA certificate is a digest     
             * <pre>
             * Pics 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[last-1] {
             *           containing signer_info {
             *             containing type
             *               indicating 'certificate_digest_with_sha256'
             *             containing digest
             *           }
             *         }
             *       }
             *   }
             * }
             * </pre>
             * @reference ETSI TS 103 097 V1.1.14, clauses 7.4.3
             */
            testcase TC_SEC_SND_CERT_AA_04_01() runs on ItsGeoNetworking system ItsSecSystem {
                var CertificateChain         v_chain;
                var Certificate              v_aa_cert;
                
                // Test component configuration
                f_cf01Up();
                
                // 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 (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();
            } // End of testcase TC_SEC_SND_CERT_AA_04_01
            
            /**
             * @desc Check that all neccesary subject attributes are present and arranged in accesing order     
             * <pre>
             * Pics 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[last-1] {
             *           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_list']
             *           }
             *         }
             *       }
             *   }
             * }
             * </pre>
             * @reference ETSI TS 103 097 V1.1.14, clauses 6.1, 7.4, 7.4.3
             */
            testcase TC_SEC_SND_CERT_AA_05_01() runs on ItsGeoNetworking system ItsSecSystem {
                var CertificateChain         v_chain;
                var SubjectAttributes        v_attrs;
                
                // Test component configuration
                f_cf01Up();
                
                // 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 (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();
            } // End of testcase TC_SEC_SND_CERT_AA_05_01
            
            /**
             * @desc Check that time_start_and_end is included in the AA certificate validation restrictions
             *       Check that end_validity is later then start_validity      
             * <pre>
             * Pics 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[last-1] {
             *           containing validity_restrictions [0..N] {
             *             not containing validity_restrictions['time_end']
             *             and not containing validity_restrictions['time_start_and_duration']
             *             and containing validity_restrictions['time_start_and_end']
             *               containing start_validity
             *                 indicating START_AA_VALIDITY
             *               containing end_validity
             *                 indicating END_AA_VALIDITY >=START_AA_VALIDITY
             *           }
             *         }
             *       }
             *   }
             * }
             * </pre>
             * @reference ETSI TS 103 097 V1.1.14, clauses 6.7, 7.4, 7.4.3
             */
            testcase TC_SEC_SND_CERT_AA_06_01() runs on ItsGeoNetworking system ItsSecSystem {
                var CertificateChain         v_chain;
                var Certificate              v_aa_cert;
                var ValidityRestriction      v_vr;
                
                // Test component configuration
                f_cf01Up();
                
                // 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 (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();
            } // End of testcase TC_SEC_SND_CERT_AA_06_01
            
            /**
             * @desc Check that all AIDs containing in the in the its_aid_list in AA certificate are unique
             *       Check that AID list contains not more then 31 items       
             * <pre>
             * Pics 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[last-1] {
             *           containing subject_attributes['its_aid_list']
             *             containing its_aid_list[0..N]
             *               containing no more then 31 unique item
             *           }
             *         }
             *       }
             *   }
             * }
             * </pre>
             * @reference ETSI TS 103 097 V1.1.14, clauses 6.9, 7.4.3
             */
            testcase TC_SEC_SND_CERT_AA_08_01() runs on ItsGeoNetworking system ItsSecSystem {
                var CertificateChain         v_chain;
                var Certificate              v_aa_cert;
                var SubjectAttribute         v_sa;
                
                // Test component configuration
                f_cf01Up();
                
                // 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 (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 (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 ***");
                    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();
            } // End of testcase TC_SEC_SND_CERT_AA_08_01
            
        } // End of group g_AA_Certificates 
        group g_AT_Certificates {
            
            /**
             * @desc Check that the subject_type of the AT certificate is set to 'authorization_ticket'   
             * <pre>
             * Pics 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 subject_info.subject_type
             *             indicating 'authorization_ticket' (1)
             *         }
             *       }
             *   }
             * }
             * </pre>
             * @reference ETSI TS 103 097 V1.1.14, clauses 7.4.1
             */
            testcase TC_SEC_SND_CERT_AT_01_01() runs on ItsGeoNetworking system ItsSecSystem {
                var Certificate         v_at_cert;
                
                // Test component configuration
                f_cf01Up();
                
                // 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();
            } // End of testcase TC_SEC_SND_CERT_AT_01_01
            
            /**
             * @desc Check that signer info of the AA certificate is a digest    
             * <pre>
             * Pics 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 signer_info {
             *             containing type
             *               indicating 'certificate_digest_with_sha256'
             *             containing digest
             *           }
             *         }
             *       }
             *   }
             * }
             * </pre>
             * @reference ETSI TS 103 097 V1.1.14, clauses 6.1, 7.4, 7.4.1
             */
            testcase TC_SEC_SND_CERT_AT_02_01() runs on ItsGeoNetworking system ItsSecSystem {
                var Certificate         v_at_cert;
                
                // Test component configuration
                f_cf01Up();
                
                // 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_certificate(mw_signerInfo_digest))
                ) {
                    log("*** " & testcasename() & ": FAIL: AT certificate doesn't contain a digest of issuing cert ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                }
                log("*** " & testcasename() & ": PASS: The signer info of AT certificate is a digest ***");
                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                
                // Postamble
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_SND_CERT_AT_02_01
            
            /**
             * @desc Check that the subject_name variable-length vector is empty for AT certificates     
             * <pre>
             * Pics 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 certificates {
             *           containing subject_info.subject_name
             *             indicating length = 0
             *         }
             *       }
             *   }
             * }
             * </pre>
             * @reference ETSI TS 103 097 V1.1.14, clauses 7.4.1
             */
            testcase TC_SEC_SND_CERT_AT_03_01() runs on ItsGeoNetworking system ItsSecSystem {
                var Certificate         v_at_cert;
                
                // Test component configuration
                f_cf01Up();
                
                // 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 (0 != lengthof(v_at_cert.subject_info.subject_name)) {
                    log("*** " & testcasename() & ": FAIL: Subject name of the AT certificate is not empty ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                }
                log("*** " & testcasename() & ": PASS: Subject name of the AT certificate is empty ***");
                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                
                // Postamble
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_SND_CERT_AT_03_01
            
            /**
             * @desc Check that all neccesary subject attributes of AT certificate are present and arranged in accesing order     
             * <pre>
             * Pics 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 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']
             *           }
             *         }
             *       }
             *   }
             * }
             * </pre>
             * @reference ETSI TS 103 097 V1.1.14, clauses 6.1, 7.4, 7.4.1
             */
            testcase TC_SEC_SND_CERT_AT_04_01() runs on ItsGeoNetworking system ItsSecSystem {
                var Certificate         v_at_cert;
                var SubjectAttributes   v_attrs;
                
                // Test component configuration
                f_cf01Up();
                
                // 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();
            } // End of testcase TC_SEC_SND_CERT_AT_04_01
            
            /**
             * @desc Check that time_start_and_end is included in the AT certificate validation restrictions
             *       Check that time_start_and_end is inside the AA certificate time restrictions       
             * <pre>
             * Pics 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[last-1] {
             *           containing subject_info.subject_type
             *             indicating 'authorization_authority' (2)
             *           containing validity_restrictions['time_start_and_end']
             *             containing start_validity
             *               indicating START_AA_VALIDITY
             *             containing end_validity
             *               indicating END_AA_VALIDITY
             *           }
             *         }
             *         containing certificates[last] {
             *           containing subject_info.subject_type
             *             indicating 'authorization_ticket' (1)
             *           not containing validity_restrictions['time_end']
             *           and not containing validity_restrictions['time_start_and_duration']
             *           and containing validity_restrictions['time_start_and_end'] {
             *             containing start_validity
             *               indicating START_AT_VALIDITY (START_AT_VALIDITY >= START_AA_VALIDITY )
             *             and containing end_validity
             *               indicating END_AT_VALIDITY (END_AT_VALIDITY >= START_AT_VALIDITY <= END_AA_VALIDITY)
             *           }
             *         }
             *       }
             *   }
             * }
             * </pre>
             * @reference ETSI TS 103 097 V1.1.14, clauses 6.7, 7.4, 7.4.1
             */
            testcase TC_SEC_SND_CERT_AT_05_01() runs on ItsGeoNetworking system ItsSecSystem {
                var CertificateChain         v_chain;
                var Certificate              v_aa_cert, v_at_cert;
                var ValidityRestriction      v_vr, v_aa_vr;
                
                // Test component configuration
                f_cf01Up();
                
                // 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 (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);
                }
                
                if ( true != f_getCertificateValidityRestriction(v_aa_cert, e_time_start_and_end, v_aa_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_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);
                }
                
                log("*** " & testcasename() & ": PASS: Time validity restriction of the AT certificate is good ***");
                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                
                // Postamble
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_SND_CERT_AT_05_01
            
            /**
             * @desc Check that all AIDs containing in the in the its_aid_ssp_list in AT certificate are unique and exists in the its_aid_list in the AA certificate
             *       Check that the length of SSP of each AID is 31 octet maximum        
             * <pre>
             * Pics 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[last-1] {
             *           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
             *           }
             *         }
             *         containing certificates[last] {
             *           containing subject_info.subject_type
             *             indicating 'authorization_ticket' (1)
             *           containing subject_attributes['its_aid_ssp_list']
             *             containing its_aid_ssp_list[0..N] {
             *               containing its_aid_ssp_list[n]{
             *                 containing its_aid
             *                   indicating unique value containing in the  ITS_AID_LIST_AA
             *                 containing service_specific_permissions
             *                   indicating length <= 31 octet
             *               }
             *             }
             *           }
             *         }
             *       }
             *   }
             * }
             * </pre>
             * @reference ETSI TS 103 097 V1.1.14, clauses 6.9, 7.4.1
             */
            testcase TC_SEC_SND_CERT_AT_07_01() runs on ItsGeoNetworking system ItsSecSystem {
                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 component configuration
                f_cf01Up();
                
                // 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 (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
//                    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);
//                    }
                    // TODO Not possible due to typing To be removed
//                    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);
//                    }
                } // 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();
            } // End of testcase TC_SEC_SND_CERT_AT_07_01
            
            /**
             * @desc Check that AT certificate is signed by AA cert         
             * <pre>
             * Pics 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 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)
             *         }
             *         containing certificates[last] {
             *           containing subject_info.subject_type
             *             indicating 'authorization_ticket' (1)
             *           }
             *           and containing signer_info[0]{
             *             containing type
             *               indicating 'certificate_digest_with_sha256'
             *             containing digest
             *               referencing to CERT_AA
             *           }
             *           and containing signature
             *             verifiable using KEY
             *         }
             *       }
             *   }
             * }
             * </pre>
             * @reference ETSI TS 103 097 V1.1.14, clauses 6.9, 7.4.1
             */
            testcase TC_SEC_SND_CERT_AT_08_01() runs on ItsGeoNetworking system ItsSecSystem {
                var CertificateChain         v_chain;
                var Certificate              v_aa_cert, v_at_cert;
                var HashedId8                v_aa_digest;
                
                // Test component configuration
                f_cf01Up();
                
                // 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 (f_askAndWaitForCertificateChain(v_chain, f_generateDefaultCam())) {
                    log("*** " & testcasename() & ": INCONC: Expected message not received ***");
                    f_selfOrClientSyncAndVerdictPreamble(c_tbDone, e_timeout);
                }
                tc_ac.stop;
                if (lengthof(v_chain) < 2) {
                    log("*** " & testcasename() & ": FAIL: Certificate chain is too short ***");
                    f_selfOrClientSyncAndVerdictPreamble(c_tbDone, e_error);
                }
                v_at_cert := v_chain[lengthof(v_chain) - 1];
                v_aa_cert := v_chain[lengthof(v_chain) - 2];
                v_aa_digest := f_calculateDigestFromCertificate(v_aa_cert); 
                
                if (not match(v_at_cert, mw_at_certificate(mw_signerInfo_digest(v_aa_digest)))) {
                    log("*** " & testcasename() & ": FAIL: AT certificate signer info doesn't reference the  AA certificate from the chain ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                }
                
                if (not f_verifyCertificateSignatureWithIssuingCertificate(v_at_cert, v_aa_cert)) {
                    log("*** " & testcasename() & ": FAIL: AT certificate signature verification failed ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                }
                
                log("*** " & testcasename() & ": PASS: AT certificate was signed by the AA certificate from the given chain ***");
                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                
                // Postamble
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_SND_CERT_AT_08_01
            
            /**
             * @desc Check that the assurance level of the subordinate certificate is equal to or lower than the assurance level of the issuing certificate
             * <pre>
             * Pics 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[last-1] (CERT_AA) {
             *           containing subject_attributes ['assurance_level']
             *             containig assurance_level
             *               indicating indicating assurance level AL_AA
             *         }
             *         containing certificates[last] (CERT_AT) {
             *           containing subject_attributes ['assurance_level']
             *             containig assurance_level
             *               indicating indicating assurance level AL_AT (AL_AT <= AL_AA)
             *         }
             *           }
             *         }
             *       }
             *   }
             * }
             * </pre>
             * @reference ETSI TS 103 097 V1.1.14, clauses 6.9, 7.4.1
             */
            testcase TC_SEC_SND_CERT_AT_09_01() 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 component configuration
                f_cf01Up();
                
                // 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 (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_SND_CERT_AT_09_01
            
        } // End of group g_AT_Certificates 
        
    } // End of group g_Certificates
    
} // End of module ItsSecurity_TestCase