ItsSecurity_TestCases.ttcn 1.5 MB
Newer Older
garciay's avatar
garciay committed
2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380
                                        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);
                    }
                    [] 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_14_BV
            
            /**
             * @desc    Check that the IUT doesn't send a secured CAM containing the AA certificate in the requestedCertificate 
             *          headerInfo field when it was previously requested and already received from another ITS-S.
             * <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) 
             *          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+ 0.8sec)
             *  }
             *  ensure that {
             *      when {
             *          the IUT is requested to send a secured CAM
             *              at TIME_3 (TIME_1 < TIME_2 < TIME_3 < TIME_1+ 0.9sec)
             *      } then {
             *          the IUT sends a SecuredMessage of type EtsiTs103097Data
             *              containing headerInfo
             *                  does not containing requestedCertificate 
             *      }
             *  }
             * </pre>
             *
             * @see          ETSI TS 103 096-2 v1.3.2 TP_SEC_ITSS_SND_CAM_15_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_15_BV() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                const float c_certificateGenerationTime := 0.8;
                
                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_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_sleep(0.1);
                        f_sendSecuredCam(
                            cc_taCert_A,
                            valueof(
                                m_headerInfo_cam(
                                    -, 
                                    f_computeGnTimestamp(),
                                    -,
                                    -,
                                    v_aa_certificate
                            )),
                            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_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);
                    }
                    [] 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_15_BV
            
            /**
             * @desc    Check that the IUT doesn't send a secured CAM containing the AA certificate in the requestedCertificate 
             *          headerInfo field when it contains certificate in the signer field.
             * <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) 
             *          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+ 0.9sec)
             *  }
             *  ensure that {
             *      when {
             *          the IUT is requested to send a secured CAM
             *              at TIME_3 (TIME_1 < TIME_2 < TIME_3 < TIME_1+ 1sec)
             *      } then {
             *          the IUT sends a SecuredMessage of type EtsiTs103097Data
             *              containing headerInfo
             *                  does not containing requestedCertificate 
             *              and containing signer
             *                  containing certificate
             *      }
             *  }
             * </pre>
             *
             * @see          ETSI TS 103 096-2 v1.3.2 TP_SEC_ITSS_SND_CAM_16_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_16_BV() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                const float c_certificateGenerationTime := 0.8;
                
                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_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
                                        ),
                                        mw_signerIdentifier_certificate // containing 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_16_BV
            
//            /**
//             * @desc    Check that the IUT doesn't send a secured CAM contains the signer_info of type certificate_chain
//             *           when the AA certificate was previously requested and already received from another ITS-S 
//             * <pre>
//             * Pics Selection: PICS_GN_SECURITY PICS_PLUGTEST_VERSION
//             * Config Id: CF01
//             * Initial conditions:
//             * </pre>
//             * with
//             *     the IUT being in the 'authorized' state
//             *     and the IUT is configured to send more than one CAM per second
//             *     and the IUT having already sent a CAM
//             *         containing header_fields['signer_info'].signer.type
garciay's avatar
garciay committed
//             *             containing certificate
//             *         at TIME_1
//             *     and the IUT having received a Ieee1609Dot2Data
//             *         containing header_fields['request_unrecognized_certificate']
//             *             containing digests
//             *                 containing HashedId3 value (HASH1)
//             *                     referencing to the AA certificate
//             *         at TIME_2 (TIME_1 < TIME_2 < TIME_1+1sec)
//             *     and the IUT having received a Ieee1609Dot2Data
//             *         containing header_fields['signer_info'].signer.type
//             *             indicating 'certificate_chain'
//             *                 containing AA certificate
//             *                     having HashedId3 value of HASH1
//             *         at TIME_3 (TIME_2 < TIME_3 < TIME_2+0.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 Ieee1609Dot2Data
//             *             and containing header_fields['signer_info']
//             *                 containing signer
//             *                     containing type
//             *                         indicating 'digest'
garciay's avatar
garciay committed
//             *                         or containing certificate
//             *
//             * @see          ETSI TS 103 096-2 v1.3.3 TP_SEC_ITSS_SND_CAM_09_02_BV
//             * @reference    ETSI TS 103 097 [1], clause 7.1
//             */
//            testcase TC_SEC_ITSS_SND_CAM_09_02_BV() runs on ItsGeoNetworking system ItsSecSystem {
//                
//                // Local variables
//                const float c_certificateGenerationTime := 1.0;
//                
//                timer t_maxTransInterval := c_certificateGenerationTime * 1.1;
//                var GeoNetworkingInd v_geoNwInd;
//                var ItsCam v_component;
//                var SignerInfo v_si;
//                var boolean f_CamReceived := false;
//                
//                // Test control
//                if (not(PICS_GN_SECURITY)) {
//                    log("*** " & testcasename() & ": ERROR: 'PICS_GN_SECURITY' required for executing the TC ***");
//                    stop;
//                }
//                if (not(PICS_PLUGTEST_VERSION)) {
//                    log("*** " & testcasename() & ": ERROR: 'PICS_PLUGTEST_VERSION' required for executing the TC ***");
//                    stop;
//                }
//                // Test component configuration
//                f_cf01Up(); // init IUT with CERT_IUT_A_AT signed with CERT_TS_A_AA
//                
//                // Test adapter configuration
//                
//                // Preamble
//                f_prNeighbour();
//                geoNetworkingPort.clear;
//                v_component := f_setCamFrequencyGreatherThan1Hz();
//                tc_ac.start;
//                alt {
//                    [] geoNetworkingPort.receive(
//                        mw_geoNwInd(
//                            mw_geoNwSecPdu(
//                                mw_ieee1609Dot2Data_CAMs(
//                                    mw_header_info_signer_info_certificate
//                    ))))  -> value v_geoNwInd { 
//                        tc_ac.stop;
//                        t_maxTransInterval.start;
//                        
//                        f_getMsgSignerInfo(f_getSecuredMessage(v_geoNwInd.msgIn),v_si);
//                        f_getCertificateSignerInfo(v_si.signerInfo.certificate, v_si);
//                        log("*** " & testcasename() & ": INFO: Initial conditions: First CAM message with certificate received ***");
//                                                
//                        // Send secured message with request for unrecognized certificate
//                        f_sendSecuredCam(
//                            cc_taCert_B1 , // certificate signed with CERT_TS_B_AA
//                            {
//                                m_header_info_unrecognised_certificate(                    // containing digests
//                                    f_HashedId3FromHashedId8(                               //     containing HashedId3 value
//                                        v_si.signerInfo.digest                              //         referencing to the CERT_TS_A_AA certificate
//                                    )
//                                )
//                            });
//
//                        // Send secured message signed with certificate_chain
//                        f_sendSecuredCam(
//                            cc_taCert_A, // sign message with CERT_TS_A_AT signed with CERT_TS_A_AA
//                            omit,
//                            e_certificate_chain // and send both certs in the chain
//                        );
//                        
//                        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_ieee1609Dot2Data_CAMs(
//                                    mw_header_info_signer_info_certificate_chain
//                    )))) {
//                        log("*** " & testcasename() & ": FAIL: CAM retransmition with unexpected certificate_chain ***");
//                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error); 
//                    }
//                    [] geoNetworkingPort.receive(
//                        mw_geoNwInd(
//                            mw_geoNwSecPdu(
//                                mw_ieee1609Dot2Data_CAMs
//                    ))) {
//                        log("*** " & testcasename() & ": INFO: CAM retransmission w/o certificate chain ***"); 
//                        f_CamReceived := true;
//                        repeat;
//                    }
//                    [f_CamReceived] t_maxTransInterval.timeout {
//                        tc_ac.stop; 
//                        log("*** " & testcasename() & ": PASS: Generation of CAM messages including certificate chain was successfully skipped ***");
//                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
//                    }
//                    [] t_maxTransInterval.timeout {
//                        tc_ac.stop;
//                        log("*** " & testcasename() & ": INCONC: Expected CAM not received ***");
//                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
//                    }
//                    [] 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_02_BV
//            
//            
//            /**
//             * @desc    Check that the sent secured CAM contains exactly one HeaderInfo generation_time which is inside 
//             *          the validity time of the certificate referenced by the signer_info
//             * <pre>
//             * Pics Selection: PICS_GN_SECURITY
//             * Config Id: CF01
//             * Initial conditions:
//             *  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 CAM
//             *      } then {
//             *          the IUT sends a Ieee1609Dot2Data 
//             *              containing security_profile
//             *                  indicating '1'
//             *              containing header_fields ['generation_time'] 
//             *                  containing generation_time
//             *                      indicating TIME_1 (CUR_TIME - 5min <= TIME_1 <= CUR_TIME + 5min)
//             *              containing header_fields ['signer_info'] 
//             *                  containing signer 
//             *                      containing type
garciay's avatar
garciay committed
//             *                          containing certificate
//             *                      and containing certificate 
//             *                          containing validity_restrictions['time_end']
//             *                              containing end_validity
//             *                                  indicating value > GEN_TIME
//             *                          or containing validity_restrictions['time_start_and_end']
//             *                              containing start_validity
//             *                                  indicating value <= GEN_TIME
//             *                              and containing end_validity
//             *                                  indicating value > GEN_TIME
//             *                          or containing validity_restrictions['time_start_and_duration']
//             *                              containing start_validity (X_START_VALIDITY)
//             *                                  indicating value <= GEN_TIME
//             *                              and containing duration
//             *                                  indicating value > GEN_TIME - X_START_VALIDITY 
//             *      }
//             *  }
//             * </pre>
//             *
garciay's avatar
garciay committed
//             * @see          ETSI TS 103 096-2 v1.3.2 TP_SEC_ITSS_SND_CAM_10_01_BV
//             * @reference    ETSI TS 103 097 [1], clauses 5.4 and 7.1
//             */
//            testcase TC_SEC_ITSS_SND_CAM_10_01_BV() runs on ItsGeoNetworking system ItsSecSystem {
//                
//                // Local variables
//                const integer c_timeThreshold := 1000 * 60; /** Time threshold in milliseconds */
//                
//                var GeoNetworkingInd v_geoNwInd;
//                var SignerInfo v_signerInfo;
//                var Certificate v_certificate;
//                var HeaderInfo v_headerField;
//                var Time64 v_generationTime;
//                var ValidityRestriction v_validity;
//                var integer v_currentTime, v_lowerBound, v_upperBound;
//                
//                // Test control
//                if (not(PICS_GN_SECURITY)) {
//                    log("*** " & testcasename() & ": ERROR: 'PICS_GN_SECURITY' required for executing the TC ***");
//                    stop;
//                }
//                
//                // Test component configuration
//                f_cf01Up();
//                
//                // Test adapter configuration
//                
//                // Preamble
//                f_prNeighbour();
//                
//                // Test Body
//                tc_ac.start;
//                alt {
//                    [] geoNetworkingPort.receive(
//                        mw_geoNwInd(
//                            mw_geoNwSecPdu(
//                                mw_securedMessage(
//                                    superset(
//                                        mw_header_info_generation_time, 
//                                        mw_header_info_signer_info_certificate,
//                                        mw_header_info_its_aid_CAM
//                    ))))) -> value v_geoNwInd {
//                        tc_ac.stop; 
//                        log("*** " & testcasename() & ": INFO: CAM transmission with certificate ***");
//                        
//                        v_currentTime := f_getCurrentTime();
//                        log("v_currentTime (us)=", v_currentTime * 1000);
//                        v_lowerBound := (v_currentTime - c_timeThreshold) * 1000;
//                        v_upperBound := (v_currentTime + c_timeThreshold) * 1000;
//                        
//                        // Extract generation_time
//                        f_getMsgHeaderField(v_geoNwInd.msgIn.gnPacket.securedMsg, e_generation_time, v_headerField);
//                        v_generationTime := v_headerField.headerField.generation_time;
//                        
//                        // Extract certificate
//                        f_getMsgSignerInfo(v_geoNwInd.msgIn.gnPacket.securedMsg, v_signerInfo);
//                        v_certificate := v_signerInfo.signerInfo.certificate;
//                         
//                        // Check current time 
//                        if (match(v_generationTime, (v_lowerBound .. v_upperBound))) {
//                            log("*** " & testcasename() & ": PASS: Generation time matches current time ***");
//                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success); 
//                        } else {
//                            log("*** " & testcasename() & ": FAIL: Generation time does not match current time " & int2str(v_currentTime-v_lowerBound) & " / " & int2str(v_upperBound - v_currentTime) & " . ***");
//                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
//                        }   
//                        
//                        // Check generation_time validity
//                        if (
//                            (f_getCertificateValidityRestriction(v_certificate, e_time_start_and_end, v_validity) == true) and 
//                            (v_generationTime >= (v_validity.validity.time_start_and_end.start_validity * 1000000) and 
//                            (v_generationTime < (v_validity.validity.time_start_and_end.end_validity * 1000000)))
//                        ) {
//                            log("*** " & testcasename() & ": PASS: Generation time within certificate validity/time_start_and_end ***");
//                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success); 
//                        } else if (
//                            (f_getCertificateValidityRestriction(v_certificate, e_time_end, v_validity) == true) and 
//                            (v_generationTime < (v_validity.validity.end_validity * 1000000))
//                        ) {
//                            log("*** " & testcasename() & ": PASS: Generation time within certificate validity ***");
//                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success); 
//                        } else if (f_getCertificateValidityRestriction(v_certificate, e_time_start_and_duration, v_validity) == true) {
//                            if (PICS_PLUGTEST_VERSION) {
//                                log("*** " & testcasename() & ": FAIL: Usage of time_start_and_duration is forbidden in TS103097 v1.2.5 ***");
//                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
//                            }
//                            if ((v_generationTime >= (v_validity.validity.time_start_and_duration.start_validity * 1000000)) and 
//                                (v_generationTime < (f_duration2time(v_validity.validity.time_start_and_duration.duration_) * 1000000))
//                            ) {
//                                log("*** " & testcasename() & ": PASS: Generation time within certificate validity ***");
//                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success); 
//                            }
//                        } else {
//                            log("*** " & testcasename() & ": FAIL: Generation time not within certificate validity ***");
//                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
//                        }
//                    }
//                    [] geoNetworkingPort.receive(
//                        mw_geoNwInd(
//                            mw_geoNwSecPdu(
//                                mw_ieee1609Dot2Data_CAMs
//                    ))) {
//                        log("*** " & testcasename() & ": INFO: CAM retransmission w/o certificate  ***"); 
//                        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_01_BV
//            
//            /**
//             * @desc    Check that the IUT sends certificate request when it receives a message from unknown station
//             * <pre>
//             * Pics Selection: PICS_GN_SECURITY
//             * Config Id: CF01
//             * Initial conditions:
//             *  with {
//             *      the IUT being in the 'authorized' state
//             *      and the IUT has receiving a Ieee1609Dot2Data
//             *          containing header_fields['signer_info'].signer
//             *              containing type
//             *                  indicating 'certificate_digest_with_sha256'
//             *              containing digest
//             *                  indicating HashedId3 value DIGEST_A
//             *                      referenced to unknown certificate
//             *  }
//             *  ensure that {
//             *      when {
//             *          the IUT is requested to send CAM
//             *      } then {
//             *          the IUT sends a Ieee1609Dot2Data
//             *              containing header_fields['request_unrecognized_certificate']
//             *                  containing digests
//             *                      containing HashedId3 value
//             *                          indicating DIGEST_A
//             *      }
//             *  }
//             * </pre>
//             *
garciay's avatar
garciay committed
//             * @see          ETSI TS 103 096-2 v1.3.2 TP_SEC_ITSS_SND_CAM_12_01_BV
//             * @reference    ETSI TS 103 097 [1], clause 7.1
//             */
//            testcase TC_SEC_ITSS_SND_CAM_12_01_BV() runs on ItsGeoNetworking system ItsSecSystem {
//                // Local variables
//                var HashedId8 v_expectedHashedId8;
//                var HashedId3 v_expectedHashedId3;
//                var GeoNetworkingPdu v_securedGnPduToBeSent;
//                
//                // Test control
//                if (not(PICS_GN_SECURITY)) {
//                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY' required for executing the TC ***");
//                    stop;
//                }
//                
//                // Send secured message from unknown ITS-S
//                // Test component configuration
//                f_cf01Up();
//                
//                // Test adapter configuration
//                
//                // Preamble
//                f_prNeighbour();
//                
//                f_getCertificateDigest(
//                    cc_taCert_F,
//                    v_expectedHashedId8
//                );
//                v_expectedHashedId3 := f_HashedId3FromHashedId8(v_expectedHashedId8);
//                
//                // preamble: waiting for CAM with certificate and send a CAM with unknown digest right after that
//                v_securedGnPduToBeSent := f_prepareSecuredCam(cc_taCert_F);
//                   
//                geoNetworkingPort.clear;
//                tc_ac.start;
//                alt {
//                    [] geoNetworkingPort.receive
//                    {
//                        f_sendGeoNetMessage(valueof(m_geoNwReq_linkLayerBroadcast(v_securedGnPduToBeSent)));
//                        tc_ac.stop;
//
//                        log("*** " & testcasename() & ": INFO: Initial conditions: First CAM message with certificate 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 preamble 'alt' statement
//
//                // Test Body
//                tc_ac.start;
//                alt {
//                    [] geoNetworkingPort.receive(
//                        mw_geoNwInd(
//                            mw_geoNwSecPdu(
//                                mw_ieee1609Dot2Data_CAMs(
//                                    mw_header_info_request_unrecognized_certificate(
//                                        { v_expectedHashedId3 }
//                    ))))) {
//                        tc_ac.stop;
//                        log("*** " & testcasename() & ": PASS: CAM received with request for unrecognized certificate");
//                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
//                    }
//                    [] geoNetworkingPort.receive(
//                        mw_geoNwInd(
//                            mw_geoNwSecPdu(
//                                mw_ieee1609Dot2Data_CAMs
//                    ))) {
//                        log("*** " & testcasename() & ": FAIL: CAM received without request for unrecognized certificate ***"); 
//                        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_poNeighbour();
//                f_cf01Down();
//            } // End of testcase TC_SEC_ITSS_SND_CAM_12_01_BV
//            
//            /**
//             * @desc    Check that the Secured CAM contains non-empty payload of type signed
//             * <pre>
//             * Pics Selection: PICS_GN_SECURITY
//             * Config Id: CF01
//             * Initial conditions:
//             *  with {
//             *      the IUT being in the 'authorized' state
//             *  }
//             *  ensure that {
//             *      when {
//             *          the IUT is requested to send a CAM
//             *      } then {
//             *          the IUT sends a Ieee1609Dot2Data
//             *              containing payload_field
//             *                  containing exactly one element of type Payload
//             *                      containing type
//             *                          indicating 'signed'
//             *                      containing not-empty data
//             *      }
//             *  }
//             * </pre>
//             *
garciay's avatar
garciay committed
//             * @see          ETSI TS 103 096-2 v1.3.2 TP_SEC_ITSS_SND_CAM_14_01_BV
//             * @reference    ETSI TS 103 097 [1], clause 7.1
//             */
//            testcase TC_SEC_ITSS_SND_CAM_14_01_BV() runs on ItsGeoNetworking system ItsSecSystem {
//                // Local variables
//                
//                // Test control
//                if (not(PICS_GN_SECURITY)) {
//                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY' required for executing the TC ***");
//                    stop;
//                }
//                
//                // Test component configuration
//                f_cf01Up();
//                
//                // 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_ieee1609Dot2Data_CAMs(
//                                    ?, 
//                                    mw_payload(
//                                        e_signed
//                    ))))) {
//                        tc_ac.stop;
//                        
//                        log("*** " & testcasename() & ": PASS: CAM received with exactly 1 signed payload");
//                        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_poNeighbour();
//                f_cf01Down();
//            } // End of testcase TC_SEC_ITSS_SND_CAM_14_01_BV
//            /**
//             * @desc    Check that the secured CAM contains only the trailer field of type signature 
//             *          and no other trailer fields
//             * <pre>
//             * Pics Selection: PICS_GN_SECURITY PICS_PLUGTEST_VERSION
//             * Config Id: CF01
//             * Initial conditions:
//             * with
//             *         the IUT being in the 'authorized' state
//             * ensure that
//             *     when
//             *         the IUT is requested to send a CAM
//             *     then
//             *         the IUT sends a Ieee1609Dot2Data
//             *             containing trailer_fields
//             *                 containing trailer_fields[0]
//             *                     containing type
//             *                         indicating 'signature'
//             *                 and not containing any other items
//
//             * </pre>
//             *
garciay's avatar
garciay committed
//             * @see          ETSI TS 103 096-2 v1.3.2 TP_SEC_ITSS_SND_CAM_15_01_BV
//             * @reference    ETSI TS 103 097 [1], clause 7.1
//             */
//            testcase TC_SEC_ITSS_SND_CAM_15_01_BV() runs on ItsGeoNetworking system ItsSecSystem {
//                
//                //  Local variables
//                const integer c_nbVerification := 3;
//                var integer v_nbVerification := 0;
//                var GeoNetworkingInd v_geoNwInd;
//                var SignerInfo v_signerInfo;
//                var Certificate v_certificate;
//                var boolean v_certificateReceived := false;
//                
//                // Test control
//                if (not(PICS_GN_SECURITY)) {
//                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY' required for executing the TC ***");
//                    stop;
//                }
//                if (not(PICS_PLUGTEST_VERSION)) {
//                    log("*** " & testcasename() & ":ERROR: 'PICS_PLUGTEST_VERSION' required for executing the TC ***");
//                    stop;
//                }
//                
//                // Test component configuration
//                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_ieee1609Dot2Data_CAMs(?, ?,
//                                    superset(mw_trailer_field_signature,
//                                             mw_trailer_field
//                    ))))){
//                        tc_ac.stop;
//                        log("*** " & testcasename() & ": FAIL: CAM received with more then one trailer fields");
//                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
//                    }
//                    [] geoNetworkingPort.receive(
//                        mw_geoNwInd(
//                            mw_geoNwSecPdu(
//                                mw_ieee1609Dot2Data_CAMs(?, ?,
//                                { mw_trailer_field_signature }
//                    )))){
//                        tc_ac.stop;
//                        log("*** " & testcasename() & ": INFO: CAM message with signature trailer received ***");
//                        v_nbVerification := v_nbVerification + 1;
//                        if (v_nbVerification < c_nbVerification) {
//                            tc_ac.start;
//                            repeat;
//                        }
//                    }
//                    [] tc_ac.timeout {
//                        log("*** " & testcasename() & ": INCONC: Expected CAM not received ***");
//                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
//                    }
//                } // End of 'alt' statement
//                log("*** " & testcasename() & ": PASS: All CAMs received with correct trailer fields count");
//                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
//                
//                // Postamble
//                f_poNeighbour();
//                f_cf01Down();
//            } // End of testcase TC_SEC_ITSS_SND_CAM_15_01_BV
//             
//            
//            /**
//             * @desc    Check that the secured CAM contains only one TrailerField of type signature.
//             *          Check that the signature contained in the Ieee1609Dot2Data is calculated over the right fields by 
//             *          cryptographically verifying the signature.
//             * <pre>
//             * Pics Selection: PICS_GN_SECURITY
//             * Config Id: CF01
//             * Initial conditions:
//             *  with {
//             *      the IUT being in the 'authorized' state
//             *  }
//             *  ensure that {
//             *      when {
//             *          the IUT is requested to send a CAM
//             *      } then {
//             *          the IUT sends a Ieee1609Dot2Data
//            *              containing header_fields ['signer_info']
//             *                  containing signer
//             *                      containing type
//             *                          indicating 'certificate_digest_with_sha256'
//             *                      containing digest
//             *                          referenced to the certificate
//             *                              containing subject_info.subject_type
//             *                                  indicating 'authorization_ticket' (2)
//             *                              and containing subject_attributes['verification key'] (KEY)
//             *                  or containing signer
//             *                      containing type