ItsSecurity_TestCases.ttcn 1.5 MB
Newer Older
garciay's avatar
garciay committed
                        log("*** " & testcasename() & ": INFO: Initial conditions: First CAM message with certificate received ***");
                        
                        // Send secured message from unknown ITS-S
                        geoNetworkingPort.clear;
                        f_sendSecuredCam(cc_taCert_B, valueof(m_headerInfo_cam(-, f_computeGnTimestamp())), valueof(m_signerIdentifier_digest));
                        
                        f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                    }
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: Initial conditions: CAM message with certificate not received ***");
                        f_selfOrClientSyncAndVerdictPreamble("error", e_timeout);
                    }
                }
                
                // Test Body
                t_maxTransInterval.start;
                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 // containing certificate
                                    )
                                ), 
                                mw_geoNwShbPacket
                    ))) {
                        tc_ac.stop; 
                        t_maxTransInterval.stop;
                        log("*** " & testcasename() & ": PASS: Generation of CAM messages including certificate was successful ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                    }
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mw_etsiTs103097Data_signed(
                                    mw_signedData(
                                        -, 
                                        mw_toBeSignedData(
                                            mw_signedDataPayload,
                                            mw_headerInfo_cam
                                        )
                                    )
                                ), 
                                mw_geoNwShbPacket
                    ))) {
                        repeat;
                    }
                    [] t_maxTransInterval.timeout {
                        log("*** " & testcasename() & ": FAIL: CAM was transmited w/o unrecognized request header ***"); 
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                    }
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: Expected CAM not received ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                    }
                } // End of 'alt' statement
                
                // Postamble
                f_terminateCam(v_component);
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_ITSS_SND_CAM_08_BV
            
garciay's avatar
garciay committed
            /**
             * @desc    Check that IUT restarts the certificate sending timer when the certificate has been sent
             * <pre>
             * Pics Selection: PICS_GN_SECURITY
             * Config Id: CF01
             * Initial conditions:
             *  with {
             *      the IUT being in the 'authorized' state (CERT_IUT_A_AT) 
             *      and the IUT is configured to send more then one CAM per second
             *      and the IUT having already sent CAM at TIME_1
             *          containing signer
             *              containing certificate
             *      and the IUT having received a CAM at TIME_2 (TIME_1 + 0.3sec)
             *          containing signer
             *              containing digest
             *                  containing HashedId8 value
             *                      indicating ann unknown certificate
             *      and the IUT having sent CAM at TIME_3 (TIME_3 > TIME_2)
             *          containing signer
             *              containing certificate
             *  }
             *  ensure that {
             *      when {
             *          the IUT is sending the next CAM at TIME_4
             *              containing signer
             *                  containing certificate
             *      } then {
             *          the difference between TIME_4 and TIME_3 is about of 1sec
             *      }
             *  }
             * </pre>
             *
             * @see          ETSI TS 103 096-2 v1.3.2 TP_SEC_ITSS_SND_CAM_09_TI
             * @reference    ETSI TS 103 097 [1], clause 7.1.1
             */
            testcase TC_SEC_ITSS_SND_CAM_09_TI() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                const float c_certificateGenerationTime := 1.0;
                
                timer t_maxTransInterval := c_certificateGenerationTime * 0.9;
                var GeoNetworkingInd v_geoNwInd;
                var SignerIdentifier v_signerInfo;
                var ItsCam v_component;
                var boolean v_firstCertReceived := false;
                
                // Test control
                if (not(PICS_GN_SECURITY)) {
                    log("*** " & testcasename() & ": ERROR: 'PICS_GN_SECURITY' required for executing the TC ***");
                    stop;
                }
                
                // Test component configuration
garciay's avatar
garciay committed
                f_cf01Up(); // Initialise IUT with CERT_IUT_A_AT signed with CERT_IUT_A_AA
