ItsPki_TestCases.ttcn 515 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;
YannGarcia's avatar
YannGarcia committed
29
  import from EtsiTs102941TrustLists language "ASN.1:1997" all;
garciay's avatar
garciay committed
30
31
32
  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
33
  
garciay's avatar
garciay committed
34
  // LibItsCommon
Yann Garcia's avatar
Yann Garcia committed
35
  import from LibItsCommon_TypesAndValues all;
garciay's avatar
garciay committed
36
  import from LibItsCommon_Functions all;
Yann Garcia's avatar
Yann Garcia committed
37
  import from LibItsCommon_TypesAndValues all;
garciay's avatar
garciay committed
38
  import from LibItsCommon_ASN1_NamedNumbers all;
Yann Garcia's avatar
Yann Garcia committed
39
40
  
  // LibItsGeoNetworking
41
  import from LibItsGeoNetworking_TypesAndValues all;
Yann Garcia's avatar
Yann Garcia committed
42
43
44
  import from LibItsGeoNetworking_Functions all;
  import from LibItsGeoNetworking_Templates all;
  import from LibItsGeoNetworking_Pics all;
45
  import from LibItsGeoNetworking_TestSystem all;
Yann Garcia's avatar
Yann Garcia committed
46
  
garciay's avatar
garciay committed
47
48
49
50
51
52
53
  // 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
54
  
garciay's avatar
garciay committed
55
56
57
58
59
  // 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
60
  import from LibItsHttp_TestSystem all;
garciay's avatar
garciay committed
61
  
garciay's avatar
garciay committed
62
  // LibItsPki
Yann Garcia's avatar
Yann Garcia committed
63
  import from LibItsPki_TypesAndValues all;
garciay's avatar
garciay committed
64
  import from LibItsPki_Templates all;
Yann Garcia's avatar
Yann Garcia committed
65
  import from LibItsPki_Functions all;
garciay's avatar
garciay committed
66
  import from LibItsPki_TestSystem all;
garciay's avatar
garciay committed
67
  import from LibItsPki_Pics all;
68
  import from LibItsPki_Pixits all;
Yann Garcia's avatar
Yann Garcia committed
69
70
71

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

Yann Garcia's avatar
Yann Garcia committed
80
81
82
83
84
85
86
87
88
89
      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
90
91
92
93
94
        // 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
95
        var InnerEcResponse v_inner_ec_response;
Yann Garcia's avatar
Yann Garcia committed
96
97
        var template (value) HttpMessage v_response;
        
Yann Garcia's avatar
Yann Garcia committed
98
        log(">>> f_verify_http_ec_request_from_iut_itss: ", p_request);
Yann Garcia's avatar
Yann Garcia committed
99
100
101
        
        p_result := 0;
        
