TestCodec_SecuredFuntions.ttcn 34.9 KB
Newer Older
garciay's avatar
garciay committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/*
 * @author
 *     
 * @version
 *     1.0
 * @desc
 *     
 * @remark
 *     
 * @see
 *     
 */ 
module TestCodec_SecuredFuntions {
    
    // LibCommon
    import from LibCommon_BasicTypesAndValues all;
    import from LibCommon_DataStrings all;
    
    // LibIts
    import from IEEE1609dot2BaseTypes language "ASN.1:1997" all;
    import from IEEE1609dot2 language "ASN.1:1997" all;
    import from EtsiTs103097Module language "ASN.1:1997" all;
    
    // LibItsSecurity
    import from LibItsSecurity_EncdecDeclarations all;
    import from LibItsSecurity_TypesAndValues all;
    import from LibItsSecurity_Templates all;
    import from LibItsSecurity_Functions all;
    import from LibItsSecurity_Pixits all;
    
    // TestCodec
    import from TestCodec_TestAndSystem all;

34
35
    testcase tc_load_certificates() runs on TCType system TCType {

36
      if (fx_loadCertificates(PX_CERTIFICATE_POOL_PATH, PX_IUT_SEC_CONFIG_NAME) == false) {
37
38
39
40
41
42
43
44
45
        setverdict(fail);
      } else {
        setverdict(pass);
      }
    } // End of testcase tc_load_certificates

    testcase tc_read_certificate_1() runs on TCType system TCType {
      var octetstring v_certificate;
      
46
      if (fx_loadCertificates(PX_CERTIFICATE_POOL_PATH, PX_IUT_SEC_CONFIG_NAME) == false) {
47
48
49
50
51
        setverdict(fail);
      } else {
        setverdict(pass);
      }

52
      if (fx_readCertificate("CERT_IUT_A_RCA", v_certificate) == false) {
53
54
55
56
57
58
59
60
61
62
        setverdict(fail);
      } else {
        log("v_certificate: ", v_certificate);
        setverdict(pass);
      }
    } // End of testcase tc_read_certificates_1

    testcase tc_read_certificate_2() runs on TCType system TCType {
      var octetstring v_certificate;
      
63
      if (fx_loadCertificates(PX_CERTIFICATE_POOL_PATH, PX_IUT_SEC_CONFIG_NAME) == false) {
64
65
66
67
68
        setverdict(fail);
      } else {
        setverdict(pass);
      }

garciay's avatar
garciay committed
69
      if (fx_readCertificate("CERT_IUT_A_AA", v_certificate) == false) {
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
        setverdict(fail);
      } else {
        var bitstring v_oct2bit;
        var EtsiTs103097Certificate v_dec_certificate;
                    
        log("v_certificate: ", v_certificate);
        v_oct2bit := oct2bit(v_certificate);
        if (0 == decvalue(v_oct2bit,  v_dec_certificate)) {
          log("v_certificate: ",  v_dec_certificate);
          setverdict(pass);
        } else {
          setverdict(fail);
        }
      }
    } // End of testcase tc_load_certificates_2

