ItsSecurity_TestCases.ttcn 1.59 MB
Newer Older
                f_prNeighbour();
                f_acTriggerEvent(m_startPassBeaconing(m_beaconHeader(v_longPosVectorIut).beaconHeader)); // Authorize the TA to forward the received beacons
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
                tc_ac.start;
                alt {
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mw_etsiTs103097Data_signed(
                                    mw_signedData(
                                        -, 
                                        mw_toBeSignedData(
                                            mw_signedDataPayload,
                                            mw_headerInfo_gn
                                        ),
                                        mw_signerIdentifier_digest // containing digest
                                    )
                                )
                    ))) {
                        log("*** " & testcasename() & ": INFO: Correct secured packet received, containing digest ***");
                        repeat;
                    }
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mw_etsiTs103097Data_signed(
                                    mw_signedData(
                                        -, 
                                        mw_toBeSignedData(
                                            mw_signedDataPayload,
                                            mw_headerInfo_gn
                                        ),
                                        mw_signerIdentifier_certificate( // or containing certificate
                                            mw_etsiTs103097Certificate(
                                                -,
                                                mw_toBeSignedCertificate_at(
                                                    { mw_appPermissions(c_its_aid_GN) }
                                                )
                                            )
                                        )
                                    )
                                )
                    ))) {
                        tc_ac.stop;
                        log("*** " & testcasename() & ": PASS: Correct secured packet received, containing digest ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                    }
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: Expected message not received ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                    }
                } // End of 'alt' statement
                
                // Postamble
                f_acTriggerEvent(m_stopPassBeaconing);
                f_poNeighbour();
                f_cf01Down();
                
            } // End of testcase TC_SEC_ITSS_SND_GENMSG_04_BV
            
            /**
             * @desc    Check that IUT sends the secured GeoNetworking message 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 and PICS_SEC_ITS_AID_OTHER
             * 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 a secured Beacon
             *             containing certificate
             *     } 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_GENMSG_05_BV
             * @reference   ETSI TS 103 097 [1] Clauses 7.1.3
             * @reference   IEEE 1609.2 [2] Clause 6.3.4
             */
            testcase TC_SEC_ITSS_SND_GENMSG_05_BV() runs on ItsGeoNetworking system ItsSecSystem {
                    
                // Local variables
                const integer        c_timeLimit := 10 * 60 * 1000000; // us
                var LongPosVector v_longPosVectorIut;
                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;
                    
                // Test control
                if (not(PICS_GN_SECURITY) or not(PICS_SEC_ITS_AID_OTHER)) {
                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY and PICS_SEC_ITS_AID_OTHER' required for executing the TC ***");
                    stop;
                }
                
                // Test component configuration
                f_cf01Up(); // Initialise IUT with CERT_IUT_A_AT signed with CERT_IUT_A_AA
                v_longPosVectorIut := f_getPosition(c_compIut);
                    
                // Test adapter configuration
                
                // Preamble
                f_prNeighbour();
                f_acTriggerEvent(m_startPassBeaconing(m_beaconHeader(v_longPosVectorIut).beaconHeader)); // Authorize the TA to forward the received beacons
                alt {
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mw_etsiTs103097Data_signed(
                                    mw_signedData(
                                        -, 
                                        mw_toBeSignedData(
                                            mw_signedDataPayload,
                                            mw_headerInfo_gn
                                        ),
                                        mw_signerIdentifier_certificate // containing certificate
                                    )
                                )
                    ))) {
                        tc_ac.stop;
                        log("*** " & testcasename() & ": INFO: Initial conditions: First GN message with certificate received ***");
                        f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                    }
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: Initial conditions: GN message with certificate not received ***");
                        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_gn
                                        ),
                                        mw_signerIdentifier_certificate // containing certificate
                                    )
                                )
                    ))) -> 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: GN generation time is not in 5 min range");
                            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: GN certificate validity period is not in 5 min range");
                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                            } else {
                                log("*** " & testcasename() & ": PASS: Generation of GN 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_gn
                                        ),
                                        mw_signerIdentifier_digest // containing digest
                                    )
                                )
                    ))) {
                        log("*** " & testcasename() & ": PASS: Correct secured packet received, containing digest ***");
                        repeat;
                    }
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: Expected message not received ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                    }
                } // End of 'alt' statement
                
                // Postamble
                f_acTriggerEvent(m_stopPassBeaconing);
                f_poNeighbour();
                f_cf01Down();
                
            } // End of testcase TC_SEC_ITSS_SND_GENMSG_05_BV
            
            /**
             * @desc    Check that IUT sends the secured message using the 'data' field in signed data payload, 
             *          containing the EtsiTs103097Data of type unsecured, 
             *          containing the data payload or using the extDataHash field containing the SHA256 hash of data payload.
             * <pre>
             * Pics Selection: PICS_GN_SECURITY and PICS_SEC_ITS_AID_OTHER
             * 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 a secured Beacon
             *     } 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_GENMSG_06_BV
             * @reference   ETSI TS 103 097 [1] Clauses 7.1.3
             */
            testcase TC_SEC_ITSS_SND_GENMSG_06_BV() runs on ItsGeoNetworking system ItsSecSystem {
                    
                // Local variables
                var LongPosVector v_longPosVectorIut;
                    
                // Test control
                if (not(PICS_GN_SECURITY) or not(PICS_SEC_ITS_AID_OTHER)) {
                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY and PICS_SEC_ITS_AID_OTHER' required for executing the TC ***");
                    stop;
                }
                
                // Test component configuration
                f_cf01Up(); // Initialise IUT with CERT_IUT_A_AT signed with CERT_IUT_A_AA
                v_longPosVectorIut := f_getPosition(c_compIut);
                    
                // Test adapter configuration
                
                // Preamble
                f_prNeighbour();
                f_acTriggerEvent(m_startPassBeaconing(m_beaconHeader(v_longPosVectorIut).beaconHeader)); // Authorize the TA to forward the received beacons
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
                tc_ac.start;
                alt {
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mw_etsiTs103097Data_signed(
                                    mw_signedData(
                                        -, 
                                        mw_toBeSignedData(
                                            mw_signedDataPayload(
                                                mw_ieee1609Dot2Data(
                                                    mw_ieee1609Dot2Data_unsecured
                                            )),
                                            mw_headerInfo_gn
                                        )
                                    )
                                )
                    ))) {
                        tc_ac.stop;
                        log("*** " & testcasename() & ": PASS: GN received with a well formated payload ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                    }
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: Expected message not received ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                    }
                } // End of 'alt' statement
                
                // Postamble
                f_acTriggerEvent(m_stopPassBeaconing);
                f_poNeighbour();
                f_cf01Down();
                
            } // End of testcase TC_SEC_ITSS_SND_GENMSG_06_BV
            
            /**
             * @desc    Check that the IUT sends the secured messages signed with the certificate 
             *          containing appPermisions allowing to sign these messages.
             * <pre>
             * Pics Selection: PICS_GN_SECURITY and PICS_SEC_ITS_AID_OTHER
             * 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 a secured Beacon
             *     } 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_GENMSG_07_BV
             * @reference   ETSI TS 103 097 [1] Clauses 7.1.3
             * @reference   IEEE 1609.2 [2] Clause 5.2.3.2.2
             */
            testcase TC_SEC_ITSS_SND_GENMSG_07_BV() runs on ItsGeoNetworking system ItsSecSystem {
                    
                // Local variables
                var LongPosVector v_longPosVectorIut;
                    
                // Test control
                if (not(PICS_GN_SECURITY) or not(PICS_SEC_ITS_AID_OTHER)) {
                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY and PICS_SEC_ITS_AID_OTHER' required for executing the TC ***");
                    stop;
                }
                
                // Test component configuration
                f_cf01Up(); // Initialise IUT with CERT_IUT_A_AT signed with CERT_IUT_A_AA
                v_longPosVectorIut := f_getPosition(c_compIut);
                    
                // Test adapter configuration
                
                // Preamble
                f_prNeighbour();
                f_acTriggerEvent(m_startPassBeaconing(m_beaconHeader(v_longPosVectorIut).beaconHeader)); // Authorize the TA to forward the received beacons
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
                tc_ac.start;
                alt {
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mw_etsiTs103097Data_signed(
                                    mw_signedData(
                                        -, 
                                        mw_toBeSignedData(
                                            mw_signedDataPayload,
                                            mw_headerInfo_gn
                                        ),
                                        mw_signerIdentifier_digest // containing digest
                                    )
                                )
                    ))) {
                        tc_ac.stop;
                        log("*** " & testcasename() & ": PASS: Correct secured packet received, containing digest ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                    }
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mw_etsiTs103097Data_signed(
                                    mw_signedData(
                                        -, 
                                        mw_toBeSignedData(
                                            mw_signedDataPayload(
                                                mw_ieee1609Dot2Data(
                                                    mw_ieee1609Dot2Data_unsecured
                                            )),
                                            mw_headerInfo_gn
                                        )
                                    )
                                )
                    ))) {
                        tc_ac.stop;
                        log("*** " & testcasename() & ": PASS: received with a well formated payload ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                    }
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: Expected message not received ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                    }
                } // End of 'alt' statement
                
                // Postamble
                f_acTriggerEvent(m_stopPassBeaconing);
                f_poNeighbour();
                f_cf01Down();
                
            } // End of testcase TC_SEC_ITSS_SND_GENMSG_07_BV
                        
            /**
             * @desc    Check that IUT sends the secured GeoNetworking message containing signature;
             *          Check that the signature is calculated over the right fields and using right 
             *          hash algorythm by cryptographically verifying the signature.
             * <pre>
             * Pics Selection: PICS_GN_SECURITY and PICS_SEC_ITS_AID_OTHER
             * Config Id: CF01
             * Initial conditions:
             *  with {
             *      the IUT is authorized with AT certificate (X_CERTIFICATE) 
             *  }
             *  ensure that {
             *      when {
             *          the IUT is requested to send a secured beacon
             *      } then {
             *          the IUT sends a message of type EtsiTs103097Data
             *              containing signedData
             *                  containing signer
             *                       containing digest
             *                           referencing the certificate X_CERTIFICATE
             *                       or containing certificate
             *                           indicating X_CERTIFICATE
             *                  and containing signature
             *                      containing X_SIGNATURE
             *                          verifiable using KEY 
             *      }
             *  }
             * </pre>
             *
             * @see         ETSI TS 103 096-2 v1.3.2 TP_SEC_ITSS_SND_GENMSG_08_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_GENMSG_08_BV() runs on ItsGeoNetworking system ItsSecSystem {
                    
                // Local variables
                var LongPosVector           v_longPosVectorIut;
                var EtsiTs103097Certificate v_certificate;
                var Signature               v_signature;
                var GeoNetworkingInd        v_geoNwInd;
                    
                // Test control
                if (not(PICS_GN_SECURITY) or not(PICS_SEC_ITS_AID_OTHER)) {
                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY and PICS_SEC_ITS_AID_OTHER' required for executing the TC ***");
                    stop;
                }
                
                // Test component configuration
                vc_hashedId8ToBeUsed := PICS_CERTFICATE_ID_VARIANT;
                f_cf01Up();
                v_longPosVectorIut := f_getPosition(c_compIut);
                    
                // Test adapter configuration
                
                // Preamble
                f_prNeighbour();
                f_readCertificate(vc_hashedId8ToBeUsed, v_certificate);
                f_acTriggerEvent(m_startPassBeaconing(m_beaconHeader(v_longPosVectorIut).beaconHeader)); // Authorize the TA to forward the received beacons
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
                tc_ac.start;
                alt {
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mw_etsiTs103097Data_signed(
                                    mw_signedData(
                                        PICS_CERTFICATES_FOI[PICS_CERTFICATES_VAR].hashAlgorithm, 
                                        mw_toBeSignedData(
                                            mw_signedDataPayload,
                                            mw_headerInfo_gn
                                        ),
                                        mw_signerIdentifier_digest( // containing digest referencing the certificate X_CERTIFICATE
                                            PICS_CERTFICATES_FOI[PICS_CERTFICATES_VAR].issuer
                                        )
                                    )
                                )
                    ))) -> value v_geoNwInd {
                        tc_ac.stop;
                        log("*** " & testcasename() & ": INFO: GN message with digest received ***");
                    }
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mw_etsiTs103097Data_signed(
                                    mw_signedData(
                                        PICS_CERTFICATES_FOI[PICS_CERTFICATES_VAR].hashAlgorithm, 
                                        mw_toBeSignedData(
                                            mw_signedDataPayload,
                                            mw_headerInfo_gn
                                        ),
                                        mw_signerIdentifier_certificate( // or containing containing certificate indicating X_CERTIFICATE
                                            v_certificate
                                        )
                                    )
                                )
                    ))) -> value v_geoNwInd {
                        tc_ac.stop;
                        log("*** " & testcasename() & ": INFO: GN message with certificate received ***");
                    }
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: Expected message not received ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                    }
                } // End of 'alt' statement
                
                // Postamble
                f_acTriggerEvent(m_stopPassBeaconing);
                f_poNeighbour();
                f_cf01Down();
                
            } // End of testcase TC_SEC_ITSS_SND_GENMSG_08_BV
                        
        } // End of group genericSignedMessageProfile
         * @desc Sending behaviour test cases for certificates profile
         * @see ETSI TS 103 096-2 V1.3.32 (2018-01) Clause 5.2.7 Encrypted messages profile
        group encryptedMessagesProfile {
            
            /**
             * @desc    Check that the IUT can generate encrypted message.
             * <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 recipients
             *                     containing at least one item of type RecipientInfo
             *     }
             * }
             * </pre>
             *
             * @see         ETSI TS 103 096-2 v1.3.2 TP_SEC_ITSS_SND_ENC_01_BV
             * @reference   ETSI TS 103 097 [1], Clauses 5.3
             */
            testcase TC_SEC_ITSS_SND_ENC_01_BV() runs on ItsGeoNetworking system ItsSecSystem {
                    
                // Local variables
                    
                // 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
                    ))))) {
                        tc_ac.stop;
                        log("*** " & testcasename() & ": PASS: IUT sends encrypted data successfully ***");
                        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_01_BV
            
            /**
             * @desc    Check that the IUT can generate encrypted message.
             * <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
             *     }
             * }
             * </pre>
             *
             * @see         ETSI TS 103 096-2 v1.3.2 TP_SEC_ITSS_SND_ENC_02_BV
             * @reference   IEEE 1609.2 [2] Clause 6.3.31
             */
            testcase TC_SEC_ITSS_SND_ENC_02_BV() runs on ItsGeoNetworking system ItsSecSystem {
                    
                // Local variables
                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
                    ))))) -> value v_geoNwInd {
                        tc_ac.stop;
                        if (lengthof(f_getSecuredMessage(v_geoNwInd.msgIn).content.encryptedData.recipients) >= 1) {
                            log("*** " & testcasename() & ": PASS: IUT sends encrypted data successfully ***");
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                        } else {
                            log("*** " & testcasename() & ": FAIL: RecipientInfo list is empty ***");
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                        }
                    }
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: Expected message not received ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                    }
                } // End of 'alt' statement
                
                // Postamble
                f_poNeighbour();
                f_cf01Down();
                
            } // End of testcase TC_SEC_ITSS_SND_ENC_02_BV
            
            /**
             * @desc    Check that the IUT can generate encrypted message.
             * <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
             *     }
             * }
             * </pre>
             *
             * @see         ETSI TS 103 096-2 v1.3.2 TP_SEC_ITSS_SND_ENC_03_BV
             * @reference   IEEE 1609.2 [2] Clause 6.3.31
             */
            testcase TC_SEC_ITSS_SND_ENC_03_BV() runs on ItsGeoNetworking system ItsSecSystem {
                    
                // Local variables
                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 {
                    [PICS_SEC_NIST_P256 == true] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mw_etsiTs103097Data_encrypted(
                                    mw_encryptedData(
                                        { 
                                            mw_recipientInfo_certRecipInfo(
                                                mw_pKRecipientInfo(
                                                    -,
                                                    mw_encryptedDataEncryptionKey_eciesNistP256(
                                                        mw_evciesP256EncryptedKey
                                                    )
                                                )
                                            )
                                        },
                                        mw_SymmetricCiphertext_aes128ccm
                    ))))) -> value v_geoNwInd {
                        tc_ac.stop;
                        log("*** " & testcasename() & ": PASS: IUT sends encrypted data successfully ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                    }
                    [PICS_SEC_BRAINPOOL_P256R1 == true] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mw_etsiTs103097Data_encrypted(
                                    mw_encryptedData(
                                        { 
                                            mw_recipientInfo_certRecipInfo(
                                                mw_pKRecipientInfo(
                                                    -,
                                                    mw_encryptedDataEncryptionKey_eciesBrainpoolP256r1(
                                                        mw_evciesP256EncryptedKey
                                                    )
                                                )
                                            )
                                        },
                                        mw_SymmetricCiphertext_aes128ccm
                    ))))) -> value v_geoNwInd {
                        tc_ac.stop;
                        log("*** " & testcasename() & ": PASS: IUT sends encrypted data successfully ***");
                        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_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
                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;
                        
                        if (f_decrypt(f_getSecuredMessage(v_geoNwInd.msgIn), v_decryptedMsg) == false) {
                            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
                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;
                        
                        if (f_decrypt(f_getSecuredMessage(v_geoNwInd.msgIn), v_decryptedMsg) == false) {
                            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