ItsSecurity_TestCases.ttcn 1.35 MB
Newer Older
filatov's avatar
filatov committed
             *     the IUT being in the 'authorized' state
             *     and the IUT current time is inside the time validity period of CERT_TS_A_AT
             * Expected results:
             *   ensure that
             *     when
             *       the IUT is receiving a SecuredMessage (MSG_SEC_RCV_DENM_A)
             *         containing header_fields['signer_info']
             *             containing certificate (CERT_TS_MSG_06_02_BO_AT)
             *               containing validity_restrictions['time_start_and_end']
             *                 containing start_validity
             *                   indicating START_VALIDITY_AT
             *                 and containing end_validity
             *                   indicating END_VALIDITY_AT
             *         and containing header_fields ['generation_time']
             *           containing generation_time
             *             indicating GEN_TIME > END_VALIDITY_AT
             *     then
             *       the IUT discards the message
             * </pre>
filatov's avatar
filatov committed
             * @see         ETSI TS 103 096-2 v1.3.1 TP_SEC_ITSS_RCV_DENM_06_02_BO
             * @reference   ETSI TS 103 097 v1.2.1, clauses 5.4 and 7.2
             */
            testcase TC_SEC_ITSS_RCV_DENM_06_02_BO() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var integer i;
                var GeoNetworkingPdu v_securedGnPdu;
                var GnRawPayload v_sentRawPayload;
                var LongPosVector v_longPosVectorNodeB := f_getPosition(c_compNodeB); // Use NodeB
                var ValidityRestriction v_validity;
                
                // Test adapter configuration
                if (not(PICS_GN_SECURITY)) {
                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY' required for executing the TC ***");
                    stop;
                }
                
                // Test component configuration
                f_cf01Up();
                
                // Test adapter configuration
                
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
                f_getCertificateValidityRestriction(vc_atCertificate, e_time_start_and_end, v_validity);
                v_securedGnPdu := f_prepareSecuredDenm(
                    cc_taCert0602_BO, 
                    {
                        m_header_field_generation_time(
                            (v_validity.validity.time_start_and_end.end_validity + 3600) * 1000
                        ) // In us
                    }, 
                    e_certificate
                ); 
                f_sendGeoNetMessage(m_geoNwReq_linkLayerBroadcast(v_securedGnPdu));
                
                f_sleep(PX_TNOAC);
                v_sentRawPayload := f_adaptPayloadForUtInd_m(v_securedGnPdu.gnPacket.packet.payload);
                for (i := 0; i < lengthof(vc_utInds) and not match(vc_utInds[i].rawPayload, v_sentRawPayload); i := i + 1) {
                    // Empty on purpose 
                } // 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_06_02_BO
            
            /**
filatov's avatar
filatov committed
             * @desc  Check that IUT discards a Secured DENM if the generation_time is more than 10 minute in the past (C2C only)
filatov's avatar
filatov committed
             * Pics Selection: PICS_GN_SECURITY AND PICS_C2C
             * Config Id: CF01
             * Initial conditions:
filatov's avatar
filatov committed
             *   with
             *     the IUT being in the 'authorized' state
             *     and the IUT current time is inside the time validity period of CERT_TS_A_AT
             * Expected results:
             *   ensure that
             *     when
             *       the IUT is receiving a SecuredMessage (MSG_SEC_RCV_DENM_A)
             *         containing header_fields ['generation_time']
             *           containing generation_time
             *             indicating CURRENT_TIME - 11min
             *     then
             *       the IUT discards the message
             * </pre>
filatov's avatar
filatov committed
             * @see         ETSI TS 103 096-2 v1.3.1 TP_SEC_ITSS_RCV_DENM_06_03_BO
             * @reference   ETSI TS 103 097 v1.2.1, clauses 5.4 and 7.2
             */
            testcase TC_SEC_ITSS_RCV_DENM_06_03_BO() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var integer i;
                var GeoNetworkingPdu v_securedGnPdu;
                var GnRawPayload v_sentRawPayload;
                var LongPosVector v_longPosVectorNodeB := f_getPosition(c_compNodeB); // Use NodeB
                
                // Test adapter configuration
                if (not(PICS_GN_SECURITY)) {
                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY' required for executing the TC ***");
                    stop;
                }
                
                // Test component configuration
                f_cf01Up();
                
                // Test adapter configuration
                
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
                v_securedGnPdu := f_prepareSecuredDenm(
                    cc_taCert_A, 
                    {
                        m_header_field_generation_time( 
                            (1000 * f_getCurrentTime() - 660) * 1000
                        ) // In us
                    }, 
                    e_certificate
                ); 
                f_sendGeoNetMessage(m_geoNwReq_linkLayerBroadcast(v_securedGnPdu));
                
                f_sleep(PX_TNOAC);
                v_sentRawPayload := f_adaptPayloadForUtInd_m(v_securedGnPdu.gnPacket.packet.payload);
                for (i := 0; i < lengthof(vc_utInds) and not match(vc_utInds[i].rawPayload, v_sentRawPayload); i := i + 1) {
                    // Empty on purpose 
                } // 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_06_03_BO
            
            /**
filatov's avatar
filatov committed
             * @desc  Check that IUT discards a Secured DENM if the generation_time is more than 10 minute in the future(C2C only)
filatov's avatar
filatov committed
             * Pics Selection: PICS_GN_SECURITY AND PICS_C2C
             * Config Id: CF01
             * Initial conditions:
filatov's avatar
filatov committed
             *   with
             *     the IUT being in the 'authorized' state
             *     and the IUT current time is inside the time validity period of CERT_TS_A_AT
             * Expected results:
             *   ensure that
             *     when
             *       the IUT is receiving a SecuredMessage (MSG_SEC_RCV_DENM_A)
             *         containing header_fields ['generation_time']
             *           containing generation_time
             *             indicating CURRENT_TIME + 11min
             *     then
             *       the IUT discards the message
             * </pre>
filatov's avatar
filatov committed
             * @see         ETSI TS 103 096-2 v1.3.1 TP_SEC_ITSS_RCV_DENM_06_04_BO
             * @reference   ETSI TS 103 097 v1.2.1, clauses 5.4 and 7.2
             */
            testcase TC_SEC_ITSS_RCV_DENM_06_04_BO() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var integer i;
                var GeoNetworkingPdu v_securedGnPdu;
                var GnRawPayload v_sentRawPayload;
                var LongPosVector v_longPosVectorNodeB := f_getPosition(c_compNodeB); // Use NodeB
                
                // Test adapter configuration
                if (not(PICS_GN_SECURITY)) {
                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY' required for executing the TC ***");
                    stop;
                }
                
                // Test component configuration
                f_cf01Up();
                
                // Test adapter configuration
                
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
                v_securedGnPdu := f_prepareSecuredDenm(
                    cc_taCert_A, 
                    {
                        m_header_field_generation_time( 
                            (1000 * f_getCurrentTime() + 660) * 1000
                        ) // In us
                    }, 
                    e_certificate
                ); 
                f_sendGeoNetMessage(m_geoNwReq_linkLayerBroadcast(v_securedGnPdu));
                
                f_sleep(PX_TNOAC);
                v_sentRawPayload := f_adaptPayloadForUtInd_m(v_securedGnPdu.gnPacket.packet.payload);
                for (i := 0; i < lengthof(vc_utInds) and not match(vc_utInds[i].rawPayload, v_sentRawPayload); i := i + 1) {
                    // Empty on purpose 
                } // 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_06_04_BO
            
            /**
filatov's avatar
filatov committed
             * @desc  Check that IUT discards a Secured DENM when its_aid value is not AID_DENM
             * <pre>
             * Pics Selection: PICS_GN_SECURITY
             * Config Id: CF01
             * Initial conditions:
filatov's avatar
filatov committed
             *   with
             *     the IUT being in the 'authorized' state
             *     and the IUT current time is inside the time validity period of CERT_TS_A_AT
             * Expected results:
             *   ensure that
             *     when
             *       the IUT is receiving a SecuredMessage (MSG_SEC_RCV_DENM_A)
             *         containing header_fields['its_aid']
             *           indicating 'AID_CAM'
             *         and containing payload_field
             *           containing type
             *             indicating 'signed'
             *           and containing data
             *             containing DENM payload
             *     then
             *       the IUT discards the DENM message
             * </pre>
filatov's avatar
filatov committed
             * @see         ETSI TS 103 096-2 v1.3.1 TP_SEC_ITSS_RCV_DENM_07_01_BO
             * @reference   ETSI TS 103 097 v1.2.1, clause 7.2
             */
            testcase TC_SEC_ITSS_RCV_DENM_07_01_BO() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var integer i;
                var GeoNetworkingPdu v_securedGnPdu;
                var GnRawPayload v_sentRawPayload;
                
                // Test control
                if (not(PICS_GN_SECURITY)) {
                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY' required for executing the TC ***");
                    stop;
                }
                
                // Test component configuration
                f_cf01Up();
                
                // Test adapter configuration
                
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
                v_securedGnPdu := f_prepareSecuredDenm(
                    cc_taCert_A, 
                    {
                        m_header_field_its_aid_CAM
                    }
                ); 
                f_sendGeoNetMessage(m_geoNwReq_linkLayerBroadcast(v_securedGnPdu));
                
                f_sleep(PX_TNOAC);
                v_sentRawPayload := f_adaptPayloadForUtInd_m(v_securedGnPdu.gnPacket.packet.payload);
                for (i := 0; i < lengthof(vc_utInds) and not match(vc_utInds[i].rawPayload, v_sentRawPayload); i := i + 1) {
                    // Empty on purpose 
                } // End of 'for' statement
                if (i < lengthof(vc_utInds)) {
                    log("*** " & testcasename() & ": FAIL: GN was transmitted to upper layer ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                }
                else {
                    log("*** " & testcasename() & ": PASS: GN was not transmitted to upper layer ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                }
                
                // Postamble
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_ITSS_RCV_DENM_07_01_BO
            
            /**
             * @desc  Check that IUT discards a Secured DENM when its_aid value is undefined
             * <pre>
             * Pics Selection: PICS_GN_SECURITY
             * Config Id: CF01
             * Initial conditions:
filatov's avatar
filatov committed
             *   with
             *     the IUT being in the 'authorized' state
             *     and the IUT current time is inside the time validity period of CERT_TS_A_AT
             * Expected results:
             *   ensure that
             *     when
             *       the IUT is receiving a SecuredMessage (MSG_SEC_RCV_DENM_A)
             *         containing header_fields['its_aid']
             *           indicating 'AID_UNDEFINED'
             *         and containing payload_field
             *           containing type
             *             indicating 'signed'
             *           and containing data
             *             containing DENM payload
             *     then
             *       the IUT discards the message
             * </pre>
filatov's avatar
filatov committed
             * @see         ETSI TS 103 096-2 v1.3.1 TP_SEC_ITSS_RCV_DENM_07_02_BO
             * @reference   ETSI TS 103 097 v1.2.1, clause 7.2
             */
            testcase TC_SEC_ITSS_RCV_DENM_07_02_BO() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var integer i;
                var GeoNetworkingPdu v_securedGnPdu;
                var GnRawPayload v_sentRawPayload;
                
                // Test control
                if (not(PICS_GN_SECURITY)) {
                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY' required for executing the TC ***");
                    stop;
                }
                
                // Test component configuration
                f_cf01Up();
                
                // Test adapter configuration
                
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
                v_securedGnPdu := f_prepareSecuredDenm(
                    cc_taCert_A, 
                    {
                        m_header_field_its_aid_Other
                    }
                ); 
                f_sendGeoNetMessage(m_geoNwReq_linkLayerBroadcast(v_securedGnPdu));
                
                f_sleep(PX_TNOAC);
                v_sentRawPayload := f_adaptPayloadForUtInd_m(v_securedGnPdu.gnPacket.packet.payload);
                for (i := 0; i < lengthof(vc_utInds) and not match(vc_utInds[i].rawPayload, v_sentRawPayload); i := i + 1) {
                    // Empty on purpose 
                } // End of 'for' statement
                if (i < lengthof(vc_utInds)) {
                    log("*** " & testcasename() & ": FAIL: GN was transmitted to upper layer ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                }
                else {
                    log("*** " & testcasename() & ": PASS: GN was not transmitted to upper layer ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                }
                
                // Postamble
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_ITSS_RCV_DENM_07_02_BO
            
            /**
filatov's avatar
filatov committed
             * @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: PICS_GN_SECURITY AND PICS_USE_CIRCULAR_REGION
             * Config Id: CF01
             * Initial conditions:
             *   with
             *     the IUT being in the 'authorized' state
             * Expected results:
             *   ensure that
             *     when
             *       the IUT is receiving a SecuredMessage
             *         and containing header_fields ['signer_info'].type
             *           indicating certificate
             *         and containing header_fields ['signer_info'].certificate (CERT_TS_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 value outside of the REGION
             *         and containing header_fields['its_aid']
             *           indicating 'AID_DENM'
             *     then
             *       the IUT discards the message
             * </pre>
filatov's avatar
filatov committed
             * @see         ETSI TS 103 096-2 v1.3.1 TP_SEC_ITSS_RCV_DENM_08_01_BO
             * @reference   ETSI TS 103 097 v1.2.1, clause 7.2
             */
            testcase TC_SEC_ITSS_RCV_DENM_08_01_BO() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var integer i;
                var GeoNetworkingPdu v_securedGnPdu;
                var GnRawPayload v_sentRawPayload;
                
                // Test control
                if (not(PICS_GN_SECURITY) or not(PICS_USE_CIRCULAR_REGION)) {
                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY and PICS_USE_CIRCULAR_REGION' required for executing the TC ***");
                    stop;
                }
                
                // Test component configuration
                f_cf01Up();
                
                // Test adapter configuration
                
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
                v_securedGnPdu := f_sendSecuredDenm(cc_taCert_B_BO, omit, e_certificate);
                
                f_sleep(PX_TNOAC);
                v_sentRawPayload := f_adaptPayloadForUtInd_m(v_securedGnPdu.gnPacket.packet.payload);
                for (i := 0; i < lengthof(vc_utInds) and not match(vc_utInds[i].rawPayload, v_sentRawPayload); i := i + 1) {
                    // Empty on purpose 
                } // 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_08_01_BO
            
            /**
filatov's avatar
filatov committed
             * @desc  Check that IUT discards Secured DENM if the HeaderField generation_location is outside of the rectangular validity region of the signing certificate
             * <pre>
             * Pics Selection: PICS_GN_SECURITY AND PICS_USE_RECTANGULAR_REGION
             * Config Id: CF01
             * Initial conditions:
             *   with
             *     the IUT being in the 'authorized' state
             * Expected results:
             *   ensure that
             *     when
             *       the IUT is receiving a SecuredMessage
             *         containing header_fields ['signer_info'].type
             *           indicating certificate
             *         and containing header_fields ['signer_info'].certificate (CERT_TS_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 value outside of the REGION
             *         and containing header_fields['its_aid']
             *           indicating 'AID_DENM'
             *     then
             *       the IUT discards the message
             * </pre>
filatov's avatar
filatov committed
             * @see         ETSI TS 103 096-2 v1.3.1 TP_SEC_ITSS_RCV_DENM_08_02_BO
             * @reference   ETSI TS 103 097 v1.2.1, clause 7.2
             */
            testcase TC_SEC_ITSS_RCV_DENM_08_02_BO() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var integer i;
                var GeoNetworkingPdu v_securedGnPdu;
                var GnRawPayload v_sentRawPayload;
                
                // Test control
                if (not(PICS_GN_SECURITY) or not(PICS_USE_RECTANGULAR_REGION)) {
                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY and PICS_USE_RECTANGULAR_REGION' required for executing the TC ***");
                    stop;
                }
                
                // Test component configuration
                f_cf01Up();
                
                // Test adapter configuration
                
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
                v_securedGnPdu := f_sendSecuredDenm(cc_taCert_C_BO, omit, e_certificate);
                
                f_sleep(PX_TNOAC);
                v_sentRawPayload := f_adaptPayloadForUtInd_m(v_securedGnPdu.gnPacket.packet.payload);
                for (i := 0; i < lengthof(vc_utInds) and not match(vc_utInds[i].rawPayload, v_sentRawPayload); i := i + 1) {
                    // Empty on purpose 
                } // 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_08_02_BO
            
            /**
filatov's avatar
filatov committed
             * @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: PICS_GN_SECURITY AND PICS_USE_POLYGONAL_REGION
             * Config Id: CF01
             * Initial conditions:
             *   with
             *     the IUT being in the 'authorized' state
             * Expected results:
             *   ensure that
             *     when
             *       the IUT is receiving a SecuredMessage
             *         containing header_fields ['signer_info'].type
             *           indicating certificate
             *         and containing header_fields ['signer_info'].certificate (CERT_TS_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 value outside of the REGION
             *         and containing header_fields['its_aid']
             *           indicating 'AID_DENM'
             *     then
             *       the IUT discards the message
             * </pre>
filatov's avatar
filatov committed
             * @see         ETSI TS 103 096-2 v1.3.1 TP_SEC_ITSS_RCV_DENM_08_03_BO
             * @reference   ETSI TS 103 097 v1.2.1, clause 7.2
             */
            testcase TC_SEC_ITSS_RCV_DENM_08_03_BO() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var integer i;
                var GeoNetworkingPdu v_securedGnPdu;
                var GnRawPayload v_sentRawPayload;
                
                // Test control
                if (not(PICS_GN_SECURITY) or not(PICS_USE_POLYGONAL_REGION)) {
                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY and PICS_USE_POLYGONAL_REGION' required for executing the TC ***");
                    stop;
                }
                
                // Test component configuration
                f_cf01Up();
                
                // Test adapter configuration
                
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
                v_securedGnPdu := f_sendSecuredDenm(cc_taCert_D_BO, omit, e_certificate);
                
                f_sleep(PX_TNOAC);
                v_sentRawPayload := f_adaptPayloadForUtInd_m(v_securedGnPdu.gnPacket.packet.payload);
                for (i := 0; i < lengthof(vc_utInds) and not match(vc_utInds[i].rawPayload, v_sentRawPayload); i := i + 1) {
                    // Empty on purpose 
                } // 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_08_03_BO
            
            /**
filatov's avatar
filatov committed
             * @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: PICS_GN_SECURITY AND PICS_USE_IDENTIFIED_REGION
             * Config Id: CF01
             * Initial conditions:
             *   with
             *     the IUT being in the 'authorized' state
             * Expected results:
             *   ensure that
             *     when
             *       the IUT is receiving a SecuredMessage
             *         containing header_fields ['signer_info'].type
             *           indicating certificate
             *         and containing header_fields ['signer_info'].certificate (CERT_TS_AT_E)
             *           containing validity_restrictions ['region']
             *             containing region
             *               containing region_type
             *                 indicating 'id_region'
             *               and and containing identified_region
             *                 indicating REGION
             *         and containing header_fields ['generation_location']
             *           containing generation_location
             *             indicating value outside of the REGION
             *         and containing header_fields['its_aid']
             *           indicating 'AID_DENM'
             *     then
             *       the IUT discards the message
             * </pre>
filatov's avatar
filatov committed
             * @see         ETSI TS 103 096-2 v1.3.1 TP_SEC_ITSS_RCV_DENM_08_04_BO
             * @reference   ETSI TS 103 097 v1.2.1, clause 7.2
             */
            testcase TC_SEC_ITSS_RCV_DENM_08_04_BO() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var integer i;
                var GeoNetworkingPdu v_securedGnPdu;
                var GnRawPayload v_sentRawPayload;
                
                // Test control
                if (not(PICS_GN_SECURITY) or not(PICS_USE_IDENTIFIED_REGION)) {
                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY and PICS_USE_IDENTIFIED_REGION' required for executing the TC ***");
                    stop;
                }
                
                // Test component configuration
                f_cf01Up();
                
                // Test adapter configuration
                
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
                v_securedGnPdu := f_sendSecuredDenm(cc_taCert_E_BO, omit, e_certificate);
                
                f_sleep(PX_TNOAC);
                v_sentRawPayload := f_adaptPayloadForUtInd_m(v_securedGnPdu.gnPacket.packet.payload);
                for (i := 0; i < lengthof(vc_utInds) and not match(vc_utInds[i].rawPayload, v_sentRawPayload); i := i + 1) {
                    // Empty on purpose 
                } // 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_08_04_BO
            
            /**
filatov's avatar
filatov committed
             * @desc  Check that IUT accepts a Secured DENM if the distance between the current position of IUT and the value of optional HeaderField generation_location is 29.9 km (C2C only)
filatov's avatar
filatov committed
             * Pics Selection: PICS_GN_SECURITY AND PICS_C2C
             * Config Id: CF01
filatov's avatar
filatov committed
             * Initial conditions:
             *   with
             *     the IUT being in the 'authorized' state
             *     and the IUT current time is inside the time validity period of CERT_TS_A_AT
             * Expected results:
             *   ensure that
             *     when
             *       the IUT is receiving a SecuredMessage (MSG_SEC_RCV_DENM_A)
             *         containing header_fields ['generation_location']
             *           containing generation_location
             *             indicating position in 29.9 km from the current position of IUT
             *     then
             *       the IUT accepts the message
             * </pre>
filatov's avatar
filatov committed
             * @see         ETSI TS 103 096-2 v1.3.1 TP_SEC_ITSS_RCV_DENM_08_05_BV
             * @reference   ETSI TS 103 097 v1.2.1, clause 7.2
             */
            testcase TC_SEC_ITSS_RCV_DENM_08_05_BV() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var integer i;
                var GeoNetworkingPdu v_securedGnPdu;
                var GnRawPayload v_sentRawPayload;
                var LongPosVector v_longPosVectorNodeB := f_getPosition(c_compNodeB); // Use NodeB
                var Int32 v_latitude;
                var Int32 v_longitude;
                
                
                // 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
                fx_computePositionUsingDistance(
                    v_longPosVectorNodeB.latitude,
                    v_longPosVectorNodeB.longitude,
                    29900.0, 
                    0,
                    v_latitude,
                    v_longitude
                );
                v_securedGnPdu := f_prepareSecuredDenm(
                    cc_taCert_A, 
                    {
                        m_header_field_generation_location(
                            valueof(m_threeDLocation(
                                v_latitude,
                                v_longitude,
                                '0000'O
                            ))
                        )
                    }, 
                    e_certificate_digest_with_sha256
                ); 
                f_sendGeoNetMessage(m_geoNwReq_linkLayerBroadcast(v_securedGnPdu));
                
                f_sleep(PX_TNOAC);
                v_sentRawPayload := f_adaptPayloadForUtInd_m(v_securedGnPdu.gnPacket.packet.payload);
                for (i := 0; i < lengthof(vc_utInds) and not match(vc_utInds[i].rawPayload, v_sentRawPayload); i := i + 1) {
                    // Empty on purpose 
                }
                if (i < lengthof(vc_utInds)) {
                    log("*** " & testcasename() & ": PASS: 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_08_05_BV
            
            /**
filatov's avatar
filatov committed
             * @desc  Check that IUT discards Secured DENM if the distance between the current position of IUT and the value of optional HeaderField generation_location is more than 30 km
filatov's avatar
filatov committed
             * Pics Selection: PICS_GN_SECURITY AND PICS_C2C
             * Config Id: CF01
filatov's avatar
filatov committed
             * Initial conditions:
             *   with
             *     the IUT being in the 'authorized' state
             *     and the IUT current time is inside the time validity period of CERT_TS_A_AT
             * Expected results:
             *   ensure that
             *     when
             *       the IUT is receiving a SecuredMessage
             *         and containing header_fields ['generation_location']
             *           containing generation_location
             *             indicating position in 31 km from the current position of IUT
             *     then
             *       the IUT discards the message
             * </pre>
filatov's avatar
filatov committed
             * @see         ETSI TS 103 096-2 v1.3.1 TP_SEC_ITSS_RCV_DENM_08_06_BO
             * @reference   ETSI TS 103 097 v1.2.1, clause 7.2
             */
            testcase TC_SEC_ITSS_RCV_DENM_08_06_BO() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var integer i;
                var GeoNetworkingPdu v_securedGnPdu;
                var GnRawPayload v_sentRawPayload;
                var LongPosVector v_longPosVectorNodeB := f_getPosition(c_compNodeB); // Use NodeB
                var Int32 v_latitude;
                var Int32 v_longitude;
                
                
                // 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
                fx_computePositionUsingDistance(
                    v_longPosVectorNodeB.latitude,
                    v_longPosVectorNodeB.longitude,
                    31000.0, 
                    0,
                    v_latitude,
                    v_longitude
                );
                v_securedGnPdu := f_prepareSecuredDenm(
                    cc_taCert_A, 
                    {
                        m_header_field_generation_location(
                            valueof(m_threeDLocation(
                                v_latitude,
                                v_longitude,
                                '0000'O
                            ))
                        )
                    }, 
                    e_certificate_digest_with_sha256
                ); 
                f_sendGeoNetMessage(m_geoNwReq_linkLayerBroadcast(v_securedGnPdu));
                
                f_sleep(PX_TNOAC);
                v_sentRawPayload := f_adaptPayloadForUtInd_m(v_securedGnPdu.gnPacket.packet.payload);
                for (i := 0; i < lengthof(vc_utInds) and not match(vc_utInds[i].rawPayload, v_sentRawPayload); i := i + 1) {
                    // Empty on purpose 
                }
                if (i < lengthof(vc_utInds)) {
                    log("*** " & testcasename() & ": 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_08_06_BO
            
            /**
filatov's avatar
filatov committed
             * @desc  Check that IUT discards the Secured DENM containing empty payload of type 'signed'
             * <pre>
             * Pics Selection: PICS_GN_SECURITY
             * Config Id: CF01
             * Initial conditions:
filatov's avatar
filatov committed
             *   with
             *     the IUT being in the 'authorized' state
             *     and the IUT current time is inside the time validity period of CERT_TS_A_AT
             * Expected results:
             *   ensure that
             *     when
             *       the IUT is receiving a SecuredMessage (MSG_SEC_RCV_DENM_A)
             *         containing payload_field
             *           containing type
             *             indicating 'signed'
             *           and containing data
             *             indicating length 0
             *     then
             *       the IUT discards the message
             * </pre>
filatov's avatar
filatov committed
             * @see         ETSI TS 103 096-2 v1.3.1 TP_SEC_ITSS_RCV_DENM_09_02_BO
             * @reference   ETSI TS 103 097 v1.2.1, clause 7.2
filatov's avatar
filatov committed
             */
            testcase TC_SEC_ITSS_RCV_DENM_09_02_BO() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var integer i;
                var GnNonSecuredPacket v_gnNonSecuredPacket;
                var octetstring v_gnPayload;
                var template (value) SecuredMessage v_securedMessage;
                var GeoNetworkingPdu v_securedGnPdu;
                var GnRawPayload v_sentRawPayload;
                var LongPosVector v_longPosVectorNodeB := f_getPosition(c_compNodeB); // Use NodeB
                var template (value) SituationContainer v_situation := m_situation(CauseCodeType_vehicleBreakdown_, VehicleBreakdownSubCauseCode_unavailable_);
                
                // Test adapter configuration
                if (not(PICS_GN_SECURITY)) {
                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY' required for executing the TC ***");
                    stop;
                }
                
                // Test component configuration
                f_cf01Up();
                
                // Test adapter configuration
                
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
                v_gnNonSecuredPacket := valueof(
                    m_geoNwBroadcastPacket(
                        v_longPosVectorNodeB,
                        vc_localSeqNumber,
                        f_getGeoBroadcastArea(
                            c_area1                 // Select area1 (see ETSI TS 102 871-2 Clause 4.2 Configuration 1)
                )));
                // Add the DENM payload
                v_gnNonSecuredPacket.payload := valueof(
                    f_adaptPayload_m(
                        bit2oct(
                            encvalue(
                                m_denmReq(
                                    m_denmPdu(
                                        m_denm(
                                            m_denmMgmtCon(
                                                m_tsActionId
                                            ),
                                            v_situation,
                                            m_denmLocation_zeroDelta
                )))))));
                
                // Encode it
                v_gnPayload := bit2oct(
                    encvalue(
                        v_gnNonSecuredPacket
                    )
                );
                f_buildGnSecuredDenm(
                    v_securedMessage,
                    m_payload_signed(
                        ''O
                    ),
                    e_certificate_digest_with_sha256,
                    valueof(m_threeDLocation(
                        v_longPosVectorNodeB.latitude,
                        v_longPosVectorNodeB.longitude,
                        '0000'O
                    ))
                );
                v_securedGnPdu := valueof(m_geoNwSecPdu(v_gnNonSecuredPacket, v_securedMessage));
                f_sendGeoNetMessage(m_geoNwReq_linkLayerBroadcast(v_securedGnPdu));
                
                f_sleep(PX_TNOAC);
                v_sentRawPayload := f_adaptPayloadForUtInd_m(v_securedGnPdu.gnPacket.packet.payload);
                for (i := 0; i < lengthof(vc_utInds) and not match(vc_utInds[i].rawPayload, v_sentRawPayload); i := i + 1) {
                    // Empty on purpose 
                } // End of 'for' statement
                if (i < lengthof(vc_utInds)) {
                    log("*** " & testcasename() & ": FAIL: GN was transmitted to upper layer ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                }
                else {
                    log("*** " & testcasename() & ": PASS: GN was not transmitted to upper layer ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                }
                
                // Postamble
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_ITSS_RCV_DENM_09_02_BO
            
            /**
filatov's avatar
filatov committed
             * @desc  Check that IUT discards the Secured DENM containing payload of type 'unsecured'
             * <pre>
             * Pics Selection: PICS_GN_SECURITY
             * Config Id: CF01
             * Initial conditions:
filatov's avatar
filatov committed
             *   with
             *     the IUT being in the 'authorized' state
             *     and the IUT current time is inside the time validity period of CERT_TS_A_AT
             * Expected results:
             *   ensure that
             *     when
             *       the IUT is receiving a SecuredMessage (MSG_SEC_RCV_DENM_A)
             *         containing payload_field
             *           containing type
             *             indicating 'unsecured'
             *           and containing data
             *             indicating length > 0