Yann Garcia's avatar
Yann Garcia committed
102
        if (f_verify_pki_request_message(vc_eaPrivateEncKey, vc_eaWholeHash/*salt*/, ''O, p_request.body.binary_body.ieee1609dot2_data, true, v_request_hash, v_etsi_ts_102941_data, v_aes_enc_key) == false) { // Cannot decrypt the message
Yann Garcia's avatar
Yann Garcia committed
103
          // Send error message
YannGarcia's avatar
YannGarcia committed
104
          v_response := m_http_response(m_http_response_ko_no_body(p_headers, 400, "Bad request")); // Initialize v_reponse with an error message
Yann Garcia's avatar
Yann Garcia committed
105
106
107
          // Set verdict
          p_result := -1;
        } else {
Yann Garcia's avatar
Yann Garcia committed
108
          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
109
110
          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
111
            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
112
113
114
115
116
117
            // 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
118
              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
119
120
121
122
              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
123
124
              log("f_verify_http_ec_request_from_iut_itss: matching: ", 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
              if (match(p_inner_ec_request, mw_innerEcRequest(p_its_id, -, mw_certificate_subject_attributes_optional_assuranceLevel({mw_appPermissions(c_its_aid_SCR, ?)}, -, -, omit))) == false) {
Yann Garcia's avatar
Yann Garcia committed
125
                // Send error message: Not enrolmentrequest
Yann Garcia's avatar
Yann Garcia committed
126
                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
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 {
Yann Garcia's avatar
Yann Garcia committed
131
                // TODO Check ValidityPeriod
Yann Garcia's avatar
Yann Garcia committed
132
                // Send OK message
Yann Garcia's avatar
Yann Garcia committed
133
                log("f_verify_http_ec_request_from_iut_itss: Receive ", p_inner_ec_request);
Yann Garcia's avatar
Yann Garcia committed
134
                if (p_force_response_code == ok) {
Yann Garcia's avatar
Yann Garcia committed
135
                  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
136
                } else {
Yann Garcia's avatar
Yann Garcia committed
137
                  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
138
                  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
139
140
141
142
143
144
145
146
147
148
                }
                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
149
150
151
        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
152

Yann Garcia's avatar
Yann Garcia committed
153
154
155
156
157
158
159
160
161
      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
162
163
164
165
166
        // 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
167
        var InnerAtResponse v_inner_at_response;
Yann Garcia's avatar
Yann Garcia committed
168
169
        var template (value) HttpMessage v_response;
        
Yann Garcia's avatar
Yann Garcia committed
170
        log(">>> f_verify_http_at_request_from_iut_itss:", p_request);
Yann Garcia's avatar
Yann Garcia committed
171
172
173
        
        p_result := 0;
        
Yann Garcia's avatar
Yann Garcia committed
174
        if (f_verify_pki_request_message(vc_eaPrivateEncKey, vc_eaWholeHash/*salt*/, ''O, p_request.body.binary_body.ieee1609dot2_data, true, v_request_hash, v_etsi_ts_102941_data, v_aes_enc_key) == false) { // Cannot decrypt the message
Yann Garcia's avatar
Yann Garcia committed
175
          // Send error message
YannGarcia's avatar
YannGarcia committed
176
          v_response := m_http_response(m_http_response_ko_no_body(p_headers, 400, "Bad request")); // Initialize v_reponse with an error message
Yann Garcia's avatar
Yann Garcia committed
177
178
          // Set verdict
          p_result := -1;
Yann Garcia's avatar
Yann Garcia committed
179
        } else {
Yann Garcia's avatar
Yann Garcia committed
180
          log("f_verify_http_at_request_from_iut_itss: matching: ", 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
181
          if (match(v_etsi_ts_102941_data.content, mw_authorizationRequest(mw_innerAtRequest)) == false) {
Yann Garcia's avatar
Yann Garcia committed
182
            // Send error message
Yann Garcia's avatar
Yann Garcia committed
183
            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
184
185
186
            // Set verdict
            p_result := -2;
          } else {
Yann Garcia's avatar
Yann Garcia committed
187
            // Verify signature of mw_innerATRequestSignedForPop
Yann Garcia's avatar
Yann Garcia committed
188
189
            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
190
              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
191
192
193
194
              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
195
196
              log("f_verify_http_at_request_from_iut_itss: match ", match(p_inner_at_request, mw_innerAtRequest(mw_publicKeys, -, mw_shared_at_request, mw_ec_signature))); // TODO In TITAN, this is the only way to get the unmatching in log
              if (match(p_inner_at_request, mw_innerAtRequest(mw_publicKeys, -, mw_shared_at_request, mw_ec_signature)) == false) { // TODO To be refined
Yann Garcia's avatar
Yann Garcia committed
197
                // Send error message: No enrolment request
Yann Garcia's avatar
Yann Garcia committed
198
                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
199
200
201
202
                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 {
Yann Garcia's avatar
Yann Garcia committed
203
204
205
206
207
208
209
210
211
                var PublicVerificationKey v_verification_tag;
                var octetstring v_encoded_tag;
                var octetstring v_key_tag;
                
                // Build the tag
                v_encoded_tag := bit2oct(encvalue(p_inner_at_request.publicKeys.verificationKey));
                if (ispresent(p_inner_at_request.publicKeys.encryptionKey)) {
                  v_encoded_tag := v_encoded_tag & bit2oct(encvalue(p_inner_at_request.publicKeys.encryptionKey));
                }
Yann Garcia's avatar
Yann Garcia committed
212
                // Verify HMAC-SHA256
Yann Garcia's avatar
Yann Garcia committed
213
                log("f_verify_http_at_request_from_iut_itss: v_encoded_tag= ", v_encoded_tag);
Yann Garcia's avatar
Yann Garcia committed
214
215
216
217
218
219
220
221
                v_key_tag := substr(
                                    fx_hmac_sha256( // TODO Rename and use a wrapper function
                                                   p_inner_at_request.hmacKey,
                                                   v_encoded_tag
                                                    ),
                                    0,
                                    16); // Leftmost 128 bits of the HMAC-SHA256 tag computed previously
                log("f_verify_http_at_request_from_iut_itss: v_key_tag: ", v_key_tag);
Yann Garcia's avatar
Yann Garcia committed
222
                log("f_verify_http_at_request_from_iut_itss: keyTag= ", p_inner_at_request.sharedAtRequest.keyTag);
Yann Garcia's avatar
Yann Garcia committed
223
224
225
226
227
228
229
230
                log("f_verify_http_at_request_from_iut_itss: matching: ", match(p_inner_at_request.sharedAtRequest.keyTag, v_key_tag));
                if (match(p_inner_at_request.sharedAtRequest.keyTag, v_key_tag) == false) {
                  // Send error message: No enrolment request
                  f_http_build_authorization_response(p_inner_at_request, its_aa_keysdontmatch, v_request_hash, -, -, v_aes_enc_key, v_inner_at_response, 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 := -5;
                  
Yann Garcia's avatar
Yann Garcia committed
231
                } else {
Yann Garcia's avatar
Yann Garcia committed
232
233
234
235
236
237
238
239
                  // Send OK message
                  log("f_verify_http_at_request_from_iut_itss: Receive ", p_inner_at_request);
                  if (p_force_response_code == ok) {
                    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);
                  } else {
                    log("f_verify_http_at_request_from_iut_itss: Succeed built force error code ", p_force_response_code);
                    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
240
                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));
Yann Garcia's avatar
Yann Garcia committed
241
242
243
                  // Set verdict
                  p_result := 0;
                }
Yann Garcia's avatar
Yann Garcia committed
244
245
246
              }
            }
          }
Yann Garcia's avatar
Yann Garcia committed
247
        }
Yann Garcia's avatar
Yann Garcia committed
248
249

        p_response := valueof(v_response);
Yann Garcia's avatar
Yann Garcia committed
250
251
252
        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
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
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315

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

317
    group itss_enrolment_request {
Yann Garcia's avatar
Yann Garcia committed
318
      
garciay's avatar
garciay committed
319
320
321
      /**
       * @desc Check that IUT sends an enrolment request when triggered.
       * <pre>
322
       * Pics Selection: PICS_IUT_ITS_S_ROLE and PICS_SECPKI_ENROLMENT
garciay's avatar
garciay committed
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
       * 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>
       * 
YannGarcia's avatar
YannGarcia committed
338
       * @see       ETSI TS 103 525-2 SECPKI_ITSS_ENR_01_BV
garciay's avatar
garciay committed
339
340
       * @reference ETSI TS 102 941 [2], clause 6.1.3
       */
YannGarcia's avatar
YannGarcia committed
341
      testcase TC_SECPKI_ITSS_ENR_01_BV() runs on ItsMtc system ItsPkiHttpSystem {
garciay's avatar
garciay committed
342
        // Local variables
Yann Garcia's avatar
Yann Garcia committed
343
        var ItsPkiItss v_itss;
Yann Garcia's avatar
Yann Garcia committed
344
        var ItsPkiHttp v_ea;
Yann Garcia's avatar
Yann Garcia committed
345
        
garciay's avatar
garciay committed
346
        // Test control
347
348
        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
349
350
351
          setverdict(inconc);
          stop;
        }
352
        
garciay's avatar
garciay committed
353
        // Test component configuration
354
        f_cfMtcUp01(v_itss, v_ea);
Yann Garcia's avatar
Yann Garcia committed
355
        
YannGarcia's avatar
YannGarcia committed
356
        // Start components
Yann Garcia's avatar
Yann Garcia committed
357
358
        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
359
360
        
        // Synchronization
Yann Garcia's avatar
Yann Garcia committed
361
        f_serverSync2ClientsAndStop({c_prDone, c_tbDone});
garciay's avatar
garciay committed
362
        
Yann Garcia's avatar
Yann Garcia committed
363
        // Cleanup
364
        f_cfMtcDown01(v_itss, v_ea);
garciay's avatar
garciay committed
365
        
366
      } // End of testcase TC_SECPKI_ITSS_ENR_01_BV
garciay's avatar
garciay committed
367
      
368
      group f_TC_SECPKI_ITSS_ENR_01_BV {
Yann Garcia's avatar
Yann Garcia committed
369
        
YannGarcia's avatar
YannGarcia committed
370
        function f_TC_SECPKI_ITSS_ENR_01_BV_itss() runs on ItsPkiItss system ItsPkiHttpSystem {
garciay's avatar
garciay committed
371
          // Local variables
Yann Garcia's avatar
Yann Garcia committed
372
373
          var HashedId8               v_certificate_digest;
          var EtsiTs103097Certificate v_certificate;
374
          
garciay's avatar
garciay committed
375
          // Test component configuration
Yann Garcia's avatar
Yann Garcia committed
376
          vc_hashedId8ToBeUsed := PX_IUT_DEFAULT_CERTIFICATE;
garciay's avatar
garciay committed
377
          f_cfUp_itss();
378
          
garciay's avatar
garciay committed
379
          // Test adapter configuration
380
          
garciay's avatar
garciay committed
381
          // Preamble
Yann Garcia's avatar
Yann Garcia committed
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
          if (true) {
            // Initial state: No CAM shall be emitted
            f_selfOrClientSyncAndVerdict(c_prDone, e_success);
          } else {
            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_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);
407
              }
Yann Garcia's avatar
Yann Garcia committed
408
409
            } // End of 'alt' statement
          }
410
          
garciay's avatar
garciay committed
411
          // Test Body
Yann Garcia's avatar
Yann Garcia committed
412
          f_sendUtTriggerEnrolmentRequestPrimitive();
Yann Garcia's avatar
Yann Garcia committed
413
          log("*** " & testcasename() & ": PASS: Enrolment trigger sent succesfully ***");
Yann Garcia's avatar
Yann Garcia committed
414
          f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
Yann Garcia's avatar
Yann Garcia committed
415
          
garciay's avatar
garciay committed
416
417
          // Postamble
          f_cfDown_itss();
418
        } // End of function f_TC_SECPKI_ITSS_ENR_01_BV_itss
Yann Garcia's avatar
Yann Garcia committed
419
        
YannGarcia's avatar
YannGarcia committed
420
        function f_TC_SECPKI_ITSS_ENR_01_BV_pki() runs on ItsPkiHttp system ItsPkiHttpSystem {
Yann Garcia's avatar
Yann Garcia committed
421
          // Local variable
Yann Garcia's avatar
Yann Garcia committed
422
423
          var HeaderLines v_headers;
          var HttpMessage v_request;
424
425
          
          // Test component configuration
Yann Garcia's avatar
Yann Garcia committed
426
          f_cfHttpUp(PICS_TS_EA_CERTIFICATE_ID, PICS_TS_AA_CERTIFICATE_ID);
Yann Garcia's avatar
Yann Garcia committed
427
          
428
429
          // Test adapter configuration
          
430
          // Preamble
Yann Garcia's avatar
Yann Garcia committed
431
432
          f_init_default_headers_list(-, "inner_ec_response", v_headers);
          f_selfOrClientSyncAndVerdict(c_prDone, e_success);
Yann Garcia's avatar
Yann Garcia committed
433
434
          
          // Test Body
435
436
          tc_ac.start;
          alt {
Yann Garcia's avatar
Yann Garcia committed
437
438
439
440
441
442
443
444
445
            [] 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(
Yann Garcia's avatar
Yann Garcia committed
446
                                                                                                                                                                                               { *, mw_recipientInfo_certRecipInfo(mw_pKRecipientInfo(vc_eaHashedId8)), * },
Yann Garcia's avatar
Yann Garcia committed
447
448
449
450
451
452
                                                                                                                                                                                               mw_SymmetricCiphertext_aes128ccm
                                                                                                                                                                                               )))))),
                                                 v_request
                                                 ) {
              var HttpMessage v_response;
              var integer v_result;
Yann Garcia's avatar
Yann Garcia committed
453
454
              var InnerEcRequest v_inner_ec_request;
              
Yann Garcia's avatar
Yann Garcia committed
455
              tc_ac.stop;
Yann Garcia's avatar
Yann Garcia committed
456
457

              // Verify IUT response
Yann Garcia's avatar
Yann Garcia committed
458
              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
459
460
461
              // Send response
              if (isvalue(v_response)) {
                httpPort.send(v_response);
Yann Garcia's avatar
Yann Garcia committed
462
              } // TODO Send HTTP error 500
Yann Garcia's avatar
Yann Garcia committed
463
464
465
466
              // Set verdict
              if (v_result == 0) {
                log("*** " & testcasename() & ": PASS: InnerEcRequest received ***");
                f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
Yann Garcia's avatar
Yann Garcia committed
467
              } else {
Yann Garcia's avatar
Yann Garcia committed
468
469
                log("*** " & testcasename() & ": FAIL: Failed to verify EA an EnrolmentRequestMessage ***");
                f_selfOrClientSyncAndVerdict(c_tbDone, e_error);
Yann Garcia's avatar
Yann Garcia committed
470
              }
471
472
473
            }
            [] tc_ac.timeout {
              log("*** " & testcasename() & ": INCONC: Expected message not received ***");
Yann Garcia's avatar
Yann Garcia committed
474
              f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);
