test_LibItsGeoNetworking_TypesAndValues.ttcn 155 KB
Newer Older
1
module test_LibItsGeoNetworking_TypesAndValues /*language "TTCN-3:2009 Advanced Parameterization"*/ {
2 3
    
    // LibCommon
4 5
    import from LibCommon_BasicTypesAndValues all;
    import from LibCommon_DataStrings all;
6 7 8 9 10 11 12 13
    
    // LibIts
    import from ITS_Container language "ASN.1:1997" all;
    import from CAM_PDU_Descriptions language "ASN.1:1997"all;
    import from DENM_PDU_Descriptions language "ASN.1:1997" all;
    
    // LibItsCommon
    import from LibItsCommon_TypesAndValues all;
garciay's avatar
garciay committed
14
    import from LibItsCommon_Templates all;
15 16 17 18 19 20 21 22
    import from LibItsCommon_Functions all;
    
    // LibItsExternal
    import from LibItsExternal_TypesAndValues all;
    
    // LibItsCam
    import from LibItsCam_TypesAndValues all;
    import from LibItsCam_TestSystem all;
23
    import from LibItsCam_Templates all;
24 25 26 27 28 29 30
    
    // LibItsDenm
    import from LibItsDenm_Templates all;
    import from LibItsDenm_TestSystem all;
    
    // LibItsSecurity
    import from LibItsSecurity_TypesAndValues all;
31
    import from LibItsSecurity_TestSystem all;
32 33 34 35 36
    import from LibItsSecurity_Templates all;
    import from LibItsSecurity_Functions all;
    import from LibItsSecurity_Pixits all;
    
    // LibItsGeoNetworking
37 38 39
    import from LibItsGeoNetworking_TypesAndValues all;
    import from LibItsGeoNetworking_Templates all;
    import from LibItsGeoNetworking_Functions all;
40 41 42 43
    import from LibItsGeoNetworking_TestSystem all;
    import from LibItsGeoNetworking_Pixits all;
    import from LibItsGeoNetworking_Pics all;
    
44 45 46
    // AtsSecurity
    import from AtsSecurity_Functions all;
    
47 48 49
//    import from LibItsIpv6OverGeoNetworking_TypesAndValues all;
//    import from LibItsIpv6OverGeoNetworking_Templates all;
//    import from LibItsExternal_TypesAndValues all;
50 51 52 53 54 55 56

    import from test_CommonCodec all;
    