garciay's avatar
garciay committed
                
                // Test adapter configuration
                
                // Preamble
                f_prNeighbour();
                v_component := f_setCamFrequencyGreatherThan1Hz();
                tc_ac.start;
                alt {
                    [v_firstCertReceived == false] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mw_etsiTs103097Data_signed(
                                    mw_signedData(
                                        -, 
                                        mw_toBeSignedData(
                                            mw_signedDataPayload,
                                            mw_headerInfo_cam
                                        ),
                                        mw_signerIdentifier_certificate // containing certificate
                                    )
                                ), 
                                mw_geoNwShbPacket
                    ))) -> value v_geoNwInd {
                        log("*** " & testcasename() & ": INFO: Initial conditions: The first CAM with certificate is received ***");
                        v_firstCertReceived := true;
                        f_sleep(0.3);
                        // Send secured message with request for unrecognized certificate
                        f_getMsgSignerIdentifier(f_getSecuredMessage(v_geoNwInd.msgIn), v_signerInfo);
                        f_sendSecuredCam(
                            cc_taCert_F,
                            valueof(m_headerInfo_cam(-, f_computeGnTimestamp())),
                            valueof(
                                m_signerIdentifier_digest(
                                    f_calculateDigestFromCertificate(
                                        v_signerInfo.certificate[0]
                                    )
                                )
                            )
                        );
                        repeat;
                    }
                    [v_firstCertReceived == true] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mw_etsiTs103097Data_signed(
                                    mw_signedData(
                                        -, 
                                        mw_toBeSignedData(
                                            mw_signedDataPayload,
                                            mw_headerInfo_cam
                                        ),
                                        mw_signerIdentifier_certificate // containing certificate
                                    )
                                ), 
                                mw_geoNwShbPacket
                    ))) {
                        tc_ac.stop;
                        // start a timeout of one second to check
                        // that the next cert will be received after this timeout
                        t_maxTransInterval.start;
                        log("*** " & testcasename() & ": INFO: Initial conditions: The requested CAM with certificate is received ***");
                        f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                    }
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: Initial conditions: CAM message with certificate not received ***");
                        f_selfOrClientSyncAndVerdictPreamble("error", e_timeout);
                    }
                } // End of 'alt' statement
                
                // Test Body
                tc_ac.start;
                alt {
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mw_etsiTs103097Data_signed(
                                    mw_signedData(
                                        -, 
                                        mw_toBeSignedData(
                                            mw_signedDataPayload,
                                            mw_headerInfo_cam
                                        ),
                                        mw_signerIdentifier_certificate // containing certificate
                                    )
                                ), 
                                mw_geoNwShbPacket
                    ))) {
                        tc_ac.stop;
                        t_maxTransInterval.stop;
                        log("*** " & testcasename() & ": FAIL: CAM certificate inclusion time wasn't restarted ***");
                        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
                                    )
                                ), 
                                mw_geoNwShbPacket
                    ))) {
                        log("*** " & testcasename() & ": INFO: CAM retransmission w/o certificate ***"); 
                        repeat;
                    }
                    [] t_maxTransInterval.timeout {
                        tc_ac.stop;
                        log("*** " & testcasename() & ": PASS: The CAM certificate inclusion timer has been restarted ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                    }
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: Expected CAM not received ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                    }
                } // End of 'alt' statement
                
                // Postamble
                f_terminateCam(v_component);
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_ITSS_SND_CAM_09_TI
            
            /**
             * @desc    Check that the IUT sends certificate request when it receives secured CAM containing 
             *          digest of unknown certificate as a message signer.  
             * <pre>
             * Pics Selection: PICS_GN_SECURITY, PICS_SEC_P2P_AT_DISTRIBUTION
             * Config Id: CF01
             * Initial conditions:
             *  with {
             *      the IUT is authorized with AT certificate (CERT_IUT_A_AT)
             *      and the IUT has receiving a CAM
             *          containing signer
             *              containing digest
             *                  indicating HashedId8 value DIGEST_A
             *                      referencing an unknown certificate (CERT_TS_B_AT)
             *  }
             *  ensure that {
             *      when {
             *          the IUT is requested to send a secured CAM
             *      } then {
             *          the IUT sends a Ieee1609Dot2Data
             *              containing headerInfo
             *                  containing inlineP2pcdRequest
             *                      containing HashedId3 value
             *                          indicating last 3 octets of DIGEST_A
             *      }
             *  }
             * </pre>
             *
             * @see          ETSI TS 103 096-2 v1.3.2 TP_SEC_ITSS_SND_CAM_10_BV
             * @reference    ETSI TS 103 097 [1], clause 7.1.1
             *               IEEE 1609.2 [2], clauses 6.3.9, 8.2.4.1.2
             */
            testcase TC_SEC_ITSS_SND_CAM_10_BV() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                
                var GeoNetworkingInd v_geoNwInd;
                var HashedId8 v_hashedId8;
                var HashedId3 v_expectedHashedId3;
                
                // Test control
                if (not(PICS_GN_SECURITY) or not(PICS_SEC_P2P_AT_DISTRIBUTION)) {
                    log("*** " & testcasename() & ": ERROR: 'PICS_GN_SECURITY and PICS_SEC_P2P_AT_DISTRIBUTION' required for executing the TC ***");
                    stop;
                }
                
                // Test component configuration
