Skip to content

Commit

Permalink
Merge 14a3423 into b439f83
Browse files Browse the repository at this point in the history
  • Loading branch information
sjaeckel authored May 8, 2017
2 parents b439f83 + 14a3423 commit 53c9804
Show file tree
Hide file tree
Showing 26 changed files with 597 additions and 952 deletions.
4 changes: 4 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/.gitattributes export-ignore
/.gitignore export-ignore

/** export-subst
14 changes: 12 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
/MSVC_*
.libs/

# release files
/libtomcrypt-*
/crypt-*

# suppress output of build process
gcc_[12].txt
testok.txt
Expand All @@ -20,8 +24,8 @@ doc/refman.pdf
# *nix/windows test executables
constants
constants.exe
crypt
crypt.exe
ltcrypt
ltcrypt.exe
hashsum
hashsum.exe
multi
Expand All @@ -47,6 +51,11 @@ timing.exe
*.idb
*.pdb

# Eclipse special files
.project
.cproject
.settings/

# oops ;) but we don't want them to appear in the repository...
*.stackdump
*.core
Expand All @@ -61,6 +70,7 @@ timing.exe
*.gcda
*.gcno
*.gcov
libtomcrypt.pc

coverage/
coverage*.info
Expand Down
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ language: c
compiler:
- gcc
- clang
script: bash "${BUILDSCRIPT}" "${BUILDNAME}" "${BUILDOPTIONS}" "makefile" "-DUSE_LTM -DLTM_DESC -I/usr/include" "/usr/lib/x86_64-linux-gnu/libtommath.a"
script: bash "${BUILDSCRIPT}" "${BUILDNAME}" "${BUILDOPTIONS}" "makefile V=1" "-DUSE_LTM -DLTM_DESC -I/usr/include" "/usr/lib/x86_64-linux-gnu/libtommath.a"
env:
- |
BUILDSCRIPT="check_source.sh"
Expand Down Expand Up @@ -95,6 +95,7 @@ after_failure:
- cat test_std.txt
- cat test_err.txt
after_script:
- cat gcc_1.txt
- cat gcc_2.txt
notifications:
irc: "chat.freenode.net#libtom-notifications"
File renamed without changes.
6 changes: 5 additions & 1 deletion demos/test.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#include <tomcrypt_test.h>

#ifndef GIT_VERSION
#define GIT_VERSION "Undefined version"
#endif

#define LTC_TEST_FN(f) { f, #f }

static const struct {
Expand Down Expand Up @@ -36,7 +40,7 @@ int main(int argc, char **argv)
ulong64 ts, dur = 0;
reg_algs();

printf("build == \n%s\n", crypt_build_settings);
printf("build == %s\n%s\n", GIT_VERSION, crypt_build_settings);

#ifdef USE_LTM
ltc_mp = ltm_desc;
Expand Down
12 changes: 6 additions & 6 deletions Doxyfile → doc/Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ PROJECT_LOGO =
# entered, it will be relative to the location where doxygen was started. If
# left blank the current directory will be used.

OUTPUT_DIRECTORY = doc/doxygen
OUTPUT_DIRECTORY = doxygen

# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create 4096 sub-
# directories (in 2 levels) under the output directory of each output format and
Expand Down Expand Up @@ -161,7 +161,7 @@ STRIP_FROM_PATH = src
# specify the list of include paths that are normally passed to the compiler
# using the -I flag.

STRIP_FROM_INC_PATH = src/headers
STRIP_FROM_INC_PATH = ../src/headers

# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter (but
# less readable) file names. This can be useful is your file systems doesn't
Expand Down Expand Up @@ -754,7 +754,7 @@ WARN_LOGFILE =
# spaces.
# Note: If this tag is empty the current directory is searched.

INPUT = src
INPUT = ../src/

# This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
Expand Down Expand Up @@ -1046,7 +1046,7 @@ HTML_FILE_EXTENSION = .html
# of the possible markers and block names see the documentation.
# This tag requires that the tag GENERATE_HTML is set to YES.

HTML_HEADER = doc/header.html
HTML_HEADER = header.html

# The HTML_FOOTER tag can be used to specify a user-defined HTML footer for each
# generated HTML page. If the tag is left blank doxygen will generate a standard
Expand All @@ -1056,7 +1056,7 @@ HTML_HEADER = doc/header.html
# that doxygen normally uses.
# This tag requires that the tag GENERATE_HTML is set to YES.

HTML_FOOTER = doc/footer.html
HTML_FOOTER = footer.html

# The HTML_STYLESHEET tag can be used to specify a user-defined cascading style
# sheet that is used by each HTML page. It can be used to fine-tune the look of
Expand Down Expand Up @@ -1924,7 +1924,7 @@ SEARCH_INCLUDES = YES
# preprocessor.
# This tag requires that the tag SEARCH_INCLUDES is set to YES.

INCLUDE_PATH = src/headers
INCLUDE_PATH = ../src//headers

# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard
# patterns (like *.h and *.hpp) to filter out the header-files in the
Expand Down
File renamed without changes.
54 changes: 54 additions & 0 deletions doc/makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
ifeq ($V,1)
silent=
silent_stdout=
else
silent=@
silent_stdout= > /dev/null
endif

#Files left over from making the crypt.pdf.
LEFTOVERS=*.dvi *.log *.aux *.toc *.idx *.ilg *.ind *.out *.lof

#build the doxy files (requires Doxygen, tetex and patience)
.PHONY: doxygen
doxygen:
doxygen $(silent_stdout)

doxy: doxygen
${MAKE} -C doxygen/latex $(silent_stdout) && mv -f doxygen/latex/refman.pdf .
@echo The huge doxygen PDF should be available as doc/refman.pdf

#This builds the crypt.pdf file. Note that the rm -f *.pdf has been removed
#from the clean command! This is because most people would like to keep the
#nice pre-compiled crypt.pdf that comes with libtomcrypt! We only need to
#delete it if we are rebuilding it.
.PHONY: crypt.pdf
crypt.pdf: crypt.tex
rm -f crypt.pdf $(LEFTOVERS)
cp crypt.tex crypt.bak
touch -r crypt.tex crypt.bak
(printf "%s" "\def\fixedpdfdate{"; date +'D:%Y%m%d%H%M%S%:z' -d @$$(stat --format=%Y crypt.tex) | sed "s/:\([0-9][0-9]\)$$/'\1'}/g") > crypt-deterministic.tex
printf "%s\n" "\pdfinfo{" >> crypt-deterministic.tex
printf "%s\n" " /CreationDate (\fixedpdfdate)" >> crypt-deterministic.tex
printf "%s\n}\n" " /ModDate (\fixedpdfdate)" >> crypt-deterministic.tex
cat crypt.tex >> crypt-deterministic.tex
mv crypt-deterministic.tex crypt.tex
touch -r crypt.bak crypt.tex
echo "hello" > crypt.ind
latex crypt $(silent_stdout)
latex crypt $(silent_stdout)
makeindex crypt.idx $(silent_stdout)
perl ../helper.pl --fixupind crypt.ind
pdflatex crypt $(silent_stdout)
sed -b -i 's,^/ID \[.*\]$$,/ID [<0> <0>],g' crypt.pdf
mv crypt.bak crypt.tex
rm -f $(LEFTOVERS)

docdvi: crypt.tex
echo hello > crypt.ind
latex crypt $(silent_stdout)
latex crypt $(silent_stdout)
makeindex crypt.idx
perl ../helper.pl --fixupind crypt.ind
latex crypt $(silent_stdout)
latex crypt $(silent_stdout)
16 changes: 0 additions & 16 deletions fixupind.pl

This file was deleted.

90 changes: 53 additions & 37 deletions helper.pl
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ sub check_defines {
my $cryp_c = read_file("src/misc/crypt/crypt.c");
$cust_h =~ s|/\*.*?\*/||sg; # remove comments
$cryp_c =~ s|/\*.*?\*/||sg; # remove comments
my %def = map { $_ => 1 } map { $_ =~ s/^\s*#define\s+(LTC_\S+).*$/$1/; $_ } grep { /^\s*#define\s+LTC_\S+/ } split /\n/, $cust_h;
my %def = map { $_ => 1 } map { my $x = $_; $x =~ s/^\s*#define\s+(LTC_\S+).*$/$1/; $x } grep { /^\s*#define\s+LTC_\S+/ } split /\n/, $cust_h;
for my $d (sort keys %def) {
next if $d =~ /^LTC_(DH\d+|ECC\d+|ECC_\S+|MPI|MUTEX_\S+\(x\)|NO_\S+)$/;
warn "$d missing in src/misc/crypt/crypt.c\n" and $fails++ if $cryp_c !~ /\Q$d\E/;
Expand All @@ -86,7 +86,7 @@ sub check_hashes {
my @descriptors;
find({ wanted => sub { push @src, $_ if $_ =~ /\.c$/ }, no_chdir=>1 }, './src/hashes/');
for my $f (@src) {
my @n = map { $_ =~ s/^.*?ltc_hash_descriptor\s+(\S+).*$/$1/; $_ } grep { $_ =~ /ltc_hash_descriptor/ } split /\n/, read_file($f);
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;
}
my $fails = 0;
Expand Down Expand Up @@ -201,24 +201,27 @@ sub prepare_msvc_files_xml {
}

sub patch_makefile {
my ($in_ref, $out_ref, $data) = @_;
open(my $src, '<', $in_ref);
open(my $dst, '>', $out_ref);
my $l = 0;
while (<$src>) {
if ($_ =~ /START_INS/) {
print {$dst} $_;
$l = 1;
print {$dst} $data;
} elsif ($_ =~ /END_INS/) {
print {$dst} $_;
$l = 0;
} elsif ($l == 0) {
print {$dst} $_;
my ($content, @variables) = @_;
for my $v (@variables) {
if ($v =~ /^([A-Z0-9_]+)\s*=.*$/si) {
my $name = $1;
$content =~ s/\n\Q$name\E\b.*?[^\\]\n/\n$v\n/s;
}
else {
die "patch_makefile failed: " . substr($v, 0, 30) . "..";
}
}
return $content;
}

sub version_form_tomcrypt_h {
my $h = read_file(shift);
if ($h =~ /\n#define\s*SCRYPT\s*"([0-9]+)\.([0-9]+)"/s) {
return "VERSION_MAJ=$1", "VERSION_MIN=$2", "VERSION=$1.$2", "VERSION_LT=0:$1$2";
}
else {
die "#define SCRYPT not found in tomcrypt.h";
}
close $dst;
close $src;
}

sub process_makefiles {
Expand All @@ -230,12 +233,20 @@ sub process_makefiles {
find({ no_chdir => 1, wanted => sub { push @h, $_ if -f $_ && $_ =~ /\.h$/ && $_ !~ /dh_static.h$/ } }, 'src');
my @all = ();
find({ no_chdir => 1, wanted => sub { push @all, $_ if -f $_ && $_ =~ /\.(c|h)$/ } }, 'src');
my @t = qw();
find({ no_chdir => 1, wanted => sub { push @t, $_ if $_ =~ /(no_prng|test_driver|x86_prof|_tests?).c$/ } }, 'testprof');

my @o = sort ('src/ciphers/aes/aes_enc.o', map { $_ =~ s/\.c$/.o/; $_ } @c);
my $var_o = prepare_variable("OBJECTS", @o);
my @o = sort ('src/ciphers/aes/aes_enc.o', map { my $x = $_; $x =~ s/\.c$/.o/; $x } @c);
my $var_o = prepare_variable("OBJECTS", @o);
my $var_h = prepare_variable("HEADERS", (sort @h));
(my $var_obj = $var_o) =~ s/\.o\b/.obj/sg;
my $var_h = prepare_variable("HEADERS", (sort @h, 'testprof/tomcrypt_test.h'));

my $var_to = prepare_variable("TOBJECTS", sort map { my $x = $_; $x =~ s/\.c$/.o/; $x } @t);
(my $var_tobj = $var_to) =~ s/\.o\b/.obj/sg;

my @ver_version = version_form_tomcrypt_h("src/headers/tomcrypt.h");

# update MSVC project files
my $msvc_files = prepare_msvc_files_xml(\@all, qr/tab\.c$/, ['Debug|Win32', 'Release|Win32', 'Debug|x64', 'Release|x64']);
for my $m (qw/libtomcrypt_VS2008.vcproj/) {
my $old = read_file($m);
Expand All @@ -248,22 +259,18 @@ sub process_makefiles {
}
}

my @makefiles = qw( makefile makefile.icc makefile.shared makefile.unix makefile.mingw makefile.msvc );
for my $m (@makefiles) {
# update OBJECTS + HEADERS in makefile*
for my $m (qw/ makefile makefile.shared makefile.unix makefile.mingw makefile.msvc makefile.include /) {
my $old = read_file($m);
my $new;
if ($m eq 'makefile.msvc') {
patch_makefile(\$old, \$new, "$var_obj\n\n$var_h\n\n");
}
else {
patch_makefile(\$old, \$new, "$var_o\n\n$var_h\n\n");
}
my $new = $m eq 'makefile.msvc' ? patch_makefile($old, $var_obj, $var_h, $var_tobj, @ver_version)
: patch_makefile($old, $var_o, $var_h, $var_to, @ver_version);
if ($old ne $new) {
write_file($m, $new) if $write;
warn "changed: $m\n";
$changed_count++;
}
}

if ($write) {
return 0; # no failures
}
Expand All @@ -280,18 +287,27 @@ sub die_usage {
$0 --check-makefiles
$0 --check-all
$0 --update-makefiles
$0 --fixupind crypt.ind
MARKER
}

GetOptions( "check-source" => \my $check_source,
"check-defines" => \my $check_defines,
"check-hashes" => \my $check_hashes,
"check-makefiles" => \my $check_makefiles,
"check-all" => \my $check_all,
"update-makefiles" => \my $update_makefiles,
"help" => \my $help
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
) or die_usage;

if ($fixupind) {
my $txt = read_file($fixupind);
$txt =~ s/^([^\n]*\n)/$1\n\\addcontentsline{toc}{chapter}{Index}\n/s;
write_file($fixupind, $txt);
exit 0;
}

my $failure;
$failure ||= check_source() if $check_all || $check_source;
$failure ||= check_defines() if $check_all || $check_defines;
Expand Down
6 changes: 3 additions & 3 deletions libtomcrypt.pc.in
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
prefix=/usr
prefix=@to-be-replaced@
exec_prefix=${prefix}
libdir=@LIBDIR@
libdir=${exec_prefix}/lib
includedir=${prefix}/include

Name: LibTomCrypt
Description: public domain open source cryptographic toolkit
Version: 1.17
Version: @to-be-replaced@
Libs: -L${libdir} -ltomcrypt
Cflags: -I${includedir}
Loading

0 comments on commit 53c9804

Please sign in to comment.