ItsPki_TestCases.ttcn 267 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_itss(
                                                      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_itss: ", 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_itss: 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_itss: 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_itss: 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
                  log("f_verify_http_ec_request_from_iut_itss: Succeed buit force error code ", p_force_response_code);
Yann Garcia's avatar
Yann Garcia committed
136
                  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
        log("<<< f_verify_http_ec_request_from_iut_itss: p_response: ", p_response);
        log("<<< f_verify_http_ec_request_from_iut_itss: p_result: ", p_result);
      } // End of function f_verify_http_ec_request_from_iut_itss
Yann Garcia's avatar
Yann Garcia committed
150

Yann Garcia's avatar
Yann Garcia committed
151
152
153
154
155
156
157
158
159
      function f_verify_http_at_request_from_iut_itss(
                                                      in Request p_request,
                                                      in HeaderLines p_headers,
                                                      out InnerAtRequest p_inner_at_request,
                                                      out HttpMessage p_response,
                                                      out integer p_result,
                                                      in template octetstring p_its_id := PICS_ITS_S_CANONICAL_ID,
                                                      in AuthorizationResponseCode p_force_response_code := ok
                                                      ) runs on ItsPkiHttp {
Yann Garcia's avatar
Yann Garcia committed
160
161
162
163
164
        // 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
165
        var InnerAtResponse v_inner_at_response;
Yann Garcia's avatar
Yann Garcia committed
166
167
        var template (value) HttpMessage v_response;
        
Yann Garcia's avatar
Yann Garcia committed
168
        log(">>> f_verify_http_at_request_from_iut_itss:", p_request);
Yann Garcia's avatar
Yann Garcia committed
169
170
171
        
        p_result := 0;
        
Yann Garcia's avatar
Yann Garcia committed
172
        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
173
174
175
176
          // 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;
Yann Garcia's avatar
Yann Garcia committed
177
        } else {
Yann Garcia's avatar
Yann Garcia committed
178
          log("f_verify_http_at_request_from_iut_itss: match ", match(v_etsi_ts_102941_data.content, mw_authorizationRequest(mw_innerAtRequest))); // TODO In TITAN, this is the only way to get the unmatching in log
Yann Garcia's avatar
Yann Garcia committed
179
          if (match(v_etsi_ts_102941_data.content, mw_authorizationRequest(mw_innerAtRequest)) == false) {
Yann Garcia's avatar
Yann Garcia committed
180
            // Send error message
Yann Garcia's avatar
Yann Garcia committed
181
            f_http_build_authorization_response(p_inner_at_request, its_aa_cantparse, v_request_hash, -, -, v_aes_enc_key, v_inner_at_response, v_ieee1609dot2_signed_and_encrypted_data);
Yann Garcia's avatar
Yann Garcia committed
182
183
184
            // Set verdict
            p_result := -2;
          } else {
Yann Garcia's avatar
Yann Garcia committed
185
            // Verify signature of mw_innerATRequestSignedForPop
Yann Garcia's avatar
Yann Garcia committed
186
187
            if (f_verify_inner_at_request_signed_for_pop(v_etsi_ts_102941_data, p_inner_at_request) == false) {
              // Send error message
Yann Garcia's avatar
Yann Garcia committed
188
              f_http_build_authorization_response(p_inner_at_request, its_aa_cantparse, v_request_hash, -, -, v_aes_enc_key, v_inner_at_response, v_ieee1609dot2_signed_and_encrypted_data);
Yann Garcia's avatar
Yann Garcia committed
189
190
191
192
              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
193
              log("f_verify_http_at_request_from_iut_itss: match ", match(p_inner_at_request, mw_innerAtRequest/* (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
194
              if (match(p_inner_at_request, mw_innerAtRequest/* (p_its_id, -, mw_certificate_subject_attributes({mw_appPermissions(c_its_aid_SCR, ?)})) */) == false) {
Yann Garcia's avatar
Yann Garcia committed
195
                // Send error message: Not enrolmentrequest
Yann Garcia's avatar
Yann Garcia committed
196
                f_http_build_authorization_response(p_inner_at_request, its_aa_badcontenttype, v_request_hash, -, -, v_aes_enc_key, v_inner_at_response, v_ieee1609dot2_signed_and_encrypted_data);
Yann Garcia's avatar
Yann Garcia committed
197
198
199
200
201
                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
202
                log("f_verify_http_at_request_from_iut_itss: Receive ", p_inner_at_request);
Yann Garcia's avatar
Yann Garcia committed
203
                if (p_force_response_code == ok) {
Yann Garcia's avatar
Yann Garcia committed
204
                  f_http_build_authorization_response(p_inner_at_request, ok, v_request_hash, vc_eaPrivateKey, vc_eaWholeHash, v_aes_enc_key, v_inner_at_response, v_ieee1609dot2_signed_and_encrypted_data);
Yann Garcia's avatar
Yann Garcia committed
205
                } else {
Yann Garcia's avatar
Yann Garcia committed
206
                  log("f_verify_http_at_request_from_iut_itss: Succeed buit force error code ", p_force_response_code);
Yann Garcia's avatar
Yann Garcia committed
207
                  f_http_build_authorization_response(p_inner_at_request, p_force_response_code, v_request_hash, -, -, v_aes_enc_key, v_inner_at_response, v_ieee1609dot2_signed_and_encrypted_data);
Yann Garcia's avatar
Yann Garcia committed
208
209
210
211
212
213
214
                }
                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;
              }
            }
          }
Yann Garcia's avatar
Yann Garcia committed
215
        }