475
476
477
478
            }
          } // End of 'alt' statement
          
          // Postamble
Yann Garcia's avatar
Yann Garcia committed
479
          f_cfHttpDown();
480
        } // End of function f_TC_SECPKI_ITSS_ENR_01_BV_pki
Yann Garcia's avatar
Yann Garcia committed
481
        
482
      } // End of group f_TC_SECPKI_ITSS_ENR_01_BV
483
      
garciay's avatar
garciay committed
484
485
486
487
488
489
      /**
       * @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>
490
       * Pics Selection: PICS_IUT_ITS_S_ROLE and PICS_SECPKI_ENROLMENT
garciay's avatar
garciay committed
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
       * 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>
       * 
YannGarcia's avatar
YannGarcia committed
512
       * @see       ETSI TS 103 525-2 SECPKI_ITSS_ENR_02_BV
513
514
       * @reference ETSI TS 102 941, clause 6.1.3
       */
YannGarcia's avatar
YannGarcia committed
515
      testcase TC_SECPKI_ITSS_ENR_02_BV() runs on ItsMtc system ItsPkiHttpSystem {
516
517
518
519
520
521
522
523
524
525
526
527
        // 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
528
        f_cfMtcUp01(v_itss, v_ea);
Yann Garcia's avatar
Yann Garcia committed
529

YannGarcia's avatar
YannGarcia committed
530
        // Start components
Yann Garcia's avatar
Yann Garcia committed
531
532
        v_itss.start(f_TC_SECPKI_ITSS_ENR_01_BV_itss());
        v_ea.start(f_TC_SECPKI_ITSS_ENR_01_BV_pki());
533
534
        
        // Synchronization
Yann Garcia's avatar
Yann Garcia committed
535
        f_serverSync2ClientsAndStop({c_prDone, c_tbDone});
536
537
        
        // Cleanup
538
        f_cfMtcDown01(v_itss, v_ea);
539
        
Yann Garcia's avatar
Yann Garcia committed
540
      } // End of testcase TC_SECPKI_ITSS_ENR_02_BV
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
      
      /**
       * @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>
       * 
YannGarcia's avatar
YannGarcia committed
571
       * @see       ETSI TS 103 525-2 SECPKI_ITSS_ENR_03_BV
garciay's avatar
garciay committed
572
573
       * @reference ETSI TS 102 941, clause 6.1.3
       */
