ItsSecurity_TestCases.ttcn 1.59 MB
Newer Older
1
/**
garciay's avatar
garciay committed
2
 *  @author   ETSI / STF481 / STF507 / STF517 / STF538
3
4
5
 *  @version  $URL$
 *            $Id$
 *  @desc     Testcases  file for Security Protocol
filatov's avatar
filatov committed
6
 *  @reference   ETSI TS 103 097 v1.2.1
garciay's avatar
garciay committed
7
8
9
10
 *  @copyright   ETSI Copyright Notification
 *               No part may be reproduced except as authorized by written permission.
 *               The copyright and the foregoing restriction extend to reproduction in all media.
 *               All rights reserved.
11
 */
filatov's avatar
filatov committed
12
module ItsSecurity_TestCases {
13
14
15
16
17
18
19
20
    
    // Libcommon
    import from LibCommon_Time all;
    import from LibCommon_VerdictControl all;
    import from LibCommon_Sync all;
    import from LibCommon_BasicTypesAndValues all;
    
    // LibIts
garciay's avatar
garciay committed
21
    //import from DENM_PDU_Descriptions language "ASN.1:1997" all;
garciay's avatar
garciay committed
22
23
24
    import from IEEE1609dot2BaseTypes language "ASN.1:1997" all;
    import from IEEE1609dot2 language "ASN.1:1997" all;
    import from EtsiTs103097Module language "ASN.1:1997" all;
25
26
    
    // LibItsCommon
27
    import from LibItsCommon_TypesAndValues all;
28
    import from LibItsCommon_Functions all;
29
    import from LibItsCommon_TypesAndValues all;
filatov's avatar
filatov committed
30
    import from LibItsCommon_ASN1_NamedNumbers all;
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
    
    // LibItsGeoNetworking
    import from LibItsGeoNetworking_TestSystem all;
    import from LibItsGeoNetworking_Functions all;
    import from LibItsGeoNetworking_Templates all;
    import from LibItsGeoNetworking_TypesAndValues all;
    import from LibItsGeoNetworking_Pics all;

    // LibItsCam
    import from LibItsCam_Templates all;
    import from LibItsCam_Functions all;
    import from LibItsCam_Templates all;
    import from LibItsCam_Functions all;
    import from LibItsCam_TestSystem all;
    
    // LibItsDenm
    import from LibItsDenm_Templates all;
    import from LibItsDenm_TestSystem all;
    
    // LibItsSecurity
    import from LibItsSecurity_TypesAndValues all;
    import from LibItsSecurity_Templates all;
    import from LibItsSecurity_Functions all;
    import from LibItsSecurity_Pixits all;
    import from LibItsSecurity_Pics all;
    
    // AtsSecurity
filatov's avatar
filatov committed
58
59
60
61
    import from ItsSecurity_TestSystem all;
    import from ItsSecurity_Functions all;
    import from ItsSecurity_Templates all;
    import from ItsSecurity_Pics all;
62
63
64
    
