ItsSecurity_TestCases.ttcn 1.47 MB
Newer Older
//                    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(
//                                mw_securedMessage(
//                                    superset(
//                                        mw_header_field(
//                                            e_generation_time
//                                        ),
//                                        mw_header_info_signer_info_certificate,
//                                        mw_header_info_its_aid_Other
//                                    )
//                                ), 
//                                mw_geoNwBeaconPacket(
//                                    ?
//                                )
//                            )
//                    )) -> value v_geoNwInd { 
//                        const integer c_deltaTime := 2 * 3600 * 1000000; // Two hours, in microsecoonds
//                        
//                        tc_ac.stop;
//                        v_curTime := f_getCurrentTime();
//                        v_curTime := v_curTime * 1000; // Clause 4.2.16 Time64: is in microseconds
//                        
//                        if (
//                            f_getMsgHeaderField(
//                                v_geoNwInd.msgIn.gnPacket.securedMsg,
//                                e_generation_time, 
//                                v_headerField
//                        )) {
//                            v_generationTime := v_headerField.headerField.generation_time;  
//                            log("v_generationTime=", v_generationTime);
//                            log("v_curTime=", v_curTime);
//                            log("v_curTime - c_deltaTime=", v_curTime - c_deltaTime);
//                            if (v_generationTime < (v_curTime - c_deltaTime)) {
//                                log("*** " & testcasename() & ": FAIL: Beacon generation time is too far in the past");
//                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
//                            }
//                            
//                            if (v_generationTime > (v_curTime + c_deltaTime)) {
//                                log("*** " & testcasename() & ": FAIL: Beacon generation time is too far in the future");
//                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
//                            }
//                            
//                            // Check that generation time is inside the certificate validation period
//                            if (
//                                f_getMsgHeaderField(
//                                    v_geoNwInd.msgIn.gnPacket.securedMsg,
//                                    e_signer_info, 
//                                    v_headerField
//                            )) {
//                                v_cert := v_headerField.headerField.signer.signerInfo.certificate;
//                                
//                                for (v_counter := 0; v_counter < lengthof(v_cert.validity_restrictions); v_counter := v_counter + 1) {
//                                    if (v_cert.validity_restrictions[v_counter].type_ == e_time_end) {
//                                        v_endTime   := v_cert.validity_restrictions[v_counter].validity.end_validity * 1000000;
//                                        if (v_generationTime > v_endTime ) {
//                                            log("*** " & testcasename() & ": FAIL: Beacon generation time is not inside the validity of the certificate");
//                                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
//                                        }
//                                    } else if (v_cert.validity_restrictions[v_counter].type_ == e_time_start_and_end) {
//                                        v_endTime   := v_cert.validity_restrictions[v_counter].validity.time_start_and_end.end_validity   * 1000000;
//                                        v_startTime := v_cert.validity_restrictions[v_counter].validity.time_start_and_end.start_validity * 1000000;
//                                        if (v_generationTime < v_startTime or v_generationTime > v_endTime ) {
//                                            log("*** " & testcasename() & ": FAIL: Beacon generation time is not inside the validity of the certificate");
//                                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
//                                        }
//                                    } else if (v_cert.validity_restrictions[v_counter].type_ == e_time_start_and_duration) {
//                                        if (PICS_PLUGTEST_VERSION){
//                                            log("*** " & testcasename() & ": FAIL: Usage of time_start_and_duration is not allowed in TS103097 v1.2.5");
//                                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
//                                        }
//                                        v_startTime := v_cert.validity_restrictions[v_counter].validity.time_start_and_duration.start_validity * 1000000;
//                                        v_duration  := f_duration2time(v_cert.validity_restrictions[v_counter].validity.time_start_and_duration.duration_) * 1000000;
//                                        if (v_generationTime < v_startTime or (v_startTime + v_duration) > v_endTime ) {
//                                            log("*** " & testcasename() & ": FAIL: Beacon generation time is not inside the validity of the certificate");
//                                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
//                                        }
//                                    } else {
//                                        log("*** " & testcasename() & ": FAIL: Mal-formed the certificate");
//                                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
//                                    }
//                                } // End of 'for' statement
//                                log("*** " & testcasename() & ": PASS: Beacon generation time is inside the validity of the certificate");
//                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
//                            } else {
//                                log("*** " & testcasename() & ": INCONC: DENM signer info is not available");
//                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
//                            }
//                        }
//                    }
//                    [] tc_ac.timeout {
//                        log("*** " & testcasename() & ": INCONC: Expected Beacon not received ***");
//                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
//                    }
//                } // End of 'alt' statement
//                
//                // Postamble
//                f_acTriggerEvent(m_stopPassBeaconing);
//                f_poNeighbour();
//                f_cf01Down();
//            } // End of testcase TC_SEC_ITSS_SND_GENMSG_04_01_BV
//
//            /**
//             * @desc   Check that the secured GN Beacon contains exactly one HeaderInfo generation_location
//             *         when AT certificate does not contain any region restrictions
//             * <pre>
//             * Pics Selection: PICS_GN_SECURITY and PICS_ITS_AID_OTHER_PROFILE and PICS_CERTIFICATE_SELECTION
//             * Config Id: CF01
//             * with {
//             *   the IUT has been authorized with the AT certificate (CERT_IUT_A)
//             *       not containing validity_restrictions['region']
//             * }
//             * ensure that {
//             *   when {
//             *     the IUT is requested to send a Beacon
//             *   } then {
//             *     the IUT sends a Ieee1609Dot2Data
//             *         containing exactly one header_fields ['generation_location']
//             *             containing generation_location
//             *   }
//             * }
//             * </pre>
garciay's avatar
garciay committed
//             * @see          ETSI TS 103 096-2 v1.3.2 TP_SEC_ITSS_SND_GENMSG_05_01_BV
//             * @reference    ETSI TS 103 097 [1], clause 7.3
//             */
//            testcase TC_SEC_ITSS_SND_GENMSG_05_01_BV() runs on ItsGeoNetworking system ItsSecSystem {
//                
//                // Local variables
//                var LongPosVector v_longPosVectorIut;
//                
//                // Test control
//                if (not(PICS_GN_SECURITY) or not(PICS_ITS_AID_OTHER_PROFILE) or not(PICS_CERTIFICATE_SELECTION)) {
//                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY and PICS_ITS_AID_OTHER_PROFILE and PICS_CERTIFICATE_SELECTION' required for executing the TC ***");
//                    stop;
//                }
//                
//                // Test component configuration
//                // CERT_IUT_A is the default one
//                f_cf01Up();
//                v_longPosVectorIut := f_getPosition(c_compIut);
//                
//                // Test adapter configuration
//                
//                // Preamble
//                f_prNeighbour();
//                f_acTriggerEvent(m_startPassBeaconing(m_beaconHeader(v_longPosVectorIut).beaconHeader)); // Authorize the TA to forward the received beacons
//                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);    
//                
//                // Test Body
//                tc_ac.start;
//                alt {
//                    [] geoNetworkingPort.receive(
//                        mw_geoNwInd(mw_geoNwSecPdu(
//                            mw_ieee1609Dot2Data_Others(
//                                mw_header_info_signer_info_certificate(
//                                    mw_certificate(
//                                        ?,
//                                        ?,
//                                        ?,
//                                        superset(
//                                            mw_validity_restriction_any_valid_region
//                    ))))))) {
//                        log("*** " & testcasename() & ": INFO: Skip DENM containing region restrictions ***");
//                        repeat;
//                    }
//                    [] geoNetworkingPort.receive(
//                        mw_geoNwInd(
//                            mw_geoNwSecPdu(
//                                mw_securedMessage(
//                                    superset(
//                                        mw_header_field(
//                                            e_generation_location
//                                        ),
//                                        mw_header_info_signer_info_certificate,
//                                        complement(
//                                            mw_header_info_its_aid_CAM,
//                                            mw_header_info_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(
//                                mw_ieee1609Dot2Data_Others(
//                                    mw_header_info_signer_info_certificate
//                    )))) {
//                        // The message does not contain generation location 
//                        tc_ac.stop;
//                        log("*** " & testcasename() & ": PASS: DENM contains generation location ***");
//                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
//                    }
//                    [] tc_ac.timeout {
//                        log("*** " & testcasename() & ": INCONC: Expected DENM not received ***");
//                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
//                    }
//                } // End of 'alt' statement
//                
//                // Postamble
//                f_acTriggerEvent(m_stopPassBeaconing);
//                f_poNeighbour();
//                f_cf01Down();
//            } // End of testcase TC_SEC_ITSS_SND_GENMSG_05_01_BV
//            
//            /**
//             * @desc   Check that the secured GN Beacon contains exactly one HeaderInfo generation_location 
//             *         which is inside the circular region containing in the validity restriction of the 
//             *         certificate pointed by the signer_info field     
//             * <pre>
//             * Pics Selection: PICS_GN_SECURITY and PICS_ITS_AID_OTHER_PROFILE and PICS_CERTIFICATE_SELECTION and PICS_USE_CIRCULAR_REGION
//             * Config Id: CF01
//             * with {
//             *   the IUT has been authorized with the AT certificate (CERT_IUT_B)
//             *       containing validity_restrictions['region']
//             *           containing region
//             *               containing region_type
//             *                   indicating 'circle'
//             *               and containing circular_region
//             *                   indicating REGION
//             * }
//             * ensure that {
//             *   when {
//             *     the IUT is requested to send a GN Beacon
//             *   } then {
//             *     the IUT sends a Ieee1609Dot2Data 
//             *         containing exactly one header_fields['generation_location']
//             *             containing generation_location
//             *                 indicating value inside the REGION
//             *   }
//             * }
//             * </pre>
garciay's avatar
garciay committed
//             * @see          ETSI TS 103 096-2 v1.3.2 TP_SEC_ITSS_SND_GENMSG_05_02_BV
//             * @reference    ETSI TS 103 097 [1], clause 7.3
//             */
//            testcase TC_SEC_ITSS_SND_GENMSG_05_02_BV() runs on ItsGeoNetworking system ItsSecSystem {
//                
//                // Local variables
//                var LongPosVector   v_longPosVectorIut;
//                
//                // Test control
//                if (not(PICS_GN_SECURITY) or not(PICS_ITS_AID_OTHER_PROFILE) or not(PICS_CERTIFICATE_SELECTION) or not(PICS_USE_CIRCULAR_REGION)) {
//                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY and PICS_ITS_AID_OTHER_PROFILE and PICS_USE_CIRCULAR_REGION' required for executing the TC ***");
//                    stop;
//                }
//                
//                // Test component configuration
//                vc_hashedId8ToBeUsed := cc_iutCert_B; 
//                f_cf01Up();
//                v_longPosVectorIut := f_getPosition(c_compIut);
//                
//                // Test adapter configuration
//                
//                // Preamble
//                f_prNeighbour();
//                f_acTriggerEvent(m_startPassBeaconing(m_beaconHeader(v_longPosVectorIut).beaconHeader)); // Authorize the TA to forward the received beacons
//                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);    
//                
//                // Test Body
//                f_TC_SEC_ITSS_SND_GENMSG_05_BV(mw_geographicRegion_circle);
//                
//                // Postamble
//                f_acTriggerEvent(m_stopPassBeaconing);
//                f_poNeighbour();
//                f_cf01Down();
//            } // End of testcase TC_SEC_ITSS_SND_GENMSG_05_02_BV
//            
//            /**
//             * @desc   Check that the secured GN Beacon contains exactly one HeaderInfo generation_location 
//             *         which is inside the rectangular region containing in the validity restriction 
//             *         of the certificate pointed by the signer_info field     
//             * <pre>
//             * Pics Selection: PICS_GN_SECURITY and PICS_ITS_AID_OTHER_PROFILE and PICS_CERTIFICATE_SELECTION and PICS_USE_RECTANGULAR_REGION
//             * Config Id: CF01
//             * with {
//             *   the IUT has been authorized with the AT certificate (CERT_IUT_C)
//             *       containing validity_restrictions ['region']
//             *           containing region
//             *               containing region_type
//             *                   indicating 'rectangle'
//             *               containing rectangular_region
//             *                   indicating REGION
//             * }
//             * ensure that {
//             *   when {
//             *       the IUT is requested to send a DENM
//             *   } then {
//             *       the IUT sends a Ieee1609Dot2Data
//             *           containing exactly one header_fields ['generation_location']
//             *               containing generation_location
//             *                   containing instance of RectangularRegion
//             *                       indicating value inside the REGION
//             *   }
//             * }
//             * </pre>
garciay's avatar
garciay committed
//             * @see          ETSI TS 103 096-2 v1.3.2 TP_SEC_ITSS_SND_GENMSG_05_03_BV
//             * @reference    ETSI TS 103 097 [1], clause 7.3
//             */
//            testcase TC_SEC_ITSS_SND_GENMSG_05_03_BV() runs on ItsGeoNetworking system ItsSecSystem {
//                
//                // Local variables
//                var LongPosVector   v_longPosVectorIut;
//                
//                // Test adapter configuration
//                if (not(PICS_GN_SECURITY) or not(PICS_ITS_AID_OTHER_PROFILE) or not(PICS_CERTIFICATE_SELECTION) or not(PICS_USE_RECTANGULAR_REGION)) {
//                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY and PICS_ITS_AID_OTHER_PROFILE and PICS_USE_RECTANGULAR_REGION' required for executing the TC ***");
//                    stop;
//                }
//                
//                // Test component configuration
//                vc_hashedId8ToBeUsed := cc_iutCert_C; // Load IUT certificate CERT_IUT_C 
//                f_cf01Up();
//                v_longPosVectorIut := f_getPosition(c_compIut);
//                
//                // Test adapter configuration
//                
//                // Preamble
//                f_prNeighbour();
//                f_acTriggerEvent(m_startPassBeaconing(m_beaconHeader(v_longPosVectorIut).beaconHeader)); // Authorize the TA to forward the received beacons
//                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);    
//                
//                // Test Body
//                f_TC_SEC_ITSS_SND_GENMSG_05_BV(mw_geographicRegion_rectangular);
//                
//                // Postamble
//                f_acTriggerEvent(m_stopPassBeaconing);
//                f_poNeighbour();
//                f_cf01Down();
//            } // End of testcase TC_SEC_ITSS_SND_GENMSG_05_03_BV
//            
//            /**
//             * @desc   Check that the secured GN Message contains exactly one HeaderInfo generation_location 
//             *         which is inside the polygonal region containing in the validity restriction 
//             *         of the certificate pointed by the signer_info field     
//             * <pre>
//             * Pics Selection: PICS_GN_SECURITY and PICS_ITS_AID_OTHER_PROFILE and PICS_CERTIFICATE_SELECTION and PICS_USE_POLYGONAL_REGION
//             * Config Id: CF01
//             * with {
//             *   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 Ieee1609Dot2Data
//             *       containing exactly one header_fields ['generation_location']
//             *         containing generation_location
//             *           indicating value inside the REGION
//             *   }
//             * }
//             * </pre>
garciay's avatar
garciay committed
//             * @see          ETSI TS 103 096-2 v1.3.2 TP_SEC_ITSS_SND_GENMSG_05_04_BV
//             * @reference    ETSI TS 103 097 [1], clause 7.3
//             */
//            testcase TC_SEC_ITSS_SND_GENMSG_05_04_BV() runs on ItsGeoNetworking system ItsSecSystem {
//                
//                // Local variables
//                var LongPosVector   v_longPosVectorIut;
//                
//                // Test adapter configuration
//                if (not(PICS_GN_SECURITY) or not(PICS_ITS_AID_OTHER_PROFILE) or not(PICS_CERTIFICATE_SELECTION) or not(PICS_USE_POLYGONAL_REGION)) {
//                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY and PICS_ITS_AID_OTHER_PROFILE and PICS_USE_POLYGONAL_REGION' required for executing the TC ***");
//                    stop;
//                }
//                
//                // Test component configuration
//                vc_hashedId8ToBeUsed := cc_iutCert_D; // Load IUT certificate CERT_IUT_D 
//                f_cf01Up();
//                v_longPosVectorIut := f_getPosition(c_compIut);
//                
//                // Test adapter configuration
//                
//                // Preamble
//                f_prNeighbour();
//                f_acTriggerEvent(m_startPassBeaconing(m_beaconHeader(v_longPosVectorIut).beaconHeader)); // Authorize the TA to forward the received beacons
//                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);    
//                
//                // Test Body
//                f_TC_SEC_ITSS_SND_GENMSG_05_BV(mw_geographicRegion_polygonal);
//                
//                // Postamble
//                f_acTriggerEvent(m_stopPassBeaconing);
//                f_poNeighbour();
//                f_cf01Down();
//            } // End of testcase TC_SEC_ITSS_SND_GENMSG_05_04_BV
//            
//            /**
//             * @desc   Check that the secured GN Message contains exactly one HeaderInfo generation_location 
//             *         which is inside the identified region containing in the validity restriction 
//             *         of the certificate pointed by the signer_info field
//             * <pre>
//             * Pics Selection: PICS_GN_SECURITY and PICS_ITS_AID_OTHER_PROFILE and PICS_USE_IDENTIFIED_REGION and PICS_CERTIFICATE_SELECTION
//             * Config Id: CF01
//             * with {
//             *   the IUT has been authorized with the AT certificate (CERT_IUT_E) 
//             *       containing validity_restrictions ['region'] 
//             *           containing region
//             *               containing region_type
//             *                   indicating 'id_region'
//             *               containing identified_region
//             *                   indicating REGION
//             * }
//             * ensure that {
//             *   when {
//             *     the IUT is requested to send a Beacon
//             *   } then {
//             *     the IUT sends a Ieee1609Dot2Data
//             *       containing exactly one header_fields ['generation_location']
//             *         containing generation_location
//             *           indicating value inside the REGION
//             *   }
//             * }
//             * </pre>
garciay's avatar
garciay committed
//             * @see          ETSI TS 103 096-2 v1.3.2 TP_SEC_ITSS_SND_GENMSG_05_05_BV
//             * @reference    ETSI TS 103 097 [1], clause 7.3
//             */
//            testcase TC_SEC_ITSS_SND_GENMSG_05_05_BV() runs on ItsGeoNetworking system ItsSecSystem {
//                // Local variables
//                var LongPosVector   v_longPosVectorIut;
//                
//                // Test adapter configuration
//                if (not(PICS_GN_SECURITY) or not(PICS_ITS_AID_OTHER_PROFILE) or not(PICS_CERTIFICATE_SELECTION) or not(PICS_USE_IDENTIFIED_REGION)) {
//                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY and PICS_ITS_AID_OTHER_PROFILE and PICS_USE_IDENTIFIED_REGION' required for executing the TC ***");
//                    stop;
//                }
//                
//                // Test component configuration
//                vc_hashedId8ToBeUsed := cc_iutCert_E; // Load IUT certificate CERT_IUT_E 
//                f_cf01Up();
//                v_longPosVectorIut := f_getPosition(c_compIut);
//                
//                // Test adapter configuration
//                
//                // Preamble
//                f_prNeighbour();
//                f_acTriggerEvent(m_startPassBeaconing(m_beaconHeader(v_longPosVectorIut).beaconHeader)); // Authorize the TA to forward the received beacons
//                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);    
//                
//                // Test Body
//                f_TC_SEC_ITSS_SND_GENMSG_05_BV(mw_geographicRegion_identified);
//                
//                // Postamble
//                f_acTriggerEvent(m_stopPassBeaconing);
//                f_poNeighbour();
//                f_cf01Down();
//            } // End of testcase TC_SEC_ITSS_SND_GENMSG_05_05_BV
//            
//            /**
//             * @desc   Check that the secured GN Message contains exactly one HeaderInfo generation_location 
//             *         which is inside the  certificate pointed by the signer_info field
//             * <pre>
//             * Pics Selection: PICS_GN_SECURITY and PICS_ITS_AID_OTHER_PROFILE and not PICS_CERTIFICATE_SELECTION
//             * Config Id: CF01
//             * with {
//             *   the IUT being in the 'authorized' state
//             * }
//             * ensure that {
//             *   when {
//             *     the IUT is requested to send a Beacon
//             *   } then {
//             *     the IUT sends a Ieee1609Dot2Data
//             *       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
//             *       and containing exactly one header_fields['generation_location']
//             *         containing generation_location
//             *           indicating location inside the REGION
//             *   }
//             * }
//             * </pre>
garciay's avatar
garciay committed
//             * @see          ETSI TS 103 096-2 v1.3.2 TP_SEC_ITSS_SND_GENMSG_05_06_BV
//             * @reference    ETSI TS 103 097 [1], clause 7.3
//             */
//            testcase TC_SEC_ITSS_SND_GENMSG_05_06_BV() runs on ItsGeoNetworking system ItsSecSystem {
//                // Local variables
//                var LongPosVector   v_longPosVectorIut;
//                
//                // Test adapter configuration
//                if (not(PICS_GN_SECURITY) or not(PICS_ITS_AID_OTHER_PROFILE) or PICS_CERTIFICATE_SELECTION) {
//                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY and PICS_ITS_AID_OTHER_PROFILE and not PICS_CERTIFICATE_SELECTION' required for executing the TC ***");
//                    stop;
//                }
//                
//                // Test component configuration
//                vc_hashedId8ToBeUsed := cc_iutCert_B; // Load IUT certificate CERT_IUT_B 
//                f_cf01Up();
//                v_longPosVectorIut := f_getPosition(c_compIut);
//                
//                // Test adapter configuration
//                
//                // Preamble
//                f_prNeighbour();
//                f_acTriggerEvent(m_startPassBeaconing(m_beaconHeader(v_longPosVectorIut).beaconHeader)); // Authorize the TA to forward the received beacons
//                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);    
//                
//                // Test Body
//                f_TC_SEC_ITSS_SND_GENMSG_05_BV(); // any type of regions
//                
//                // Postamble
//                f_acTriggerEvent(m_stopPassBeaconing);
//                f_poNeighbour();
//                f_cf01Down();
//            } // End of testcase TC_SEC_ITSS_SND_GENMSG_05_06_BV
//            
//            group f_TC_SEC_ITSS_SND_GENMSG_05_xx {
//                
//                function f_TC_SEC_ITSS_SND_GENMSG_05_BV(
//                                                        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(
//                                    mw_securedMessage(
//                                        superset(
//                                            mw_header_field(e_generation_location),
//                                            mw_header_info_signer_info_certificate(
//                                                mw_certificate(
//                                                    ?,
//                                                    ?,
//                                                    ?, 
//                                                    superset(
//                                                        mw_validity_restriction_region(
//                                                            p_region
//                        ))))))))) -> value v_geoNwInd {
//                            var ValidityRestriction v_vr;
//                            var HeaderInfo         v_hf;
//                            
//                            tc_ac.stop;
//                            // Check that generation location 
//                            if (
//                                f_getMsgHeaderField(v_geoNwInd.msgIn.gnPacket.securedMsg, e_generation_location, v_hf) and 
//                                f_getCertificateValidityRestriction(v_geoNwInd.msgIn.gnPacket.securedMsg.header_fields[0].headerField.signer.signerInfo.certificate, e_region, v_vr)
//                            ) {
//                                if (f_isLocationInsideRegion(v_vr.validity.region, v_hf.headerField.generation_location)) {
//                                    log("*** " & testcasename() & ": PASS: DENM contains generation location inside the certificate validity region ***");
//                                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
//                                } else {
//                                    log("v_vr.validity.region=", v_vr.validity.region);
//                                    log("v_hf.headerField.generation_location=", v_hf.headerField.generation_location);
//                                    log("*** " & testcasename() & ": FAIL: Invalid location");
//                                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
//                                }
//                            } else {
//                                log("*** " & testcasename() & ": FAIL: IMPOSSIBLE!!! DENM generation location or certificate region restriction header field does not exist");
//                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
//                            }
//                        }
//                        // GN message doesn't contain generation location 
//                        [] geoNetworkingPort.receive(
//                            mw_geoNwInd(
//                                mw_geoNwSecPdu(
//                                    mw_ieee1609Dot2Data_Others
//                        ))) -> value v_geoNwInd {
//                            var HeaderInfo 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(
//                                    mw_ieee1609Dot2Data_Others(
//                                        mw_header_info_signer_info_certificate(
//                                            mw_certificate(
//                                                ?,
//                                                ?,
//                                                ?, 
//                                                { } // GN signing certificate doesn't contains region restriction
//                        )))))) {
//                            tc_ac.stop;
//                            log("*** " & testcasename() & ": INCONC: DENM certificate doesn't contain region restriction");
//                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
//                        }
//                        [] tc_ac.timeout {
//                            log("*** " & testcasename() & ": INCONC: Expected DENM not received ***");
//                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
//                        }
//                    } // End of 'alt' statement
//                } // End of function f_TC_SEC_ITSS_SND_GENMSG_05_BV 
//                
//            } // End of group f_TC_SEC_ITSS_SND_GENMSG_05_xx
//            
//            /**
//             * @desc        Check that the secured message contains of type signed, signed_external or signed_and_encrypted 
//             * <pre>
//             * Pics Selection: PICS_GN_SECURITY and PICS_ITS_AID_OTHER_PROFILE
//             * Config Id: CF01
//             * Initial conditions:
//             * with {
//             *     the IUT being in the 'authorized' state
//             * }
//             * Expected results:
//             * ensure that {
//             *     when {
//             *         the IUT is requested to send a Beacon
//             *     } then {
//             *         the IUT sends a Ieee1609Dot2Data {
//             *             containing payload_fields
//             *                 containing exactly one element of type Payload
//             *                     containing type
//             *                         indicating 'signed' or 'signed_external' or 'signed_and_encrypted'
//             * }
//             * </pre>
garciay's avatar
garciay committed
//             * @see          ETSI TS 103 096-2 v1.3.2 TP_SEC_ITSS_SND_GENMSG_06_01_BV
//             * @reference    ETSI TS 103 097 [1], clause 7.3
//             */
//            testcase TC_SEC_ITSS_SND_GENMSG_06_01_BV() runs on ItsGeoNetworking system ItsSecSystem {
//                
//                // Local variables
//                var LongPosVector v_longPosVectorIut;
//                
//                // Test adapter configuration
//                if (not(PICS_GN_SECURITY) or not(PICS_ITS_AID_OTHER_PROFILE)) {
//                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY and PICS_ITS_AID_OTHER_PROFILE' required for executing the TC ***");
//                    stop;
//                }
//                
//                // Test component configuration
//                f_cf01Up();
//                v_longPosVectorIut := f_getPosition(c_compIut);
//                
//                // Test adapter configuration
//                
//                // Preamble
//                f_prNeighbour();
//                f_acTriggerEvent(m_startPassBeaconing(m_beaconHeader(v_longPosVectorIut).beaconHeader)); // Authorize the TA to forward the received beacons
//                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
//                
//                // Test Body
//                tc_ac.start;
//                alt {
//                    [] geoNetworkingPort.receive(
//                        mw_geoNwInd(
//                            mw_geoNwSecPdu(
//                                mw_ieee1609Dot2Data_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(
//                                mw_ieee1609Dot2Data_Others(
//                                    ?, 
//                                    mw_payload(
//                                        e_signed_external
//                                    ) 
//                                ),
//                                mw_geoNwBeaconPacket(
//                                    ?
//                    )))) { 
//                        log("*** " & testcasename() & ": PASS: Beacon payload is 'e_signed_external'");
//                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
//                    }
//                    [] geoNetworkingPort.receive(
//                        mw_geoNwInd(
//                            mw_geoNwSecPdu(
//                                mw_ieee1609Dot2Data_Others(
//                                    ?, 
//                                    mw_payload(
//                                        e_signed_and_encrypted
//                                    ) 
//                                ),
//                                mw_geoNwBeaconPacket(
//                                    ?
//                    )))) { 
//                        log("*** " & testcasename() & ": PASS: Beacon payload is 'e_signed_and_encrypted'");
//                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
//                    }
//                    [] geoNetworkingPort.receive(
//                        mw_geoNwInd(
//                            mw_geoNwSecPdu(
//                                mw_ieee1609Dot2Data_Others(
//                                    ?, 
//                                    mw_payload
//                                ),
//                                mw_geoNwBeaconPacket(
//                                    ?
//                    )))) { 
//                        log("*** " & testcasename() & ": FAIL: Beacon payload is not signed, signed_external or signed_and_encrypted");
//                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
//                    }
//                    [] tc_ac.timeout {
//                        log("*** " & testcasename() & ": INCONC: Expected Message not received ***");
//                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
//                    }
//                } // End of 'alt' statement
//                
//                // Postamble
//                f_acTriggerEvent(m_stopPassBeaconing);
//                f_poNeighbour();
//                f_cf01Down();
//            } // End of testcase TC_SEC_ITSS_SND_GENMSG_06_01_BV
//            
//            /**
//             * @desc   Check that the secured GN Message contains only one TrailerField of type signature ;
//             *         Check that the signature contained in the Ieee1609Dot2Data is calculated over the right fields by 
//             *         cryptographically verifying the signature 
//             * <pre>
//             * Pics Selection: PICS_GN_SECURITY and PICS_ITS_AID_OTHER_PROFILE
//             * Config Id: CF01
//             * Initial conditions:
//             * with {
//             *   the IUT being in the 'authorized' state
//             * }
//             * ensure that {
//             *   when {
//             *     the IUT is requested to send Beacon
//             *   } then {
//             *     the IUT sends a Ieee1609Dot2Data
//             *         containing header_fields ['signer_info']
//             *             containing signer
//             *                 containing type
garciay's avatar
garciay committed
//             *                     containing certificate
//             *             and containing certificate
//             *                 indicating CERT
//             *         and containing trailer_fields['signature']
//             *             containing signature
//             *                 verifiable using CERT.subject_attributes['verification_key'] 
//             *   }
//             * }
//             * </pre>
garciay's avatar
garciay committed
//             * @see          ETSI TS 103 096-2 v1.3.2 TP_SEC_ITSS_SND_GENMSG_07_01_BV
//             * @reference    ETSI TS 103 097 [1], clause 7.3
//             */
//            testcase TC_SEC_ITSS_SND_GENMSG_07_01_BV() runs on ItsGeoNetworking system ItsSecSystem {
//                
//                //  Local variables
//                var LongPosVector v_longPosVectorIut;
//                var GeoNetworkingInd v_geoNwInd;
//                var SignerInfo v_signerInfo;
//                
//                // Test adapter configuration
//                if (not(PICS_GN_SECURITY) or not(PICS_ITS_AID_OTHER_PROFILE)) {
//                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY and PICS_ITS_AID_OTHER_PROFILE' required for executing the TC ***");
//                    stop;
//                }
//                
//                // Test component configuration
//                f_cf01Up();
//                v_longPosVectorIut := f_getPosition(c_compIut);
//                
//                // Test adapter configuration
//                
//                // Preamble
//                f_prNeighbour();
//                f_acTriggerEvent(m_startPassBeaconing(m_beaconHeader(v_longPosVectorIut).beaconHeader)); // Authorize the TA to forward the received beacons
//                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
//                    
//                // Test Body
//                tc_ac.start;
//                alt {
//                    [] geoNetworkingPort.receive(
//                        mw_geoNwInd(
//                            mw_geoNwSecPdu(
//                                mw_ieee1609Dot2Data_Others(
//                                    mw_header_info_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(
//                                mw_ieee1609Dot2Data_Others
//                    ))) { 
//                        tc_ac.stop;
//                        log("*** " & testcasename() & ": FAIL: Beacon message without certificate received");
//                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
//                    }
//                    [] tc_ac.timeout {
//                        log("*** " & testcasename() & ": INCONC: Expected GN Message not received");
//                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
//                    }
//                } // End of 'alt' statement
//                log("*** " & testcasename() & ": PASS: GN Message received with correct signature");
//                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
//                
//                // Postamble
//                f_acTriggerEvent(m_stopPassBeaconing);
//                f_poNeighbour();
//                f_cf01Down();
//            } // End of testcase TC_SEC_ITSS_SND_DENM_07_01_BV
//            
//        } // End of group sendOtherProfile
         * @desc Sending behaviour test cases for certificates profile
         * @see ETSI TS 103 096-2 V1.2.2 (2016-01) Clause 5.2.7 Profiles for certificates