YannGarcia's avatar
YannGarcia committed
574
      testcase TC_SECPKI_ITSS_ENR_03_BV() runs on ItsMtc system ItsPkiHttpSystem {
575
576
577
        // Local variables
        var ItsPkiItss v_itss;
        var ItsPkiHttp v_ea;
garciay's avatar
garciay committed
578
        
579
        // Test control
580
581
        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 ***");
582
583
584
585
586
          setverdict(inconc);
          stop;
        }
        
        // Test component configuration
587
        f_cfMtcUp01(v_itss, v_ea);
588
        
YannGarcia's avatar
YannGarcia committed
589
        // Start components
Yann Garcia's avatar
Yann Garcia committed
590
591
        v_itss.start(f_TC_SECPKI_ITSS_ENR_03_BV_itss());
        v_ea.start(f_TC_SECPKI_ITSS_ENR_03_BV_pki());
592
593
        
        // Synchronization
Yann Garcia's avatar
Yann Garcia committed
594
        f_serverSync2ClientsAndStop({c_prDone, c_tbDone});
595
596
        
        // Cleanup
597
        f_cfMtcDown01(v_itss, v_ea);
598
        
Yann Garcia's avatar
Yann Garcia committed
599
      } // End of testcase TC_SECPKI_ITSS_ENR_03_BV
600
      