    testcase tc_read_certificate_digest() runs on TCType system TCType {
87
      if (fx_loadCertificates(PX_CERTIFICATE_POOL_PATH, PX_IUT_SEC_CONFIG_NAME) == false) {
88
89
90
        setverdict(fail);
      } else {
        var octetstring v_digest;
garciay's avatar
garciay committed
91
        if (fx_readCertificateDigest("CERT_IUT_A_AA", v_digest) == false) {
92
93
94
95
96
97
98
99
          setverdict(fail);
        } else {
          log("v_digest = ", v_digest);
          setverdict(pass);
        }
      }
    } // End of testcase tc_load_certificates_digest

Yann Garcia's avatar
Yann Garcia committed
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
    testcase tc_read_certificate_hashed_id3() runs on TCType system TCType {
      if (fx_loadCertificates(PX_CERTIFICATE_POOL_PATH, PX_IUT_SEC_CONFIG_NAME) == false) {
        setverdict(fail);
      } else {
        var octetstring v_digest;
        if (fx_readCertificateDigest("CERT_IUT_A_AA", v_digest) == false) {
          setverdict(fail);
        } else {
          var charstring v_certificate_id;
          log("v_digest = ", v_digest);
          if (fx_readCertificateFromHashedId3(f_HashedId3FromHashedId8(v_digest), v_certificate_id) == false) {
            setverdict(fail);
          } else {
            log("v_certificate_id = ", v_certificate_id);
            if (v_certificate_id == "CERT_IUT_A_AA") {
              setverdict(pass);
            } else {
              setverdict(fail);
            }
          }
        }
      }
    } // End of testcase tc_load_certificates_hashed_id3

124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
    testcase tc_extract_and_store_certificate_1() runs on TCType system TCType {
      var octetstring v := '2B0492F3E1A33B23'O;
      var hexstring h;
      var charstring c;

      c := oct2str(v);
      log("c= ", c);
      if (str2oct(c) == v) {
        setverdict(pass);
      } else {
        setverdict(fail);
      }
      
      h := oct2hex(v);
      log("h= ", h);
      c := hex2str(h);
      log("c= ", c);
      if (str2oct(c) == v) {
        setverdict(pass);
      } else {
        setverdict(fail);
      }

      
      /*var IEEE1609dot2::Certificate v_cert := { version := 3, type_ := explicit (0), issuer := { sha256AndDigest := '19C3405F47301C64'O }, toBeSigned := { id := { none_ := NULL }, cracaId := '000000'O, crlSeries := 0, validityPeriod := { start_ := 441849600, duration := { hours := 17520 } }, region := omit, assuranceLevel := '60'O ("`"), appPermissions := { { psid := 36, ssp := { bitmapSsp := '01FFFF'O } }, { psid := 37, ssp := { bitmapSsp := '01FFFFFF'O } }, { psid := 141, ssp := { bitmapSsp := '00'O } } }, certIssuePermissions := omit, certRequestPermissions := omit, canRequestRollover := omit, encryptionKey := { supportedSymmAlg := aes128Ccm (0), publicKey := { eciesNistP256 := { compressed_y_1 := 'E5388514801A76870EE89E6DAFA50331865EFF6CCE5E883EC6D9E78DF6B414CC'O } } }, verifyKeyIndicator := { verificationKey := { ecdsaNistP256 := { compressed_y_0 := '6B9119CED38780F4C1931DCDCC3484016A474214C7B1ECB5D3435A5F5F5D4229'O } } } }, signature_ := { ecdsaNistP256Signature := { rSig := { x_only := '1661F3D06C93740D9504024BA01085C52C6ABF8C8E38D095D14916E5598329BB'O }, sSig := '45336AB48FCE674D0ED9E1C718A31F7D1366C4E22AD812A2A91D7663D8EEA354'O } } };
      
      if (fx_loadCertificates(PX_CERTIFICATE_POOL_PATH, PX_IUT_SEC_CONFIG_NAME) == false) {
        setverdict(fail, "Failed to load certificate database");
      } else {
        setverdict(pass, "Certificate database loaded successfully");
        
        
      }
      */
    } // End of testcase tc_extract_and_store_certificate_1
    
160
161
162
163
164
    testcase tc_read_certificate_hash() runs on TCType system TCType {
      if (fx_loadCertificates(PX_CERTIFICATE_POOL_PATH, PX_IUT_SEC_CONFIG_NAME) == false) {
        setverdict(fail);
      } else {
        var octetstring v_hash;
garciay's avatar
garciay committed
165
        if (fx_readCertificateHash("CERT_IUT_A_AA", v_hash) == false) {
166
167
168
169
170
171
172
173
          setverdict(fail);
        } else {
          log("v_hash = ", v_hash);
          setverdict(pass);
        }
      }
    } // End of testcase tc_load_certificates_digest

garciay's avatar
garciay committed
174
175
    testcase tc_sha256_1() runs on TCType system TCType {
      var octetstring v_test := '616263'O;
garciay's avatar
garciay committed
176
      var Oct32 v_exp_hash := 'ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad'O;
garciay's avatar
garciay committed
177
178
179
180
181
182
183
184
185
      var Oct32 v_hash;

      v_hash := f_hashWithSha256(v_test);

      if (match(v_hash, v_exp_hash) == false) {
        setverdict(fail);
      } else {
        setverdict(pass);
      }
garciay's avatar
garciay committed
186
    } // End of testcase tc_sha256_1
garciay's avatar
garciay committed
187

188
189
190
191
192
193
194
195
196
197
198
199
200
201
    testcase tc_sha256_2() runs on TCType system TCType {
      var octetstring v_test := ''O;
      var Oct32 v_exp_hash := 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'O; /* Hash of empty string */
      var Oct32 v_hash;

      v_hash := f_hashWithSha256(v_test);

      if (match(v_hash, v_exp_hash) == false) {
        setverdict(fail);
      } else {
        setverdict(pass);
      }
    } // End of testcase tc_sha256_2

Yann Garcia's avatar
Yann Garcia committed
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
    testcase tc_sha256_3() runs on TCType system TCType {
      var octetstring v_test := '03820101828f113316e5c015ac8083d11e1eabe6ffe1a92d6a33a2ac7137bea0e9e3f5cb6bfd30708d72b0039809ade9565476f808a2469495295b7d9d9b90e5757f3d4589f8857f84fd079833e16e80616b52d5ed652fd5075e81db8201238b2bd8f344ccc4608dc84edb3ced1dd237c820cf03e07ce3284d712129f3acd7e1cf16755a84b50a72a5b7b3499bc868eff467e4ceac71728040e88389c787467c955bdd519d670baa66598a3f262eee3e706bee0756a704f56b4348646ac7681515c69fbce4746e4a00fa4de6fb92c050aae015698e41e1d390e85a8b2bfd7f943c2bd318f87253930e70c420e5c16550d45b4b2e4795e0184b74f5d9ba3532f18f8c8e4073ab65a37349da30d4e1584ac4d3e6d22174d14c65a38f6cb993122beefea2102de46f3e0a2109f5dbc07d4bf978b66b5c61410b8587648d15088e32b6dcdeadbe46a9898fca65ffa6fdee35539b4b1e19ee81d6432e91987be3dc2a32e6c813272db4ed50668783759bc2a577828ea1ce5e4900ead25f5b90f9f56ddf4c0d0a'O;
      var Oct16 v_exp_hash := 'BFB2998BBC413736505B4AA5F6B8FC4A'O;
      var Oct32 v_hash;

      v_hash := f_hashWithSha256(v_test);

      log(match(substr(v_hash, 0, 16), v_exp_hash));
      if (match(substr(v_hash, 0, 16), v_exp_hash) == false) {
        setverdict(fail);
      } else {
        setverdict(pass);
      }
    } // End of testcase tc_sha256_2

garciay's avatar
garciay committed
217
218
219
220
221
222
223
224
225
226
227
228
    testcase tc_sha384_1() runs on TCType system TCType {
      var octetstring v_test := '616263'O;
      var Oct48 v_exp_hash := 'CB00753F45A35E8BB5A03D699AC65007272C32AB0EDED1631A8B605A43FF5BED8086072BA1E7CC2358BAECA134C825A7'O;
      var Oct48 v_hash;

      v_hash := f_hashWithSha384(v_test);

      if (match(v_hash, v_exp_hash) == false) {
        setverdict(fail);
      } else {
        setverdict(pass);
      }
garciay's avatar
garciay committed
229
    } // End of testcase tc_sha384_1
garciay's avatar
garciay committed
230

231
232
233
234
235
236
237
238
239
240
241
242
243
244
    testcase tc_sha384_2() runs on TCType system TCType {
      var octetstring v_test := ''O;
      var Oct48 v_exp_hash := '38b060a751ac96384cd9327eb1b1e36a21fdb71114be07434c0cc7bf63f6e1da274edebfe76f65fbd51ad2f14898b95b'O; /* Hash of empty string */
      var Oct48 v_hash;

      v_hash := f_hashWithSha384(v_test);

      if (match(v_hash, v_exp_hash) == false) {
        setverdict(fail);
      } else {
        setverdict(pass);
      }
    } // End of testcase tc_sha384_2

garciay's avatar
garciay committed
245
246
247
248
    testcase tc_f_generate_key_pair_1() runs on TCType system TCType {
      var Oct32 v_private_key;
      var Oct32 v_publicKeyX;
      var Oct32 v_publicKeyY;
249
250
      var Oct32 v_publicKeyCompressed;
      var integer v_compressedMode;
garciay's avatar
garciay committed
251

252
      if (f_generate_key_pair_nistp256(v_private_key, v_publicKeyX, v_publicKeyY, v_publicKeyCompressed, v_compressedMode) == false) {
garciay's avatar
garciay committed
253
254
255
256
257
258
        setverdict(fail);
        stop;
      }
      log("v_private_key = ", v_private_key);
      log("v_public_key X= ", v_publicKeyX);
      log("v_public_key Y= ", v_publicKeyY);
259
      log("v_public_key compressed= ", v_publicKeyCompressed, v_compressedMode);
garciay's avatar
garciay committed
260
      
garciay's avatar
garciay committed
261
      setverdict(pass);
garciay's avatar
garciay committed
262
    } // End of testcase tc_f_generate_key_pair_1
garciay's avatar
garciay committed
263

garciay's avatar
garciay committed
264
265
266
267
    testcase tc_f_generate_key_pair_2() runs on TCType system TCType {
      var Oct32 v_private_key;
      var Oct32 v_publicKeyX;
      var Oct32 v_publicKeyY;
268
269
      var Oct32 v_publicKeyCompressed;
      var integer v_compressedMode;
garciay's avatar
garciay committed
270

271
      if (f_generate_key_pair_brainpoolp256(v_private_key, v_publicKeyX, v_publicKeyY, v_publicKeyCompressed, v_compressedMode) == false) {
garciay's avatar
garciay committed
272
273
274
275
276
277
        setverdict(fail);
        stop;
      }
      log("v_private_key = ", v_private_key);
      log("v_public_key X= ", v_publicKeyX);
      log("v_public_key Y= ", v_publicKeyY);
278
      log("v_public_key compressed= ", v_publicKeyCompressed, v_compressedMode);
garciay's avatar
garciay committed
279
280
      
      setverdict(pass);
garciay's avatar
garciay committed
281
    } // End of testcase tc_f_generate_key_pair_2
garciay's avatar
garciay committed
282
283
284
285
286