//        group sendCertificatesProfile {
//            
//            /**
//             * @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 Ieee1609Dot2Data
//             *         containing header_fields['signer_info'].signer
//             *             containing type
//             *                 indicating certificate
//             *             containing certificate
//             *                 containing version
//             *                     indicating '2'
//             *   }
//             * }
//             * </pre>
garciay's avatar
garciay committed
//             * @see         ETSI TS 103 096-2 v1.3.2 TP_SEC_ITSS_SND_CERT_01_01_BV
//             * @reference   ETSI TS 103 097 [1], clauses 6.1 and 7.4.1
//             */
//            testcase TC_SEC_ITSS_SND_CERT_01_01_BV() runs on ItsGeoNetworking system ItsSecSystem {
//                // Local variables
//                
//                // Test control
//                if (not(PICS_GN_SECURITY)) {
//                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY' required for executing the TC ***");
//                    stop;
//                }
//                
//                // Test component configuration
//                f_cf01Up();
//                    
//                // Test adapter configuration
//                    
//                // Preamble
//                f_prNeighbour();
//                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
//                
//                // Test Body
//                tc_ac.start;
//                alt {
//                    [] geoNetworkingPort.receive(
//                        mw_geoNwInd(
//                            mw_geoNwSecPdu(
//                                mw_securedMessage(
//                                    superset(
//                                        mw_header_info_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(
//                                mw_securedMessage(
//                                    superset(
//                                        mw_header_info_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_ITSS_SND_CERT_01_01_BV
//            
//            /**
//             * @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 Ieee1609Dot2Data
//             *         containing header_fields['signer_info'].signer
//             *             containing type
//             *                 indicating 'certificate_chain'
//             *             and containing certificates
//             *                 indicating length > 0
//             *                 and containing certificates[n] (0..N)
//             *                     containing version
//             *                         indicating '2'
//             *   }
//             * }
//             * </pre>
garciay's avatar
garciay committed
//             * @see         ETSI TS 103 096-2 v1.3.2 TP_SEC_ITSS_SND_CERT_01_02_BV
//             * @reference   ETSI TS 103 097 [1], clauses 6.1 and 7.4.1
//             */
//            testcase TC_SEC_ITSS_SND_CERT_01_02_BV() runs on ItsGeoNetworking system ItsSecSystem {
//                // Local variables
//                var Ieee1609Dot2Data 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();
//                
//                // 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;