ItsSecurity_TestCases.ttcn3 1.4 MB
Newer Older
garciay's avatar
garciay committed
7001
7002
7003
7004
7005
7006
7007
7008
7009
7010
7011
7012
7013
7014
7015
7016
7017
7018
7019
7020
7021
7022
7023
7024
7025
7026
7027
7028
7029
7030
7031
7032
7033
7034
                    }
                    
                    // Test component configuration
                    f_cf01Up();
                    
                    // Test adapter configuration
                    
                    // Preamble
                    f_prNeighbour();
                    f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                    
                    // Test Body
                    log("*** " & testcasename() & ": INFO: Request and waiting for the message containing certificate chain  ***");
                    tc_ac.start;
                    if (not f_askAndWaitForCertificateChain(v_chain, f_generateDefaultCam())) {
                        log("*** " & testcasename() & ": INCONC: Expected message not received ***");
                        f_selfOrClientSyncAndVerdictPreamble(c_tbDone, e_timeout);
                    }
                    tc_ac.stop;
                    if (lengthof(v_chain) < 2) {
                        log("*** " & testcasename() & ": FAIL: Certificate chain is too short ***");
                        f_selfOrClientSyncAndVerdictPreamble(c_tbDone, e_error);
                    }
                    // Verified automatically on decoding
                    if (lengthof(v_chain[lengthof(v_chain) - 2].subject_info.subject_name) > 32 ) {
                        log("*** " & testcasename() & ": FAIL: Subject name of the AA certificate is too long ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                    }
                    log("*** " & testcasename() & ": PASS: Subject name of the AA certificate is good ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                    
                    // Postamble
                    f_poNeighbour();
                    f_cf01Down();
garciay's avatar
garciay committed
7035
                } // End of testcase TC_SEC_ITSS_SND_CERT_AA_02_01_BV
garciay's avatar
garciay committed
7036
7037
                
                /**
garciay's avatar
garciay committed
7038
                 * @desc Check that signer_info type of AA certificates is set to 'certificate_digest_with_sha256'
garciay's avatar
garciay committed
7039
7040
7041
7042
7043
7044
7045
7046
7047
7048
7049
                 * <pre>
                 * Pics Selection: PICS_GN_SECURITY
                 * Config Id: CF01
                 * with {
                 *   the IUT being in the 'authorized' state
                 *   the IUT being requested to include certificate chain in the next CAM
                 * } ensure that {
                 *    when {
                 *     the IUT is requested to send a CAM
                 *   } then {
                 *     the IUT sends a SecuredMessage
garciay's avatar
garciay committed
7050
                 *       containing header_fields['signer_info'].signer
garciay's avatar
garciay committed
7051
                 *         containing type
garciay's avatar
garciay committed
7052
                 *           indicating 'certificate_chain'
garciay's avatar
garciay committed
7053
7054
                 *         containing certificates[last-1]
                 *           containing signer_info
garciay's avatar
garciay committed
7055
7056
7057
7058
7059
                 *             containing type
                 *               indicating 'certificate_digest_with_sha256'
                 *   }
                 * }
                 * </pre>
garciay's avatar
garciay committed
7060
                 * @see         ETSI TS 103 096-2 v1.3.2 TP_SEC_ITSS_SND_CERT_AA_03_01_BV
garciay's avatar
garciay committed
7061
                 * @reference   ETSI TS 103 097 [1], clause 7.4.4
garciay's avatar
garciay committed
7062
                 */
garciay's avatar
garciay committed
7063
                testcase TC_SEC_ITSS_SND_CERT_AA_03_01_BV() runs on ItsGeoNetworking system ItsSecSystem {
garciay's avatar
garciay committed
7064
7065
7066
7067
7068
7069
7070
7071
7072
7073
7074
7075
7076
7077
7078
7079
7080
7081
7082
7083
7084
7085
7086
7087
7088
7089
7090
7091
7092
7093
7094
7095
7096
7097
7098
7099
7100
7101
7102
7103
7104
                    var CertificateChain         v_chain;
                    var Certificate              v_aa_cert;
                    
                    // Test control
                    if (not(PICS_GN_SECURITY)) {
                        log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY' required for executing the TC ***");
                        stop;
                    }
                    
                    // Test component configuration
                    f_cf01Up();
                    
                    // Test adapter configuration
                    
                    // Preamble
                    f_prNeighbour();
                    f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                    
                    // Test Body
                    log("*** " & testcasename() & ": INFO: Request and waiting for the message containing certificate chain  ***");
                    tc_ac.start;
                    if (not f_askAndWaitForCertificateChain(v_chain, f_generateDefaultCam())) {
                        log("*** " & testcasename() & ": INCONC: Expected message not received ***");
                        f_selfOrClientSyncAndVerdictPreamble(c_tbDone, e_timeout);
                    }
                    tc_ac.stop;
                    if (lengthof(v_chain) < 2) {
                        log("*** " & testcasename() & ": FAIL: Certificate chain is too short ***");
                        f_selfOrClientSyncAndVerdictPreamble(c_tbDone, e_error);
                    }
                    v_aa_cert := v_chain[lengthof(v_chain) - 2];
                    if (not match(v_aa_cert, mw_aa_certificate(mw_signerInfo_digest))) {
                        log("*** " & testcasename() & ": FAIL: AA certificate not signed by digest ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                    }
                    log("*** " & testcasename() & ": PASS: AA certificate is signed by digest ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                    
                    // Postamble
                    f_poNeighbour();
                    f_cf01Down();
garciay's avatar
garciay committed
7105
7106
                } // End of testcase TC_SEC_ITSS_SND_CERT_AA_03_01_BV
                
garciay's avatar
garciay committed
7107
7108
7109
7110
7111
7112
7113
7114
7115
7116
7117
7118
7119
7120
7121
7122
7123
7124
7125
7126
7127
7128
7129
7130
7131
7132
7133
7134
7135
7136
                /**
                 * @desc Check that AA certificate is signed by Root CA or other authority
                 * @remark There is no clear specification that AA cert shall be signed by the Root CA only
                 * <pre>
                 * Pics Selection: PICS_GN_SECURITY
                 * Config Id: CF01
                 * with {
                 *   the IUT being in the 'authorized' state
                 *   the IUT being requested to include certificate in the next CAM
                 * } ensure that {
                 *    when {
                 *     the IUT is requested to send a CAM
                 *   } then {
                 *     the IUT sends a SecuredMessage
                 *       containing header_fields['signer_info'].signer
                 *         containing type
                 *           indicating 'certificate_chain'
                 *         containing certificates
                 *           containing certificates[last-1]
                 *             containing signer_info
                 *               containing type
                 *                 indicating 'certificate_digest_with_ecdsap256'
                 *               and containing digest
                 *                 referencing to the trusted certificate
                 *                   containing subject_info.subject_type
                 *                     indicating 'root_ca'
                 *                     or indicating 'authorisation_authority'
                 *   }
                 * }
                 * </pre>
garciay's avatar
garciay committed
7137
7138
                 * @see         ETSI TS 103 096-2 v1.3.2 TP_SEC_ITSS_SND_CERT_AA_04_01_BV
                 * @reference   ETSI TS 103 097 [1], clauses 6.3
garciay's avatar
garciay committed
7139
7140
7141
7142
7143
7144
7145
7146
7147
7148
7149
7150
7151
7152
7153
7154
7155
7156
7157
7158
7159
7160
7161
7162
7163
7164
7165
7166
7167
7168
7169
7170
7171
7172
7173
7174
7175
7176
7177
7178
7179
7180
7181
7182
7183
                 */
                testcase TC_SEC_ITSS_SND_CERT_AA_04_01_BV() runs on ItsGeoNetworking system ItsSecSystem {
                    var CertificateChain    v_chain;
                    var Certificate         v_aa_cert, v_ca_cert;
                    var SignerInfo          v_si;
                    var HashedId8           v_ca_digest;
                    
                    // Test control
                    if (not(PICS_GN_SECURITY)) {
                        log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY' required for executing the TC ***");
                        stop;
                    }
                    
                    // Test component configuration
                    f_cf01Up();
                    
                    // Test adapter configuration
                    
                    // Preamble
                    f_prNeighbour();
                    f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                    
                    // Test Body
                    log("*** " & testcasename() & ": INFO: Request and waiting for the message containing certificate chain  ***");
                    tc_ac.start;
                    if (not f_askAndWaitForCertificateChain(v_chain, f_generateDefaultCam())) {
                        log("*** " & testcasename() & ": INCONC: Expected message not received ***");
                        f_selfOrClientSyncAndVerdictPreamble(c_tbDone, e_timeout);
                    }
                    tc_ac.stop;
                    v_aa_cert := v_chain[lengthof(v_chain) - 2];
                    // Process signerInfo field
                    if ( true != f_getCertificateSignerInfo(v_aa_cert, v_si)) {
                        log("*** " & testcasename() & ": FAIL: AA certificate must contain SignerInfo fields ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                    }
                    if (v_si.type_ == e_certificate_digest_with_sha256) {
                        log("*** " & testcasename() & ": FAIL: AA certificate must contain SignerInfo field containing a certificate_digest_with_ecdsap256 ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                    }
                    
                    f_readCertificate(cc_taCert_CA, v_ca_cert);
                    v_ca_digest := f_calculateDigestFromCertificate(v_ca_cert); 
                    
                    if (not match(v_aa_cert, mw_aa_certificate(mw_signerInfo_digest(v_ca_digest)))) {
garciay's avatar
garciay committed
7184
                        log("*** " & testcasename() & ": FAIL: AA certificate signer info doesn't reference the CA certificate from the chain ***");
garciay's avatar
garciay committed
7185
7186
7187
7188
7189
7190
7191
7192
7193
7194
7195
7196
7197
7198
7199
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                    }
                    
                    if (not f_verifyCertificateSignatureWithIssuingCertificate(v_aa_cert, v_ca_cert)) {
                        log("*** " & testcasename() & ": FAIL: AT certificate signature verification failed ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                    }
                    
                    log("*** " & testcasename() & ": PASS: AA certificate was signed by the CA certificate from the given chain ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                    
                    // Postamble
                    f_poNeighbour();
                    f_cf01Down();
                } // End of testcase TC_SEC_ITSS_SND_CERT_AA_04_01_BV
garciay's avatar
garciay committed
7200
7201
                
                /**
garciay's avatar
garciay committed
7202
                 * @desc Check that all neccesary subject attributes are present and arranged in accesing order
garciay's avatar
garciay committed
7203
7204
7205
7206
7207
7208
7209
7210
7211
7212
7213
                 * <pre>
                 * Pics Selection: PICS_GN_SECURITY
                 * Config Id: CF01
                 * with {
                 *   the IUT being in the 'authorized' state
                 *   the IUT being requested to include certificate chain in the next CAM
                 * } ensure that {
                 *    when {
                 *     the IUT is requested to send a CAM
                 *   } then {
                 *     the IUT sends a SecuredMessage
garciay's avatar
garciay committed
7214
                 *       containing header_fields['signer_info'].signer
garciay's avatar
garciay committed
7215
                 *         containing type
garciay's avatar
garciay committed
7216
                 *           indicating 'certificate_chain'
garciay's avatar
garciay committed
7217
7218
                 *         containing certificates[last-1]
                 *           containing subject_attributes [0..N]
garciay's avatar
garciay committed
7219
7220
7221
7222
7223
7224
7225
                 *             indicating subject_attributes[n].type < subject_attributes[n+ 1].type
                 *             containing subject_attributes['verification_key']
                 *             containing subject_attributes['assurance_level']
                 *             containing subject_attributes['its_aid_list']
                 *   }
                 * }
                 * </pre>
garciay's avatar
garciay committed
7226
                 * @see         ETSI TS 103 096-2 v1.3.2 TP_SEC_ITSS_SND_CERT_AA_05_01_BV
garciay's avatar
garciay committed
7227
                 * @reference   ETSI TS 103 097 [1], clauses 6.1, 7.4.1 and 7.4.4
garciay's avatar
garciay committed
7228
                 */
garciay's avatar
garciay committed
7229
                testcase TC_SEC_ITSS_SND_CERT_AA_05_01_BV() runs on ItsGeoNetworking system ItsSecSystem {
garciay's avatar
garciay committed
7230
7231
7232
7233
7234
7235
7236
7237
7238
7239
7240
7241
7242
7243
7244
7245
7246
7247
7248
7249
7250
7251
7252
7253
7254
7255
7256
7257
7258
7259
7260
7261
7262
7263
7264
7265
7266
7267
7268
7269
7270
7271
7272
7273
7274
7275
7276
7277
7278
7279
7280
7281
7282
7283
                    var CertificateChain         v_chain;
                    var SubjectAttributes        v_attrs;
                    
                    // Test control
                    if (not(PICS_GN_SECURITY)) {
                        log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY' required for executing the TC ***");
                        stop;
                    }
                    
                    // Test component configuration
                    f_cf01Up();
                    
                    // Test adapter configuration
                    
                    // Preamble
                    f_prNeighbour();
                    f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                    
                    // Test Body
                    log("*** " & testcasename() & ": INFO: Request and waiting for the message containing certificate chain  ***");
                    tc_ac.start;
                    if (not f_askAndWaitForCertificateChain(v_chain, f_generateDefaultCam())) {
                        log("*** " & testcasename() & ": INCONC: Expected message not received ***");
                        f_selfOrClientSyncAndVerdictPreamble(c_tbDone, e_timeout);
                    }
                    tc_ac.stop;
                    if (lengthof(v_chain) < 2) {
                        log("*** " & testcasename() & ": FAIL: Certificate chain is too short ***");
                        f_selfOrClientSyncAndVerdictPreamble(c_tbDone, e_error);
                    }
                    if (not match(v_chain[lengthof(v_chain) - 2], 
                                 mw_aa_certificate(?,
                                        superset(mw_subject_attribute_verification_key,
                                                 mw_subject_attribute_assurance_level,
                                                 mw_subject_attribute_its_aid_list)))
                     ) {
                        log("*** " & testcasename() & ": FAIL: Required subject attribute of AA certificate is not found ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                    }
                    
                    v_attrs := v_chain[lengthof(v_chain) - 2].subject_attributes;
                    for (var integer v_counter := 1; v_counter < lengthof(v_attrs); v_counter := v_counter + 1 ) {
                        if (v_attrs[v_counter].type_ <= v_attrs[v_counter-1].type_) {
                            log("*** " & testcasename() & ": FAIL: AA certificate subject attributes are not arranged in accening order ***");
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                        }
                    }
                    
                    log("*** " & testcasename() & ": PASS: All required AA certificate subject attributes are presents ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                    
                    // Postamble
                    f_poNeighbour();
                    f_cf01Down();
garciay's avatar
garciay committed
7284
                } // End of testcase TC_SEC_ITSS_SND_CERT_AA_05_01_BV
garciay's avatar
garciay committed
7285
7286
                
                /**
garciay's avatar
garciay committed
7287
                 * @desc Check that all AIDs containing in the its_aid_list in AA certificate are unique
garciay's avatar
garciay committed
7288
                 *       Check that AID list contains not more then 31 items
garciay's avatar
garciay committed
7289
7290
7291
7292
7293
7294
7295
7296
7297
7298
7299
                 * <pre>
                 * Pics Selection: PICS_GN_SECURITY
                 * Config Id: CF01
                 * with {
                 *   the IUT being in the 'authorized' state
                 *   the IUT being requested to include certificate chain in the next CAM
                 * } ensure that {
                 *    when {
                 *     the IUT is requested to send a CAM
                 *   } then {
                 *     the IUT sends a SecuredMessage
garciay's avatar
garciay committed
7300
                 *       containing header_fields['signer_info'].signer
garciay's avatar
garciay committed
7301
                 *         containing type
garciay's avatar
garciay committed
7302
                 *           indicating 'certificate_chain'
garciay's avatar
garciay committed
7303
7304
7305
7306
                 *         containing certificates[last-1]
                 *           containing subject_attributes['its_aid_list']
                 *             containing its_aid_list[0..N]
                 *               containing no more then 31 unique item
garciay's avatar
garciay committed
7307
7308
7309
                 *   }
                 * }
                 * </pre>
garciay's avatar
garciay committed
7310
                 * @see         ETSI TS 103 096-2 v1.3.2 TP_SEC_ITSS_SND_CERT_AA_08_01_BV
garciay's avatar
garciay committed
7311
                 * @reference   ETSI TS 103 097 [1], clauses 7.4.4
garciay's avatar
garciay committed
7312
                 */
garciay's avatar
garciay committed
7313
                testcase TC_SEC_ITSS_SND_CERT_AA_08_01_BV() runs on ItsGeoNetworking system ItsSecSystem {
garciay's avatar
garciay committed
7314
7315
                    var CertificateChain         v_chain;
                    var Certificate              v_aa_cert;
garciay's avatar
garciay committed
7316
                    var SubjectAttribute         v_sa;
garciay's avatar
garciay committed
7317
7318
7319
7320
7321
7322
7323
7324
7325
7326
7327
7328
7329
7330
7331
7332
7333
7334
7335
7336
7337
7338
7339
7340
7341
7342
7343
7344
7345
                    
                    // Test control
                    if (not(PICS_GN_SECURITY)) {
                        log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY' required for executing the TC ***");
                        stop;
                    }
                    
                    // Test component configuration
                    f_cf01Up();
                    
                    // Test adapter configuration
                    
                    // Preamble
                    f_prNeighbour();
                    f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                    
                    // Test Body
                    log("*** " & testcasename() & ": INFO: Request and waiting for the message containing certificate chain  ***");
                    tc_ac.start;
                    if (not f_askAndWaitForCertificateChain(v_chain, f_generateDefaultCam())) {
                        log("*** " & testcasename() & ": INCONC: Expected message not received ***");
                        f_selfOrClientSyncAndVerdictPreamble(c_tbDone, e_timeout);
                    }
                    tc_ac.stop;
                    if (lengthof(v_chain) < 2) {
                        log("*** " & testcasename() & ": FAIL: Certificate chain is too short ***");
                        f_selfOrClientSyncAndVerdictPreamble(c_tbDone, e_error);
                    }
                    v_aa_cert := v_chain[lengthof(v_chain) - 2];
garciay's avatar
garciay committed
7346
7347
7348
7349
7350
7351
7352
7353
7354
7355
7356
7357
7358
7359
7360
7361
7362
                    if (f_getCertificateSubjectAttribute(v_aa_cert, e_its_aid_list, v_sa)) {
                        
                        if (lengthof(v_sa.attribute.its_aid_list) > 31) {
                            log("*** " & testcasename() & ": FAIL: ITS-AID list contains " & int2str(lengthof(v_sa.attribute.its_aid_list)) & " items (>31) ***");
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                        }
                        
                        for (var integer v_counter :=0; v_counter < lengthof(v_sa.attribute.its_aid_list); v_counter := v_counter + 1) {
                            for (var integer j :=0; j < lengthof(v_sa.attribute.its_aid_list); j := j + 1) {
                                if (v_counter != j and v_sa.attribute.its_aid_list[v_counter] == v_sa.attribute.its_aid_list[j]) {
                                    log("*** " & testcasename() & ": FAIL: ITS-AID " & int2str(v_sa.attribute.its_aid_list[j]) & " is duplicated in AA certificate ***");
                                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                                }
                            }
                        } // End of 'for' statement
                    } else {
                        log("*** " & testcasename() & ": FAIL: AA certificate does not contain its_aid_list subject attribute ***");
garciay's avatar
garciay committed
7363
7364
7365
7366
7367
7368
7369
7370
7371
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                    }
                    
                    log("*** " & testcasename() & ": PASS: Time validity restriction of the AA certificate is good ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                    
                    // Postamble
                    f_poNeighbour();
                    f_cf01Down();
garciay's avatar
garciay committed
7372
                } // End of testcase TC_SEC_ITSS_SND_CERT_AA_08_01_BV
garciay's avatar
garciay committed
7373
7374
                
                /**
garciay's avatar
garciay committed
7375
                 * @desc Check that all mandatory validity restrictions are present and arranged in ascending order
garciay's avatar
garciay committed
7376
7377
7378
7379
7380
7381
7382
7383
7384
7385
7386
                 * <pre>
                 * Pics Selection: PICS_GN_SECURITY
                 * Config Id: CF01
                 * with {
                 *   the IUT being in the 'authorized' state
                 *   the IUT being requested to include certificate chain in the next CAM
                 * } ensure that {
                 *    when {
                 *     the IUT is requested to send a CAM
                 *   } then {
                 *     the IUT sends a SecuredMessage
garciay's avatar
garciay committed
7387
7388
7389
7390
7391
7392
                 *       containing header_fields['signer_info'].signer
                 *           containing type
                 *               indicating 'certificate_chain'
                 *           and containing certificates
                 *               containing certificates[last-1]
                 *                   containing validity_restrictions[0..N]
garciay's avatar
garciay committed
7393
                 *                       indicating validity_restrictions[n].type < validity_restrictions[n+1].type
garciay's avatar
garciay committed
7394
7395
7396
                 *                       and containing validity_restrictions['time_start_and_end']
                 *                       and not containing validity_restrictions['time_end']
                 *                       and not containing validity_restrictions['time_start_and_duration']
garciay's avatar
garciay committed
7397
7398
7399
                 *   }
                 * }
                 * </pre>
garciay's avatar
garciay committed
7400
                 * @see         ETSI TS 103 096-2 v1.3.2 TP_SEC_ITSS_SND_CERT_AA_10_01_BV
garciay's avatar
garciay committed
7401
                 * @reference   ETSI TS 103 097 [1], clauses 6.1, 6.7 and 7.4.1
garciay's avatar
garciay committed
7402
                 */
garciay's avatar
garciay committed
7403
                testcase TC_SEC_ITSS_SND_CERT_AA_10_01_BV() runs on ItsGeoNetworking system ItsSecSystem {
garciay's avatar
garciay committed
7404
                    
garciay's avatar
garciay committed
7405
                    // Local variables
garciay's avatar
garciay committed
7406
7407
7408
                    var CertificateChain v_chain;
                    var Certificate v_cert;
                    var integer v_previousValidityRestrictionType;
garciay's avatar
garciay committed
7409
7410
7411
7412
7413
7414
7415
7416
7417
7418
7419
7420
7421
7422
7423
7424
                    
                    // Test control
                    if (not(PICS_GN_SECURITY)) {
                        log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY' required for executing the TC ***");
                        stop;
                    }
                    
                    // Test component configuration
                    f_cf01Up();
                    
                    // Test adapter configuration
                    
                    // Preamble
                    f_prNeighbour();
                    f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                    
garciay's avatar
garciay committed
7425
                    log("*** " & testcasename() & ": INFO: Request and waiting for the message containing certificate chain  ***");
garciay's avatar
garciay committed
7426
                    tc_ac.start;
garciay's avatar
garciay committed
7427
7428
7429
7430
7431
7432
7433
7434
7435
7436
7437
7438
7439
7440
7441
7442
7443
7444
7445
7446
7447
7448
7449
7450
7451
7452
7453
7454
                    if (not f_askAndWaitForCertificateChain(v_chain, f_generateDefaultCam())) {
                        log("*** " & testcasename() & ": INCONC: Expected message not received ***");
                        f_selfOrClientSyncAndVerdictPreamble(c_tbDone, e_timeout);
                    }
                    tc_ac.stop;
                    
                    // Test Body
                    // Process certificate[last - 1]
                    v_cert := v_chain[lengthof(v_chain) - 2];
                    if (match(
                              v_cert.validity_restrictions, 
                              (
                                  superset(
                                      mw_validity_restriction_time_end,
                                      mw_validity_restriction_time_start_and_duration
                                  )
                              )
                    )) {
                        log("*** " & testcasename() & ": FAIL: certificate[last-2] must not contain time_end and time_start_and_duration restrictions ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                    }
                    
                    for (var integer v_counter := 1; v_counter < lengthof(v_cert.validity_restrictions); v_counter := v_counter + 1) {
                        // Check forbidden header
                        if (not match(v_cert.validity_restrictions[v_counter].type_, e_time_start_and_end)) { // FIXME To be reviewed
                            log("*** " & testcasename() & ": FAIL: Forbidden header present");
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                        } 
garciay's avatar
garciay committed
7455
                        
garciay's avatar
garciay committed
7456
7457
7458
7459
7460
7461
7462
7463
7464
                        if (v_counter > 1 ) {
                            // Check that headers are ordered
                            if (match(v_cert.validity_restrictions[v_counter].type_, integer:(0..v_previousValidityRestrictionType))) {
                                // Check that header is duplicated
                                if (match(v_cert.validity_restrictions[v_counter].type_, v_previousValidityRestrictionType)) {
                                    log("*** " & testcasename() & ": FAIL: multiple instances of same header");
                                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                                } else {
                                    log("*** " & testcasename() & ": FAIL: headers not in correct order");
garciay's avatar
garciay committed
7465
7466
                                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                                }
garciay's avatar
garciay committed
7467
                            }
garciay's avatar
garciay committed
7468
                        }
garciay's avatar
garciay committed
7469
7470
7471
7472
7473
                        v_previousValidityRestrictionType := enum2int(v_cert.validity_restrictions[v_counter].type_);
                    } // End of 'for' statement
                    
                    log("*** " & testcasename() & ": PASS: Time validity restriction of the certificate[last-2] is good ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
garciay's avatar
garciay committed
7474
7475
7476
7477
                    
                    // Postamble
                    f_poNeighbour();
                    f_cf01Down();
garciay's avatar
garciay committed
7478
                } // End of testcase TC_SEC_ITSS_SND_CERT_AA_10_01_BV
garciay's avatar
garciay committed
7479
7480
                
                /**
garciay's avatar
garciay committed
7481
7482
7483
                 * @desc Check that time_start_and_end is included in the AA certificate validation restrictions;
                 *       Check that end_validity is greater than start_validity
                 *       Check that validity restriction of AA certificate is inside the validity restriction of its issuing certificate
garciay's avatar
garciay committed
7484
7485
7486
7487
7488
7489
7490
7491
7492
7493
7494
                 * <pre>
                 * Pics Selection: PICS_GN_SECURITY
                 * Config Id: CF01
                 * with {
                 *   the IUT being in the 'authorized' state
                 *   the IUT being requested to include certificate chain in the next CAM
                 * } ensure that {
                 *    when {
                 *     the IUT is requested to send a CAM
                 *   } then {
                 *     the IUT sends a SecuredMessage
garciay's avatar
garciay committed
7495
                 *       containing header_fields['signer_info'].signer
garciay's avatar
garciay committed
7496
                 *         containing type
garciay's avatar
garciay committed
7497
                 *           indicating 'certificate_chain'
garciay's avatar
garciay committed
7498
7499
                 *         containing certificates[last-1] {
                 *           containing validity_restrictions
garciay's avatar
garciay committed
7500
7501
7502
7503
7504
7505
7506
7507
7508
7509
7510
7511
7512
7513
7514
7515
7516
7517
7518
7519
7520
                 *             containing validity_restrictions['time_start_and_end']
                 *               containing start_validity
                 *                 indicating START_AA_VALIDITY
                 *               containing end_validity
                 *                 indicating END_AA_VALIDITY >=START_AA_VALIDITY
                 *             and containing signer_info
                 *               containing digest
                 *                 referenced to the trusted certificate
                 *                   containing validity_restrictions['time_end']
                 *                     containing end_validity
                 *                       indicating value > AA_END_VALIDITY
                 *                   or containing validity_restrictions['time_start_and_end']
                 *                     containing start_validity
                 *                       indicating value <= AA_START_VALIDITY
                 *                     and containing end_validity
                 *                       indicating value > AA_END_VALIDITY
                 *                   or containing validity_restrictions['time_start_and_duration']
                 *                     containing start_validity
                 *                       indicating X_START_VALIDITY <= AA_START_VALIDITY
                 *                     and containing duration
                 *                       indicating value > AA_END_VALIDITY - X_START_VALIDITY
garciay's avatar
garciay committed
7521
7522
7523
                 *   }
                 * }
                 * </pre>
garciay's avatar
garciay committed
7524
                 * @see         ETSI TS 103 096-2 v1.3.2 TP_SEC_ITSS_SND_CERT_AA_11_01_BV
garciay's avatar
garciay committed
7525
                 * @reference   ETSI TS 103 097 [1], clauses 7.4.4
garciay's avatar
garciay committed
7526
                 */
garciay's avatar
garciay committed
7527
                testcase TC_SEC_ITSS_SND_CERT_AA_11_01_BV() runs on ItsGeoNetworking system ItsSecSystem {
garciay's avatar
garciay committed
7528
7529
7530
7531
7532
7533
7534
7535
7536
7537
7538
7539
7540
7541
7542
7543
7544
7545
7546
7547
7548
7549
7550
7551
7552
7553
7554
7555
7556
7557
7558
7559
7560
7561
7562
7563
7564
7565
7566
7567
7568
7569
7570
7571
7572
7573
7574
7575
7576
7577
7578
7579
7580
7581
7582
                    var CertificateChain         v_chain;
                    var Certificate              v_aa_cert;
                    var ValidityRestriction      v_vr;
                    
                    // Test control
                    if (not(PICS_GN_SECURITY)) {
                        log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY' required for executing the TC ***");
                        stop;
                    }
                    
                    // Test component configuration
                    f_cf01Up();
                    
                    // Test adapter configuration
                    
                    // Preamble
                    f_prNeighbour();
                    f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                    
                    // Test Body
                    log("*** " & testcasename() & ": INFO: Request and waiting for the message containing certificate chain  ***");
                    tc_ac.start;
                    if (not f_askAndWaitForCertificateChain(v_chain, f_generateDefaultCam())) {
                        log("*** " & testcasename() & ": INCONC: Expected message not received ***");
                        f_selfOrClientSyncAndVerdictPreamble(c_tbDone, e_timeout);
                    }
                    tc_ac.stop;
                    if (lengthof(v_chain) < 2) {
                        log("*** " & testcasename() & ": FAIL: Certificate chain is too short ***");
                        f_selfOrClientSyncAndVerdictPreamble(c_tbDone, e_error);
                    }
                    v_aa_cert := v_chain[lengthof(v_chain) - 2];
                    if (match (v_aa_cert.validity_restrictions, (superset(mw_validity_restriction_time_end,
                                                                          mw_validity_restriction_time_start_and_duration)))
                    ) {
                        log("*** " & testcasename() & ": FAIL: AA certificate must not contain time_end and time_start_and_duration restrictions ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                    }
                    
                    if ( true != f_getCertificateValidityRestriction(v_aa_cert, e_time_start_and_end, v_vr)) {
                        log("*** " & testcasename() & ": FAIL: AA certificate must contain time_start_and_end restrictions ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                    }
                    
                    if (v_vr.validity.time_start_and_end.start_validity > v_vr.validity.time_start_and_end.end_validity ) {
                        log("*** " & testcasename() & ": FAIL: start validity mus not be greater then end validity in the validity restrictions of AA certificate ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                    }
                    
                    log("*** " & testcasename() & ": PASS: Time validity restriction of the AA certificate is good ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                    
                    // Postamble
                    f_poNeighbour();
                    f_cf01Down();
garciay's avatar
garciay committed
7583
                } // End of testcase TC_SEC_ITSS_SND_CERT_AA_11_01_BV
garciay's avatar
garciay committed
7584
7585
                
            } // End of group AA_Certificates 
7586
7587
            
            /**
garciay's avatar
garciay committed
7588
7589
7590
7591
7592
7593
             * @desc Sending behaviour test cases for AT certificate profil
             * @see ETSI TS 103 096-2 V1.2.2 (2016-01) Clause 5.2.7.8 AT certificate profile
             */
            group AT_Certificates {
                
                /**
garciay's avatar
garciay committed
7594
                 * @desc Check that the subject_type of the AT certificate is set to 'authorization_ticket'
garciay's avatar
garciay committed
7595
7596
7597
7598
                 * <pre>
                 * Pics Selection: PICS_GN_SECURITY
                 * Config Id: CF01
                 * with {
garciay's avatar
garciay committed
7599
7600
                 *     the IUT being in the 'authorized' state
                 *     the IUT being requested to include certificate in the next CAM
garciay's avatar
garciay committed
7601
                 * } ensure that {
garciay's avatar
garciay committed
7602
7603
7604
7605
7606
7607
7608
7609
7610
7611
7612
                 *      when {
                 *          the IUT is requested to send a CAM
                 *     } then {
                 *         the IUT sends a SecuredMessage
                 *             containing header_fields['signer_info'].signer
                 *                 containing type
                 *                     indicating 'certificate'
                 *                 and containing certificate
                 *                     containing subject_info.subject_type
                 *                         indicating 'authorization_ticket' (1)
                 *     }
garciay's avatar
garciay committed
7613
7614
                 * }
                 * </pre>
garciay's avatar
garciay committed
7615
                 * @see         ETSI TS 103 096-2 v1.3.2 TP_SEC_ITSS_SND_CERT_AT_01_01_BV
garciay's avatar
garciay committed
7616
                 * @reference   ETSI TS 103 097 [1], clause 7.4.2
garciay's avatar
garciay committed
7617
                 */
garciay's avatar
garciay committed
7618
                testcase TC_SEC_ITSS_SND_CERT_AT_01_01_BV() runs on ItsGeoNetworking system ItsSecSystem {
garciay's avatar
garciay committed
7619
7620
7621
7622
7623
7624
7625
7626
7627
7628
7629
7630
7631
7632
7633
7634
7635
7636
7637
7638
7639
7640
7641
7642
7643
7644
7645
7646
7647
7648
7649
7650
7651
7652
7653
                    var Certificate         v_at_cert;
                    
                    // Test control
                    if (not(PICS_GN_SECURITY)) {
                        log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY' required for executing the TC ***");
                        stop;
                    }
                    
                    // Test component configuration
                    f_cf01Up();
                    
                    // Test adapter configuration
                    
                    // Preamble
                    f_prNeighbour();
                    f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                    
                    // Test Body
                    log("*** " & testcasename() & ": INFO: Waiting for the message containing certificate  ***");
                    tc_ac.start;
                    if (not f_waitForCertificate(v_at_cert)) {
                        log("*** " & testcasename() & ": INCONC: Expected message not received ***");
                        f_selfOrClientSyncAndVerdictPreamble(c_tbDone, e_timeout);
                    }
                    tc_ac.stop;
                    if (not match(v_at_cert, mw_at_certificate)) {
                        log("*** " & testcasename() & ": FAIL: Message wasn't signed by AT certificate ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                    }
                    log("*** " & testcasename() & ": PASS: AT certificate has the 'authorization_ticket' subject_type  ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                    
                    // Postamble
                    f_poNeighbour();
                    f_cf01Down();
garciay's avatar
garciay committed
7654
                } // End of testcase TC_SEC_ITSS_SND_CERT_AT_01_01_BV
garciay's avatar
garciay committed
7655
7656
                
                /**
garciay's avatar
garciay committed
7657
                 * @desc Check that the subject_name variable-length vector is empty for AT certificates
garciay's avatar
garciay committed
7658
                 * <pre>
garciay's avatar
garciay committed
7659
                 * Pics Selection: PICS_GN_SECURITY
garciay's avatar
garciay committed
7660
7661
                 * Config Id: CF01
                 * with {
garciay's avatar
garciay committed
7662
7663
                 *     the IUT being in the 'authorized' state
                 *     the IUT being requested to include certificate in the next CAM
garciay's avatar
garciay committed
7664
                 * } ensure that {
garciay's avatar
garciay committed
7665
7666
7667
7668
7669
7670
7671
7672
7673
7674
7675
                 *      when {
                 *          the IUT is requested to send a CAM
                 *      } then {
                 *          the IUT sends a SecuredMessage
                 *              containing header_fields['signer_info'].signer
                 *                  containing type
                 *                      indicating 'certificate'
                 *                  and containing certificates
                 *                      containing subject_info.subject_name
                 *                          indicating length = 0
                 *     }
garciay's avatar
garciay committed
7676
7677
                 * }
                 * </pre>
garciay's avatar
garciay committed
7678
7679
                 * @see         ETSI TS 103 096-2 v1.3.2 TP_SEC_ITSS_SND_CERT_AT_02_01_BV
                 * @reference   ETSI TS 103 097 [1], clause 7.4.2
garciay's avatar
garciay committed
7680
                 */
garciay's avatar
garciay committed
7681
                testcase TC_SEC_ITSS_SND_CERT_AT_02_01_BV() runs on ItsGeoNetworking system ItsSecSystem {
garciay's avatar
garciay committed
7682
7683
7684
                    var Certificate         v_at_cert;
                    
                    // Test control
garciay's avatar
garciay committed
7685
7686
                    if (not(PICS_GN_SECURITY)) {
                        log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY' required for executing the TC ***");
garciay's avatar
garciay committed
7687
7688
7689
7690
7691
7692
7693
7694
7695
7696
7697
7698
7699
7700
7701
7702
7703
7704
7705
7706
                        stop;
                    }
                    
                    // Test component configuration
                    f_cf01Up();
                    
                    // Test adapter configuration
                    
                    // Preamble
                    f_prNeighbour();
                    f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                    
                    // Test Body
                    log("*** " & testcasename() & ": INFO: Waiting for the message containing certificate  ***");
                    tc_ac.start;
                    if (not f_waitForCertificate(v_at_cert)) {
                        log("*** " & testcasename() & ": INCONC: Expected message not received ***");
                        f_selfOrClientSyncAndVerdictPreamble(c_tbDone, e_timeout);
                    }
                    tc_ac.stop;
garciay's avatar
garciay committed
7707
7708
                    if (0 != lengthof(v_at_cert.subject_info.subject_name)) {
                        log("*** " & testcasename() & ": FAIL: Subject name of the AT certificate is not empty ***");
garciay's avatar
garciay committed
7709
7710
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                    }
garciay's avatar
garciay committed
7711
                    log("*** " & testcasename() & ": PASS: Subject name of the AT certificate is empty ***");
garciay's avatar
garciay committed
7712
7713
7714
7715
7716
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                    
                    // Postamble
                    f_poNeighbour();
                    f_cf01Down();
garciay's avatar
garciay committed
7717
                } // End of testcase TC_SEC_ITSS_SND_CERT_AT_02_01_BV
garciay's avatar
garciay committed
7718
7719
                
                /**
garciay's avatar
garciay committed
7720
                 * @desc Check that signer_info type of AT certificates is set to 'certificate_digest_with_sha256' 
garciay's avatar
garciay committed
7721
                 * <pre>
garciay's avatar
garciay committed
7722
                 * Pics Selection: PICS_GN_SECURITY
garciay's avatar
garciay committed
7723
7724
                 * Config Id: CF01
                 * with {
garciay's avatar
garciay committed
7725
7726
                 *     the IUT being in the 'authorized' state
                 *     the IUT being requested to include certificate in the next CAM
garciay's avatar
garciay committed
7727
                 * } ensure that {
garciay's avatar
garciay committed
7728
7729
7730
7731
7732
7733
7734
7735
7736
7737
7738
7739
                 *      when {
                 *          the IUT is requested to send a CAM
                 *      } then {
                 *          the IUT sends a SecuredMessage
                 *              containing header_fields['signer_info'].signer
                 *                  containing type
                 *                      indicating 'certificate'
                 *                  and containing certificate
                 *                      containing signer_info
                 *                          containing type
                 *                              indicating 'certificate_digest_with_sha256'
                 *      }
garciay's avatar
garciay committed
7740
7741
                 * }
                 * </pre>
garciay's avatar
garciay committed
7742
7743
                 * @see         ETSI TS 103 096-2 v1.3.2 TP_SEC_ITSS_SND_CERT_AT_03_01_BV
                 * @reference   ETSI TS 103 097 [1], clauses 7.4.2
garciay's avatar
garciay committed
7744
                 */
garciay's avatar
garciay committed
7745
                testcase TC_SEC_ITSS_SND_CERT_AT_03_01_BV() runs on ItsGeoNetworking system ItsSecSystem {
garciay's avatar
garciay committed
7746
7747
7748
                    var Certificate         v_at_cert;
                    
                    // Test control
garciay's avatar
garciay committed
7749
7750
                    if (not(PICS_GN_SECURITY)) {
                        log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY' required for executing the TC ***");
garciay's avatar
garciay committed
7751
7752
7753
7754
7755
7756
7757
7758
7759
7760
7761
7762
7763
7764
7765
7766
7767
7768
7769
7770
                        stop;
                    }
                    
                    // Test component configuration
                    f_cf01Up();
                    
                    // Test adapter configuration
                    
                    // Preamble
                    f_prNeighbour();
                    f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                    
                    // Test Body
                    log("*** " & testcasename() & ": INFO: Waiting for the message containing certificate  ***");
                    tc_ac.start;
                    if (not f_waitForCertificate(v_at_cert)) {
                        log("*** " & testcasename() & ": INCONC: Expected message not received ***");
                        f_selfOrClientSyncAndVerdictPreamble(c_tbDone, e_timeout);
                    }
                    tc_ac.stop;
garciay's avatar
garciay committed
7771
7772
7773
7774
                    if (
                        not match(v_at_cert, mw_certificate(mw_signerInfo_digest))
                    ) {
                        log("*** " & testcasename() & ": FAIL: AT certificate doesn't contain a digest of issuing cert ***");
garciay's avatar
garciay committed
7775
7776
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                    }
garciay's avatar
garciay committed
7777
                    log("*** " & testcasename() & ": PASS: The signer info of AT certificate is a digest ***");
garciay's avatar
garciay committed
7778
7779
7780
7781
7782
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                    
                    // Postamble
                    f_poNeighbour();
                    f_cf01Down();
garciay's avatar
garciay committed
7783
                } // End of testcase TC_SEC_ITSS_SND_CERT_AT_03_01_BV
garciay's avatar
garciay committed
7784
7785
                
                /**
garciay's avatar
garciay committed
7786
                 * @desc Check that subject attributes are present and arranged in ascending order
garciay's avatar
garciay committed
7787
                 * <pre>
garciay's avatar
garciay committed
7788
                 * Pics Selection: PICS_GN_SECURITY
garciay's avatar
garciay committed
7789
7790
                 * Config Id: CF01
                 * with {
garciay's avatar
garciay committed
7791
7792
                 *     the IUT being in the 'authorized' state
                 *     the IUT being requested to include certificate in the next CAM
garciay's avatar
garciay committed
7793
                 * } ensure that {
garciay's avatar
garciay committed
7794
7795
7796
7797
7798
7799
7800
7801
7802
7803
7804
7805
7806
7807
                 *     when {
                 *         the IUT is requested to send a CAM
                 *     } then {
                 *         the IUT sends a SecuredMessage
                 *             containing header_fields['signer_info'].signer
                 *                 containing type
                 *                     indicating 'certificate'
                 *             containing certificate
                 *                 containing subject_attributes [0..N]
                 *                     indicating subject_attributes[n].type < subject_attributes[n+ 1].type
                 *                 containing subject_attributes['verification_key']
                 *                 containing subject_attributes['assurance_level']
                 *                 containing subject_attributes['its_aid_ssp_list']
                 *     }
garciay's avatar
garciay committed
7808
7809
                 * }
                 * </pre>
garciay's avatar
garciay committed
7810
                 * @see         ETSI TS 103 096-2 v1.3.2 TP_SEC_ITSS_SND_CERT_AT_04_01_BV
garciay's avatar
garciay committed
7811
                 * @reference   ETSI TS 103 097 [1], clauses 7.4.1 and 7.4.2
garciay's avatar
garciay committed
7812
                 */
garciay's avatar
garciay committed
7813
                testcase TC_SEC_ITSS_SND_CERT_AT_04_01_BV() runs on ItsGeoNetworking system ItsSecSystem {
garciay's avatar
garciay committed
7814
7815
7816
7817
                    var Certificate         v_at_cert;
                    var SubjectAttributes   v_attrs;
                    
                    // Test control
garciay's avatar
garciay committed
7818
7819
                    if (not(PICS_GN_SECURITY)) {
                        log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY' required for executing the TC ***");
garciay's avatar
garciay committed
7820
7821
7822
7823
7824
7825
7826
7827
7828
7829
7830
7831
7832
7833
7834
7835
7836
7837
7838
7839
7840
7841
7842
7843
7844
7845
7846
7847
7848
7849
7850
7851
7852
7853
7854
7855
7856
7857
7858
7859
7860
7861
7862
7863
7864
7865
7866
                        stop;
                    }
                    
                    // Test component configuration
                    f_cf01Up();
                    
                    // Test adapter configuration
                    
                    // Preamble
                    f_prNeighbour();
                    f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                    
                    // Test Body
                    log("*** " & testcasename() & ": INFO: Waiting for the message containing certificate  ***");
                    tc_ac.start;
                    if (not f_waitForCertificate(v_at_cert)) {
                        log("*** " & testcasename() & ": INCONC: Expected message not received ***");
                        f_selfOrClientSyncAndVerdictPreamble(c_tbDone, e_timeout);
                    }
                    tc_ac.stop;
                    if (not match(
                        v_at_cert, 
                            mw_at_certificate(
                                ?,
                                superset(
                                    mw_subject_attribute_verification_key,
                                    mw_subject_attribute_assurance_level,
                                    mw_subject_attribute_its_aid_ssp_list
                     )))) {
                        log("*** " & testcasename() & ": FAIL: Required subject attribute of AT certificate is not found ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                    }
                    
                    v_attrs := v_at_cert.subject_attributes;
                    for (var integer v_counter := 1; v_counter < lengthof(v_attrs); v_counter := v_counter + 1 ) {
                        if (v_attrs[v_counter].type_ <= v_attrs[v_counter-1].type_) {
                            log("*** " & testcasename() & ": FAIL: AT certificate subject attributes are not arranged in ascending order ***");
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                        }
                    } // End of 'for' statement
                    
                    log("*** " & testcasename() & ": PASS: All required AT certificate subject attributes are presents and arranged in ascending order ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                    
                    // Postamble
                    f_poNeighbour();
                    f_cf01Down();
garciay's avatar
garciay committed
7867
                } // End of testcase TC_SEC_ITSS_SND_CERT_AT_04_01_BV
garciay's avatar
garciay committed
7868
7869
7870
                
                /**
                 * @desc Check that time_start_and_end is included in the AT certificate validation restrictions
garciay's avatar
garciay committed
7871
7872
                 *       Check that time_start_and_end is inside the AA certificate time restrictions
                 *       Check that validity restriction of AT certificate is inside the validity restriction of its issuing certificate 
garciay's avatar
garciay committed
7873
                 * <pre>
garciay's avatar
garciay committed
7874
                 * Pics Selection: PICS_GN_SECURITY
garciay's avatar
garciay committed
7875
7876
7877
7878
7879
7880
7881
7882
7883
                 * Config Id: CF01
                 * with {
                 *   the IUT being in the 'authorized' state
                 *   the IUT being requested to include certificate chain in the next CAM
                 * } ensure that {
                 *    when {
                 *     the IUT is requested to send a CAM
                 *   } then {
                 *     the IUT sends a SecuredMessage
garciay's avatar
garciay committed
7884
                 *       containing header_fields['signer_info'].signer
garciay's avatar
garciay committed
7885
                 *         containing type
garciay's avatar
garciay committed
7886
                 *           indicating 'certificate_chain'
garciay's avatar
garciay committed
7887
                 *         containing certificates[last] 
garciay's avatar
garciay committed
7888
7889
7890
7891
                 *           containing subject_info.subject_type
                 *             indicating 'authorization_ticket' (1)
                 *           not containing validity_restrictions['time_end']
                 *           and not containing validity_restrictions['time_start_and_duration']
garciay's avatar
garciay committed
7892
                 *           and containing validity_restrictions['time_start_and_end'] 
garciay's avatar
garciay committed
7893
                 *             containing start_validity
garciay's avatar
garciay committed
7894
                 *               indicating START_AT_VALIDITY
garciay's avatar
garciay committed
7895
                 *             and containing end_validity
garciay's avatar
garciay committed
7896
                 *               indicating END_AT_VALIDITY
garciay's avatar
garciay committed
7897
7898
7899
7900
7901
7902
7903
7904
7905
7906
7907
7908
7909
7910
                 *         and containing certificates[last-1] 
                 *           containing validity_restrictions['time_end']
                 *             containing end_validity
                 *               indicating value > AT_END_VALIDITY
                 *           or containing validity_restrictions['time_start_and_end']
                 *             containing start_validity
                 *               indicating value <= AT_START_VALIDITY
                 *             containing end_validity
                 *               indicating value > AT_END_VALIDITY
                 *           or containing validity_restrictions['time_start_and_duration']
                 *             containing start_validity
                 *               indicating X_START_VALIDITY <= AT_START_VALIDITY
                 *             and containing duration
                 *               indicating value > AT_END_VALIDITY - X_START_VALIDITY
garciay's avatar
garciay committed
7911
7912
7913
                 *   }
                 * }
                 * </pre>
garciay's avatar
garciay committed
7914
                 * @see         ETSI TS 103 096-2 v1.3.2 TP_SEC_ITSS_SND_CERT_AT_05_01_BV
garciay's avatar
garciay committed
7915
                 * @reference   ETSI TS 103 097 [1], clause 7.4.2
garciay's avatar
garciay committed
7916
                 */
garciay's avatar
garciay committed
7917
                testcase TC_SEC_ITSS_SND_CERT_AT_05_01_BV() runs on ItsGeoNetworking system ItsSecSystem {
garciay's avatar
garciay committed
7918
7919
7920
7921
7922
                    var CertificateChain         v_chain;
                    var Certificate              v_aa_cert, v_at_cert;
                    var ValidityRestriction      v_vr, v_aa_vr;
                    
                    // Test control
garciay's avatar
garciay committed
7923
7924
                    if (not(PICS_GN_SECURITY)) {
                        log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY' required for executing the TC ***");
garciay's avatar
garciay committed
7925
7926
7927
7928
7929
7930
7931
7932
7933
7934
7935
7936
7937
7938
7939
7940
7941
7942
7943
7944
7945
7946
7947
7948
7949
7950
7951
7952
7953
7954
7955
7956
7957
7958
7959
7960
7961
7962
7963
7964
7965
7966
7967
7968
7969
7970
7971
7972
7973
                        stop;
                    }
                    
                    // Test component configuration
                    f_cf01Up();
                    
                    // Test adapter configuration
                    
                    // Preamble
                    f_prNeighbour();
                    f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                    
                    // Test Body
                    log("*** " & testcasename() & ": INFO: Request and waiting for the message containing certificate chain  ***");
                    tc_ac.start;
                    if (not f_askAndWaitForCertificateChain(v_chain, f_generateDefaultCam())) {
                        log("*** " & testcasename() & ": INCONC: Expected message not received ***");
                        f_selfOrClientSyncAndVerdictPreamble(c_tbDone, e_timeout);
                    }
                    tc_ac.stop;
                    if (lengthof(v_chain) < 2) {
                        log("*** " & testcasename() & ": FAIL: Certificate chain is too short ***");
                        f_selfOrClientSyncAndVerdictPreamble(c_tbDone, e_error);
                    }
                    v_aa_cert := v_chain[lengthof(v_chain) - 2];
                    v_at_cert := v_chain[lengthof(v_chain) - 1];
                    if (match (
                        v_at_cert.validity_restrictions, 
                        (
                            superset(
                                mw_validity_restriction_time_end,
                                mw_validity_restriction_time_start_and_duration
                            )
                        )
                    )) {
                        log("*** " & testcasename() & ": FAIL: AT certificate must not contain time_end and time_start_and_duration restrictions ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                    }
                    
                    if ( true != f_getCertificateValidityRestriction(v_at_cert, e_time_start_and_end, v_vr)) {
                        log("*** " & testcasename() & ": FAIL: AT certificate must contain time_start_and_end restrictions ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                    }
                    
                    if (v_vr.validity.time_start_and_end.start_validity > v_vr.validity.time_start_and_end.end_validity ) {
                        log("*** " & testcasename() & ": FAIL: start validity must not be greater then end validity in the validity restrictions of AT certificate ***");
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                    }
                    
garciay's avatar
garciay committed
7974
7975
7976
7977
7978
7979
7980
7981
7982
7983
7984
7985
7986
7987
7988
7989
7990
7991
7992
7993
7994
7995
7996
7997
                    if (true == f_getCertificateValidityRestriction(v_aa_cert, e_time_start_and_end, v_aa_vr)) {
                        if (
                            (v_vr.validity.time_start_and_end.start_validity < v_aa_vr.validity.time_start_and_end.start_validity) or 
                            (v_vr.validity.time_start_and_end.end_validity > v_aa_vr.validity.time_start_and_end.end_validity)
                        ) {
                            log("*** " & testcasename() & ": FAIL: AT certificate time validity restriction must be inside the AA certificate time validity restriction ***"); 
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                        }
                    } else if (true == f_getCertificateValidityRestriction(v_aa_cert, e_time_end, v_aa_vr)) {
                        if (v_vr.validity.time_start_and_end.end_validity > v_aa_vr.validity.end_validity) {
                            log("*** " & testcasename() & ": FAIL: AT certificate time validity restriction must be inside the AA certificate time validity restriction ***"); 
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                        }
                    } else if (true == f_getCertificateValidityRestriction(v_aa_cert, e_time_start_and_duration, v_aa_vr)) {
                        var Time64 v_end := v_aa_vr.validity.time_start_and_duration.start_validity + f_duration2time(v_aa_vr.validity.time_start_and_duration.duration_);
                        if (
                            (v_vr.validity.time_start_and_end.start_validity < v_aa_vr.validity.time_start_and_duration.start_validity) or 
                            (v_vr.validity.time_start_and_end.end_validity > v_end)
                        ) {
                            log("*** " & testcasename() & ": FAIL: AT certificate time validity restriction must be inside the AA certificate time validity restriction ***"); 
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                        }
                    } else {
                        log("*** " & testcasename() & ": FAIL: Wrong AA certificate time restrictions ***");
garciay's avatar
garciay committed
7998
7999
8000
                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                    }
                    log("*** " & testcasename() & ": PASS: Time validity restriction of the AT certificate is good ***");
For faster browsing, not all history is shown. View entire blame