garciay's avatar
garciay committed
                f_cf01Up();  // Initialise IUT with CERT_IUT_A_AT signed with CERT_IUT_A_AA
garciay's avatar
garciay committed

                // Test adapter configuration
                
                // Preamble
                f_prNeighbour();
                f_getCertificateDigest(
                    cc_taCert_B,
                    v_hashedId8
                );
                v_expectedHashedId3 := f_HashedId3FromHashedId8(v_hashedId8);
                f_sendSecuredCam(
                    cc_taCert_B, // SHA-256/NIST P-256
                    valueof(m_headerInfo_cam(-, f_computeGnTimestamp())),
                    valueof(
                        m_signerIdentifier_digest(
                            v_hashedId8
                        )
                    )
                );
                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(
                                                -,
                                                -,
                                                -,
                                                { v_expectedHashedId3 }
                                            )
                                        )
                                    )
                                ), 
                                mw_geoNwShbPacket
                    ))) {
                        tc_ac.stop;
                        log("*** " & testcasename() & ": PASS: Generation of CAM messages including certificate request was successful ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success); 
                    }
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mw_etsiTs103097Data_signed(
                                    mw_signedData(
                                        -, 
                                        mw_toBeSignedData(
                                            mw_signedDataPayload,
                                            mw_headerInfo_cam
                                        ),
                                        mw_signerIdentifier_digest // containing digest
                                    )
                                ), 
                                mw_geoNwShbPacket
                    ))) {
                        log("*** " & testcasename() & ": INFO: CAM retransmission w/o certificate request ***"); 
                        repeat;
                    }
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: Expected CAM not received ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                    }
                } // End of 'alt' statement
                
                // Postamble
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_ITSS_SND_CAM_10_BV
            
            /**
             * @desc    Check that the IUT sends certificate request when it receives secured CAM 
             *          containing certificate signed by unknown AA certificate.  
             * <pre>
             * Pics Selection: PICS_GN_SECURITY, PICS_SEC_P2P_AT_DISTRIBUTION
             * Config Id: CF01
             * Initial conditions:
             *  with {
             *      the IUT is authorized with AT certificate (CERT_IUT_A_AT)
             *      and the IUT has receiving a CAM
             *          containing signer
             *              containing digest
             *                  indicating HashedId8 value DIGEST_A
             *                      referencing an unknown certificate (CERT_TS_B_AT)
             *  }
             *  ensure that {
             *      when {
             *          the IUT is requested to send a secured CAM
             *      } then {
             *          the IUT sends a Ieee1609Dot2Data
             *              containing headerInfo
             *                  containing inlineP2pcdRequest
             *                      containing HashedId3 value
             *                          indicating last 3 octets of DIGEST_A
             *      }
             *  }
             * </pre>
             *
             * @see          ETSI TS 103 096-2 v1.3.2 TP_SEC_ITSS_SND_CAM_11_BV
             * @reference    ETSI TS 103 097 [1], clause 7.1.1
             *               IEEE 1609.2 [2], clauses 6.3.9, 8.2.4.1.2
             */
            testcase TC_SEC_ITSS_SND_CAM_11_BV() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                
                var GeoNetworkingInd v_geoNwInd;
                var HashedId8 v_hashedId8;
                var HashedId3 v_expectedHashedId3;
                
                // Test control
                if (not(PICS_GN_SECURITY) or not(PICS_SEC_P2P_AT_DISTRIBUTION)) {
                    log("*** " & testcasename() & ": ERROR: 'PICS_GN_SECURITY and PICS_SEC_P2P_AT_DISTRIBUTION' required for executing the TC ***");
                    stop;
                }
                
                // Test component configuration
garciay's avatar
garciay committed
                f_cf01Up(); // Initialise IUT with CERT_IUT_A_AT signed with CERT_IUT_A_AA
