ItsSecurity_Functions.ttcn 33 KB
Newer Older
1
2
3
4
5
6
7
/**
 *  @author     ETSI / STF481
 *  @version    $URL$
 *              $Id$
 *  @desc       Module containing functions for the secured GN ATS
 *
 */
filatov's avatar
filatov committed
8
module ItsSecurity_Functions {
9
10
    
    // LibCommon
11
    import from LibCommon_Sync all;
12
13
14
    import from LibCommon_BasicTypesAndValues all;
    import from LibCommon_Time all;
    
15
16
17
18
    // LibIts
    import from DENM_PDU_Descriptions language "ASN.1:1997" all;
    import from ITS_Container language "ASN.1:1997" all;
    
19
20
21
22
23
24
25
26
27
28
29
30
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
    // LibItsCommon
    import from LibItsCommon_TypesAndValues all;
    import from LibItsCommon_TestSystem all;
    import from LibItsCommon_Functions all;
    
    // LibItsDenm
    import from LibItsDenm_TypesAndValues all;
    import from LibItsDenm_Templates all;
    import from LibItsDenm_Functions all;
    import from LibItsDenm_TestSystem all;
    
    // LibItsCam
    import from LibItsCam_Templates all;
    import from LibItsCam_Functions all;
    import from LibItsCam_TestSystem all;
    
    // LibItsGeoNetworking
    import from LibItsGeoNetworking_TestSystem all;
    import from LibItsGeoNetworking_Functions all;
    import from LibItsGeoNetworking_Templates all;
    import from LibItsGeoNetworking_TypesAndValues all;
    
    // LibItsSecurity
    import from LibItsSecurity_TypesAndValues all;
    import from LibItsSecurity_Templates all;
    import from LibItsSecurity_Functions all;
    import from LibItsSecurity_Pixits all;
    