    testcase tc_f_generate_key_pair_3() runs on TCType system TCType {
      var Oct48 v_private_key;
      var Oct48 v_publicKeyX;
      var Oct48 v_publicKeyY;
287
288
      var Oct48 v_publicKeyCompressed;
      var integer v_compressedMode;
garciay's avatar
garciay committed
289

290
      if (f_generate_key_pair_brainpoolp384(v_private_key, v_publicKeyX, v_publicKeyY, v_publicKeyCompressed, v_compressedMode) == false) {
garciay's avatar
garciay committed
291
292
293
294
295
296
        setverdict(fail);
        stop;
      }
      log("v_private_key = ", v_private_key);
      log("v_public_key X= ", v_publicKeyX);
      log("v_public_key Y= ", v_publicKeyY);
297
      log("v_public_key compressed= ", v_publicKeyCompressed, v_compressedMode);
garciay's avatar
garciay committed
298
299
      
      setverdict(pass);
garciay's avatar
garciay committed
300
    } // End of testcase tc_f_generate_key_pair_3
garciay's avatar
garciay committed
301

garciay's avatar
garciay committed
302
303
304
    testcase tc_f_signWithEcdsaNistp256WithSha256_1() runs on TCType system TCType {
      var Oct32 v_private_key;
      var Oct32 v_publicKeyX;
305
306
      var Oct32 v_publicKeyCompressed;
      var integer v_compressedMode;
garciay's avatar
garciay committed
307
308
309
310
      var Oct32 v_publicKeyY;
      var octetstring v_encMsg := '0A0A0102030405060708090A0B0C0D0E0F0A0A'O; 
      var octetstring v_sig := ''O;

311
      if (f_generate_key_pair_nistp256(v_private_key, v_publicKeyX, v_publicKeyY, v_publicKeyCompressed, v_compressedMode) == false) {
garciay's avatar
garciay committed
312
313
314
315
316
317
        setverdict(fail);
        stop;
      }
      log("v_private_key = ", v_private_key);
      log("v_public_key X= ", v_publicKeyX);
      log("v_public_key Y= ", v_publicKeyY);
318
      log("v_public_key compressed= ", v_publicKeyCompressed, v_compressedMode);
garciay's avatar
garciay committed
319
        
320
      v_sig := f_signWithEcdsaNistp256WithSha256(v_encMsg, int2oct(10, 32), v_private_key);  
garciay's avatar
garciay committed
321
322
323
324
325
326
      if (lengthof(v_sig) == 0) {
        setverdict(fail);
        stop;
      }
      
      setverdict(pass);
garciay's avatar
garciay committed
327
    } // End of testcase tc_f_signWithEcdsaNistp256WithSha256_1
garciay's avatar
garciay committed
328
329
330
331
332

    testcase tc_f_verifyWithEcdsaNistp256WithSha256_1() runs on TCType system TCType {
      var Oct32 v_private_key;
      var Oct32 v_publicKeyX;
      var Oct32 v_publicKeyY;
333
334
      var Oct32 v_publicKeyCompressed;
      var integer v_compressedMode;
garciay's avatar
garciay committed
335
336
337
      var octetstring v_encMsg := '0A0A0102030405060708090A0B0C0D0E0F0A0A'O; 
      var octetstring v_sig := ''O;

338
      if (f_generate_key_pair_nistp256(v_private_key, v_publicKeyX, v_publicKeyY, v_publicKeyCompressed, v_compressedMode) == false) {
garciay's avatar
garciay committed
339
340
341
342
343
344
        setverdict(fail);
        stop;
      }
      log("v_private_key = ", v_private_key);
      log("v_public_key X= ", v_publicKeyX);
      log("v_public_key Y= ", v_publicKeyY);
345
      log("v_public_key compressed= ", v_publicKeyCompressed, v_compressedMode);
garciay's avatar
garciay committed
346
        
347
      v_sig := f_signWithEcdsaNistp256WithSha256(v_encMsg, int2oct(10, 32), v_private_key);  
garciay's avatar
garciay committed
348
349
350
351
352
      if (lengthof(v_sig) == 0) {
        setverdict(fail);
        stop;
      }
      
353
      if (f_verifyWithEcdsaNistp256WithSha256(v_encMsg, int2oct(10, 32), v_sig, v_publicKeyCompressed, v_compressedMode) == false) {
354
355
356
357
        setverdict(fail);
      } else {
        setverdict(pass);
      }
358
      if (f_verifyWithEcdsaNistp256WithSha256_1(v_encMsg, int2oct(10, 32), v_sig, v_publicKeyX, v_publicKeyY) == false) {
garciay's avatar
garciay committed
359
360
361
362
        setverdict(fail);
      } else {
        setverdict(pass);
      }
garciay's avatar
garciay committed
363
    } // End of testcase tc_f_verifyWithEcdsaNistp256WithSha256_1
garciay's avatar
garciay committed
364
365
366
367
368