Yann Garcia's avatar
Yann Garcia committed
216
217

        p_response := valueof(v_response);
Yann Garcia's avatar
Yann Garcia committed
218
219
220
        log("<<< f_verify_http_at_request_from_iut_itss: p_response: ", p_response);
        log("<<< f_verify_http_at_request_from_iut_itss: p_result: ", p_result);
     } // End of function f_verify_http_at_request_from_iut_itss
Yann Garcia's avatar
Yann Garcia committed
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
282
283

      /**
       * @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
284

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

              // Verify IUT response
Yann Garcia's avatar
Yann Garcia committed
399
              f_verify_http_ec_request_from_iut_itss(v_request.request, v_headers, v_inner_ec_request, v_response, v_result);
Yann Garcia's avatar
Yann Garcia committed
400
401
402
403
404
405
406
407
              // 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
408
              } else {
Yann Garcia's avatar
Yann Garcia committed
409
410
                log("*** " & testcasename() & ": FAIL: Failed to verify EA an EnrolmentRequestMessage ***");
                f_selfOrClientSyncAndVerdict(c_tbDone, e_error);
Yann Garcia's avatar
Yann Garcia committed
411
              }
412
413
414
            }
            [] tc_ac.timeout {
              log("*** " & testcasename() & ": INCONC: Expected message not received ***");
Yann Garcia's avatar
Yann Garcia committed
415
              f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);
416
417
418
419
            }
          } // End of 'alt' statement
          
          // Postamble
Yann Garcia's avatar
Yann Garcia committed
420
          f_cfHttpDown();
421
        } // End of function f_TC_SECPKI_ITSS_ENR_01_BV_pki
Yann Garcia's avatar
Yann Garcia committed
422
        
423
      } // End of group f_TC_SECPKI_ITSS_ENR_01_BV
424
      
garciay's avatar
garciay committed
425
426
427
428
429
430
      /**
       * @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>
431
       * Pics Selection: PICS_IUT_ITS_S_ROLE and PICS_SECPKI_ENROLMENT
garciay's avatar
garciay committed
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
       * 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>
       * 
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
       * @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
469
470
471
472
473
        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());
474
475
        
        // Synchronization
Yann Garcia's avatar
Yann Garcia committed
476
        f_serverSync2ClientsAndStop({c_prDone, c_tbDone});
477
478
        
        // Cleanup
Yann Garcia's avatar
Yann Garcia committed
479
        f_cfMtcDown(v_itss, v_ea);
480
        
Yann Garcia's avatar
Yann Garcia committed
481
      } // End of testcase TC_SECPKI_ITSS_ENR_02_BV
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
      
      /**
       * @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
513
514
       * @reference ETSI TS 102 941, clause 6.1.3
       */
515
      testcase TC_SECPKI_ITSS_ENR_03_BV() runs on ItsMtc /*system ItsPkiItssSystem*/ {
516
517
518
        // Local variables
        var ItsPkiItss v_itss;
        var ItsPkiHttp v_ea;
garciay's avatar
garciay committed
519
        
520
        // Test control
521
522
        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 ***");
523
524
525
526
527
          setverdict(inconc);
          stop;
        }
        
        // Test component configuration
Yann Garcia's avatar
Yann Garcia committed
528
        f_cfMtcUp(v_itss, v_ea);