garciay's avatar
garciay committed

                // Test adapter configuration
                
                // Preamble
                f_prNeighbour();
                if (PICS_HASH_ALGORITHM == sha256) {
                    f_getCertificateDigest(
                        cc_taCert_B,
                        v_hashedId8
                    );
                } else if (PICS_HASH_ALGORITHM == sha384) {
                    f_getCertificateDigest(
                        cc_taCert_B1, // FIXME Create certificate SHA-384 / NIST P-256
                        v_hashedId8
                    );
                }
                v_expectedHashedId3 := f_HashedId3FromHashedId8(v_hashedId8);
                f_sendSecuredCam(
                    cc_taCert_B,
                    valueof(m_headerInfo_cam(-, f_computeGnTimestamp())),
                    valueof(
                        m_signerIdentifier_digest(
                            v_hashedId8
                        )
                    )
                );
                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(
                                                -,
                                                -,
                                                -,
                                                { v_expectedHashedId3 }
                                            )
                                        )
                                    )
                                ), 
                                mw_geoNwShbPacket
                    ))) {
                        tc_ac.stop;
                        log("*** " & testcasename() & ": PASS: Generation of CAM messages including certificate request was successful ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success); 
                    }
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mw_etsiTs103097Data_signed(
                                    mw_signedData(
                                        -, 
                                        mw_toBeSignedData(
                                            mw_signedDataPayload,
                                            mw_headerInfo_cam
                                        ),
                                        mw_signerIdentifier_digest // containing digest
                                    )
                                ), 
                                mw_geoNwShbPacket
                    ))) {
                        log("*** " & testcasename() & ": INFO: CAM retransmission w/o certificate request ***"); 
                        repeat;
                    }
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: Expected CAM not received ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                    }
                } // End of 'alt' statement
                
                // Postamble
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_ITSS_SND_CAM_11_BV
            
            /**
             * @desc    Check that IUT sends the secured CAM containing the signing certificate when it received 
             *          a CAM containing a request for unrecognized certificate that matches with the currently 
             *          used AT certificate ID of the IUT.
             * <pre>
             * Pics Selection: PICS_GN_SECURITY, PICS_SEC_P2P_AT_DISTRIBUTION
             * Config Id: CF01
             * Initial conditions:
             *  with {
             *      the IUT is authorized with AT certificate (CERT_IUT_A_AT) 
             *      and the IUT is configured to send more than one CAM per second
             *      and the IUT having already sent a CAM
             *          containing signer
             *              containing certificate
             *          at TIME_1
             *      and the IUT having received a CAM
             *          containing inlineP2pcdRequest
             *              containing HashedId3 value
             *                  indicating last 3 octets of currently used AT certificate
             *          at TIME_2 (TIME_1 < TIME_2 < TIME_1+ 1sec)
             *  }
             *  ensure that {
             *      when {
             *          the IUT is requested to send a CAM
             *              at TIME_3 (TIME_1 < TIME_2 < TIME_3 < TIME_1+ 1sec)
             *      } then {
             *          the IUT sends a CAM
garciay's avatar
garciay committed
             *              containing signer
             *               and containing certificate
             *                   referenced by the requested digest 
garciay's avatar
garciay committed
             *      }
             *  }
             * </pre>
             *
             * @see          ETSI TS 103 096-2 v1.3.2 TP_SEC_ITSS_SND_CAM_12_BV
             * @reference    ETSI TS 103 097 [1], clause 7.1.1
             *               IEEE 1609.2 [2], clauses 6.3.9, 8.2.4.2.3
             */
            testcase TC_SEC_ITSS_SND_CAM_12_BV() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                const float c_certificateGenerationTime := 1.0;
                
                timer t_maxTransInterval := c_certificateGenerationTime * 0.9;
                var GeoNetworkingInd v_geoNwInd;
                var ItsCam v_component;
                var HashedId8 v_hashedId8;
                                
                // Test control
garciay's avatar
garciay committed
                if (not(PICS_GN_SECURITY) or not(PICS_SEC_P2P_AT_DISTRIBUTION)) {
                    log("*** " & testcasename() & ": ERROR: 'PICS_GN_SECURITY and PICS_SEC_P2P_AT_DISTRIBUTION' required for executing the TC ***");
garciay's avatar
garciay committed
                    stop;
                }
                
                // Test component configuration
garciay's avatar
garciay committed
                f_cf01Up(); // Initialise IUT with CERT_IUT_A_AT signed with CERT_IUT_A_AA