    /**
     * @desc Sending behaviour test cases
garciay's avatar
garciay committed
65
     * @see ETSI TS 103 096-2 V1.3.32 (2018-01) Clause 5.2 Sending behaviour
66
67
68
     */
    group sendingBehavior {

garciay's avatar
garciay committed
69
        /**
70
         * @desc    Check that ITS-S sends a Ieee1609Dot2Data containing protocol version set to 3.
garciay's avatar
garciay committed
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
         * <pre>
         * Pics Selection: PICS_GN_SECURITY
         * Config Id: CF01
         * Initial conditions:
         *  with {
         *      the IUT being in the 'authorized' state
         *  }
         * Expected behaviour:
         * ensure that {
         *     when { 
         *         the IUT is requested to send a Ieee1609Dot2Data
         *     } then {
         *         the IUT sends a Ieee1609Dot2Data
         *             containing protocol_version 
         *                 indicating value '3'
         *     }
         * }
         * </pre>
         *
garciay's avatar
garciay committed
90
         * @see         ETSI TS 103 096-2 v1.3.2 TP_TC_SEC_ITSS_SND_MSG_01_BV
91
92
         * @reference   ETSI TS 103 097 [1] Clause 5.1 
         * @reference   IEEE1609.2[2] Clause 6.3.2
garciay's avatar
garciay committed
93
94
95
96
97
98
99
         */
        testcase TC_SEC_ITSS_SND_MSG_01_BV() runs on ItsGeoNetworking system ItsSecSystem {
                
            // Local variables
            var LongPosVector v_longPosVectorIut;
                
            // Test control
garciay's avatar
garciay committed
100
101
            if (not(PICS_GN_SECURITY)) {
                log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY' required for executing the TC ***");
garciay's avatar
garciay committed
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
                stop;
            }
            
            // Test component configuration
            f_cf01Up();
            v_longPosVectorIut := f_getPosition(c_compIut);
                
            // Test adapter configuration
            
            // Preamble
            f_prNeighbour();
            f_acTriggerEvent(m_startPassBeaconing(m_beaconHeader(v_longPosVectorIut).beaconHeader)); // Authorize the TA to forward the received beacons
            f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
            
            // Test Body
            tc_ac.start;
            alt {
119
120
121
122
123
                [] geoNetworkingPort.receive(
                    mw_geoNwInd(
                        mw_geoNwSecPdu(
                            mw_etsiTs103097Data_signed
                ))) {
garciay's avatar
garciay committed
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
                    tc_ac.stop;
                    log("*** " & testcasename() & ": PASS: Security protocol version set to 3 ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                }
                [] tc_ac.timeout {
                    log("*** " & testcasename() & ": INCONC: Expected message not received ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                }
            } // End of 'alt' statement
            
            // Postamble
            f_acTriggerEvent(m_stopPassBeaconing);
            f_poNeighbour();
            f_cf01Down();
            
        } // End of testcase TC_SEC_ITSS_SND_MSG_01_BV
        
141
        /**
142
         * @desc Sending behaviour test cases for CAM profile.
garciay's avatar
garciay committed
143
         * @see ETSI TS 103 096-2 V1.3.32 (2018-01) Clause 5.2.4 CAM profile
144
         */
145
        group camProfile {
garciay's avatar
garciay committed
146
147
            
            /**
148
             * @desc    Check that IUT sends the secured CAM using SignedData container.
garciay's avatar
garciay committed
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
             * <pre>
             * Pics Selection: PICS_GN_SECURITY
             * Config Id: CF01
             * Initial conditions:
             *  with {
             *     the IUT is authorized with AT certificate (CERT_IUT_A_AT) 
             * }
             * ensure that {
             *     when {
             *         the IUT is requested to send a secured CAM
             *     } then {
             *         the IUT sends a message of type EtsiTs103097Data
             *             containing content
             *                 containing signedData
             *     }
             * }
             * </pre>
             *
garciay's avatar
garciay committed
167
             * @see          ETSI TS 103 096-2 v1.3.2 TP_SEC_ITSS_SND_CAM_01_BV
168
             * @reference    ETSI TS 103 097 [1] Clause 7.1.1
garciay's avatar
garciay committed
169
170
171
172
173
174
175
176
177
178
179
180
181
             */
            testcase TC_SEC_ITSS_SND_CAM_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
garciay's avatar
garciay committed
182
                f_cf01Up(); // Initialise IUT with CERT_IUT_A_AT signed with CERT_IUT_A_AA
garciay's avatar
garciay committed
183
184
185
186
187
188
189
190
191
192
193
194
195
                
                // Test adapter configuration
                
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
                tc_ac.start;
                alt {
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
garciay's avatar
garciay committed
196
197
198
199
200
201
202
203
                                mw_etsiTs103097Data_signed(
                                    mw_signedData(
                                        -, 
                                        mw_toBeSignedData(
                                            mw_signedDataPayload,
                                            mw_headerInfo_cam
                                        )
                                    )
204
205
                                ), 
                                mw_geoNwShbPacket
garciay's avatar
garciay committed
206
207
208
209
210
211
                    ))) {
                        tc_ac.stop;
                        log("*** " & testcasename() & ": PASS: The CA message is secured");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                    }
                    [] tc_ac.timeout {
212
                        log("*** " & testcasename() & ": INCONC: Expected CA message not received ***");
garciay's avatar
garciay committed
213
214
215
216
217
218
219
220
221
222
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                    } 
                } // End of 'alt' statement
                
                // Postamble
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_ITSS_SND_CAM_01_BV
            
            /**
223
             * @desc Check that IUT sends the secured CAM containing the HeaderInfo field psid set to 'AID_CAM'.
garciay's avatar
garciay committed
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
             * <pre>
             * Pics Selection: PICS_GN_SECURITY
             * Config Id: CF01
             * Initial conditions:
             *  with {
             *     the IUT is authorized with AT certificate (CERT_IUT_A_AT) 
             * }
             * ensure that {
             *     when {
             *         the IUT is requested to send a secured CAM
             *     } then {
             *         the IUT sends a Ieee1609Dot2Data
             *             containing content
             *                 containing signedData
             *                     containing tbsData
             *                         containing headerInfo
             *                             containing psid
             *                                 indicating 'AID_CAM'
             * </pre>
             *
garciay's avatar
garciay committed
244
             * @see         ETSI TS 103 096-2 v1.3.2 TP_SEC_ITSS_SND_CAM_02_BV
245
             * @reference    ETSI TS 103 097 [1] Clause 7.1.1
garciay's avatar
garciay committed
246
247
248
249
250
251
252
253
254
255
256
257
             */
            testcase TC_SEC_ITSS_SND_CAM_02_BV() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                
                // Test control
                if (not(PICS_GN_SECURITY)) {
                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY' required for executing the TC ***");
                    stop;
                }
                
                // Test component configuration
garciay's avatar
garciay committed
258
                f_cf01Up(); // Initialise IUT with CERT_IUT_A_AT signed with CERT_IUT_A_AA
garciay's avatar
garciay committed
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
                
                // Test adapter configuration
                
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
                tc_ac.start;
                alt {
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mw_etsiTs103097Data_signed(
                                    mw_signedData(
                                        -, 
                                        mw_toBeSignedData(
                                            mw_signedDataPayload,
                                            mw_headerInfo_cam
                                        )
                                    )
                                ), 
                                mw_geoNwShbPacket
                    ))) {
                        tc_ac.stop;                        
garciay's avatar
garciay committed
284
                        log("*** " & testcasename() & ": PASS: Correct secured packet received");
garciay's avatar
garciay committed
285
286
287
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                    }
                    [] tc_ac.timeout {
288
                        log("*** " & testcasename() & ": INCONC: Expected CA message not received ***");
garciay's avatar
garciay committed
289
290
291
292
293
294
295
296
297
298
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                    } 
                } // End of 'alt' statement
                