    import from test_LibItsBtp_TypesAndValues {
        template all 
    };

57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
    group LibItsGeoNetworking_testCases {
        
        group LibItsGeoNetworking_DummyTemplates {
            
            /**
             * @desc    Dummy template for GN_Address 
             */
            template (value) GN_Address m_dummyGnAddrIut := {
                typeOfAddress := e_manual,
                stationType := e_roadSideUnit,
                stationCountryCode := 33,
                mid := 'a4fedecabeef'O
            }
    
            /**
             * @desc    Dummy template for long position vector
             */
            template (value) LongPosVector m_dummyLongPosVectorIut := {
                gnAddr := m_dummyGnAddrIut,
garciay's avatar
garciay committed
76
                timestamp_ := 123456,
77 78 79 80 81
                latitude := 4856,
                longitude := 675,
                pai := '1'B,
                speed := 55,
                heading := 9876
82 83
            }
            
84 85 86 87 88
            template (value) GN_Address m_dummyGnAddrNodeA := {
                typeOfAddress := e_manual,
                stationType := e_pedestrian,
                stationCountryCode := 49,
                mid := 'a4fdea5ea5ed'O
89
            }
90 91 92 93 94 95
            
            template (value) GN_Address m_dummyGnAddrNodeB := {
                typeOfAddress := e_manual,
                stationType := e_specialVehicle,
                stationCountryCode := 50,
                mid := 'a40102030405'O
96
            }
97 98 99 100 101 102
    
            template (value) GN_Address m_dummyGnAddrNodeC := {
                typeOfAddress := e_manual,
                stationType := e_moped,
                stationCountryCode := 42,
                mid := 'deadbabebeef'O
103
            }
104 105 106
    
            template (value) LongPosVector m_dummyLongPosVectorNodeA := {
                gnAddr := m_dummyGnAddrNodeA,
garciay's avatar
garciay committed
107
                timestamp_ := 875,
108 109 110 111 112
                latitude := 265,
                longitude := 789,
                pai := '0'B,
                speed := 80,
                heading := 548
113
            }
114 115 116
    
            template (value) LongPosVector m_dummyLongPosVectorNodeB := {
                gnAddr := m_dummyGnAddrNodeB,
garciay's avatar
garciay committed
117
                timestamp_ := 4585,
118 119 120 121 122
                latitude := 126,
                longitude := 123,
                pai := '0'B,
                speed := 45,
                heading := 125
123
            }
124 125 126
            
            template (value) LongPosVector m_dummyLongPosVectorNodeC := {
                gnAddr := m_dummyGnAddrNodeC,
garciay's avatar
garciay committed
127
                timestamp_ := 23644,
128 129 130 131 132
                latitude := 23754,
                longitude := 49645,
                pai := '0'B,
                speed := 110,
                heading := 23
133
            }
134 135 136 137 138
            
            template (value) Area m_dummyArea1 := {
                geoAreaPosLatitude := 298376,
                geoAreaPosLongitude := 32745,
                distanceA := 1234,
139
                distanceB := 6078,
140
                angle := 9123
141
            }
142 143 144 145 146 147 148
    
            template (value) Area m_dummyArea2 := {
                geoAreaPosLatitude := 873548,
                geoAreaPosLongitude := 2837,
                distanceA := 8765,
                distanceB := 4321,
                angle := 4567
149
            }
150 151 152 153
    
            template (value) GeoBroadcastArea m_dummyGeoBroadcastArea1 := {
                geoBroadcastSubType := e_geoBroadcastRect,
                geoBroadcastArea := m_dummyArea1
154
            }
155 156 157 158
    
            template (value) GeoBroadcastArea m_dummyGeoBroadcastArea2 := {
                geoBroadcastSubType := e_geoBroadcastElip,
                geoBroadcastArea := m_dummyArea2
159
            }
160 161 162 163 164 165 166 167 168 169 170
    
            template (value) GeoAnycastArea m_dummyGeoAnycastArea1 := {
                geoAnycastSubType := e_geoAnycastCircle,
                geoAnycastArea := m_dummyArea1
            }
    
            template (value) GeoAnycastArea m_dummyGeoAnycastArea2 := {
                geoAnycastSubType := e_geoAnycastRect,
                geoAnycastArea := m_dummyArea2
            }
    
171
            /**
172 173 174 175 176
             * @desc    Send template for GeoUnicast header
             * @param   p_sourceLongPosVec      Long position vector of source 
             * @param   p_destinationLongPosVec Long position vector of destination 
             * @param   p_senderLongPosVec      Long position vector of sender
             * @param   p_seqNumber             Sequence number of GeoUnicast packet
177
             */
178 179 180 181 182 183 184 185 186 187 188
            template (value) ExtendedHeader m_geoUnicastHeaderBtp(
                in template (value) LongPosVector p_sourceLongPosVec,
                in template (value) ShortPosVector p_dstPosVector,
                in template (value) UInt16 p_seqNumber
            ) := {
                geoUnicastHeader := {
                    seqNumber := p_seqNumber,
                    reserved := c_uInt8Zero,
                    srcPosVector := p_sourceLongPosVec,
                    dstPosVector := p_dstPosVector
                }
189
            }
190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207
            
        } // End of group LibItsGeoNetworking_DummyTemplates
        
        group camTemplates {
            
            template (value) CAM m_camMsg(
                StationID p_stationId,
                GenerationDeltaTime p_generationTime
            ) := {
                header := {
                    protocolVersion := 1,
                    messageID := 2,
                    stationID := p_stationId
                },
                cam := {
                    generationDeltaTime := p_generationTime,
                    camParameters := {
                        basicContainer := {
208
                            stationType := StationType_passengerCar_,
209 210 211 212
                            referencePosition := {
                                latitude := f_integer2Latitude(f_getTsLatitude()),
                                longitude := f_integer2Longitude(f_getTsLongitude()),
                                positionConfidenceEllipse := {
213 214 215
                                    semiMajorConfidence   := SemiAxisLength_oneCentimeter_,
                                    semiMinorConfidence   := SemiAxisLength_oneCentimeter_,
                                    semiMajorOrientation  := HeadingValue_wgs84North_
216 217
                                },
                                altitude := {
218
                                    altitudeValue := AltitudeValue_referenceEllipsoidSurface_,
219 220 221 222 223 224 225
                                    altitudeConfidence := unavailable
                                }
                            }
                        },
                        highFrequencyContainer := {
                            basicVehicleContainerHighFrequency := {
                                heading := {
226
                                    headingValue := HeadingValue_wgs84North_, //0
227 228 229 230 231 232 233 234 235 236 237 238 239
                                    headingConfidence := 10
                                },
                                speed := {
                                    speedValue := 45,
                                    speedConfidence := 5
                                },
                                driveDirection := forward,
                                vehicleLength := {
                                    vehicleLengthValue := 50,
                                    vehicleLengthConfidenceIndication := noTrailerPresent
                                },
                                vehicleWidth := 21,
                                longitudinalAcceleration := {
240 241
                                    longitudinalAccelerationValue := LongitudinalAccelerationValue_unavailable_,
                                    longitudinalAccelerationConfidence := AccelerationConfidence_unavailable_
242 243
                                },
                                curvature := {
244
                                    curvatureValue := CurvatureValue_straight_,
245 246 247 248
                                    curvatureConfidence := unavailable
                                },
                                curvatureCalculationMode := yawRateUsed,
                                yawRate := {
249
                                    yawRateValue := YawRateValue_straight_,
250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270
                                    yawRateConfidence := unavailable
                                },
                                accelerationControl := omit,
                                lanePosition := omit,
                                steeringWheelAngle := omit,
                                lateralAcceleration := omit,
                                verticalAcceleration := omit, 
                                performanceClass := omit,
                                cenDsrcTollingZone := omit
                                
                            }
                        },
                        lowFrequencyContainer := omit,
                        specialVehicleContainer := omit
                    }
                }
            };
            
        } // End of group camTemplates
        
        group testAcPrimitives {
271

272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339
//            /**
//             * 
//             * @desc validate StartBeaconing primitive
//             * @verdict Pass on success, Fail otherwise
//             */
//            testcase tc_startBeaconing() runs on TCType system TCType {
//                test_PDU<AcGnPrimitive>(
//                    m_startBeaconing(
//                        m_beaconHeader(m_dummyLongPosVectorIut).beaconHeader), 
//                    true,
//                    oct2bit('010027050024001000000000000a9421a4fedecabeef0001e240000012f8000002a300372694020e6248'O) // Check for 'LibItsGeoNetworking_TypesAndValues.encode:' output in codec traces to get the dump
//                );
//            }
//
//            /**
//             * 
//             * @desc validate StartBeaconing primitive for roadside equipment
//             * @verdict Pass on success, Fail otherwise
//             */
//            testcase tc_startBeaconingRoadside() runs on TCType system TCType {
//                test_PDU<AcGnPrimitive>(
//                    m_startBeaconingRoadSide, 
//                    true,
//                    oct2bit('010027050024001000000000000a4c00deadbeef00030000000017d75cf005f5e10003e8000000140000'O) // Check for 'LibItsGeoNetworking_TypesAndValues.encode:' output in codec traces to get the dump
//                );
//            }
//            testcase tc_startBeaconingRoadside_NEC() runs on TCType system TCType {
//                test_PDU<AcGnPrimitive>(
//                    m_startBeaconingRoadSide_NEC, 
//                    true,
//                    oct2bit('010027050024101000000000000a4c00deadbeef0002c90c152800004e20000000000000000000000000'O) // Check for 'LibItsGeoNetworking_TypesAndValues.encode:' output in codec traces to get the dump
//                );
//            }
//            testcase tc_startBeaconingRoadside_NEC_1() runs on TCType system TCType {
//                test_PDU<AcGnPrimitive>(
//                    m_startBeaconingRoadSide_NEC_1, 
//                    true,
//                    oct2bit('010027050024101000000000000a4c00deadbeef0003c926268affffd8f0000000000000000000000000'O) // Check for 'LibItsGeoNetworking_TypesAndValues.encode:' output in codec traces to get the dump
//                );
//            }
//
//            /**
//             * @desc validate StartPassBeaconing primitive
//             * @verdict Pass on success, Fail otherwise
//             */
//            testcase tc_startPassBeaconing() runs on TCType system TCType {
//                test_PDU<AcGnPrimitive>(
//                    m_startPassBeaconing(
//                        m_beaconHeader(m_dummyLongPosVectorIut).beaconHeader), 
//                    true,
//                    oct2bit('010027070024001000000000000a9421a4fedecabeef0001e240000012f8000002a300372694020e6248'O) // Check for 'LibItsGeoNetworking_TypesAndValues.encode:' output in codec traces to get the dump
//                );
//            }
//
//            /**
//             * @desc validate StartBeaconingMultipleNeighbour primitive
//             * @verdict Pass on success, Fail otherwise
//             */
//            testcase tc_startBeaconingMultipleNeighbour() runs on TCType system TCType {
//                test_PDU<AcGnPrimitive>(
//                    m_startBeaconingMultipleNeighbour(
//                        m_beaconHeader(m_dummyLongPosVectorIut).beaconHeader,
//                        3), 
//                    true,
//                    oct2bit('01002b090028001000000000000a9421a4fedecabeef0001e240000012f8000002a300372694020e624800000003'O) // Check for 'LibItsGeoNetworking_TypesAndValues.encode:' output in codec traces to get the dump
//                );
//            }
//
340 341 342 343 344
            /**
             * @desc validate StopBeaconing primitive
             * @verdict Pass on success, Fail otherwise
             */
            testcase tc_stopBeaconing() runs on TCType system TCType {
345
                test_PDU<AcGnPrimitive>(m_stopBeaconing, true, oct2bit('0001'O));
346 347 348 349 350 351 352
            }

            /**
             * @desc validate StopPassBeaconing primitive
             * @verdict Pass on success, Fail otherwise
             */
            testcase tc_stopPassBeaconing() runs on TCType system TCType {
353
                test_PDU<AcGnPrimitive>(m_stopPassBeaconing, true, oct2bit('0003'O));
354 355 356 357 358 359 360
            }

            /**
             * @desc validate StopBeaconingMultipleNeighbour
             * @verdict Pass on success, Fail otherwise
             */
            testcase tc_stopBeaconingMultipleNeighbour() runs on TCType system TCType {
361
                test_PDU<AcGnPrimitive>(m_stopBeaconingMultipleNeighbour, true, oct2bit('0005'O));
362 363 364 365 366 367 368
            }

            /**
             * @desc validate AcGetLongPosVector
             * @verdict Pass on success, Fail otherwise
             */
            testcase tc_getLongPosVector() runs on TCType system TCType {
369
                test_PDU<AcGnPrimitive>(m_getLongPosVector(m_dummyGnAddrIut), true, oct2bit('0006BC21A4FEDECABEEF'O)); // Check log for TC_GEONW_FDV_COH_BV_01 TC to retrieve the frame
370 371
            }

372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387
//            /**
//             * @desc validate AcGnResponse
//             * @verdict Pass on success, Fail otherwise
//             */
//            testcase tc_longPosVector() runs on TCType system TCType {
//                test_decodePDU<AcGnResponse>(mw_getLongPosVectorAny(m_dummyGnAddrIut), '0300270c00249421a4fedecabeef000030aa000030aa000030aa000030aa000030aa000030aa000030aa'O); // Check log for TC_GEONW_FDV_COH_BV_01 TC to retrieve the frame
//            }
//
//            /**
//             * @desc validate AcGnResponse with a NULL LongPosVector
//             * @verdict Pass on success, Fail otherwise
//             */
//            testcase tc_longPosVectorWithNullLongPosVector() runs on TCType system TCType {
//                test_decodePDU<AcGnResponse>(mw_getLongPosVectorAny(m_dummyGnAddrIut), '03000b0c00088400000000000001FFFFFFFFFFFF'O); // Check log for TC_GEONW_PON_LPV_BV_01 TC to retrieve the frame
//            }
//
388
            /**
389
             * @desc validate AcEnableSecurity
390 391
             * @verdict Pass on success, Fail otherwise
             */
392 393 394 395 396 397 398
            testcase tc_enableSecurity() runs on TCType system TCType {
                if (f_loadCertificates("dummy") == true) {
                    setverdict(fail);
                    stop;
                }
                
                // Setup certificates memory cache
399
                if (f_loadCertificates(PX_IUT_SEC_CONFIG_NAME) == false) {
400 401 402 403 404 405 406 407
                    setverdict(fail);
                    stop;
                }
                f_setGenerationLocation(
                    f_getTsLatitude(),
                    f_getTsLongitude()
                );
                
garciay's avatar
garciay committed
408 409
                test_PDU<AcSecPrimitive>(
                    m_acEnableSecurity(
410
                        "TA_CERT_A"
garciay's avatar
garciay committed
411
                    ), 
412 413
                    false
                ); 
414
            }
415
            
416
            /**
417
             * @desc validate AcDisableSecurity
418 419
             * @verdict Pass on success, Fail otherwise
             */
420
            testcase tc_disableSecurity() runs on TCType system TCType {
garciay's avatar
garciay committed
421 422
                test_PDU<AcSecPrimitive>(
                    m_acDisableSecurity, 
423 424
                    false
                ); 
425 426 427
            }

        } // End of group testAcPrimitives
428 429 430
        
        group testDeviceSigning {
            
431
            /**
432 433 434 435 436 437 438
             * @desc This function build and sign the SecureMessage part covered by the signature process
             * @param p_securedMessage      The signed  SecureMessage part
             * @param p_unsecuredPayload    The unsigned payload (e.g. a beacon)
             * @param p_threeDLocation      The ThreeDLocation value
             * @param p_headerFileds        Additional HeaderFields
             * @return true on success, false otherwise
             * @verdict Unchanged
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
            function f_buildGnSecuredOtherMessageWithDeviceCertificate(
                                                                       out template (value) SecuredMessage p_securedMessage, 
                                                                       in octetstring p_signedPayload, 
                                                                       in ThreeDLocation p_threeDLocation, 
                                                                       in template (value) Certificate p_deviceCertificate,
                                                                       in Oct32 p_devicePrivateKey,
                                                                       in template (omit) HeaderFields p_hearderFields := omit
            ) return boolean {
                
                // Local variables
                var octetstring v_secPayload, v_signature;
                var Oct32 v_hash;
                var template (value) ToBeSignedSecuredMessage v_toBeSignedSecuredMessage;
                 
                // Create SecuredMessage payload to be signed
                v_toBeSignedSecuredMessage := m_toBeSignedSecuredMessage(
                    { // Field HeaderFields
                        m_header_field_signer_info(
                            m_signerInfo_certificate(
                                p_deviceCertificate
                            ) // End of template m_signerInfo_certificate
                        ), // End of template m_header_field_signer_info
                        m_header_field_generation_time(1000 * f_getCurrentTime()), // In us
                        m_header_field_generation_location(
                            p_threeDLocation
                        )
                    }, // End of field HeaderFields
                    m_payload_signed(
                        p_signedPayload
                    ),
                    e_signature
                );
                v_secPayload := bit2oct(encvalue(v_toBeSignedSecuredMessage));
473
                log("f_buildGnSecuredOtherMessageWithDeviceCertificate:ithDeviceCertificate v_toBeSignedSecuredMessage: ", v_secPayload);
474
                
475 476 477
                // FIXME BUG Framework already compute the hash
//                // Calculate the hash of the SecuredMessage payload to be signed
//                v_hash := f_hashWithSha256(v_secPayload);
478 479 480 481
//                log("f_buildGnSecuredOtherMessageWithDeviceCertificate: v_hash: ", v_hash);
                
                // Signed payload
                v_signature := fx_signWithEcdsaNistp256WithSha256(
482
                    v_secPayload, 
483 484
                    p_devicePrivateKey
                );
485
                log("f_buildGnSecuredOtherMessageWithDeviceCertificate: v_signature: ", v_signature);
486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506
                
                p_securedMessage := m_securedMessage( // See Clause 7.3   Generic security profile for other signed messages
                    v_toBeSignedSecuredMessage.header_fields,
                    v_toBeSignedSecuredMessage.payload_field,
                    {
                        m_trailer_field_signature(
                            m_signature(
                                m_ecdsaSignature(
                                    m_eccPointecdsa_nistp256_with_sha256_y_coordinate_only(
                                        substr(v_signature, 2, 32)
                                    ),
                                    substr(v_signature, 34, 32)
                                )
                            )
                        )
                    }
                ); // End of template md_securedMessage_profileOther
                
                return true;
            } // End of function f_buildGnSecuredOtherMessageWithDeviceCertificate
            
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 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600
            testcase tc_checkDeviceSignature_01() runs on TCType system TCType {
                // Local variables
                var GnNonSecuredPacket v_gnNonSecuredPacket;
                var octetstring v_gnPayload;
                var template (value) SecuredMessage v_securedMessage;
                var Certificate v_aaCertificate, v_atCertificate;
                var HeaderFields v_mandatoryHeaders := {};
                var HeaderField v_signerInfo;
                var template (value) SecPayload p_payloadField := m_payload_signed(v_gnPayload);
                var template (omit) SignerInfoType p_signerInfoType := e_certificate;
                var template (omit) HeaderFields p_headerFields := {
                    m_header_field_generation_time(1000 * f_getCurrentTime()), // In us
                    m_header_field_its_aid_CAM
                };
                var template (omit) charstring p_certificateName := cc_taCert_EC;
                var boolean p_addMissingHeaders := true;
                
                f_loadCertificates(PX_IUT_SEC_CONFIG_NAME);
                
                // Build signed SecuredMessage
                 v_gnNonSecuredPacket := m_geoNwShbPacket(
                    m_dummyLongPosVectorIut
                );
                
                // 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
                ))))));
                log("v_gnNonSecuredPacket=", v_gnNonSecuredPacket);
                
                // Encode it
                v_gnPayload := bit2oct(
                    encvalue(
                        v_gnNonSecuredPacket
                    )
                );
                log("v_gnPayload=", v_gnPayload);
                
                // Load certificates if required
                if (f_prepareCertificates(p_certificateName, v_aaCertificate, v_atCertificate) == false) {
                    setverdict(fail);
                    stop;
                }
                log("v_aaCertificate=", v_aaCertificate);
                log("v_atCertificate=", v_atCertificate);
                
                if (p_addMissingHeaders == true) {
                    // Prepare mandatory headers
                    if (valueof(p_signerInfoType) == e_certificate) { // Add the AT certificate
                        v_signerInfo := valueof(
                            m_header_field_signer_info(
                                m_signerInfo_certificate(
                                    v_atCertificate
                        )));
                    }
                    if (valueof(p_signerInfoType) == e_certificate_chain) { // Add the AT certificate + AA Certificate
                        v_signerInfo := valueof(
                            m_header_field_signer_info(
                                m_signerInfo_certificates(
                                    {
                                        v_aaCertificate,
                                        v_atCertificate
                                    }
                                )
                        ));
                    }
                    if (valueof(p_signerInfoType) == e_certificate_digest_with_sha256) { // Add the AT certificate digest
                        v_signerInfo := valueof(
                            m_header_field_signer_info(
                                m_signerInfo_digest(
                                    f_calculateDigestFromCertificate(v_atCertificate)
                        )));
                    }
                    v_mandatoryHeaders := {
                        v_signerInfo,
                        valueof(m_header_field_generation_time(1000 * f_getCurrentTime())), // In us
                        valueof(m_header_field_its_aid(c_its_aid_CAM))
                    }
                }
                log("v_mandatoryHeaders=", v_mandatoryHeaders);
                
                log("v_securedMessage=", v_securedMessage);
                
                setverdict(pass);
            }
            
            testcase tc_checkDeviceSignature_02() runs on TCType system TCType {
601 602 603 604
                var GeoNetworkingReq v_gnReq;
                var octetstring v_gnPayload, v_encMsg;
                var template (value) ToBeSignedSecuredMessage v_toBeSignedSecuredMessage;
                var template (value) SecuredMessage v_securedMessageBeacon;
605 606 607 608 609 610
                
                if (PX_GN_UPPER_LAYER != e_any) {
                    log("PX_GN_UPPER_LAYER shall be set to e_any");
                    stop;
                }
                
611 612
                f_loadCertificates(PX_IUT_SEC_CONFIG_NAME);
                
613 614 615 616 617 618 619 620
                // Build signed SecuredMessage
                v_gnPayload := bit2oct( // Create GN payload
                    encvalue(
                        m_geoNwBeaconPacket( // Non secured GN beacon
                            m_dummyLongPosVectorIut
                        )
                    )
                );
621 622 623
                log("v_securedMessageBeacon= ", v_securedMessageBeacon);
                log("vc_atCertificate= ", vc_atCertificate);
                log("vc_signingPrivateKey= ", vc_signingPrivateKey);
624 625 626 627 628 629 630 631
                f_buildGnSecuredOtherMessageWithDeviceCertificate(
                    v_securedMessageBeacon,
                    v_gnPayload, 
                    m_threeDLocation(
                        1234,
                        5678,
                        '002F'O
                    ),
632 633
                    vc_atCertificate,
                    vc_signingPrivateKey
634
                );
635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654
                
                // Build secured Gn packet
                v_gnReq := m_geoNwReq_linkLayerBroadcast(
                    m_geoNwSecPdu(
                        m_geoNwBeaconPacket(
                            m_dummyLongPosVectorIut
                        ),
                        v_securedMessageBeacon
                    ) // End of template m_geoNwBeaconPacket
                ); // End of template m_geoNwReq_linkLayerBroadcast
                
                // Encode it
                v_encMsg := bit2oct(encvalue(v_gnReq));
                if (not isbound(v_encMsg)) {
                    setverdict(fail, "Encoding failed!");
                    stop;
                }
                log("Secured beacon: ", v_encMsg);
                setverdict(pass, "Encoding passed.");
                // Decode it
655
                test_decodePDU<GeoNetworkingReq>(
656 657
                    v_gnReq, 
                    v_encMsg
658
                );
659 660
                
                if (decvalue(oct2bit(v_encMsg), v_gnReq) == 0) {
661
                    if (f_verifyGnSecuredMessageSignatureWithCertificate(v_securedMessageBeacon, vc_atCertificate) == true) {
662 663 664 665 666 667 668
                        setverdict(pass, "Signature check succeed.");
                    } else {
                        setverdict(fail, "Signature check failed.");
                    } 
                } else {
                    setverdict(fail, "Decoding failed.");
                }
669 670
            }
            
671 672 673
        } // End of group testSecurityFunctions
        
        group testGeoNetPrimitiveMessages {
674 675
            
            /**
676
             * @desc validate GeoNetworkingReq/Beacon
677 678
             * @verdict Pass on success, Fail otherwise
             */
679 680 681
            testcase tc_GeoNetReq_Beacon() runs on TCType system TCType {
                var GeoNetworkingReq v_gnReq;
                var octetstring v_buffer := '01002B0A0010800000000100BC21A4FEDECABEEF0001E240000012F8000002A380372694FFFFFFFFFFFF'O;
682 683 684 685 686
                
                if (PX_GN_UPPER_LAYER != e_any) {
                    log("PX_GN_UPPER_LAYER shall be set to e_any");
                    stop;
                }
687 688 689 690 691 692
                
                v_gnReq := m_geoNwReq_linkLayerBroadcast(
                    m_geoNwPdu(
                        m_geoNwBeaconPacket(
                            m_dummyLongPosVectorIut
                    )));
693
                test_PDU<GeoNetworkingReq>(
694 695 696
                    v_gnReq, 
                    true, 
                    oct2bit(v_buffer)
697 698 699 700
                );
            }
            
            /**
701
             * @desc validate secured GeoNetworkingReq/Beacon with certificate digest in header fields
702 703
             * @verdict Pass on success, Fail otherwise
             */
704 705 706 707 708
            testcase tc_GeoNetReq_SecuredBeacon_digest() runs on TCType system TCType {
                var GeoNetworkingReq v_gnReq;
                var octetstring v_gnPayload, v_encMsg;
                var template (value) ToBeSignedSecuredMessage v_toBeSignedSecuredMessage;
                var template (value) SecuredMessage v_securedMessageBeacon;
709 710 711 712 713
                
                if (PX_GN_UPPER_LAYER != e_any) {
                    log("PX_GN_UPPER_LAYER shall be set to e_any");
                    stop;
                }
714 715
                
                // Load certificates & keys
716
                if (f_loadCertificates(PX_IUT_SEC_CONFIG_NAME) == false) {
717 718 719 720 721 722 723 724 725 726 727 728 729
                    setverdict(fail);
                    stop;
                }
                f_setGenerationLocation(
                    f_getTsLatitude(),
                    f_getTsLongitude()
                );
                
                // Build signed SecuredMessage
                v_gnPayload := bit2oct( // Create GN payload
                    encvalue(
                        m_geoNwBeaconPacket( // Non secured GN beacon
                            m_dummyLongPosVectorIut
730
                        )
731 732 733 734 735 736 737 738 739 740 741
                    )
                );
                f_buildGnSecuredOtherMessage(
                    v_securedMessageBeacon,
                    m_payload_signed(v_gnPayload),
                    e_certificate_digest_with_sha256,
                    m_threeDLocation(
                        1234,
                        5678,
                        '002F'O
                    )
742 743
                );
                
744 745 746 747 748 749 750 751 752 753 754 755 756 757
                // Build secured Gn packet
                v_gnReq := m_geoNwReq_linkLayerBroadcast(
                    m_geoNwSecPdu(
                        m_geoNwBeaconPacket(
                            m_dummyLongPosVectorIut
                        ),
                        v_securedMessageBeacon
                    ) // End of template m_geoNwBeaconPacket
                ); // End of template m_geoNwReq_linkLayerBroadcast
                
                // Encode it
                v_encMsg := bit2oct(encvalue(v_gnReq));
                if (not isbound(v_encMsg)) {
                    setverdict(fail, "Encoding failed!");
758 759
                    stop;
                }
760 761 762
                log("Secured beacon: ", v_encMsg);
                setverdict(pass, "Encoding passed.");
                // Decode it
763
                test_decodePDU<GeoNetworkingReq>(
764 765
                    v_gnReq, 
                    v_encMsg
766
                );
767 768 769 770 771 772 773 774 775 776
                
                if (decvalue(oct2bit(v_encMsg), v_gnReq) == 0) {
                    if (f_verifyGnSecuredMessageSignatureWithCertificate(v_gnReq.msgOut.gnPacket.securedMsg, vc_atCertificate) == true) {
                        setverdict(pass, "Signature check succeed.");
                    } else {
                        setverdict(fail, "Signature check failed.");
                    } 
                } else {
                    setverdict(fail, "Decoding failed.");
                }
777 778 779
            }
            
            /**
780
             * @desc validate secured GeoNetworkingReq/Beacon with certificate in header fields
781 782
             * @verdict Pass on success, Fail otherwise
             */
783 784 785 786 787
            testcase tc_GeoNetReq_SecuredBeacon_certificate() runs on TCType system TCType {
                var GeoNetworkingReq v_gnReq;
                var octetstring v_gnPayload, v_encMsg;
                var template (value) ToBeSignedSecuredMessage v_toBeSignedSecuredMessage;
                var template (value) SecuredMessage v_securedMessageBeacon;
788 789 790 791 792
                
                if (PX_GN_UPPER_LAYER != e_any) {
                    log("PX_GN_UPPER_LAYER shall be set to e_any");
                    stop;
                }
793 794
                
                // Load certificates & keys
795
                if (f_loadCertificates(PX_IUT_SEC_CONFIG_NAME) == false) {
796 797 798 799 800 801 802 803 804 805 806 807 808
                    setverdict(fail);
                    stop;
                }
                f_setGenerationLocation(
                    f_getTsLatitude(),
                    f_getTsLongitude()
                );
                
                // Build signed SecuredMessage
                v_gnPayload := bit2oct( // Create GN payload
                    encvalue(
                        m_geoNwBeaconPacket( // Non secured GN beacon
                            m_dummyLongPosVectorIut
809
                        )
810 811 812 813 814 815 816 817 818 819 820
                    )
                );
                f_buildGnSecuredOtherMessage(
                    v_securedMessageBeacon,
                    m_payload_signed(v_gnPayload),
                    e_certificate,
                    m_threeDLocation(
                        1234,
                        5678,
                        '002F'O
                    )
821 822
                );
                
823 824 825 826 827 828 829 830 831 832 833 834 835 836
                // Build secured Gn packet
                v_gnReq := m_geoNwReq_linkLayerBroadcast(
                    m_geoNwSecPdu(
                        m_geoNwBeaconPacket(
                            m_dummyLongPosVectorIut
                        ),
                        v_securedMessageBeacon
                    ) // End of template m_geoNwBeaconPacket
                ); // End of template m_geoNwReq_linkLayerBroadcast
                
                // Encode it
                v_encMsg := bit2oct(encvalue(v_gnReq));
                if (not isbound(v_encMsg)) {
                    setverdict(fail, "Encoding failed!");
837 838
                    stop;
                }
839 840 841
                log("Secured beacon: ", v_encMsg);
                setverdict(pass, "Encoding passed.");
                // Decode it
842
                test_decodePDU<GeoNetworkingReq>(
843 844
                    v_gnReq, 
                    v_encMsg
845
                );
846 847 848 849 850 851 852 853 854
                
                if (decvalue(oct2bit(v_encMsg), v_gnReq) == 0) {
                    if (f_verifyGnSecuredMessageSignatureWithCertificate(v_gnReq.msgOut.gnPacket.securedMsg, vc_atCertificate) == true) {
                        setverdict(pass, "Signature check succeed.");
                    } else {
                        setverdict(fail, "Signature check failed.");
                    } 
                } else {
                    setverdict(fail, "Decoding failed.");
855 856
                }
            }
857
            
858
            /**
859
             * @desc validate secured GeoNetworkingReq/Beacon
860 861
             * @verdict Pass on success, Fail otherwise
             */
862 863 864 865 866
            testcase tc_GeoNetReq_SecuredBeacon_WithAdditionalHeaders() runs on TCType system TCType {
                var GeoNetworkingReq v_gnReq;
                var octetstring v_gnPayload, v_encMsg;
                var template (value) ToBeSignedSecuredMessage v_toBeSignedSecuredMessage;
                var template (value) SecuredMessage v_securedMessageBeacon;
867
                
868 869
                if (PX_GN_UPPER_LAYER != e_any) {
                    log("PX_GN_UPPER_LAYER shall be set to e_any");
870 871
                    stop;
                }
872 873
                
                // Load certificates & keys
874
                if (f_loadCertificates(PX_IUT_SEC_CONFIG_NAME) == false) {
875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891
                    setverdict(fail);
                    stop;
                }
                f_setGenerationLocation(
                    f_getTsLatitude(),
                    f_getTsLongitude()
                );
                log("vc_signingPrivateKey=", vc_signingPrivateKey);
                log("vc_encryptPrivateKey=", vc_encryptPrivateKey);
                log("vc_aaCertificate=", vc_aaCertificate);
                log("vc_atCertificate=", vc_atCertificate);
                
                // Build signed SecuredMessage
                v_gnPayload := bit2oct( // Create GN payload
                    encvalue(
                        m_geoNwBeaconPacket( // Non secured GN beacon
                            m_dummyLongPosVectorIut
892
                        )
893
                    )
894
                );
895 896 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 927 928
                f_buildGnSecuredOtherMessage(
                    v_securedMessageBeacon,
                    m_payload_signed(v_gnPayload),
                    e_certificate_digest_with_sha256,
                    m_threeDLocation(
                        1234,
                        5678,
                        '002F'O
                    ),
                    {
                        {
                            type_ := e_request_unrecognized_certificate,
                            headerField := {
                                digests := { '00CAFE'O }
                            }
                        }
                    }
                );
                log("v_securedMessageBeacon= ", v_securedMessageBeacon);
                
                // Build secured Gn packet
                v_gnReq := m_geoNwReq_linkLayerBroadcast(
                    m_geoNwSecPdu(
                        m_geoNwBeaconPacket(
                            m_dummyLongPosVectorIut
                        ),
                        v_securedMessageBeacon
                    ) // End of template m_geoNwBeaconPacket
                ); // End of template m_geoNwReq_linkLayerBroadcast
                
                // Encode it
                v_encMsg := bit2oct(encvalue(v_gnReq));
                if (not isbound(v_encMsg)) {
                    setverdict(fail, "Encoding failed!");
929 930
                    stop;
                }
931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947
                log("Secured beacon: ", v_encMsg);
                setverdict(pass, "Encoding passed.");
                // Decode it
                test_decodePDU<GeoNetworkingReq>(
                    v_gnReq, 
                    v_encMsg
                );
                
                if (decvalue(oct2bit(v_encMsg), v_gnReq) == 0) {
                    if (f_verifyGnSecuredMessageSignatureWithCertificate(v_gnReq.msgOut.gnPacket.securedMsg, vc_atCertificate) == true) {
                        setverdict(pass, "Signature check succeed.");
                    } else {
                        setverdict(fail, "Signature check failed.");
                    } 
                } else {
                    setverdict(fail, "Decoding failed.");
                }
948 949 950
            }
            
            /**
951
             * @desc validate secured digest GeoNetworkingReq/LsRequest
952 953
             * @verdict Pass on success, Fail otherwise
             */
954 955 956
            testcase tc_GeoNetReq_LsRequestPacket() runs on TCType system TCType {
                var GeoNetworkingReq v_gnReq;
                var octetstring v_buffer := '01002B0A0060800000000A0030390000BC21A4FEDECABEEF0001E240000012F8000002A380372694BC21A4FEDECABEEFFFFFFFFFFFFF'O;
957 958 959 960 961 962
                
                if (PX_GN_UPPER_LAYER != e_any) {
                    log("PX_GN_UPPER_LAYER shall be set to e_any");
                    stop;
                }
                
963 964 965 966 967 968 969
                v_gnReq := m_geoNwReq_linkLayerBroadcast(
                    m_geoNwPdu(
                        m_geoNwLsRequestPacket(
                            m_dummyLongPosVectorIut,
                            12345,
                            m_dummyGnAddrIut
                    )));
970
                test_PDU<GeoNetworkingReq>(
971
                    v_gnReq, 
972
                    false, 
973 974
                    oct2bit(v_buffer)
                );
975
                test_decodePDU<GeoNetworkingReq>(
976
                    v_gnReq, 
977 978 979 980
                    v_buffer
                );
            }
            
981 982 983 984 985 986 987 988 989
            /**
             * @desc validate secured digest GeoNetworkingReq/LsRequest
             * @verdict Pass on success, Fail otherwise
             */
            testcase tc_GeoNetReq_SecuredDigestLsRequestPacket() runs on TCType system TCType {
                var GeoNetworkingReq v_gnReq;
                var octetstring v_gnPayload, v_encMsg;
                var template (value) ToBeSignedSecuredMessage v_toBeSignedSecuredMessage;
                var template (value) SecuredMessage v_securedMessageBeacon;
990 991 992 993 994 995
                
                if (PX_GN_UPPER_LAYER != e_any) {
                    log("PX_GN_UPPER_LAYER shall be set to e_any");
                    stop;
                }
                
996
                // Load certificates & keys
997
                if (f_loadCertificates(PX_IUT_SEC_CONFIG_NAME) == false) {
998
                    setverdict(fail);
999 1000
                    stop;
                }
1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042
                f_setGenerationLocation(
                    f_getTsLatitude(),
                    f_getTsLongitude()
                );
                
                // Build signed SecuredMessage
                v_gnPayload := bit2oct( // Create GN payload
                    encvalue(
                        m_geoNwLsRequestPacket(
                            m_dummyLongPosVectorIut,
                            12345,
                            m_dummyGnAddrIut
                        )
                    )
                );
                f_buildGnSecuredOtherMessage(
                    v_securedMessageBeacon,
                    m_payload_signed(v_gnPayload),
                    e_certificate_digest_with_sha256,
                    m_threeDLocation(
                        1234,
                        5678,
                        '002F'O
                    )
                );
                
                // Build secured Gn packet
                v_gnReq := m_geoNwReq_linkLayerBroadcast(
                    m_geoNwSecPdu(
                        m_geoNwLsRequestPacket(
                            m_dummyLongPosVectorIut,
                            12345,
                            m_dummyGnAddrIut
                        ), // End of template m_geoNwLsRequestPacket
                        v_securedMessageBeacon
                    ) // End of template m_geoNwSecPdu
                ); // End of template m_geoNwReq_linkLayerBroadcast
                
                // Encode it
                v_encMsg := bit2oct(encvalue(v_gnReq));
                if (not isbound(v_encMsg)) {
                    setverdict(fail, "Encoding failed!");
1043 1044 1045
                    stop;
                }
                
1046 1047 1048 1049 1050
                setverdict(pass, "Encoding passed.");
                // Decode it
                test_decodePDU<GeoNetworkingReq>(
                    v_gnReq, 
                    v_encMsg
1051
                );
1052 1053 1054 1055 1056 1057 1058 1059 1060 1061
                log("Secured beacon: ", v_encMsg);
                if (decvalue(oct2bit(v_encMsg), v_gnReq) == 0) {
                    if (f_verifyGnSecuredMessageSignatureWithCertificate(v_gnReq.msgOut.gnPacket.securedMsg, vc_atCertificate) == true) {
                        setverdict(pass, "Signature check succeed.");
                    } else {
                        setverdict(fail, "Signature check failed.");
                    } 
                } else {
                    setverdict(fail, "Decoding failed.");
                }
1062 1063 1064
            }
            
            /**
1065
             * @desc validate GeoNetworkingReq/LsReply
1066 1067
             * @verdict Pass on success, Fail otherwise
             */
1068 1069 1070
            testcase tc_GeoNetReq_LsReplyPacket() runs on TCType system TCType {
                var GeoNetworkingReq v_gnReq;
                var octetstring v_buffer := '01002B0A0061800000000A0030390000BC21A4FEDECABEEF0001E240000012F8000002A3803726948431A4FDEA5EA5ED0000036B0000010900000315FFFFFFFFFFFF'O;
1071 1072 1073 1074 1075
                
                if (PX_GN_UPPER_LAYER != e_any) {
                    log("PX_GN_UPPER_LAYER shall be set to e_any");
                    stop;
                }
1076 1077 1078 1079 1080 1081 1082 1083
                
                v_gnReq := m_geoNwReq_linkLayerBroadcast(
                    m_geoNwPdu(
                        m_geoNwLsReplyPacket(
                            m_dummyLongPosVectorIut,
                            f_longPosVector2ShortPosVector(m_dummyLongPosVectorNodeA),
                            12345
                )));
1084
                test_PDU<GeoNetworkingReq>(
1085
                    v_gnReq, 
1086
                    false, 
1087 1088
                    oct2bit(v_buffer)
                );
1089
                test_decodePDU<GeoNetworkingReq>(
1090
                    v_gnReq, 
1091 1092 1093 1094 1095
                    v_buffer
                );
            }
            
            /**
1096
             * @desc validate secured GeoNetworkingReq/LsReply
1097 1098
             * @verdict Pass on success, Fail otherwise
             */
1099 1100 1101 1102 1103
            testcase tc_GeoNetReq_SecuredLsReplyPacket() runs on TCType system TCType {
                var GeoNetworkingReq v_gnReq;
                var octetstring v_gnPayload, v_encMsg;
                var template (value) ToBeSignedSecuredMessage v_toBeSignedSecuredMessage;
                var template (value) SecuredMessage v_securedMessageBeacon;
1104 1105 1106 1107 1108
                
                if (PX_GN_UPPER_LAYER != e_any) {
                    log("PX_GN_UPPER_LAYER shall be set to e_any");
                    stop;
                }
1109 1110
                
                // Load certificates & keys
1111
                if (f_loadCertificates(PX_IUT_SEC_CONFIG_NAME) == false) {
1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161
                    setverdict(fail);
                    stop;
                }
                f_setGenerationLocation(
                    f_getTsLatitude(),
                    f_getTsLongitude()
                );
                
                // Build signed SecuredMessage
                v_gnPayload := bit2oct( // Create GN payload
                    encvalue(
                        m_geoNwLsReplyPacket(
                            m_dummyLongPosVectorIut,
                            f_longPosVector2ShortPosVector(m_dummyLongPosVectorNodeA),
                            12345
                        )
                    )
                );
                f_buildGnSecuredOtherMessage(
                    v_securedMessageBeacon,
                    m_payload_signed(v_gnPayload),
                    e_certificate_digest_with_sha256,
                    m_threeDLocation(
                        1234,
                        5678,
                        '002F'O
                    )
                );
                
                // Build secured Gn packet
                v_gnReq := m_geoNwReq_linkLayerBroadcast(
                    m_geoNwSecPdu(
                        m_geoNwLsReplyPacket(
                            m_dummyLongPosVectorIut,
                            f_longPosVector2ShortPosVector(m_dummyLongPosVectorNodeA),
                            12345
                        ), // End of template m_geoNwLsReplyPacket
                        v_securedMessageBeacon
                    ) // End of template m_geoNwSecPdu
                ); // End of template m_geoNwReq_linkLayerBroadcast
                
                // Encode it
                v_encMsg := bit2oct(encvalue(v_gnReq));
                if (not isbound(v_encMsg)) {
                    setverdict(fail, "Encoding failed!");
                    stop;
                }
                
                setverdict(pass, "Encoding passed.");
                // Decode it
1162
                test_decodePDU<GeoNetworkingReq>(
1163 1164
                    v_gnReq, 
                    v_encMsg
1165
                );
1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177
                log("Secured beacon: ", v_encMsg);
                if (decvalue(oct2bit(v_encMsg), v_gnReq) == 0) {
                    if (f_verifyGnSecuredMessageSignatureWithCertificate(v_gnReq.msgOut.gnPacket.securedMsg, vc_atCertificate) == true) {
                        setverdict(pass, "Signature check succeed.");
                    } else {
                        setverdict(fail, "Signature check failed.");
                    } 
                } else {
                    setverdict(fail, "Decoding failed.");
                }
            }
            
1178
            /**
1179
             * @desc validate GeoNetworkingReq/NwShb
1180 1181
             * @verdict Pass on success, Fail otherwise
             */
1182 1183 1184
            testcase tc_GeoNetReq_NwShbPacket() runs on TCType system TCType {
                var GeoNetworkingReq v_gnReq;
                var octetstring v_buffer := '01002B0A00508000000F0A00BC21A4FEDECABEEF0001E240000012F8000002A3803726940000000044454641554C545F5041594C4F4144FFFFFFFFFFFF'O;
1185 1186 1187 1188 1189
                
                if (PX_GN_UPPER_LAYER != e_any) {
                    log("PX_GN_UPPER_LAYER shall be set to e_any");
                    stop;
                }
1190 1191 1192 1193 1194 1195
                
                v_gnReq := m_geoNwReq_linkLayerBroadcast(
                    m_geoNwPdu(
                        m_geoNwShbPacket(
                            m_dummyLongPosVectorIut
                )));
1196
                test_PDU<GeoNetworkingReq>(
1197 1198 1199 1200
                    v_gnReq, 
                    false
                );
                v_gnReq.msgOut.gnPacket.packet.commonHeader.plLength := 15;
1201
                test_decodePDU<GeoNetworkingReq>(
1202
                    v_gnReq, 
1203 1204 1205 1206 1207
                    v_buffer
                );
            }
            
            /**
1208
             * @desc validate GeoNetworkingReq/NwShb with a CAM payload
1209 1210
             * @verdict Pass on success, Fail otherwise
             */
1211 1212 1213
            testcase tc_GeoNetReq_NwShbPacketWithBtpPayloadCam() runs on TCType system TCType {
                var GeoNetworkingReq v_gnReq;
                var octetstring v_buffer := '01002B0A10508000002E0A00BC21A4FEDECABEEF0001E240000012F8000002A380372694000000000000000001020001B20788B80059F48D95CDEFC8C5E0020020002461A83C000004805A100C4528399D4C387FFF80FFFFFFFFFFFF'O;
1214
                
1215 1216
                if ((PX_GN_UPPER_LAYER != e_btpA) and (PX_GN_UPPER_LAYER != e_btpB)) {
                    log("PX_GN_UPPER_LAYER shall be set to e_btpA or e_btpB");
1217 1218 1219
                    setverdict(inconc);
                    stop;
                }
1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238
                
                v_gnReq := m_geoNwReq_linkLayerBroadcast(
                    m_geoNwPdu(
                        m_geoNwShbPacket(
                            m_dummyLongPosVectorIut
                )));
                v_gnReq.msgOut.gnPacket.packet.payload := f_adaptPayload_m(
                    bit2oct(
                        encvalue(
                            m_camReq(
                                m_camMsg(
                                    f_getTsStationId(),
                                    35000
                                )
                            )
                        )
                    )
                );
                
1239
                test_PDU<GeoNetworkingReq>(
1240 1241 1242 1243
                    v_gnReq, 
                    false
                );
                v_gnReq.msgOut.gnPacket.packet.commonHeader.plLength := 46;
1244
                test_decodePDU<GeoNetworkingReq>(
1245
                    v_gnReq, 
1246 1247 1248
                    v_buffer
                );
            }
1249
            
1250
            /**
1251
             * @desc validate GeoNetworkingReq/NwShb with a DENM payload
1252 1253
             * @verdict Pass on success, Fail otherwise
             */
1254
            testcase tc_GeoNetReq_NwShbPacketWithBtpPayloadDenm() runs on TCType system TCType {
1255
                var template (value) SituationContainer v_situation := m_situation(CauseCodeType_vehicleBreakdown_, VehicleBreakdownSubCauseCode_unavailable_);
1256
                var GeoNetworkingReq v_gnReq;
1257
                var octetstring v_buffer := '01002B0A20508000003C0A00BC21A4FEDECABEEF0001E240000012F8000002A3803726940000000007D2000001010001B207C70000D90380000A0843ABBBE28210EAF534FA46CAE6F7E4630001001000186A000009600C05B00000DFFFF7FFFD8CE40400FFFFFFFFFFFF'O;
1258
                
1259 1260
                if (PX_GN_UPPER_LAYER != e_btpB) {
                    log("PX_GN_UPPER_LAYER shall be set to e_btpB");
1261 1262 1263
                    setverdict(inconc);
                    stop;
                }
1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287
                
                v_gnReq := m_geoNwReq_linkLayerBroadcast(
                    m_geoNwPdu(
                        m_geoNwShbPacket(
                            m_dummyLongPosVectorIut
                )));
                v_gnReq.msgOut.gnPacket.packet.payload := f_adaptPayload_m(
                    bit2oct(
                        encvalue(
                            m_denmReq(
                                m_denmPdu(
                                    m_denm(
                                        m_denmMgmtCon(
                                            m_tsActionId
                                        ),
                                        v_situation,
                                        m_denmLocation_zeroDelta
                                    )
                               )
                           )
                        )
                    )
                );
                
1288
                test_PDU<GeoNetworkingReq>(
1289 1290 1291
                    v_gnReq, 
                    false
                );
1292
                v_gnReq.msgOut.gnPacket.packet.commonHeader.plLength := 60;
1293
                test_decodePDU<GeoNetworkingReq>(
1294
                    v_gnReq, 
1295 1296 1297
                    v_buffer
                );
            }
1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310
            
            /**
             * @desc validate secured GeoNetworkingReq/NwShb
             * @verdict Pass on success, Fail otherwise
             */
            testcase tc_GeoNetReq_SecuredNwShbPacket() runs on TCType system TCType {
                var GeoNetworkingReq v_gnReq;
                var octetstring v_gnPayload, v_encMsg;
                var template (value) ToBeSignedSecuredMessage v_toBeSignedSecuredMessage;
                var template (value) SecuredMessage v_securedMessageBeacon;
                
                if (PX_GN_UPPER_LAYER != e_any) {
                    log("PX_GN_UPPER_LAYER shall be set to e_any");
1311 1312
                    stop;
                }
1313 1314
                
                // Load certificates & keys
1315
                if (f_loadCertificates(PX_IUT_SEC_CONFIG_NAME) == false) {
1316
                    setverdict(fail);
1317 1318
                    stop;
                }
1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356
                f_setGenerationLocation(
                    f_getTsLatitude(),
                    f_getTsLongitude()
                );
                
                // Build signed SecuredMessage
                v_gnPayload := bit2oct( // Create GN payload
                    encvalue(
                        m_geoNwShbPacket( 
                            m_dummyLongPosVectorIut
                        )
                    )
                );
                f_buildGnSecuredOtherMessage(
                    v_securedMessageBeacon,
                    m_payload_signed(v_gnPayload),
                    e_certificate_digest_with_sha256,
                    m_threeDLocation(
                        1234,
                        5678,
                        '002F'O
                    )
                );
                
                // Build secured Gn packet
                v_gnReq := m_geoNwReq_linkLayerBroadcast(
                    m_geoNwSecPdu(
                        m_geoNwShbPacket(
                            m_dummyLongPosVectorIut
                        ), // End of template m_geoNwLsReplyPacket
                        v_securedMessageBeacon
                    ) // End of template m_geoNwSecPdu
                ); // End of template m_geoNwReq_linkLayerBroadcast
                
                // Encode it
                v_encMsg := bit2oct(encvalue(v_gnReq));
                if (not isbound(v_encMsg)) {
                    setverdict(fail, "Encoding failed!");
1357 1358
                    stop;
                }
1359 1360 1361 1362 1363 1364 1365
                setverdict(pass, "Encoding passed.");
                // Decode it
                v_gnReq.msgOut.gnPacket.packet.commonHeader.plLength := 15;
                test_decodePDU<GeoNetworkingReq>(
                    v_gnReq, 
                    v_encMsg
                );
1366
                
1367 1368 1369 1370 1371 1372
                if (decvalue(oct2bit(v_encMsg), v_gnReq) == 0) {
                    if (f_verifyGnSecuredMessageSignatureWithCertificate(v_gnReq.msgOut.gnPacket.securedMsg, vc_atCertificate) == true) {
                        setverdict(pass, "Signature check succeed.");
                    } else {
                        setverdict(fail, "Signature check failed.");
                    } 
1373
                } else {
1374
                    setverdict(fail, "Decoding failed.");
1375 1376
                }
            }
1377
            
1378
            /**
1379
             * @desc validate secured with digest GeoNetworkingReq/NwShb with a CAM payload
1380 1381
             * @verdict Pass on success, Fail otherwise
             */
1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395
            testcase tc_GeoNetReq_SecuredDigestNwShbPacketWithBtpPayloadCam() runs on TCType system TCType {
                var GeoNetworkingReq v_gnReq;
                var GnNonSecuredPacket v_gnNonSecuredPacket;
                var octetstring v_gnPayload, v_encMsg;
                var template (value) ToBeSignedSecuredMessage v_toBeSignedSecuredMessage;
                var template (value) SecuredMessage v_securedMessageBeacon;
                
                if ((PX_GN_UPPER_LAYER != e_btpA) and (PX_GN_UPPER_LAYER != e_btpB)) {
                    log("PX_GN_UPPER_LAYER shall be set to e_btpA or e_btpB");
                    setverdict(inconc);
                    stop;
                }
                
                // Load certificates & keys
1396
                if (f_loadCertificates(PX_IUT_SEC_CONFIG_NAME) == false) {
1397
                    setverdict(fail);
1398
                    stop;
1399
                }
1400 1401 1402
                f_setGenerationLocation(
                    f_getTsLatitude(),
                    f_getTsLongitude()
1403
                );
1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453
                
                // Build signed SecuredMessage
                v_gnNonSecuredPacket := m_geoNwShbPacket(
                    m_dummyLongPosVectorIut
                );
                log("v_gnNonSecuredPacket= ", v_gnNonSecuredPacket);
                // Add CAM payload
                v_gnNonSecuredPacket.payload := f_adaptPayload_m(
                    bit2oct(
                        encvalue(
                            m_camReq(
                                m_camMsg(
                                    f_getTsStationId(),
                                    35000
                                )
                            )
                        )
                    )
                );
                log("v_gnNonSecuredPacket.payload= ", v_gnNonSecuredPacket.payload);
                // Encode it
                v_gnPayload := bit2oct( 
                    encvalue(
                        v_gnNonSecuredPacket
                    )
                );
                log("v_gnPayload= ", v_gnPayload);
                f_buildGnSecuredCam(
                    v_securedMessageBeacon,
                    m_payload_signed(v_gnPayload)
                );
                log("v_securedMessageBeacon= ", v_securedMessageBeacon);
                
                // Build secured Gn packet
                v_gnReq := m_geoNwReq_linkLayerBroadcast(
                    m_geoNwSecPdu(
                        v_gnNonSecuredPacket,
                        v_securedMessageBeacon
                    ) // End of template m_geoNwSecPdu
                ); // End of template m_geoNwReq_linkLayerBroadcast
                
                // Encode it
                v_encMsg := bit2oct(encvalue(v_gnReq));
                log("v_encMsg= ", v_encMsg);
                if (not isbound(v_encMsg)) {
                    setverdict(fail, "Encoding failed!");
                    stop;
                }
                setverdict(pass, "Encoding passed.");
                // Decode it
1454
                v_gnReq.msgOut.gnPacket.packet.commonHeader.plLength := 45;
1455 1456 1457
                test_decodePDU<GeoNetworkingReq>(
                    v_gnReq, 
                    v_encMsg
1458
                );
1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469
                log("v_gnReq: ", v_gnReq);
                
                if (decvalue(oct2bit(v_encMsg), v_gnReq) == 0) {
                    if (f_verifyGnSecuredMessageSignatureWithCertificate(v_gnReq.msgOut.gnPacket.securedMsg, vc_atCertificate) == true) {
                        setverdict(pass, "Signature check succeed.");
                    } else {
                        setverdict(fail, "Signature check failed.");
                    } 
                } else {
                    setverdict(fail, "Decoding failed.");
                }
1470
            }
1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489
            
            /**
             * @desc validate secured with digest GeoNetworkingReq/NwShb with a CAM payload and one additional header field
             * @verdict Pass on success, Fail otherwise
             */
            testcase tc_GeoNetReq_SecuredDigestNwShbPacketWithBtpPayloadCam_withMoreHeaders_1() runs on TCType system TCType {
                var GeoNetworkingReq v_gnReq;
                var GnNonSecuredPacket v_gnNonSecuredPacket;
                var octetstring v_gnPayload, v_encMsg;
                var template (value) ToBeSignedSecuredMessage v_toBeSignedSecuredMessage;
                var template (value) SecuredMessage v_securedMessageBeacon;
                
                if ((PX_GN_UPPER_LAYER != e_btpA) and (PX_GN_UPPER_LAYER != e_btpB)) {
                    log("PX_GN_UPPER_LAYER shall be set to e_btpA or e_btpB");
                    setverdict(inconc);
                    stop;
                }
                
                // Load certificates & keys
1490
                if (f_loadCertificates(PX_IUT_SEC_CONFIG_NAME) == false) {
1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591
                    setverdict(fail);
                    stop;
                }
                f_setGenerationLocation(
                    f_getTsLatitude(),
                    f_getTsLongitude()
                );
                
                // Build signed SecuredMessage
                v_gnNonSecuredPacket := m_geoNwShbPacket(
                    m_dummyLongPosVectorIut
                );
                log("v_gnNonSecuredPacket= ", v_gnNonSecuredPacket);
                // Add CAM payload
                v_gnNonSecuredPacket.payload := f_adaptPayload_m(
                    bit2oct(
                        encvalue(
                            m_camReq(
                                m_camMsg(
                                    f_getTsStationId(),
                                    35000
                                )
                            )
                        )
                    )
                );
                log("v_gnNonSecuredPacket.payload= ", v_gnNonSecuredPacket.payload);
                // Encode it
                v_gnPayload := bit2oct( 
                    encvalue(
                        v_gnNonSecuredPacket
                    )
                );
                log("v_gnPayload= ", v_gnPayload);
                f_buildGnSecuredCam(
                    v_securedMessageBeacon,
                    m_payload_signed(v_gnPayload),
                    e_certificate_digest_with_sha256,
                    {
                        m_header_field_unrecognised_certificate(
                            f_HashedId3FromHashedId8(
                                vc_aaCertificate.signer_info.signerInfo.digest
                            )
                        )
                     }
                );
                log("v_securedMessageBeacon= ", v_securedMessageBeacon);
                
                // Build secured Gn packet
                v_gnReq := m_geoNwReq_linkLayerBroadcast(
                    m_geoNwSecPdu(
                        v_gnNonSecuredPacket,
                        v_securedMessageBeacon
                    ) // End of template m_geoNwSecPdu
                ); // End of template m_geoNwReq_linkLayerBroadcast
                
                // Encode it
                v_encMsg := bit2oct(encvalue(v_gnReq));
                log("v_encMsg= ", v_encMsg);
                if (not isbound(v_encMsg)) {
                    setverdict(fail, "Encoding failed!");
                    stop;
                }
                setverdict(pass, "Encoding passed.");
                // Decode it
                v_gnReq.msgOut.gnPacket.packet.commonHeader.plLength := 45;
                test_decodePDU<GeoNetworkingReq>(
                    v_gnReq, 
                    v_encMsg
                );
                log("v_gnReq: ", v_gnReq);
                
                if (decvalue(oct2bit(v_encMsg), v_gnReq) == 0) {
                    if (f_verifyGnSecuredMessageSignatureWithCertificate(v_gnReq.msgOut.gnPacket.securedMsg, vc_atCertificate) == true) {
                        setverdict(pass, "Signature check succeed.");
                    } else {
                        setverdict(fail, "Signature check failed.");
                    } 
                } else {
                    setverdict(fail, "Decoding failed.");
                }
            }
            
            /**
             * @desc validate secured with digest GeoNetworkingReq/NwShb with a CAM payload and two additional header field
             * @verdict Pass on success, Fail otherwise
             */
            testcase tc_GeoNetReq_SecuredDigestNwShbPacketWithBtpPayloadCam_withMoreHeaders_2() runs on TCType system TCType {
                var GeoNetworkingReq v_gnReq;
                var GnNonSecuredPacket v_gnNonSecuredPacket;
                var octetstring v_gnPayload, v_encMsg;
                var template (value) ToBeSignedSecuredMessage v_toBeSignedSecuredMessage;
                var template (value) SecuredMessage v_securedMessageBeacon;
                
                if ((PX_GN_UPPER_LAYER != e_btpA) and (PX_GN_UPPER_LAYER != e_btpB)) {
                    log("PX_GN_UPPER_LAYER shall be set to e_btpA or e_btpB");
                    setverdict(inconc);
                    stop;
                }
                
                // Load certificates & keys
1592
                if (f_loadCertificates(PX_IUT_SEC_CONFIG_NAME) == false) {
1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696
                    setverdict(fail);
                    stop;
                }
                f_setGenerationLocation(
                    f_getTsLatitude(),
                    f_getTsLongitude()
                );
                
                // Build signed SecuredMessage
                v_gnNonSecuredPacket := m_geoNwShbPacket(
                    m_dummyLongPosVectorIut
                );
                log("v_gnNonSecuredPacket= ", v_gnNonSecuredPacket);
                // Add CAM payload
                v_gnNonSecuredPacket.payload := f_adaptPayload_m(
                    bit2oct(
                        encvalue(
                            m_camReq(
                                m_camMsg(
                                    f_getTsStationId(),
                                    35000
                                )
                            )
                        )
                    )
                );
                log("v_gnNonSecuredPacket.payload= ", v_gnNonSecuredPacket.payload);
                // Encode it
                v_gnPayload := bit2oct( 
                    encvalue(
                        v_gnNonSecuredPacket
                    )
                );
                log("v_gnPayload= ", v_gnPayload);
                f_buildGnSecuredCam(
                    v_securedMessageBeacon,
                    m_payload_signed(v_gnPayload),
                    e_certificate_digest_with_sha256,
                    {
                        m_header_field_generation_location(
                            vc_location
                        ),
                        m_header_field_unrecognised_certificate(
                            f_HashedId3FromHashedId8(
                                vc_aaCertificate.signer_info.signerInfo.digest
                            )
                        )
                     }
                );
                log("v_securedMessageBeacon= ", v_securedMessageBeacon);
                
                // Build secured Gn packet
                v_gnReq := m_geoNwReq_linkLayerBroadcast(
                    m_geoNwSecPdu(
                        v_gnNonSecuredPacket,
                        v_securedMessageBeacon
                    ) // End of template m_geoNwSecPdu
                ); // End of template m_geoNwReq_linkLayerBroadcast
                
                // Encode it
                v_encMsg := bit2oct(encvalue(v_gnReq));
                log("v_encMsg= ", v_encMsg);
                if (not isbound(v_encMsg)) {
                    setverdict(fail, "Encoding failed!");
                    stop;
                }
                setverdict(pass, "Encoding passed.");
                // Decode it
                v_gnReq.msgOut.gnPacket.packet.commonHeader.plLength := 45;
                test_decodePDU<GeoNetworkingReq>(
                    v_gnReq, 
                    v_encMsg
                );
                log("v_gnReq: ", v_gnReq);
                
                if (decvalue(oct2bit(v_encMsg), v_gnReq) == 0) {
                    if (f_verifyGnSecuredMessageSignatureWithCertificate(v_gnReq.msgOut.gnPacket.securedMsg, vc_atCertificate) == true) {
                        setverdict(pass, "Signature check succeed.");
                    } else {
                        setverdict(fail, "Signature check failed.");
                    } 
                } else {
                    setverdict(fail, "Decoding failed.");
                }
            }
            
            /**
             * @desc validate secured with digest GeoNetworkingReq/NwShb with a CAM payload and three additional header field
             * @verdict Pass on success, Fail otherwise
             */
            testcase tc_GeoNetReq_SecuredDigestNwShbPacketWithBtpPayloadCam_withMoreHeaders_3() runs on TCType system TCType {
                var GeoNetworkingReq v_gnReq;
                var GnNonSecuredPacket v_gnNonSecuredPacket;
                var octetstring v_gnPayload, v_encMsg;
                var template (value) ToBeSignedSecuredMessage v_toBeSignedSecuredMessage;
                var template (value) SecuredMessage v_securedMessageBeacon;
                
                if ((PX_GN_UPPER_LAYER != e_btpA) and (PX_GN_UPPER_LAYER != e_btpB)) {
                    log("PX_GN_UPPER_LAYER shall be set to e_btpA or e_btpB");
                    setverdict(inconc);
                    stop;
                }
                
                // Load certificates & keys
1697
                if (f_loadCertificates(PX_IUT_SEC_CONFIG_NAME) == false) {
1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805
                    setverdict(fail);
                    stop;
                }
                f_setGenerationLocation(
                    f_getTsLatitude(),
                    f_getTsLongitude()
                );
                
                // Build signed SecuredMessage
                v_gnNonSecuredPacket := m_geoNwShbPacket(
                    m_dummyLongPosVectorIut
                );
                log("v_gnNonSecuredPacket= ", v_gnNonSecuredPacket);
                // Add CAM payload
                v_gnNonSecuredPacket.payload := f_adaptPayload_m(
                    bit2oct(
                        encvalue(
                            m_camReq(
                                m_camMsg(
                                    f_getTsStationId(),
                                    35000
                                )
                            )
                        )
                    )
                );
                log("v_gnNonSecuredPacket.payload= ", v_gnNonSecuredPacket.payload);
                // Encode it
                v_gnPayload := bit2oct( 
                    encvalue(
                        v_gnNonSecuredPacket
                    )
                );
                log("v_gnPayload= ", v_gnPayload);
                f_buildGnSecuredCam(
                    v_securedMessageBeacon,
                    m_payload_signed(v_gnPayload),
                    e_certificate_digest_with_sha256,
                    {
                        m_header_field_signer_info(
                            m_signerInfo_certificate(
                                vc_aaCertificate
                        )),
                        m_header_field_generation_location(
                            vc_location
                        ),
                        m_header_field_unrecognised_certificate(
                            f_HashedId3FromHashedId8(
                                vc_aaCertificate.signer_info.signerInfo.digest
                            )
                        )
                     }
                );
                log("v_securedMessageBeacon= ", v_securedMessageBeacon);
                
                // Build secured Gn packet
                v_gnReq := m_geoNwReq_linkLayerBroadcast(
                    m_geoNwSecPdu(
                        v_gnNonSecuredPacket,
                        v_securedMessageBeacon
                    ) // End of template m_geoNwSecPdu
                ); // End of template m_geoNwReq_linkLayerBroadcast
                
                // Encode it
                v_encMsg := bit2oct(encvalue(v_gnReq));
                log("v_encMsg= ", v_encMsg);
                if (not isbound(v_encMsg)) {
                    setverdict(fail, "Encoding failed!");
                    stop;
                }
                setverdict(pass, "Encoding passed.");
                // Decode it
                v_gnReq.msgOut.gnPacket.packet.commonHeader.plLength := 45;
                test_decodePDU<GeoNetworkingReq>(
                    v_gnReq, 
                    v_encMsg
                );
                log("v_gnReq: ", v_gnReq);
                
                if (decvalue(oct2bit(v_encMsg), v_gnReq) == 0) {
                    if (f_verifyGnSecuredMessageSignatureWithCertificate(v_gnReq.msgOut.gnPacket.securedMsg, vc_atCertificate) == true) {
                        setverdict(pass, "Signature check succeed.");
                    } else {
                        setverdict(fail, "Signature check failed.");
                    } 
                } else {
                    setverdict(fail, "Decoding failed.");
                }
            }
            
            /**
             * @desc validate secured with certificate GeoNetworkingReq/NwShb with a CAM payload
             * @verdict Pass on success, Fail otherwise
             */
            testcase tc_GeoNetReq_SecuredCertificateNwShbPacketWithBtpPayloadCam() runs on TCType system TCType {
                var GeoNetworkingReq v_gnReq;
                var GnNonSecuredPacket v_gnNonSecuredPacket;
                var octetstring v_gnPayload, v_encMsg;
                var template (value) ToBeSignedSecuredMessage v_toBeSignedSecuredMessage;
                var template (value) SecuredMessage v_securedMessageBeacon;
                
                if ((PX_GN_UPPER_LAYER != e_btpA) and (PX_GN_UPPER_LAYER != e_btpB)) {
                    log("PX_GN_UPPER_LAYER shall be set to e_btpA or e_btpB");
                    setverdict(inconc);
                    stop;
                }
                
                // Load certificates & keys
1806
                if (f_loadCertificates(PX_IUT_SEC_CONFIG_NAME) == false) {
1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864
                    setverdict(fail);
                    stop;
                }
                f_setGenerationLocation(
                    f_getTsLatitude(),
                    f_getTsLongitude()
                );
                
                // Build signed SecuredMessage
                v_gnNonSecuredPacket := m_geoNwShbPacket(
                    m_dummyLongPosVectorIut
                );
                log("v_gnNonSecuredPacket= ", v_gnNonSecuredPacket);
                // Add CAM payload
                v_gnNonSecuredPacket.payload := f_adaptPayload_m(
                    bit2oct(
                        encvalue(
                            m_camReq(
                                m_camMsg(
                                    f_getTsStationId(),
                                    35000
                                )
                            )
                        )
                    )
                );
                log("v_gnNonSecuredPacket.payload= ", v_gnNonSecuredPacket.payload);
                // Encode it
                v_gnPayload := bit2oct( 
                    encvalue(
                        v_gnNonSecuredPacket
                    )
                );
                log("v_gnPayload= ", v_gnPayload);
                f_buildGnSecuredCam(
                    v_securedMessageBeacon,
                    m_payload_signed(v_gnPayload),
                    e_certificate
                );
                log("v_securedMessageBeacon= ", v_securedMessageBeacon);
                
                // Build secured Gn packet
                v_gnReq := m_geoNwReq_linkLayerBroadcast(
                    m_geoNwSecPdu(
                        v_gnNonSecuredPacket,
                        v_securedMessageBeacon
                    ) // End of template m_geoNwSecPdu
                ); // End of template m_geoNwReq_linkLayerBroadcast
                
                // Encode it
                v_encMsg := bit2oct(encvalue(v_gnReq));
                log("v_encMsg= ", v_encMsg);
                if (not isbound(v_encMsg)) {
                    setverdict(fail, "Encoding failed!");
                    stop;
                }
                setverdict(pass, "Encoding passed.");
                // Decode it
1865
                v_gnReq.msgOut.gnPacket.packet.commonHeader.plLength := 45;
1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900
                test_decodePDU<GeoNetworkingReq>(
                    v_gnReq, 
                    v_encMsg
                );
                log("v_gnReq: ", v_gnReq);
                
                if (decvalue(oct2bit(v_encMsg), v_gnReq) == 0) {
                    if (f_verifyGnSecuredMessageSignatureWithCertificate(v_gnReq.msgOut.gnPacket.securedMsg, vc_atCertificate) == true) {
                        setverdict(pass, "Signature check succeed.");
                    } else {
                        setverdict(fail, "Signature check failed.");
                    } 
                } else {
                    setverdict(fail, "Decoding failed.");
                }
            }
            
            /**
             * @desc validate secured with certificate chain GeoNetworkingReq/NwShb with a CAM payload
             * @verdict Pass on success, Fail otherwise
             */
            testcase tc_GeoNetReq_SecuredCertCertificateNwShbPacketWithBtpPayloadCam() runs on TCType system TCType {
                var GeoNetworkingReq v_gnReq;
                var GnNonSecuredPacket v_gnNonSecuredPacket;
                var octetstring v_gnPayload, v_encMsg;
                var template (value) ToBeSignedSecuredMessage v_toBeSignedSecuredMessage;
                var template (value) SecuredMessage v_securedMessageBeacon;
                
                if ((PX_GN_UPPER_LAYER != e_btpA) and (PX_GN_UPPER_LAYER != e_btpB)) {
                    log("PX_GN_UPPER_LAYER shall be set to e_btpA or e_btpB");
                    setverdict(inconc);
                    stop;
                }
                
                // Load certificates & keys
1901
                if (f_loadCertificates(PX_IUT_SEC_CONFIG_NAME) == false) {
1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959
                    setverdict(fail);
                    stop;
                }
                f_setGenerationLocation(
                    f_getTsLatitude(),
                    f_getTsLongitude()
                );
                
                // Build signed SecuredMessage
                v_gnNonSecuredPacket := m_geoNwShbPacket(
                    m_dummyLongPosVectorIut
                );
                log("v_gnNonSecuredPacket= ", v_gnNonSecuredPacket);
                // Add CAM payload
                v_gnNonSecuredPacket.payload := f_adaptPayload_m(
                    bit2oct(
                        encvalue(
                            m_camReq(
                                m_camMsg(
                                    f_getTsStationId(),
                                    35000
                                )
                            )
                        )
                    )
                );
                log("v_gnNonSecuredPacket.payload= ", v_gnNonSecuredPacket.payload);
                // Encode it
                v_gnPayload := bit2oct( 
                    encvalue(
                        v_gnNonSecuredPacket
                    )
                );
                log("v_gnPayload= ", v_gnPayload);
                f_buildGnSecuredCam(
                    v_securedMessageBeacon,
                    m_payload_signed(v_gnPayload),
                    e_certificate_chain
                );
                log("v_securedMessageBeacon= ", v_securedMessageBeacon);
                
                // Build secured Gn packet
                v_gnReq := m_geoNwReq_linkLayerBroadcast(
                    m_geoNwSecPdu(
                        v_gnNonSecuredPacket,
                        v_securedMessageBeacon
                    ) // End of template m_geoNwSecPdu
                ); // End of template m_geoNwReq_linkLayerBroadcast
                
                // Encode it
                v_encMsg := bit2oct(encvalue(v_gnReq));
                log("v_encMsg= ", v_encMsg);
                if (not isbound(v_encMsg)) {
                    setverdict(fail, "Encoding failed!");
                    stop;
                }
                setverdict(pass, "Encoding passed.");
                // Decode it
1960
                v_gnReq.msgOut.gnPacket.packet.commonHeader.plLength := 45;
1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982
                test_decodePDU<GeoNetworkingReq>(
                    v_gnReq, 
                    v_encMsg
                );
                log("v_gnReq: ", v_gnReq);
                
                if (decvalue(oct2bit(v_encMsg), v_gnReq) == 0) {
                    if (f_verifyGnSecuredMessageSignatureWithCertificate(v_gnReq.msgOut.gnPacket.securedMsg, vc_atCertificate) == true) {
                        setverdict(pass, "Signature check succeed.");
                    } else {
                        setverdict(fail, "Signature check failed.");
                    } 
                } else {
                    setverdict(fail, "Decoding failed.");
                }
            }
            
            /**
             * @desc validate secured with digest GeoNetworkingReq/NwShb with a DENM payload
             * @verdict Pass on success, Fail otherwise
             */
            testcase tc_GeoNetReq_SecuredDigestNwShbPacketWithBtpPayloadDenm() runs on TCType system TCType {
1983
                var template (value) SituationContainer v_situation := m_situation(CauseCodeType_vehicleBreakdown_, VehicleBreakdownSubCauseCode_unavailable_);
1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996
                var GeoNetworkingReq v_gnReq;
                var GnNonSecuredPacket v_gnNonSecuredPacket;
                var octetstring v_gnPayload, v_encMsg;
                var template (value) ToBeSignedSecuredMessage v_toBeSignedSecuredMessage;
                var template (value) SecuredMessage v_securedMessageBeacon;
                
                if (PX_GN_UPPER_LAYER != e_btpB) {
                    log("PX_GN_UPPER_LAYER shall be set to e_btpB");
                    setverdict(inconc);
                    stop;
                }
                
                // Load certificates & keys
1997
                if (f_loadCertificates(PX_IUT_SEC_CONFIG_NAME) == false) {
1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066
                    setverdict(fail);
                    stop;
                }
                f_setGenerationLocation(
                    f_getTsLatitude(),
                    f_getTsLongitude()
                );
                
                // Build signed SecuredMessage
                v_gnNonSecuredPacket := m_geoNwShbPacket(
                    m_dummyLongPosVectorIut
                );
                // Add DENM payload
                v_gnNonSecuredPacket.payload := f_adaptPayload_m(
                    bit2oct(
                        encvalue(
                            m_denmReq(
                                m_denmPdu(
                                    m_denm(
                                        m_denmMgmtCon(
                                            m_tsActionId
                                        ),
                                        v_situation,
                                        m_denmLocation_zeroDelta
                                    )
                               )
                           )
                        )
                    )
                );
                log("v_gnNonSecuredPacket= ", v_gnNonSecuredPacket);
                // Encode it
                v_gnPayload := bit2oct( // Create GN payload
                    encvalue(
                        v_gnNonSecuredPacket
                    )
                );
                log("v_gnPayload= ", v_gnPayload);
                
                f_buildGnSecuredDenm(
                    v_securedMessageBeacon,
                    m_payload_signed(v_gnPayload),
                    e_certificate_digest_with_sha256,
                    m_threeDLocation(
                        1234,
                        5678,
                        '002F'O
                    )
                );
                log("v_securedMessageBeacon= ", v_securedMessageBeacon);
                
                // Build secured Gn packet
                v_gnReq := m_geoNwReq_linkLayerBroadcast(
                    m_geoNwSecPdu(
                        v_gnNonSecuredPacket,
                        v_securedMessageBeacon
                    ) // End of template m_geoNwSecPdu
                ); // End of template m_geoNwReq_linkLayerBroadcast
                log("v_gnReq= ", v_gnReq);
                
                // Encode it
                v_encMsg := bit2oct(encvalue(v_gnReq));
                log("v_encMsg= ", v_encMsg);
                if (not isbound(v_encMsg)) {
                    setverdict(fail, "Encoding failed!");
                    stop;
                }
                setverdict(pass, "Encoding passed.");
                // Decode it
2067
                v_gnReq.msgOut.gnPacket.packet.commonHeader.plLength := 60;
2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147
                test_decodePDU<GeoNetworkingReq>(
                    v_gnReq, 
                    v_encMsg
                );
                
                if (decvalue(oct2bit(v_encMsg), v_gnReq) == 0) {
                    if (f_verifyGnSecuredMessageSignatureWithCertificate(v_gnReq.msgOut.gnPacket.securedMsg, vc_atCertificate) == true) {
                        setverdict(pass, "Signature check succeed.");
                    } else {
                        setverdict(fail, "Signature check failed.");
                    } 
                } else {
                    setverdict(fail, "Decoding failed.");
                }
            }
            
            /**
             * @desc validate GeoNetworkingReq/TSB ExtendedHeader
             * @verdict Pass on success, Fail otherwise
             */
            testcase tc_GeoNetReq_TsbHeaderPacket() runs on TCType system TCType {
                var GeoNetworkingReq v_gnReq;
                var GeoNetworkingPacket v_geoNetworkingPacket;
                var octetstring v_payload := 'CAFEDECACAFEDECACAFEDECACAFEDECACAFEDECACAFEDECACAFEDECACAFEDECACAFEDECACAFEDECACAFEDECACAFEDECACAFEDECACAFEDECACAFEDECACAFEDECACAFEDECACAFEDECA'O;
                var octetstring v_buffer := '01002B0A0051800000480A00269400008431A4FDEA5EA5ED0000036B000001090000031500500224CAFEDECACAFEDECACAFEDECACAFEDECACAFEDECACAFEDECACAFEDECACAFEDECACAFEDECACAFEDECACAFEDECACAFEDECACAFEDECACAFEDECACAFEDECACAFEDECACAFEDECACAFEDECAFFFFFFFFFFFF'O;
                
                if (PX_GN_UPPER_LAYER != e_any) {
                    log("PX_GN_UPPER_LAYER shall be set to e_any");
                    setverdict(inconc);
                    stop;
                }
                
                v_geoNetworkingPacket := m_geoNwPacketWithOctetstringPayload(
                    m_commonHeader(
                        PX_GN_UPPER_LAYER,
                        m_tsbHeaderType,
                        m_trafficClass,
                        c_defaultHopLimit
                    ),
                    m_tsbHeader(
                        9876, 
                        m_dummyLongPosVectorNodeA
                    ),
                    v_payload
                );
                v_gnReq := m_geoNwReq_linkLayerBroadcast(
                    m_geoNwPdu(
                        v_geoNetworkingPacket.packet
                ));
                log("v_gnReq :", v_gnReq);
                test_PDU<GeoNetworkingReq>(
                    v_gnReq, 
                    false, 
                    oct2bit(v_buffer)
                );
                v_gnReq.msgOut.gnPacket.packet.commonHeader.plLength := lengthof(v_payload);
                test_decodePDU<GeoNetworkingReq>(
                    v_gnReq, 
                    v_buffer
                );
            }
            
            /**
             * @desc validate secured GeoNetworkingReq/TSB ExtendedHeader
             * @verdict Pass on success, Fail otherwise
             */
            testcase tc_GeoNetReq_SecuredTsbHeaderPacket() runs on TCType system TCType {
                var GeoNetworkingReq v_gnReq;
                var GeoNetworkingPacket v_geoNetworkingPacket;
                var octetstring v_gnPayload, v_encMsg;
                var octetstring v_payload := 'CAFEDECACAFEDECACAFEDECACAFEDECACAFEDECACAFEDECACAFEDECACAFEDECACAFEDECACAFEDECACAFEDECACAFEDECACAFEDECACAFEDECACAFEDECACAFEDECACAFEDECACAFEDECA'O;
                var template (value) ToBeSignedSecuredMessage v_toBeSignedSecuredMessage;
                var template (value) SecuredMessage v_securedMessageBeacon;
                
                if (PX_GN_UPPER_LAYER != e_any) {
                    log("PX_GN_UPPER_LAYER shall be set to e_any");
                    stop;
                }
                
                // Load certificates & keys
2148
                if (f_loadCertificates(PX_IUT_SEC_CONFIG_NAME) == false) {
2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229
                    setverdict(fail);
                    stop;
                }
                f_setGenerationLocation(
                    f_getTsLatitude(),
                    f_getTsLongitude()
                );
                
                // Build signed SecuredMessage
                v_geoNetworkingPacket := m_geoNwPacketWithOctetstringPayload(
                    m_commonHeader(
                        PX_GN_UPPER_LAYER,
                        m_tsbHeaderType,
                        m_trafficClass,
                        c_defaultHopLimit
                    ),
                    m_tsbHeader(
                        9876, 
                        m_dummyLongPosVectorNodeA
                    ),
                    v_payload
                );
                v_gnReq := m_geoNwReq_linkLayerBroadcast(
                    m_geoNwPdu(
                        v_geoNetworkingPacket.packet
                ));
                v_gnPayload := bit2oct( // Create GN payload
                    encvalue(
                        v_gnReq.msgOut.gnPacket.packet 
                    )
                );
                f_buildGnSecuredOtherMessage(
                    v_securedMessageBeacon,
                    m_payload_signed(v_gnPayload),
                    e_certificate_digest_with_sha256,
                    m_threeDLocation(
                        1234,
                        5678,
                        '002F'O
                    )
                );
                
                // Build secured Gn packet
                v_gnReq := m_geoNwReq_linkLayerBroadcast(
                    m_geoNwSecPdu(
                        v_gnReq.msgOut.gnPacket.packet,
                        v_securedMessageBeacon
                    ) // End of template m_geoNwSecPdu
                ); // End of template m_geoNwReq_linkLayerBroadcast
                
                // Encode it
                v_encMsg := bit2oct(encvalue(v_gnReq));
                if (not isbound(v_encMsg)) {
                    setverdict(fail, "Encoding failed!");
                    stop;
                }
                setverdict(pass, "Encoding passed.");
                // Decode it
                v_gnReq.msgOut.gnPacket.packet.commonHeader.plLength := lengthof(v_payload);
                test_decodePDU<GeoNetworkingReq>(
                    v_gnReq, 
                    v_encMsg
                );
                
                if (decvalue(oct2bit(v_encMsg), v_gnReq) == 0) {
                    if (f_verifyGnSecuredMessageSignatureWithCertificate(v_gnReq.msgOut.gnPacket.securedMsg, vc_atCertificate) == true) {
                        setverdict(pass, "Signature check succeed.");
                    } else {
                        setverdict(fail, "Signature check failed.");
                    } 
                } else {
                    setverdict(fail, "Decoding failed.");
                }
            }
            
            /**
             * @desc validate GeoNetworkingReq/Anycast
             * @verdict Pass on success, Fail otherwise
             */
            testcase tc_GeoNetReq_AnycastPacket() runs on TCType system TCType {
                var GeoNetworkingReq v_gnReq;
2230
                var octetstring v_buffer := '01002B0A00308000000F0A001DE60000A832A40102030405000011E90000007E0000007B002D007D00048D8800007FE904D217BE23A3000044454641554C545F5041594C4F4144FFFFFFFFFFFF'O;
2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270
                
                if (PX_GN_UPPER_LAYER != e_any) {
                    log("PX_GN_UPPER_LAYER shall be set to e_any");
                    stop;
                }
                
                v_gnReq := m_geoNwReq_linkLayerBroadcast(
                    m_geoNwPdu(
                        m_geoNwAnycastPacket(
                            m_dummyLongPosVectorNodeB, 
                            7654, 
                            m_dummyGeoAnycastArea1
                )));
                test_PDU<GeoNetworkingReq>(
                    v_gnReq, 
                    false, 
                    oct2bit(v_buffer));
                v_gnReq.msgOut.gnPacket.packet.commonHeader.plLength := 15;
                test_decodePDU<GeoNetworkingReq>(
                    v_gnReq, 
                    v_buffer
                );
            }
            
            /**
             * @desc validate secured GeoNetworkingReq/Anycast
             * @verdict Pass on success, Fail otherwise
             */
            testcase tc_GeoNetReq_SecuredAnycastPacket() runs on TCType system TCType {
                var GeoNetworkingReq v_gnReq;
                var octetstring v_gnPayload, v_encMsg;
                var template (value) ToBeSignedSecuredMessage v_toBeSignedSecuredMessage;
                var template (value) SecuredMessage v_securedMessageBeacon;
                
                if (PX_GN_UPPER_LAYER != e_any) {
                    log("PX_GN_UPPER_LAYER shall be set to e_any");
                    stop;
                }
                
                // Load certificates & keys
2271
                if (f_loadCertificates(PX_IUT_SEC_CONFIG_NAME) == false) {
2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344
                    setverdict(fail);
                    stop;
                }
                f_setGenerationLocation(
                    f_getTsLatitude(),
                    f_getTsLongitude()
                );
                
                // Build signed SecuredMessage
                v_gnPayload := bit2oct( // Create GN payload
                    encvalue(
                        m_geoNwAnycastPacket(
                            m_dummyLongPosVectorNodeB, 
                            7654, 
                            m_dummyGeoAnycastArea1
                        )
                    )
                );
                f_buildGnSecuredOtherMessage(
                    v_securedMessageBeacon,
                    m_payload_signed(v_gnPayload),
                    e_certificate_digest_with_sha256,
                    m_threeDLocation(
                        1234,
                        5678,
                        '002F'O
                    )
                );
                
                // Build secured Gn packet
                v_gnReq := m_geoNwReq_linkLayerBroadcast(
                    m_geoNwSecPdu(
                        m_geoNwAnycastPacket(
                            m_dummyLongPosVectorNodeB, 
                            7654, 
                            m_dummyGeoAnycastArea1
                        ),
                        v_securedMessageBeacon
                    ) // End of template m_geoNwSecPdu
                ); // End of template m_geoNwReq_linkLayerBroadcast
                
                // Encode it
                v_encMsg := bit2oct(encvalue(v_gnReq));
                if (not isbound(v_encMsg)) {
                    setverdict(fail, "Encoding failed!");
                    stop;
                }
                setverdict(pass, "Encoding passed.");
                // Decode it
                v_gnReq.msgOut.gnPacket.packet.commonHeader.plLength := 15;
                test_decodePDU<GeoNetworkingReq>(
                    v_gnReq, 
                    v_encMsg
                );
                
                if (decvalue(oct2bit(v_encMsg), v_gnReq) == 0) {
                    if (f_verifyGnSecuredMessageSignatureWithCertificate(v_gnReq.msgOut.gnPacket.securedMsg, vc_atCertificate) == true) {
                        setverdict(pass, "Signature check succeed.");
                    } else {
                        setverdict(fail, "Signature check failed.");
                    } 
                } else {
                    setverdict(fail, "Decoding failed.");
                }
            }
            
            /**
             * @desc validate GeoNetworkingReq/Anycast with hop limit
             * @verdict Pass on success, Fail otherwise
             */
            testcase tc_GeoNetReq_AnycastPacketWithHopLimit() runs on TCType system TCType {
                var GeoNetworkingReq v_gnReq;
                var ExtendedHeader v_header := null;
2345
                var octetstring v_buffer := '01002B0A00308000000F05001DE60000A832A40102030405000011E90000007E0000007B002D007D00048D8800007FE904D217BE23A3000044454641554C545F5041594C4F4144FFFFFFFFFFFF'O;
2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386
                
                if (PX_GN_UPPER_LAYER != e_any) {
                    log("PX_GN_UPPER_LAYER shall be set to e_any");
                    stop;
                }
                
                v_gnReq := m_geoNwReq_linkLayerBroadcast(
                    m_geoNwPdu(
                        m_geoNwAnycastPacket(
                            m_dummyLongPosVectorNodeB, 
                            7654, 
                            m_dummyGeoAnycastArea1,
                            c_defaultHopLimit / 2
                )));
                test_PDU<GeoNetworkingReq>(
                    v_gnReq, 
                    false, 
                    oct2bit(v_buffer));
                v_gnReq.msgOut.gnPacket.packet.commonHeader.plLength := 15;
                test_decodePDU<GeoNetworkingReq>(
                    v_gnReq, 
                    v_buffer
                );
            }
            
            /**
             * @desc validate secured GeoNetworkingReq/Anycast with hop limit
             * @verdict Pass on success, Fail otherwise
             */
            testcase tc_GeoNetReq_SecuredAnycastPacketWithHopLimit() runs on TCType system TCType {
                var GeoNetworkingReq v_gnReq;
                var octetstring v_gnPayload, v_encMsg;
                var template (value) ToBeSignedSecuredMessage v_toBeSignedSecuredMessage;
                var template (value) SecuredMessage v_securedMessageBeacon;
                
                if (PX_GN_UPPER_LAYER != e_any) {
                    log("PX_GN_UPPER_LAYER shall be set to e_any");
                    stop;
                }
                
                // Load certificates & keys
2387
                if (f_loadCertificates(PX_IUT_SEC_CONFIG_NAME) == false) {
2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503
                    setverdict(fail);
                    stop;
                }
                f_setGenerationLocation(
                    f_getTsLatitude(),
                    f_getTsLongitude()
                );
                
                // Build signed SecuredMessage
                v_gnPayload := bit2oct( // Create GN payload
                    encvalue(
                        m_geoNwAnycastPacket(
                            m_dummyLongPosVectorNodeB, 
                            7654, 
                            m_dummyGeoAnycastArea1,
                            c_defaultHopLimit / 2
                        )
                    )
                );
                f_buildGnSecuredOtherMessage(
                    v_securedMessageBeacon,
                    m_payload_signed(v_gnPayload),
                    e_certificate_digest_with_sha256,
                    m_threeDLocation(
                        1234,
                        5678,
                        '002F'O
                    )
                );
                
                // Build secured Gn packet
                v_gnReq := m_geoNwReq_linkLayerBroadcast(
                    m_geoNwSecPdu(
                        m_geoNwAnycastPacket(
                            m_dummyLongPosVectorNodeB, 
                            7654, 
                            m_dummyGeoAnycastArea1,
                            c_defaultHopLimit / 2
                        ),
                        v_securedMessageBeacon
                    ) // End of template m_geoNwSecPdu
                ); // End of template m_geoNwReq_linkLayerBroadcast
                
                // Encode it
                v_encMsg := bit2oct(encvalue(v_gnReq));
                if (not isbound(v_encMsg)) {
                    setverdict(fail, "Encoding failed!");
                    stop;
                }
                setverdict(pass, "Encoding passed.");
                // Decode it
                v_gnReq.msgOut.gnPacket.packet.commonHeader.plLength := 15;
                test_decodePDU<GeoNetworkingReq>(
                    v_gnReq, 
                    v_encMsg
                );
                
                if (decvalue(oct2bit(v_encMsg), v_gnReq) == 0) {
                    if (f_verifyGnSecuredMessageSignatureWithCertificate(v_gnReq.msgOut.gnPacket.securedMsg, vc_atCertificate) == true) {
                        setverdict(pass, "Signature check succeed.");
                    } else {
                        setverdict(fail, "Signature check failed.");
                    } 
                } else {
                    setverdict(fail, "Decoding failed.");
                }
            }
            
            /**
             * @desc validate GeoNetworkingReq/Unicast
             * @verdict Pass on success, Fail otherwise
             */
            testcase tc_GeoNetReq_UnicastPacket() runs on TCType system TCType {
                var GeoNetworkingReq v_gnReq;
                var ExtendedHeader v_header := null;
                var octetstring v_buffer := '01002B0A00208000000F0A001DE60000A832A40102030405000011E90000007E0000007B002D007DBC21A4FEDECABEEF0001E240000012F8000002A344454641554C545F5041594C4F4144FFFFFFFFFFFF'O;
                
                if (PX_GN_UPPER_LAYER != e_any) {
                    log("PX_GN_UPPER_LAYER shall be set to e_any");
                    stop;
                }
                
                v_gnReq := m_geoNwReq_linkLayerBroadcast(
                    m_geoNwPdu(
                        m_geoNwUnicastPacket(
                            m_dummyLongPosVectorNodeB, 
                            f_longPosVector2ShortPosVector(m_dummyLongPosVectorIut), 
                            7654
                )));
                test_PDU<GeoNetworkingReq>(
                    v_gnReq, 
                    false, 
                    oct2bit(v_buffer));
                v_gnReq.msgOut.gnPacket.packet.commonHeader.plLength := 15;
                test_decodePDU<GeoNetworkingReq>(
                    v_gnReq, 
                    v