601
      group f_TC_SECPKI_ITSS_ENR_03_BV {
602
        
YannGarcia's avatar
YannGarcia committed
603
        function f_TC_SECPKI_ITSS_ENR_03_BV_itss() runs on ItsPkiItss system ItsPkiHttpSystem {
604
          // Local variables
Yann Garcia's avatar
Yann Garcia committed
605
606
          var HashedId8               v_certificate_digest;
          var EtsiTs103097Certificate v_certificate;
607
608
          
          // Test component configuration
Yann Garcia's avatar
Yann Garcia committed
609
          vc_hashedId8ToBeUsed := PX_IUT_DEFAULT_CERTIFICATE;
610
611
612
613
614
          f_cfUp_itss();
          
          // Test adapter configuration
          
          // Preamble
Yann Garcia's avatar
Yann Garcia committed
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
          if (true) {
            // Initial state: No CAM shall be emitted
            f_selfOrClientSyncAndVerdict(c_prDone, e_success);
          } else {
            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_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
          }
643
644
          
          // Test Body
Yann Garcia's avatar
Yann Garcia committed
645
          f_sendUtTriggerEnrolmentRequestPrimitive();
Yann Garcia's avatar
Yann Garcia committed
646
647
          log("*** " & testcasename() & ": PASS: Enrolment trigger sent succesfully ***");
          f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
648
649
650
          
          // Postamble
          f_cfDown_itss();
651
        } // End of function f_TC_SECPKI_ITSS_ENR_03_BV_itss
652
        
YannGarcia's avatar
YannGarcia committed
653
        function f_TC_SECPKI_ITSS_ENR_03_BV_pki() runs on ItsPkiHttp system ItsPkiHttpSystem {
654
          // Local variable
Yann Garcia's avatar
Yann Garcia committed
655
656
657
          var HeaderLines v_headers;
          var HttpMessage v_request;
          var Ieee1609Dot2Data v_ieee1609dot2_signed_and_encrypted_data;
658
659
          
          // Test component configuration
Yann Garcia's avatar
Yann Garcia committed
660
          f_cfHttpUp(PICS_TS_EA_CERTIFICATE_ID, PICS_TS_AA_CERTIFICATE_ID);
661
662
663
664
          
          // Test adapter configuration
          
          // Preamble
Yann Garcia's avatar
Yann Garcia committed
665
666
          f_init_default_headers_list(-, "inner_ec_response", v_headers);
          f_selfOrClientSyncAndVerdict(c_prDone, e_success);
667
668
669
670
          
          // Test Body
          tc_ac.start;
          alt {
Yann Garcia's avatar
Yann Garcia committed
671
672
673
674
675
676
677
678
679
            [] 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(
Yann Garcia's avatar
Yann Garcia committed
680
                                                                                                                                                                                               { *, mw_recipientInfo_certRecipInfo(mw_pKRecipientInfo(vc_eaHashedId8)), * },
Yann Garcia's avatar
Yann Garcia committed
681
682
683
684
685
686
687
                                                                                                                                                                                               mw_SymmetricCiphertext_aes128ccm
                                                                                                                                                                                               )))))),
                                                 v_request
                                                 ) {
              var integer v_result;
              var InnerEcRequest v_inner_ec_request;
              var HttpMessage v_response;
688
              
Yann Garcia's avatar
Yann Garcia committed
689
690
691
              tc_ac.stop;

              // Verify IUT response
Yann Garcia's avatar
Yann Garcia committed
692
693
              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
694
695
696
697
                                                     PX_EC_HASHED_ID8, // containing itsId declared as digest containing the HashedId8 of the EC identifier
                                                     m_signerIdentifier_digest(PX_EC_HASHED_ID8 // containing signer declared as digest containing the HashedId8 of the EC identifier
                                                                               )
                                                     );
Yann Garcia's avatar
Yann Garcia committed
698
              
Yann Garcia's avatar
Yann Garcia committed
699
700
701
702
703
704
705
706
              // 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);
707
              } else {
Yann Garcia's avatar
Yann Garcia committed
708
709
710
                log("*** " & testcasename() & ": FAIL: Failed to verify EA an EnrolmentRequestMessage ***");
                f_selfOrClientSyncAndVerdict(c_tbDone, e_error);
              }
711
712
713
            }
            [] tc_ac.timeout {
              log("*** " & testcasename() & ": INCONC: Expected message not received ***");
Yann Garcia's avatar
Yann Garcia committed
714
              f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);
715
716
717
718
719
            }
          } // End of 'alt' statement
          
          // Postamble
          f_cfHttpDown();
720
721
        } // End of function f_TC_SECPKI_ITSS_ENR_03_BV_pki
        
Yann Garcia's avatar
Yann Garcia committed
722
      } // End of group f_TC_SECPKI_ITSS_ENR_03_BV
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
      
      /**
       * @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>
       * 
YannGarcia's avatar
YannGarcia committed
739
       * @see       ETSI TS 103 525-2 SECPKI_ITSS_ENR_04_BV
740
741
       * @reference ETSI TS 102 941, clause 6.1.3, 6.2.3.2.1
       */
YannGarcia's avatar
YannGarcia committed
742
      testcase TC_SECPKI_ITSS_ENR_04_BV() runs on ItsMtc system ItsPkiHttpSystem {
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
        // 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
764
        setverdict(inconc);
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
        
      } // 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>
       * 
YannGarcia's avatar
YannGarcia committed
783
       * @see       ETSI TS 103 525-2 SECPKI_ITSS_ENR_05_BV
784
785
       * @reference ETSI TS 102 941, clause 6.1.3, 6.2.3.2.1
       */
YannGarcia's avatar
YannGarcia committed
786
      testcase TC_SECPKI_ITSS_ENR_05_BV() runs on ItsMtc system ItsPkiHttpSystem {
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
        // 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
808
        setverdict(inconc);
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
        
      } // 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>
       * 
YannGarcia's avatar
YannGarcia committed
829
       * @see       ETSI TS 103 525-2 SECPKI_ITSS_ENR_06_BV
830
831
       * @reference ETSI TS 102 941, clause 6.1.3
       */
