ItsSecurity_TestCases.ttcn 1.58 MB
Newer Older
             *                              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_CERTFICATES_FOI[PICS_CERTFICATES_VAR].certificate_id;
                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 sendOtherProfile
         * @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;
                        
                        
                        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);
                        }
                    }
                    [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;
                        
                        
                        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_03_BV
            
            // TODO
            
        } // 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 sendCertificatesProfile {
            
            /**
             * @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