    group secCam {
        
        /**
        * @desc   Prepare a secured CAM
        * @param  p_configId            The configuration identifier to be used
        * @param  p_headerFields        HeaderFields to be inserted in the message
        * @param  p_signerInfoType      Add digest or AT certificate or certificate chain
        * @param  p_addMissingHeaders   Whether to add mandatory headers not present in p_headerFields
        * @return Secured GeoNetworking packet containing a CAM
        */
        function f_prepareSecuredCam(
                                     in charstring p_configId,
                                     in template (omit) HeaderFields p_headerFields := omit,
                                     in SignerInfoType p_signerInfoType := e_certificate_digest_with_sha256,
                                     in boolean p_addMissingHeaders := true
        ) runs on ItsGeoNetworking return GeoNetworkingPdu {
            // Local variables
            var GnNonSecuredPacket v_gnNonSecuredPacket;
            var octetstring v_gnPayload;
            var template (value) SecuredMessage v_securedMessage;
            
            // Build signed SecuredMessage
            v_gnNonSecuredPacket := valueof(m_geoNwShbPacket(
                f_getPosition(c_compNodeC)
            ));
            
            // Add CAM payload
            v_gnNonSecuredPacket.payload := valueof(
                f_adaptPayload_m(
                    bit2oct(
                        encvalue(
                            m_camReq(
                                m_camMsg_vehicle_HF_BV(
                                    f_getTsStationId(),
                                    f_getCurrentTime() mod 65536, // See ETSI EN 302 637-2 V1.3.0 - Clause B.3 generationDelatTime
                                    LibItsCam_Templates.m_tsPosition
            ))))));
            
            // Encode it
            v_gnPayload := bit2oct(
                encvalue(
                    v_gnNonSecuredPacket
                )
            );
            f_buildGnSecuredCam(
                v_securedMessage,
                m_payload_signed(v_gnPayload),
                p_signerInfoType,
                p_headerFields,
                p_configId,
                p_addMissingHeaders
            );
            
            // Return secured Gn packet
            return valueof(m_geoNwSecPdu(v_gnNonSecuredPacket, v_securedMessage));
        } // End of function f_prepareSecuredCam
        
104
105
        /**
         * @desc   Prepare a secured CAM including wrong elements of protocols. It is used for BO test cases
garciay's avatar
garciay committed
106
107
108
109
110
111
112
113
114
115
116
         * @param  p_configId                   The configuration identifier to be used
         * @param  p_protocolVersion            The protocol version to be set. Default: 2
         * @param  p_trailerStatus              The Traile behaviour:
         *                                      <li>0 for no trailer</li>
         *                                      <li>1 for invalid trailer</li>
         *                                      <li>2 for duplicated trailer</li>
         * @param  p_headerFields               HeaderFields to be inserted in the message
         * @param  p_signerInfoType             Add digest or AT certificate or certificate chain
         * @param  p_addMissingHeaders          Whether to add mandatory headers not present in p_headerFields
         * @param p_alterATCertificateSignature Set to true to alter the AT certificate signature
         * @param p_alterAACertificateSignature Set to true to alter the AA certificate signature
117
118
119
120
         * @return Secured GeoNetworking packet containing a CAM
         */
        function f_prepareSecuredCam_Bo(
                                        in charstring p_configId,
garciay's avatar
garciay committed
121
                                        in UInt8 p_protocolVersion := c_protocol_version,
122
123
124
                                        in integer p_trailerStatus := 0,
                                        in template (omit) HeaderFields p_headerFields := omit,
                                        in SignerInfoType p_signerInfoType := e_certificate_digest_with_sha256,
garciay's avatar
garciay committed
125
126
127
                                        in boolean p_addMissingHeaders := true,
                                        in boolean p_alterATCertificateSignature := false,
                                        in boolean p_alterAACertificateSignature := false
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
        ) runs on ItsGeoNetworking return GeoNetworkingPdu {
            // Local variables
            var GnNonSecuredPacket v_gnNonSecuredPacket;
            var octetstring v_gnPayload;
            var template (value) SecuredMessage v_securedMessage;
            
            // Build signed SecuredMessage
            v_gnNonSecuredPacket := valueof(m_geoNwShbPacket(
                f_getPosition(c_compNodeC)
            ));
            
            // Add CAM payload
            v_gnNonSecuredPacket.payload := valueof(
                f_adaptPayload_m(
                    bit2oct(
                        encvalue(
                            m_camReq(
                                m_camMsg_vehicle_HF_BV(
                                    f_getTsStationId(),
                                    f_getCurrentTime() mod 65536, // See ETSI EN 302 637-2 V1.3.0 - Clause B.3 generationDelatTime
                                    LibItsCam_Templates.m_tsPosition
            ))))));
            
            // Encode it
            v_gnPayload := bit2oct(
                encvalue(
                    v_gnNonSecuredPacket
                )
            );
            f_buildGnSecuredCam_Bo(
                v_securedMessage,
                p_protocolVersion,
                p_trailerStatus,
                m_payload_signed(v_gnPayload),
                p_signerInfoType,
                p_headerFields,
                p_configId,
garciay's avatar
garciay committed
165
166
167
                p_addMissingHeaders,
                p_alterATCertificateSignature,
                p_alterAACertificateSignature
168
169
170
            );
            
            // Return secured Gn packet
171
//            log("f_prepareSecuredCam_Bo: ", m_geoNwSecPdu(v_gnNonSecuredPacket, v_securedMessage));
172
173
174
            return valueof(m_geoNwSecPdu(v_gnNonSecuredPacket, v_securedMessage));
        } // End of function f_prepareSecuredCam_Bo
        
175
176
177
178
179
180
181
182
183
184
185
186
        /**
        * @desc   Sends a secured CAM
        * @param  p_configId        The configuration identifier to be used
        * @param  p_headerFields    Additional HeaderFields
        * @param  p_signerInfoType  Add digest or AT certificate or certificate chain
        * @return GeoNetworking payload
        */
        function f_sendSecuredCam(
                                  in charstring p_configId,
                                  in template (omit) HeaderFields p_headerFields := omit,
                                  in SignerInfoType p_signerInfoType := e_certificate_digest_with_sha256
        ) runs on ItsGeoNetworking return GeoNetworkingPdu {
187
            
188
189
190
191
192
193
194
195
196
            // Local variables
            var GeoNetworkingPdu v_securedGnPdu := f_prepareSecuredCam(p_configId, p_headerFields, p_signerInfoType);
                   
            f_sendGeoNetMessage(m_geoNwReq_linkLayerBroadcast(v_securedGnPdu));
                        
            return v_securedGnPdu;
            
        } // End of function f_sendSecuredCam
        
197
198
199
200
201
202
203
204
205
206
207
208
209
210
        /**
        * @desc   Sends a secured CAM including wrong elements of protocols. It is used for BO test cases
        * @param  p_configId        The configuration identifier to be used
         * @param  p_protocolVersion     The protocol version to be set. Default: 2
         * @param  p_trailerStatus       The Traile behaviour:
         *                               <li>0 for no trailer</li>
         *                               <li>1 for invalid trailer</li>
         *                               <li>2 for duplicated trailer</li>
        * @param  p_headerFields    Additional HeaderFields
        * @param  p_signerInfoType  Add digest or AT certificate or certificate chain
        * @return GeoNetworking payload
        */
        function f_sendSecuredCam_Bo(
                                     in charstring p_configId,
garciay's avatar
garciay committed
211
                                     in UInt8 p_protocolVersion := c_protocol_version,
212
213
214
215
216
217
218
                                     in integer p_trailerStatus := 1,
                                     in template (omit) HeaderFields p_headerFields := omit,
                                     in SignerInfoType p_signerInfoType := e_certificate_digest_with_sha256
        ) runs on ItsGeoNetworking return GeoNetworkingPdu {
            
            // Local variables
            var GeoNetworkingPdu v_securedGnPdu := f_prepareSecuredCam_Bo(p_configId, p_protocolVersion, p_trailerStatus, p_headerFields, p_signerInfoType);
garciay's avatar
garciay committed
219
            
garciay's avatar
garciay committed
220
//            log("v_securedGnPdu = ", v_securedGnPdu);
221
222
223
224
225
226
            f_sendGeoNetMessage(m_geoNwReq_linkLayerBroadcast(v_securedGnPdu));
                        
            return v_securedGnPdu;
            
        } // End of function f_sendSecuredCam
        
227
228
229
230
231
    } // End of group secCam
    
