Codebase list libcryptx-perl / 4663dbe
update wycheproof tests Karel Miko 5 years ago
1 changed file(s) with 19 addition(s) and 23 deletion(s). Raw diff Collapse all Expand all
77
88 plan skip_all => "No JSON::* module installed" unless eval { require JSON::PP } || eval { require JSON::XS } || eval { require Cpanel::JSON::XS };
99 #plan skip_all => "Temporarily disabled";
10 plan tests => 13299;
10 plan tests => 14139;
1111
1212 use CryptX;
1313 use Crypt::Misc 'read_rawfile';
1414 use Crypt::Digest 'digest_data';
1515
16 if (0) {
16 if (1) {
1717 use Crypt::AuthEnc::ChaCha20Poly1305 qw(chacha20poly1305_encrypt_authenticate chacha20poly1305_decrypt_verify);
1818
1919 my $tests = CryptX::_decode_json read_rawfile 't/wycheproof/chacha20_poly1305_test.json';
117117 }
118118 elsif ($result eq 'invalid') {
119119 SKIP: {
120 skip "ltc bug", 1 if $comment eq "bit padding"; #XXX-FIXME
121 skip "ltc bug", 1 if $comment eq "zero padding"; #XXX-FIXME
120 skip "ltc bug CBC/PAD", 1 if $comment eq "bit padding"; #XXX-FIXME
121 skip "ltc bug CBC/PAD", 1 if $comment eq "zero padding"; #XXX-FIXME
122122 is($pt2, undef, "$testname PT-i");
123123 }
124124 }
129129 }
130130 }
131131
132 if (0) {
132 if (1) {
133133 use Crypt::AuthEnc::GCM qw(gcm_encrypt_authenticate gcm_decrypt_verify);
134134
135135 my $tests = CryptX::_decode_json read_rawfile 't/wycheproof/aes_gcm_test.json';
243243 is(unpack("H*", $pt2), $t->{msg}, "$testname PT-a");
244244 }
245245 elsif ($result eq 'invalid') {
246 SKIP: {
247 skip "ltc bug", 1 if $comment eq "Invalid tag size"; #XXX-FIXME
248 is($pt2, undef, "$testname PT-i");
249 }
246 is($pt2, undef, "$testname PT-i");
250247 }
251248 else {
252249 ok(0, "UNEXPECTED result=$result");
257254
258255 if (1) {
259256 use Crypt::PK::RSA;
260 use Crypt::PK::ECC;
261257 my @files = ( "t/wycheproof/rsa_signature_test.json" );
262258 push @files, glob("t/wycheproof/rsa_signature_*_test.json");
263259 push @files, glob("t/wycheproof/rsa_pss_*.json ");
298294 }
299295 elsif ($result eq 'invalid') {
300296 SKIP: {
301 skip "ltc bug", 1 if $comment eq "changing tag value of sequence"; #XXX-FIXME
297 skip "ltc bug RSA", 1 if $comment eq "changing tag value of sequence"; #XXX-FIXME
302298 ok(!$valid, $testname);
303299 }
304300 }
347343 }
348344 elsif ($result eq 'invalid') {
349345 SKIP: {
350 skip "ltc bug", 1 if $comment eq "changing tag value of sequence"; #XXX-FIXME
346 skip "ltc bug DSA", 1 if $comment eq "changing tag value of sequence"; #XXX-FIXME
351347 ok(!$valid, $testname);
352348 }
353349 }
388384 my $valid = $pk->verify_message($sig, $message, $sha);
389385 if ($result eq 'valid') {
390386 SKIP: {
391 skip "ltc bug", 1 if $comment eq "Edge case for Shamir multiplication"; #XXX-FIXME
392 skip "ltc bug", 1 if $comment eq "extreme value for k and edgecase s"; #XXX-FIXME
393 skip "ltc bug", 1 if $comment eq "extreme value for k"; #XXX-FIXME
394 skip "ltc bug", 1 if $comment eq "extreme value for k and s^-1"; #XXX-FIXME
395 skip "ltc bug", 1 if $comment eq "extreme value for k and edgecase s"; #XXX-FIXME
387 skip "ltc bug ECC", 1 if $comment eq "Edge case for Shamir multiplication"; #XXX-FIXME
388 skip "ltc bug ECC", 1 if $comment eq "extreme value for k and edgecase s"; #XXX-FIXME
389 skip "ltc bug ECC", 1 if $comment eq "extreme value for k"; #XXX-FIXME
390 skip "ltc bug ECC", 1 if $comment eq "extreme value for k and s^-1"; #XXX-FIXME
391 skip "ltc bug ECC", 1 if $comment eq "extreme value for k and edgecase s"; #XXX-FIXME
396392 ok($valid, "$testname verify_message=$valid");
397393 }
398394 }
399395 elsif ($result eq 'acceptable') {
400396 SKIP: {
401 skip "ltc bug", 1 if $comment eq "Hash weaker than DL-group"; #XXX-FIXME
397 skip "ltc bug ECC", 1 if $comment eq "Hash weaker than DL-group"; #XXX-FIXME
402398 #ok($valid, "$testname verify_message=$valid"); ## treat "acceptable" as "valid"
403399 ok(!$valid, "$testname verify_message=$valid"); ## treat "acceptable" as "invalid"
404400 #ok(1, "do not care about 'acceptable'"); ## ignore acceptable
406402 }
407403 elsif ($result eq 'invalid') {
408404 SKIP: {
409 skip "ltc bug", 1 if $comment eq "changing tag value of sequence"; #XXX-FIXME
410 skip "ltc bug", 1 if $comment eq "long form encoding of length"; #XXX-FIXME
411 skip "ltc bug", 1 if $comment eq "length contains leading 0"; #XXX-FIXME
405 skip "ltc bug ECC", 1 if $comment eq "changing tag value of sequence"; #XXX-FIXME
406 skip "ltc bug ECC", 1 if $comment eq "long form encoding of length"; #XXX-FIXME
407 skip "ltc bug ECC", 1 if $comment eq "length contains leading 0"; #XXX-FIXME
412408 ok(!$valid, "$testname verify_message=$valid");
413409 }
414410
447443 my $valid = $pk->verify_message_rfc7518($sig, $message, $sha);
448444 if ($result eq 'valid') {
449445 SKIP: {
450 skip "ltc bug", 1 if $comment eq "Edge case for Shamir multiplication"; #XXX-FIXME
446 skip "ltc bug ECC", 1 if $comment eq "Edge case for Shamir multiplication"; #XXX-FIXME
451447 ok($valid, "$testname verify_message=$valid");
452448 }
453449 }
454450 elsif ($result eq 'acceptable') {
455451 SKIP: {
456 skip "ltc bug", 1 if $comment eq "Hash weaker than DL-group"; #XXX-FIXME
452 skip "ltc bug ECC", 1 if $comment eq "Hash weaker than DL-group"; #XXX-FIXME
457453 #ok($valid, "$testname verify_message=$valid"); ## treat "acceptable" as "valid"
458454 ok(!$valid, "$testname verify_message=$valid"); ## treat "acceptable" as "invalid"
459455 #ok(1, "do not care about 'acceptable'"); ## ignore acceptable