ItsSecurity_TestCases.ttcn 1.59 MB
Newer Older
garciay's avatar
garciay committed
                    }
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: Expected DEN message not received ***");
garciay's avatar
garciay committed
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                    } 
                } // End of 'alt' statement
                
                // Postamble
                f_cancelDenmEvent(v_denmComponent);
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_ITSS_SND_DENM_03_BV
            
            /**
             * @desc Check that IUT sends the secured DENM containing signer containing certificate.
             * <pre>
             * Pics Selection: PICS_GN_SECURITY
             * Config Id: CF01
             * Initial conditions:
             *  with {
             *     the IUT is authorized with AT certificate (CERT_IUT_A_AT) 
             * }
             * ensure that {
             *     when {
             *         the IUT is requested to send a secured DENM
             *     } then {
             *         the IUT sends a Ieee1609Dot2Data
             *             containing content
             *                 containing signedData
             *                     containing signer
             *                         containing certificate
             *                             containing toBeSigned
             *                                 containing appPermissions
             *                                     containing the item of type PsidSsp
             *                                         containing psid
             *                                             indicating AID_DENM
             * </pre>
             *
             * @see         ETSI TS 103 096-2 v1.3.2 TP_SEC_ITSS_SND_DENM_04_BV
             * @reference    ETSI TS 103 097 [1] Clauses 5.2 & 7.1.2
             * @reference    IEEE 1609.2 [2] Clause 6.3.4
garciay's avatar
garciay committed
             */
            testcase TC_SEC_ITSS_SND_DENM_04_BV() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var ItsDenm v_denmComponent;
                
                // Test control
                if (not(PICS_GN_SECURITY)) {
                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY' required for executing the TC ***");
                    stop;
                }
                
                // Test component configuration
                f_cf01Up(); // Initialise IUT with CERT_IUT_A_AT signed with CERT_IUT_A_AA
                
                // Test adapter configuration
                
                // Preamble
                f_prNeighbour();
                v_denmComponent := f_triggerDenmEvent();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
                tc_ac.start;
                alt {
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mw_etsiTs103097Data_signed(
                                    mw_signedData(
                                        -, 
                                        mw_toBeSignedData(
                                            mw_signedDataPayload,
                                            mw_headerInfo_denm
                                        ),
                                        mw_signerIdentifier_certificate( // or containing certificate
                                            mw_etsiTs103097Certificate(
                                                -,
                                                mw_toBeSignedCertificate_at(
                                                    { mw_appPermissions(c_its_aid_DENM) }
                                                )
                                            )
                                        )
garciay's avatar
garciay committed
                                    )
                                ), 
                                mw_geoNwShbPacket
                    ))) {
                        tc_ac.stop;                        
                        log("*** " & testcasename() & ": PASS: Correct secured packet received, containing certificate");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                    }
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mw_etsiTs103097Data_signed(
                                    mw_signedData(
                                        -, 
                                        mw_toBeSignedData(
                                            mw_signedDataPayload,
                                            mw_headerInfo_denm
                                        ),
                                        mw_signerIdentifier_digest // containing digest
                                    )
                                ), 
                                mw_geoNwBroadcastPacket