    group secDenm {
        
        /**
232
        * @desc   Prepare a secured DENM
233
234
235
236
237
238
239
240
241
        * @param  p_configId            The configuration identifier to be used
        * @param  p_headerFields        HeaderFields to be inserted in the message
        * @param  p_signerInfoType      Add digest or AT certificate or certificate chain
        * @param  p_addMissingHeaders   Whether to add mandatory headers not present in p_headerFields
        * @return Secured GeoNetworking packet containing a CAM
        */
        function f_prepareSecuredDenm(
                                      in charstring p_configId,
                                      in template (omit) HeaderFields p_headerFields := omit,
242
                                      in SignerInfoType p_signerInfoType := e_certificate,
243
244
245
246
247
                                      in boolean p_addMissingHeaders := true
        ) runs on ItsGeoNetworking return GeoNetworkingPdu {
            // Local variables
            var GnNonSecuredPacket v_gnNonSecuredPacket;
            var octetstring v_gnPayload;
248
            var LongPosVector v_longPosVectorNodeB := f_getPosition(c_compNodeB); // Use NodeB
249
            var template (value) SecuredMessage v_securedMessage;
250
            var template (value) SituationContainer v_situation := m_situation(CauseCodeType_vehicleBreakdown_, VehicleBreakdownSubCauseCode_unavailable_);
251
252
253
254
            
            // Build signed SecuredMessage
            v_gnNonSecuredPacket := valueof(
                m_geoNwBroadcastPacket(
255
                    v_longPosVectorNodeB,
256
257
                    vc_localSeqNumber,
                    f_getGeoBroadcastArea(
258
                        c_area1                 // Select area1 (see ETSI TS 102 871-2 Clause 4.2 Configuration 1)
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
284
285
286
            )));
            
            // Add the DENM payload
            v_gnNonSecuredPacket.payload := valueof(
                f_adaptPayload_m(
                    bit2oct(
                        encvalue(
                            m_denmReq(
                                m_denmPdu(
                                    m_denm(
                                        m_denmMgmtCon(
                                            m_tsActionId
                                        ),
                                        v_situation,
                                        m_denmLocation_zeroDelta
            )))))));
            
            // Encode it
            v_gnPayload := bit2oct(
                encvalue(
                    v_gnNonSecuredPacket
                )
            );
            f_buildGnSecuredDenm(
                v_securedMessage,
                m_payload_signed(v_gnPayload),
                p_signerInfoType,
                valueof(m_threeDLocation(
287
288
                    v_longPosVectorNodeB.latitude,
                    v_longPosVectorNodeB.longitude,
289
290
291
292
293
294
295
296
297
298
299
300
                    '0000'O
                )),
                p_headerFields,
                p_configId,
                p_addMissingHeaders
            );
            
            // Return secured Gn packet
            return valueof(m_geoNwSecPdu(v_gnNonSecuredPacket, v_securedMessage));
        } // End of function f_prepareSecuredDenm
        
        /**
garciay's avatar
garciay committed
301
302
         * @desc   Prepare a secured DENM including wrong elements of protocols. It is used for BO test cases
         * @param  p_configId            The configuration identifier to be used
303
304
305
306
307
         * @param  p_protocolVersion     The protocol version to be set. Default: 2
         * @param  p_trailerStatus       The Traile behaviour:
         *                               <li>0 for no trailer</li>
         *                               <li>1 for invalid trailer</li>
         *                               <li>2 for duplicated trailer</li>
garciay's avatar
garciay committed
308
309
310
311
312
         * @param  p_headerFields        HeaderFields to be inserted in the message
         * @param  p_signerInfoType      Add digest or AT certificate or certificate chain
         * @param  p_addMissingHeaders   Whether to add mandatory headers not present in p_headerFields
         * @return Secured GeoNetworking packet containing a CAM
         */
313
314
        function f_prepareSecuredDenm_Bo(
                                         in charstring p_configId,
garciay's avatar
garciay committed
315
                                         in UInt8 p_protocolVersion := c_protocol_version,
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
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
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
                                         in integer p_trailerStatus := 0,
                                         in template (omit) HeaderFields p_headerFields := omit,
                                         in SignerInfoType p_signerInfoType := e_certificate,
                                         in boolean p_addMissingHeaders := true
        ) runs on ItsGeoNetworking return GeoNetworkingPdu {
            // Local variables
            var GnNonSecuredPacket v_gnNonSecuredPacket;
            var octetstring v_gnPayload;
            var LongPosVector v_longPosVectorNodeB := f_getPosition(c_compNodeB); // Use NodeB
            var template (value) SecuredMessage v_securedMessage;
            var template (value) SituationContainer v_situation := m_situation(CauseCodeType_vehicleBreakdown_, VehicleBreakdownSubCauseCode_unavailable_);
            
            // Build signed SecuredMessage
            v_gnNonSecuredPacket := valueof(
                m_geoNwBroadcastPacket(
                    v_longPosVectorNodeB,
                    vc_localSeqNumber,
                    f_getGeoBroadcastArea(
                        c_area1                 // Select area1 (see ETSI TS 102 871-2 Clause 4.2 Configuration 1)
            )));
            
            // Add the DENM payload
            v_gnNonSecuredPacket.payload := valueof(
                f_adaptPayload_m(
                    bit2oct(
                        encvalue(
                            m_denmReq(
                                m_denmPdu(
                                    m_denm(
                                        m_denmMgmtCon(
                                            m_tsActionId
                                        ),
                                        v_situation,
                                        m_denmLocation_zeroDelta
            )))))));
            
            // Encode it
            v_gnPayload := bit2oct(
                encvalue(
                    v_gnNonSecuredPacket
                )
            );
            f_buildGnSecuredDenm_Bo(
                v_securedMessage,
                p_protocolVersion,
                p_trailerStatus,
                m_payload_signed(v_gnPayload),
                p_signerInfoType,
                valueof(m_threeDLocation(
                    v_longPosVectorNodeB.latitude,
                    v_longPosVectorNodeB.longitude,
                    '0000'O
                )),
                p_headerFields,
                p_configId,
                p_addMissingHeaders
            );
            
            // Return secured Gn packet
            return valueof(m_geoNwSecPdu(v_gnNonSecuredPacket, v_securedMessage));
        } // End of function f_prepareSecuredDenm_Bo
        
        /**
         * @desc   Sends a secured DENM
         * @param  p_configId        The configuration identifier to be used
         * @param  p_headerFields    Additional HeaderFields
         * @param  p_signerInfoType  Add digest or AT certificate or certificate chain
         * @return GeoNetworking payload
         */
385
386
387
388
389
390
391
392
393
394
395
396
397
398
        function f_sendSecuredDenm(
                                  in charstring p_configId,
                                  in template (omit) HeaderFields p_headerFields := omit,
                                  in SignerInfoType p_signerInfoType := e_certificate_digest_with_sha256
        ) runs on ItsGeoNetworking return GeoNetworkingPdu {
            // Local variables
            var GeoNetworkingPdu v_securedGnPdu := f_prepareSecuredDenm(p_configId, p_headerFields, p_signerInfoType);
                   
            f_sendGeoNetMessage(m_geoNwReq_linkLayerBroadcast(v_securedGnPdu));
                        
            return v_securedGnPdu;
            
        } // End of function f_sendSecuredDenm
        
399
400
401
402
403
404
405
406
407
408
409
410
411
412
        /**
         * @desc   Sends a secured DENM including wrong elements of protocols. It is used for BO test cases
         * @param  p_configId        The configuration identifier to be used
         * @param  p_protocolVersion     The protocol version to be set. Default: 2
         * @param  p_trailerStatus       The Traile behaviour:
         *                               <li>0 for no trailer</li>
         *                               <li>1 for invalid trailer</li>
         *                               <li>2 for duplicated trailer</li>
         * @param  p_headerFields    Additional HeaderFields
         * @param  p_signerInfoType  Add digest or AT certificate or certificate chain
         * @return GeoNetworking payload
         */
        function f_sendSecuredDenm_Bo(
                                      in charstring p_configId,
garciay's avatar
garciay committed
413
                                      in UInt8 p_protocolVersion := c_protocol_version,
414
415
416
417
418
419
420
421
422
423
424
425
426
                                      in integer p_trailerStatus := 1,
                                      in template (omit) HeaderFields p_headerFields := omit,
                                      in SignerInfoType p_signerInfoType := e_certificate_digest_with_sha256
        ) runs on ItsGeoNetworking return GeoNetworkingPdu {
            // Local variables
            var GeoNetworkingPdu v_securedGnPdu := f_prepareSecuredDenm_Bo(p_configId, p_protocolVersion, p_trailerStatus, p_headerFields, p_signerInfoType);
                   
            f_sendGeoNetMessage(m_geoNwReq_linkLayerBroadcast(v_securedGnPdu));
                        
            return v_securedGnPdu;
            
        } // End of function f_sendSecuredDenm_Bo
        
427
428
    } // End of group secDenm 
    
garciay's avatar
garciay committed
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
    group secBeacon {
        
        /**
        * @desc   Prepare a secured Beacon
        * @param  p_configId            The configuration identifier to be used
        * @param  p_headerFields        HeaderFields to be inserted in the message
        * @param  p_signerInfoType      Add digest or AT certificate or certificate chain
        * @param  p_addMissingHeaders   Whether to add mandatory headers not present in p_headerFields
        * @return Secured GeoNetworking packet containing a CAM
        */
        function f_prepareSecuredBeacon(
                                      in charstring p_configId,
                                      in template (omit) HeaderFields p_headerFields := omit,
                                      in SignerInfoType p_signerInfoType := e_certificate,
                                      in boolean p_addMissingHeaders := true
        ) runs on ItsGeoNetworking return GeoNetworkingPdu {
            // Local variables
            var GnNonSecuredPacket v_gnNonSecuredPacket;
            var octetstring v_gnPayload;
            var LongPosVector v_longPosVectorNodeB := f_getPosition(c_compNodeB); // Use NodeB
            var template (value) SecuredMessage v_securedMessage;
            
            // Build signed SecuredMessage
            v_gnNonSecuredPacket := valueof(
                m_geoNwBroadcastPacket(
                    v_longPosVectorNodeB,
                    vc_localSeqNumber,
                    f_getGeoBroadcastArea(
                        c_area1                 // Select area1 (see ETSI TS 102 871-2 Clause 4.2 Configuration 1)
            )));
            
            // Encode it
            v_gnPayload := bit2oct(
                encvalue(
                    v_gnNonSecuredPacket
                )
            );
            f_buildGnSecuredOtherMessage(
                v_securedMessage,
                m_payload_signed(v_gnPayload),
                p_signerInfoType,
                valueof(m_threeDLocation(
                    v_longPosVectorNodeB.latitude,
                    v_longPosVectorNodeB.longitude,
                    '0000'O
                )),
                p_headerFields,
                p_configId,
                p_addMissingHeaders
            );
            
            // Return secured Gn packet
            return valueof(m_geoNwSecPdu(v_gnNonSecuredPacket, v_securedMessage));
        } // End of function f_prepareSecuredBeacon
        
        /**
         * @desc   Prepare a secured Beacon including wrong elements of protocols. It is used for BO test cases
         * @param  p_configId            The configuration identifier to be used
         * @param  p_protocolVersion     The protocol version to be set. Default: 2
         * @param  p_trailerStatus       The Traile behaviour:
         *                               <li>0 for no trailer</li>
         *                               <li>1 for invalid trailer</li>
         *                               <li>2 for duplicated trailer</li>
         * @param  p_headerFields        HeaderFields to be inserted in the message
         * @param  p_signerInfoType      Add digest or AT certificate or certificate chain
         * @param  p_addMissingHeaders   Whether to add mandatory headers not present in p_headerFields
         * @return Secured GeoNetworking packet containing a CAM
         */
        function f_prepareSecuredBeacon_Bo(
                                         in charstring p_configId,
garciay's avatar
garciay committed
499
                                         in UInt8 p_protocolVersion := c_protocol_version,
garciay's avatar
garciay committed
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
                                         in integer p_trailerStatus := 0,
                                         in template (omit) HeaderFields p_headerFields := omit,
                                         in SignerInfoType p_signerInfoType := e_certificate,
                                         in boolean p_addMissingHeaders := true
        ) runs on ItsGeoNetworking return GeoNetworkingPdu {
            // Local variables
            var GnNonSecuredPacket v_gnNonSecuredPacket;
            var octetstring v_gnPayload;
            var LongPosVector v_longPosVectorNodeB := f_getPosition(c_compNodeB); // Use NodeB
            var template (value) SecuredMessage v_securedMessage;
            
            // Build signed SecuredMessage
            v_gnNonSecuredPacket := valueof(
                m_geoNwBroadcastPacket(
                    v_longPosVectorNodeB,
                    vc_localSeqNumber,
                    f_getGeoBroadcastArea(
                        c_area1                 // Select area1 (see ETSI TS 102 871-2 Clause 4.2 Configuration 1)
            )));
            
            // Encode it
            v_gnPayload := bit2oct(
                encvalue(
                    v_gnNonSecuredPacket
                )
            );
            f_buildGnSecuredOtherMessage_Bo(
                v_securedMessage,
                p_protocolVersion,
                p_trailerStatus,
                m_payload_signed(v_gnPayload),
                p_signerInfoType,
                valueof(m_threeDLocation(
                    v_longPosVectorNodeB.latitude,
                    v_longPosVectorNodeB.longitude,
                    '0000'O
                )),
                p_headerFields,
                p_configId,
                p_addMissingHeaders
            );
            
            // Return secured Gn packet
            return valueof(m_geoNwSecPdu(v_gnNonSecuredPacket, v_securedMessage));
        } // End of function f_prepareSecuredBeacon_Bo
        
        /**
         * @desc   Sends a secured Beacon
         * @param  p_configId        The configuration identifier to be used
         * @param  p_headerFields    Additional HeaderFields
         * @param  p_signerInfoType  Add digest or AT certificate or certificate chain
         * @return GeoNetworking payload
         */
        function f_sendSecuredBeacon(
                                     in charstring p_configId,
                                     in template (omit) HeaderFields p_headerFields := omit,
                                     in SignerInfoType p_signerInfoType := e_certificate_digest_with_sha256
        ) runs on ItsGeoNetworking return GeoNetworkingPdu {
            // Local variables
            var GeoNetworkingPdu v_securedGnPdu := f_prepareSecuredBeacon(p_configId, p_headerFields, p_signerInfoType);
                   
            f_sendGeoNetMessage(m_geoNwReq_linkLayerBroadcast(v_securedGnPdu));
                        
            return v_securedGnPdu;
            
        } // End of function f_sendSecuredBeacon
        
        /**
         * @desc   Sends a secured Beacon including wrong elements of protocols. It is used for BO test cases
         * @param  p_configId        The configuration identifier to be used
         * @param  p_protocolVersion     The protocol version to be set. Default: 2
         * @param  p_trailerStatus       The Traile behaviour:
         *                               <li>0 for no trailer</li>
         *                               <li>1 for invalid trailer</li>
         *                               <li>2 for duplicated trailer</li>
         * @param  p_headerFields    Additional HeaderFields
         * @param  p_signerInfoType  Add digest or AT certificate or certificate chain
         * @return GeoNetworking payload
         */
        function f_sendSecuredBeacon_Bo(
                                        in charstring p_configId,
garciay's avatar
garciay committed
581
                                        in UInt8 p_protocolVersion := c_protocol_version,
garciay's avatar
garciay committed
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
                                        in integer p_trailerStatus := 1,
                                        in template (omit) HeaderFields p_headerFields := omit,
                                        in SignerInfoType p_signerInfoType := e_certificate_digest_with_sha256
        ) runs on ItsGeoNetworking return GeoNetworkingPdu {
            // Local variables
            var GeoNetworkingPdu v_securedGnPdu := f_prepareSecuredBeacon_Bo(p_configId, p_protocolVersion, p_trailerStatus, p_headerFields, p_signerInfoType);
                   
            f_sendGeoNetMessage(m_geoNwReq_linkLayerBroadcast(v_securedGnPdu));
                        
            return v_securedGnPdu;
            
        } // End of function f_sendSecuredBeacon_Bo
        
    } // End of group secBeacon
    
597
598
599
    group camTrigger {
        
        /**
600
601
        * @desc    Triggers a CAM change speed events to get a CAM frequency greather than 1 Hz (i.e. more than one CAM per seconds)
        * @return  Reference to the component used to send the trigger
602
603
604
605
606
607
608
609
610
611
612
613
        * @remark  This function spawns an ItsCam component in alive mode
        * @see     fb_changeCamFrequencyGreatherThan1Hz()
        */
        function f_setCamFrequencyGreatherThan1Hz() runs on ItsBaseComponent return ItsCam {
            var ItsCam v_camComponent;
            
            v_camComponent := ItsCam.create("CAM Trigger");
            v_camComponent.start(fb_setCamFrequencyGreatherThan1Hz());
            
            return v_camComponent;
        } // End of function f_setCamFrequencyGreatherThan1Hz
        
614
615
616
617
618
619
620
621
622
623
624
        /**
        * @desc    Terminate CAM component execution
        * @param   Reference to the component used to send the trigger
        */
        function f_terminateCam(inout ItsCam p_camComponent) runs on ItsBaseComponent {
            
            p_camComponent.done;
            p_camComponent.kill;
            
        } // End of function f_terminateCam
        
625
626
627
628
629
630
        /**
        * @desc Behaviour function for triggering a CAM change speed event on IUT
        */
        function fb_setCamFrequencyGreatherThan1Hz() runs on ItsCam {
            
            // Local variables
631
632
633
            var SpeedValue v_speedValues[5] := { 1000, 2000, 3000, 4000, 5000 } //cm/s
            var integer v_cntSpeed;
            var float v_timer := 0.2; // 1 / 5;
634
635
            
            map(self:utPort, system:camUtPort);
636
            vc_default := activate(LibItsCam_Functions.a_utDefault());
637
            
638
639
640
641
            for (v_cntSpeed := 0; v_cntSpeed < lengthof(v_speedValues); v_cntSpeed:=v_cntSpeed + 1) {
                LibItsCam_Functions.f_utTriggerEvent(valueof(m_changeSpeed(v_speedValues[v_cntSpeed])));
                f_sleep(v_timer);
            } // End of 'for' statement
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
            
            unmap(self:utPort, system:camUtPort);
        }  // End of function fb_setCamFrequencyGreatherThan1Hz
        
    } // End of group camTrigger 
    