529
        
Yann Garcia's avatar
Yann Garcia committed
530
531
532
        // Start component
        v_itss.start(f_TC_SECPKI_ITSS_ENR_03_BV_itss());
        v_ea.start(f_TC_SECPKI_ITSS_ENR_03_BV_pki());
533
534
        
        // Synchronization
Yann Garcia's avatar
Yann Garcia committed
535
        f_serverSync2ClientsAndStop({c_prDone, c_tbDone});
536
537
        
        // Cleanup
Yann Garcia's avatar
Yann Garcia committed
538
        f_cfMtcDown(v_itss, v_ea);
539
        
Yann Garcia's avatar
Yann Garcia committed
540
      } // End of testcase TC_SECPKI_ITSS_ENR_03_BV
541
      
542
      group f_TC_SECPKI_ITSS_ENR_03_BV {
543
        
Yann Garcia's avatar
Yann Garcia committed
544
        function f_TC_SECPKI_ITSS_ENR_03_BV_itss() runs on ItsPkiItss /*system ItsPkiItssSystem*/ {
545
          // Local variables
Yann Garcia's avatar
Yann Garcia committed
546
547
          var HashedId8               v_certificate_digest;
          var EtsiTs103097Certificate v_certificate;
548
549
          
          // Test component configuration
Yann Garcia's avatar
Yann Garcia committed
550
          vc_hashedId8ToBeUsed := PX_IUT_DEFAULT_CERTIFICATE;
551
552
553
554
555
          f_cfUp_itss();
          
          // Test adapter configuration
          
          // Preamble
Yann Garcia's avatar
Yann Garcia committed
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
          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
580
581
          
          // Test Body
Yann Garcia's avatar
Yann Garcia committed
582
583
          log("*** " & testcasename() & ": PASS: Enrolment trigger sent succesfully ***");
          f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
584
585
586
          
          // Postamble
          f_cfDown_itss();
587
        } // End of function f_TC_SECPKI_ITSS_ENR_03_BV_itss
588
        
Yann Garcia's avatar
Yann Garcia committed
589
        function f_TC_SECPKI_ITSS_ENR_03_BV_pki() runs on ItsPkiHttp /*system ItsPkiHttpSystem*/ {
590
          // Local variable
Yann Garcia's avatar
Yann Garcia committed
591
592
593
          var HeaderLines v_headers;
          var HttpMessage v_request;
          var Ieee1609Dot2Data v_ieee1609dot2_signed_and_encrypted_data;
594
595
          
          // Test component configuration
Yann Garcia's avatar
Yann Garcia committed
596
          f_cfHttpUp(PICS_TS_EA_CERTIFICATE_ID, PICS_TS_AA_CERTIFICATE_ID);
597
598
599
600
          
          // Test adapter configuration
          
          // Preamble
Yann Garcia's avatar
Yann Garcia committed
601
602
          f_init_default_headers_list(-, "inner_ec_response", v_headers);
          f_selfOrClientSyncAndVerdict(c_prDone, e_success);
603
604
605
606
          
          // Test Body
          tc_ac.start;
          alt {
Yann Garcia's avatar
Yann Garcia committed
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
            [] 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;
624
              
Yann Garcia's avatar
Yann Garcia committed
625
626
627
              tc_ac.stop;

              // Verify IUT response
Yann Garcia's avatar
Yann Garcia committed
628
629
630
631
632
633
              f_verify_http_ec_request_from_iut_itss(
                                                     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
              
Yann Garcia's avatar
Yann Garcia committed
634
635
636
637
638
639
640
641
              // 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);
642
              } else {
Yann Garcia's avatar
Yann Garcia committed
643
644
645
                log("*** " & testcasename() & ": FAIL: Failed to verify EA an EnrolmentRequestMessage ***");
                f_selfOrClientSyncAndVerdict(c_tbDone, e_error);
              }
646
647
648
            }
            [] tc_ac.timeout {
              log("*** " & testcasename() & ": INCONC: Expected message not received ***");
Yann Garcia's avatar
Yann Garcia committed
649
              f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);
650
651
652
653
654
            }
          } // End of 'alt' statement
          
          // Postamble
          f_cfHttpDown();
655
656
        } // End of function f_TC_SECPKI_ITSS_ENR_03_BV_pki
        
Yann Garcia's avatar
Yann Garcia committed
657
      } // End of group f_TC_SECPKI_ITSS_ENR_03_BV