                // Postamble
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_ITSS_SND_CAM_02_BV
            
            /**
garciay's avatar
garciay committed
299
             * @desc Check that IUT sends the secured CAM with the HeaderInfo containing generationTime 
300
             *       and doesn't containing expiryTime, generationLocation, encryptionKey, p2pcdLearningRequest, missingCrlIdentifier.
garciay's avatar
garciay committed
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
             * <pre>
             * Pics Selection: PICS_GN_SECURITY
             * Config Id: CF01
             * Initial conditions:
             *  with {
             *     the IUT is authorized with AT certificate (CERT_IUT_A_AT) 
             * }
             * ensure that {
             *     when {
             *         the IUT is requested to send a secured CAM
             *     } then {
             *         the IUT sends a Ieee1609Dot2Data
             *             containing content
             *                 containing signedData
             *                     containing tbsData
             *                         containing headerInfo
             *                             containing generationTime
             *                             and not containing expiryTime
             *                             and not containing generationLocation, 
             *                             and not containing encryptionKey
             *                             and not containing p2pcdLearningRequest
             *                             and not containing missingCrlIdentifier
             * </pre>
             *
garciay's avatar
garciay committed
325
             * @see         ETSI TS 103 096-2 v1.3.2 TP_SEC_ITSS_SND_CAM_03_BV
326
             * @reference    ETSI TS 103 097 [1] Clauses 5.2 & 7.1.1
garciay's avatar
garciay committed
327
328
329
330
331
332
333
334
335
336
337
338
             */
            testcase TC_SEC_ITSS_SND_CAM_03_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
garciay's avatar
garciay committed
339
                f_cf01Up(); // Initialise IUT with CERT_IUT_A_AT signed with CERT_IUT_A_AA
garciay's avatar
garciay committed
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
                