YannGarcia's avatar
YannGarcia committed
832
      testcase TC_SECPKI_ITSS_ENR_06_BV() runs on ItsMtc system ItsPkiHttpSystem {
833
834
835
836
837
838
839
840
841
842
843
844
        // 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
YannGarcia's avatar
YannGarcia committed
845
        f_cfMtcUp01(v_itss, v_ea);
846
        
YannGarcia's avatar
YannGarcia committed
847
        // Start components
Yann Garcia's avatar
Yann Garcia committed
848
849
        v_itss.start(f_TC_SECPKI_ITSS_ENR_06_BV_itss());
        v_ea.start(f_TC_SECPKI_ITSS_ENR_06_BV_pki());
850
851
        
        // Synchronization
Yann Garcia's avatar
Yann Garcia committed
852
        f_serverSync2ClientsAndStop({c_prDone, c_tbDone});
853
854
855
856
857
858
859
        
        // Cleanup
        
      } // End of TC_SECPKI_ITSS_ENR_06_BV
      
      group f_TC_SECPKI_ITSS_ENR_06_BV {
        
YannGarcia's avatar
YannGarcia committed
860
        function f_TC_SECPKI_ITSS_ENR_06_BV_itss() runs on ItsPkiItss system ItsPkiHttpSystem {
861
          // Local variables
Yann Garcia's avatar
Yann Garcia committed
862
863
          var HashedId8               v_certificate_digest;
          var EtsiTs103097Certificate v_certificate;
864
865
866
867
868
869
870
          
          // Test component configuration
          f_cfUp_itss();
          
          // Test adapter configuration
          
          // Preamble
Yann Garcia's avatar
Yann Garcia committed
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
          // 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
893
894
          
          // Test Body
Yann Garcia's avatar
Yann Garcia committed
895
896
897
898
899
900
          // 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 ***");
901
902
903
904
905
906
          f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
          
          // Postamble
          f_cfDown_itss();
        } // End of function f_TC_SECPKI_ITSS_ENR_06_BV_itss
        
YannGarcia's avatar
YannGarcia committed
907
        function f_TC_SECPKI_ITSS_ENR_06_BV_pki() runs on ItsPkiHttp system ItsPkiHttpSystem {
908
          // Local variable
Yann Garcia's avatar
Yann Garcia committed
909
910
911
          var integer v_counter := 0;
          var HeaderLines v_headers;
          var HttpMessage v_request;
912
913
          var HttpMessage v_response;
          var InnerEcRequest v_inner_ec_request;
Yann Garcia's avatar
Yann Garcia committed
914
915
          var ListOfPublicVerificationKey v_generated_keys;
          var integer v_result;
916
917
918
919
920
921
922
          
          // Test component configuration
          f_cfHttpUp();
          
          // Test adapter configuration
          
          // Preamble
Yann Garcia's avatar
Yann Garcia committed
923
924
925
926
927
928
929
930
931
932
933
934
935
          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(
Yann Garcia's avatar
Yann Garcia committed
936
                                                                                                                                                                                               { *, mw_recipientInfo_certRecipInfo(mw_pKRecipientInfo(vc_eaHashedId8)), * },
Yann Garcia's avatar
Yann Garcia committed
937
938
939
940
941
942
943
                                                                                                                                                                                               mw_SymmetricCiphertext_aes128ccm
                                                                                                                                                                                               )))))),
                                                 v_request
                                                 ) {
              tc_ac.stop;

              // Verify IUT response
Yann Garcia's avatar
Yann Garcia committed
944
              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
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
              // 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
964
965
966
967
          
          // Test Body
          tc_ac.start;
          alt {
Yann Garcia's avatar
Yann Garcia committed
968
969
970
971
972
973
974
975
976
            [] 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(
Yann Garcia's avatar
Yann Garcia committed
977
                                                                                                                                                                                               { *, mw_recipientInfo_certRecipInfo(mw_pKRecipientInfo(vc_eaHashedId8)), * },
Yann Garcia's avatar
Yann Garcia committed
978
979
980
981
                                                                                                                                                                                               mw_SymmetricCiphertext_aes128ccm
                                                                                                                                                                                               )))))),
                                                 v_request
                                                 ) {
982
              tc_ac.stop;
Yann Garcia's avatar
Yann Garcia committed
983
984

              // Verify IUT response
Yann Garcia's avatar
Yann Garcia committed
985
              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
986
987
988
989
990
991
992
993
994
995
996
              // 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);
997
                } else {
Yann Garcia's avatar
Yann Garcia committed
998
999
                  log("*** " & testcasename() & ": FAIL: Duplication of generated public keys ***");
                  f_selfOrClientSyncAndVerdict(c_prDone, e_error);
1000
                }
Yann Garcia's avatar
Yann Garcia committed
1001
1002
1003
1004
              } else {
                log("*** " & testcasename() & ": FAIL: Failed to verify EA an EnrolmentRequestMessage ***");
                f_selfOrClientSyncAndVerdict(c_prDone, e_error);
              }
1005
1006
            }
            [] tc_ac.timeout {
Yann Garcia's avatar
Yann Garcia committed
1007
1008
1009
1010
1011
1012
1013
              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);
              }
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
            }
          } // 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>
       * 
YannGarcia's avatar
YannGarcia committed
1044
       * @see       ETSI TS 103 525-2 SECPKI_ITSS_ENR_07_BV
1045
1046
       * @reference ETSI TS 102 941, clause 6.2.3.2.1
       */