garciay's avatar
garciay committed
                    ))) {
                        tc_ac.stop;                        
                        log("*** " & testcasename() & ": FAIL: Incorrect secured packet received, containing digest");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                    }
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: Expected DEN message not received ***");
garciay's avatar
garciay committed
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                    } 
                } // End of 'alt' statement
                
                // Postamble
                f_cancelDenmEvent(v_denmComponent);
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_ITSS_SND_DENM_04_BV
            
            /**
             * @desc   Check that IUT sends the secured DENM containing generation time 
             *         and this time is inside the validity period of the signing certificate;
             *         Check that message generation time value is realistic.
 
             * <pre>
             * Pics Selection: PICS_GN_SECURITY
             * Config Id: CF01
             * Initial conditions:
             * with {
             *   the IUT is authorized with AT certificate (CERT_IUT_A_AT) 
             * }
             * ensure that {
             *   when {
             *       the IUT is requested to send a DENM
             *   } then {
             *       the IUT sends a SecuredMessage of type EtsiTs103097Data
             *           containing headerInfo
             *               containing generationTime
             *                   indicating TIME_1 (CUR_TIME - 10min <= TIME_1 <= CUR_TIME + 10min)
             *           and containing signer
             *               containing certificate
             *                   containing toBeSigned
             *                       containing validityPeriod
             *                           containing start
             *                               indicating value X_START_VALIDITY (X_START_VALIDITY <= GEN_TIME)
             *                           and containing duration
             *                               indicating value > GEN_TIME - X_START_VALIDITY 
             *   }
             * }
             * </pre>
             * @see         ETSI TS 103 096-2 v1.3.2 TP_SEC_ITSS_SND_DENM_05_BV
             * @reference   ETSI TS 103 097 [1] Clauses 7.1.2
             * @reference   IEEE 1609.2 [2], Clauses 5.2.3.2.2, 5.2.4.2.2, 5.2.4.2.3  
garciay's avatar
garciay committed
             */
            testcase TC_SEC_ITSS_SND_DENM_05_BV() runs on ItsGeoNetworking system ItsSecSystem {
                // Local variables
                const integer        c_timeLimit := 10 * 60 * 1000000; // us
                var GeoNetworkingInd v_geoNwInd;
                var HeaderInfo       v_headerInfo;
                var Time64           v_generationTime;
                var Time64           v_curTime;
                var SignerIdentifier v_signerIdentifier;
                var ValidityPeriod   v_validityPeriod;
                var Certificate      v_cert;
                var ItsDenm          v_denmComponent;
                
                // Test control
                if (not(PICS_GN_SECURITY)) {
                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY' required for executing the TC ***");
                    stop;
                }
                
                // Test component configuration
                f_cf01Up(); // Initialise IUT with CERT_IUT_A_AT signed with CERT_IUT_A_AA
                
                // Test adapter configuration
                
                // Preamble
                f_prNeighbour();
                v_denmComponent := f_triggerDenmEvent();
                tc_ac.start;
                alt {
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mw_etsiTs103097Data_signed(
                                    mw_signedData(
                                        -, 
                                        mw_toBeSignedData(
                                            mw_signedDataPayload,
                                            mw_headerInfo_denm
                                        ),
                                        mw_signerIdentifier_certificate // containing certificate
                                    )
                                ), 
                                mw_geoNwBroadcastPacket
garciay's avatar
garciay committed
                    ))) {
                        tc_ac.stop;
                        log("*** " & testcasename() & ": INFO: Initial conditions: First DEN message with certificate received ***");
garciay's avatar
garciay committed
                        f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                    }
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mw_etsiTs103097Data_signed(
                                    mw_signedData(
                                        -, 
                                        mw_toBeSignedData(
                                            mw_signedDataPayload,
                                            mw_headerInfo_denm
                                        ),
                                        mw_signerIdentifier_digest
                                    )
                                ), 
                                mw_geoNwBroadcastPacket
garciay's avatar
garciay committed
                    ))) {
                        tc_ac.stop;                        
                        log("*** " & testcasename() & ": FAIL: DEN message retransmission with digest ***"); 
garciay's avatar
garciay committed
                        f_selfOrClientSyncAndVerdictTestBody(c_prDone, e_error);
                        //repeat;
                    }
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: Initial conditions: DEN message with certificate not received ***");
garciay's avatar
garciay committed
                        f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_timeout);
                    }
                } // End of 'alt' statement
                
                // Test Body
                tc_ac.start;
                alt {
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mw_etsiTs103097Data_signed(
                                    mw_signedData(
                                        -, 
                                        mw_toBeSignedData(
                                            mw_signedDataPayload,
                                            mw_headerInfo_denm
                                        ),
                                        mw_signerIdentifier_certificate // containing certificate
                                    )
                                ), 
                                mw_geoNwBroadcastPacket
garciay's avatar
garciay committed
                    ))) -> value v_geoNwInd {
                        tc_ac.stop;
                        f_getMsgHeaderInfo(f_getSecuredMessage(v_geoNwInd.msgIn), v_headerInfo);
                        v_generationTime := v_headerInfo.generationTime;
                        v_curTime := f_getCurrentTime();
                        v_curTime := v_curTime * 1000; // Time64 is in microseconds 
                        log("v_curTime (us)=", v_curTime);
                        // Check generation time
                        if (not match(v_generationTime, Time64:(v_curTime - c_timeLimit, v_curTime + c_timeLimit))) {
                            log("*** " & testcasename() & ": FAIL: DEN message generation time is not in 5 min range");
garciay's avatar
garciay committed
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                        } else {
                            // Check certificate validity period
                            f_getMsgSignerIdentifier (f_getSecuredMessage(v_geoNwInd.msgIn), v_signerIdentifier);
                            if (not match(v_signerIdentifier.certificate[0].toBeSigned.validityPeriod.start_, Time32:(v_curTime - c_timeLimit, v_curTime + c_timeLimit))) {
                                log("*** " & testcasename() & ": FAIL: DEN message certificate validity period is not in 5 min range");
garciay's avatar
garciay committed
                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                            } else {
                                log("*** " & testcasename() & ": PASS: Generation of DENM messages including certificate was successful ***");
                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                            }
                        }
                    }
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mw_etsiTs103097Data_signed(
                                    mw_signedData(
                                        -, 
                                        mw_toBeSignedData(
                                            mw_signedDataPayload,
                                            mw_headerInfo_denm
                                        ),
                                        mw_signerIdentifier_digest
                                    )
                                ), 
                                mw_geoNwBroadcastPacket