658
659
660
661
662
663
664
665
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
691
692
693
694
695
696
697
698
      
      /**
       * @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
699
        setverdict(inconc);
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
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
        
      } // 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
743
        setverdict(inconc);
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
        
      } // 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
781
782
        v_itss.start(f_TC_SECPKI_ITSS_ENR_06_BV_itss());
        v_ea.start(f_TC_SECPKI_ITSS_ENR_06_BV_pki());
783
784
        
        // Synchronization
Yann Garcia's avatar
Yann Garcia committed
785
        f_serverSync2ClientsAndStop({c_prDone, c_tbDone});
786
787
788
789
790
791
792
        
        // Cleanup
        
      } // End of TC_SECPKI_ITSS_ENR_06_BV
      
      group f_TC_SECPKI_ITSS_ENR_06_BV {
        
Yann Garcia's avatar
Yann Garcia committed
793
        function f_TC_SECPKI_ITSS_ENR_06_BV_itss() runs on ItsPkiItss /*system ItsPkiItssSystem*/ {
794
          // Local variables
Yann Garcia's avatar
Yann Garcia committed
795
796
          var HashedId8               v_certificate_digest;
          var EtsiTs103097Certificate v_certificate;
797
798
799
800
801
802
803
          
          // Test component configuration
          f_cfUp_itss();
          
          // Test adapter configuration
          
          // Preamble
Yann Garcia's avatar
Yann Garcia committed
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
          // 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
826
827
          
          // Test Body
Yann Garcia's avatar
Yann Garcia committed
828
829
830
831
832
833
          // 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 ***");
834
835
836
837
838
839
          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
840
        function f_TC_SECPKI_ITSS_ENR_06_BV_pki() runs on ItsPkiHttp /*system ItsPkiHttpSystem*/ {
841
          // Local variable
Yann Garcia's avatar
Yann Garcia committed
842
843
844
          var integer v_counter := 0;
          var HeaderLines v_headers;
          var HttpMessage v_request;
845
846
          var HttpMessage v_response;
          var InnerEcRequest v_inner_ec_request;
Yann Garcia's avatar
Yann Garcia committed
847
848
          var ListOfPublicVerificationKey v_generated_keys;
          var integer v_result;
849
850
851
852
853
854
855
          
          // Test component configuration
          f_cfHttpUp();
          
          // Test adapter configuration
          
          // Preamble
Yann Garcia's avatar
Yann Garcia committed
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
          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
877
              f_verify_http_ec_request_from_iut_itss(v_request.request, v_headers, v_inner_ec_request, v_response, v_result);
Yann Garcia's avatar
Yann Garcia committed
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
              // 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
897
898
899
900
          
          // Test Body
          tc_ac.start;
          alt {
Yann Garcia's avatar
Yann Garcia committed
901
902
903
904
905
906
907
908
909
910
911
912
913
914
            [] 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
                                                 ) {
915
              tc_ac.stop;
Yann Garcia's avatar
Yann Garcia committed
916
917

              // Verify IUT response
Yann Garcia's avatar
Yann Garcia committed
918
              f_verify_http_ec_request_from_iut_itss(v_request.request, v_headers, v_inner_ec_request, v_response, v_result);
Yann Garcia's avatar
Yann Garcia committed
919
920
921
922
923
924
925
926
927
928
929
              // 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);
930
                } else {
Yann Garcia's avatar
Yann Garcia committed
931
932
                  log("*** " & testcasename() & ": FAIL: Duplication of generated public keys ***");
                  f_selfOrClientSyncAndVerdict(c_prDone, e_error);
933
                }
Yann Garcia's avatar
Yann Garcia committed
934
935
936
937
              } else {
                log("*** " & testcasename() & ": FAIL: Failed to verify EA an EnrolmentRequestMessage ***");
                f_selfOrClientSyncAndVerdict(c_prDone, e_error);
              }
938
939
            }
            [] tc_ac.timeout {
Yann Garcia's avatar
Yann Garcia committed
940
941
942
943
944
945
946
              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);
              }
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
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*/ {
        // 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
        
        if (f_generate_key_pair_nistp256(v_private_key, v_public_key_x, v_public_key_y, v_public_compressed_key, v_compressed_mode) == false) {
          log("*** " & testcasename() & ": FAIL: Failed to setup InnerEcRequest message ***")
For faster browsing, not all history is shown. View entire blame