garciay's avatar
garciay committed
                
                // Test adapter configuration
                
                // Preamble
                f_prNeighbour();
garciay's avatar
garciay committed
                f_getCertificateDigest(
                    cc_taCert_A,
                    v_hashedId8
                );
garciay's avatar
garciay committed
                geoNetworkingPort.clear;
                v_component := f_setCamFrequencyGreatherThan1Hz();
                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 // containing certificate
                                    )
                                ), 
                                mw_geoNwShbPacket
                    ))) {
                        tc_ac.stop;
                        t_maxTransInterval.start;
                        
                        log("*** " & testcasename() & ": INFO: Initial conditions: First CAM message with certificate received ***");
                                                
                        // Send secured message with request for the currently used AT certificate
                        f_sendSecuredCam(
                            cc_taCert_A,
                            valueof(
                                m_headerInfo_cam(
                                    -, 
                                    f_computeGnTimestamp(),
                                    -,
                                    { f_HashedId3FromHashedId8(v_hashedId8) }
                            )),
                            valueof(
                                m_signerIdentifier_digest(
                                    v_hashedId8
                                )
                            )
                        );
                        f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                    }
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: Initial conditions: CAM message with certificate not received ***");
                        f_selfOrClientSyncAndVerdictPreamble("error", e_timeout);
                    }
                } // End of 'alt' statement
                
                // Test Body
                tc_ac.start;
                alt {
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mw_etsiTs103097Data_signed(
                                    mw_signedData(
                                        -, 
                                        mw_toBeSignedData(
                                            mw_signedDataPayload,
                                            mw_headerInfo_cam
                                        ),
                                        mw_signerIdentifier_certificate // containing certificate
                                    )
                                ), 
                                mw_geoNwShbPacket
                    ))) -> value v_geoNwInd {
                        var SignerIdentifier v_signerIdentifier;
                        var SequenceOfCertificate v_certificates;
                        var integer v_certificatesLength;
                        
                        tc_ac.stop; 
                        t_maxTransInterval.stop;
                        // Extract certificate chain
                        f_getMsgSignerIdentifier(v_geoNwInd.msgIn.gnPacket.securedMsg, v_signerIdentifier);
                        v_certificates := v_signerIdentifier.certificate;
                        v_certificatesLength := lengthof(v_certificates);
                        if (v_certificatesLength == 1) {
                            // Check reference
                            if (f_calculateDigestFromCertificate(v_certificates[0]) == v_hashedId8) {
                                log("*** " & testcasename() & ": PASS: Generation of CAM messages including certificate ***");
                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                            } else {
                                log("*** " & testcasename() & ": FAIL: Wrong certificate reference ***");
                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error); 
                            }
                        } else {
                            log("*** " & testcasename() & ": FAIL: Unexpected certificate content ***");
                            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
                                    )
                                ), 
                                mw_geoNwShbPacket
                    ))) {
                        log("*** " & testcasename() & ": INFO: CAM retransmission w/o certificate ***"); 
                        repeat;
                    }
                    [] t_maxTransInterval.timeout {
                        tc_ac.stop; 
                        log("*** " & testcasename() & ": FAIL: The certificate chain has not been received during 1 sec ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                    }
                    
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: Expected CAM not received ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                    }
                } // End of 'alt' statement
                
                // Postamble
                f_terminateCam(v_component);
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_ITSS_SND_CAM_12_BV
            