                // Test adapter configuration
                
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
                tc_ac.start;
                alt {
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mw_etsiTs103097Data_signed(
                                    mw_signedData(
                                        -, 
                                        mw_toBeSignedData(
                                            mw_signedDataPayload,
                                            mw_headerInfo_cam
                                        )
                                    )
                                ), 
                                mw_geoNwShbPacket
                    ))) {
                        tc_ac.stop;                        
garciay's avatar
garciay committed
365
                        log("*** " & testcasename() & ": PASS: Correct secured packet received");
garciay's avatar
garciay committed
366
367
368
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                    }
                    [] tc_ac.timeout {
369
                        log("*** " & testcasename() & ": INCONC: Expected CA message not received ***");
garciay's avatar
garciay committed
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                    } 
                } // End of 'alt' statement
                
                // Postamble
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_ITSS_SND_CAM_03_BV
            
            /**
             * @desc Check that IUT sends the secured CAM containing signer containing either certificate or digest;
             *       Check that signing certificate has permissions to sign CAM messages.
             * <pre>
             * Pics Selection: PICS_GN_SECURITY
             * Config Id: CF01
             * Initial conditions:
             *  with {
             *     the IUT is authorized with AT certificate (CERT_IUT_A_AT) 
             * }
             * ensure that {
             *     when {
             *         the IUT is requested to send a secured CAM
             *     } then {
             *         the IUT sends a Ieee1609Dot2Data
             *             containing content
             *                 containing signedData
             *                     containing signer
             *                         containing digest
             *                         or containing certificate
             *                             containing toBeSigned
             *                                 containing appPermissions
             *                                     containing the item of type PsidSsp
             *                                         containing psid
             *                                             indicating AID_CAM
             * </pre>
             *
garciay's avatar
garciay committed
406
             * @see         ETSI TS 103 096-2 v1.3.2 TP_SEC_ITSS_SND_CAM_04_BV
407
408
             * @reference    ETSI TS 103 097 [1] Clauses 5.2 & 7.1.1
             * @reference    IEEE 1609.2 [2] Clause 6.3.4
garciay's avatar
garciay committed
409
410
411
412
413
414
415
416
417
418
419
420
             */
            testcase TC_SEC_ITSS_SND_CAM_04_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
garciay's avatar
garciay committed
421
                f_cf01Up(); // Initialise IUT with CERT_IUT_A_AT signed with CERT_IUT_A_AA
garciay's avatar
garciay committed
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
                
                // Test adapter configuration
                
                // Preamble
                f_prNeighbour();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
                tc_ac.start;
                alt {
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mw_etsiTs103097Data_signed(
                                    mw_signedData(
                                        -, 
                                        mw_toBeSignedData(
                                            mw_signedDataPayload,
                                            mw_headerInfo_cam
                                        ),
                                        mw_signerIdentifier_digest // containing digest
                                    )
                                ), 
                                mw_geoNwShbPacket
                    ))) {
                        tc_ac.stop;                        
garciay's avatar
garciay committed
448
                        log("*** " & testcasename() & ": PASS: Correct secured packet received, containing digest");
garciay's avatar
garciay committed
449
450
451
452
453
454
455
456
457
458
459
460
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                    }
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mw_etsiTs103097Data_signed(
                                    mw_signedData(
                                        -, 
                                        mw_toBeSignedData(
                                            mw_signedDataPayload,
                                            mw_headerInfo_cam
                                        ),
461
462
463
464
465
466
467
468
                                        mw_signerIdentifier_certificate( // or containing certificate
                                            mw_etsiTs103097Certificate(
                                                -,
                                                mw_toBeSignedCertificate_at(
                                                    { mw_appPermissions(c_its_aid_CAM) }
                                                )
                                            )
                                        )
garciay's avatar
garciay committed
469
470
471
472
473
                                    )
                                ), 
                                mw_geoNwShbPacket
                    ))) {
                        tc_ac.stop;                        
garciay's avatar
garciay committed
474
                        log("*** " & testcasename() & ": PASS: Correct secured packet received, containing certificate");
garciay's avatar
garciay committed
475
476
477
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                    }
                    [] tc_ac.timeout {
478
                        log("*** " & testcasename() & ": INCONC: Expected CA message not received ***");
garciay's avatar
garciay committed
479
480
481
482
483
484
485
486
487
488
489
490
491
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                    } 
                } // End of 'alt' statement
                
                // Postamble
                f_poNeighbour();
                f_cf01Down();
            } // End of testcase TC_SEC_ITSS_SND_CAM_04_BV
            
            /**
             * @desc Check that IUT calculate the digest of certificate using proper hash algorithm;
             *       Check that IUT canonicalize certificates before hash calculation.
             * <pre>
492
             * Pics Selection: PICS_GN_SECURITY and ((PICS_SEC_SHA256 and (PICS_SEC_NIST_P256 or PICS_SEC_BRAINPOOL_P256R1)) or (PICS_SEC_SHA384 and PICS_SEC_BRAINPOOL_P384R1))
garciay's avatar
garciay committed
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
             * Config Id: CF01
             * Initial conditions:
             *  with {
             *     the IUT is authorized with AT certificate (X_CERTIFICATE) 
             *     and the IUT is configured to send more than one CAM per second
             *     and the IUT having sent a secured CAM
             *         containing signer
             *             containing certificate
             *                 indicating X_CERTIFICATE
             *                     containing verifyKeyIndicator
             *                         containing verificationKey
             *                             containing X_KEY
             * }
             * ensure that {
             *     when {
             *         the IUT is requested to send a subsequent secured CAM
             *             containing signer
             *                 containing digest
             *     } then {
             *         the IUT sends a Ieee1609Dot2Data
             *             containing content
             *                 containing signedData
             *                     containing signer
             *                         containing digest
             *                             indicating last 8 bytes of the Hash value calculated using X_HASH algorithm
             * </pre>
             *
garciay's avatar
garciay committed
520
             * @see         ETSI TS 103 096-2 v1.3.2 TP_SEC_ITSS_SND_CAM_05_BV
521
522
             * @reference    ETSI TS 103 097 [1] Clauses 5.2 & 7.1.1
             * @reference    IEEE 1609.2 [2] Clause 6.3.4
garciay's avatar
garciay committed
523
524
525
526
             */
            testcase TC_SEC_ITSS_SND_CAM_05_BV() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
