ItsPki_TestCases.ttcn 113 KB
Newer Older
garciay's avatar
garciay committed
1
2
3
4
5
6
7
8
9
10
11
12
/**
 *  @author   ETSI / STF545
 *  @version  $URL$
 *            $Id$
 *  @desc     Testcases  file for Security Protocol
 *  @reference   ETSI TS ITS-00546v006
 *  @copyright   ETSI Copyright Notification
 *               No part may be reproduced except as authorized by written permission.
 *               The copyright and the foregoing restriction extend to reproduction in all media.
 *               All rights reserved.
 */
module ItsPki_TestCases {
Yann Garcia's avatar
Yann Garcia committed
13
  
garciay's avatar
garciay committed
14
15
16
17
18
  // Libcommon
  import from LibCommon_Time all;
  import from LibCommon_VerdictControl all;
  import from LibCommon_Sync all;
  import from LibCommon_BasicTypesAndValues all;
Yann Garcia's avatar
Yann Garcia committed
19
  import from LibCommon_DataStrings all;
garciay's avatar
garciay committed
20
21
22
23
24
25
    
  // LibIts
  import from IEEE1609dot2BaseTypes language "ASN.1:1997" all;
  import from IEEE1609dot2 language "ASN.1:1997" all;
  import from EtsiTs102941BaseTypes language "ASN.1:1997" all;
  import from EtsiTs102941TypesEnrolment language "ASN.1:1997" all;
26
27
  import from EtsiTs102941TypesAuthorization language "ASN.1:1997" all;
  import from EtsiTs102941TypesAuthorizationValidation language "ASN.1:1997" all;
28
  import from EtsiTs102941MessagesCa language "ASN.1:1997" all;
garciay's avatar
garciay committed
29
30
31
  import from EtsiTs103097Module language "ASN.1:1997" all;
  import from ITS_Container language "ASN.1:1997" all;
  import from CAM_PDU_Descriptions language "ASN.1:1997" all;
Yann Garcia's avatar
Yann Garcia committed
32
  
garciay's avatar
garciay committed
33
  // LibItsCommon
Yann Garcia's avatar
Yann Garcia committed
34
  import from LibItsCommon_TypesAndValues all;
garciay's avatar
garciay committed
35
  import from LibItsCommon_Functions all;
Yann Garcia's avatar
Yann Garcia committed
36
  import from LibItsCommon_TypesAndValues all;
garciay's avatar
garciay committed
37
  import from LibItsCommon_ASN1_NamedNumbers all;
Yann Garcia's avatar
Yann Garcia committed
38
39
  
  // LibItsGeoNetworking
40
  import from LibItsGeoNetworking_TypesAndValues all;
Yann Garcia's avatar
Yann Garcia committed
41
42
43
  import from LibItsGeoNetworking_Functions all;
  import from LibItsGeoNetworking_Templates all;
  import from LibItsGeoNetworking_Pics all;
44
  import from LibItsGeoNetworking_TestSystem all;
Yann Garcia's avatar
Yann Garcia committed
45
  
garciay's avatar
garciay committed
46
47
48
49
50
51
52
  // LibItsSecurity
  import from LibItsSecurity_TypesAndValues all;
  import from LibItsSecurity_TestSystem all;
  import from LibItsSecurity_Templates all;
  import from LibItsSecurity_Functions all;
  import from LibItsSecurity_Pixits all;
  import from LibItsSecurity_Pics all;
Yann Garcia's avatar
Yann Garcia committed
53
  
garciay's avatar
garciay committed
54
55
56
57
58
  // LibItsHttp
  import from LibItsHttp_TypesAndValues all;
  import from LibItsHttp_Templates all;
  import from LibItsHttp_BinaryTemplates all;
  import from LibItsHttp_Functions all;
Yann Garcia's avatar
Yann Garcia committed
59
  import from LibItsHttp_TestSystem all;
garciay's avatar
garciay committed
60
  
garciay's avatar
garciay committed
61
62
  // LibItsPki
  import from LibItsPki_Templates all;
Yann Garcia's avatar
Yann Garcia committed
63
  import from LibItsPki_Functions all;
garciay's avatar
garciay committed
64
  import from LibItsPki_TestSystem all;
garciay's avatar
garciay committed
65
66
  import from LibItsPki_Pics all;
  
garciay's avatar
garciay committed
67
68
69
70
71
72
73
74
75
  // AtsPki
  import from ItsPki_Functions all;