    testcase tc_f_verifyWithEcdsaNistp256WithSha256_2() runs on TCType system TCType {
      var Oct32 v_private_key;
      var Oct32 v_publicKeyX;
      var Oct32 v_publicKeyY;
369
370
371
      var Oct32 v_publicKeyCompressed;
      var integer v_compressedMode;
      var octetstring v_private_key_wrong;
garciay's avatar
garciay committed
372
373
374
      var octetstring v_encMsg := '0A0A0102030405060708090A0B0C0D0E0F0A0A'O; 
      var octetstring v_sig := ''O;

375
      if (f_generate_key_pair_nistp256(v_private_key, v_publicKeyX, v_publicKeyY, v_publicKeyCompressed, v_compressedMode) == false) {
garciay's avatar
garciay committed
376
377
378
379
380
381
        setverdict(fail);
        stop;
      }
      log("v_private_key = ", v_private_key);
      log("v_public_key X= ", v_publicKeyX);
      log("v_public_key Y= ", v_publicKeyY);
382
      log("v_public_key compressed= ", v_publicKeyCompressed, v_compressedMode);
garciay's avatar
garciay committed
383
384
385
      
      v_private_key_wrong := v_private_key;
        
386
      v_sig := f_signWithEcdsaNistp256WithSha256(v_encMsg, int2oct(10, 32), v_private_key);  
garciay's avatar
garciay committed
387
388
389
390
391
      if (lengthof(v_sig) == 0) {
        setverdict(fail);
        stop;
      }
      
392
      if (f_verifyWithEcdsaNistp256WithSha256(v_encMsg, int2oct(10, 32), v_sig, v_publicKeyCompressed, v_compressedMode) == false) {
393
394
395
396
        setverdict(fail);
      } else {
        setverdict(pass);
      }
397
      if (f_verifyWithEcdsaNistp256WithSha256_1(v_encMsg, int2oct(10, 32), v_sig, v_publicKeyX, v_publicKeyY) == false) {
garciay's avatar
garciay committed
398
399
400
401
402
403
404
        setverdict(fail);
        stop;
      } else {
        setverdict(pass);
      }
      
      v_private_key_wrong[2] := 'AA'O;
405
      v_private_key_wrong[3] := 'BB'O;
406
407
      v_sig := f_signWithEcdsaNistp256WithSha256(v_encMsg, int2oct(10, 32), v_private_key_wrong);  
      if (f_verifyWithEcdsaNistp256WithSha256(v_encMsg, int2oct(10, 32), v_sig, v_publicKeyCompressed, v_compressedMode) == true) {
garciay's avatar
garciay committed
408
        setverdict(fail);
409
410
      } else {
        setverdict(pass);
garciay's avatar
garciay committed
411
      }
412
      if (f_verifyWithEcdsaNistp256WithSha256_1(v_encMsg, int2oct(10, 32), v_sig, v_publicKeyX, v_publicKeyY) == true) {
garciay's avatar
garciay committed
413
414
415
416
        setverdict(fail);
      } else {
        setverdict(pass);
      }
garciay's avatar
garciay committed
417
    } // End of testcase tc_f_verifyWithEcdsaNistp256WithSha256_2
garciay's avatar
garciay committed
418
419
420
421
422

