ItsSecurity_TestCases.ttcn 1.6 MB
Newer Older
                        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_ENC_03_BV
            
            /**
             * @desc    Check that the ciphertext of encrypted message contains encrypted EtsiTs103097Data structure.
             * <pre>
             * Pics Selection: PICS_GN_SECURITY AND PICS_SEC_ENCRYPTION_SUPPORT
             * Config Id: CF01
             * Initial conditions:
             *  with {
             *      the IUT is authorized with AT certificate (CERT_IUT_A_AT)
             *  }
             * Expected behaviour:
             * ensure that {
             *     when { 
             *         the IUT is requested to send an encrypted message
             *     } then {
             *         the IUT sends a message of type EtsiTs103097Data
             *             containing encryptedData
             *                 containing ciphertext
             *                     containing encrypted data
             *                        containing COER encoded data
             *                           containing structure of type EtsiTs103097Data
             *     }
             * }
             * </pre>
             *
             * @see         ETSI TS 103 096-2 v1.3.2 TP_SEC_ITSS_SND_ENC_04_BV
             * @reference   IEEE 1609.2 [2], clauses 6.3.31
             * @reference   ETSI TS 103 097 [1] Clause 7.1.4
             */
            testcase TC_SEC_ITSS_SND_ENC_04_BV() runs on ItsGeoNetworking system ItsSecSystem {
                    
                // Local variables
Yann Garcia's avatar
Yann Garcia committed
                var Oct16                 v_aes_sym_enc_key;
                var EtsiTs103097Data      v_decryptedMsg;
                var GeoNetworkingInd      v_geoNwInd;
                    
                // Test control
                if (not(PICS_GN_SECURITY) or not(PICS_SEC_ENCRYPTION_SUPPORT)) {
                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY and PICS_SEC_ENCRYPTION_SUPPORT' 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();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
                tc_ac.start;
                alt {
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mw_etsiTs103097Data_encrypted(
                                    mw_encryptedData(
                                        -,
                                        mw_SymmetricCiphertext_aes128ccm(
                                            mw_aesCcmCiphertext
                    )))))) -> value v_geoNwInd {
                        tc_ac.stop;
                        
Yann Garcia's avatar
Yann Garcia committed
                        if (f_decrypt(vc_encryptPrivateKey, f_getSecuredMessage(v_geoNwInd.msgIn), ''O, v_decryptedMsg, v_aes_sym_enc_key) == false) { // No salt value
                            log("*** " & testcasename() & ": FAIL: Unable to process encryption data ***");
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                        } else if (match(v_decryptedMsg, mw_etsiTs103097Data) == false) {
                            log("*** " & testcasename() & ": FAIL: Unable to parse EtsiTs103097Data data ***");
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                        } else {
                            log("*** " & testcasename() & ": PASS: IUT sends signed and encrypted message ***");
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                        }
                    }
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: Expected message not received ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                    }
                } // End of 'alt' statement
                
                // Postamble
                f_poNeighbour();
                f_cf01Down();
                
            } // End of testcase TC_SEC_ITSS_SND_ENC_04_BV
            
            /**
             * @desc    Check that when the IUT sends SignedAndEncrypted message then it sends the 
             *          EtsiTs103097Data-Encrypted message containing the EtsiTs103097Data-Signed 
             *          structure as the ToBeSignedDataContent.
             * <pre>
             * Pics Selection: PICS_GN_SECURITY AND PICS_SEC_ENCRYPTION_SUPPORT
             * Config Id: CF01
             * Initial conditions:
             *  with {
             *      the IUT is authorized with AT certificate (CERT_IUT_A_AT)
             *  }
             * Expected behaviour:
             * ensure that {
             *     when { 
             *         the IUT is requested to send an encrypted and signed message
             *     } then {
             *         the IUT sends a message of type EtsiTs103097Data
             *             containing encryptedData
             *                 containing ciphertext
             *                     containing encrypted data
             *                        containing COER encoded data
             *                           containing structure of type EtsiTs103097Data
             *                               containing signedData
             *     }
             * }
             * </pre>
             *
             * @see         ETSI TS 103 096-2 v1.3.2 TP_SEC_ITSS_SND_ENC_05_BV
             * @reference   IEEE 1609.2 [2], clauses 6.3.31
             * @reference   ETSI TS 103 097 [1] Clause 7.1.5
             */
            testcase TC_SEC_ITSS_SND_ENC_05_BV() runs on ItsGeoNetworking system ItsSecSystem {
                    
                // Local variables
Yann Garcia's avatar
Yann Garcia committed
                var Oct16                 v_aes_sym_enc_key;
                var EtsiTs103097Data      v_decryptedMsg;
                var GeoNetworkingInd      v_geoNwInd;
                    
                // Test control
                if (not(PICS_GN_SECURITY) or not(PICS_SEC_ENCRYPTION_SUPPORT)) {
                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY and PICS_SEC_ENCRYPTION_SUPPORT' 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();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
                tc_ac.start;
                alt {
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mw_etsiTs103097Data_encrypted(
                                    mw_encryptedData(
                                        -,
                                        mw_SymmetricCiphertext_aes128ccm(
                                            mw_aesCcmCiphertext
                    )))))) -> value v_geoNwInd {
                        tc_ac.stop;
                        
Yann Garcia's avatar
Yann Garcia committed
                        if (f_decrypt(vc_encryptPrivateKey, f_getSecuredMessage(v_geoNwInd.msgIn), ''O, v_decryptedMsg, v_aes_sym_enc_key) == false) { // No salt value
                            log("*** " & testcasename() & ": FAIL: Unable to process encryption data ***");
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                        } else if (match(v_decryptedMsg, mw_etsiTs103097Data_signed) == false) {
                            log("*** " & testcasename() & ": FAIL: Unable to parse signed data ***");
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                        } else {
                            // TODO Check signature?
                            log("*** " & testcasename() & ": PASS: IUT sends signed and encrypted message ***");
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                        }
                    }
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: Expected message not received ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                    }
                } // End of 'alt' statement
                
                // Postamble
                f_poNeighbour();
                f_cf01Down();
                
            } // End of testcase TC_SEC_ITSS_SND_ENC_05_BV
            
        } // End of group encryptedMessagesProfile
        
        /**
         * @desc Sending behaviour test cases for certificates profile
         * @see ETSI TS 103 096-2 V1.3.32 (2018-01) Clause 5.2.8 Profiles for certificates
         */
        group profileForCertificates {
            /**
             * @desc    Check that IUT certificate is explicit and has version 3.
             * <pre>
             * Pics Selection: PICS_GN_SECURITY
             * Config Id: CF01
             * Initial conditions:
             *  with {
             *      the IUT being in the 'authorized' state
             *  }
             * Expected behaviour:
             * ensure that {
             *     when { 
             *         the AA is issued the certificate
             *     } then {
             *         this certificate is of type EtsiTs103097Certificate
             *             containing version
             *                 indicating 3
             *             and containing type
             *                 indicating 'explicit'
             *             and containing toBeSigned
             *                 containing verifyKeyIndicator
             *                     containing verificationKey
             *     }
             * }
             * </pre>
             *
             * @see         ETSI TS 103 096-2 v1.3.2 TP_SEC_ITSS_SND_CERT_01_BV
             * @reference   ETSI TS 103 097 [1], Clauses 6
             * @reference   IEEE 1609.2 [2] Clause 6.4.3
             */
            testcase TC_SEC_ITSS_SND_CERT_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(); // Initialise IUT with CERT_IUT_A_AT signed with CERT_IUT_A_AA
                    
                // Test adapter configuration
                // Preamble
                f_prNeighbour();
                log("*** " & testcasename() & ": INFO: Wait for certificate and ask for AA certificate  ***");
                f_askForCertificateChain(f_generateDefaultCam()); // TODO Rename f_askForCertificateChain into f_askForCertificateAA
                tc_ac.stop;
                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_ieee1609Dot2_headerInfo_request_certificate(
                                                mw_etsiTs103097Certificate(
                                                    -,
                                                    mw_toBeSignedCertificate_aa
                    )))))))) {
                        tc_ac.stop;
                        log("*** " & testcasename() & ": PASS: Security protocol version set to 3 ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                    }
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: Expected message not received ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                    }
                } // End of 'alt' statement
                
                // Postamble
                f_poNeighbour();
                f_cf01Down();
                
            } // End of testcase TC_SEC_ITSS_SND_CERT_01_BV
            
            /**
             * @desc    Check that IUT certificate is conformed to ETSI TS 103 097 clause 6.
             * <pre>
             * Pics Selection: PICS_GN_SECURITY
             * Config Id: CF01
             * Initial conditions:
             *  with {
             *      the IUT being in the 'authorized' state
             *  }
             * Expected behaviour:
             * ensure that {
             *     when { 
             *         the AA is issued the certificate
             *     } then {
             *         this certificate is of type EtsiTs103097Certificate
             *             containing toBeSigned
             *                 containing id
             *                     indicating 'none'
             *                     or indicating 'name'
             *                 and containing cracaId
             *                     indicating '000000'H
             *                 and containing crlSeries
             *                     indicating '0'D
             *                 and not containing certRequestPermissions
             *                 and not containing canRequestRollover
             *                 and containing signature
             *     }
             * }
             * </pre>
             *
             * @see         ETSI TS 103 096-2 v1.3.2 TP_SEC_ITSS_SND_CERT_02_BV
             * @reference   ETSI TS 103 097 [1], Clauses 6
             */
            testcase TC_SEC_ITSS_SND_CERT_02_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(); // Initialise IUT with CERT_IUT_A_AT signed with CERT_IUT_A_AA
                    
                // Test adapter configuration
                
                // Preamble
                f_prNeighbour();
                log("*** " & testcasename() & ": INFO: Wait for certificate and ask for AA certificate ***");
                tc_ac.start;
                f_askForCertificateChain(f_generateDefaultCam());
                tc_ac.stop;
                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_ieee1609Dot2_headerInfo_request_certificate(
                                                -,
                                                mw_etsiTs103097Certificate(
                                                    -,
                                                    mw_toBeSignedCertificate_aa(
                                                        mw_certificateId_name
                    ))))))))) {
                        tc_ac.stop;
                        log("*** " & testcasename() & ": PASS: AA certificate is conformed to ETSI TS 103 097 clause 6, with named id ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                    }
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mw_etsiTs103097Data_signed(
                                    mw_signedData(
                                        -,
                                        mw_toBeSignedData(
                                            -,
                                            mw_ieee1609Dot2_headerInfo_request_certificate(
                                                -,
                                                mw_etsiTs103097Certificate(
                                                    -,
                                                    mw_toBeSignedCertificate_aa(
                                                        mw_certificateId_none
                    ))))))))) {
                        tc_ac.stop;
                        log("*** " & testcasename() & ": PASS: AA certificate is conformed to ETSI TS 103 097 clause 6, with none id ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                    }
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: Expected message not received ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                    }
                } // End of 'alt' statement
                
                // Postamble
                f_poNeighbour();
                f_cf01Down();
                
            } // End of testcase TC_SEC_ITSS_SND_CERT_02_BV
            
            /**
             * @desc    Check that the certificate issuer of certificates is referenced using digest;
             *          Check that right digest field is used to reference to the certificate.
             * <pre>
             * Pics Selection: PICS_GN_SECURITY
             * Config Id: CF01
             * Initial conditions:
             *  with {
             *      the IUT is authorized with AT certificate (X_CERTIFICATE) 
             *  }
             *  ensure that {
             *      when {
             *          the CA is issued the certificate
             *      } then {
             *          this certificate is of type EtsiTs103097Certificate
             *              containing signedData
             *                  containing self
             *                  or containing X_DIGEST
             *                      indicating last 8 bytes of the hash of the certificate calculated using X_ALGORITHM
             *                          referenced to certificate
             *                              containing toBeSigned
             *                                  containing verifyKeyIndicator
             *                                      containing verificationKey
             *                                          containing X_KEY
             *      }
             *  }
             * </pre>
             *
             * @see         ETSI TS 103 096-2 v1.3.2 TP_SEC_ITSS_SND_CERT_03_BV
             * @reference   ETSI TS 103 097 [1], Clauses 5.2 & 7.1.3
             * @reference   IEEE 1609.2 [2], Clauses 5.3.1, 6.3.4, 6.3.29, 6.3.30, 6.3.31
            testcase TC_SEC_ITSS_SND_CERT_03_BV() runs on ItsGeoNetworking system ItsSecSystem {
                    
                // Local variables
                var EtsiTs103097Certificate v_ca_certificate;
                var EtsiTs103097Certificate v_aa_certificate;
                var EtsiTs103097Certificate v_at_certificate;
                var HashedId8               v_ca_hashedId8;
                var HashedId8               v_aa_hashedId8;
                
                // Test control
                if (not(PICS_GN_SECURITY)) {
                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY' required for executing the TC ***");
                    stop;
                
                // Test component configuration
                    
                // Test adapter configuration
                
                // Preamble
                f_readCertificate(cc_taCert_CA1, v_ca_certificate); // TODO Use PIXIT as array of strings to change 
                                                                    // certificates to be checked
                f_readCertificate(cc_taCert_CC_AA, v_aa_certificate);
                f_readCertificate(cc_iutCert_A, v_at_certificate);
                f_getCertificateDigest(cc_taCert_CC_AA, v_ca_hashedId8);
                f_getCertificateDigest(cc_taCert_CC_AA, v_aa_hashedId8);
                
                // Test Body
                // 1. Check certificate format
                if (match(
                          v_ca_certificate,
                          mw_etsiTs103097Certificate(
                                                     mw_issuerIdentifier_self,
                                                     mw_toBeSignedCertificate_ca
                )) == true) {
                    log("*** " & testcasename() & ": INFO: CA certificate are well formatted ***");
                } else {
                    log("*** " & testcasename() & ": FAIL: Invalid CA certificate ***");
                    setverdict(fail);
                } // End of 'alt' statement
                if (match(
                          v_aa_certificate,
                          mw_etsiTs103097Certificate(
                                                     ?,
                                                     mw_toBeSignedCertificate_aa
                )) == true) {
                    log("*** " & testcasename() & ": INFO: AA certificate are well formatted ***");
                } else {
                    log("*** " & testcasename() & ": FAIL: Invalid AA certificate ***");
                    setverdict(fail);
                } // End of 'alt' statement
                if (match(
                          v_at_certificate,
                          mw_etsiTs103097Certificate(
                                                     ?,
                                                     mw_toBeSignedCertificate_at
                )) == true) {
                    log("*** " & testcasename() & ": INFO: AT sertificate are well formatted ***");
                } else {
                    log("*** " & testcasename() & ": Invalid AT certificate ***");
                    setverdict(fail);
                } // End of 'alt' statement
                // 2. Check issuers
                if (v_ca_certificate.issuer.self_ == sha256) {
                    if (match(v_ca_hashedId8, v_aa_certificate.issuer.sha256AndDigest) == true) {
                        log("*** " & testcasename() & ": INFO: AA certificate is issued from CA certificate ***");
                    } else {
                        log("*** " & testcasename() & ": FAIL: Invalid AA certificate ***");
                        setverdict(fail);
                    } // End of 'alt' statement
                    if (match(v_aa_hashedId8, v_at_certificate.issuer.sha256AndDigest) == true) {
                        log("*** " & testcasename() & ": INFO: AT certificate is issued from CA certificate ***");
                        setverdict(pass, "Certificates are well-formated and issuer chain is correct");
                    } else {
                        log("*** " & testcasename() & ": FAIL: Invalid AA certificate ***");
                        setverdict(fail);
                    } // End of 'alt' statement
                } else if (v_ca_certificate.issuer.self_ == sha384) {
                    if (match(v_ca_hashedId8, v_aa_certificate.issuer.sha384AndDigest) == true) {
                        log("*** " & testcasename() & ": INFO: AA certificate is issued from CA certificate ***");
                    } else {
                        log("*** " & testcasename() & ": FAIL: Invalid AA certificate ***");
                        setverdict(fail);
                    } // End of 'alt' statement
                    if (match(v_aa_hashedId8, v_at_certificate.issuer.sha384AndDigest) == true) {
                        log("*** " & testcasename() & ": INFO: AT certificate is issued from CA certificate ***");
                        setverdict(pass, "Certificates are well-formated and issuer chain is correct");
                    } else {
                        log("*** " & testcasename() & ": FAIL: Invalid AA certificate ***");
                        setverdict(fail);
                    } // End of 'alt' statement
                } else {
                    log("*** " & testcasename() & ": FAIL: Invalid CA certificate issuer ***");
                    setverdict(fail);
                }
                
                // Postamble
                
            } // End of testcase TC_SEC_ITSS_SND_CERT_03_BV
            
            /**
             * @desc    Check that the rectangular certificate validity region of the subordinate certificate is well formed 
             *          and inside the validity region of the issuing certificate.
             * <pre>
             * Pics Selection: PICS_GN_SECURITY and PICS_SEC_RECTANGULAR_REGION
             * Config Id: CF01
             * Initial conditions:
             *  with {
             *      the CA is authorized with AA certificate 
             *          containing toBeSigned
             *              containing region
             *                  indicating REGION
             *  }
             * Expected behaviour:
             * ensure that {
             *     when { 
             *         the IUT issued the AT certificate 
             *     } then {
             *         this certificate is of type EtsiTs103097Certificate
             *             containing toBeSigned
             *                 containing region
             *                     containing rectangularRegion
             *                         containing items of type RectangularRegion
             *                             containing northwest
             *                                 indicating a point inside the REGION
             *                             and containing southeast
             *                                 indicating a point on the south from northwest
             *             and inside the REGION
             *     }
             * }
             * </pre>
             *
             * @see         ETSI TS 103 096-2 v1.3.2 TP_SEC_ITSS_SND_CERT_04_BV
             * @reference   ETSI TS 103 097 [1], Clauses 6
             */
            testcase TC_SEC_ITSS_SND_CERT_04_BV() runs on ItsGeoNetworking system ItsSecSystem {
                    
                // Local variables
                var SequenceOfCertificate v_aa_certificate;
                var SignerIdentifier      v_signerIdentifier;
                var GeoNetworkingInd      v_geoNwInd;
                
                // Test control
                if (not(PICS_GN_SECURITY) or not(PICS_SEC_RECTANGULAR_REGION)) {
                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY and PICS_SEC_RECTANGULAR_REGION' 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();
                log("*** " & testcasename() & ": INFO: Wait for certificate and ask for AA certificate ***");
                tc_ac.start;
                f_askAndWaitForCertificateChain(v_aa_certificate, f_generateDefaultCam());
                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_cam
                                        mw_signerIdentifier_certificate(
                                            mw_etsiTs103097Certificate(
                                                -,
                                                mw_toBeSignedCertificate_at(
                                                    -, -, -,
                                                    mw_geographicRegion_rectangular
                    )))))))) -> value v_geoNwInd {
                        if (f_getMsgSignerIdentifier(f_getSecuredMessage(v_geoNwInd.msgIn), v_signerIdentifier)) {
                            var integer v_counter;
                            
                            for (v_counter := 0; v_counter < lengthof(v_signerIdentifier.certificate); v_counter := v_counter + 1) {
                                if (f_areRectanglesInside(v_signerIdentifier.certificate[v_counter].toBeSigned.region.rectangularRegion, v_aa_certificate[0].toBeSigned.region.rectangularRegion) == false) {
                                    break;
                                }
                            } // End of of for statement
                            if (v_counter == lengthof(v_signerIdentifier.certificate)) {
                                log("*** " & testcasename() & ": PASS: AT certificate is inside the validity region of the issuing certificate ***");
                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                            } else {
                                log("*** " & testcasename() & ": FAIL: AT certificate is not inside the validity region of the issuing certificate ***");
                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                            }
                        } else {
                            log("*** " & testcasename() & ": FAIL: IMPOSSIBLE!!! CAM 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_cam
                                        mw_signerIdentifier_digest // containing digest
                    ))) {
                        log("*** " & testcasename() & ": INFO: Generation of CAM messages including digest ***");
                        repeat;
                    }
                    [] 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_04_BV
             * @desc    Check that the IUT supports at least 8 entries in the rectangular certificate validity 
             *          region in the AT certificate.
             * <pre>
             * Pics Selection: PICS_GN_SECURITY and PICS_SEC_RECTANGULAR_REGION
             * Config Id: CF01
             * Initial conditions:
             *  with {
             *      the IUT is authorized with AT certificate (CERT_IUT_C_AT_8)
             *          containing toBeSigned
             *              containing region
             *                  containing rectangularRegion
             *                      containing 8 entries
             *                          containing one entry (ENTRY)
             *                              containing current IUT position
             *  }
             * Expected behaviour:
             * ensure that {
             *     when { 
             *         the IUT is requested to send a secured DENM 
             *     } then {
             *         this certificate is of type EtsiTs103097Certificate
             *             containing headerInfo
             *                 containing generationLocation
             *                     indicating position inside the ENTRY 
             *     }
             * }
             * </pre>
             *
             * @see         ETSI TS 103 096-2 v1.3.2 TP_SEC_ITSS_SND_CERT_05_BV
             * @reference   ETSI TS 103 097 [1], Clauses 6.4.17
             */
            testcase TC_SEC_ITSS_SND_CERT_05_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_RECTANGULAR_REGION)) {
                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY and PICS_SEC_RECTANGULAR_REGION' required for executing the TC ***");
                    stop;
                }
                
                // Test component configuration
                vc_hashedId8ToBeUsed := cc_iutCert_A; // FIXME Review certificate to be used
                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_geographicRegion_rectangular
                                                )
                                            )
                                        )
                                     )
                                ), 
                                mw_geoNwBroadcastPacket
                    ))) -> value v_geoNwInd {
                        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: AT certificate is inside the validity region of the issuing certificate ***");
                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                            } else {
                                log("*** " & testcasename() & ": FAIL: AT certificate is not inside the validity region of the issuing certificate ***");
                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                            }
                        } else {
                            log("*** " & testcasename() & ": FAIL: IMPOSSIBLE!!! CAM 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 // containing digest
                                    )
                                ), 
                                mw_geoNwBroadcastPacket
                    ))) {
                        log("*** " & testcasename() & ": INFO: Generation of CAM messages including digest ***");
                        repeat;
                    }
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: Expected 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_CERT_05_BV
            /**
             * @desc    Check that the rectangular certificate validity region of the subordinate certificate is well formed 
             *          and inside the validity region of the issuing certificate.
             * <pre>
             * Pics Selection: PICS_GN_SECURITY and PICS_SEC_POLYGONAL_REGION
             * Config Id: CF01
             * Initial conditions:
             *  with {
             *      the CA is authorized with AA certificate 
             *          containing toBeSigned
             *              containing region
             *                  indicating REGION
             *  }
             * Expected behaviour:
             * ensure that {
             *     when { 
             *         the IUT issued the AT certificate 
             *     } then {
             *         this certificate is of type EtsiTs103097Certificate
             *             containing toBeSigned
             *                 containing region
             *                     containing polygonalRegion
             *                         containing more than 2 items of type TwoDLocation
             *                             indicating points inside the REGION
             *                             and indicating unintercepting segments
             *     }
             * }
             * </pre>
             *
             * @see         ETSI TS 103 096-2 v1.3.2 TP_SEC_ITSS_SND_CERT_06_BV
             * @reference   ETSI TS 103 097 [1], Clauses 6.4.21, 6.4.17,5.1.2.4
             */
            testcase TC_SEC_ITSS_SND_CERT_06_BV() runs on ItsGeoNetworking system ItsSecSystem {
                    
                // Local variables
                var SequenceOfCertificate v_aa_certificate;
                var SignerIdentifier      v_signerIdentifier;
                var GeoNetworkingInd      v_geoNwInd;
                
                // Test control
                if (not(PICS_GN_SECURITY) or not(PICS_SEC_POLYGONAL_REGION)) {
                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY and PICS_SEC_POLYGONAL_REGION' 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();
                // 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 AA certificate ***");
                f_askAndWaitForCertificateChain(v_aa_certificate, f_generateDefaultCam());
                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_cam
                                        ),
                                        mw_signerIdentifier_certificate(
                                            mw_etsiTs103097Certificate(
                                                -,
                                                mw_toBeSignedCertificate_at(
                                                    -, -, -,
                                                    mw_geographicRegion_polygonal
                    )))))))) -> value v_geoNwInd {
                        tc_ac.stop;
                        if (f_getMsgSignerIdentifier(f_getSecuredMessage(v_geoNwInd.msgIn), v_signerIdentifier)) {
                            var integer v_counter;
                            
                            for (v_counter := 0; v_counter < lengthof(v_signerIdentifier.certificate); v_counter := v_counter + 1) {
                                if (f_arePolygonsInside(v_signerIdentifier.certificate[v_counter].toBeSigned.region.polygonalRegion, v_aa_certificate[0].toBeSigned.region.polygonalRegion) == false) {
                                    break;
                                }
                            } // End of of for statement
                            if (v_counter == lengthof(v_signerIdentifier.certificate)) {
                                log("*** " & testcasename() & ": PASS: AT certificate is inside the validity region of the issuing certificate ***");
                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                            } else {
                                log("*** " & testcasename() & ": FAIL: AT certificate is not inside the validity region of the issuing certificate ***");
                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                            }
                        } else {
                            log("*** " & testcasename() & ": FAIL: IMPOSSIBLE!!! CAM 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_cam
                                        ),
                                        mw_signerIdentifier_digest // containing digest
                                    )
                                )
                    ))) {
                        log("*** " & testcasename() & ": INFO: Generation of CAM messages including digest ***");
                        repeat;
                    }
                    [] 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_06_BV
            
            /**
             * @desc    Check that the IUT supports at least 8 entries in the polygonal certificate validity 
             *          region in the AT certificate.
             * <pre>
             * Pics Selection: PICS_GN_SECURITY and PICS_SEC_POLYGONAL_REGION
             * Config Id: CF01
             * Initial conditions:
             *  with {
             *      the IUT is authorized with AT certificate (CERT_IUT_D_AT_8)
             *          containing toBeSigned
             *              containing region
             *                  containing polygonalRegion
             *                      containing 8 entries
             *                          indicating polygon P
             *          and the IUT’s position is inside the polygon P
             *  }
             * Expected behaviour:
             * ensure that {
             *     when { 
             *         the IUT is requested to send a secured DENM 
             *     } then {
             *         this certificate is of type EtsiTs103097Certificate
             *             containing headerInfo
             *                 containing generationLocation
             *                     indicating position inside the P 
             *     }
             * }
             * </pre>
             *
             * @see         ETSI TS 103 096-2 v1.3.2 TP_SEC_ITSS_SND_CERT_07_BV
             * @reference   ETSI TS 103 097 [1], Clauses 6.4.17
             */
            testcase TC_SEC_ITSS_SND_CERT_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_POLYGONAL_REGION)) {
                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY and PICS_SEC_POLYGONAL_REGION' required for executing the TC ***");
                    stop;
                }
                
                // Test component configuration
                vc_hashedId8ToBeUsed := cc_iutCert_A; // FIXME Review certificate to be used
                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_geographicRegion_polygonal
                                                )
                                            )
                                        )