527
528
529
                var EtsiTs103097Certificate v_certificate;
                var HashedId8               v_certificate_digest;
                var ItsCam                  v_component;
garciay's avatar
garciay committed
530
531
                
                // Test control
532
533
                if (not(PICS_GN_SECURITY and ((PICS_SEC_SHA256 and (PICS_SEC_NIST_P256 or PICS_SEC_BRAINPOOL_P256R1)) or (PICS_SEC_SHA384 and PICS_SEC_BRAINPOOL_P384R1)))) {
                    log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY and ((PICS_SEC_SHA256 and (PICS_SEC_NIST_P256 or PICS_SEC_BRAINPOOL_P256R1)) or (PICS_SEC_SHA384 and PICS_SEC_BRAINPOOL_P384R1))' required for executing the TC ***");
garciay's avatar
garciay committed
534
535
536
537
                    stop;
                }
                
                // Test component configuration
538
                vc_hashedId8ToBeUsed := PICS_CERTFICATE_ID_VARIANT;
garciay's avatar
garciay committed
539
540
541
542
543
544
                f_cf01Up();
                
                // Test adapter configuration
                
                // Preamble
                f_prNeighbour();
545
546
                f_readCertificate(vc_hashedId8ToBeUsed, v_certificate);
                f_getCertificateDigest(vc_hashedId8ToBeUsed, v_certificate_digest);
garciay's avatar
garciay committed
547
548
549
550
                geoNetworkingPort.clear;
                v_component := f_setCamFrequencyGreatherThan1Hz();
                tc_ac.start;
                alt {
551
                    [PICS_SEC_SHA256 == true] geoNetworkingPort.receive(
garciay's avatar
garciay committed
552
553
554
555
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mw_etsiTs103097Data_signed(
                                    mw_signedData(
556
                                        sha256, 
garciay's avatar
garciay committed
557
558
559
560
561
562
563
                                        mw_toBeSignedData(
                                            mw_signedDataPayload,
                                            mw_headerInfo_cam
                                        ),
                                        mw_signerIdentifier_certificate(
                                            mw_etsiTs103097Certificate(
                                                mw_issuerIdentifier_sha256AndDigest(
564
565
566
567
568
                                                    v_certificate.issuer.sha256AndDigest
                                                ),
                                                mw_toBeSignedCertificate_at(
                                                    -,
                                                    v_certificate.toBeSigned.verifyKeyIndicator
garciay's avatar
garciay committed
569
570
571
572
573
574
575
576
                                                )
                                            )
                                        )
                                    )
                                ), 
                                mw_geoNwShbPacket
                    ))) {
                        tc_ac.stop;
577
                        log("*** " & testcasename() & ": INFO: Initial conditions: First CA message with certificate received ***");
garciay's avatar
garciay committed
578
579
                        f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                    }
