Changeset 1260

Show
Ignore:
Timestamp:
09/28/08 22:02:10 (2 months ago)
Author:
mbr
Message:

(Test suite) Added tests for GnuPG version 2 (a check is made to see if
it is installed before these tests are run).

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • fwknop/trunk/ChangeLog

    r1256 r1260  
    5050    - (Test suite) Added tests for GPG_NO_REQUIRE_PREFIX functionality and for 
    5151      the expected GnuPG prefix. 
     52    - (Test suite) Added tests for GnuPG version 2 (a check is made to see if 
     53      it is installed before these tests are run). 
    5254 
    5355fwknop-1.9.7 (08/24/2008): 
  • fwknop/trunk/fwknopd

    r1259 r1260  
    34783478                } elsif ($line =~ /^\s*GPG_REMOTE_ID:\s*(.*)\s*;/) { 
    34793479                    unless ($imported_gpg) { 
    3480                         &check_commands({'gpg' => ''}, {}); 
    34813480                        require GnuPG::Interface; 
    34823481                        print STDERR "[+] GnuPG::Interface::VERSION ", 
     
    34903489                } elsif ($line =~ /^\s*GPG_DECRYPT_ID:\s*(.*)\s*;/) { 
    34913490                    unless ($imported_gpg) { 
    3492                         &check_commands({'gpg' => ''}, {}); 
    34933491                        require GnuPG::Interface; 
    34943492                        print STDERR "[+] GnuPG::Interface::VERSION ", 
     
    34993497                } elsif ($line =~ /^\s*GPG_DECRYPT_PW:\s*(.*)\s*;/) { 
    35003498                    unless ($imported_gpg) { 
    3501                         &check_commands({'gpg' => ''}, {}); 
    35023499                        require GnuPG::Interface; 
    35033500                        print STDERR "[+] GnuPG::Interface::VERSION ", 
     
    35083505                } elsif ($line =~ /^\s*GPG_HOME_DIR:\s*(\S+)\s*;/) { 
    35093506                    unless ($imported_gpg) { 
    3510                         &check_commands({'gpg' => ''}, {}); 
    35113507                        require GnuPG::Interface; 
    35123508                        print STDERR "[+] GnuPG::Interface::VERSION ", 
     
    39203916            $access_hr->{'GPG_PATH'} = '' 
    39213917                unless defined $access_hr->{'GPG_PATH'}; 
     3918            unless ($access_hr->{'GPG_PATH'}) { 
     3919                &check_commands({'gpg' => ''}, {}); 
     3920            } 
    39223921        } 
    39233922        if (defined ($access_hr->{'REQUIRE_AUTH_METHOD'})) { 
     
    42334232 
    42344233    ### make sure command paths are correct 
    4235     &check_commands({}, {'gpg' => ''}) unless $os_fprint_only; 
     4234    &check_commands({}, {'gpg' => '', 'gpg2' => ''}) unless $os_fprint_only; 
    42364235 
    42374236    if ($fw_del_ip) { 
  • fwknop/trunk/test/fwknop_test.pl

    r1257 r1260  
    4141my $tcpdumpCmd = '/usr/sbin/tcpdump'; 
    4242my $gpgCmd     = '/usr/bin/gpg'; 
     43my $gpg2Cmd    = '/usr/bin/gpg2'; 
    4344 
    4445my $conf_dir   = 'conf'; 
     
    4950my $default_access_conf   = "$conf_dir/default_access.conf"; 
    5051my $default_fwknop_conf   = "$conf_dir/default_fwknop.conf"; 
     52my $gpg2_fwknop_conf      = "$conf_dir/gpg2_fwknop.conf"; 
    5153my $fwknop_62203_conf     = "$conf_dir/filter_62203_fwknop.conf"; 
    5254my $sha256_fwknop_conf    = "$conf_dir/sha256_fwknop.conf"; 
     
    6264my $rand_port_fwknop_conf = "$conf_dir/rand_port_fwknop.conf"; 
    6365my $gpg_access_conf       = "$conf_dir/gpg_access.conf"; 
     66my $gpg2_access_conf      = "$conf_dir/gpg2_access.conf"; 
    6467my $gpg_access_no_prefix_conf = "$conf_dir/gpg_access_no_prefix.conf"; 
    6568my $no_promisc_fwknop_conf = "$conf_dir/no_promisc_fwknop.conf"; 
     
    503506} 
    504507 
     508if (-e $gpg2Cmd and -x $gpg2Cmd) { 
     509    &test_driver('(GnuPG v2) Generating SPA access packet', 
     510        \&SPA_gpg2_access_packet); 
     511    &test_driver('(GnuPG v2) Sniffing SPA access packet to acquire access', 
     512        \&gpg2_sniff_decrypt); 
     513    &test_driver('(GnuPG v2) Verifying sniffed SPA access packet format', 
     514        \&spa_access_format); 
     515    &test_driver('(GnuPG v2) Firewall access rules exist', \&fw_rules_exist); 
     516    &fw_sleep('(GnuPG v2)'); 
     517    &test_driver('(GnuPG v2) Firewall access rules removed', 
     518        \&fw_rules_removed); 
     519    &test_driver('(GnuPG v2) Stopping all running fwknopd processes', 
     520        \&stop_fwknopd); 
     521} 
     522 
    505523### test SPA command execution instead of access requests 
    506524&test_driver('(Command execution) Generating SPA command packet', 
     
    15191537} 
    15201538 
     1539sub gpg2_sniff_decrypt() { 
     1540 
     1541    if (&run_fwknopd($cache_encrypted_spa_packet, 
     1542            $gpg2_fwknop_conf, $gpg2_access_conf)) { 
     1543 
     1544        ### now that fwknopd has exited, see if the SPA packet was valid 
     1545        open SE, "< $current_test_file" 
     1546            or die "[*] Could not open $current_test_file: $!"; 
     1547        while (<SE>) { 
     1548            if (/\[\-\]\s+Key\s+mis\-?match/i) { 
     1549                ### [-] Key mis-match or broken message checksum for SOURCE \ 
     1550                ### ANY (# 1 in access.conf) 
     1551                close SE; 
     1552                return &print_errors("[-] Key mis-match"); 
     1553            } elsif (/\[\-\]\s+Decrypted.*not\s+conform/i) { 
     1554                ### [-] Decrypted message does not conform to a valid SPA packet 
     1555                close SE; 
     1556                return &print_errors("[-] Invalid SPA packet"); 
     1557            } 
     1558        } 
     1559        close SE; 
     1560        return 1; 
     1561    } 
     1562    return &print_errors("[-] Sniff alarm ($sniff_alarm seconds) expired"); 
     1563} 
     1564 
    15211565sub SPA_sniff_decrypt() { 
    15221566    return &sniff_decrypt($default_fwknop_conf); 
     
    23122356        "--Include-gpg-prefix", 
    23132357        $NO_QUIET); 
     2358} 
     2359 
     2360sub SPA_gpg2_access_packet() { 
     2361    return &get_access_packet("$default_fwknop_args " . 
     2362        "--gpg-home conf/client-gpg --gpg-recip $gpg_server_key " . 
     2363        "--gpg-sign $gpg_client_key --gpg-no-options " . 
     2364        "--gpg-path $gpg2Cmd", $NO_QUIET); 
    23142365} 
    23152366