garciay's avatar
garciay committed
                    ))) {
                        tc_ac.stop;                        
                        log("*** " & testcasename() & ": FAIL: DEN message retransmission with digest ***"); 
garciay's avatar
garciay committed
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                        //repeat;
                    }
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: Expected DEN message not received ***");
garciay's avatar
garciay committed
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                    }
                } // End of 'alt' statement
                
                // Postamble
                f_cancelDenmEvent(v_denmComponent);
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_ITSS_SND_DENM_05_BV
            
            /**
             * @desc   Check that IUT sends the secured DENM containing generation location when signing certificate 
             *         chain doesn't have any region restriction.
garciay's avatar
garciay committed
             * <pre>
             * Pics Selection: PICS_GN_SECURITY
             * Config Id: CF01
             * Initial conditions:
             * with {
             *   the IUT is authorized with AT certificate (CERT_IUT_A_AT) 
             *       containing toBeSigned
             *           not containing region
             *       and issuied by the certificate AA (CERT_IUT_A_AA)
             *           containing toBeSigned
             *               not containing region
             *       and issuied by the certificate RCA (CERT_IUT_A_RCA)
             *           containing toBeSigned
             *               not containing region
             * }
             * ensure that {
             *   when {
             *       the IUT is requested to send a DENM
             *   } then {
             *       the IUT sends a SecuredMessage of type EtsiTs103097Data
             *           containing headerInfo
             *               containing generationLocation 
garciay's avatar
garciay committed
             *   }
             * }
             * </pre>
             * @see         ETSI TS 103 096-2 v1.3.2 TP_SEC_ITSS_SND_DENM_06_BV
             * @reference   ETSI TS 103 097 [1] Clauses 7.1.2
             * @reference   IEEE 1609.2 [2], Clauses 5.2.3.2.2  
garciay's avatar
garciay committed
             */
            testcase TC_SEC_ITSS_SND_DENM_06_BV() runs on ItsGeoNetworking system ItsSecSystem {
                // Local variables
                var GeoNetworkingInd v_geoNwInd;
                var HeaderInfo       v_headerInfo;
                var ItsDenm          v_denmComponent;
                
                // Test control
                if (not(PICS_GN_SECURITY)) {
                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY' required for executing the TC ***");
                    stop;
                }
                
                // Test component configuration
                f_cf01Up(); // Initialise IUT with CERT_IUT_A_AT signed with CERT_IUT_A_AA
                
                // Test adapter configuration
                
                // Preamble
                f_prNeighbour();
                v_denmComponent := f_triggerDenmEvent();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
                tc_ac.start;
                alt {
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mw_etsiTs103097Data_signed(
                                    mw_signedData(
                                        -, 
                                        mw_toBeSignedData(
                                            mw_signedDataPayload,
                                            mw_headerInfo_denm
                                        ),
                                        mw_signerIdentifier_certificate(
                                            mw_etsiTs103097Certificate(
                                                -,
                                                mw_toBeSignedCertificate_at(
                                                    -, -, -, 
                                mw_geoNwBroadcastPacket
garciay's avatar
garciay committed
                    ))) -> value v_geoNwInd {
                        tc_ac.stop;
                        f_getMsgHeaderInfo(f_getSecuredMessage(v_geoNwInd.msgIn), v_headerInfo);
                    }
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mw_etsiTs103097Data_signed(
                                    mw_signedData(
                                        -, 
                                        mw_toBeSignedData(
                                            mw_signedDataPayload,
                                            mw_headerInfo_denm
                                        ),
                                        mw_signerIdentifier_digest
                                    )
                                ), 
                                mw_geoNwBroadcastPacket
garciay's avatar
garciay committed
                    ))) {
                        tc_ac.stop;                        
                        log("*** " & testcasename() & ": FAIL: DEN message retransmission with digest ***"); 
garciay's avatar
garciay committed
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                        //repeat;
                    }
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: Expected DEN message not received ***");
garciay's avatar
garciay committed
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                    }
                } // End of 'alt' statement
                
                // Postamble
                f_cancelDenmEvent(v_denmComponent);
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_ITSS_SND_DENM_06_BV
            
            /**
             * @desc   Check that IUT sends the secured DENM containing generation location which is inside the circular region 
             *         defined by the validity restriction of the certificate pointed by the message signer.
             * <pre>
             * Pics Selection: PICS_GN_SECURITY and PICS_SEC_CERTIFICATE_SELECTION
             * Config Id: CF01
             * Initial conditions:
             * with {
             *   the IUT is authorized with AT certificate (X_AT_CERTIFICATE) 
             *       containing toBeSigned
             *           indicating REGION
             * }
             * ensure that {
             *   when {
             *       the IUT is requested to send a DENM
             *   } then {
             *       the IUT sends a SecuredMessage of type EtsiTs103097Data
             *           containing headerInfo
             *               containing generationLocation
             *                   indicating value inside the REGION  
             *   }
             * }
             * </pre>
             * @see         ETSI TS 103 096-2 v1.3.2 TP_SEC_ITSS_SND_DENM_07_BV
             * @reference   ETSI TS 103 097 [1] Clauses 7.1.2
             * @reference   IEEE 1609.2 [2], Clauses 5.2.3.2.2  
garciay's avatar
garciay committed
             */
            testcase TC_SEC_ITSS_SND_DENM_07_BV() runs on ItsGeoNetworking system ItsSecSystem {
                // Local variables
                var GeoNetworkingInd v_geoNwInd;
                var HeaderInfo       v_headerInfo;
                var SignerIdentifier v_signerIdentifier;
                var Certificate      v_cert;
                var ItsDenm          v_denmComponent;
                
                // Test control
                if (not(PICS_GN_SECURITY) or not(PICS_SEC_CERTIFICATE_SELECTION)) {
                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY and PICS_SEC_CERTIFICATE_SELECTION' required for executing the TC ***");
                    stop;
                }
                
                // Test component configuration
                vc_hashedId8ToBeUsed := PICS_CERTFICATE_ID_VARIANT;
garciay's avatar
garciay committed
                f_cf01Up();
                
                // Test adapter configuration
                
                // Preamble
                f_prNeighbour();
                v_denmComponent := f_triggerDenmEvent();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
                tc_ac.start;
                alt {
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mw_etsiTs103097Data_signed(
                                    mw_signedData(
                                        -, 
                                        mw_toBeSignedData(
                                            mw_signedDataPayload,
                                            mw_headerInfo_denm
                                        ),
                                        mw_signerIdentifier_certificate(
                                            mw_etsiTs103097Certificate(
                                                -,
                                                mw_toBeSignedCertificate_at(
                                                    -, -, -,
                                                    ?
                                                )
                                mw_geoNwBroadcastPacket
garciay's avatar
garciay committed
                    ))) -> value v_geoNwInd {
                        tc_ac.stop;
                        if (f_getMsgHeaderInfo(f_getSecuredMessage(v_geoNwInd.msgIn), v_headerInfo) and f_getMsgSignerIdentifier(f_getSecuredMessage(v_geoNwInd.msgIn), v_signerIdentifier)) {
                            var ThreeDLocation v_location := { v_headerInfo.generationLocation.latitude, v_headerInfo.generationLocation.longitude, v_headerInfo.generationLocation.elevation };                            
                            var integer v_counter;
                            
                            for (v_counter := 0; v_counter < lengthof(v_signerIdentifier.certificate); v_counter := v_counter + 1) {                 
                                if (f_isLocationInsideRegion(v_signerIdentifier.certificate[v_counter].toBeSigned.region, v_location) == false) {
                                    break;
                                }
                            } // End of of for statement
                            if (v_counter == lengthof(v_signerIdentifier.certificate)) {
                                log("*** " & testcasename() & ": PASS: DENM contains generation location inside the certificate validity region ***");
                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                            } else {
                                log("*** " & testcasename() & ": FAIL: DEN message contains generation location outside the certificate validity region ***");
garciay's avatar
garciay committed
                                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);
                        }
                    }
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mw_etsiTs103097Data_signed(
                                    mw_signedData(
                                        -, 
                                        mw_toBeSignedData(
                                            mw_signedDataPayload,
                                            mw_headerInfo_denm
                                        ),
                                        mw_signerIdentifier_digest
                                    )
                                ), 
                                mw_geoNwBroadcastPacket
garciay's avatar
garciay committed
                    ))) {
                        tc_ac.stop;                        
                        log("*** " & testcasename() & ": FAIL: DEN message retransmission with digest ***"); 
garciay's avatar
garciay committed
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                        //repeat;
                    }
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: Expected DEN message not received ***");
garciay's avatar
garciay committed
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                    }
                } // End of 'alt' statement
                
                // Postamble
                f_cancelDenmEvent(v_denmComponent);
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_ITSS_SND_DENM_07_BV
            
            /**
             * @desc   Check that IUT sends the secured DENM containing generation location which is inside the region 
             *         defined by the validity restriction of the certificate pointed by the message signer . 
garciay's avatar
garciay committed
             * <pre>
             * Pics Selection: PICS_GN_SECURITY and not PICS_SEC_CERTIFICATE_SELECTION
garciay's avatar
garciay committed
             * Config Id: CF01
             * Initial conditions:
             * with {
             *   the IUT is authorized with AT certificate (X_AT_CERTIFICATE) 
             *       containing toBeSigned
             *           indicating REGION
             * }
             * ensure that {
             *   when {
             *       the IUT is requested to send a DENM
             *   } then {
             *       the IUT sends a SecuredMessage of type EtsiTs103097Data
             *           containing headerInfo
             *               containing generationLocation
             *                   indicating value inside the REGION  
             *   }
             * }
             * </pre>
             * @see         ETSI TS 103 096-2 v1.3.2 TP_SEC_ITSS_SND_DENM_08_BV
             * @reference   ETSI TS 103 097 [1] Clauses 7.1.2
             * @reference   IEEE 1609.2 [2], Clauses 5.2.3.2.2  
garciay's avatar
garciay committed
             */
            testcase TC_SEC_ITSS_SND_DENM_08_BV() runs on ItsGeoNetworking system ItsSecSystem {
                // Local variables
                var GeoNetworkingInd v_geoNwInd;
                var HeaderInfo       v_headerInfo;
                var SignerIdentifier v_signerIdentifier;
                var Certificate      v_cert;
                var ItsDenm          v_denmComponent;
                
                // Test control
                if (not(PICS_GN_SECURITY) or PICS_SEC_CERTIFICATE_SELECTION) {
                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY and not PICS_SEC_CERTIFICATE_SELECTION' required for executing the TC ***");
garciay's avatar
garciay committed
                    stop;
                }
                
                // Test component configuration
                vc_hashedId8ToBeUsed := PICS_CERTFICATE_ID_VARIANT;
garciay's avatar
garciay committed
                f_cf01Up();
                
                // Test adapter configuration
                
                // Preamble
                f_prNeighbour();
                v_denmComponent := f_triggerDenmEvent();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
                tc_ac.start;
                alt {
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mw_etsiTs103097Data_signed(
                                    mw_signedData(
                                        -, 
                                        mw_toBeSignedData(
                                            mw_signedDataPayload,
                                            mw_headerInfo_denm
                                        ),
                                        mw_signerIdentifier_certificate(
                                            mw_etsiTs103097Certificate(
                                                -,
                                                mw_toBeSignedCertificate_at
                                            )
                                        )
                                    )
                                ), 
                                mw_geoNwBroadcastPacket
garciay's avatar
garciay committed
                    ))) -> value v_geoNwInd {
                        tc_ac.stop;
                        if (f_getMsgHeaderInfo(f_getSecuredMessage(v_geoNwInd.msgIn), v_headerInfo) and f_getMsgSignerIdentifier(f_getSecuredMessage(v_geoNwInd.msgIn), v_signerIdentifier)) {
                            var ThreeDLocation v_location := { v_headerInfo.generationLocation.latitude, v_headerInfo.generationLocation.longitude, v_headerInfo.generationLocation.elevation };                            
                            var integer v_counter;
                            
                            for (v_counter := 0; v_counter < lengthof(v_signerIdentifier.certificate); v_counter := v_counter + 1) {                 
                                if (f_isLocationInsideRegion(v_signerIdentifier.certificate[v_counter].toBeSigned.region, v_location) == false) {
                                    break;
                                }
                            } // End of of for statement
                            if (v_counter == lengthof(v_signerIdentifier.certificate)) {
                                log("*** " & testcasename() & ": PASS: DENM contains generation location inside the certificate validity region ***");
                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                            } else {
                                log("*** " & testcasename() & ": FAIL: DEN message contains generation location outside the certificate validity region ***");
garciay's avatar
garciay committed
                                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);
                        }
                    }
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mw_etsiTs103097Data_signed(
                                    mw_signedData(
                                        -, 
                                        mw_toBeSignedData(
                                            mw_signedDataPayload,
                                            mw_headerInfo_denm
                                        ),
                                        mw_signerIdentifier_digest
                                    )
                                ), 
                                mw_geoNwBroadcastPacket
