ItsPki_TestCases.ttcn 224 KB
Newer Older
garciay's avatar
garciay committed
1
/**
2
 *  @Author   ETSI / STF545
garciay's avatar
garciay committed
3
4
5
6
7
8
9
10
11
12
 *  @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;
Yann Garcia's avatar
Yann Garcia committed
20
  
garciay's avatar
garciay committed
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
  // LibItsPki
Yann Garcia's avatar
Yann Garcia committed
62
  import from LibItsPki_TypesAndValues all;
garciay's avatar
garciay committed
63
  import from LibItsPki_Templates all;
Yann Garcia's avatar
Yann Garcia committed
64
  import from LibItsPki_Functions all;
garciay's avatar
garciay committed
65
  import from LibItsPki_TestSystem all;
garciay's avatar
garciay committed
66
  import from LibItsPki_Pics all;
67
  import from LibItsPki_Pixits all;
Yann Garcia's avatar
Yann Garcia committed
68
69
70

  // ItsPki
  import from ItsPki_Pixits all;
garciay's avatar
garciay committed
71
  
garciay's avatar
garciay committed
72
73
74
75
  /**
   * @desc 5.2	ITS-S behaviour
   */
  group itss_behavior {
Yann Garcia's avatar
Yann Garcia committed
76
77
78
    
    group itss_helpers {

Yann Garcia's avatar
Yann Garcia committed
79
80
81
82
83
84
85
86
87
88
      function f_verify_http_ec_request_from_iut(
                                                 in Request p_request,
                                                 in HeaderLines p_headers,
                                                 out InnerEcRequest p_inner_ec_request,
                                                 out HttpMessage p_response,
                                                 out integer p_result,
                                                 in template octetstring p_its_id := PICS_ITS_S_CANONICAL_ID,
                                                 in template SignerIdentifier p_signer := m_signerIdentifier_self,
                                                 in EnrolmentResponseCode p_force_response_code := ok
                                                 ) runs on ItsPkiHttp {
Yann Garcia's avatar
Yann Garcia committed
89
90
91
92
93
        // Local variables
        var Ieee1609Dot2Data v_ieee1609dot2_signed_and_encrypted_data;
        var EtsiTs102941Data v_etsi_ts_102941_data;
        var Oct16 v_request_hash;
        var Oct16 v_aes_enc_key;
Yann Garcia's avatar
Yann Garcia committed
94
        var InnerEcResponse v_inner_ec_response;
Yann Garcia's avatar
Yann Garcia committed
95
96
        var template (value) HttpMessage v_response;
        
Yann Garcia's avatar
Yann Garcia committed
97
        log(">>> f_verify_http_ec_request_from_iut:", p_request);
Yann Garcia's avatar
Yann Garcia committed
98
99
100
        
        p_result := 0;
        
Yann Garcia's avatar
Yann Garcia committed
101
        if (f_verify_pki_request_message(vc_eaPrivateEncKey, vc_eaWholeHash/*salt*/, vc_eaWholeHash, p_request.body.binary_body.ieee1609dot2_data, false, v_request_hash, v_etsi_ts_102941_data, v_aes_enc_key) == false) { // Cannot decrypt the message
Yann Garcia's avatar
Yann Garcia committed
102
103
104
105
106
          // Send error message
          v_response := m_http_response(m_http_response_ko(m_http_message_body_binary(m_binary_body_ieee1609dot2_data(v_ieee1609dot2_signed_and_encrypted_data)), p_headers, 400, "Bad request")); // Initialize v_reponse with an error message
          // Set verdict
          p_result := -1;
        } else {
Yann Garcia's avatar
Yann Garcia committed
107
          log("f_verify_http_ec_request_from_iut: match ", match(v_etsi_ts_102941_data.content, mw_enrolmentRequest(mw_innerEcRequestSignedForPop(mw_signedData(sha256, mw_toBeSignedData(-, mw_headerInfo_inner_pki_request), p_signer))))); // TODO In TITAN, this is the only way to get the unmatching in log
Yann Garcia's avatar
Yann Garcia committed
108
109
          if (match(v_etsi_ts_102941_data.content, mw_enrolmentRequest(mw_innerEcRequestSignedForPop(mw_signedData(sha256, mw_toBeSignedData(-, mw_headerInfo_inner_pki_request), p_signer)))) == false) {
            // Send error message
Yann Garcia's avatar
Yann Garcia committed
110
            f_http_build_inner_ec_response(p_inner_ec_request/*Not required*/, cantparse, v_request_hash, -, -, v_aes_enc_key, v_inner_ec_response, v_ieee1609dot2_signed_and_encrypted_data);
Yann Garcia's avatar
Yann Garcia committed
111
112
113
114
115
116
            // Set verdict
            p_result := -2;
          } else {
            // Verify signature of mw_innerEcRequestSignedForPop
            if (f_verify_inner_ec_request_signed_for_pop(v_etsi_ts_102941_data, p_inner_ec_request) == false) {
              // Send error message
Yann Garcia's avatar
Yann Garcia committed
117
              f_http_build_inner_ec_response(p_inner_ec_request/*Not required*/, cantparse, v_request_hash, -, -, v_aes_enc_key, v_inner_ec_response, v_ieee1609dot2_signed_and_encrypted_data);
Yann Garcia's avatar
Yann Garcia committed
118
119
120
121
              v_response := m_http_response(m_http_response_ok(m_http_message_body_binary(m_binary_body_ieee1609dot2_data(v_ieee1609dot2_signed_and_encrypted_data)), p_headers));
              // Set verdict
              p_result := -3;
            } else {
Yann Garcia's avatar
Yann Garcia committed
122
              log("f_verify_http_ec_request_from_iut: match ", match(p_inner_ec_request, mw_innerEcRequest(p_its_id, -, mw_certificate_subject_attributes({mw_appPermissions(c_its_aid_SCR, ?)})))); // TODO In TITAN, this is the only way to get the unmatching in log
Yann Garcia's avatar
Yann Garcia committed
123
124
              if (match(p_inner_ec_request, mw_innerEcRequest(p_its_id, -, mw_certificate_subject_attributes({mw_appPermissions(c_its_aid_SCR, ?)}))) == false) {
                // Send error message: Not enrolmentrequest
Yann Garcia's avatar
Yann Garcia committed
125
                f_http_build_inner_ec_response(p_inner_ec_request, badcontenttype, v_request_hash, -, -, v_aes_enc_key, v_inner_ec_response, v_ieee1609dot2_signed_and_encrypted_data);
Yann Garcia's avatar
Yann Garcia committed
126
127
128
129
130
                v_response := m_http_response(m_http_response_ok(m_http_message_body_binary(m_binary_body_ieee1609dot2_data(v_ieee1609dot2_signed_and_encrypted_data)), p_headers));
                // Set verdict
                p_result := -4;
              } else {
                // Send OK message
Yann Garcia's avatar
Yann Garcia committed
131
                log("f_verify_http_ec_request_from_iut: Receive ", p_inner_ec_request);
Yann Garcia's avatar
Yann Garcia committed
132
                if (p_force_response_code == ok) {
Yann Garcia's avatar
Yann Garcia committed
133
                  f_http_build_inner_ec_response(p_inner_ec_request, ok, v_request_hash, vc_eaPrivateKey, vc_eaWholeHash, v_aes_enc_key, v_inner_ec_response, v_ieee1609dot2_signed_and_encrypted_data);
Yann Garcia's avatar
Yann Garcia committed
134
                } else {
Yann Garcia's avatar
Yann Garcia committed
135
136
                  log("f_verify_http_ec_request_from_iut: Succeed buit force error code ", p_force_response_code);
                  f_http_build_inner_ec_response(p_inner_ec_request, p_force_response_code, v_request_hash, -, -, v_aes_enc_key, v_inner_ec_response, v_ieee1609dot2_signed_and_encrypted_data);
Yann Garcia's avatar
Yann Garcia committed
137
138
139
140
141
142
143
144
145
146
                }
                v_response := m_http_response(m_http_response_ok(m_http_message_body_binary(m_binary_body_ieee1609dot2_data(v_ieee1609dot2_signed_and_encrypted_data)), p_headers));
                // Set verdict
                p_result := 0;
              }
            }
          }
        }

        p_response := valueof(v_response);
Yann Garcia's avatar
Yann Garcia committed
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
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
209
210
211
212
213
214
215
216
217
218
        log("<<< f_verify_http_ec_request_from_iut: p_response: ", p_response);
        log("<<< f_verify_http_ec_request_from_iut: p_result: ", p_result);
     } // End of function f_verify_http_ec_request_from_iut

      function f_verify_http_at_request_from_iut(
                                                 in Request p_request,
                                                 in HeaderLines p_headers,
                                                 in InnerEcResponse p_inner_ec_resonse,
                                                 out InnerAtRequest pinner_at_request,
                                                 out HttpMessage p_response,
                                                 out integer p_result
                                                 ) runs on ItsPkiHttp {
        // Local variables
        var Ieee1609Dot2Data v_ieee1609dot2_signed_and_encrypted_data;
        var EtsiTs102941Data v_etsi_ts_102941_data;
        var Oct16 v_request_hash;
        var Oct16 v_aes_enc_key;
        var template (value) HttpMessage v_response;
        
        log(">>> f_verify_http_at_request_from_iut:", p_request);
        
        p_result := 0;
        
        if (f_verify_pki_request_message(vc_aaPrivateEncKey, vc_aaWholeHash/*salt*/, vc_aaWholeHash, p_request.body.binary_body.ieee1609dot2_data, false, v_request_hash, v_etsi_ts_102941_data, v_aes_enc_key) == false) { // Cannot decrypt the message
          // Send error message
          v_response := m_http_response(m_http_response_ko(m_http_message_body_binary(m_binary_body_ieee1609dot2_data(v_ieee1609dot2_signed_and_encrypted_data)), p_headers, 400, "Bad request")); // Initialize v_reponse with an error message
          // Set verdict
          p_result := -1;
        } else {/*
          log("f_verify_http_at_request_from_iut: match ", match(v_etsi_ts_102941_data.content, mw_authorizationRequest(mw_innerEcRequestSignedForPop(mw_signedData(sha256, mw_toBeSignedData(-, mw_headerInfo_inner_pki_request), p_signer))))); // TODO In TITAN, this is the only way to get the unmatching in log
          if (match(v_etsi_ts_102941_data.content, mw_enrolmentRequest(mw_innerEcRequestSignedForPop(mw_signedData(sha256, mw_toBeSignedData(-, mw_headerInfo_inner_pki_request), p_signer)))) == false) {
            // Send error message
            f_http_build_inner_at_response(p_inner_at_request, cantparse, v_request_hash, -, -, v_aes_enc_key, v_ieee1609dot2_signed_and_encrypted_data);
            // Set verdict
            p_result := -2;
          } else {
            // Verify signature of mw_innerEcRequestSignedForPop
            if (f_verify_inner_at_request_signed_for_pop(v_etsi_ts_102941_data, p_inner_at_request) == false) {
              // Send error message
              f_http_build_inner_at_response(p_inner_at_request, cantparse, v_request_hash, -, -, v_aes_enc_key, v_ieee1609dot2_signed_and_encrypted_data);
              v_response := m_http_response(m_http_response_ok(m_http_message_body_binary(m_binary_body_ieee1609dot2_data(v_ieee1609dot2_signed_and_encrypted_data)), p_headers));
              // Set verdict
              p_result := -3;
            } else {
              log("f_verify_http_at_request_from_iut: match ", match(p_inner_at_request, mw_innerEcRequest(p_its_id, -, mw_certificate_subject_attributes({mw_appPermissions(c_its_aid_SCR, ?)})))); // TODO In TITAN, this is the only way to get the unmatching in log
              if (match(p_inner_at_request, mw_innerEcRequest(p_its_id, -, mw_certificate_subject_attributes({mw_appPermissions(c_its_aid_SCR, ?)}))) == false) {
                // Send error message: Not enrolmentrequest
                f_http_build_inner_at_response(p_inner_at_request, badcontenttype, v_request_hash, -, -, v_aes_enc_key, v_ieee1609dot2_signed_and_encrypted_data);
                v_response := m_http_response(m_http_response_ok(m_http_message_body_binary(m_binary_body_ieee1609dot2_data(v_ieee1609dot2_signed_and_encrypted_data)), p_headers));
                // Set verdict
                p_result := -4;
              } else {
                // Send OK message
                log("f_verify_http_at_request_from_iut: Receive ", p_inner_at_request);
                if (p_force_response_code == ok) {
                  f_http_build_inner_at_response(p_inner_at_request, ok, v_request_hash, vc_eaPrivateKey, vc_eaWholeHash, v_aes_enc_key, v_ieee1609dot2_signed_and_encrypted_data);
                } else {
                  log("f_verify_http_at_request_from_iut: Succeed buit force error code ", p_force_response_code);
                  f_http_build_inner_at_response(p_inner_at_request, p_force_response_code, v_request_hash, -, -, v_aes_enc_key, v_ieee1609dot2_signed_and_encrypted_data);
                }
                v_response := m_http_response(m_http_response_ok(m_http_message_body_binary(m_binary_body_ieee1609dot2_data(v_ieee1609dot2_signed_and_encrypted_data)), p_headers));
                // Set verdict
                p_result := 0;
              }
            }
          }
       */ }

        p_response := valueof(v_response);
        log("<<< f_verify_http_at_request_from_iut: p_response: ", p_response);
        log("<<< f_verify_http_at_request_from_iut: p_result: ", p_result);
     } // End of function f_verify_http_at_request_from_iut
Yann Garcia's avatar
Yann Garcia committed
219
220
221
222
223
224
225
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
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281

      /**
       * @desc Await CA message using the default AT certificate
       */
      altstep a_await_cam_with_current_cert(
                                            in HashedId8 p_certificate_digest,
                                            in EtsiTs103097Certificate p_certificate
                                            ) runs on ItsPkiItss {
        [PICS_SEC_SHA256 == true] geoNetworkingPort.receive(
                                                            mw_geoNwInd(
                                                                        mw_geoNwSecPdu(
                                                                                       mw_etsiTs103097Data_signed(
                                                                                                                  mw_signedData(
                                                                                                                                sha256, 
                                                                                                                                mw_toBeSignedData(
                                                                                                                                                  mw_signedDataPayload,
                                                                                                                                                  mw_headerInfo_cam
                                                                                                                                                  ),
                                                                                                                                mw_signerIdentifier_certificate(
                                                                                                                                                                mw_etsiTs103097Certificate(
                                                                                                                                                                                           mw_issuerIdentifier_sha256AndDigest(
                                                                                                                                                                                                                               p_certificate.issuer.sha256AndDigest
                                                                                                                                                                                                                               ),
                                                                                                                                                                                           mw_toBeSignedCertificate_at(
                                                                                                                                                                                                                       -,
                                                                                                                                                                                                                       p_certificate.toBeSigned.verifyKeyIndicator
                                                                                                                                                                                                                       )
                                                                                                                                                                                           )
                                                                                                                                                                )
                                                                                                                                )
                                                                                                                  ), 
                                                                                       mw_geoNwShbPacket
                                                                                       ))) {
        }
        [PICS_SEC_SHA384 == true] geoNetworkingPort.receive(
                                                            mw_geoNwInd(
                                                                        mw_geoNwSecPdu(
                                                                                       mw_etsiTs103097Data_signed(
                                                                                                                  mw_signedData(
                                                                                                                                sha384, 
                                                                                                                                mw_toBeSignedData(
                                                                                                                                                  mw_signedDataPayload,
                                                                                                                                                  mw_headerInfo_cam
                                                                                                                                                  ),
                                                                                                                                mw_signerIdentifier_certificate(
                                                                                                                                                                mw_etsiTs103097Certificate(
                                                                                                                                                                                           mw_issuerIdentifier_sha384AndDigest(
                                                                                                                                                                                                                               p_certificate.issuer.sha384AndDigest
                                                                                                                                                                                                                               ),
                                                                                                                                                                                           mw_toBeSignedCertificate_at(
                                                                                                                                                                                                                       -,
                                                                                                                                                                                                                       p_certificate.toBeSigned.verifyKeyIndicator
                                                                                                                                                                                                                       )
                                                                                                                                                                                           )
                                                                                                                                                                )
                                                                                                                                )
                                                                                                                  ),
                                                                                       mw_geoNwShbPacket
                                                                                       ))) {
        }
      } // End of altstep a_await_cam_with_current_cert
      
    } // End of group itss_helpers
garciay's avatar
garciay committed
282

283
    group itss_enrolment_request {
Yann Garcia's avatar
Yann Garcia committed
284
      
garciay's avatar
garciay committed
285
286
287
      /**
       * @desc Check that IUT sends an enrolment request when triggered.
       * <pre>
288
       * Pics Selection: PICS_IUT_ITS_S_ROLE and PICS_SECPKI_ENROLMENT
garciay's avatar
garciay committed
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
       * 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>
       * 
304
       * @see       ETSI TS 103 525-2 v0.0.10 SECPKI_ITSS_ENR_01_BV
garciay's avatar
garciay committed
305
306
       * @reference ETSI TS 102 941 [2], clause 6.1.3
       */
307
      testcase TC_SECPKI_ITSS_ENR_01_BV() runs on ItsMtc /*system ItsPkiItssSystem*/ {
garciay's avatar
garciay committed
308
        // Local variables
Yann Garcia's avatar
Yann Garcia committed
309
        var ItsPkiItss v_itss;
Yann Garcia's avatar
Yann Garcia committed
310
        var ItsPkiHttp v_ea;
Yann Garcia's avatar
Yann Garcia committed
311
        
garciay's avatar
garciay committed
312
        // Test control
313
314
        if (not PICS_IUT_ITS_S_ROLE or not PICS_SECPKI_ENROLMENT) {
          log("*** " & testcasename() & ": PICS_IUT_ITS_S_ROLE and PICS_SECPKI_ENROLMENT required for executing the TC ***");
garciay's avatar
garciay committed
315
316
317
          setverdict(inconc);
          stop;
        }
318
        
garciay's avatar
garciay committed
319
        // Test component configuration
Yann Garcia's avatar
Yann Garcia committed
320
        f_cfMtcUp(v_itss, v_ea);
Yann Garcia's avatar
Yann Garcia committed
321
        
Yann Garcia's avatar
Yann Garcia committed
322
        // Start component
Yann Garcia's avatar
Yann Garcia committed
323
324
        v_itss.start(f_TC_SECPKI_ITSS_ENR_01_BV_itss());
        v_ea.start(f_TC_SECPKI_ITSS_ENR_01_BV_pki());
Yann Garcia's avatar
Yann Garcia committed
325
326
        
        // Synchronization
Yann Garcia's avatar
Yann Garcia committed
327
        f_serverSync2ClientsAndStop({c_prDone, c_tbDone});
garciay's avatar
garciay committed
328
        
Yann Garcia's avatar
Yann Garcia committed
329
        // Cleanup
Yann Garcia's avatar
Yann Garcia committed
330
        f_cfMtcDown(v_itss, v_ea);
garciay's avatar
garciay committed
331
        
332
      } // End of testcase TC_SECPKI_ITSS_ENR_01_BV
garciay's avatar
garciay committed
333
      
334
      group f_TC_SECPKI_ITSS_ENR_01_BV {
Yann Garcia's avatar
Yann Garcia committed
335
        
Yann Garcia's avatar
Yann Garcia committed
336
        function f_TC_SECPKI_ITSS_ENR_01_BV_itss() runs on ItsPkiItss /*system ItsPkiItssSystem*/ {
garciay's avatar
garciay committed
337
          // Local variables
Yann Garcia's avatar
Yann Garcia committed
338
339
          var HashedId8               v_certificate_digest;
          var EtsiTs103097Certificate v_certificate;
340
          
garciay's avatar
garciay committed
341
          // Test component configuration
Yann Garcia's avatar
Yann Garcia committed
342
          vc_hashedId8ToBeUsed := PX_IUT_DEFAULT_CERTIFICATE;
garciay's avatar
garciay committed
343
          f_cfUp_itss();
344
          
garciay's avatar
garciay committed
345
          // Test adapter configuration
346
          
garciay's avatar
garciay committed
347
          // Preamble
Yann Garcia's avatar
Yann Garcia committed
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
          f_readCertificate(vc_hashedId8ToBeUsed, v_certificate);
          f_getCertificateDigest(vc_hashedId8ToBeUsed, v_certificate_digest);
          // Wait for IUT certificate
          geoNetworkingPort.clear;
          tc_ac.start;
          alt {
            [] a_await_cam_with_current_cert(v_certificate_digest, v_certificate) {
              tc_ac.stop;
              
              f_sendUtTriggerEnrolmentRequestPrimitive();
              f_selfOrClientSyncAndVerdict(c_prDone, e_success);
            }
            [] geoNetworkingPort.receive(
                                         mw_geoNwInd(
                                                     mw_geoNwSecPdu(
                                                                    mw_etsiTs103097Data_signed
                                                                    ))) {
              repeat;
            }
            [] tc_ac.timeout {
              log("*** " & testcasename() & ": INCONC: Expected CA message not received ***");
              f_selfOrClientSyncAndVerdict(c_prDone, e_timeout);
            } 
          } // End of 'alt' statement
372
          
garciay's avatar
garciay committed
373
          // Test Body
Yann Garcia's avatar
Yann Garcia committed
374
          log("*** " & testcasename() & ": PASS: Enrolment trigger sent succesfully ***");
Yann Garcia's avatar
Yann Garcia committed
375
          f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
Yann Garcia's avatar
Yann Garcia committed
376
          
garciay's avatar
garciay committed
377
378
          // Postamble
          f_cfDown_itss();
379
        } // End of function f_TC_SECPKI_ITSS_ENR_01_BV_itss
Yann Garcia's avatar
Yann Garcia committed
380
        
Yann Garcia's avatar
Yann Garcia committed
381
        function f_TC_SECPKI_ITSS_ENR_01_BV_pki() runs on ItsPkiHttp /*system ItsPkiHttpSystem*/ {
Yann Garcia's avatar
Yann Garcia committed
382
          // Local variable
Yann Garcia's avatar
Yann Garcia committed
383
384
          var HeaderLines v_headers;
          var HttpMessage v_request;
385
386
          
          // Test component configuration
Yann Garcia's avatar
Yann Garcia committed
387
          f_cfHttpUp(PICS_TS_EA_CERTIFICATE_ID, PICS_TS_AA_CERTIFICATE_ID);
Yann Garcia's avatar
Yann Garcia committed
388
          
389
390
          // Test adapter configuration
          
391
          // Preamble
Yann Garcia's avatar
Yann Garcia committed
392
393
          f_init_default_headers_list(-, "inner_ec_response", v_headers);
          f_selfOrClientSyncAndVerdict(c_prDone, e_success);
Yann Garcia's avatar
Yann Garcia committed
394
395
          
          // Test Body
396
397
          tc_ac.start;
          alt {
Yann Garcia's avatar
Yann Garcia committed
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
            [] a_await_at_http_response_from_iut(
                                                 mw_http_request(
                                                                 mw_http_request_post(
                                                                                      PICS_HTTP_POST_URI_EC,
                                                                                      -,
                                                                                      mw_http_message_body_binary(
                                                                                                                  mw_binary_body_ieee1609dot2_data(
                                                                                                                                                   mw_enrolmentRequestMessage(
                                                                                                                                                                              mw_encryptedData(
                                                                                                                                                                                               -,
                                                                                                                                                                                               mw_SymmetricCiphertext_aes128ccm
                                                                                                                                                                                               )))))),
                                                 v_request
                                                 ) {
              var HttpMessage v_response;
              var integer v_result;
Yann Garcia's avatar
Yann Garcia committed
414
415
              var InnerEcRequest v_inner_ec_request;
              
Yann Garcia's avatar
Yann Garcia committed
416
              tc_ac.stop;
Yann Garcia's avatar
Yann Garcia committed
417
418

              // Verify IUT response
Yann Garcia's avatar
Yann Garcia committed
419
              f_verify_http_ec_request_from_iut(v_request.request, v_headers, v_inner_ec_request, v_response, v_result);
Yann Garcia's avatar
Yann Garcia committed
420
421
422
423
424
425
426
427
              // Send response
              if (isvalue(v_response)) {
                httpPort.send(v_response);
              }
              // Set verdict
              if (v_result == 0) {
                log("*** " & testcasename() & ": PASS: InnerEcRequest received ***");
                f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
Yann Garcia's avatar
Yann Garcia committed
428
              } else {
Yann Garcia's avatar
Yann Garcia committed
429
430
                log("*** " & testcasename() & ": FAIL: Failed to verify EA an EnrolmentRequestMessage ***");
                f_selfOrClientSyncAndVerdict(c_tbDone, e_error);
Yann Garcia's avatar
Yann Garcia committed
431
              }
432
433
434
            }
            [] tc_ac.timeout {
              log("*** " & testcasename() & ": INCONC: Expected message not received ***");
Yann Garcia's avatar
Yann Garcia committed
435
              f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);
436
437
438
439
            }
          } // End of 'alt' statement
          
          // Postamble
Yann Garcia's avatar
Yann Garcia committed
440
          f_cfHttpDown();
441
        } // End of function f_TC_SECPKI_ITSS_ENR_01_BV_pki
Yann Garcia's avatar
Yann Garcia committed
442
        
443
      } // End of group f_TC_SECPKI_ITSS_ENR_01_BV
444
      
garciay's avatar
garciay committed
445
446
447
448
449
450
      /**
       * @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>
451
       * Pics Selection: PICS_IUT_ITS_S_ROLE and PICS_SECPKI_ENROLMENT
garciay's avatar
garciay committed
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
       * 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>
       * 
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
       * @see       ETSI TS 103 525-2 v0.0.10 SECPKI_ITSS_ENR_02_BV
       * @reference ETSI TS 102 941, clause 6.1.3
       */
      testcase TC_SECPKI_ITSS_ENR_02_BV() runs on ItsMtc /*system ItsPkiItssSystem*/ {
        // Local variables
        var ItsPkiItss v_itss;
        var ItsPkiHttp v_ea;
        
        // Test control
        if (not PICS_IUT_ITS_S_ROLE or not PICS_SECPKI_ENROLMENT) {
          log("*** " & testcasename() & ": PICS_IUT_ITS_S_ROLE and PICS_SECPKI_ENROLMENT required for executing the TC ***");
          setverdict(inconc);
          stop;
        }
        
        // Test component configuration
Yann Garcia's avatar
Yann Garcia committed
489
490
491
492
493
        f_cfMtcUp(v_itss, v_ea);

        // Start component
        v_itss.start(f_TC_SECPKI_ITSS_ENR_01_BV_itss());
        v_ea.start(f_TC_SECPKI_ITSS_ENR_01_BV_pki());
494
495
        
        // Synchronization
Yann Garcia's avatar
Yann Garcia committed
496
        f_serverSync2ClientsAndStop({c_prDone, c_tbDone});
497
498
        
        // Cleanup
Yann Garcia's avatar
Yann Garcia committed
499
        f_cfMtcDown(v_itss, v_ea);
500
        
Yann Garcia's avatar
Yann Garcia committed
501
      } // End of testcase TC_SECPKI_ITSS_ENR_02_BV
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
      
      /**
       * @desc In presence of a valid EC, the enrolment request of the IUT is a rekeying enrolment 
               request with the itsId (contained in the InnerECRequest) and the SignerIdentifier 
               (contained in the outer EtsiTs1030971Data-Signed) both declared as digest containing 
               the HashedId8 of the EC and the outer signature computed using the current valid EC 
               private key corresponding to the verification public key.
       * <pre>
       * Pics Selection: PICS_IUT_ITS_S_ROLE and PICS_SECPKI_ENROLMENT and PICS_SECPKI_REENROLMENT
       * 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
       *                                     declared as digest containing the HashedId8 of the EC identifier
       *                 and containing signer
       *                     declared as digest containing the HashedId8 of the EC identifier 
       *                 and containing signature 
       *                     computed using the current valid EC private key corresponding to the verification public key
       *         }
       *     }
       * </pre>
       * 
       * @see       ETSI TS 103 525-2 v0.0.10 SECPKI_ITSS_ENR_03_BV
garciay's avatar
garciay committed
533
534
       * @reference ETSI TS 102 941, clause 6.1.3
       */
535
      testcase TC_SECPKI_ITSS_ENR_03_BV() runs on ItsMtc /*system ItsPkiItssSystem*/ {
536
537
538
        // Local variables
        var ItsPkiItss v_itss;
        var ItsPkiHttp v_ea;
garciay's avatar
garciay committed
539
        
540
        // Test control
541
542
        if (not PICS_IUT_ITS_S_ROLE or not PICS_SECPKI_ENROLMENT or not PICS_SECPKI_REENROLMENT) {
          log("*** " & testcasename() & ": PICS_IUT_ITS_S_ROLE and PICS_SECPKI_ENROLMENT and PICS_SECPKI_REENROLMENT required for executing the TC ***");
543
544
545
546
547
          setverdict(inconc);
          stop;
        }
        
        // Test component configuration
Yann Garcia's avatar
Yann Garcia committed
548
        f_cfMtcUp(v_itss, v_ea);
549
        
Yann Garcia's avatar
Yann Garcia committed
550
551
552
        // Start component
        v_itss.start(f_TC_SECPKI_ITSS_ENR_03_BV_itss());
        v_ea.start(f_TC_SECPKI_ITSS_ENR_03_BV_pki());
553
554
        
        // Synchronization
Yann Garcia's avatar
Yann Garcia committed
555
        f_serverSync2ClientsAndStop({c_prDone, c_tbDone});
556
557
        
        // Cleanup
Yann Garcia's avatar
Yann Garcia committed
558
        f_cfMtcDown(v_itss, v_ea);
559
        
Yann Garcia's avatar
Yann Garcia committed
560
      } // End of testcase TC_SECPKI_ITSS_ENR_03_BV
561
      
562
      group f_TC_SECPKI_ITSS_ENR_03_BV {
563
        
Yann Garcia's avatar
Yann Garcia committed
564
        function f_TC_SECPKI_ITSS_ENR_03_BV_itss() runs on ItsPkiItss /*system ItsPkiItssSystem*/ {
565
          // Local variables
Yann Garcia's avatar
Yann Garcia committed
566
567
          var HashedId8               v_certificate_digest;
          var EtsiTs103097Certificate v_certificate;
568
569
          
          // Test component configuration
Yann Garcia's avatar
Yann Garcia committed
570
          vc_hashedId8ToBeUsed := PX_IUT_DEFAULT_CERTIFICATE;
571
572
573
574
575
          f_cfUp_itss();
          
          // Test adapter configuration
          
          // Preamble
Yann Garcia's avatar
Yann Garcia committed
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
          f_readCertificate(vc_hashedId8ToBeUsed, v_certificate);
          f_getCertificateDigest(vc_hashedId8ToBeUsed, v_certificate_digest);
          // Wait for IUT certificate
          geoNetworkingPort.clear;
          tc_ac.start;
          alt {
            [] a_await_cam_with_current_cert(v_certificate_digest, v_certificate) {
              tc_ac.stop;
              
              f_sendUtTriggerEnrolmentRequestPrimitive();
              f_selfOrClientSyncAndVerdict(c_prDone, e_success);
            }
            [] geoNetworkingPort.receive(
                                         mw_geoNwInd(
                                                     mw_geoNwSecPdu(
                                                                    mw_etsiTs103097Data_signed
                                                                    ))) {
              repeat;
            }
            [] tc_ac.timeout {
              log("*** " & testcasename() & ": INCONC: Expected CA message not received ***");
              f_selfOrClientSyncAndVerdict(c_prDone, e_timeout);
            } 
          } // End of 'alt' statement
600
601
          
          // Test Body
Yann Garcia's avatar
Yann Garcia committed
602
603
          log("*** " & testcasename() & ": PASS: Enrolment trigger sent succesfully ***");
          f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
604
605
606
          
          // Postamble
          f_cfDown_itss();
607
        } // End of function f_TC_SECPKI_ITSS_ENR_03_BV_itss
608
        
Yann Garcia's avatar
Yann Garcia committed
609
        function f_TC_SECPKI_ITSS_ENR_03_BV_pki() runs on ItsPkiHttp /*system ItsPkiHttpSystem*/ {
610
          // Local variable
Yann Garcia's avatar
Yann Garcia committed
611
612
613
          var HeaderLines v_headers;
          var HttpMessage v_request;
          var Ieee1609Dot2Data v_ieee1609dot2_signed_and_encrypted_data;
614
615
          
          // Test component configuration
Yann Garcia's avatar
Yann Garcia committed
616
          f_cfHttpUp(PICS_TS_EA_CERTIFICATE_ID, PICS_TS_AA_CERTIFICATE_ID);
617
618
619
620
          
          // Test adapter configuration
          
          // Preamble
Yann Garcia's avatar
Yann Garcia committed
621
622
          f_init_default_headers_list(-, "inner_ec_response", v_headers);
          f_selfOrClientSyncAndVerdict(c_prDone, e_success);
623
624
625
626
          
          // Test Body
          tc_ac.start;
          alt {
Yann Garcia's avatar
Yann Garcia committed
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
            [] a_await_at_http_response_from_iut(
                                                 mw_http_request(
                                                                 mw_http_request_post(
                                                                                      PICS_HTTP_POST_URI_EC,
                                                                                      -,
                                                                                      mw_http_message_body_binary(
                                                                                                                  mw_binary_body_ieee1609dot2_data(
                                                                                                                                                   mw_enrolmentRequestMessage(
                                                                                                                                                                              mw_encryptedData(
                                                                                                                                                                                               -,
                                                                                                                                                                                               mw_SymmetricCiphertext_aes128ccm
                                                                                                                                                                                               )))))),
                                                 v_request
                                                 ) {
              var integer v_result;
              var InnerEcRequest v_inner_ec_request;
              var HttpMessage v_response;
644
              
Yann Garcia's avatar
Yann Garcia committed
645
646
647
              tc_ac.stop;

              // Verify IUT response
Yann Garcia's avatar
Yann Garcia committed
648
              f_verify_http_ec_request_from_iut(
Yann Garcia's avatar
Yann Garcia committed
649
650
651
652
653
654
655
656
657
658
659
660
661
                                             v_request.request, v_headers, v_inner_ec_request, v_response, v_result,
                                             PICS_ITS_S_CANONICAL_ID, // containing itsId declared as digest containing the HashedId8 of the EC identifier 

                                             m_signerIdentifier_digest(PICS_ITS_S_CANONICAL_ID)); // containing signer declared as digest containing the HashedId8 of the EC identifier

              // Send response
              if (isvalue(v_response)) {
                httpPort.send(v_response);
              }
              // Set verdict
              if (v_result == 0) {
                log("*** " & testcasename() & ": PASS: InnerEcRequest received ***");
                f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
662
              } else {
Yann Garcia's avatar
Yann Garcia committed
663
664
665
                log("*** " & testcasename() & ": FAIL: Failed to verify EA an EnrolmentRequestMessage ***");
                f_selfOrClientSyncAndVerdict(c_tbDone, e_error);
              }
666
667
668
            }
            [] tc_ac.timeout {
              log("*** " & testcasename() & ": INCONC: Expected message not received ***");
Yann Garcia's avatar
Yann Garcia committed
669
              f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);
670
671
672
673
674
            }
          } // End of 'alt' statement
          
          // Postamble
          f_cfHttpDown();
675
676
        } // End of function f_TC_SECPKI_ITSS_ENR_03_BV_pki
        
Yann Garcia's avatar
Yann Garcia committed
677
      } // End of group f_TC_SECPKI_ITSS_ENR_03_BV
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
      
      /**
       * @desc If the EC is revoked, the IUT returns to the state 'initialized'.
       * <pre>
       * Pics Selection: PICS_IUT_ITS_S_ROLE and PICS_SECPKI_ENROLMENT and PICS_SECPKI_CRL
       * Expected behaviour:
       *     ensure that {
       *         when {
       *             the IUT is informed about a revocation of its EC
       *         }
       *         then {
       *             the IUT returns to the "initialized" state
       *         }
       *     }
       * </pre>
       * 
       * @see       ETSI TS 103 525-2 v0.0.10 SECPKI_ITSS_ENR_04_BV
       * @reference ETSI TS 102 941, clause 6.1.3, 6.2.3.2.1
       */
      testcase TC_SECPKI_ITSS_ENR_04_BV() runs on ItsMtc /*system ItsPkiItssSystem*/ {
        // Local variables
        var Oct32      v_private_key;
        var Oct32      v_public_key_x;
        var Oct32      v_public_key_y;
        var Oct32      v_public_compressed_key;
        var integer    v_compressed_mode;
        var ItsPkiItss v_itss;
        var ItsPkiHttp v_ea;
        
        // Test control
        if (not PICS_IUT_ITS_S_ROLE or not PICS_SECPKI_ENROLMENT or not PICS_SECPKI_CRL) {
          log("*** " & testcasename() & ": PICS_IUT_ITS_S_ROLE and PICS_SECPKI_ENROLMENT and PICS_SECPKI_CRL required for executing the TC ***");
          setverdict(inconc);
          stop;
        }
        
        // Test component configuration
        
        // Synchronization
        
        // Cleanup
Yann Garcia's avatar
Yann Garcia committed
719
        setverdict(inconc);
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
        
      } // End of TC_SECPKI_ITSS_ENR_04_BV
      
      /**
       * @desc If the EC expires, the IUT returns to the state 'initialized'.
       * <pre>
       * Pics Selection: PICS_IUT_ITS_S_ROLE and PICS_SECPKI_ENROLMENT
       * Expected behaviour:
       *     ensure that {
       *         when {
       *             the EC of the IUT expires
       *         }
       *         then {
       *             the IUT returns to the "initialized" state
       *         }
       *     }
       * </pre>
       * 
       * @see       ETSI TS 103 525-2 v0.0.10 SECPKI_ITSS_ENR_05_BV
       * @reference ETSI TS 102 941, clause 6.1.3, 6.2.3.2.1
       */
      testcase TC_SECPKI_ITSS_ENR_05_BV() runs on ItsMtc /*system ItsPkiItssSystem*/ {
        // Local variables
        var Oct32      v_private_key;
        var Oct32      v_public_key_x;
        var Oct32      v_public_key_y;
        var Oct32      v_public_compressed_key;
        var integer    v_compressed_mode;
        var ItsPkiItss v_itss;
        var ItsPkiHttp v_ea;
        
        // Test control
        if (not PICS_IUT_ITS_S_ROLE or not PICS_SECPKI_ENROLMENT) {
          log("*** " & testcasename() & ": PICS_IUT_ITS_S_ROLE and PICS_SECPKI_ENROLMENT required for executing the TC ***");
          setverdict(inconc);
          stop;
        }
        
        // Test component configuration
        
        // Synchronization
        
        // Cleanup
Yann Garcia's avatar
Yann Garcia committed
763
        setverdict(inconc);
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
        
      } // End of TC_SECPKI_ITSS_ENR_05_BV
      
      /**
       * @desc For each enrolment request, the ITS-S shall generate a new verification key pair 
               corresponding to an approved signature algorithm as specified in TS 103 097.
       * <pre>
       * Pics Selection: PICS_IUT_ITS_S_ROLE and PICS_SECPKI_ENROLMENT and not PICS_SECPKI_REENROLMENT
       * Expected behaviour:
       *     ensure that {
       *         when {
       *             the IUT is requested to send multiple EnrolmentRequestMessage
       *         }
       *         then {
       *             each EnrolmentRequestMessage
       *                 contains a different and unique verification key pair within the InnerECRequest
       *         }
       *     }
       * </pre>
       * 
       * @see       ETSI TS 103 525-2 v0.0.10 SECPKI_ITSS_ENR_06_BV
       * @reference ETSI TS 102 941, clause 6.1.3
       */
      testcase TC_SECPKI_ITSS_ENR_06_BV() runs on ItsMtc /*system ItsPkiItssSystem*/ {
        // Local variables
        var ItsPkiItss v_itss;
        var ItsPkiHttp v_ea;
        
        // Test control
        if (not PICS_IUT_ITS_S_ROLE or not PICS_SECPKI_ENROLMENT or PICS_SECPKI_REENROLMENT) {
          log("*** " & testcasename() & ": PICS_IUT_ITS_S_ROLE and PICS_SECPKI_ENROLMENT and not PICS_SECPKI_REENROLMENT required for executing the TC ***");
          setverdict(inconc);
          stop;
        }
        
        // Test component configuration
        
Yann Garcia's avatar
Yann Garcia committed
801
802
        v_itss.start(f_TC_SECPKI_ITSS_ENR_06_BV_itss());
        v_ea.start(f_TC_SECPKI_ITSS_ENR_06_BV_pki());
803
804
        
        // Synchronization
Yann Garcia's avatar
Yann Garcia committed
805
        f_serverSync2ClientsAndStop({c_prDone, c_tbDone});
806
807
808
809
810
811
812
        
        // Cleanup
        
      } // End of TC_SECPKI_ITSS_ENR_06_BV
      
      group f_TC_SECPKI_ITSS_ENR_06_BV {
        
Yann Garcia's avatar
Yann Garcia committed
813
        function f_TC_SECPKI_ITSS_ENR_06_BV_itss() runs on ItsPkiItss /*system ItsPkiItssSystem*/ {
814
          // Local variables
Yann Garcia's avatar
Yann Garcia committed
815
816
          var HashedId8               v_certificate_digest;
          var EtsiTs103097Certificate v_certificate;
817
818
819
820
821
822
823
          
          // Test component configuration
          f_cfUp_itss();
          
          // Test adapter configuration
          
          // Preamble
Yann Garcia's avatar
Yann Garcia committed
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
          // First enrolment
          geoNetworkingPort.clear;
          tc_ac.start;
          alt {
            [] a_await_cam_with_current_cert(v_certificate_digest, v_certificate) {
              tc_ac.stop;
              
              f_sendUtTriggerEnrolmentRequestPrimitive();
              f_selfOrClientSyncAndVerdict(c_prDone, e_success);
            }
            [] geoNetworkingPort.receive(
                                         mw_geoNwInd(
                                                     mw_geoNwSecPdu(
                                                                    mw_etsiTs103097Data_signed
                                                                    ))) {
              repeat;
            }
            [] tc_ac.timeout {
              log("*** " & testcasename() & ": INCONC: Expected CA message not received ***");
              f_selfOrClientSyncAndVerdict(c_prDone, e_timeout);
            } 
          } // End of 'alt' statement
846
847
          
          // Test Body
Yann Garcia's avatar
Yann Garcia committed
848
849
850
851
852
853
          // Re-enrolment
          for (var integer v_i := 0; v_i < PX_RE_ENROLMENT_COUNTER; v_i := v_i + 1) {
            f_sendUtTriggerEnrolmentRequestPrimitive();
            f_sleep(PX_RE_ENROLMENT_DELAY);
          } // End of 'for' statement
          log("*** " & testcasename() & ": PASS: Enrolment trigger sent succesfully ***");
854
855
856
857
858
859
          f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
          
          // Postamble
          f_cfDown_itss();
        } // End of function f_TC_SECPKI_ITSS_ENR_06_BV_itss
        
Yann Garcia's avatar
Yann Garcia committed
860
        function f_TC_SECPKI_ITSS_ENR_06_BV_pki() runs on ItsPkiHttp /*system ItsPkiHttpSystem*/ {
861
          // Local variable
Yann Garcia's avatar
Yann Garcia committed
862
863
864
          var integer v_counter := 0;
          var HeaderLines v_headers;
          var HttpMessage v_request;
865
866
          var HttpMessage v_response;
          var InnerEcRequest v_inner_ec_request;
Yann Garcia's avatar
Yann Garcia committed
867
868
          var ListOfPublicVerificationKey v_generated_keys;
          var integer v_result;
869
870
871
872
873
874
875
          
          // Test component configuration
          f_cfHttpUp();
          
          // Test adapter configuration
          
          // Preamble
Yann Garcia's avatar
Yann Garcia committed
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
          f_init_default_headers_list(-, "inner_ec_response", v_headers);
          // Wait for the first enrolment response
          tc_ac.start;
          alt {
            [] a_await_at_http_response_from_iut(
                                                 mw_http_request(
                                                                 mw_http_request_post(
                                                                                      PICS_HTTP_POST_URI_EC,
                                                                                      -,
                                                                                      mw_http_message_body_binary(
                                                                                                                  mw_binary_body_ieee1609dot2_data(
                                                                                                                                                   mw_enrolmentRequestMessage(
                                                                                                                                                                              mw_encryptedData(
                                                                                                                                                                                               -,
                                                                                                                                                                                               mw_SymmetricCiphertext_aes128ccm
                                                                                                                                                                                               )))))),
                                                 v_request
                                                 ) {
              tc_ac.stop;

              // Verify IUT response
Yann Garcia's avatar
Yann Garcia committed
897
              f_verify_http_ec_request_from_iut(v_request.request, v_headers, v_inner_ec_request, v_response, v_result);
Yann Garcia's avatar
Yann Garcia committed
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
              // Send response
              if (isvalue(v_response)) {
                httpPort.send(v_response);
              }
              // Set verdict
              if (v_result == 0) {
                v_generated_keys[v_counter] := v_inner_ec_request.publicKeys.verificationKey;
                v_counter := v_counter + 1;
                f_selfOrClientSyncAndVerdictTestBody(c_prDone, e_success);
              } else {
                log("*** " & testcasename() & ": FAIL: Failed to verify EA an EnrolmentRequestMessage ***");
                f_selfOrClientSyncAndVerdict(c_prDone, e_error);
              }
            }
            [] tc_ac.timeout {
              log("*** " & testcasename() & ": INCONC: Expected message not received ***");
              f_selfOrClientSyncAndVerdict(c_prDone, e_timeout);
            }
          } // End of 'alt' statement
917
918
919
920
          
          // Test Body
          tc_ac.start;
          alt {
Yann Garcia's avatar
Yann Garcia committed
921
922
923
924
925
926
927
928
929
930
931
932
933
934
            [] a_await_at_http_response_from_iut(
                                                 mw_http_request(
                                                                 mw_http_request_post(
                                                                                      PICS_HTTP_POST_URI_EC,
                                                                                      -,
                                                                                      mw_http_message_body_binary(
                                                                                                                  mw_binary_body_ieee1609dot2_data(
                                                                                                                                                   mw_enrolmentRequestMessage(
                                                                                                                                                                              mw_encryptedData(
                                                                                                                                                                                               -,
                                                                                                                                                                                               mw_SymmetricCiphertext_aes128ccm
                                                                                                                                                                                               )))))),
                                                 v_request
                                                 ) {
935
              tc_ac.stop;
Yann Garcia's avatar
Yann Garcia committed
936
937

              // Verify IUT response
Yann Garcia's avatar
Yann Garcia committed
938
              f_verify_http_ec_request_from_iut(v_request.request, v_headers, v_inner_ec_request, v_response, v_result);
Yann Garcia's avatar
Yann Garcia committed
939
940
941
942
943
944
945
946
947
948
949
              // Send response
              if (isvalue(v_response)) {
                httpPort.send(v_response);
              }
              // Set verdict
              if (v_result == 0) {
                log("*** " & testcasename() & ": LOG: ", match(v_generated_keys, superset(v_inner_ec_request.publicKeys.verificationKey)), "***");
                if (match(v_generated_keys, superset(v_inner_ec_request.publicKeys.verificationKey))) {
                  v_generated_keys[v_counter] := v_inner_ec_request.publicKeys.verificationKey;
                  v_counter := v_counter + 1;
                  f_selfOrClientSyncAndVerdictTestBody(c_prDone, e_success);
950
                } else {
Yann Garcia's avatar
Yann Garcia committed
951
952
                  log("*** " & testcasename() & ": FAIL: Duplication of generated public keys ***");
                  f_selfOrClientSyncAndVerdict(c_prDone, e_error);
953
                }
Yann Garcia's avatar
Yann Garcia committed
954
955
956
957
              } else {
                log("*** " & testcasename() & ": FAIL: Failed to verify EA an EnrolmentRequestMessage ***");
                f_selfOrClientSyncAndVerdict(c_prDone, e_error);
              }
958
959
            }
            [] tc_ac.timeout {
Yann Garcia's avatar
Yann Garcia committed
960
961
962
963
964
965
966
              if (v_counter == PX_RE_ENROLMENT_COUNTER) {
                log("*** " & testcasename() & ": PASS: InnerEcRequest received with different key pairs ***");
                f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
              } else {
                log("*** " & testcasename() & ": INCONC: Expected message not received ***");
                f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);
              }
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
            }
          } // End of 'alt' statement
          
          // Postamble
          f_cfHttpDown();
        } // End of function f_TC_SECPKI_ITSS_ENR_06_BV_pki
        
      } // End of f_TC_SECPKI_ITSS_ENR_06_BV
      
      /**
       * @desc Within the InnerECRequest, the requestedSubjectAttributes shall not contain a certIssuePermissions field.
       * <pre>
       * Pics Selection: PICS_IUT_ITS_S_ROLE and PICS_SECPKI_ENROLMENT
       * 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 requestedSubjectAttributes
       *                                     not containing certIssuePermissions 
       *         }
       *     }
       * </pre>
       * 
       * @see       ETSI TS 103 525-2 v0.0.10 SECPKI_ITSS_ENR_07_BV
       * @reference ETSI TS 102 941, clause 6.2.3.2.1
       */
      testcase TC_SECPKI_ITSS_ENR_07_BV() runs on ItsMtc /*system ItsPkiItssSystem*/ {
For faster browsing, not all history is shown. View entire blame