    testcase tc_f_verifyWithEcdsaNistp256WithSha256_3() runs on TCType system TCType {
      var Oct32 v_private_key;
      var Oct32 v_publicKeyX;
      var Oct32 v_publicKeyY;
423
424
      var Oct32 v_publicKeyCompressed;
      var integer v_compressedMode;
garciay's avatar
garciay committed
425
426
427
428
429
430
      var octetstring v_encMsg := '0A0A0102030405060708090A0B0C0D0E0F0A0A'O; 
      var octetstring v_sig := ''O;
      var octetstring v_sig_wrong := ''O;
      var Oct32 v_publicKeyX_wrong;
      var Oct32 v_publicKeyY_wrong;

431
      if (f_generate_key_pair_nistp256(v_private_key, v_publicKeyX, v_publicKeyY, v_publicKeyCompressed, v_compressedMode) == false) {
garciay's avatar
garciay committed
432
433
434
435
436
437
        setverdict(fail);
        stop;
      }
      log("v_private_key = ", v_private_key);
      log("v_public_key X= ", v_publicKeyX);
      log("v_public_key Y= ", v_publicKeyY);
438
      log("v_public_key compressed= ", v_publicKeyCompressed, v_compressedMode);
garciay's avatar
garciay committed
439
        
440
441
      v_sig := f_signWithEcdsaNistp256WithSha256(v_encMsg, int2oct(10, 32), v_private_key);  
      if (f_verifyWithEcdsaNistp256WithSha256_1(v_encMsg, int2oct(10, 32), v_sig, v_publicKeyX, v_publicKeyY) == false) {
garciay's avatar
garciay committed
442
443
        setverdict(fail);
        stop;
444
445
      } else {
        setverdict(pass);
garciay's avatar
garciay committed
446
447
      }
      
448
      if (f_verifyWithEcdsaNistp256WithSha256_1('0A0A0A0A'O, int2oct(10, 32), v_sig, v_publicKeyX, v_publicKeyY) == true) {
garciay's avatar
garciay committed
449
450
        setverdict(fail);
        stop;
451
452
      } else {
        setverdict(pass);
garciay's avatar
garciay committed
453
454
455
456
      }
      
      v_sig_wrong := v_sig;
      v_sig_wrong[0] := 'FF'O;
457
      if (f_verifyWithEcdsaNistp256WithSha256(v_encMsg, int2oct(10, 32), v_sig_wrong, v_publicKeyCompressed, v_compressedMode) == true) {
458
        setverdict(fail);
459
460
      } else {
        setverdict(pass);
461
      }
462
      if (f_verifyWithEcdsaNistp256WithSha256_1(v_encMsg, int2oct(10, 32), v_sig_wrong, v_publicKeyX, v_publicKeyY) == true) {
garciay's avatar
garciay committed
463
464
        setverdict(fail);
        stop;
465
466
      } else {
        setverdict(pass);
garciay's avatar
garciay committed
467
468
      }
      
469
470
      v_publicKeyX_wrong := v_publicKeyCompressed;
      v_publicKeyX_wrong[0] := 'FF'O;
471
      if (f_verifyWithEcdsaNistp256WithSha256(v_encMsg, int2oct(10, 32), v_sig_wrong, v_publicKeyCompressed, v_compressedMode) == true) {
472
473
        setverdict(fail);
      }
garciay's avatar
garciay committed
474
475
      v_publicKeyX_wrong := v_publicKeyX;
      v_publicKeyX_wrong[0] := 'FF'O;
476
      if (f_verifyWithEcdsaNistp256WithSha256_1(v_encMsg, int2oct(10, 32), v_sig, v_publicKeyX_wrong, v_publicKeyY) == true) {
garciay's avatar
garciay committed
477
478
479
480
481
482
        setverdict(fail);
        stop;
      }
      
      v_publicKeyY_wrong := v_publicKeyY;
      v_publicKeyY_wrong[0] := 'FF'O;
483
      if (f_verifyWithEcdsaNistp256WithSha256_1(v_encMsg, int2oct(10, 32), v_sig, v_publicKeyX, v_publicKeyY_wrong) == true) {
garciay's avatar
garciay committed
484
485
486
487
488
        setverdict(fail);
        stop;
      }
      
      setverdict(pass);
garciay's avatar
garciay committed
489
    } // End of testcase tc_f_verifyWithEcdsaNistp256WithSha256_3
garciay's avatar
garciay committed
490

Yann Garcia's avatar
Yann Garcia committed
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
    /**
     * @desc Check sign/verify signature on raw data
     * @remark To check result, use this Web sites: https://www.javacardos.com/tools/ecdsa-sign-verify, https://kjur.github.io/jsrsasign/sample/sample-ecdsa.html
     */
    testcase tc_f_verifyWithEcdsaNistp256WithSha256_4() runs on TCType system TCType {
      var Oct32 v_private_key := '69674ea17f88ae0e30b04cddb00abc6bf4e65db757752b1e5fe3f8bdbfb60e79'O;
      var Oct32 v_publicKeyCompressed := '8a5037fa359ccb0c3437ab1451cedce10cb13a1f82658c1d985fc994d55df340'O;
      var integer v_compressedMode := 0;
      var octetstring v_message := '616161'O;
      var octetstring v_sig := ''O;

      log("v_private_key = ", v_private_key);
      log("v_public_key compressed= ", v_publicKeyCompressed, " - ", v_compressedMode);

      v_sig := fx_test_signWithEcdsaNistp256WithSha256(v_message, v_private_key);
      log("Signature: ", v_sig);
      if (fx_test_verifyWithEcdsaNistp256WithSha256(v_message, v_sig, v_publicKeyCompressed, v_compressedMode) == true) {
        setverdict(pass, "Signature was verified");
      } else {
        setverdict(fail, "Signature wasn't verified");
      }
    } // End of testcase tc_f_verifyWithEcdsaNistp256WithSha256_4

garciay's avatar
garciay committed
514
515
516
517
    testcase tc_f_signWithEcdsaBrainpoolp256WithSha256_1() runs on TCType system TCType {
      var Oct32 v_private_key;
      var Oct32 v_publicKeyX;
      var Oct32 v_publicKeyY;
518
519
      var Oct32 v_publicKeyCompressed;
      var integer v_compressedMode;
garciay's avatar
garciay committed
520
521
522
      var octetstring v_encMsg := '0A0A0102030405060708090A0B0C0D0E0F0A0A'O; 
      var octetstring v_sig := ''O;

523
      if (f_generate_key_pair_brainpoolp256(v_private_key, v_publicKeyX, v_publicKeyY, v_publicKeyCompressed, v_compressedMode) == false) {
garciay's avatar
garciay committed
524
525
526
527
528
529
        setverdict(fail);
        stop;
      }
      log("v_private_key = ", v_private_key);
      log("v_public_key X= ", v_publicKeyX);
      log("v_public_key Y= ", v_publicKeyY);
530
      log("v_public_key compressed= ", v_publicKeyCompressed, v_compressedMode);
garciay's avatar
garciay committed
531
        
532
      v_sig := f_signWithEcdsaBrainpoolp256WithSha256(v_encMsg, int2oct(10, 32), v_private_key);  
garciay's avatar
garciay committed
533
534
535
536
537
538
      if (lengthof(v_sig) == 0) {
        setverdict(fail);
        stop;
      }
      
      setverdict(pass);
garciay's avatar
garciay committed
539
    } // End of testcase tc_f_signWithEcdsaBrainpoolp256WithSha256_1
garciay's avatar
garciay committed
540

garciay's avatar
garciay committed
541
542
543
544
    testcase tc_f_signWithEcdsaBrainpoolp384WithSha384_1() runs on TCType system TCType {
      var Oct48 v_private_key;
      var Oct48 v_publicKeyX;
      var Oct48 v_publicKeyY;
545
546
      var Oct48 v_publicKeyCompressed;
      var integer v_compressedMode;
garciay's avatar
garciay committed
547
548
549
      var octetstring v_encMsg := '0A0A0102030405060708090A0B0C0D0E0F0A0A'O; 
      var octetstring v_sig := ''O;

550
      if (f_generate_key_pair_brainpoolp384(v_private_key, v_publicKeyX, v_publicKeyY, v_publicKeyCompressed, v_compressedMode) == false) {
garciay's avatar
garciay committed
551
552
553
554
555
556
        setverdict(fail);
        stop;
      }
      log("v_private_key = ", v_private_key);
      log("v_public_key X= ", v_publicKeyX);
      log("v_public_key Y= ", v_publicKeyY);
557
      log("v_public_key compressed= ", v_publicKeyCompressed, v_compressedMode);
garciay's avatar
garciay committed
558
        
559
      v_sig := f_signWithEcdsaBrainpoolp384WithSha384(v_encMsg, int2oct(10, 48), v_private_key);  
garciay's avatar
garciay committed
560
561
562
563
564
565
      if (lengthof(v_sig) == 0) {
        setverdict(fail);
        stop;
      }
      
      setverdict(pass);
garciay's avatar
garciay committed
566
    } // End of testcase tc_f_signWithEcdsaBrainpoolp384WithSha384_1
garciay's avatar
garciay committed
567
568
569
570
571