YannGarcia's avatar
YannGarcia committed
1047
      testcase TC_SECPKI_ITSS_ENR_07_BV() runs on ItsMtc system ItsPkiHttpSystem {
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
        // 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
YannGarcia's avatar
YannGarcia committed
1065
        f_cfMtcUp01(v_itss, v_ea);
1066
        
YannGarcia's avatar
YannGarcia committed
1067
        // Start components
Yann Garcia's avatar
Yann Garcia committed
1068
1069
        v_itss.start(f_TC_SECPKI_ITSS_ENR_01_BV_itss());
        v_ea.start(f_TC_SECPKI_ITSS_ENR_01_BV_pki());
1070
1071
        
        // Synchronization
Yann Garcia's avatar
Yann Garcia committed
1072
        f_serverSync2ClientsAndStop({c_prDone, c_tbDone});
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
        
        // Cleanup
        
      } // End of TC_SECPKI_ITSS_ENR_07_BV
      
      /**
       * @desc In the headerInfo of the tbsData of the InnerECRequestSignedForPOP all other components 
       *       of the component tbsdata.headerInfo except generationTime and psid are not used and absent. 
       *       The psid shall be set to "secured certificate request" as assigned in ETSI TS 102 965 and 
       *       the generationTime shall be present.
       * <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 tbsData
       *                                 containing headerInfo
       *                                     containing psid
       *                                         indicating AID_CERT_REQ
       *                                     and containing generationTime
       *                                     and not containing any other component of tbsdata.headerInfo
       *         }
       *     }
       * </pre>
       * 
YannGarcia's avatar
YannGarcia committed
1105
       * @see       ETSI TS 103 525-2 SECPKI_ITSS_ENR_08_BV
1106
1107
       * @reference ETSI TS 102 941, clause 6.2.3.2.1
       */
YannGarcia's avatar
YannGarcia committed
1108
      testcase TC_SECPKI_ITSS_ENR_08_BV() runs on ItsMtc system ItsPkiHttpSystem {
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
        // 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
YannGarcia's avatar
YannGarcia committed
1121
        f_cfMtcUp01(v_itss, v_ea);
1122
        
YannGarcia's avatar
YannGarcia committed
1123
        // Start components
Yann Garcia's avatar
Yann Garcia committed
1124
1125
        v_itss.start(f_TC_SECPKI_ITSS_ENR_01_BV_itss());
        v_ea.start(f_TC_SECPKI_ITSS_ENR_01_BV_pki());
1126
1127
        
        // Synchronization
Yann Garcia's avatar
Yann Garcia committed
1128
        f_serverSync2ClientsAndStop({c_prDone, c_tbDone});
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
        
        // Cleanup
        
      } // End of TC_SECPKI_ITSS_ENR_08_BV
      
      /**
       * @desc In the headerInfo of the tbsData of the outer EtsiTs102941Data-Signed all other components 
       *       of the component tbsdata.headerInfo except generationTime and psid are not used and absent. 
       *       The psid shall be set to "secured certificate request" as assigned in ETSI TS 102 965 and 
       *       the generationTime shall be present.
       * <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 tbsData
       *                                 containing headerInfo
       *                                     containing psid
       *                                         indicating AID_CERT_REQ
       *                                     and containing generationTime
       *                                     and not containing any other component of tbsdata.headerInfo
       *         }
       *     }
       * </pre>
       * 
YannGarcia's avatar
YannGarcia committed
1161
       * @see       ETSI TS 103 525-2 SECPKI_ITSS_ENR_09_BV
1162
1163
       * @reference ETSI TS 102 941, clause 6.2.3.2.1
       */
YannGarcia's avatar
YannGarcia committed
1164
      testcase TC_SECPKI_ITSS_ENR_09_BV() runs on ItsMtc system ItsPkiHttpSystem {
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
        // 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
YannGarcia's avatar
YannGarcia committed
1177
        f_cfMtcUp01(v_itss, v_ea);
1178
        
YannGarcia's avatar
YannGarcia committed
1179
        // Start components
Yann Garcia's avatar
Yann Garcia committed
1180
1181
        v_itss.start(f_TC_SECPKI_ITSS_ENR_01_BV_itss());
        v_ea.start(f_TC_SECPKI_ITSS_ENR_01_BV_pki());
1182
1183
        
        // Synchronization
Yann Garcia's avatar
Yann Garcia committed
1184
        f_serverSync2ClientsAndStop({c_prDone, c_tbDone});
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
        
        // Cleanup
        
      } // End of TC_SECPKI_ITSS_ENR_09_BV
      
      /**
       * @desc The EtsiTs103097Data-Encrypted containing the correctly encrypted ciphertext and a recipients 
       *       component containing one instance of RecipientInfo of choice certRecipInfo containing the 
       *       hashedId8 of the EA certificate in recipientId and the encrypted data encryption key in encKey. 
       *       The data encryption key is encrypted using the public key found in the EA certificate referenced 
       *       in the recipientId.
       * <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 recipients
       *                     containing exactly one instance of RecipientInfo of choice certRecipInfo
       *                         containing recipientId
       *                             indicating the hashedId8
       *                                 referencing to the EA certificate
       *                                     containing encryptionKey (KEY)
       *                      and containing encKey
       *                          being a symmetric key (SYMKEY) encrypted using the key KEY
       *                  containing ciphertext
       *                      which is encrypted using the symmetric key SYMKEY contained in encKey
       *         }
       *     }
       * </pre>
       * 
YannGarcia's avatar
YannGarcia committed
1219
       * @see       ETSI TS 103 525-2 SECPKI_ITSS_ENR_10_BV
1220
1221
       * @reference ETSI TS 102 941, clause 6.2.3.2.1
       */