garciay's avatar
garciay committed
                    ))) {
                        tc_ac.stop;                        
                        log("*** " & testcasename() & ": FAIL: DEN message retransmission with digest ***"); 
garciay's avatar
garciay committed
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                        //repeat;
                    }
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: Expected DEN message not received ***");
garciay's avatar
garciay committed
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                    }
                } // End of 'alt' statement
                
                // Postamble
                f_cancelDenmEvent(v_denmComponent);
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_ITSS_SND_DENM_08_BV
            
            /**
             * @desc   Check that IUT sends the secured DENM containing generation location which is inside the identified 
             *         region defined by the validity restriction of the AA certificate used to sign the certificate 
             *         pointed by the message signer doesn't containing any region restriction. 
             * <pre>
             * Pics Selection: PICS_GN_SECURITY and PICS_SEC_CERTIFICATE_SELECTION
             * Config Id: CF01
             * Initial conditions:
             * with {
             *   the IUT is authorized with AT certificate (CERT_IUT_CA1_AT)
             *       containing toBeSigned
             *           not containing region
             *           and issuied by the certificate AA (CERT_IUT_CC_AA)
             *               containing toBeSigned
             *                   containing circularRegion
             *                       indicating REGION
             *               and issuied by the certificate RCA (CERT_IUT_C_RCA)
             *                   containing toBeSigned
             *                       containing circularRegion
             *                           indicating REGION
             * }
             * ensure that {
             *   when {
             *       the IUT is requested to send a DENM
             *   } then {
             *       the IUT sends a SecuredMessage of type EtsiTs103097Data
             *           containing headerInfo
             *               containing generationLocation
             *                   indicating value inside the REGION  
             *   }
             * }
             * </pre>
             * @see         ETSI TS 103 096-2 v1.3.2 TP_SEC_ITSS_SND_DENM_09_BV
             * @reference   ETSI TS 103 097 [1] Clauses 7.1.2
             * @reference   IEEE 1609.2 [2], Clauses 5.2.3.2.2 & 6.4.8 
             */
            testcase TC_SEC_ITSS_SND_DENM_09_BV() runs on ItsGeoNetworking system ItsSecSystem {
                // Local variables
                var GeoNetworkingInd v_geoNwInd;
                var HeaderInfo       v_headerInfo;
                var SignerIdentifier v_signerIdentifier;
                var Certificate      v_at_certificate;
                var Certificate      v_aa_certificate;
                var ItsDenm          v_denmComponent;
                
                // Test control
                if (not(PICS_GN_SECURITY) or not(PICS_SEC_CERTIFICATE_SELECTION)) {
                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY and PICS_SEC_CERTIFICATE_SELECTION' required for executing the TC ***");
                    stop;
                }
                
                // Test component configuration
                vc_hashedId8ToBeUsed := PICS_CERTFICATE_ID_VARIANT;
                f_cf01Up();
                
                // Test adapter configuration
                
                // Preamble
                f_prNeighbour();
                f_readCertificate(cc_taCert_CA1, v_at_certificate);
                f_readCertificate(cc_taCert_CC_AA, v_aa_certificate);
                v_denmComponent := f_triggerDenmEvent();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
                tc_ac.start;
                alt {
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mw_etsiTs103097Data_signed(
                                    mw_signedData(
                                        -, 
                                        mw_toBeSignedData(
                                            mw_signedDataPayload,
                                            mw_headerInfo_denm
                                        ),
                                        mw_signerIdentifier_certificate(
                                            mw_etsiTs103097Certificate(
                                                -,
                                                mw_toBeSignedCertificate_at(
                                                                            v_at_certificate.toBeSigned.appPermissions,
                                                                            v_at_certificate.toBeSigned.verifyKeyIndicator,
                                                                            v_at_certificate.toBeSigned.validityPeriod,
                                                                            omit
                                                )
                                            )
                                        )
                                    )
                                ), 
                                mw_geoNwBroadcastPacket
                    ))) -> value v_geoNwInd {
                        tc_ac.stop;
                        if (f_getMsgHeaderInfo(f_getSecuredMessage(v_geoNwInd.msgIn), v_headerInfo)) {
                            var ThreeDLocation v_location := { v_headerInfo.generationLocation.latitude, v_headerInfo.generationLocation.longitude, v_headerInfo.generationLocation.elevation };                            
                            
                            if (f_isLocationInsideRegion(v_at_certificate.toBeSigned.region, v_location) == true) {
                                log("*** " & testcasename() & ": PASS: DENM contains generation location inside the certificate validity region ***");
                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                            } else {
                                log("*** " & testcasename() & ": FAIL: DEN message contains generation location outside the certificate validity region ***");
                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                            }
                        } else {
                            log("*** " & testcasename() & ": FAIL: IMPOSSIBLE!!! DENM generation location or certificate region restriction header field does not exist ***"); 
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                        }
                    }
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mw_etsiTs103097Data_signed(
                                    mw_signedData(
                                        -, 
                                        mw_toBeSignedData(
                                            mw_signedDataPayload,
                                            mw_headerInfo_denm
                                        ),
                                        mw_signerIdentifier_digest
                                    )
                                ), 
                                mw_geoNwBroadcastPacket
                    ))) {
                        tc_ac.stop;                        
                        log("*** " & testcasename() & ": FAIL: DEN message retransmission with digest ***"); 
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                        //repeat;
                    }
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: Expected DEN message not received ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                    }
                } // End of 'alt' statement
                
                // Postamble
                f_cancelDenmEvent(v_denmComponent);
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_ITSS_SND_DENM_09_BV
            
            /**
             * @desc   Check that IUT sends the secured DENM containing generation location which is inside the identified 
             *         region defined by the validity restriction of the root certificate when subordinate AA and AT 
             *         certificates don't contain any region restriction. 
             * <pre>
             * Pics Selection: PICS_GN_SECURITY and PICS_SEC_CERTIFICATE_SELECTION
             * Config Id: CF01
             * Initial conditions:
             * with {
             *   the IUT is authorized with AT certificate (CERT_IUT_CA2_AT)
             *       containing toBeSigned
             *           not containing region
             *           and issuied by the certificate AA (CERT_IUT_CC_AA)
             *               containing toBeSigned
             *                   containing circularRegion
             *                       indicating REGION
             *               and issuied by the certificate RCA (CERT_IUT_C_RCA)
             *                   containing toBeSigned
             *                       containing circularRegion
             *                           indicating REGION
             * }
             * ensure that {
             *   when {
             *       the IUT is requested to send a DENM
             *   } then {
             *       the IUT sends a SecuredMessage of type EtsiTs103097Data
             *           containing headerInfo
             *               containing generationLocation
             *                   indicating value inside the REGION  
             *   }
             * }
             * </pre>
             * @see         ETSI TS 103 096-2 v1.3.2 TP_SEC_ITSS_SND_DENM_10_BV
             * @reference   ETSI TS 103 097 [1] Clauses 7.1.2
             * @reference   IEEE 1609.2 [2], Clauses 5.2.3.2.2 & 6.4.8 
             */
            testcase TC_SEC_ITSS_SND_DENM_10_BV() runs on ItsGeoNetworking system ItsSecSystem {
                // Local variables
                var GeoNetworkingInd v_geoNwInd;
                var HeaderInfo       v_headerInfo;
                var SignerIdentifier v_signerIdentifier;
                var Certificate      v_at_certificate;
                var Certificate      v_aa_certificate;
                var ItsDenm          v_denmComponent;
                
                // Test control
                if (not(PICS_GN_SECURITY) or not(PICS_SEC_CERTIFICATE_SELECTION)) {
                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY and PICS_SEC_CERTIFICATE_SELECTION' required for executing the TC ***");
                    stop;
                }
                
                // Test component configuration
                vc_hashedId8ToBeUsed := PICS_CERTFICATE_ID_VARIANT;
                f_cf01Up();
                
                // Test adapter configuration
                
                // Preamble
                f_prNeighbour();
                f_readCertificate(cc_taCert_CA2, v_at_certificate);
                f_readCertificate(cc_taCert_CC_AA, v_aa_certificate);
                v_denmComponent := f_triggerDenmEvent();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
                tc_ac.start;
                alt {
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mw_etsiTs103097Data_signed(
                                    mw_signedData(
                                        -, 
                                        mw_toBeSignedData(
                                            mw_signedDataPayload,
                                            mw_headerInfo_denm
                                        ),
                                        mw_signerIdentifier_certificate(
                                            mw_etsiTs103097Certificate(
                                                -,
                                                mw_toBeSignedCertificate_at(
                                                                            v_at_certificate.toBeSigned.appPermissions,
                                                                            v_at_certificate.toBeSigned.verifyKeyIndicator,
                                                                            v_at_certificate.toBeSigned.validityPeriod,
                                                                            omit
                                                )
                                            )
                                        )
                                    )
                                ), 
                                mw_geoNwBroadcastPacket
                    ))) -> value v_geoNwInd {
                        tc_ac.stop;
                        if (f_getMsgHeaderInfo(f_getSecuredMessage(v_geoNwInd.msgIn), v_headerInfo)) {
                            var ThreeDLocation v_location := { v_headerInfo.generationLocation.latitude, v_headerInfo.generationLocation.longitude, v_headerInfo.generationLocation.elevation };                            
                            
                            if (f_isLocationInsideRegion(v_at_certificate.toBeSigned.region, v_location) == true) {
                                log("*** " & testcasename() & ": PASS: DENM contains generation location inside the certificate validity region ***");
                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                            } else {
                                log("*** " & testcasename() & ": FAIL: DEN message contains generation location outside the certificate validity region ***");
                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                            }
                        } else {
                            log("*** " & testcasename() & ": FAIL: IMPOSSIBLE!!! DENM generation location or certificate region restriction header field does not exist ***"); 
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                        }
                    }
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mw_etsiTs103097Data_signed(
                                    mw_signedData(
                                        -, 
                                        mw_toBeSignedData(
                                            mw_signedDataPayload,
                                            mw_headerInfo_denm
                                        ),
                                        mw_signerIdentifier_digest
                                    )
                                ), 
                                mw_geoNwBroadcastPacket
                    ))) {
                        tc_ac.stop;                        
                        log("*** " & testcasename() & ": FAIL: DEN message retransmission with digest ***"); 
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                        //repeat;
                    }
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: Expected DEN message not received ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                    }
                } // End of 'alt' statement