580
                    [PICS_SEC_SHA384 == true] geoNetworkingPort.receive(
garciay's avatar
garciay committed
581
582
583
584
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mw_etsiTs103097Data_signed(
                                    mw_signedData(
585
                                        sha384, 
garciay's avatar
garciay committed
586
587
588
589
590
591
592
                                        mw_toBeSignedData(
                                            mw_signedDataPayload,
                                            mw_headerInfo_cam
                                        ),
                                        mw_signerIdentifier_certificate(
                                            mw_etsiTs103097Certificate(
                                                mw_issuerIdentifier_sha384AndDigest(
593
594
595
596
597
                                                    v_certificate.issuer.sha384AndDigest
                                                ),
                                                mw_toBeSignedCertificate_at(
                                                    -,
                                                    v_certificate.toBeSigned.verifyKeyIndicator
garciay's avatar
garciay committed
598
599
600
601
602
603
604
605
                                                )
                                            )
                                        )
                                    )
                                ), 
                                mw_geoNwShbPacket
                    ))) {
                        tc_ac.stop;
606
                        log("*** " & testcasename() & ": INFO: Initial conditions: First CA message with AT certificate received ***");
garciay's avatar
garciay committed
607
608
609
                        f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                    }
                    [] tc_ac.timeout {
610
                        log("*** " & testcasename() & ": INCONC: Initial conditions: CA message with AT certificate not received ***");
garciay's avatar
garciay committed
611
                        f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_timeout);
garciay's avatar
garciay committed
612
613
614
615
616
617
                    }
                } // End of 'alt' statement
                
                // Test Body
                tc_ac.start;
                alt {
618
                    [PICS_SEC_SHA256 == true] geoNetworkingPort.receive(
garciay's avatar
garciay committed
619
620
621
622
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mw_etsiTs103097Data_signed(
                                    mw_signedData(
623
                                        sha256, 
garciay's avatar
garciay committed
624
625
626
627
628
                                        mw_toBeSignedData(
                                            mw_signedDataPayload,
                                            mw_headerInfo_cam
                                        ),
                                        mw_signerIdentifier_digest(
629
                                            v_certificate_digest
garciay's avatar
garciay committed
630
631
632
633
634
635
                                        )
                                    )
                                ), 
                                mw_geoNwShbPacket
                    ))) {
                        tc_ac.stop;
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
                        log("*** " & testcasename() & ": PASS: Correct secured CA message received");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                    }
                    [PICS_SEC_SHA384 == true] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mw_etsiTs103097Data_signed(
                                    mw_signedData(
                                        sha384, 
                                        mw_toBeSignedData(
                                            mw_signedDataPayload,
                                            mw_headerInfo_cam
                                        ),
                                        mw_signerIdentifier_digest(
                                            v_certificate_digest
                                        )
                                    )
                                ), 
                                mw_geoNwShbPacket
                    ))) {
                        tc_ac.stop;
                        log("*** " & testcasename() & ": PASS: Correct secured CA message received");
garciay's avatar
garciay committed
658
659
660
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                    }
                    [] tc_ac.timeout {
661
                        log("*** " & testcasename() & ": INCONC: Expected CA message not received ***");
garciay's avatar
garciay committed
662
663
664
665
666
667
668
669
670
671
                        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_05_BV
            
garciay's avatar
garciay committed
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
            /**
             * @desc    Check that IUT sends the secured CAM containing the signing certificate when over the time of one 
             *          second no other secured CAM contained the certificate was sent.
             * <pre>
             * Pics Selection: PICS_GN_SECURITY
             * 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 then one CAM per second
             *     and the IUT having sent a CAM
             *         containing generationTime
             *             indicating TIME_LAST
             *     }
             * ensure that {
             *     when {
             *         the IUT is sending secured CAM as a message of type EtsiTs103097Data
             *             containing signer
             *                 containing signer
garciay's avatar
garciay committed
691
             *                     containing certificate
garciay's avatar
garciay committed
692
693
694
695
696
697
698
699
700
701
             *     } then {
             *         this message
             *             contains headerInfo
             *                 containing generation_time
             *                     indicating TIME (TIME >= TIME_LAST + 1sec)
             *     }
             * }
             * </pre>
             *
             * @see          ETSI TS 103 096-2 v1.3.2 TP_SEC_ITSS_SND_CAM_06_BV
702
             * @reference    ETSI TS 103 097 [1] Clause 7.1.1
garciay's avatar
garciay committed
703
704
705
706
707
708
             */
            testcase TC_SEC_ITSS_SND_CAM_06_BV() runs on ItsGeoNetworking system ItsSecSystem {
                
                // Local variables
                var GeoNetworkingInd v_geoNwInd;
                var ItsCam v_component;
garciay's avatar
garciay committed
709
                var Time64 v_time_last;
garciay's avatar
garciay committed
710
711
712
713
714
715
716
717
                
                // 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
718
                f_cf01Up(); // Initialise IUT with CERT_IUT_A_AT signed with CERT_IUT_A_AA
garciay's avatar
garciay committed
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
                
                // Test adapter configuration
                
                // Preamble
                f_prNeighbour();
                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
garciay's avatar
garciay committed
742
                    ))) -> value v_geoNwInd {
garciay's avatar
garciay committed
743
                        tc_ac.stop;
744
745
                        v_time_last := f_getSecuredMessage(v_geoNwInd.msgIn).content.signedData.tbsData.headerInfo.generationTime;
                        log("*** " & testcasename() & ": INFO: Initial conditions: First CA message with certificate received, TIME_LAST = ", v_time_last, " ***");
garciay's avatar
garciay committed
746
747
748
                        f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                    }
                    [] tc_ac.timeout {
749
                        log("*** " & testcasename() & ": INCONC: Initial conditions: CA message with certificate not received ***");
garciay's avatar
garciay committed
750
                        f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_timeout);
