Merge remote-tracking branch 'upstream/hmac_support' into hmac_support

This commit is contained in:
Franck Joncourt 2013-03-20 22:33:45 +01:00
commit 11ba153832
6 changed files with 95 additions and 7 deletions

View File

@ -209,8 +209,9 @@ try_url(struct url *url, fko_cli_options_t *options)
}
else
{
fprintf(stderr, "Invalid IP (%s) in HTTP response:\n\n%s\n",
ndx, http_response);
fprintf(stderr,
"[-] From http://%s%s\n Invalid IP (%s) in HTTP response:\n\n%s\n",
url->host, url->path, ndx, http_response);
return(-1);
}
}

View File

@ -53,7 +53,7 @@ print "Timestamp:", fko.timestamp()
print "Username:", fko.username()
print "Digest Type (value):", fko.digest_type()
print "Digest Type (string):", fko.digest_type_str()
print "Digest:", fko.digest()
print "Digest:", fko.spa_digest()
print "SPA Message:", fko.spa_message()

View File

@ -69,7 +69,7 @@ FKO_DIGEST_SHA256 = 3
FKO_DIGEST_SHA384 = 4
FKO_DIGEST_SHA512 = 5
"""Digest type constants
"""Hmac type constants
"""
FKO_HMAC_INVALID_DATA = -1
FKO_HMAC_UNKNOWN = 0
@ -482,7 +482,7 @@ class Fko:
else:
return _fko.get_spa_encryption_mode(self.ctx)
def spa_hmac_type(self, val=None):
def hmac_type(self, val=None):
"""Get or set the spa_hmac_type
This is an integer value. If no argument is given, the current value

View File

