diff --git a/Makefile.am b/Makefile.am index f12a6c37..eb9218d1 100644 --- a/Makefile.am +++ b/Makefile.am @@ -99,6 +99,7 @@ EXTRA_DIST = \ perl/FKO/MANIFEST \ perl/FKO/ppport.h \ perl/FKO/FKO.xs \ + perl/FKO/t/fuzzing_spa_packets \ perl/FKO/t/04_fuzzing.t \ perl/FKO/t/03_errors.t \ perl/FKO/t/02_functions.t \ @@ -282,7 +283,6 @@ EXTRA_DIST = \ test/fuzzing/patches/invalid_long_proto_define_rijndael_trigger.patch \ test/fuzzing/patches/long_ip.patch \ test/fuzzing/patches/non_b64_user_char.patch \ - test/fuzzing/fuzzing_spa_packets \ test/tests/build_security.pl \ test/tests/preliminaries.pl \ test/tests/code_structure.pl \ diff --git a/perl/FKO/MANIFEST b/perl/FKO/MANIFEST index 8079f956..41030b9a 100644 --- a/perl/FKO/MANIFEST +++ b/perl/FKO/MANIFEST @@ -9,6 +9,8 @@ t/00_init.t t/01_constants.t t/02_functions.t t/03_errors.t +t/04_fuzzing.t +t/fuzzing_spa_packets lib/FKO.pm lib/FKO_Constants.pl inc/Devel/CheckLib.pm diff --git a/perl/FKO/t/04_fuzzing.t b/perl/FKO/t/04_fuzzing.t index 6734d91b..48da09a4 100644 --- a/perl/FKO/t/04_fuzzing.t +++ b/perl/FKO/t/04_fuzzing.t @@ -13,7 +13,7 @@ # use FKO; -use Test::More tests => 593; +use Test::More tests => 9693; my $err; @@ -354,6 +354,37 @@ $f2->destroy() if $f2; $f1->destroy(); +my $fuzzing_pkts_file = 't/fuzzing_spa_packets'; +my %fuzzing_spa_packets = (); +my $fuzzing_key = 'testtest'; +open F, "< $fuzzing_pkts_file" or die $!; +while () { + if (/(?:Bogus|Invalid_encoding)\s(\S+)\:\s+(.*)\,\sSPA\spacket\:\s(\S+)/) { + push @{$fuzzing_spa_packets{$1}{$2}}, $3; + } +} +close F; + +for my $enc_mode (FKO::FKO_ENC_MODE_CBC, FKO::FKO_ENC_MODE_CBC_LEGACY_IV) { + for my $field (keys %fuzzing_spa_packets) { + for my $field_val (keys %{$fuzzing_spa_packets{$field}}) { + for my $encrypted_spa_pkt (@{$fuzzing_spa_packets{$field}{$field_val}}) { + + $f3 = FKO->new(); + ok($f3, 'Create f3 full fuzzing packets'); + + $f3->encryption_mode($enc_mode); + $f3->spa_data($encrypted_spa_pkt); + + ok($f3->decrypt_spa_data($fuzzing_key) != FKO::FKO_SUCCESS, + "accepted fuzzing packet (enc mode: $enc_mode, $field: $field_val)"); + + $f3->destroy(); + } + } + } +} + ############################################################################## sub create diff --git a/test/fuzzing/fuzzing_spa_packets b/perl/FKO/t/fuzzing_spa_packets similarity index 100% rename from test/fuzzing/fuzzing_spa_packets rename to perl/FKO/t/fuzzing_spa_packets diff --git a/test/test-fwknop.pl b/test/test-fwknop.pl index 470ad6c3..c3f70441 100755 --- a/test/test-fwknop.pl +++ b/test/test-fwknop.pl @@ -266,7 +266,7 @@ my $tarfile = 'test_fwknop.tar.gz'; our $key_gen_file = "$output_dir/key_gen"; our $verbose_str = "--verbose --verbose"; my $gdb_test_file = ''; -my $fuzzing_pkts_file = 'fuzzing/fuzzing_spa_packets'; +my $fuzzing_pkts_file = '../perl/FKO/t/fuzzing_spa_packets'; my $fuzzing_pkts_append = 0; my $fuzzing_key = 'testtest'; my $fuzzing_num_pkts = 0;