ItsSecurity_TestCases.ttcn 1.59 MB
Newer Older
                                        )
                                    )
                                ), 
                                mw_geoNwShbPacket
                    ))) -> value v_geoNwInd {
                        tc_ac.stop;
                        log("*** " & testcasename() & ": PASS: Message with well-formated signature received ***");
                        f_selfOrClientSyncAndVerdictPreamble(c_tbDone, e_success);
                    }
                    [PICS_SEC_BRAINPOOL_P256R1 == true] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mw_etsiTs103097Data_signed(
                                    mw_signedData(
                                        -, 
                                        mw_toBeSignedData(
                                            mw_signedDataPayload,
                                            mw_headerInfo_cam
                                        ),
                                        mw_signerIdentifier_certificate(
                                            mw_etsiTs103097Certificate(
                                                -,
                                                mw_toBeSignedCertificate_at(
                                                    -, -, -, -, -,
                                                    mw_encryptionKey(
                                                        -,
                                                        mw_publicEncryptionKey_eciesBrainpoolP256r1(
                                                            mw_eccP256CurvePoint_compressed_y_0
                                                        )
                                                    )
                                                )
                                            )
                                        )
                                    )
                                ), 
                                mw_geoNwShbPacket
                    ))) -> value v_geoNwInd {
                        tc_ac.stop;
                        log("*** " & testcasename() & ": PASS: Message with well-formated signature received ***");
                        f_selfOrClientSyncAndVerdictPreamble(c_tbDone, e_success);
                    }
                    [PICS_SEC_BRAINPOOL_P256R1 == true] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mw_etsiTs103097Data_signed(
                                    mw_signedData(
                                        -, 
                                        mw_toBeSignedData(
                                            mw_signedDataPayload,
                                            mw_headerInfo_cam
                                        ),
                                        mw_signerIdentifier_certificate(
                                            mw_etsiTs103097Certificate(
                                                -,
                                                mw_toBeSignedCertificate_at(
                                                    -, -, -, -, -,
                                                    mw_encryptionKey(
                                                        -,
                                                        mw_publicEncryptionKey_eciesBrainpoolP256r1(
                                                            mw_eccP256CurvePoint_compressed_y_1
                                                        )
                                                    )
                                                )
                                            )
                                        )
                                    )
                                ), 
                                mw_geoNwShbPacket
                    ))) -> value v_geoNwInd {
                        tc_ac.stop;
                        log("*** " & testcasename() & ": PASS: Message with well-formated signature received ***");
                        f_selfOrClientSyncAndVerdictPreamble(c_tbDone, e_success);
                    }
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mw_etsiTs103097Data_signed(
                                    mw_signedData(
                                        -, 
                                        mw_toBeSignedData(
                                            mw_signedDataPayload,
                                            mw_headerInfo_cam
                                        ),
                                        mw_signerIdentifier_certificate(
                                            mw_etsiTs103097Certificate(
                                                -,
                                                mw_toBeSignedCertificate_at
                                            )
                                        )
                                    )
                                ), 
                                mw_geoNwShbPacket
                    ))) -> value v_geoNwInd {
                        tc_ac.stop;
                        log("*** " & testcasename() & ": FAIL: Message with wrong signature received ***");
                        f_selfOrClientSyncAndVerdictPreamble(c_tbDone, e_error);
                    }
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mw_etsiTs103097Data_signed(
                                    mw_signedData(
                                        -, 
                                        mw_toBeSignedData(
                                            mw_signedDataPayload,
                                            mw_headerInfo_cam
                                        ),
                                        mw_signerIdentifier_digest
                                    )
                                ), 
                                mw_geoNwShbPacket
                    ))) -> value v_geoNwInd {
                        repeat;
                    }
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: Message with certificate not received ***");
                        f_selfOrClientSyncAndVerdictPreamble(c_tbDone, e_timeout);
                    }
                } // End of 'alt' statement
                
                // Postamble
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_ITSS_SND_CERT_14_BV
            
            /**
             * @desc    Check the certificate signature.
             * <pre>
             * Pics Selection: PICS_GN_SECURITY
             * Config Id: CF01
             * Initial conditions:
             *  with {
             *      the CA is authorized with AA certificate 
             *          containing toBeSigned
             *              containing verifyKeyIndicator
             *                  containing verificationKey
             *                      containing X_KEY
             *  }
             * Expected behaviour:
             * ensure that {
             *     when { 
             *         the IUT issued the AT certificate 
             *     } then {
             *         this certificate is of type EtsiTs103097Certificate
             *             containing issuer
             *                referencing the certificate
             *                    containing toBeSigned
             *                        containing verifyKeyIndicator
             *                            containing verificationKey
             *                                containing X_KEY
             *                                    indicating KEY
             *             and containing signature
             *                containing X_SIGNATURE
             *                    verifiable using KEY
             *     }
             * }
             * </pre>
             *
             * @see         ETSI TS 103 096-2 v1.3.2 TP_SEC_ITSS_SND_CERT_15_BV
             * @reference   ETSI TS 103 097 [1], Clauses 6
             */
            testcase TC_SEC_ITSS_SND_CERT_15_BV() runs on ItsGeoNetworking system ItsSecSystem {
                    
                // Local variables
                var SequenceOfCertificate v_aa_certificate;
                var SignerIdentifier      v_signerIdentifier;
                var GeoNetworkingInd      v_geoNwInd;
                
                // Test control
                if (not(PICS_GN_SECURITY)) {
                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY' required for executing the TC ***");
                    stop;
                }
                
                // Test component configuration
                vc_hashedId8ToBeUsed := PICS_CERTFICATE_ID_VARIANT;
                f_cf01Up();
                    
                // Test adapter configuration
                
                // Preamble
                f_prNeighbour();
                log("*** " & testcasename() & ": INFO: Wait for certificate and ask for AA certificate ***");
                tc_ac.start;
                f_askAndWaitForCertificateChain(v_aa_certificate, f_generateDefaultCam());
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
                tc_ac.start;
                alt {
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mw_etsiTs103097Data_signed(
                                    mw_signedData(
                                        -, 
                                        mw_toBeSignedData(
                                            mw_signedDataPayload,
                                            mw_headerInfo_cam
                                        ),
                                        mw_signerIdentifier_certificate( // Get the AT certificate
                                            mw_etsiTs103097Certificate(
                                                -,
                                                mw_toBeSignedCertificate_at
                    ))))))) -> value v_geoNwInd {
                        tc_ac.stop;
                        if (f_getMsgSignerIdentifier(f_getSecuredMessage(v_geoNwInd.msgIn), v_signerIdentifier)) {
                            if (f_verifyCertificateSignatureWithIssuingCertificate(v_signerIdentifier.certificate[0], v_aa_certificate[0]) == true) {
                                log("*** " & testcasename() & ": PASS: AT certificate is signed by AA certificate ***");
                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                            } else {
                                log("*** " & testcasename() & ": FAIL: AT/AA certificate signature mismatch ***");
                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                            }
                        } else {
                            log("*** " & testcasename() & ": FAIL: IMPOSSIBLE!!! CAM generation location or certificate region restriction header field does not exist ***"); 
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                        }
                    }
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mw_etsiTs103097Data_signed(
                                    mw_signedData(
                                        -, 
                                        mw_toBeSignedData(
                                            mw_signedDataPayload,
                                            mw_headerInfo_cam
                                        ),
                                        mw_signerIdentifier_digest // containing digest
                                    )
                                )
                    ))) {
                        log("*** " & testcasename() & ": INFO: Generation of CAM messages including digest ***");
                        repeat;
                    }
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: Expected message not received ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                    }
                } // End of 'alt' statement
                
                // Postamble
                f_poNeighbour();
                f_cf01Down();
                
            } // End of testcase TC_SEC_ITSS_SND_CERT_15_BV
            
            /**
             * @desc    Check the certificate signature.
             * <pre>
             * Pics Selection: PICS_GN_SECURITY
             * Config Id: CF01
             * Initial conditions:
             *  with {
             *      the CA is authorized with AA certificate 
             *          containing toBeSigned
             *              containing verifyKeyIndicator
             *                  containing verificationKey
             *                      containing X_KEY
             *  }
             * Expected behaviour:
             * ensure that {
             *     when { 
             *         the IUT issued the AT certificate 
             *     } then {
             *         this certificate is of type EtsiTs103097Certificate
             *             containing issuer
             *                referencing the certificate
             *                    containing toBeSigned
             *                        containing verifyKeyIndicator
             *                            containing verificationKey
             *                                containing X_KEY
             *                                    indicating KEY
             *             and containing signature
             *                containing X_SIGNATURE
             *                    verifiable using KEY
             *     }
             * }
             * </pre>
             *
             * @see         ETSI TS 103 096-2 v1.3.2 TP_SEC_ITSS_SND_CERT_16_BV
             * @reference   ETSI TS 103 097 [1], Clauses 6
             */
            testcase TC_SEC_ITSS_SND_CERT_16_BV() runs on ItsGeoNetworking system ItsSecSystem {
                    
                // Local variables
                var SequenceOfCertificate v_aa_certificate;
                var SignerIdentifier      v_signerIdentifier;
                var GeoNetworkingInd      v_geoNwInd;
                
                // Test control
                if (not(PICS_GN_SECURITY)) {
                    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_askAndWaitForCertificateChain(v_aa_certificate, f_generateDefaultCam());
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
                tc_ac.start;
                alt {
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mw_etsiTs103097Data_signed(
                                    mw_signedData(
                                        -, 
                                        mw_toBeSignedData(
                                            mw_signedDataPayload,
                                            mw_headerInfo_cam
                                        ),
                                        mw_signerIdentifier_certificate( // Get the AT certificate
                                            mw_etsiTs103097Certificate(
                                                -,
                                                mw_toBeSignedCertificate_at
                    ))))))) -> value v_geoNwInd {
                        tc_ac.stop;
                        if (f_getMsgSignerIdentifier(f_getSecuredMessage(v_geoNwInd.msgIn), v_signerIdentifier)) {
                            var integer v_counter;
                            var charstring v_psid;
                            var template charstring v_found_pattern; // Used in regex to verify that 'v_psid' was not found before
                            
                            // Check in AA certificate
                            var charstring v_psid_found_aa := ";"; // Used to build the list of the Psid already processed
                            
                            for (v_counter := 0; v_counter < lengthof(v_aa_certificate[0].toBeSigned.appPermissions); v_counter := v_counter + 1) {
                                v_psid := int2str(v_aa_certificate[0].toBeSigned.appPermissions[v_counter].psid);
                                v_found_pattern := pattern "*({v_psid})*";
                                if (regexp(v_psid_found_aa, v_found_pattern, 0) == v_psid) {
                                    break; // v_psid exist at least 2 times, uniqueness is not verified
                                }
                                v_psid_found_aa := v_psid_found_aa & v_psid & ";";
                            } // End of 'for' statement
                            if (v_counter == lengthof(v_aa_certificate[0].toBeSigned.appPermissions)) {
                                var charstring v_psid_found_at := ";"; // Used to build the list of the Psid already processed
                                
                                for (v_counter := 0; v_counter < lengthof(v_signerIdentifier.certificate[0].toBeSigned.appPermissions); v_counter := v_counter + 1) {
                                    v_psid := int2str(v_signerIdentifier.certificate[0].toBeSigned.appPermissions[v_counter].psid);
                                    v_found_pattern := pattern "*({v_psid})*";
                                    if (regexp(v_psid_found_at, v_found_pattern, 0) == v_psid) {
                                        log("*** " & testcasename() & ": FAIL: AT certificate contains duplicated Psid ***"); 
                                        break; // v_psid exist at least 2 times, uniqueness is not verified
                                    } else if (regexp(v_psid_found_aa, v_found_pattern, 0) == v_psid) {
                                        log("*** " & testcasename() & ": FAIL: AT certificate contains a Psid not contained in AA certificate ***"); 
                                        break;
                                    }
                                    v_psid_found_at := v_psid_found_at & v_psid & ";";
                                } // End of 'for' statement
                                if (v_counter == lengthof(v_signerIdentifier.certificate[0].toBeSigned.appPermissions)) {
                                    log("*** " & testcasename() & ": PASS: Psid are unique in certificates ***"); 
                                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                                } else {
                                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                                }
                            } else {
                                log("*** " & testcasename() & ": FAIL: AA certificate contains duplicated Psid ***"); 
                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                            }
                        } else {
                            log("*** " & testcasename() & ": FAIL: IMPOSSIBLE!!! CAM generation location or certificate region restriction header field does not exist ***"); 
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                        }
                    }
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mw_etsiTs103097Data_signed(
                                    mw_signedData(
                                        -, 
                                        mw_toBeSignedData(
                                            mw_signedDataPayload,
                                            mw_headerInfo_cam
                                        ),
                                        mw_signerIdentifier_digest // containing digest
                                    )
                                )
                    ))) {
                        log("*** " & testcasename() & ": INFO: Generation of CAM messages including digest ***");
                        repeat;
                    }
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: Expected message not received ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                    }
                } // End of 'alt' statement
                
                // Postamble
                f_poNeighbour();
                f_cf01Down();
                
            } // End of testcase TC_SEC_ITSS_SND_CERT_16_BV
            
            /**
             * @desc    Check that IUT supports at least 8 items in the appPermissions component of the certificate.
             * <pre>
             * Pics Selection: PICS_GN_SECURITY
             * Config Id: CF01
             * Initial conditions:
             *  with {
             *      the IUT is authorized with AT certificate (CERT_IUT_A_AT_A8)
             *          containing toBeSigned
             *              containing appPermissions
             *                  containing 8 entries
             *                      indicating the last item
             *                          containing psid
             *                              indicating the ‘AID_CAM’
             *  }
             * Expected behaviour:
             * ensure that {
             *     when { 
             *         the IUT is requested to send a secured CAM
             *     } then {
             *         this certificate is of type EtsiTs103097Certificate
             *             containing containing content
             *                containing signedData
             *                    containing tbsData
             *                        containing headerInfo
             *                            containing psid
             *                                indicating 'AID_CAM'
             *     }
             * }
             * </pre>
             *
             * @see         ETSI TS 103 096-2 v1.3.2 TP_SEC_ITSS_SND_CERT_17_BV
             * @reference   ETSI TS 103 097 [1], Clauses 6
             */
            testcase TC_SEC_ITSS_SND_CERT_17_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
                vc_hashedId8ToBeUsed := PICS_CERTFICATE_ID_VARIANT; // FIXME
                f_cf01Up();
                    
                // Test adapter configuration
                
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
                tc_ac.start;
                alt {
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mw_etsiTs103097Data_signed(
                                    mw_signedData(
                                        -, 
                                        mw_toBeSignedData(
                                            mw_signedDataPayload,
                                            mw_headerInfo_cam
                                        )
                    ))))) {
                        tc_ac.stop;
                        log("*** " & testcasename() & ": PASS: ATS_AID was received ***"); 
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                    }
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: Expected message not received ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                    }
                } // End of 'alt' statement
                
                // Postamble
                f_poNeighbour();
                f_cf01Down();
                
            } // End of testcase TC_SEC_ITSS_SND_CERT_17_BV
            
            /**
             * @desc    Check that all PSID entries of the certIssuePermissions component of the certificate are unique.
             * <pre>
             * Pics Selection: PICS_GN_SECURITY
             * Config Id: CF01
             * Initial conditions:
             *  with {
             *      
             *  }
             * Expected behaviour:
             * ensure that {
             *     when { 
             *         the IUT issued the certificate 
             *             containing toBeSigned
             *                 containing certIssuePermissions
             *     } then {
             *         this certificate is of type EtsiTs103097Certificate
             *             containing toBeSigned
             *                 containing certIssuePermissions
             *                     containing items of type PsidGroupPermissions
             *                     and containing subjectPermissions
             *                         containing explicit
             *                             containing items of type PsidSspRange
             *                                 containing psid
             *                                     indicating unique values in this sequence
             *     }
             * }
             * </pre>
             *
             * @see         ETSI TS 103 096-2 v1.3.2 TP_SEC_ITSS_SND_CERT_18_BV
             * @reference   ETSI TS 103 097 [1], Clauses 6.4.28 & 5.1.2.4
             */
            testcase TC_SEC_ITSS_SND_CERT_18_BV() runs on ItsGeoNetworking system ItsSecSystem {
                    
                // Local variables
                var SequenceOfCertificate v_aa_certificate;
                var integer v_counter;
                var integer v_counter1;
                var charstring v_psid;
                var charstring v_psid_found_aa := ";"; // Used to build the list of the Psid already processed
                var template charstring v_found_pattern; // Used in regex to verify that 'v_psid' was not found before
                
                // 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_askAndWaitForCertificateChain(v_aa_certificate, f_generateDefaultCam());
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
                if (not(ispresent(v_aa_certificate[0].toBeSigned.certIssuePermissions))) {
                    log("*** " & testcasename() & ": FAIL: PsidGroupPermissions required in AA certificate ***"); 
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                } else {
                    for (v_counter := 0; v_counter < lengthof(v_aa_certificate[0].toBeSigned.certIssuePermissions); v_counter := v_counter + 1) {
                        if (match(v_aa_certificate[0].toBeSigned.certIssuePermissions[v_counter], mw_psidGroupPermissions(mw_subjectPermissions_explicit)) == false){
                            break;
                        }
                        for (v_counter1 := 0; v_counter1 < lengthof(v_aa_certificate[0].toBeSigned.certIssuePermissions[v_counter].subjectPermissions.explicit); v_counter1 := v_counter1 + 1) {
                            v_psid := int2str(v_aa_certificate[0].toBeSigned.certIssuePermissions[v_counter].subjectPermissions.explicit[v_counter1].psid);
                            v_found_pattern := pattern "*({v_psid})*";
                            if (regexp(v_psid_found_aa, v_found_pattern, 0) == v_psid) {
                                break; // v_psid exist at least 2 times, uniqueness is not verified
                            }
                            v_psid_found_aa := v_psid_found_aa & v_psid & ";";
                        } // End of 'for' statement
                        if (v_counter < lengthof(v_aa_certificate[0].toBeSigned.certIssuePermissions[v_counter].subjectPermissions.explicit)) {
                            break;
                        }
                    } // End of 'for' statement
                    if (v_counter == lengthof(v_aa_certificate[0].toBeSigned.certIssuePermissions)) {
                        log("*** " & testcasename() & ": PASS: Psid are unique in certificates ***"); 
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                    } else {
                        log("*** " & testcasename() & ": FAIL: Wrong PsidGroupPermissions in AA certificate ***"); 
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                    }
                }
                
                // Postamble
                f_poNeighbour();
                f_cf01Down();
                
            } // End of testcase TC_SEC_ITSS_SND_CERT_18_BV
            
            /**
             * @desc    Check that IUT supports at least 8 items in the certIssuePermissions component of the certificate.
             * <pre>
             * Pics Selection: PICS_GN_SECURITY
             * Config Id: CF01
             * Initial conditions:
             *  with {
             *      the IUT is authorized with AT certificate (CERT_IUT_A_AT_A8)
             *          containing appPermissions
             *              conformed to the certIssuePermissions
             *          issued by AA certificate (CERT_IUT_A_AA_C8)
             *              containing toBeSigned
             *                  containing certIssuePermissions
             *                      containing 8 entries
             *                          indicating the last item
             *                              containing psid
             *                                  indicating the ‘AID_CAM’
             *  }
             * Expected behaviour:
             * ensure that {
             *     when { 
             *         the IUT is requested to send a secured CAM
             *     } then {
             *         this certificate is of type EtsiTs103097Certificate
             *             containing containing content
             *                containing signedData
             *                    containing tbsData
             *                        containing headerInfo
             *                            containing psid
             *                                indicating 'AID_CAM'
             *     }
             * }
             * </pre>
             *
             * @see         ETSI TS 103 096-2 v1.3.2 TP_SEC_ITSS_SND_CERT_19_BV
             * @reference   ETSI TS 103 097 [1], Clauses 6.4.8
             */
            testcase TC_SEC_ITSS_SND_CERT_19_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
                vc_hashedId8ToBeUsed := PICS_CERTFICATE_ID_VARIANT; // FIXME
                f_cf01Up();
                    
                // Test adapter configuration
                
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
                tc_ac.start;
                alt {
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mw_etsiTs103097Data_signed(
                                    mw_signedData(
                                        -, 
                                        mw_toBeSignedData(
                                            mw_signedDataPayload,
                                            mw_headerInfo_cam
                                        )
                    ))))) {
                        tc_ac.stop;
                        log("*** " & testcasename() & ": PASS: ATS_AID was received ***"); 
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                    }
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: Expected message not received ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                    }
                } // End of 'alt' statement
                
                // Postamble
                f_poNeighbour();
                f_cf01Down();
                
            } // End of testcase TC_SEC_ITSS_SND_CERT_19_BV
             * @desc    Check that all PSID entries of the appPermissions component of the certificate are also 
             *          contained in the certIssuePermissions component in the issuing certificate.
             * <pre>
             * Pics Selection: PICS_GN_SECURITY
             * Config Id: CF01
             * Initial conditions:
             *  with {
             *  }
             * Expected behaviour:
             * ensure that {
             *     when { 
             *         the IUT issued the certificate 
             *             containing toBeSigned
             *                 containing certIssuePermissions
             *     } then {
             *         this certificate is of type EtsiTs103097Certificate
             *             containing issuer
             *                 referenced to the certificate
             *                     containing toBeSigned
             *                         containing certIssuePermissions
             *                             containing items of type PsidGroupPermissions
             *                                 containing eeType
             *                                     indicating app(0)
             *                                 and containing subjectPermissions
             *                                     containing explicit
             *                                         containing items of type PsidSspRange
             *                                             indicating X_PSID_RANGE_LIST
             *                                     or containing all
             *             and containing toBeSigned
             *                 containing appPermissions
             *                    containing items of type PsidSsp
             *                        containing psid
             *                            contained in the X_PSID_RANGE_LIST
             *                                as a psid
             * @see         ETSI TS 103 096-2 v1.3.2 TP_SEC_ITSS_SND_CERT_20_BV
             * @reference   ETSI TS 103 097 [1], Clauses 6.4.28 & 5.1.2.4
            testcase TC_SEC_ITSS_SND_CERT_20_BV() runs on ItsGeoNetworking system ItsSecSystem {
                    
                // Local variables
                var SequenceOfCertificate v_aa_certificate;
                var SignerIdentifier      v_signerIdentifier;
                var GeoNetworkingInd      v_geoNwInd;
                
                // Test control
                if (not(PICS_GN_SECURITY)) {
                    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_askAndWaitForCertificateChain(v_aa_certificate, f_generateDefaultCam());
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                // Test Body
                tc_ac.start;
                alt {
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mw_etsiTs103097Data_signed(
                                    mw_signedData(
                                        -, 
                                        mw_toBeSignedData(
                                            mw_signedDataPayload,
                                            mw_headerInfo_cam
                                        ),
                                        mw_signerIdentifier_certificate( // Get the AT certificate
                                            mw_etsiTs103097Certificate(
                                                -,
                                                mw_toBeSignedCertificate_at
                    ))))))) -> value v_geoNwInd {
                        tc_ac.stop;
                        if (f_getMsgSignerIdentifier(f_getSecuredMessage(v_geoNwInd.msgIn), v_signerIdentifier)) {
                            var integer v_counter;
                            var integer v_counter1;
                            var charstring v_psid;
                            var charstring v_psid_found_aa := ";"; // Used to build the list of the Psid already processed
                            var template charstring v_found_pattern; // Used in regex to verify that 'v_psid' was not found before
                            
                            // Check in AA certificate
                            if (not(ispresent(v_aa_certificate[0].toBeSigned.certIssuePermissions))) {
                                log("*** " & testcasename() & ": FAIL: PsidGroupPermissions required in AA certificate ***"); 
                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                            } else {
                                for (v_counter := 0; v_counter < lengthof(v_aa_certificate[0].toBeSigned.certIssuePermissions); v_counter := v_counter + 1) {
                                    if (match(v_aa_certificate[0].toBeSigned.certIssuePermissions[v_counter], mw_psidGroupPermissions(mw_subjectPermissions_explicit)) == false){
                                        break;
                                    }
                                    for (v_counter1 := 0; v_counter1 < lengthof(v_aa_certificate[0].toBeSigned.certIssuePermissions[v_counter].subjectPermissions.explicit); v_counter1 := v_counter1 + 1) {
                                        v_psid := int2str(v_aa_certificate[0].toBeSigned.certIssuePermissions[v_counter].subjectPermissions.explicit[v_counter1].psid);
                                        v_found_pattern := pattern "*({v_psid})*";
                                        if (regexp(v_psid_found_aa, v_found_pattern, 0) == v_psid) {
                                            break; // v_psid exist at least 2 times, uniqueness is not verified
                                        }
                                        v_psid_found_aa := v_psid_found_aa & v_psid & ";";
                                    } // End of 'for' statement
                                    if (v_counter < lengthof(v_aa_certificate[0].toBeSigned.certIssuePermissions[v_counter].subjectPermissions.explicit)) {
                                        break;
                                    }
                                } // End of 'for' statement
                                if (v_counter == lengthof(v_aa_certificate[0].toBeSigned.certIssuePermissions)) {
                                    /*var charstring v_psid_found_at := ";"; // Used to build the list of the Psid already processed
                                    
                                    for (v_counter := 0; v_counter < lengthof(v_signerIdentifier.certificate[0].toBeSigned.appPermissions); v_counter := v_counter + 1) {
                                        v_psid := int2str(v_signerIdentifier.certificate[0].toBeSigned.appPermissions[v_counter].psid);
                                        v_found_pattern := pattern "*({v_psid})*";
                                        if (regexp(v_psid_found_at, v_found_pattern, 0) == v_psid) {
                                            log("*** " & testcasename() & ": FAIL: AT certificate contains duplicated Psid ***"); 
                                            break; // v_psid exist at least 2 times, uniqueness is not verified
                                        } else if (regexp(v_psid_found_aa, v_found_pattern, 0) == v_psid) {
                                            log("*** " & testcasename() & ": FAIL: AT certificate contains a Psid not contained in AA certificate ***"); 
                                            break;
                                        }
                                        v_psid_found_at := v_psid_found_at & v_psid & ";";
                                    } // End of 'for' statement
                                    if (v_counter == lengthof(v_signerIdentifier.certificate[0].toBeSigned.appPermissions)) {
                                        log("*** " & testcasename() & ": PASS: Psid are unique in certificates ***"); 
                                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                                    } else {
                                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                                    }*/

                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    log("*** " & testcasename() & ": PASS: Psid are unique in certificates ***"); 
                                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                                } else {
                                    log("*** " & testcasename() & ": FAIL: Wrong PsidGroupPermissions in AA certificate ***"); 
                                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                                }
                            }
                        } else {
                            log("*** " & testcasename() & ": FAIL: IMPOSSIBLE!!! CAM generation location or certificate region restriction header field does not exist ***"); 
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                        }
                    }
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mw_etsiTs103097Data_signed(
                                    mw_signedData(
                                        -, 
                                        mw_toBeSignedData(
                                            mw_signedDataPayload,
                                            mw_headerInfo_cam
                                        ),
                                        mw_signerIdentifier_digest // containing digest
                                    )
                                )
                    ))) {
                        log("*** " & testcasename() & ": INFO: Generation of CAM messages including digest ***");
                        repeat;
                    }
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: Expected message not received ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                    }
                } // End of 'alt' statement
                
                // Postamble
                f_poNeighbour();
                f_cf01Down();
                
            } // End of testcase TC_SEC_ITSS_SND_CERT_20_BV
             * @desc    Check that SSP field in each entry of the appPermissions component of the AT certificate is 
             *          equal to or a subset of the SSP Range in the corresponding issuing entry.
             * <pre>
             * Pics Selection: PICS_GN_SECURITY
             * Config Id: CF01
             * Initial conditions:
             *  with {
             *  }
             * Expected behaviour:
             * ensure that {
             *     when { 
             *         the IUT issued the certificate 
             *             containing toBeSigned
             *                 containing certIssuePermissions
             *     } then {
             *         this certificate is of type EtsiTs103097Certificate
             *             containing issuer
             *                 referenced to the certificate
             *                     containing toBeSigned
             *                         containing certIssuePermissions
             *                             containing items of type PsidGroupPermissions
             *                                 containing eeType
             *                                     indicating app(0)
             *                                 and containing explicit
             *                                     containing psid
             *                                         indicating X_PSID_AA
             *                                     and containing sspRange
             *                                         indicating X_SSP_AA [ X_PSID_AA ]
             *                                 or containing all
             *             and containing toBeSigned
             *                 containing appPermissions
             *                    containing items of type PsidSsp
             *                        containing psid
             *                            indicating value equal to X_PSID_AA
             *                        and containing ssp
             *                            indicating value permitted by X_SSP_AA [ X_PSID_AA ]
             * @see         ETSI TS 103 096-2 v1.3.2 TP_SEC_ITSS_SND_CERT_21_BV
             * @reference   ETSI TS 103 097 [1], Clauses 6.4.28 & 5.1.2.4
            testcase TC_SEC_ITSS_SND_CERT_21_BV() runs on ItsGeoNetworking system ItsSecSystem {
                    
                // Local variables
                var SequenceOfCertificate v_aa_certificate;
                var SignerIdentifier      v_signerIdentifier;
                var GeoNetworkingInd      v_geoNwInd;
                
                // Test control
                if (not(PICS_GN_SECURITY)) {
                    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_askAndWaitForCertificateChain(v_aa_certificate, f_generateDefaultCam());
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                // Test Body
                tc_ac.start;
                alt {
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mw_etsiTs103097Data_signed(
                                    mw_signedData(
                                        -, 
                                        mw_toBeSignedData(
                                            mw_signedDataPayload,
                                            mw_headerInfo_cam
                                        ),
                                        mw_signerIdentifier_certificate( // Get the AT certificate
                                            mw_etsiTs103097Certificate(
                                                -,
                                                mw_toBeSignedCertificate_at
                    ))))))) -> value v_geoNwInd {
                        tc_ac.stop;
                        if (f_getMsgSignerIdentifier(f_getSecuredMessage(v_geoNwInd.msgIn), v_signerIdentifier)) {
                            // Check in AA certificate
                            if (not(ispresent(v_aa_certificate[0].toBeSigned.certIssuePermissions))) {
                                log("*** " & testcasename() & ": FAIL: PsidGroupPermissions required in AA certificate ***"); 
                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                            } else { // Parse AT SSP and compared it in AA
                                for (var integer v_counter := 0; v_counter < lengthof(v_signerIdentifier.certificate[0].toBeSigned.appPermissions); v_counter := v_counter + 1) {
                                    var Psid v_psid := v_signerIdentifier.certificate[0].toBeSigned.appPermissions[v_counter].psid;
                                    var ServiceSpecificPermissions v_ssp := v_signerIdentifier.certificate[0].toBeSigned.appPermissions[v_counter].ssp;
                                    for (var integer v_counter1 := 0; v_counter1 < lengthof(v_aa_certificate[0].toBeSigned.certIssuePermissions); v_counter1 := v_counter1 + 1) {
                                        var SequenceOfPsidSspRange v_psidSsps;
                                        var integer v_counter2;
                                        if (match(v_aa_certificate[0].toBeSigned.certIssuePermissions[v_counter], mw_psidGroupPermissions(mw_subjectPermissions_explicit)) == false){
                                            log("*** " & testcasename() & ": FAIL: AA  certificate field certIssuePermissions does not match ***");
                                            f_setVerdict(e_error);
                                            break;
                                        }
                                        v_psidSsps := v_aa_certificate[0].toBeSigned.certIssuePermissions[v_counter1].subjectPermissions.explicit;
                                        for (v_counter2 := 0; v_counter2 < lengthof(v_psidSsps); v_counter2 := v_counter2 + 1) {
                                            if (v_psidSsps[v_counter2].psid == v_psid) {
                                                if (ispresent(v_psidSsps[v_counter2].sspRange)) {
                                                    var SspRange v_sspRange := v_psidSsps[v_counter2].sspRange;
                                                    // Compare SSps
                                                    log(" Compare '", v_sspRange, "' with '", v_ssp, "'");
                                                    if (not(ischosen(v_sspRange.all_))) {
                                                        if (ischosen(v_sspRange.opaque) and ischosen(v_ssp.opaque)) {
                                                            // TODO How to compare values?
                                                        } else if (ischosen(v_sspRange.bitmapSspRange) and ischosen(v_ssp.bitmapSsp)) {
                                                            // TODO How to compare values?
                                                        } else {
                                                            log("*** " & testcasename() & ": FAIL: SSPs do not match ***");
                                                            f_setVerdict(e_error);
                                                            break;
                                                        }
                                                    } // else All rights are sey, nothing to check
                                                } else {
                                                    log("*** " & testcasename() & ": FAIL: AA certificate field SspRange field is missging ***");
                                                    f_setVerdict(e_error);
                                                    break;
                                                }
                                                break;
                                            }
                                        } // End of 'for' statement
                                        if (v_counter2 == lengthof(v_psidSsps)) { // Psid not found
                                            log("*** " & testcasename() & ": FAIL: psid ", v_psid, " not found in AT certificate ***");
                                            f_setVerdict(e_error);
                                            break;
                                        }