    testcase tc_f_verifyWithEcdsaBrainpoolp256WithSha256_1() runs on TCType system TCType {
      var Oct32 v_private_key;
      var Oct32 v_publicKeyX;
      var Oct32 v_publicKeyY;
572
573
      var Oct32 v_publicKeyCompressed;
      var integer v_compressedMode;
garciay's avatar
garciay committed
574
575
576
      var octetstring v_encMsg := '0A0A0102030405060708090A0B0C0D0E0F0A0A'O; 
      var octetstring v_sig := ''O;

577
      if (f_generate_key_pair_brainpoolp256(v_private_key, v_publicKeyX, v_publicKeyY, v_publicKeyCompressed, v_compressedMode) == false) {
garciay's avatar
garciay committed
578
579
580
581
582
583
        setverdict(fail);
        stop;
      }
      log("v_private_key = ", v_private_key);
      log("v_public_key X= ", v_publicKeyX);
      log("v_public_key Y= ", v_publicKeyY);
584
      log("v_public_key compressed= ", v_publicKeyCompressed, v_compressedMode);
garciay's avatar
garciay committed
585
        
586
      v_sig := f_signWithEcdsaBrainpoolp256WithSha256(v_encMsg, int2oct(10, 32), v_private_key);  
garciay's avatar
garciay committed
587
588
589
590
591
      if (lengthof(v_sig) == 0) {
        setverdict(fail);
        stop;
      }
      
592
      if (f_verifyWithEcdsaBrainpoolp256WithSha256(v_encMsg, int2oct(10, 32), v_sig, v_publicKeyCompressed, v_compressedMode) == false) {
593
594
595
596
        setverdict(fail);
      } else {
        setverdict(pass);
      }
597
      if (f_verifyWithEcdsaBrainpoolp256WithSha256_1(v_encMsg, int2oct(10, 32), v_sig, v_publicKeyX, v_publicKeyY) == false) {
garciay's avatar
garciay committed
598
599
600
601
        setverdict(fail);
      } else {
        setverdict(pass);
      }
garciay's avatar
garciay committed
602
    } // End of testcase tc_f_verifyWithEcdsaBrainpoolp256WithSha256_1
garciay's avatar
garciay committed
603
604
605
606
607

    testcase tc_f_verifyWithEcdsaBrainpoolp256WithSha256_2() runs on TCType system TCType {
      var Oct32 v_private_key;
      var Oct32 v_publicKeyX;
      var Oct32 v_publicKeyY;
608
609
610
      var Oct32 v_publicKeyCompressed;
      var integer v_compressedMode;
      var octetstring v_private_key_wrong;
garciay's avatar
garciay committed
611
612
613
      var octetstring v_encMsg := '0A0A0102030405060708090A0B0C0D0E0F0A0A'O; 
      var octetstring v_sig := ''O;

614
      if (f_generate_key_pair_brainpoolp256(v_private_key, v_publicKeyX, v_publicKeyY, v_publicKeyCompressed, v_compressedMode) == false) {
garciay's avatar
garciay committed
615
616
617
618
619
620
        setverdict(fail);
        stop;
      }
      log("v_private_key = ", v_private_key);
      log("v_public_key X= ", v_publicKeyX);
      log("v_public_key Y= ", v_publicKeyY);
621
      log("v_public_key compressed= ", v_publicKeyCompressed, v_compressedMode);
garciay's avatar
garciay committed
622
623
624
      
      v_private_key_wrong := v_private_key;
        
625
      v_sig := f_signWithEcdsaBrainpoolp256WithSha256(v_encMsg, int2oct(10, 32), v_private_key);  
garciay's avatar
garciay committed
626
627
628
629
630
      if (lengthof(v_sig) == 0) {
        setverdict(fail);
        stop;
      }
      
631
      if (f_verifyWithEcdsaBrainpoolp256WithSha256(v_encMsg, int2oct(10, 32), v_sig, v_publicKeyCompressed, v_compressedMode) == false) {
632
633
634
635
        setverdict(fail);
      } else {
        setverdict(pass);
      }
636
      if (f_verifyWithEcdsaBrainpoolp256WithSha256_1(v_encMsg, int2oct(10, 32), v_sig, v_publicKeyX, v_publicKeyY) == false) {
garciay's avatar
garciay committed
637
638
639
640
641
642
        setverdict(fail);
      } else {
        setverdict(pass);
      }
      
      v_private_key_wrong[2] := 'AA'O;
643
644
      v_sig := f_signWithEcdsaBrainpoolp256WithSha256(v_encMsg, int2oct(10, 32), v_private_key_wrong);  
      if (f_verifyWithEcdsaBrainpoolp256WithSha256(v_encMsg, int2oct(10, 32), v_sig, v_publicKeyCompressed, v_compressedMode) == true) {
garciay's avatar
garciay committed
645
        setverdict(fail);
646
647
      } else {
        setverdict(pass);
garciay's avatar
garciay committed
648
      }
649
      if (f_verifyWithEcdsaBrainpoolp256WithSha256_1(v_encMsg, int2oct(10, 32), v_sig, v_publicKeyX, v_publicKeyY) == true) {
garciay's avatar
garciay committed
650
651
652
653
        setverdict(fail);
      } else {
        setverdict(pass);
      }
garciay's avatar
garciay committed
654
    } // End of testcase tc_f_verifyWithEcdsaBrainpoolp256WithSha256_2
garciay's avatar
garciay committed
655
656
657
658
659

    testcase tc_f_verifyWithEcdsaBrainpoolp256WithSha256_3() runs on TCType system TCType {
      var Oct32 v_private_key;
      var Oct32 v_publicKeyX;
      var Oct32 v_publicKeyY;
660
661
      var Oct32 v_publicKeyCompressed;
      var integer v_compressedMode;
garciay's avatar
garciay committed
662
663
664
665
666
667
      var octetstring v_encMsg := '0A0A0102030405060708090A0B0C0D0E0F0A0A'O; 
      var octetstring v_sig := ''O;
      var octetstring v_sig_wrong := ''O;
      var Oct32 v_publicKeyX_wrong;
      var Oct32 v_publicKeyY_wrong;

668
      if (f_generate_key_pair_brainpoolp256(v_private_key, v_publicKeyX, v_publicKeyY, v_publicKeyCompressed, v_compressedMode) == false) {
garciay's avatar
garciay committed
669
670
671
672
673
674
        setverdict(fail);
        stop;
      }
      log("v_private_key = ", v_private_key);
      log("v_public_key X= ", v_publicKeyX);
      log("v_public_key Y= ", v_publicKeyY);
675
      log("v_public_key compressed= ", v_publicKeyCompressed, v_compressedMode);
garciay's avatar
garciay committed
676
        
677
678
      v_sig := f_signWithEcdsaBrainpoolp256WithSha256(v_encMsg, int2oct(10, 32), v_private_key);  
      if (f_verifyWithEcdsaBrainpoolp256WithSha256_1(v_encMsg, int2oct(10, 32), v_sig, v_publicKeyX, v_publicKeyY) == false) {
garciay's avatar
garciay committed
679
        setverdict(fail);
680
681
      } else {
        setverdict(pass);
garciay's avatar
garciay committed
682
683
      }
      
684
      if (f_verifyWithEcdsaBrainpoolp256WithSha256_1('0A0A0A0A'O, int2oct(10, 32), v_sig, v_publicKeyX, v_publicKeyY) == true) {
garciay's avatar
garciay committed
685
        setverdict(fail);
686
687
      } else {
        setverdict(pass);
garciay's avatar
garciay committed
688
689
690
691
      }
      
      v_sig_wrong := v_sig;
      v_sig_wrong[0] := 'FF'O;
692
      if (f_verifyWithEcdsaBrainpoolp256WithSha256_1(v_encMsg, int2oct(10, 32), v_sig_wrong, v_publicKeyX, v_publicKeyY) == true) {
garciay's avatar
garciay committed
693
        setverdict(fail);
694
695
      } else {
        setverdict(pass);
garciay's avatar
garciay committed
696
697
698
699
      }
      
      v_publicKeyX_wrong := v_publicKeyX;
      v_publicKeyX_wrong[0] := 'FF'O;
700
      if (f_verifyWithEcdsaBrainpoolp256WithSha256_1(v_encMsg, int2oct(10, 32), v_sig, v_publicKeyX_wrong, v_publicKeyY) == true) {
garciay's avatar
garciay committed
701
702
703
704
705
        setverdict(fail);
      }
      
      v_publicKeyY_wrong := v_publicKeyY;
      v_publicKeyY_wrong[0] := 'FF'O;
706
      if (f_verifyWithEcdsaBrainpoolp256WithSha256_1(v_encMsg, int2oct(10, 32), v_sig, v_publicKeyX, v_publicKeyY_wrong) == true) {
garciay's avatar
garciay committed
707
708
709
710
        setverdict(fail);
      }
      
      setverdict(pass);
garciay's avatar
garciay committed
711
    } // End of testcase tc_f_verifyWithEcdsaBrainpoolp256WithSha256_3
garciay's avatar
garciay committed
712
713
714
715
716

