ItsSecurity_TestCases.ttcn3 510 KB
Newer Older
                // Test Body
                log("*** " & testcasename() & ": INFO: Request and waiting for the message containing certificate chain  ***");
                tc_ac.start;
                if (not f_askAndWaitForCertificateChain(v_chain, f_generateDefaultCam())) {
                    log("*** " & testcasename() & ": INCONC: Expected message not received ***");
                    f_selfOrClientSyncAndVerdictPreamble(c_tbDone, e_timeout);
                }
                tc_ac.stop;
                if (lengthof(v_chain) < 2) {
                    log("*** " & testcasename() & ": FAIL: Certificate chain is too short ***");
                    f_selfOrClientSyncAndVerdictPreamble(c_tbDone, e_error);
                }
                v_aa_cert := v_chain[lengthof(v_chain) - 2];
                if (f_getCertificateSubjectAttribute(v_aa_cert, e_its_aid_list, v_sa)) {
                    
                    if (lengthof(v_sa.attribute.its_aid_list) > 31) {
                        log("*** " & testcasename() & ": FAIL: ITS-AID list contains " & int2str(lengthof(v_sa.attribute.its_aid_list)) & " items (>31) ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                    }
                    
                    for (var integer v_counter :=0; v_counter < lengthof(v_sa.attribute.its_aid_list); v_counter := v_counter + 1) {
                        for (var integer j :=0; j < lengthof(v_sa.attribute.its_aid_list); j := j + 1) {
                            if (v_counter != j and v_sa.attribute.its_aid_list[v_counter] == v_sa.attribute.its_aid_list[j]) {
                                log("*** " & testcasename() & ": FAIL: ITS-AID " & int2str(v_sa.attribute.its_aid_list[j]) & " is duplicated in AA certificate ***");
                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                            }
                        }
                    } // End of 'for' statement
                } else {
                    log("*** " & testcasename() & ": FAIL: AA certificate does not contain its_aid_list subject attribute ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                }
                
                log("*** " & testcasename() & ": PASS: Time validity restriction of the AA certificate is good ***");
                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                
                // Postamble
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_SND_CERT_AA_08_01
            
        } // End of group g_AA_Certificates 
        group g_AT_Certificates {
            
            /**
             * @desc Check that the subject_type of the AT certificate is set to 'authorization_ticket'   
             * <pre>
             * Pics Selection: PICS_GN_SECURITY
             * Config Id: CF01
             * with {
             *   the IUT being in the 'authorized' state
             *   the IUT being requested to include certificate in the next CAM
             * } ensure that {
             *    when {
             *     the IUT is requested to send a CAM
             *   } then {
             *     the IUT sends a SecuredMessage
             *       containing header_fields['signer_info'].signer {
             *         containing type
             *           indicating 'certificate'
             *         containing certificate {
             *           containing subject_info.subject_type
             *             indicating 'authorization_ticket' (1)
             *         }
             *       }
             *   }
             * }
             * </pre>
			 * @see			ETSI TS 103 096-2 v1.2.1 TP_SEC_ITSS_SND_CERT_AT_01_01_BV
             * @reference	ETSI TS 103 097 [1], clause 7.4.1
             */
            testcase TC_SEC_SND_CERT_AT_01_01() runs on ItsGeoNetworking system ItsSecSystem {
                var Certificate         v_at_cert;
                
                // Test control
                if (not(PICS_GN_SECURITY)) {
                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY' required for executing the TC ***");
                    stop;
                }
                
                // Test component configuration
                f_cf01Up();
                
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
                log("*** " & testcasename() & ": INFO: Waiting for the message containing certificate  ***");
                tc_ac.start;
                if (not f_waitForCertificate(v_at_cert)) {
                    log("*** " & testcasename() & ": INCONC: Expected message not received ***");
                    f_selfOrClientSyncAndVerdictPreamble(c_tbDone, e_timeout);
                }
                tc_ac.stop;
                if (not match(v_at_cert, mw_at_certificate)) {
                    log("*** " & testcasename() & ": FAIL: Message wasn't signed by AT certificate ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                }
                log("*** " & testcasename() & ": PASS: AT certificate has the 'authorization_ticket' subject_type  ***");
                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                
                // Postamble
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_SND_CERT_AT_01_01
            
            /**
             * @desc Check that signer info of the AA certificate is a digest    
             * <pre>
             * Pics Selection: PICS_GN_SECURITY and PICS_CERTIFICATE_SELECTION
             * Config Id: CF01
             * with {
             *   the IUT being in the 'authorized' state
             *   the IUT being requested to include certificate in the next CAM
             * } ensure that {
             *    when {
             *     the IUT is requested to send a CAM
             *   } then {
             *     the IUT sends a SecuredMessage
             *       containing header_fields['signer_info'].signer {
             *         containing type
             *           indicating 'certificate'
             *         containing certificate
             *           containing signer_info {
             *             containing type
             *               indicating 'certificate_digest_with_sha256'
             *             containing digest
             *           }
             *         }
             *       }
             *   }
             * }
             * </pre>
			 * @see			ETSI TS 103 096-2 v1.2.1 TP_SEC_ITSS_SND_CERT_AT_02_01_BV
             * @reference	ETSI TS 103 097 [1], clauses 6.1, 7.4 and 7.4.1
             */
            testcase TC_SEC_SND_CERT_AT_02_01() runs on ItsGeoNetworking system ItsSecSystem {
                var Certificate         v_at_cert;
                
                // Test control
                if (not(PICS_GN_SECURITY) or not(PICS_CERTIFICATE_SELECTION)) {
                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY and PICS_CERTIFICATE_SELECTION' required for executing the TC ***");
                    stop;
                }
                
                // Test component configuration
                f_cf01Up();
                
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
                log("*** " & testcasename() & ": INFO: Waiting for the message containing certificate  ***");
                tc_ac.start;
                if (not f_waitForCertificate(v_at_cert)) {
                    log("*** " & testcasename() & ": INCONC: Expected message not received ***");
                    f_selfOrClientSyncAndVerdictPreamble(c_tbDone, e_timeout);
                }
                tc_ac.stop;
                if (
                    not match(v_at_cert, mw_certificate(mw_signerInfo_digest))
                ) {
                    log("*** " & testcasename() & ": FAIL: AT certificate doesn't contain a digest of issuing cert ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                }
                log("*** " & testcasename() & ": PASS: The signer info of AT certificate is a digest ***");
                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                
                // Postamble
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_SND_CERT_AT_02_01
            
            /**
             * @desc Check that the subject_name variable-length vector is empty for AT certificates     
             * <pre>
             * Pics Selection: PICS_GN_SECURITY and PICS_CERTIFICATE_SELECTION
             * Config Id: CF01
             * with {
             *   the IUT being in the 'authorized' state
             *   the IUT being requested to include certificate in the next CAM
             * } ensure that {
             *    when {
             *     the IUT is requested to send a CAM
             *   } then {
             *     the IUT sends a SecuredMessage
             *       containing header_fields['signer_info'].signer {
             *         containing type
             *           indicating 'certificate'
             *         containing certificates {
             *           containing subject_info.subject_name
             *             indicating length = 0
             *         }
             *       }
             *   }
             * }
             * </pre>
             * @see			ETSI TS 103 096-2 v1.2.1 TP_SEC_ITSS_SND_CERT_AT_03_01_BV
             * @reference	ETSI TS 103 097 [1], clause 7.4.1
             */
            testcase TC_SEC_SND_CERT_AT_03_01() runs on ItsGeoNetworking system ItsSecSystem {
                var Certificate         v_at_cert;
                
                // Test control
                if (not(PICS_GN_SECURITY) or not(PICS_CERTIFICATE_SELECTION)) {
                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY and PICS_CERTIFICATE_SELECTION' required for executing the TC ***");
                    stop;
                }
                
                // Test component configuration
                f_cf01Up();
                
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
                log("*** " & testcasename() & ": INFO: Waiting for the message containing certificate  ***");
                tc_ac.start;
                if (not f_waitForCertificate(v_at_cert)) {
                    log("*** " & testcasename() & ": INCONC: Expected message not received ***");
                    f_selfOrClientSyncAndVerdictPreamble(c_tbDone, e_timeout);
                }
                tc_ac.stop;
                if (0 != lengthof(v_at_cert.subject_info.subject_name)) {
                    log("*** " & testcasename() & ": FAIL: Subject name of the AT certificate is not empty ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                }
                log("*** " & testcasename() & ": PASS: Subject name of the AT certificate is empty ***");
                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                
                // Postamble
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_SND_CERT_AT_03_01
            
            /**
             * @desc Check that all neccesary subject attributes of AT certificate are present and arranged in accesing order     
             * <pre>
             * Pics Selection: PICS_GN_SECURITY and PICS_CERTIFICATE_SELECTION
             * Config Id: CF01
             * with {
             *   the IUT being in the 'authorized' state
             *   the IUT being requested to include certificate in the next CAM
             * } ensure that {
             *    when {
             *     the IUT is requested to send a CAM
             *   } then {
             *     the IUT sends a SecuredMessage
             *       containing header_fields['signer_info'].signer {
             *         containing type
             *           indicating 'certificate'
             *         containing certificate {
             *           containing subject_attributes [0..N] {
             *             indicating subject_attributes[n].type < subject_attributes[n+ 1].type
             *             containing subject_attributes['verification_key']
             *             containing subject_attributes['assurance_level']
             *             containing subject_attributes['its_aid_ssp_list']
             *           }
             *         }
             *       }
             *   }
             * }
             * </pre>
             * @see			ETSI TS 103 096-2 v1.2.1 TP_SEC_ITSS_SND_CERT_AT_04_01_BV
             * @reference	ETSI TS 103 097 [1], clauses 7.4 and 7.4.1
             */
            testcase TC_SEC_SND_CERT_AT_04_01() runs on ItsGeoNetworking system ItsSecSystem {
                var Certificate         v_at_cert;
                var SubjectAttributes   v_attrs;
                
                // Test control
                if (not(PICS_GN_SECURITY) or not(PICS_CERTIFICATE_SELECTION)) {
                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY and PICS_CERTIFICATE_SELECTION' required for executing the TC ***");
                    stop;
                }
                
                // Test component configuration
                f_cf01Up();
                
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
                log("*** " & testcasename() & ": INFO: Waiting for the message containing certificate  ***");
                tc_ac.start;
                if (not f_waitForCertificate(v_at_cert)) {
                    log("*** " & testcasename() & ": INCONC: Expected message not received ***");
                    f_selfOrClientSyncAndVerdictPreamble(c_tbDone, e_timeout);
                }
                tc_ac.stop;
                if (not match(
                    v_at_cert, 
                        mw_at_certificate(
                            ?,
                            superset(
                                mw_subject_attribute_verification_key,
                                mw_subject_attribute_assurance_level,
                                mw_subject_attribute_its_aid_ssp_list
                 )))) {
                    log("*** " & testcasename() & ": FAIL: Required subject attribute of AT certificate is not found ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                }
                
                v_attrs := v_at_cert.subject_attributes;
                for (var integer v_counter := 1; v_counter < lengthof(v_attrs); v_counter := v_counter + 1 ) {
                    if (v_attrs[v_counter].type_ <= v_attrs[v_counter-1].type_) {
                        log("*** " & testcasename() & ": FAIL: AT certificate subject attributes are not arranged in ascending order ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                    }
                } // End of 'for' statement
                
                log("*** " & testcasename() & ": PASS: All required AT certificate subject attributes are presents and arranged in ascending order ***");
                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                
                // Postamble
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_SND_CERT_AT_04_01
            
            /**
             * @desc Check that time_start_and_end is included in the AT certificate validation restrictions
             *       Check that time_start_and_end is inside the AA certificate time restrictions       
             * <pre>
             * Pics Selection: PICS_GN_SECURITY and PICS_CERTIFICATE_SELECTION
             * Config Id: CF01
             * with {
             *   the IUT being in the 'authorized' state
             *   the IUT being requested to include certificate chain in the next CAM
             * } ensure that {
             *    when {
             *     the IUT is requested to send a CAM
             *   } then {
             *     the IUT sends a SecuredMessage
             *       containing header_fields['signer_info'].signer {
             *         containing type
             *           indicating certificate_chain
             *         containing certificates[last-1] {
             *           containing subject_info.subject_type
             *             indicating 'authorization_authority' (2)
             *           containing validity_restrictions['time_start_and_end']
             *             containing start_validity
             *               indicating START_AA_VALIDITY
             *             containing end_validity
             *               indicating END_AA_VALIDITY
             *           }
             *         }
             *         containing certificates[last] {
             *           containing subject_info.subject_type
             *             indicating 'authorization_ticket' (1)
             *           not containing validity_restrictions['time_end']
             *           and not containing validity_restrictions['time_start_and_duration']
             *           and containing validity_restrictions['time_start_and_end'] {
             *             containing start_validity
             *               indicating START_AT_VALIDITY (START_AT_VALIDITY >= START_AA_VALIDITY )
             *             and containing end_validity
             *               indicating END_AT_VALIDITY (END_AT_VALIDITY >= START_AT_VALIDITY <= END_AA_VALIDITY)
             *           }
             *         }
             *       }
             *   }
             * }
             * </pre>
             * @see			ETSI TS 103 096-2 v1.2.1 TP_SEC_ITSS_SND_CERT_AT_05_01_BV
             * @reference	ETSI TS 103 097 [1], clause 7.4.1
             */
            testcase TC_SEC_SND_CERT_AT_05_01() runs on ItsGeoNetworking system ItsSecSystem {
                var CertificateChain         v_chain;
                var Certificate              v_aa_cert, v_at_cert;
                var ValidityRestriction      v_vr, v_aa_vr;
                
                // Test control
                if (not(PICS_GN_SECURITY) or not(PICS_CERTIFICATE_SELECTION)) {
                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY and PICS_CERTIFICATE_SELECTION' required for executing the TC ***");
                    stop;
                }
                
                // Test component configuration
                f_cf01Up();
                
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
                log("*** " & testcasename() & ": INFO: Request and waiting for the message containing certificate chain  ***");
                tc_ac.start;
                if (not f_askAndWaitForCertificateChain(v_chain, f_generateDefaultCam())) {
                    log("*** " & testcasename() & ": INCONC: Expected message not received ***");
                    f_selfOrClientSyncAndVerdictPreamble(c_tbDone, e_timeout);
                }
                tc_ac.stop;
                if (lengthof(v_chain) < 2) {
                    log("*** " & testcasename() & ": FAIL: Certificate chain is too short ***");
                    f_selfOrClientSyncAndVerdictPreamble(c_tbDone, e_error);
                }
                v_aa_cert := v_chain[lengthof(v_chain) - 2];
                v_at_cert := v_chain[lengthof(v_chain) - 1];
                if (match (
                    v_at_cert.validity_restrictions, 
                    (
                        superset(
                            mw_validity_restriction_time_end,
                            mw_validity_restriction_time_start_and_duration
                        )
                    )
                )) {
                    log("*** " & testcasename() & ": FAIL: AT certificate must not contain time_end and time_start_and_duration restrictions ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                }
                
                if ( true != f_getCertificateValidityRestriction(v_at_cert, e_time_start_and_end, v_vr)) {
                    log("*** " & testcasename() & ": FAIL: AT certificate must contain time_start_and_end restrictions ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                }
                
                if (v_vr.validity.time_start_and_end.start_validity > v_vr.validity.time_start_and_end.end_validity ) {
                    log("*** " & testcasename() & ": FAIL: start validity must not be greater then end validity in the validity restrictions of AT certificate ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                }
                
                if ( true != f_getCertificateValidityRestriction(v_aa_cert, e_time_start_and_end, v_aa_vr)) {
                    log("*** " & testcasename() & ": FAIL: AA certificate must contain time_start_and_end restrictions ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                }
                
                if (    v_vr.validity.time_start_and_end.start_validity < v_aa_vr.validity.time_start_and_end.start_validity 
                    or v_vr.validity.time_start_and_end.end_validity > v_aa_vr.validity.time_start_and_end.end_validity
                ) {
                    log("*** " & testcasename() & ": FAIL: AT certificate time validity restriction must be inside the AA certificate time validity restriction ***"); 
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                }
                
                log("*** " & testcasename() & ": PASS: Time validity restriction of the AT certificate is good ***");
                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                
                // Postamble
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_SND_CERT_AT_05_01
            
            /**
             * @desc Check that all AIDs containing in the in the its_aid_ssp_list in AT certificate are unique and exists in the its_aid_list in the AA certificate
             *       Check that the length of SSP of each AID is 31 octet maximum        
             * <pre>
             * Pics Selection: PICS_GN_SECURITY and PICS_CERTIFICATE_SELECTION
             * Config Id: CF01
             * with {
             *   the IUT being in the 'authorized' state
             *   the IUT being requested to include certificate chain in the next CAM
             * } ensure that {
             *    when {
             *     the IUT is requested to send a CAM
             *   } then {
             *     the IUT sends a SecuredMessage
             *       containing header_fields['signer_info'].signer {
             *         containing type
             *           indicating certificate_chain
             *         containing certificates[last-1] {
             *           containing subject_info.subject_type
             *             indicating 'authorization_authority' (2)
             *           containing subject_attributes['its_aid_list']
             *             containing its_aid_list[0..N]
             *               indicating ITS_AID_LIST_AA
             *           }
             *         }
             *         containing certificates[last] {
             *           containing subject_info.subject_type
             *             indicating 'authorization_ticket' (1)
             *           containing subject_attributes['its_aid_ssp_list']
             *             containing its_aid_ssp_list[0..N] {
             *               containing its_aid_ssp_list[n]{
             *                 containing its_aid
             *                   indicating unique value containing in the  ITS_AID_LIST_AA
             *                 containing service_specific_permissions
             *                   indicating length <= 31 octet
             *               }
             *             }
             *           }
             *         }
             *       }
             *   }
             * }
             * </pre>
             * @see			ETSI TS 103 096-2 v1.2.1 TP_SEC_ITSS_SND_CERT_AT_07_01_BV
             * @reference	ETSI TS 103 097 [1], clauses 6.9 and 7.4.1
             */
            testcase TC_SEC_SND_CERT_AT_07_01() runs on ItsGeoNetworking system ItsSecSystem {
                var CertificateChain         v_chain;
                var Certificate              v_aa_cert, v_at_cert;
                var SubjectAttribute         v_sa;
                var IntXs                    v_aid_list;
                var ItsAidSsps               v_aid_ssp_list;
                
                // Test control
                if (not(PICS_GN_SECURITY) or not(PICS_CERTIFICATE_SELECTION)) {
                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY and PICS_CERTIFICATE_SELECTION' required for executing the TC ***");
                    stop;
                }
                
                // Test component configuration
                f_cf01Up();
                
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
                log("*** " & testcasename() & ": INFO: Request and waiting for the message containing certificate chain  ***");
                tc_ac.start;
                if (not f_askAndWaitForCertificateChain(v_chain, f_generateDefaultCam())) {
                    log("*** " & testcasename() & ": INCONC: Expected message not received ***");
                    f_selfOrClientSyncAndVerdictPreamble(c_tbDone, e_timeout);
                }
                tc_ac.stop;
                if (lengthof(v_chain) < 2) {
                    log("*** " & testcasename() & ": FAIL: Certificate chain is too short ***");
                    f_selfOrClientSyncAndVerdictPreamble(c_tbDone, e_error);
                }
                v_aa_cert := v_chain[lengthof(v_chain) - 2];
                v_at_cert := v_chain[lengthof(v_chain) - 1];
                if (not f_getCertificateSubjectAttribute(v_aa_cert, e_its_aid_list, v_sa)) {
                    log("*** " & testcasename() & ": FAIL: AA certificate does not contain its_aid_list subject attribute ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                }
                v_aid_list := v_sa.attribute.its_aid_list;
                
                if (not f_getCertificateSubjectAttribute(v_at_cert, e_its_aid_ssp_list, v_sa)) {
                    log("*** " & testcasename() & ": FAIL: AA certificate does not contain its_aid_list subject attribute ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                }
                v_aid_ssp_list := v_sa.attribute.its_aid_ssp_list;
                
                for (var integer v_counter :=0; v_counter < lengthof(v_aid_ssp_list); v_counter := v_counter + 1) {
                    // Check unique
                    for (var integer j :=0; j < lengthof(v_aid_ssp_list); j := j + 1) {
                        if (v_counter != j and v_aid_ssp_list[v_counter].its_aid == v_aid_ssp_list[j].its_aid) {
                            log("*** " & testcasename() & ": FAIL: ITS-AID " & int2str(v_aid_ssp_list[v_counter].its_aid) & " is duplicated in AT certificate ***");
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                        }
                    } // End of 'for' statement
//                    if (not match(v_aid_ssp_list[v_counter], (all from v_aid_list))) {
//                        log("*** " & testcasename() & ": FAIL: ITS-AID " & int2str(v_aid_ssp_list[v_counter].its_aid) & " is not exist in AA certificate ***");
//                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
//                    }
                    // TODO Not possible due to typing To be removed
//                    if (lengthof(v_aid_ssp_list[v_counter].service_specific_permissions.sspContainer) > 31) {
//                        log("*** " & testcasename() & ": FAIL: ITS-AID " & int2str(v_aid_ssp_list[v_counter].its_aid) & " has too long service_specific_permissions ***");
//                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
//                    }
                } // End of 'for' statement
                
                log("*** " & testcasename() & ": PASS: The ITS_AID_SSP list of the AT certificate is good ***");
                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                
                // Postamble
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_SND_CERT_AT_07_01
            
            /**
             * @desc Check that AT certificate is signed by AA cert
             * Pics Selection: PICS_GN_SECURITY and PICS_CERTIFICATE_SELECTION
             * Config Id: CF01
             * with {
             *   the IUT being in the 'authorized' state
             *   the IUT being requested to include certificate chain in the next CAM
             * } ensure that {
             *    when {
             *     the IUT is requested to send a first CAM
             *   } then {
             *     the IUT sends a SecuredMessage
             *       containing header_fields['signer_info'].signer {
             *         containing type
             *           indicating certificate_chain
             *         containing certificates[last-1] (CERT_AA) {
             *           containing subject_info.subject_type
             *             indicating 'authorization_authority' (2)
             *           and containing subject_attributes['verification key'] (KEY)
             *         }
             *         containing certificates[last] {
             *           containing subject_info.subject_type
             *             indicating 'authorization_ticket' (1)
             *           }
             *           and containing signer_info[0]{
             *             containing type
             *               indicating 'certificate_digest_with_sha256'
             *             containing digest
             *               referencing to CERT_AA
             *           }
             *           and containing signature
             *             verifiable using KEY
             *         }
             *       }
             *   }
             * }
             * </pre>
             * @see			ETSI TS 103 096-2 v1.2.1 TP_SEC_ITSS_SND_CERT_AT_08_01_BV
             * @reference	ETSI TS 103 097 [1], clause 6.3
             */
            testcase TC_SEC_SND_CERT_AT_08_01() runs on ItsGeoNetworking system ItsSecSystem {
                var CertificateChain         v_chain;
                var Certificate              v_aa_cert, v_at_cert;
                var HashedId8                v_aa_digest;
                
                // Test control
                if (not(PICS_GN_SECURITY) or not(PICS_CERTIFICATE_SELECTION)) {
                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY and PICS_CERTIFICATE_SELECTION' required for executing the TC ***");
                    stop;
                }
                
                // Test component configuration
                f_cf01Up();
                
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                
                // Test Body
                log("*** " & testcasename() & ": INFO: Request and waiting for the message containing certificate chain  ***");
                tc_ac.start;
                if (not f_askAndWaitForCertificateChain(v_chain, f_generateDefaultCam())) {
                    log("*** " & testcasename() & ": INCONC: Expected message not received ***");
                    f_selfOrClientSyncAndVerdictPreamble(c_tbDone, e_timeout);
                }
                tc_ac.stop;
                if (lengthof(v_chain) < 2) {
                    log("*** " & testcasename() & ": FAIL: Certificate chain is too short ***");
                    f_selfOrClientSyncAndVerdictPreamble(c_tbDone, e_error);
                }
                v_at_cert := v_chain[lengthof(v_chain) - 1];
                v_aa_cert := v_chain[lengthof(v_chain) - 2];
                v_aa_digest := f_calculateDigestFromCertificate(v_aa_cert); 
                
                if (not match(v_at_cert, mw_at_certificate(mw_signerInfo_digest(v_aa_digest)))) {
                    log("*** " & testcasename() & ": FAIL: AT certificate signer info doesn't reference the  AA certificate from the chain ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                }
                
                if (not f_verifyCertificateSignatureWithIssuingCertificate(v_at_cert, v_aa_cert)) {
                    log("*** " & testcasename() & ": FAIL: AT certificate signature verification failed ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                }
                
                log("*** " & testcasename() & ": PASS: AT certificate was signed by the AA certificate from the given chain ***");
                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                
                // Postamble
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_SND_CERT_AT_08_01
            
            /**
             * @desc Check that the assurance level of the subordinate certificate is equal to or lower than the assurance level of the issuing certificate
             * <pre>
             * Pics Selection: PICS_GN_SECURITY and PICS_CERTIFICATE_SELECTION
             * Config Id: CF01
             * with {
             *   the IUT being in the 'authorized' state
             *   the IUT being requested to include certificate chain in the next CAM
             * } ensure that {
             *    when {
             *     the IUT is requested to send a CAM
             *   } then {
             *     the IUT sends a SecuredMessage
             *       containing header_fields['signer_info'].signer {
             *         containing type
             *           indicating certificate_chain
             *         containing certificates[last-1] (CERT_AA) {
             *           containing subject_attributes ['assurance_level']
             *             containig assurance_level
             *               indicating indicating assurance level AL_AA
             *         }
             *         containing certificates[last] (CERT_AT) {
             *           containing subject_attributes ['assurance_level']
             *             containig assurance_level
             *               indicating indicating assurance level AL_AT (AL_AT <= AL_AA)
             *         }
             *           }
             *         }
             *       }
             *   }
             * }
             * </pre>
             * @see			ETSI TS 103 096-2 v1.2.1 TP_SEC_ITSS_SND_CERT_AT_09_01_BV
             * @reference	ETSI TS 103 097 [1], clause 7.4
             */
            testcase TC_SEC_SND_CERT_AT_09_01() runs on ItsGeoNetworking system ItsSecSystem {
                var CertificateChain         v_chain;
                var Certificate              v_aa_cert, v_at_cert;
                var SubjectAttribute         v_sa;
                var SubjectAssurance         v_aa_assurance_level, v_at_assurance_level;
                
                // Test control
                if (not(PICS_GN_SECURITY) or not(PICS_CERTIFICATE_SELECTION)) {
                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY and PICS_CERTIFICATE_SELECTION' required for executing the TC ***");
                    stop;
                }
                
                // Test component configuration
                f_cf01Up();
                
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
                log("*** " & testcasename() & ": INFO: Request and waiting for the message containing certificate chain  ***");
                tc_ac.start;
                if (not f_askAndWaitForCertificateChain(v_chain, f_generateDefaultCam())) {
                    log("*** " & testcasename() & ": INCONC: Expected message not received ***");
                    f_selfOrClientSyncAndVerdictPreamble(c_tbDone, e_timeout);
                }
                tc_ac.stop;
                if (lengthof(v_chain) < 2) {
                    log("*** " & testcasename() & ": FAIL: Certificate chain is too short ***");
                    f_selfOrClientSyncAndVerdictPreamble(c_tbDone, e_error);
                }
                v_aa_cert := v_chain[lengthof(v_chain) - 2];
                v_at_cert := v_chain[lengthof(v_chain) - 1];
                if (not f_getCertificateSubjectAttribute(v_aa_cert, e_assurance_level, v_sa)) {
                    log("*** " & testcasename() & ": FAIL: AA certificate does not contain its_aid_list subject attribute ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                }
                v_aa_assurance_level := v_sa.attribute.assurance_level;
                
                if (not f_getCertificateSubjectAttribute(v_at_cert, e_assurance_level, v_sa)) {
                    log("*** " & testcasename() & ": FAIL: AA certificate does not contain its_aid_list subject attribute ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                }
                v_at_assurance_level := v_sa.attribute.assurance_level;
                
                if (bit2int(v_aa_assurance_level.levels) < bit2int(v_at_assurance_level.levels)) {
                    log("*** " & testcasename() & ": FAIL: The assurence levels mismatch ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                } else {
                    log("*** " & testcasename() & ": PASS: The assurence levels match ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                }
                
                // Postamble
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_SND_CERT_AT_09_01
            
        } // End of group g_AT_Certificates 
        
    } // End of group g_Certificates
    
} // End of module ItsSecurity_TestCase