garciay's avatar
garciay committed
1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000
            /**
             * @desc    Check that IUT sends the secured CAM containing the AA certificate in the requestedCertificate 
             *          headerInfo field when it received a CAM containing a request for unrecognized certificate that 
             *          matches with the currently used AA certificate ID of the IUT.
             * <pre>
             * Pics Selection: PICS_GN_SECURITY, PICS_SEC_P2P_AT_DISTRIBUTION
             * Config Id: CF01
             * Initial conditions:
             *  with {
             *      the IUT is authorized with AT certificate (CERT_IUT_A_AT) 
             *          issued by the AA certificate (CERT_IUT_A_AA)
             *      and the IUT is configured to send more than one CAM per second
             *      and the IUT having already sent a CAM
             *          containing signer
             *              containing certificate
             *          at TIME_1
             *      and the IUT having received a CAM
             *          containing inlineP2pcdRequest
             *              containing HashedId3 value
             *                  indicating last 3 octets of the digest of CERT_IUT_A_AA
             *          at TIME_2 (TIME_1 < TIME_2 < TIME_1+ 1sec)
             *  }
             *  ensure that {
             *      when {
             *          the IUT is requested to send a CAM
             *              at TIME_3 (TIME_1 < TIME_2 < TIME_3 < TIME_1+ 1sec)
             *      } then {
             *          the IUT sends a CAM
             *              containing headerInfo
             *               and containing the requestedCertificate
             *                   indicating requested AA certificate CERT_IUT_A_AA 
             *      }
             *  }
             * </pre>
             *
             * @see          ETSI TS 103 096-2 v1.3.2 TP_SEC_ITSS_SND_CAM_13_BV
             * @reference    ETSI TS 103 097 [1], clause 7.1.1
             *               IEEE 1609.2 [2], clauses 6.3.9, 8.2.4.2.3
             */
            testcase TC_SEC_ITSS_SND_CAM_13_BV() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                const float c_certificateGenerationTime := 1.0;
                
                timer t_maxTransInterval := c_certificateGenerationTime * 0.9;
                var GeoNetworkingInd v_geoNwInd;
                var ItsCam v_component;
                var Certificate v_aa_certificate;
                var HashedId8 v_hashedId8;
                                
                // Test control
                if (not(PICS_GN_SECURITY) or not(PICS_SEC_P2P_AT_DISTRIBUTION)) {
                    log("*** " & testcasename() & ": ERROR: 'PICS_GN_SECURITY and PICS_SEC_P2P_AT_DISTRIBUTION' required for executing the TC ***");
                    stop;
                }
                
                // Test component configuration
                f_cf01Up(); // Initialise IUT with CERT_IUT_A_AT signed with CERT_IUT_A_AA
                
                // Test adapter configuration
                
                // Preamble
                f_prNeighbour();
                f_readCertificate(cc_taCert_AA, v_aa_certificate);
                f_getCertificateDigest(
                    cc_taCert_AA,
                    v_hashedId8
                );
                geoNetworkingPort.clear;
                v_component := f_setCamFrequencyGreatherThan1Hz();
                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 // containing certificate
                                    )
                                ), 
                                mw_geoNwShbPacket
                    ))) {
                        tc_ac.stop;
                        t_maxTransInterval.start;
                        
                        log("*** " & testcasename() & ": INFO: Initial conditions: First CAM message with certificate received ***");
                                                
                        // Send secured message with request for the currently used AT certificate
                        f_sendSecuredCam(
                            cc_taCert_A,
                            valueof(
                                m_headerInfo_cam(
                                    -, 
                                    f_computeGnTimestamp(),
                                    -,
                                    { f_HashedId3FromHashedId8(v_hashedId8) }
                            )),
                            valueof(
                                m_signerIdentifier_digest(
                                    v_hashedId8
                                )
                            )
                        );
                        f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                    }
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: Initial conditions: CAM message with certificate not received ***");
                        f_selfOrClientSyncAndVerdictPreamble("error", e_timeout);
                    }
                } // End of 'alt' statement
                
                // Test Body
                tc_ac.start;
                alt {
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mw_etsiTs103097Data_signed(
                                    mw_signedData(
                                        -, 
                                        mw_toBeSignedData(
                                            mw_signedDataPayload,
                                            mw_headerInfo_cam(
                                                -, -, -, -,
                                                v_aa_certificate
                                            )
                                        )
                                    )
                                ), 
                                mw_geoNwShbPacket
                    ))) -> value v_geoNwInd {
                        tc_ac.stop; 
                        t_maxTransInterval.stop;
                        log("*** " & testcasename() & ": PASS: Generation of CAM messages including certificate ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                    }
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mw_etsiTs103097Data_signed(
                                    mw_signedData(
                                        -, 
                                        mw_toBeSignedData(
                                            mw_signedDataPayload,
                                            mw_headerInfo_cam
                                        ),
                                        mw_signerIdentifier_digest // containing digest
                                    )
                                ), 
                                mw_geoNwShbPacket
                    ))) {
                        log("*** " & testcasename() & ": INFO: CAM retransmission w/o certificate ***"); 
                        repeat;
                    }
                    [] t_maxTransInterval.timeout {
                        tc_ac.stop; 
                        log("*** " & testcasename() & ": FAIL: The certificate chain has not been received during 1 sec ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                    }
                    
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: Expected CAM not received ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                    }
                } // End of 'alt' statement
                
                // Postamble
                f_terminateCam(v_component);
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_ITSS_SND_CAM_13_BV
            
            /**
             * @desc    Check that IUT sends the secured CAM containing the AA certificate in the requestedCertificate headerInfo 
             *          field when it received a CAM containing a request for unrecognized certificate that matches with the known 
             *          AA certificate ID which is not currently used by the IUT.
             * <pre>
             * Pics Selection: PICS_GN_SECURITY, PICS_SEC_P2P_AA_DISTRIBUTION
             * Config Id: CF01
             * Initial conditions:
             *  with {
             *      the IUT is authorized with AT certificate (CERT_IUT_A_AT)
             *      and the IUT is configured to send more than one CAM per second
             *      and the IUT is configured to know the AA certificate (CERT_TS_B_AA)
             *      and the IUT having already sent a CAM
             *          containing signer
             *              containing certificate
             *          at TIME_1
             *      and the IUT having received a CAM
             *          containing inlineP2pcdRequest
             *              containing HashedId3 value
             *                  indicating last 3 octets of the digest of CERT_TS_B_AA
             *                      which is not an issuer of currently used AT certificate
             *          at TIME_2 (TIME_1 < TIME_2 < TIME_1+ 1sec)
             *  }
             *  ensure that {
             *      when {
             *          the IUT is requested to send a CAM
             *              at TIME_3 (TIME_1 < TIME_2 < TIME_3 < TIME_1+ 1sec)
             *      } then {
             *          the IUT sends a SecuredMessage of type EtsiTs103097Data
             *              containing headerInfo
             *                  containing the requestedCertificate
             *                      indicating requested AA certificate CERT_TS_B_AA 
             *      }
             *  }
             * </pre>
             *
             * @see          ETSI TS 103 096-2 v1.3.2 TP_SEC_ITSS_SND_CAM_14_BV
             * @reference    ETSI TS 103 097 [1], clause 7.1.1
             *               IEEE 1609.2 [2], clauses 6.3.9, 8.2.4.2.3
             */
            testcase TC_SEC_ITSS_SND_CAM_14_BV() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                const float c_certificateGenerationTime := 1.0;
                
                timer t_maxTransInterval := c_certificateGenerationTime * 0.9;
                var GeoNetworkingInd v_geoNwInd;
                var ItsCam v_component;
                var Certificate v_aa_certificate;
                var HashedId8 v_hashedId8;
                                
                // Test control
                if (not(PICS_GN_SECURITY) or not(PICS_SEC_P2P_AA_DISTRIBUTION)) {
                    log("*** " & testcasename() & ": ERROR: 'PICS_GN_SECURITY and PICS_SEC_P2P_AA_DISTRIBUTION' required for executing the TC ***");
                    stop;
                }
                
                // Test component configuration
                f_cf01Up(); // Initialise IUT with CERT_IUT_A_AT signed with CERT_IUT_A_AA
                
                // Test adapter configuration
                
                // Preamble
                f_prNeighbour();
                f_readCertificate(cc_taCert_B_AA, v_aa_certificate);
                f_getCertificateDigest(
                    cc_taCert_B_AA,
                    v_hashedId8
                );
                geoNetworkingPort.clear;
                v_component := f_setCamFrequencyGreatherThan1Hz();
                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 // containing certificate
                                    )
                                ), 
                                mw_geoNwShbPacket
                    ))) {
                        tc_ac.stop;
                        t_maxTransInterval.start;
                        
                        log("*** " & testcasename() & ": INFO: Initial conditions: First CAM message with certificate received ***");
                                                
                        // Send secured message with request for the currently used AT certificate
                        f_sendSecuredCam(
                            cc_taCert_A,
                            valueof(
                                m_headerInfo_cam(
                                    -, 
                                    f_computeGnTimestamp(),
                                    -,
                                    { f_HashedId3FromHashedId8(v_hashedId8) }
                            )),
                            valueof(
                                m_signerIdentifier_digest(
                                    v_hashedId8
                                )
                            )
                        );
                        f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                    }
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: Initial conditions: CAM message with certificate not received ***");
                        f_selfOrClientSyncAndVerdictPreamble("error", e_timeout);
                    }
                } // End of 'alt' statement
                
                // Test Body
                tc_ac.start;
                alt {
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mw_etsiTs103097Data_signed(
                                    mw_signedData(
                                        -,