garciay's avatar
garciay committed
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
                    }
                } // 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
                    ))) {
garciay's avatar
garciay committed
772
                        tc_ac.stop;
773
774
                        if (ff_abs(int2float(v_geoNwInd.msgIn.gnPacket.securedMsg.content.signedData.tbsData.headerInfo.generationTime - v_time_last)) <= 0.95) {
                            log("*** " & testcasename() & ": PASS: Generation of CAM messages including certificate was within a second ***");
garciay's avatar
garciay committed
775
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
776
                        } else {
garciay's avatar
garciay committed
777
778
                            log("*** " & testcasename() & ": FAIL: Generation of CAM messages including certificate was not within a second ***");
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
garciay's avatar
garciay committed
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
                        }
                    }
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mw_etsiTs103097Data_signed(
                                    mw_signedData(
                                        -, 
                                        mw_toBeSignedData(
                                            mw_signedDataPayload,
                                            mw_headerInfo_cam
                                        ),
                                        mw_signerIdentifier_digest
                                    )
                                ), 
                                mw_geoNwShbPacket
                    ))) {
796
                        log("*** " & testcasename() & ": INFO: CA message retransmission with digest ***"); 
garciay's avatar
garciay committed
797
798
799
                        repeat;
                    }
                    [] tc_ac.timeout {
800
                        log("*** " & testcasename() & ": INCONC: Expected CA message not received ***");
garciay's avatar
garciay committed
801
802
803
804
805
806
807
808
809
810
811
                        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_06_BV
            
            /**
garciay's avatar
garciay committed
812
             * @desc    Check that IUT sends the secured CAM containing the signing certificate when the timeout of one second 
garciay's avatar
garciay committed
813
814
815
816
817
818
819
820
821
             *          has been expired after the previous CAM containing the certificate.
             * <pre>
             * Pics Selection: PICS_GN_SECURITY
             * Config Id: CF01
             * Initial conditions:
             *  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 sent a CAM
garciay's avatar
garciay committed
822
823
824
825
             *          containing signer
             *              containing certificate
             *          and containing generationTime
             *             indicating TIME_LAST
garciay's avatar
garciay committed
826
827
828
829
830
831
832
             *  }
             *  ensure that {
             *      when {
             *          the IUT is sending a CAM
             *              containing header_fields['generation_time']
             *                  indicating TIME >= TIME_LAST + 1sec
             *      } then {
garciay's avatar
garciay committed
833
834
835
836
837
838
839
             *     when {
             *         the IUT is sending secured CAM as a message of type EtsiTs103097Data
             *             containing generationTime
             *                 indicating TIME (TIME >= TIME_LAST + 1sec) 
             *     } then {
             *         this message is
             *             containing certificate
garciay's avatar
garciay committed
840
841
842
843
844
             *      }
             *  }
             * </pre>
             *
             * @see          ETSI TS 103 096-2 v1.3.2 TP_SEC_ITSS_SND_CAM_07_BV
845
             * @reference    ETSI TS 103 097 [1] Clause 7.1.1
garciay's avatar
garciay committed
846
847
             */
            testcase TC_SEC_ITSS_SND_CAM_07_BV() runs on ItsGeoNetworking system ItsSecSystem {
garciay's avatar
garciay committed
848
                
garciay's avatar
garciay committed
849
850
                // Local variables
                const integer c_cntTimeLimit := 10;
garciay's avatar
garciay committed
851
                const float c_certificateGenerationTime := 1.0;                
garciay's avatar
garciay committed
852
853
854
855
856
857
858
859
860
861
862
863
                timer t_maxTransInterval := c_certificateGenerationTime * 1.15;
                var integer v_cntTime := 0;
                var GeoNetworkingInd v_geoNwInd;
                var ItsCam v_component;
                
                // 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
864
                f_cf01Up(); // Initialise IUT with CERT_IUT_A_AT signed with CERT_IUT_A_AA
garciay's avatar
garciay committed
865
866
867
868
869
870
                
                // Test adapter configuration
                
                // Preamble
                f_prNeighbour();
                v_component := f_setCamFrequencyGreatherThan1Hz();
871
                geoNetworkingPort.clear;
garciay's avatar
garciay committed
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
                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
                    ))) {
                        t_maxTransInterval.start;
                        tc_ac.stop;
891
                        log("*** " & testcasename() & ": INFO: Initial conditions: First CA message with certificate received ***");
garciay's avatar
garciay committed
892
893
894
                        f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                    }
                    [] tc_ac.timeout {
895
                        log("*** " & testcasename() & ": INCONC: Initial conditions: CA message with certificate not received ***");
garciay's avatar
garciay committed
896
                        f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_timeout);