    testcase tc_f_verifyWithEcdsaBrainpoolp384WithSha384_1() runs on TCType system TCType {
      var Oct48 v_private_key;
      var Oct48 v_publicKeyX;
      var Oct48 v_publicKeyY;
717
718
      var Oct48 v_publicKeyCompressed;
      var integer v_compressedMode;
garciay's avatar
garciay committed
719
720
721
      var octetstring v_encMsg := '0A0A0102030405060708090A0B0C0D0E0F0A0A'O; 
      var octetstring v_sig := ''O;

722
      if (f_generate_key_pair_brainpoolp384(v_private_key, v_publicKeyX, v_publicKeyY, v_publicKeyCompressed, v_compressedMode) == false) {
garciay's avatar
garciay committed
723
724
725
726
727
728
        setverdict(fail);
        stop;
      }
      log("v_private_key = ", v_private_key);
      log("v_public_key X= ", v_publicKeyX);
      log("v_public_key Y= ", v_publicKeyY);
729
      log("v_public_key compressed= ", v_publicKeyCompressed, v_compressedMode);
garciay's avatar
garciay committed
730
        
731
      v_sig := f_signWithEcdsaBrainpoolp384WithSha384(v_encMsg, int2oct(10, 48), v_private_key);  
garciay's avatar
garciay committed
732
733
734
735
736
      if (lengthof(v_sig) == 0) {
        setverdict(fail);
        stop;
      }
      
737
      if (f_verifyWithEcdsaBrainpoolp384WithSha384(v_encMsg, int2oct(10, 48), v_sig, v_publicKeyCompressed, v_compressedMode) == false) {
738
739
740
741
        setverdict(fail);
      } else {
        setverdict(pass);
      }
742
      if (f_verifyWithEcdsaBrainpoolp384WithSha384_1(v_encMsg, int2oct(10, 48), v_sig, v_publicKeyX, v_publicKeyY) == false) {
garciay's avatar
garciay committed
743
744
745
746
        setverdict(fail);
      } else {
        setverdict(pass);
      }
garciay's avatar
garciay committed
747
    } // End of testcase tc_f_verifyWithEcdsaBrainpoolp384WithSha384_1
garciay's avatar
garciay committed
748
749
750
751
752

    testcase tc_f_verifyWithEcdsaBrainpoolp384WithSha384_2() runs on TCType system TCType {
      var Oct48 v_private_key;
      var Oct48 v_publicKeyX;
      var Oct48 v_publicKeyY;
753
754
      var Oct48 v_publicKeyCompressed;
      var integer v_compressedMode;
garciay's avatar
garciay committed
755
756
757
758
      var Oct48 v_private_key_wrong;
      var octetstring v_encMsg := '0A0A0102030405060708090A0B0C0D0E0F0A0A'O; 
      var octetstring v_sig := ''O;

759
      if (f_generate_key_pair_brainpoolp384(v_private_key, v_publicKeyX, v_publicKeyY, v_publicKeyCompressed, v_compressedMode) == false) {
garciay's avatar
garciay committed
760
761
762
763
764
765
        setverdict(fail);
        stop;
      }
      log("v_private_key = ", v_private_key);
      log("v_public_key X= ", v_publicKeyX);
      log("v_public_key Y= ", v_publicKeyY);
766
      log("v_public_key compressed= ", v_publicKeyCompressed, v_compressedMode);
garciay's avatar
garciay committed
767
768
769
      
      v_private_key_wrong := v_private_key;
        
770
      v_sig := f_signWithEcdsaBrainpoolp384WithSha384(v_encMsg, int2oct(10, 48), v_private_key);  
garciay's avatar
garciay committed
771
772
773
774
775
      if (lengthof(v_sig) == 0) {
        setverdict(fail);
        stop;
      }
      
776
      if (f_verifyWithEcdsaBrainpoolp384WithSha384(v_encMsg, int2oct(10, 48), v_sig, v_publicKeyCompressed, v_compressedMode) == false) {
777
778
779
780
        setverdict(fail);
      } else {
        setverdict(pass);
      }
781
      if (f_verifyWithEcdsaBrainpoolp384WithSha384_1(v_encMsg, int2oct(10, 48), v_sig, v_publicKeyX, v_publicKeyY) == false) {
garciay's avatar
garciay committed
782
783
784
785
786
787
        setverdict(fail);
      } else {
        setverdict(pass);
      }
      
      v_private_key_wrong[2] := 'AA'O;
788
      v_sig := f_signWithEcdsaBrainpoolp384WithSha384(v_encMsg, int2oct(10, 48), v_private_key_wrong);  
789

790
      if (f_verifyWithEcdsaBrainpoolp384WithSha384(v_encMsg, int2oct(10, 48), v_sig, v_publicKeyCompressed, v_compressedMode) == true) {
garciay's avatar
garciay committed
791
        setverdict(fail);
792
793
      } else {
        setverdict(pass);
garciay's avatar
garciay committed
794
      }
795
      if (f_verifyWithEcdsaBrainpoolp384WithSha384_1(v_encMsg, int2oct(10, 48), v_sig, v_publicKeyX, v_publicKeyY) == true) {
garciay's avatar
garciay committed
796
797
798
799
        setverdict(fail);
      } else {
        setverdict(pass);
      }
garciay's avatar
garciay committed
800
    } // End of testcase tc_f_verifyWithEcdsaBrainpoolp384WithSha384_2
garciay's avatar
garciay committed
801
802
803
804
805