garciay's avatar
garciay committed
                
                // Postamble
                f_cancelDenmEvent(v_denmComponent);
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_ITSS_SND_DENM_10_BV
            
            /**
             * @desc    Check that IUT sends the secured DENM containing the 'data' field in signed data payload, 
             *          containing the EtsiTs103097Data of type unsecured, contained the DENM payload
             * <pre>
             * Pics Selection: PICS_GN_SECURITY
             * Config Id: CF01
             * Initial conditions:
             *  with {
             *      the IUT is authorized with AT certificate (CERT_IUT_A_AT) 
             *  }
             *  ensure that {
             *      when {
             *          the IUT is requested to send a secured DENM
             *      } then {
             *          the IUT sends a message of type EtsiTs103097Data
             *              contains content
             *                  contains signedData
             *                      containing tbsData
             *                          containing payload
             *                              containing data
             *                                  containing content
             *                                      containing unsecuredData
             *                                          containing not-empty data
             *      }
             *  }
             * </pre>
             *
             * @see          ETSI TS 103 096-2 v1.3.2 TP_SEC_ITSS_SND_DENM_11_BV
             * @reference    ETSI TS 103 097 [1] Clauses 5.2 & 7.1.2
             */
            testcase TC_SEC_ITSS_SND_DENM_11_BV() runs on ItsGeoNetworking system ItsSecSystem {
                // Local variables
                var ItsDenm v_denmComponent;
                
                // Test control
                if (not(PICS_GN_SECURITY)) {
                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY' required for executing the TC ***");
                    stop;
                }