Add test #5.
* Makefile.in, Makefile.am:
Add some missing dist files, expand the third-party files variable.
* commandline.c:
Expand the openfiles macro (this makes the source look better and
also helps people know what the heck I'm talking about).
http://code.google.com/p/shacrypt/source/detail?r=665b146cff
Added:
/tests/t5.sh
Modified:
/ChangeLog
/Makefile.am
/Makefile.in
/commandline.c
/configure
/configure.ac
/tests/t1.sh
/tests/t2.sh
/tests/t3.sh
/tests/t4.sh
=======================================
--- /dev/null
+++ /tests/t5.sh Tue Feb 23 16:24:17 2010
@@ -0,0 +1,20 @@
+#!/bin/bash
+
+# This file is part of the SHACrypt test suite and is licensed
+# under the same license as SHACrypt.
+
+# Description:
+# Make an empty file. Attempt to do an asymmetric crypt with
+# the password "test" (which should fail)
+
+echo "Test 5: Asymmetric crypt of random data"
+
+mkdir tests 2> /dev/null
+./test-helper tests/rand5.tmp
+
+./shacrypt a test tests/rand5.tmp tests/f5.tmp
+result=$?
+
+rm -f tests/rand5.tmp tests/f5.tmp
+
+exit $result
=======================================
--- /ChangeLog Sun Feb 21 11:21:39 2010
+++ /ChangeLog Tue Feb 23 16:24:17 2010
@@ -1,3 +1,19 @@
+2010-02-23 Nightgunner5 <nightg...@llamaslayers.net>
+
+ * tests/t1.sh, tests/t2.sh, tests/t3.sh, tests/t4.sh, tests/t5.sh,
+ configure, configure.ac, Makefile.in, Makefile.am:
+ mkdir the tests directory just in case we're compiling and testing
+ outside of the source root.
+
+ Add test #5.
+
+ * Makefile.in, Makefile.am:
+ Add some missing dist files, expand the third-party files variable.
+
+ * commandline.c:
+ Expand the openfiles macro (this makes the source look better and
+ also helps people know what the heck I'm talking about).
+
2010-02-21 Nightgunner5 <nightg...@llamaslayers.net>
* Makefile.am, configure.ac, configure, config.guess, config.sub,
=======================================
--- /Makefile.am Sun Feb 21 11:21:39 2010
+++ /Makefile.am Tue Feb 23 16:24:17 2010
@@ -1,13 +1,12 @@
## Process this file with automake to produce Makefile.in
-third_party_hashfuncs = third-party/sha1.c third-party/sha2.c
third-party/md5c.c third-party/cubehash.c third-party/whirlpool.c
EXTRA_PROGRAMS = shacrypt-gui
-EXTRA_DIST = tests test-helper.c third-party shacrypt.glade
+EXTRA_DIST = tests test-helper.c third-party shacrypt.glade glade.sed
include_HEADERS = shacrypt.h
lib_LIBRARIES = libshacrypt.a
-libshacrypt_a_SOURCES = shacrypt.h shacrypt.c $(third_party_hashfuncs)
+libshacrypt_a_SOURCES = shacrypt.h shacrypt.c third-party/sha1.c
third-party/sha2.c third-party/md5c.c third-party/cubehash.c
third-party/whirlpool.c
libshacrypt_a_CFLAGS = $(DWINDOWS)
bin_PROGRAMS = shacrypt $(GUI)
@@ -18,7 +17,7 @@
CLEANFILES = glade.h
glade.h: shacrypt.glade glade.sed Makefile
- $(SED) -f glade.sed -e 's/[@]VERSION[@]/$(VERSION)/g' < shacrypt.glade >
glade.h
+ $(SED) -f $(srcdir)/glade.sed -e 's/[@]VERSION[@]/$(VERSION)/g' <
$(srcdir)/shacrypt.glade > glade.h
shacrypt_gui_SOURCES = gui.c shacrypt.h shacrypt-icon.h
nodist_shacrypt_gui_SOURCES = glade.h
@@ -32,6 +31,6 @@
test_helper_LDADD = libshacrypt.a
TESTS = $(TESTS_CLI)
-XFAIL_TESTS = tests/t1.sh
+XFAIL_TESTS = tests/t1.sh tests/t5.sh
dist_man_MANS = shacrypt.1
=======================================
--- /Makefile.in Sun Feb 21 11:21:39 2010
+++ /Makefile.in Tue Feb 23 16:24:17 2010
@@ -84,13 +84,12 @@
libshacrypt_a_AR = $(AR) $(ARFLAGS)
libshacrypt_a_LIBADD =
am__dirstamp = $(am__leading_dot)dirstamp
-am__objects_1 = third-party/libshacrypt_a-sha1.$(OBJEXT) \
+am_libshacrypt_a_OBJECTS = libshacrypt_a-shacrypt.$(OBJEXT) \
+ third-party/libshacrypt_a-sha1.$(OBJEXT) \
third-party/libshacrypt_a-sha2.$(OBJEXT) \
third-party/libshacrypt_a-md5c.$(OBJEXT) \
third-party/libshacrypt_a-cubehash.$(OBJEXT) \
third-party/libshacrypt_a-whirlpool.$(OBJEXT)
-am_libshacrypt_a_OBJECTS = libshacrypt_a-shacrypt.$(OBJEXT) \
- $(am__objects_1)
libshacrypt_a_OBJECTS = $(am_libshacrypt_a_OBJECTS)
PROGRAMS = $(bin_PROGRAMS)
am_shacrypt_OBJECTS = commandline.$(OBJEXT)
@@ -245,11 +244,10 @@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
-third_party_hashfuncs = third-party/sha1.c third-party/sha2.c
third-party/md5c.c third-party/cubehash.c third-party/whirlpool.c
-EXTRA_DIST = tests test-helper.c third-party shacrypt.glade
+EXTRA_DIST = tests test-helper.c third-party shacrypt.glade glade.sed
include_HEADERS = shacrypt.h
lib_LIBRARIES = libshacrypt.a
-libshacrypt_a_SOURCES = shacrypt.h shacrypt.c $(third_party_hashfuncs)
+libshacrypt_a_SOURCES = shacrypt.h shacrypt.c third-party/sha1.c
third-party/sha2.c third-party/md5c.c third-party/cubehash.c
third-party/whirlpool.c
libshacrypt_a_CFLAGS = $(DWINDOWS)
shacrypt_SOURCES = commandline.c shacrypt.h
shacrypt_LDADD = libshacrypt.a
@@ -262,7 +260,7 @@
test_helper_SOURCES = test-helper.c shacrypt.h
test_helper_LDADD = libshacrypt.a
TESTS = $(TESTS_CLI)
-XFAIL_TESTS = tests/t1.sh
+XFAIL_TESTS = tests/t1.sh tests/t5.sh
dist_man_MANS = shacrypt.1
all: $(BUILT_SOURCES) config.h
$(MAKE) $(AM_MAKEFLAGS) all-am
@@ -1060,7 +1058,7 @@
glade.h: shacrypt.glade glade.sed Makefile
- $(SED) -f glade.sed -e 's/[@]VERSION[@]/$(VERSION)/g' < shacrypt.glade >
glade.h
+ $(SED) -f $(srcdir)/glade.sed -e 's/[@]VERSION[@]/$(VERSION)/g' <
$(srcdir)/shacrypt.glade > glade.h
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
=======================================
--- /commandline.c Sun Feb 21 11:21:39 2010
+++ /commandline.c Tue Feb 23 16:24:17 2010
@@ -27,20 +27,6 @@
#include <time.h>
#include "shacrypt.h"
#include "config.h"
-#define openfiles if (argc > 3) {\
- f = fopen(argv[3], "rb");\
- if (!f) {\
- perror(argv[3]);\
- exit(1);\
- }\
- o = fopen(argv[4], "wb");\
- if (!o) {\
- perror(argv[4]);\
- exit(1);\
- }\
- } else {\
- f = stdin; o = stdout;\
- }
static const char identifier[3] = "\xA7\x09\xC3";
@@ -52,7 +38,7 @@
}
}
-void showhelp( char* appname, char* mode ) {
+void showhelp( char *appname, char *mode ) {
if ( strcmp( mode, "ha" ) == 0 ) {
printf( "SHACrypt %s: Asymmetric Encryption\n", PACKAGE_VERSION );
printf( "Please note: All steps are formed in the same way as
normal encryption, with the exception of the first argument (the e, a, or
d). See '%s h' for more details. In these examples, Alice is the sender and
Bob is the recipient. Between each step, the file would be transmitted to
the other person.\n", appname );
@@ -85,10 +71,10 @@
}
}
-void encryptmode( int argc, char** argv ) {
+void encryptmode( int argc, char **argv ) {
int n;
- FILE* f;
- FILE* o;
+ FILE *f,
+ *o;
static char fbuf[256] = {0},
obuf[256] = {0};
SHACrypt_Context s;
@@ -131,7 +117,21 @@
if ( algos == '\0' )
algos = '\x01';
- openfiles
+ if ( argc > 3 ) {
+ f = fopen( argv[3], "rb");
+ if ( !f ) {
+ perror( argv[3] );
+ exit( 1 );
+ }
+ o = fopen( argv[4], "wb" );
+ if ( !o ) {
+ perror( argv[4] );
+ exit( 1 );
+ }
+ } else {
+ f = stdin;
+ o = stdout;
+ }
n = SHACrypt_GetRand( algos, fbuf );
if ( n < 0 ) {
@@ -155,17 +155,31 @@
}
}
-void decryptmode( int argc, char** argv ) {
+void decryptmode( int argc, char **argv ) {
int n;
- FILE* f;
- FILE* o;
+ FILE *f,
+ *o;
static char fbuf[256] = {0},
obuf[256] = {0};
SHACrypt_Context s;
unsigned char algos,
randlen;
- openfiles
+ if ( argc > 3 ) {
+ f = fopen( argv[3], "rb");
+ if ( !f ) {
+ perror( argv[3] );
+ exit( 1 );
+ }
+ o = fopen( argv[4], "wb" );
+ if ( !o ) {
+ perror( argv[4] );
+ exit( 1 );
+ }
+ } else {
+ f = stdin;
+ o = stdout;
+ }
fread( fbuf, 1, 5, f );
@@ -193,7 +207,7 @@
}
}
-void compatmode( int argc, char** argv ) {
+void compatmode( int argc, char **argv ) {
int n;
FILE* f;
FILE* o;
@@ -201,7 +215,21 @@
obuf[256] = {0};
SHACrypt_Context s;
- openfiles
+ if ( argc > 3 ) {
+ f = fopen( argv[3], "rb");
+ if ( !f ) {
+ perror( argv[3] );
+ exit( 1 );
+ }
+ o = fopen( argv[4], "wb" );
+ if ( !o ) {
+ perror( argv[4] );
+ exit( 1 );
+ }
+ } else {
+ f = stdin;
+ o = stdout;
+ }
SHACrypt_Init( &s, argv[2], strlen( argv[2] ), '\x01', "", 0 );
@@ -213,17 +241,31 @@
}
}
-void asymmetricmode( int argc, char** argv ) {
+void asymmetricmode( int argc, char **argv ) {
int n;
- FILE* f;
- FILE* o;
+ FILE *f,
+ *o;
static char fbuf[256] = {0},
obuf[256] = {0};
SHACrypt_Context s;
unsigned char algos,
randlen;
- openfiles
+ if ( argc > 3 ) {
+ f = fopen( argv[3], "rb");
+ if ( !f ) {
+ perror( argv[3] );
+ exit( 1 );
+ }
+ o = fopen( argv[4], "wb" );
+ if ( !o ) {
+ perror( argv[4] );
+ exit( 1 );
+ }
+ } else {
+ f = stdin;
+ o = stdout;
+ }
fread( fbuf, 1, 5, f );
@@ -257,7 +299,7 @@
}
}
-int main( int argc, char** argv ) {
+int main( int argc, char **argv ) {
if ( !argv[1] ) {
argv[1] = "h";
}
=======================================
--- /configure Sun Feb 21 11:21:39 2010
+++ /configure Tue Feb 23 16:24:17 2010
@@ -4064,7 +4064,7 @@
if test "$enable_commandline" == "yes"; then :
COMMANDLINE='shacrypt'
- TESTS_CLI='tests/t1.sh tests/t2.sh tests/t3.sh tests/t4.sh'
+ TESTS_CLI='tests/t1.sh tests/t2.sh tests/t3.sh tests/t4.sh tests/t5.sh'
fi
ac_aux_dir=
=======================================
--- /configure.ac Sun Feb 21 11:21:39 2010
+++ /configure.ac Tue Feb 23 16:24:17 2010
@@ -44,7 +44,7 @@
[])
AS_IF([test "$enable_commandline" == "yes"],
[AC_SUBST([COMMANDLINE], ['shacrypt'])
- AC_SUBST([TESTS_CLI], ['tests/t1.sh tests/t2.sh tests/t3.sh
tests/t4.sh'])],
+ AC_SUBST([TESTS_CLI], ['tests/t1.sh tests/t2.sh tests/t3.sh tests/t4.sh
tests/t5.sh'])],
[])
AS_IF([test "$with_windows" == "check"],
[AC_CANONICAL_HOST
=======================================
--- /tests/t1.sh Sat Feb 20 11:49:56 2010
+++ /tests/t1.sh Tue Feb 23 16:24:17 2010
@@ -9,6 +9,7 @@
echo "Test 1: Asymmetric crypt on an empty file"
+mkdir tests 2> /dev/null
touch tests/rand1.tmp
./shacrypt a test tests/rand1.tmp tests/f1.tmp
=======================================
--- /tests/t2.sh Sun Feb 21 11:21:39 2010
+++ /tests/t2.sh Tue Feb 23 16:24:17 2010
@@ -9,6 +9,7 @@
echo "Test 2: Encryption of random data"
+mkdir tests 2> /dev/null
./test-helper tests/rand2.tmp
./shacrypt e test tests/rand2.tmp tests/f2.tmp
=======================================
--- /tests/t3.sh Sun Feb 21 11:21:39 2010
+++ /tests/t3.sh Tue Feb 23 16:24:17 2010
@@ -9,6 +9,7 @@
echo "Test 3: Encryption and decryption of random data"
+mkdir tests 2> /dev/null
./test-helper tests/rand3.tmp
./shacrypt e test tests/rand3.tmp tests/f3a.tmp
=======================================
--- /tests/t4.sh Sun Feb 21 11:21:39 2010
+++ /tests/t4.sh Tue Feb 23 16:24:17 2010
@@ -9,6 +9,7 @@
# handshake to change the password to "tset" (test backwards)
# and then decrypt it with the password "tset"
+mkdir tests 2> /dev/null
echo "Test 4: Real asymmetric crypt"
./test-helper tests/rand4.tmp