    testcase tc_f_verifyWithEcdsaBrainpoolp384WithSha384_3() runs on TCType system TCType {
      var Oct48 v_private_key;
      var Oct48 v_publicKeyX;
      var Oct48 v_publicKeyY;
806
807
      var Oct48 v_publicKeyCompressed;
      var integer v_compressedMode;
garciay's avatar
garciay committed
808
809
810
811
812
813
      var octetstring v_encMsg := '0A0A0102030405060708090A0B0C0D0E0F0A0A'O; 
      var octetstring v_sig := ''O;
      var octetstring v_sig_wrong := ''O;
      var Oct48 v_publicKeyX_wrong;
      var Oct48 v_publicKeyY_wrong;

814
      if (f_generate_key_pair_brainpoolp384(v_private_key, v_publicKeyX, v_publicKeyY, v_publicKeyCompressed, v_compressedMode) == false) {
garciay's avatar
garciay committed
815
816
817
818
819
820
        setverdict(fail);
        stop;
      }
      log("v_private_key = ", v_private_key);
      log("v_public_key X= ", v_publicKeyX);
      log("v_public_key Y= ", v_publicKeyY);
821
      log("v_public_key compressed= ", v_publicKeyCompressed, v_compressedMode);
garciay's avatar
garciay committed
822
        
823
824
      v_sig := f_signWithEcdsaBrainpoolp384WithSha384(v_encMsg, int2oct(10, 48), v_private_key);  
      if (f_verifyWithEcdsaBrainpoolp384WithSha384(v_encMsg, int2oct(10, 48), v_sig, v_publicKeyCompressed, v_compressedMode) == false) {
825
        setverdict(fail);
826
827
      } else {
        setverdict(pass);
828
      }
829
      if (f_verifyWithEcdsaBrainpoolp384WithSha384_1(v_encMsg, int2oct(10, 48), v_sig, v_publicKeyX, v_publicKeyY) == false) {
garciay's avatar
garciay committed
830
        setverdict(fail);
831
832
      } else {
        setverdict(pass);
garciay's avatar
garciay committed
833
834
      }
      
835
      if (f_verifyWithEcdsaBrainpoolp384WithSha384_1('0A0A0A0A'O, int2oct(10, 48), v_sig, v_publicKeyX, v_publicKeyY) == true) {
garciay's avatar
garciay committed
836
        setverdict(fail);
837
838
      } else {
        setverdict(pass);
garciay's avatar
garciay committed
839
840
841
842
      }
      
      v_sig_wrong := v_sig;
      v_sig_wrong[0] := 'FF'O;
843
      if (f_verifyWithEcdsaBrainpoolp384WithSha384_1(v_encMsg, int2oct(10, 48), v_sig_wrong, v_publicKeyX, v_publicKeyY) == true) {
garciay's avatar
garciay committed
844
        setverdict(fail);
845
846
      } else {
        setverdict(pass);
garciay's avatar
garciay committed
847
848
      }
      
849
850
      v_publicKeyX_wrong := v_publicKeyCompressed;
      v_publicKeyX_wrong[0] := 'FF'O;
851
      if (f_verifyWithEcdsaBrainpoolp384WithSha384(v_encMsg, int2oct(10, 48), v_sig, v_publicKeyX_wrong, v_compressedMode) == true) {
852
        setverdict(fail);
853
854
      } else {
        setverdict(pass);
855
      }
garciay's avatar
garciay committed
856
857
      v_publicKeyX_wrong := v_publicKeyX;
      v_publicKeyX_wrong[0] := 'FF'O;
858
      if (f_verifyWithEcdsaBrainpoolp384WithSha384_1(v_encMsg, int2oct(10, 48), v_sig, v_publicKeyX_wrong, v_publicKeyY) == true) {
garciay's avatar
garciay committed
859
860
861
862
863
        setverdict(fail);
      }
      
      v_publicKeyY_wrong := v_publicKeyY;
      v_publicKeyY_wrong[0] := 'FF'O;
864
      if (f_verifyWithEcdsaBrainpoolp384WithSha384_1(v_encMsg, int2oct(10, 48), v_sig, v_publicKeyX, v_publicKeyY_wrong) == true) {
garciay's avatar
garciay committed
865
866
867
868
        setverdict(fail);
      }
      
      setverdict(pass);
garciay's avatar
garciay committed
869
    } // End of testcase tc_f_verifyWithEcdsaBrainpoolp384WithSha384_3
870

garciay's avatar
garciay committed
871
    control {
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
      execute(tc_extract_and_store_certificate_1());
      execute(tc_sha256_1());
      execute(tc_sha384_1());
      execute(tc_f_generate_key_pair_1());
      execute(tc_f_generate_key_pair_2());
      execute(tc_f_generate_key_pair_3());
      execute(tc_f_signWithEcdsaNistp256WithSha256_1());
      execute(tc_f_verifyWithEcdsaNistp256WithSha256_1());
      execute(tc_f_verifyWithEcdsaNistp256WithSha256_2());
      execute(tc_f_verifyWithEcdsaNistp256WithSha256_3());
      execute(tc_f_signWithEcdsaBrainpoolp256WithSha256_1());
      execute(tc_f_signWithEcdsaBrainpoolp384WithSha384_1());
      execute(tc_f_verifyWithEcdsaBrainpoolp256WithSha256_1());
      execute(tc_f_verifyWithEcdsaBrainpoolp256WithSha256_2());
      execute(tc_f_verifyWithEcdsaBrainpoolp256WithSha256_3());
      execute(tc_f_verifyWithEcdsaBrainpoolp384WithSha384_1());
      execute(tc_f_verifyWithEcdsaBrainpoolp384WithSha384_2());
      execute(tc_f_verifyWithEcdsaBrainpoolp384WithSha384_3());
garciay's avatar
garciay committed
890
891
    }
    
garciay's avatar
garciay committed
892
} // End of module TestCodec_SecuredFuntions