    group denmTrigger {
        
        /**
        * @desc    Triggers a DENM event on IUT
        * @remark  This function spawns an ItsDenm component in alive mode
        * @see     fb_secTriggerDenmEvent()
        * @return  Reference to the component used to send the trigger
        */
        function f_triggerDenmEvent() runs on ItsBaseComponent return ItsDenm {
            var ItsDenm v_denmComponent;
            
659
            v_denmComponent := ItsDenm.create("DENM Trigger");
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
            v_denmComponent.start(fb_secTriggerDenmEvent());
            v_denmComponent.done;
            
            return v_denmComponent;
        } // End of function f_triggerDenmEvent
        
        /**
        * @desc    Cancels all previously triggered DENM events on IUT
        * @param   p_denmComponent     Reference of the component previously used to trigger DENM events
        * @see     fb_secCancelDenmEvent()
        */
        function f_cancelDenmEvent(ItsDenm p_denmComponent) runs on ItsBaseComponent {
            p_denmComponent.start(fb_secCancelDenmEvent());
            p_denmComponent.done;
            p_denmComponent.kill;
        } // End of function f_cancelDenmEvent
        
        /**
        * @desc Behaviour function for triggering a DENM event on IUT
        */
        function fb_secTriggerDenmEvent() runs on ItsDenm {
            
            // Local variables
683
            var template (value) SituationContainer v_situation := m_situation(CauseCodeType_vehicleBreakdown_, VehicleBreakdownSubCauseCode_unavailable_);
684
685
686
687
            
            map(self:utPort, system:denmUtPort);
            vc_default := activate(LibItsDenm_Functions.a_utDefault());
            
688
            vc_utActionIDs[0] := LibItsDenm_Functions.f_utTriggerEvent(m_utTriggerEvent(v_situation, defaultValidity));
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
            log("actionId=", vc_utActionIDs[0]);
            
        }  // End of function f_secTriggerDenmEvent
        
        /**
        * @desc Behaviour function for cancelling previously triggered DENM events on IUT
        */
        function fb_secCancelDenmEvent() runs on ItsDenm {
            
            // Local variables
            var integer v_counter;
            
            for (v_counter := 0; v_counter < lengthof(vc_utActionIDs); v_counter := v_counter + 1) {
                LibItsDenm_Functions.f_utTerminateEvent(m_utEventCancellation(vc_utActionIDs[v_counter]));
            } // End of 'for' statement
            
            unmap(self:utPort, system:denmUtPort);
            deactivate(vc_default);
            
        } // End of function f_secTriggerDenmEvent
        
    } // End of group denmTrigger
    
} // End of module AtsSecurity_Functions