@ -1258,7 +1258,7 @@ key_gen(PyObject *self, PyObject *args)
int hmac_type;
int res;
if(!PyArg_ParseTuple(args, "s#s#i", &key_b64, &key_b64_len,
if(!PyArg_ParseTuple(args, "s#s#ih", &key_b64, &key_b64_len,
&hmac_key_b64, &hmac_key_b64_len, &hmac_type))
return NULL;

View File

@ -1,4 +1,8 @@
#!/usr/bin/perl -w
#
# This is the main driver program for the fwknop test suite. Test definitions
# are imported from the tests/ directory.
#
use Cwd;
use File::Copy;
@ -146,6 +150,8 @@ my $valgrind_cov_dir = 'valgrind-coverage';
our $spoof_ip = '1.2.3.4';
my $perl_mod_fko_dir = 'FKO';
my $python_fko_dir = 'python_fko';
my $python_script = 'fko-python.py';
our $cmd_exec_test_file = '/tmp/fwknoptest';
my $default_key = 'fwknoptest';
@ -162,6 +168,7 @@ my @test_files = (
"$tests_dir/rijndael_backwards_compatibility.pl",
"$tests_dir/rijndael_hmac.pl",
"$tests_dir/perl_FKO_module.pl",
"$tests_dir/python_fko.pl",
"$tests_dir/gpg_no_pw.pl",
"$tests_dir/gpg.pl",
);
@ -180,6 +187,7 @@ our @rijndael_fuzzing = (); ### from tests/rijndael_fuzzing.pl
our @gpg_no_pw = (); ### from tests/gpg_now_pw.pl
our @gpg = (); ### from tests/gpg.pl
our @perl_FKO_module = (); ### from tests/perl_FKO_module.pl
our @python_fko = (); ### from tests/python_fko.pl
our @rijndael_backwards_compatibility = (); ### from tests/rijndael_backwards_compatibility.pl
my $passed = 0;
@ -226,6 +234,7 @@ my $enable_profile_coverage_check = 0;
my $enable_make_distcheck = 0;
my $enable_perl_module_checks = 0;
my $enable_perl_module_fuzzing_spa_pkt_generation = 0;
my $enable_python_module_checks = 0;
my $enable_openssl_compatibility_tests = 0;
my $openssl_success_ctr = 0;
my $openssl_failure_ctr = 0;
@ -285,6 +294,7 @@ exit 1 unless GetOptions(
'exclude=s' => \$test_exclude, ### synonym
'enable-perl-module-checks' => \$enable_perl_module_checks,
'enable-perl-module-pkt-generation' => \$enable_perl_module_fuzzing_spa_pkt_generation,
'enable-python-module-checks' => \$enable_python_module_checks,
'fuzzing-pkts-file=s' => \$fuzzing_pkts_file,
'fuzzing-pkts-append' => \$fuzzing_pkts_append,
'fuzzing-test-tag=s' => \$fuzzing_test_tag,
@ -318,6 +328,7 @@ if ($enable_all) {
$enable_make_distcheck = 1;
$enable_client_ip_resolve_test = 1;
$enable_perl_module_checks = 1;
$enable_python_module_checks = 1;
$enable_openssl_compatibility_tests = 1;
}
@ -431,6 +442,7 @@ my @tests = (
@rijndael_fuzzing,
@rijndael_hmac,
@perl_FKO_module,
@python_fko,
@gpg_no_pw,
@gpg,
);
@ -561,7 +573,7 @@ if ($enable_openssl_compatibility_tests) {
}
if ($fuzzing_ctr > 0) {
&logr("[+] $fuzzing_success_ctr/$fuzzing_failure_ctr/$fuzzing_ctr " .
"Fuzzing test passed/failed/executed\n");
"Fuzzing tests passed/failed/executed\n");
}
&logr("[+] $passed/$failed/$executed test buckets passed/failed/executed\n\n");
@ -1177,6 +1189,56 @@ sub gpg_pinentry_check() {
return $rv;
}
sub python_fko_compile_install() {
my $test_hr = shift;
my $rv = 1;
if (-d $python_fko_dir) {
rmtree $python_fko_dir or die $!;
}
mkdir $python_fko_dir or die "[*] Could not mkdir $python_fko_dir: $!";
my $curr_pwd = cwd() or die $!;
chdir '../python' or die $!;
&run_cmd("python setup.py build", $cmd_out_tmp,
"../test/$curr_test_file");
&run_cmd("python setup.py install --prefix=../test/$python_fko_dir",
$cmd_out_tmp, "../test/$curr_test_file");
chdir $curr_pwd or die $!;
return $rv;
}
sub python_fko_basic_exec() {
my $test_hr = shift;
my $rv = 1;
my $site_dir = "$python_fko_dir/lib";
for my $dir (glob("$site_dir/python*")) {
$site_dir = $dir;
last;
}
$site_dir .= '/site-packages';
unless (-d $site_dir) {
&write_test_file("[-] $site_dir directory dir does not exist.\n",
$curr_test_file);
return 0;
}
$rv = &run_cmd("LD_LIBRARY_PATH=$lib_dir " .
"PYTHONPATH=$site_dir ./$python_script", $cmd_out_tmp,
$curr_test_file);
return $rv;
}
sub perl_fko_module_compile_install() {
my $test_hr = shift;
@ -4353,6 +4415,14 @@ sub init() {
push @tests_to_exclude, qr/perl FKO module/;
}
if ($enable_python_module_checks) {
die "[*] The python test script: $python_script doesn't exist ",
"or is not executable."
unless -e $python_script and -x $python_script;
} else {
push @tests_to_exclude, qr/python fko extension/;
}
if ($enable_perl_module_fuzzing_spa_pkt_generation) {
push @tests_to_include, qr/perl FKO module/;
if ($fuzzing_class eq 'bogus data') {

17
test/tests/python_fko.pl Normal file
View File

@ -0,0 +1,17 @@
@python_fko = (
{
'category' => 'python fko extension',
'subcategory' => 'compile/install',
'detail' => 'to: ./python_fko/',
'function' => \&python_fko_compile_install,
'fatal' => $NO
},
{
'category' => 'python fko extension',
'subcategory' => 'basic exec',
'detail' => 'import and use fko',
'function' => \&python_fko_basic_exec,
'fatal' => $NO
},
);