From 0a23c6d32ef3239233a2a1f6bbc18c3e421f96dd Mon Sep 17 00:00:00 2001 From: Steffen Jaeckel Date: Fri, 12 May 2017 16:48:44 +0200 Subject: [PATCH] also check for cipher descriptors --- helper.pl | 25 +++++++++++++++---------- src/ciphers/safer/safer.c | 3 +-- testprof/common.c | 10 ++++++++++ 3 files changed, 26 insertions(+), 12 deletions(-) diff --git a/helper.pl b/helper.pl index 9ef0f9a..6bba344 100755 --- a/helper.pl +++ b/helper.pl @@ -81,7 +81,7 @@ sub check_defines { return $fails; } -sub check_hashes { +sub check_descriptors { my @src; my @descriptors; find({ wanted => sub { push @src, $_ if $_ =~ /\.c$/ }, no_chdir=>1 }, './src/hashes/'); @@ -89,6 +89,11 @@ sub check_hashes { my @n = map { my $x = $_; $x =~ s/^.*?ltc_hash_descriptor\s+(\S+).*$/$1/; $x } grep { $_ =~ /ltc_hash_descriptor/ } split /\n/, read_file($f); push @descriptors, @n if @n; } + find({ wanted => sub { push @src, $_ if $_ =~ /\.c$/ }, no_chdir=>1 }, './src/ciphers/'); + for my $f (@src) { + my @n = map { my $x = $_; $x =~ s/^.*?ltc_cipher_descriptor\s+(\S+).*$/$1/; $x } grep { $_ =~ /ltc_cipher_descriptor/ } split /\n/, read_file($f); + push @descriptors, @n if @n; + } my $fails = 0; for my $d (@descriptors) { for my $f (qw{ testprof/common.c }) { @@ -291,14 +296,14 @@ sub die_usage { MARKER } -GetOptions( "s|check-source" => \my $check_source, - "d|check-defines" => \my $check_defines, - "h|check-hashes" => \my $check_hashes, - "m|check-makefiles" => \my $check_makefiles, - "a|check-all" => \my $check_all, - "u|update-makefiles" => \my $update_makefiles, - "f|fixupind=s" => \my $fixupind, - "h|help" => \my $help +GetOptions( "s|check-source" => \my $check_source, + "c|check-descriptors" => \my $check_descriptors, + "d|check-defines" => \my $check_defines, + "m|check-makefiles" => \my $check_makefiles, + "a|check-all" => \my $check_all, + "u|update-makefiles" => \my $update_makefiles, + "f|fixupind=s" => \my $fixupind, + "h|help" => \my $help ) or die_usage; if ($fixupind) { @@ -311,7 +316,7 @@ if ($fixupind) { my $failure; $failure ||= check_source() if $check_all || $check_source; $failure ||= check_defines() if $check_all || $check_defines; -$failure ||= check_hashes() if $check_all || $check_hashes; +$failure ||= check_descriptors() if $check_all || $check_descriptors; $failure ||= process_makefiles(0) if $check_all || $check_makefiles; $failure ||= process_makefiles(1) if $update_makefiles; diff --git a/src/ciphers/safer/safer.c b/src/ciphers/safer/safer.c index 85af1f2..11f4b1b 100644 --- a/src/ciphers/safer/safer.c +++ b/src/ciphers/safer/safer.c @@ -35,8 +35,7 @@ #define __LTC_SAFER_TAB_C__ #include "safer_tab.c" -const struct ltc_cipher_descriptor - safer_k64_desc = { +const struct ltc_cipher_descriptor safer_k64_desc = { "safer-k64", 8, 8, 8, 8, LTC_SAFER_K64_DEFAULT_NOF_ROUNDS, &safer_k64_setup, diff --git a/testprof/common.c b/testprof/common.c index 3cfe478..7912941 100644 --- a/testprof/common.c +++ b/testprof/common.c @@ -250,8 +250,18 @@ void register_algs(void) atexit(_unregister_all); #ifdef LTC_RIJNDAEL +#ifdef ENCRYPT_ONLY + /* alternative would be + * register_cipher (&rijndael_enc_desc); + */ + register_cipher (&aes_enc_desc); +#else + /* alternative would be + * register_cipher (&rijndael_desc); + */ register_cipher (&aes_desc); #endif +#endif #ifdef LTC_BLOWFISH register_cipher (&blowfish_desc); #endif