YannGarcia's avatar
YannGarcia committed
1222
      testcase TC_SECPKI_ITSS_ENR_10_BV() runs on ItsMtc system ItsPkiHttpSystem {
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
        // 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
YannGarcia's avatar
YannGarcia committed
1235
        f_cfMtcUp01(v_itss, v_ea);
1236
        
YannGarcia's avatar
YannGarcia committed
1237
        // Start components
Yann Garcia's avatar
Yann Garcia committed
1238
1239
        v_itss.start(f_TC_SECPKI_ITSS_ENR_01_BV_itss());
        v_ea.start(f_TC_SECPKI_ITSS_ENR_01_BV_pki());
1240
1241
        
        // Synchronization
Yann Garcia's avatar
Yann Garcia committed
1242
        f_serverSync2ClientsAndStop({c_prDone, c_tbDone});
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
        
        // Cleanup
        
      } // End of TC_SECPKI_ITSS_ENR_10_BV
      
      /**
       * @desc In the inner signed data structure (InnerECRequestSignedForPOP), the signature is computed 
       *       on InnerECRequest with the private key corresponding to the new verificationKey to prove 
       *       possession of the generated verification key pair.
       * <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 tbsData
       *                                 containing InnerEcRequest
       *                                     containing verificationKey (VKEY)
       *                              containing signature
       *                                  computed on InnerECRequest
       *                                      using the private key corresponding to VKEY
       *                                          contained in InnerECRequest
       *         }
       *     }
       * </pre>
       * 
YannGarcia's avatar
YannGarcia committed
1275
       * @see       ETSI TS 103 525-2 SECPKI_ITSS_ENR_11_BV
1276
1277
       * @reference ETSI TS 102 941, clause 6.2.3.2.1
       */
YannGarcia's avatar
YannGarcia committed
1278
      testcase TC_SECPKI_ITSS_ENR_11_BV() runs on ItsMtc system ItsPkiHttpSystem {
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
        // 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
YannGarcia's avatar
YannGarcia committed
1291
        f_cfMtcUp01(v_itss, v_ea);
1292
        
YannGarcia's avatar
YannGarcia committed
1293
        // Start components
Yann Garcia's avatar
Yann Garcia committed
1294
1295
        v_itss.start(f_TC_SECPKI_ITSS_ENR_01_BV_itss());
        v_ea.start(f_TC_SECPKI_ITSS_ENR_01_BV_pki());
1296
1297
        
        // Synchronization
Yann Garcia's avatar
Yann Garcia committed
1298
        f_serverSync2ClientsAndStop({c_prDone, c_tbDone});
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
        
        // Cleanup
        
      } // End of TC_SECPKI_ITSS_ENR_11_BV
      
      /**
       * @desc Check that signing of Enrolment Request message is permitted by the EC certificate.
       * <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 signer
       *                         containing digest
       *                             indicating HashedId8 of the EC certificate
       *                                 containing appPermissions
       *                                     containing an item of type PsidSsp
       *                                         containing psid
       *                                             indicating AID_CERT_REQ
       *                                         and containing ssp
       *                                             containing opaque[0] (version) 
       *                                                 indicating 1
       *                                             containing opaque[1] (value) 
       *                                                 indicating "Enrolment Request" (bit 1) set to 1
       *         }
       *     }
       * </pre>
       * 
YannGarcia's avatar
YannGarcia committed
1332
       * @see       ETSI TS 103 525-2 SECPKI_ITSS_ENR_12_BV
1333
1334
       * @reference ETSI TS 102 941, clause 6.1.3, 6.2.3.2.1
       */
YannGarcia's avatar
YannGarcia committed
1335
      testcase TC_SECPKI_ITSS_ENR_12_BV() runs on ItsMtc system ItsPkiHttpSystem {
1336
1337
1338
1339
1340
        // Local variables
        var ItsPkiItss v_itss;
        var ItsPkiHttp v_ea;
        
        // Test control
Yann Garcia's avatar
Yann Garcia committed
1341
1342
        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 ***");
1343
1344
1345
1346
1347
          setverdict(inconc);
          stop;
        }
        
        // Test component configuration
YannGarcia's avatar
YannGarcia committed
1348
        f_cfMtcUp01(v_itss, v_ea);
1349
        
YannGarcia's avatar
YannGarcia committed
1350
        // Start components
Yann Garcia's avatar
Yann Garcia committed
1351
1352
        v_itss.start(f_TC_SECPKI_ITSS_ENR_03_BV_itss());
        v_ea.start(f_TC_SECPKI_ITSS_ENR_03_BV_pki());
1353
1354
        
        // Synchronization
Yann Garcia's avatar
Yann Garcia committed
1355
        f_serverSync2ClientsAndStop({c_prDone, c_tbDone});
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
        
        // Cleanup
        
      } // End of TC_SECPKI_ITSS_ENR_12_BV
      
    } // End of group itss_enrolment_request
    
    group itss_enrolment_response {
      
      /**
       * @desc If an enrolment request fails, 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 IUT is requested to send an EnrolmentRequestMessage
       *             and the EnrolmentResponseMessage is received
       *                 containing a responseCode different than 0
       *         }
       *         then {
       *             the IUT returns to the "initialized" state
       *         }
       *     }
       * </pre>
       * 
YannGarcia's avatar
YannGarcia committed
1382
       * @see       ETSI TS 103 525-2 SECPKI_ITSS_ENR_RECV_01_BV
1383
1384
       * @reference ETSI TS 102 941, clause 6.1.3, 6.2.3.2.1
       */
YannGarcia's avatar
YannGarcia committed
1385
      testcase TC_SECPKI_ITSS_ENR_RECV_01_BV() runs on ItsMtc system ItsPkiHttpSystem {