  /**
   * @desc 5.2	ITS-S behaviour
   */
  group itss_behavior {

    group itss_manufacturing {
Yann Garcia's avatar
Yann Garcia committed
76
      
garciay's avatar
garciay committed
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
      /**
       * @desc Check that IUT sends an enrolment request when triggered.
       * <pre>
       * Pics Selection: 
       * Initial conditions: 
       *     with {
       *         the IUT being in the "initial state"
       *     }
       * Expected behaviour:
       *     ensure that {
       *         when {
       *             the IUT is triggered to requested a new Enrolment Certificate (EC)
       *         }
       *         then {
       *             the IUT sends to EA an EnrolmentRequestMessage
       *         }
       *     }
       * </pre>
       * 
       * @see       ETSI TS ITS-00546v006 TP 2
       * @reference ETSI TS 102 941 [2], clause 6.1.3
       */
99
      testcase TC_SEC_PKI_ITSS_ENR_BV_01() runs on ItsMtc /*system ItsPkiItssSystem*/ {
garciay's avatar
garciay committed
100
        // Local variables
101
102
103
104
105
        var Oct32      v_private_key;
        var Oct32      v_publicKeyX;
        var Oct32      v_publicKeyY;
        var Oct32      v_publicKeyCompressed;
        var integer    v_compressedMode;
Yann Garcia's avatar
Yann Garcia committed
106
107
108
        var ItsPkiItss v_itss;
        var ItsPki     v_ea;
        
garciay's avatar
garciay committed
109
110
111
112
113
114
        // Test control
        if (not PICS_IUT_ITS_S_ROLE) {
          log("*** " & testcasename() & ": PICS_IUT_ITS_S_ROLE required for executing the TC ***");
          setverdict(inconc);
          stop;
        }
115
        
garciay's avatar
garciay committed
116
        // Test component configuration
Yann Garcia's avatar
Yann Garcia committed
117
        
118
119
120
121
122
        if (f_generate_key_pair_nistp256(v_private_key, v_publicKeyX, v_publicKeyY, v_publicKeyCompressed, v_compressedMode) == false) {
          log("*** " & testcasename() & ": FAIL: Failed to setup InnerEcRequest message ***")
          setverdict(inconc);
          stop;
        }
Yann Garcia's avatar
Yann Garcia committed
123
124
        v_itss.start(f_TC_SEC_PKI_ITSS_ENR_BV_01_itss(cc_taCert_A, v_private_key, v_publicKeyCompressed, v_compressedMode));
        v_ea.start(f_TC_SEC_PKI_ITSS_ENR_BV_01_pki(cc_taCert_A, v_private_key, v_publicKeyCompressed, v_compressedMode));
Yann Garcia's avatar
Yann Garcia committed
125
126
127
        
        // Synchronization
        f_serverSync2ClientsAndStop({c_prDone, c_tbDone, c_poDone});
garciay's avatar
garciay committed
128
        
Yann Garcia's avatar
Yann Garcia committed
129
        // Cleanup
garciay's avatar
garciay committed
130
131
132
        
      } // End of testcase TC_SEC_PKI_ITSS_ENR_BV_01
      
Yann Garcia's avatar
Yann Garcia committed
133
134
      group f_TC_SEC_PKI_ITSS_ENR_BV_01 {
        
135
        function f_TC_SEC_PKI_ITSS_ENR_BV_01_itss(
Yann Garcia's avatar
Yann Garcia committed
136
137
138
139
140
                                                 in charstring p_certificate_id,
                                                 in octetstring p_private_key,
                                                 in octetstring p_publicKeyCompressed,
                                                 in integer p_compressedMode
                                                 ) runs on ItsPkiItss /*system ItsPkiItssSystem*/ {
garciay's avatar
garciay committed
141
          // Local variables
142
          
garciay's avatar
garciay committed
143
144
          // Test component configuration
          f_cfUp_itss();
145
          
garciay's avatar
garciay committed
146
          // Test adapter configuration
147
          
garciay's avatar
garciay committed
148
          // Preamble
Yann Garcia's avatar
Yann Garcia committed
149
150
          f_sendUtTriggerPrimitive(PICS_ITS_S_CANONICAL_ID, '00'O, p_private_key, p_publicKeyCompressed, p_compressedMode);
          f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
151
          
garciay's avatar
garciay committed
152
          // Test Body
Yann Garcia's avatar
Yann Garcia committed
153
154
          f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
          
garciay's avatar
garciay committed
155
156
          // Postamble
          f_cfDown_itss();
Yann Garcia's avatar
Yann Garcia committed
157
        } // End of function f_TC_SEC_PKI_ITSS_ENR_BV_01_itss
Yann Garcia's avatar
Yann Garcia committed
158
        
159
160
161
162
163
        function f_TC_SEC_PKI_ITSS_ENR_BV_01_pki(
                                                 in charstring p_certificate_id,
                                                 in octetstring p_private_key,
                                                 in octetstring p_publicKeyCompressed,
                                                 in integer p_compressedMode
164
165
166
167
                                                 ) runs on ItsPki /*system ItsPkiSystem*/ {
          // Local variables
          
          // Test component configuration
168
          LibItsPki_Functions.f_cfUp();
Yann Garcia's avatar
Yann Garcia committed
169
          
170
171
          // Test adapter configuration
          
172
          // Preamble
Yann Garcia's avatar
Yann Garcia committed
173
174
175
          f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
          
          // Test Body
176
177
          tc_ac.start;
          alt {
Yann Garcia's avatar
Yann Garcia committed
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
            [PICS_SEC_NIST_P256 and p_compressedMode == 0] pkiPort.receive(
                                                                           mw_innerEcRequest(
                                                                                             PICS_ITS_S_CANONICAL_ID,
                                                                                             mw_publicKeys(
                                                                                                           mw_publicVerificationKey_ecdsaNistP256(
                                                                                                                                                  mw_eccP256CurvePoint_compressed_y_0(
                                                                                                                                                                                      p_publicKeyCompressed
                                                                                                                                                                                      )
                                                                                                                                                 ),
                                                                                                           omit
                                                                                                           )
                                                                                             )
                                                                           ) {
              log("*** " & testcasename() & ": INFO: InnerEcRequest received ***");
              // TODO Send InnerEcResponse;
              log("*** " & testcasename() & ": PASS: Message triggered ***");
              f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
            }
            [PICS_SEC_NIST_P256 and p_compressedMode == 1] pkiPort.receive(
                                                                           mw_innerEcRequest(
                                                                                             PICS_ITS_S_CANONICAL_ID,
                                                                                             mw_publicKeys(
                                                                                                           mw_publicVerificationKey_ecdsaNistP256(
                                                                                                                                                  mw_eccP256CurvePoint_compressed_y_1(
                                                                                                                                                                                      p_publicKeyCompressed
                                                                                                                                                                                      )
                                                                                                                                                 ),
                                                                                                           omit
                                                                                                           )
                                                                                             )
                                                                           ) {
209
              log("*** " & testcasename() & ": INFO: InnerEcRequest received ***");
Yann Garcia's avatar
Yann Garcia committed
210
211
212
              // TODO Send InnerEcResponse;
              log("*** " & testcasename() & ": PASS: Message triggered ***");
              f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
213
214
215
216
217
218
219
220
221
            }
            [] tc_ac.timeout {
              log("*** " & testcasename() & ": INCONC: Expected message not received ***");
              f_selfOrClientSyncAndVerdictTestBody(c_prDone, e_timeout);
            }
          } // End of 'alt' statement
          
          // Postamble
          LibItsPki_Functions.f_cfDown();
Yann Garcia's avatar
Yann Garcia committed
222
        } // End of function f_TC_SEC_PKI_ITSS_ENR_BV_01_pki
Yann Garcia's avatar
Yann Garcia committed
223
        
Yann Garcia's avatar
Yann Garcia committed
224
      } // End of group f_TC_SEC_PKI_ITSS_ENR_BV_01
225
      
garciay's avatar
garciay committed
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
      /**
       * @desc If the enrolment request of the IUT is an initial enrolment request, the itsId 
       *       (contained in the InnerECRequest) shall be set to the canonical identifier, the 
       *       signer (contained in the outer EtsiTs1030971Data-Signed) shall be set to self and 
       *       the outer signature shall be computed using the canonical private key.
       * <pre>
       * Pics Selection: 
       * Expected behaviour:
       *     ensure that {
       *         when {
       *             the IUT is requested to send an EnrolmentRequestMessage
       *         }
       *         then {
       *             the IUT sends an EtsiTs103097Data-Encrypted
       *                 containing an encrypted EtsiTs103097Data-Signed
       *                     containing EtsiTs103097Data
       *                          containing InnerECRequestSignedForPOP
       *                             containing InnerEcRequest
       *                                 containing itsId
       *                                     indicating the canonical identifier of the ITS-S 
       *                 and containing signer
       *                     declared as self
       *                 and containing signature 
       *                     computed using the canonical private key
       *         }
       *     }
       * </pre>
       * 
       * @see       ETSI TS ITS-00546v006 TP 3
       * @reference ETSI TS 102 941, clause 6.1.3
       */
257
      testcase TC_SEC_PKI_ITSS_ENR_BV_02() runs on ItsMtc /*system ItsPkiItssSystem*/ {
258
259
260
261
262
263
264
265
        // Local variables
        var Oct32      v_private_key;
        var Oct32      v_publicKeyX;
        var Oct32      v_publicKeyY;
        var Oct32      v_publicKeyCompressed;
        var integer    v_compressedMode;
        var ItsPkiItss v_itss;
        var ItsPkiHttp v_ea;
garciay's avatar
garciay committed
266
        
267
268
269
270
271
272
273
274
275
276
277
278
279
280
        // Test control
        if (not PICS_IUT_ITS_S_ROLE) {
          log("*** " & testcasename() & ": PICS_IUT_ITS_S_ROLE required for executing the TC ***");
          setverdict(inconc);
          stop;
        }
        
        // Test component configuration
        
        if (f_generate_key_pair_nistp256(v_private_key, v_publicKeyX, v_publicKeyY, v_publicKeyCompressed, v_compressedMode) == false) {
          log("*** " & testcasename() & ": FAIL: Failed to setup InnerEcRequest message ***")
          setverdict(inconc);
          stop;
        }
Yann Garcia's avatar
Yann Garcia committed
281
282
        v_itss.start(f_TC_SEC_PKI_ITSS_ENR_BV_02_itss(cc_taCert_A, v_private_key, v_publicKeyCompressed, v_compressedMode));
        v_ea.start(f_TC_SEC_PKI_ITSS_ENR_BV_02_pki(cc_taCert_A, v_private_key, v_publicKeyCompressed, v_compressedMode));
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
        
        // Synchronization
        f_serverSync2ClientsAndStop({c_prDone, c_tbDone, c_poDone});
        
        // Cleanup
        
      } // End of TC_SEC_PKI_ITSS_ENR_BV_02
      
      group f_TC_SEC_PKI_ITSS_ENR_BV_02 {
        
        function f_TC_SEC_PKI_ITSS_ENR_BV_02_itss(
                                                  in charstring p_certificate_id,
                                                  in octetstring p_private_key,
                                                  in octetstring p_publicKeyCompressed,
                                                  in integer p_compressedMode
298
                                                  ) runs on ItsPkiItss /*system ItsPkiItssSystem*/ {
299
300
301
302
303
304
305
306
          // Local variables
          
          // Test component configuration
          f_cfUp_itss();
          
          // Test adapter configuration
          
          // Preamble
Yann Garcia's avatar
Yann Garcia committed
307
308
          f_sendUtTriggerPrimitive(PICS_ITS_S_CANONICAL_ID, '00'O, p_private_key, p_publicKeyCompressed, p_compressedMode);
          f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
309
310
311
312
313
314
          
          // Test Body
          f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
          
          // Postamble
          f_cfDown_itss();
Yann Garcia's avatar
Yann Garcia committed
315
        } // End of function f_TC_SEC_PKI_ITSS_ENR_BV_02_itss
316
317
318
319
320
321
        
        function f_TC_SEC_PKI_ITSS_ENR_BV_02_pki(
                                                 in charstring p_certificate_id,
                                                 in octetstring p_private_key,
                                                 in octetstring p_publicKeyCompressed,
                                                 in integer p_compressedMode
Yann Garcia's avatar
Yann Garcia committed
322
                                                 ) runs on ItsPkiHttp system ItsPkiHttpSystem {
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
          // Local variable
          var HttpMessage v_response;
          var EtsiTs102941Data v_etsi_ts_102941_data;
          var InnerEcRequest v_inner_ec_request;
          
          // Test component configuration
          f_cfHttpUp();
          
          // Test adapter configuration
          
          // Preamble
          f_selfOrClientSyncAndVerdictTestBody(c_prDone, e_success);
          
          // Test Body
          tc_ac.start;
          alt {
            [] httpPort.receive(
                                mw_http_response(
                                                 mw_http_response_ok(
                                                                     mw_http_message_body_binary(
                                                                                                 mw_binary_body_ieee1609dot2_data(
                                                                                                                                  mw_enrolmentRequestMessage(
                                                                                                                                                             mw_encryptedData(
                                                                                                                                                                              -,
                                                                                                                                                                              mw_SymmetricCiphertext_aes128ccm
                                                                                                                                                                              ))))))) -> value v_response {
              tc_ac.stop;
              
              if (f_verify_pki_message(vc_eaPrivateEncKey, int2oct(0, 32), vc_eaCertificate, v_response.response.body.binary_body.ieee1609dot2_data, false, v_etsi_ts_102941_data) == false) {
                log("*** " & testcasename() & ": FAIL: Failed to verify PKI message ***");
                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
              } else {
                log("*** " & testcasename() & ": LOG: Receive ", v_etsi_ts_102941_data, " ***");
                log("*** " & testcasename() & ": DEBUG: match ", match(v_etsi_ts_102941_data.content, mw_enrolmentRequest(mw_innerEcRequestSignedForPop(mw_signedData))), " ***"); // TODO In TITAN, this is the oly way to get the unmatching in log
                if (match(v_etsi_ts_102941_data.content, mw_enrolmentRequest(mw_innerEcRequestSignedForPop(mw_signedData)))) {
                  // TODO Verify signature of mw_innerEcRequestSignedForPop
                  log("*** " & testcasename() & ": PASS: InnerEcRequestSignedForPop received ***");
                  f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                } else {
                  log("*** " & testcasename() & ": FAIL: Unexpected message received ***");
                  f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                }
              }
            }
            [] tc_ac.timeout {
              log("*** " & testcasename() & ": INCONC: Expected message not received ***");
              f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
            }
          } // End of 'alt' statement
          
          // Postamble
          f_cfHttpDown();
Yann Garcia's avatar
Yann Garcia committed
375
        } // End of function f_TC_SEC_PKI_ITSS_ENR_BV_02_pki
376
        
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
      } // End of f_TC_SEC_PKI_ITSS_ENR_BV_02
      
      /**
       * @desc Check that IUT sends an enrolment request when triggered.
       * <pre>
       * Pics Selection: 
       * Initial conditions: 
       *     with {
       *         the IUT being in the "initial state"
       *     }
       * Expected behaviour:
       *     ensure that {
       *         when {
       *             the IUT is triggered to requested a new Enrolment Certificate (EC)
       *         }
       *         then {
       *             the IUT sends to EA an EnrolmentRequestMessage
       *         }
       *     }
       * </pre>
       * 
       * @see       ETSI TS ITS-00546v006 TP 2
       * @reference ETSI TS 102 941 [2], clause 6.1.3
       */
      testcase TEST() runs on ItsMtc /*system ItsPkiItssSystem*/ {
        // Local variables
        var Oct32      v_private_key;
        var Oct32      v_publicKeyX;
        var Oct32      v_publicKeyY;
        var Oct32      v_publicKeyCompressed;
        var integer    v_compressedMode;
        var ItsPkiItss v_itss;
        var ItsPki     v_ea;
        
        // Test control
        if (not PICS_IUT_ITS_S_ROLE) {
          log("*** " & testcasename() & ": PICS_IUT_ITS_S_ROLE required for executing the TC ***");
          setverdict(inconc);
          stop;
        }
        
        // Test component configuration
        
        if (f_generate_key_pair_nistp256(v_private_key, v_publicKeyX, v_publicKeyY, v_publicKeyCompressed, v_compressedMode) == false) {
          log("*** " & testcasename() & ": FAIL: Failed to setup InnerEcRequest message ***")
          setverdict(inconc);
          stop;
        }
        v_itss.start(f_TEST_itss(cc_taCert_A, v_private_key, v_publicKeyX, v_publicKeyY, v_publicKeyCompressed, v_compressedMode));
        v_ea.start(f_TEST_pki(cc_taCert_A, v_private_key, v_publicKeyX, v_publicKeyY, v_publicKeyCompressed, v_compressedMode));
        
        // Synchronization
        f_serverSync2ClientsAndStop({c_prDone, c_tbDone, c_poDone});
        
        // Cleanup
        
      } // End of testcase TEST
      
      group f_TEST {
        
        function f_TEST_itss(
                                                  in charstring p_certificate_id,
                                                  in octetstring p_private_key,
                                                  in octetstring p_publicKeyX,
                                                  in octetstring p_publicKeyY,
                                                  in octetstring p_publicKeyCompressed,
                                                  in integer p_compressedMode
                                                  ) runs on ItsPkiItss /*system ItsPkiItssSystem*/ {
          
          // Local variables
          var GeoNetworkingInd        v_geoNwInd;
          var EtsiTs103097Certificate v_initial_certificate;
          
          // Test component configuration
          f_cfUp_itss();
          
          // Test adapter configuration
          
          // Preamble
          tc_ac.start; // Wait for current certificate
          alt {
            [] geoNetworkingPort.receive(
                                         mw_geoNwInd(
                                                     mw_geoNwSecPdu(
                                                                    mw_etsiTs103097Data_signed(
                                                                                               mw_signedData(
                                                                                                             -, 
                                                                                                             mw_toBeSignedData(
                                                                                                                               mw_signedDataPayload,
                                                                                                                               mw_headerInfo_cam
                                                                                                                               ),
                                                                                                             mw_signerIdentifier_certificate(
                                                                                                                                             mw_etsiTs103097Certificate(
                                                                                                                                                                        -,
                                                                                                                                                                        mw_toBeSignedCertificate_at(
                                                                                                                                                                                                    { mw_appPermissions(c_its_aid_CAM) }
                                                                                                                                                                                                    )
                                                                                                                                                                        )
                                                                                                                                             )
                                                                                                             )
                                                                                               ), 
                                                                    mw_geoNwShbPacket
                                                                    ))) -> value v_geoNwInd {
              tc_ac.stop;
              
              log("*** " & testcasename() & ": INFO: Receieve initial certificate");
              // Extract the initial certificate
              v_initial_certificate := v_geoNwInd.msgIn.gnPacket.securedMsg.content.signedData.signer.certificate[0];
              f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
            }
            [] geoNetworkingPort.receive(
                                         mw_geoNwInd(
                                                     mw_geoNwSecPdu(
                                                                    mw_etsiTs103097Data_signed
                                                                    ))) {
              log("*** " & testcasename() & ": DEBUG: Still waiting for certificate");
              repeat;
            }
            [] tc_ac.timeout {
              log("*** " & testcasename() & ": INCONC: Expected CA message not received ***");
              f_selfOrClientSyncAndVerdictTestBody(c_prDone, e_timeout);
            }
          } // End of 'alt' statement
          
          // Test Body
          tc_ac.start;
          alt {
            [] geoNetworkingPort.receive(
                                         mw_geoNwInd(
                                                     mw_geoNwSecPdu(
                                                                    mw_etsiTs103097Data_signed(
                                                                                               mw_signedData(
                                                                                                             -,
                                                                                                             mw_toBeSignedData(
                                                                                                                               mw_signedDataPayload,
                                                                                                                               mw_headerInfo_cam
                                                                                                                               ),
                                                                                                             mw_signerIdentifier_certificate(
                                                                                                                                             v_initial_certificate
                                                                                                                                             )
                                                                                                             )
                                                                                               ),
                                                                    mw_geoNwShbPacket
                                                                    ))) {
              log("*** " & testcasename() & ": INFO: IUT still using initial certificate ***");
              repeat;
            }
            [] geoNetworkingPort.receive(
                                         mw_geoNwInd(
                                                     mw_geoNwSecPdu(
                                                                    mw_etsiTs103097Data_signed(
                                                                                               mw_signedData(
                                                                                                             -,
                                                                                                             mw_toBeSignedData(
                                                                                                                               mw_signedDataPayload,
                                                                                                                               mw_headerInfo_gn
                                                                                                                               ),
                                                                                                             mw_signerIdentifier_certificate
                                                                                                             )
                                                                                               )
                                                                    ))) -> value v_geoNwInd {
              tc_ac.stop;
              log("*** " & testcasename() & ": PASS: IUT uses new certificate ***");
              // TODO Check that is the expected one
              f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
            }
            [] geoNetworkingPort.receive(
                                         mw_geoNwInd(
                                                     mw_geoNwSecPdu(
                                                                    mw_etsiTs103097Data_signed
                                                                    ))) {
              log("*** " & testcasename() & ": INFO: Unexpected message received, continue ***");
              repeat;
            }
            [] tc_ac.timeout {
              log("*** " & testcasename() & ": INCONC: Expected message not received ***");
              f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
            }
          } // End of 'alt' statement
            
          // Postamble
          f_cfDown_itss();
Yann Garcia's avatar
Yann Garcia committed
559
        } // End of function f_TEST_itss
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
601
602
603
        
        function f_TEST_pki(
                                                 in charstring p_certificate_id,
                                                 in octetstring p_private_key,
                                                 in octetstring p_publicKeyX,
                                                 in octetstring p_publicKeyY,
                                                 in octetstring p_publicKeyCompressed,
                                                 in integer p_compressedMode
                                                 ) runs on ItsPki /*system ItsPkiSystem*/ {
          // Local variables
          
          // Test component configuration
          LibItsPki_Functions.f_cfUp();
          
          // Test adapter configuration
          
          // Preamble
          tc_ac.start;
          alt {
            [] pkiPort.receive(
                               mw_innerEcRequest
                               ) {
              log("*** " & testcasename() & ": INFO: InnerEcRequest received ***");
              repeat;
            }
            [] pkiPort.receive(
                               mw_innerEcResponse_ok
                               ) {
              tc_ac.stop;
              log("*** " & testcasename() & ": INFO: InnerEcResponse received ***");
              f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
            }
            [] tc_ac.timeout {
              log("*** " & testcasename() & ": INCONC: Expected message not received ***");
              f_selfOrClientSyncAndVerdictTestBody(c_prDone, e_timeout);
            }
          } // End of 'alt' statement
          
          // Test Body
          log("*** " & testcasename() & ": PASS: Message triggered ***");
          f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
          
          // Postamble
          LibItsPki_Functions.f_cfDown();
Yann Garcia's avatar
Yann Garcia committed
604
        } // End of function f_TEST_pki
605
606
        
      } // End of f_TEST
Yann Garcia's avatar
Yann Garcia committed
607
      
garciay's avatar
garciay committed
608
609
610
    } // End of group itss_manufacturing
    
  } // End of group itss_behavior
Yann Garcia's avatar
Yann Garcia committed
611
  
garciay's avatar
garciay committed
612
  group ea_behavior {
garciay's avatar
garciay committed
613
614

    group enrolment_request_handling {
garciay's avatar
garciay committed
615
      
garciay's avatar
garciay committed
616
617
618
619
620
      /**
       * @desc The EnrolmentResponse message shall be sent by the EA to the 
       *       ITS-S across the interface at reference point S3 in response 
       *       to a received EnrolmentRequest message.
       * <pre>
garciay's avatar
garciay committed
621
       * Pics Selection: PICS_IUT_EA_ROLE
garciay's avatar
garciay committed
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
       * Initial conditions: 
       *     with {
       *         the IUT being in the "operational state"
       *     }
       * Expected behaviour:
       *     ensure that {
       *         when {
       *             the IUT receives an EnrolmentRequestMessage across the interface at the reference point S3
       *         }
       *         then {
       *             the IUT answers with an EnrolmentResponseMessage across the interface at reference point S3
       *         }
       *     }
       * </pre>
       * 
       * @see       ETSI TS ITS-00546v006 TP 20
       * @reference ETSI TS 102 941, clause 6.2.3.2.2
       */
      testcase TC_SEC_PKI_SND_EA_BV_01() runs on ItsPki system ItsPkiSystem {
        // Local variables
        var Oct32 v_private_key;
        var Oct32 v_publicKeyCompressed;
        var integer v_compressedMode;
        var InnerEcRequest v_inner_ec_request;
        
        // Test control
        if (not PICS_IUT_EA_ROLE) {
          log("*** " & testcasename() & ": PICS_IUT_EA_ROLE required for executing the TC ***");
          setverdict(inconc);
          stop;
Yann Garcia's avatar
Yann Garcia committed
652
        }
garciay's avatar
garciay committed
653
654
        
        // Test component configuration
Yann Garcia's avatar
Yann Garcia committed
655
        LibItsPki_Functions.f_cfUp(PICS_TS_CERTIFICATE_ID, PICS_IUT_EA_CERTIFICATE_ID);
garciay's avatar
garciay committed
656
657
658
659
        
        // Test adapter configuration
        
        // Preamble
Yann Garcia's avatar
Yann Garcia committed
660
        if (f_generate_inner_ec_request(v_private_key, v_publicKeyCompressed, v_compressedMode, v_inner_ec_request) == false) {
garciay's avatar
garciay committed
661
662
663
          log("*** " & testcasename() & ": FAIL: Failed to setup InnerEcRequest message ***")
          f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_error);
          stop;
Yann Garcia's avatar
Yann Garcia committed
664
        }
Yann Garcia's avatar
Yann Garcia committed
665
        f_sendAcPkiPrimitive(PICS_TS_CERTIFICATE_ID, v_private_key, v_publicKeyCompressed, v_compressedMode);
garciay's avatar
garciay committed
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
        f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
        
        // Test Body
        pkiPort.send(v_inner_ec_request);
        tc_ac.start;
        alt {
          [] pkiPort.receive(
                             mw_innerEcResponse_ok
                             ) {
            tc_ac.stop;
            log("*** " & testcasename() & ": PASS: InnerEcResponse received ***");
            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
          }
          [] tc_ac.timeout {
            log("*** " & testcasename() & ": INCONC: Expected message not received ***");
            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
          }
        } // End of 'alt' statement
        
        // Postamble
        LibItsPki_Functions.f_cfDown();
        
      } // End of testcase TC_SEC_PKI_SND_EA_BV_01

    } // End of group enrolment_request_handling
Yann Garcia's avatar
Yann Garcia committed
691

garciay's avatar
garciay committed
692
693
694
695
696
697
698
    group enrolment_response {
      
      /**
       * @desc The EnrolmentResponse message shall be encrypted using an ETSI TS 103 097 approved 
       *       algorithm and the encryption shall be done with the same AES key as the one used 
       *       by the ITS-S requestor for the encryption of the EnrolmentRequest message
       * <pre>
garciay's avatar
garciay committed
699
       * Pics Selection: PICS_IUT_EA_ROLE
garciay's avatar
garciay committed
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
       * Expected behaviour:
       *     ensure that {
       *         when {
       *             the IUT receives an EnrolmentRequestMessage
       *                 containing encKey
       *                     containing an encrypted AES key (SYMKEY)
       *         }
       *         then {
       *             the IUT answers with an EnrolmentResponseMessage
       *                 containing cipherTex
       *                     being encrypted
       *                         using SYMKEY
       *                         and using an ETSI TS 103 097 approved algorithm
       *         }
       *     }
       * </pre>
       * 
       * @see       ETSI TS ITS-00546v006 TP 22
       * @reference ETSI TS 102 941, clause 6.2.3.2.2
       */
      testcase TC_SEC_PKI_SND_EA_BV_02() runs on ItsPkiHttp system ItsPkiHttpSystem {
        // Local variables
        var Oct32 v_private_key;
        var Oct32 v_publicKeyCompressed;
        var integer v_compressedMode;
725
        var Oct32 v_hash_inner_ec_request_signed_for_pop;
garciay's avatar
garciay committed
726
727
728
729
        var Ieee1609Dot2Data v_ieee1609dot2_signed_and_encrypted_data;
        var HeaderLines v_headers;
        var HttpMessage v_response;
        var EtsiTs102941Data v_etsi_ts_102941_data;
730
        
garciay's avatar
garciay committed
731
732
733
734
735
736
        // Test control
        if (not PICS_IUT_EA_ROLE) {
          log("*** " & testcasename() & ": PICS_IUT_EA_ROLE required for executing the TC ***");
          setverdict(inconc);
          stop;
        }
737
        
garciay's avatar
garciay committed
738
739
        // Test component configuration
        f_cfHttpUp(); // Default value: CERT_TS_A_EA
740
        
garciay's avatar
garciay committed
741
        // Test adapter configuration
742
        
garciay's avatar
garciay committed
743
        // Preamble
Yann Garcia's avatar
Yann Garcia committed
744
        f_http_build_inner_ec_request(v_private_key, v_publicKeyCompressed, v_compressedMode, v_ieee1609dot2_signed_and_encrypted_data, v_hash_inner_ec_request_signed_for_pop);
garciay's avatar
garciay committed
745
746
        f_init_default_headers_list(v_headers);
        f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
747
        
garciay's avatar
garciay committed
748
749
750
751
        // Test Body
        httpPort.send(
                      m_http_request(
                                     m_http_request_get(
752
                                                        PICS_HTTP_GET_URI,
garciay's avatar
garciay committed
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
                                                        v_headers,
                                                        m_http_message_body_binary(
                                                                                   m_binary_body_ieee1609dot2_data(
                                                                                                                   v_ieee1609dot2_signed_and_encrypted_data
                                                                                                                   )))));
        tc_ac.start;
        alt {
          [] httpPort.receive(
                              mw_http_response(
                                               mw_http_response_ok(
                                                                   mw_http_message_body_binary(
                                                                                               mw_binary_body_ieee1609dot2_data(
                                                                                                                                mw_enrolmentResponseMessage(
                                                                                                                                                            mw_encryptedData(
                                                                                                                                                                             -,
                                                                                                                                                                             mw_SymmetricCiphertext_aes128ccm
                                                                                                                                                                             ))))))) -> value v_response {
            tc_ac.stop;
771
            
772
            if (f_verify_pki_message(vc_eaPrivateEncKey, vc_eaPeerWholeHash, vc_peerEaCertificate, v_response.response.body.binary_body.ieee1609dot2_data, false, v_etsi_ts_102941_data) == false) {
garciay's avatar
garciay committed
773
              log("*** " & testcasename() & ": FAIL: Failed to verify PKI message ***");
774
775
              f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
            } else {
garciay's avatar
garciay committed
776
              log("*** " & testcasename() & ": LOG: Receive ", v_etsi_ts_102941_data, " ***");
777
778
              log("*** " & testcasename() & ": DEBUG: match ", match(v_etsi_ts_102941_data.content, mw_enrolmentResponse(mw_innerEcResponse_ok(substr(v_hash_inner_ec_request_signed_for_pop, 0, 16)))), " ***"); // TODO In TITAN, this is the oly way to get the unmatching in log
              if (match(v_etsi_ts_102941_data.content, mw_enrolmentResponse(mw_innerEcResponse_ok(substr(v_hash_inner_ec_request_signed_for_pop, 0, 16))))) {
garciay's avatar
garciay committed
779
780
                log("*** " & testcasename() & ": PASS: InnerEcResponse received ***");
                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
781
782
783
              } else {
                log("*** " & testcasename() & ": FAIL: Unexpected message received ***");
                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
garciay's avatar
garciay committed
784
              }
785
786
            }
          }
garciay's avatar
garciay committed
787
788
789
790
791
          [] tc_ac.timeout {
            log("*** " & testcasename() & ": INCONC: Expected message not received ***");
            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
          }
        } // End of 'alt' statement
792
    
garciay's avatar
garciay committed
793
794
        // Postamble
        f_cfHttpDown();
795
    
garciay's avatar
garciay committed
796
      } // End of testcase TC_SEC_PKI_SND_EA_BV_02
797
    
garciay's avatar
garciay committed
798
799
800
801
802
803
804
805
      /**
       * @desc The outermost structure is an EtsiTs103097Data-Encrypted structure containing 
       *       the component recipients containing one instance of RecipientInfo of choice 
       *       pskRecipInfo, which contains the HashedId8 of the symmetric key used by the 
       *       ITS-S to encrypt the EnrolmentRequest message to which the response is built 
       *       and containing the component ciphertext, once decrypted, contains an 
       *       EtsiTs103097Data-Signed structure
       * <pre>
garciay's avatar
garciay committed
806
       * Pics Selection: PICS_IUT_EA_ROLE
garciay's avatar
garciay committed
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
       * Expected behaviour:
       *     ensure that {
       *         when {
       *             the IUT receives an EnrolmentRequestMessage
       *         }
       *         then {
       *             the IUT sends an EtsiTs103097Data-Encrypted structure
       *                 containing recipients
       *                     containing one instance of RecipientInfo of choice pskRecipInfo
       *                         containing the HashedId8 of the symmetric key used to encrypt the EnrolmentRequestMessage
       *                 and containing cipherText
       *                     being an encrypted EtsiTs103097Data-Signed structure
       *         }
       *     }
       * </pre>
       * 
       * @see       ETSI TS ITS-00546v006 TP 24
       * @reference ETSI TS 102 941, clause 6.2.3.2.2
       */
      testcase TC_SEC_PKI_SND_EA_BV_03() runs on ItsPkiHttp system ItsPkiHttpSystem {
        // Local variables
        var Oct32 v_private_key;
        var Oct32 v_publicKeyCompressed;
        var integer v_compressedMode;
831
        var Oct32 v_hash_inner_ec_request_signed_for_pop;
garciay's avatar
garciay committed
832
833
834
835
        var Ieee1609Dot2Data v_ieee1609dot2_signed_and_encrypted_data;
        var HeaderLines v_headers;
        var HttpMessage v_response;
        var EtsiTs102941Data v_etsi_ts_102941_data;
836
        
garciay's avatar
garciay committed
837
838
839
840
841
842
        // Test control
        if (not PICS_IUT_EA_ROLE) {
          log("*** " & testcasename() & ": PICS_IUT_EA_ROLE required for executing the TC ***");
          setverdict(inconc);
          stop;
        }
843
        
garciay's avatar
garciay committed
844
845
        // Test component configuration
        f_cfHttpUp(); // Default value: CERT_TS_A_EA
846
        
garciay's avatar
garciay committed
847
        // Test adapter configuration
848
        
garciay's avatar
garciay committed
849
        // Preamble
Yann Garcia's avatar
Yann Garcia committed
850
        f_http_build_inner_ec_request(v_private_key, v_publicKeyCompressed, v_compressedMode, v_ieee1609dot2_signed_and_encrypted_data, v_hash_inner_ec_request_signed_for_pop);
garciay's avatar
garciay committed
851
852
853
854
        f_init_default_headers_list(v_headers);
        httpPort.send(
                      m_http_request(
                                     m_http_request_get(
855
                                                        PICS_HTTP_GET_URI,
garciay's avatar
garciay committed
856
857
858
859
860
861
                                                        v_headers,
                                                        m_http_message_body_binary(
                                                                                   m_binary_body_ieee1609dot2_data(
                                                                                                                   v_ieee1609dot2_signed_and_encrypted_data
                                                                                                                   )))));
        f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
862
      
garciay's avatar
garciay committed
863
864
865
866
867
868
869
870
871
872
873
874
875
876
        // Test Body
        tc_ac.start;
        alt {
          [] httpPort.receive(
                              mw_http_response(
                                               mw_http_response_ok(
                                                                   mw_http_message_body_binary(
                                                                                               mw_binary_body_ieee1609dot2_data(
                                                                                                                                mw_enrolmentResponseMessage(
                                                                                                                                                            mw_encryptedData(
                                                                                                                                                                             -,
                                                                                                                                                                             mw_SymmetricCiphertext_aes128ccm
                                                                                                                                                                             ))))))) -> value v_response {
            tc_ac.stop;
877
            
878
            if (f_verify_pki_message(vc_eaPrivateEncKey, vc_eaPeerWholeHash, vc_peerEaCertificate, v_response.response.body.binary_body.ieee1609dot2_data, false, v_etsi_ts_102941_data) == false) {
garciay's avatar
garciay committed
879
              log("*** " & testcasename() & ": FAIL: Failed to verify PKI message ***");
880
881
              f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
            } else {
garciay's avatar
garciay committed
882
              log("*** " & testcasename() & ": LOG: Receive ", v_etsi_ts_102941_data, " ***");
883
884
              log("*** " & testcasename() & ": DEBUG: match ", match(v_etsi_ts_102941_data.content, mw_enrolmentResponse(mw_innerEcResponse_ok(substr(v_hash_inner_ec_request_signed_for_pop, 0, 16)))), " ***"); // TODO In TITAN, this is the oly way to get the unmatching in log
              if (match(v_etsi_ts_102941_data.content, mw_enrolmentResponse(mw_innerEcResponse_ok(substr(v_hash_inner_ec_request_signed_for_pop, 0, 16))))) {
garciay's avatar
garciay committed
885
886
                log("*** " & testcasename() & ": PASS: InnerEcResponse received ***");
                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
887
888
889
              } else {
                log("*** " & testcasename() & ": FAIL: Unexpected message received ***");
                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
garciay's avatar
garciay committed
890
              }
891
892
            }
          }
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
          [] tc_ac.timeout {
            log("*** " & testcasename() & ": INCONC: Expected message not received ***");
            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
          }
        } // End of 'alt' statement
        
        // Postamble
        f_cfHttpDown();
        
      } // End of testcase TC_SEC_PKI_SND_EA_BV_03

      /**
       * @desc If the ITS-S has been able to decrypt the content, this expected EtsiTs103097Data-Signed structure shall 
       *       contain hashId, tbsData, signer and signature. The hashId shall indicate the hash algorithm to be used as 
       *       specified in ETSI TS 103 097, the signer shall be declared as a digest, containing the HashedId8 of the 
       *       EA certificate and the signature over tbsData shall be computed using the EA private key corresponding to 
       *       its publicVerificationKey found in the referenced EA certificate.
       * <pre>
garciay's avatar
garciay committed
911
       * Pics Selection: PICS_IUT_EA_ROLE
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
       * Expected behaviour:
       *     ensure that {
       *         when {
       *             the IUT receives an EnrolmentRequestMessage
       *         }
       *         then {
       *             the IUT sends an EtsiTs103097Data-Encrypted structure
       *                 containing an encrypted EtsiTs103097Data-Signed structure
       *                     containing hashId
       *                        indicating the hash algorithm to be used as specified in ETSI TS 103 097
       *                     and containing tbsData
       *                     and containing signer
       *                         declared as a digest
       *                             containing the HashedId8 of the EA certificate
       *                     and containing signature
       *                         computed over tbsData
       *                             using the EA private key
       *                                 corresponding to the publicVerificationKey found in the referenced EA certificate
       *         }
       *     }
       * </pre>
       * 
       * @see       ETSI TS ITS-00546v006 TP 25
       * @reference ETSI TS 102 941, clause 6.2.3.2.2
       */
      testcase TC_SEC_PKI_SND_EA_BV_04() runs on ItsPkiHttp system ItsPkiHttpSystem {
        // Local variables
        var Oct32 v_private_key;
        var Oct32 v_publicKeyCompressed;
        var integer v_compressedMode;
        var Oct32 v_hash_inner_ec_request_signed_for_pop;
        var Ieee1609Dot2Data v_ieee1609dot2_signed_and_encrypted_data;
        var HeaderLines v_headers;
        var HttpMessage v_response;
        var EtsiTs102941Data v_etsi_ts_102941_data;
      
        // Test control
        if (not PICS_IUT_EA_ROLE) {
          log("*** " & testcasename() & ": PICS_IUT_EA_ROLE required for executing the TC ***");
          setverdict(inconc);
          stop;
        }
        
        // Test component configuration
        f_cfHttpUp(); // Default value: CERT_TS_A_EA
        
        // Test adapter configuration
        
        // Preamble
Yann Garcia's avatar
Yann Garcia committed
961
        f_http_build_inner_ec_request(v_private_key, v_publicKeyCompressed, v_compressedMode, v_ieee1609dot2_signed_and_encrypted_data, v_hash_inner_ec_request_signed_for_pop);
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
        f_init_default_headers_list(v_headers);
        httpPort.send(
                      m_http_request(
                                     m_http_request_get(
                                                        PICS_HTTP_GET_URI,
                                                        v_headers,
                                                        m_http_message_body_binary(
                                                                                   m_binary_body_ieee1609dot2_data(
                                                                                                                   v_ieee1609dot2_signed_and_encrypted_data
                                                                                                                   )))));
        f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
        
        // Test Body
        tc_ac.start;
        alt {
          [] httpPort.receive(
garciay's avatar
garciay committed
978
                              mw_http_response(
979
980
981
982
983
984
985
986
                                               mw_http_response_ok(
                                                                   mw_http_message_body_binary(
                                                                                               mw_binary_body_ieee1609dot2_data(
                                                                                                                                mw_enrolmentResponseMessage(
                                                                                                                                                            mw_encryptedData(
                                                                                                                                                                             -,
                                                                                                                                                                             mw_SymmetricCiphertext_aes128ccm
                                                                                                                                                                             ))))))) -> value v_response {
garciay's avatar
garciay committed
987
            tc_ac.stop;
988
            
989
            if (f_verify_pki_message(vc_eaPrivateEncKey, vc_eaPeerWholeHash, vc_peerEaCertificate, v_response.response.body.binary_body.ieee1609dot2_data, false, v_etsi_ts_102941_data) == false) {
990
991
992
993
              log("*** " & testcasename() & ": FAIL: Failed to verify PKI message ***");
              f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
            } else {
              log("*** " & testcasename() & ": LOG: Receive ", v_etsi_ts_102941_data, " ***");
994
995
              log("*** " & testcasename() & ": DEBUG: match ", match(v_etsi_ts_102941_data.content, mw_enrolmentResponse(mw_innerEcResponse_ok(substr(v_hash_inner_ec_request_signed_for_pop, 0, 16)))), " ***"); // TODO In TITAN, this is the oly way to get the unmatching in log
              if (match(v_etsi_ts_102941_data.content, mw_enrolmentResponse(mw_innerEcResponse_ok(substr(v_hash_inner_ec_request_signed_for_pop, 0, 16))))) {
996
997
998
999
1000
                if (f_verify_ea_certificate(v_etsi_ts_102941_data.content.enrolmentResponse.certificate, v_publicKeyCompressed, v_compressedMode)) {
                  log("*** " & testcasename() & ": PASS: Well-secured EA certificate received ***");
                  f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                } else {
                  log("*** " & testcasename() & ": FAIL: Cannot verify EA certificate signature ***");
For faster browsing, not all history is shown. View entire blame