garciay's avatar
garciay committed
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
                    }
                } // 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
                    ))) {
                        t_maxTransInterval.stop;
                        v_cntTime := v_cntTime + 1;
                        if (v_cntTime == c_cntTimeLimit) { // Exit message loop
                            log("*** " & testcasename() & ": PASS: Generation of CAM messages including certificate was successful ***");
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                            // end of alt
                        }
                        else {
                            t_maxTransInterval.start;
927
                            log("*** " & testcasename() & ": INFO: CA message retransmission with certificate ***"); 
garciay's avatar
garciay committed
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
                            repeat;
                        }
                    }
                    [] geoNetworkingPort.receive(
                        mw_geoNwInd(
                            mw_geoNwSecPdu(
                                mw_etsiTs103097Data_signed(
                                    mw_signedData(
                                        -, 
                                        mw_toBeSignedData(
                                            mw_signedDataPayload,
                                            mw_headerInfo_cam
                                        ),
                                        mw_signerIdentifier_digest
                                    )
                                ), 
                                mw_geoNwShbPacket
                    ))) {
946
                        log("*** " & testcasename() & ": INFO: CA message retransmission with digest ***"); 
garciay's avatar
garciay committed
947
948
949
                        repeat;
                    }
                    [] t_maxTransInterval.timeout {
950
                        log("*** " & testcasename() & ": FAIL: CA message with certificate was not received in 1 sec after previous one ***");
garciay's avatar
garciay committed
951
952
953
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                    }
                    [] tc_ac.timeout {
954
                        log("*** " & testcasename() & ": INCONC: Expected CA message not received ***");
garciay's avatar
garciay committed
955
956
957
958
959
960
961
962
963
964
965
966
                        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_07_BV
            
            /**
             * @desc    Check that IUT sends the secured CAM containing the signing certificate when the IUT received 
967
             *          a CAM from an unknown ITS-S.
garciay's avatar
garciay committed
968
969
970
971
972
973
974
             * <pre>
             * Pics Selection: PICS_GN_SECURITY
             * 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
975
             *      and the IUT having already sent CAM
garciay's avatar
garciay committed
976
             *          containing certificate
977
978
979
             *              at TIME_1
             *      and the IUT having received a Ieee1609Dot2Data
             *          containing signedData
garciay's avatar
garciay committed
980
981
982
             *              containing signer
             *                  containing digest
             *                      indicating HashedId8 value
983
984
             *                          referenced to unknown certificate (CERT_TS_B_AT)
             *                              at TIME_2 (TIME_1 < TIME_2 < TIME_1+1sec)
garciay's avatar
garciay committed
985
986
987
             *  }
             *  ensure that {
             *      when {
988
989
             *          the IUT is requested to send CAM 
             *              at TIME_3 (TIME_1 < TIME_2 < TIME_3 < TIME_1 + 1sec)
garciay's avatar
garciay committed
990
991
992
993
994
995
996
997
998
999
1000
             *      } then {
             *          the IUT sends a Ieee1609Dot2Data
             *              containing signedData
             *                  containing type 
             *                      containing signer
             *                          containing certificate
             *      }
             *  }
             * </pre>
             *
             * @see          ETSI TS 103 096-2 v1.3.2 TP_SEC_ITSS_SND_CAM_08_BV
For faster browsing, not all history is shown. View entire blame