diff options
author | Werner Koch <[email protected]> | 1998-04-04 20:16:55 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 1998-04-04 20:16:55 +0000 |
commit | 53a578711fe65b97c14539048dc9015dc5026da8 (patch) | |
tree | 2d358795a9d14fd7dcfe9f7a82e32363038ea8c5 /tools | |
parent | started with keyserver (diff) | |
download | gnupg-53a578711fe65b97c14539048dc9015dc5026da8.tar.gz gnupg-53a578711fe65b97c14539048dc9015dc5026da8.zip |
cast5 does now work
Diffstat (limited to 'tools')
-rw-r--r-- | tools/Makefile.am | 10 | ||||
-rw-r--r-- | tools/Makefile.in | 25 | ||||
-rw-r--r-- | tools/cast5test.c | 108 |
3 files changed, 134 insertions, 9 deletions
diff --git a/tools/Makefile.am b/tools/Makefile.am index ed1e83dfb..e9bf4782e 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -1,19 +1,23 @@ ## Process this file with automake to produce Makefile.in INCLUDES = -I$(top_srcdir)/include -I$(top_srcdir)/intl -I../intl -needed_libs = ../cipher/libcipher.a ../util/libutil.a ../mpi/libmpi.a ../util/libutil.a +needed_libs = ../cipher/libcipher.a ../util/libutil.a \ + ../mpi/libmpi.a ../util/libutil.a -noinst_PROGRAMS = mpicalc bftest clean-sat +noinst_PROGRAMS = mpicalc bftest cast5test clean-sat mpicalc_SOURCES = mpicalc.c bftest_SOURCES = bftest.c +cast5test_SOURCES = cast5test.c + clean_sat_SOURCES = clean-sat.c mpicalc_LDADD = @INTLLIBS@ $(needed_libs) bftest_LDADD = @INTLLIBS@ $(needed_libs) +cast5test_LDADD = @INTLLIBS@ $(needed_libs) -mpicalc bftest: $(needed_libs) +mpicalc bftest cast5test: $(needed_libs) diff --git a/tools/Makefile.in b/tools/Makefile.in index a9ceae455..9b99174e0 100644 --- a/tools/Makefile.in +++ b/tools/Makefile.in @@ -93,18 +93,22 @@ ZLIBS = @ZLIBS@ l = @l@ INCLUDES = -I$(top_srcdir)/include -I$(top_srcdir)/intl -I../intl -needed_libs = ../cipher/libcipher.a ../util/libutil.a ../mpi/libmpi.a ../util/libutil.a +needed_libs = ../cipher/libcipher.a ../util/libutil.a \ + ../mpi/libmpi.a ../util/libutil.a -noinst_PROGRAMS = mpicalc bftest clean-sat +noinst_PROGRAMS = mpicalc bftest cast5test clean-sat mpicalc_SOURCES = mpicalc.c bftest_SOURCES = bftest.c +cast5test_SOURCES = cast5test.c + clean_sat_SOURCES = clean-sat.c mpicalc_LDADD = @INTLLIBS@ $(needed_libs) bftest_LDADD = @INTLLIBS@ $(needed_libs) +cast5test_LDADD = @INTLLIBS@ $(needed_libs) mkinstalldirs = $(SHELL) $(top_srcdir)/scripts/mkinstalldirs CONFIG_HEADER = ../config.h CONFIG_CLEAN_FILES = @@ -123,6 +127,10 @@ bftest_OBJECTS = bftest.o bftest_DEPENDENCIES = ../cipher/libcipher.a ../util/libutil.a \ ../mpi/libmpi.a ../util/libutil.a bftest_LDFLAGS = +cast5test_OBJECTS = cast5test.o +cast5test_DEPENDENCIES = ../cipher/libcipher.a ../util/libutil.a \ +../mpi/libmpi.a ../util/libutil.a +cast5test_LDFLAGS = clean_sat_OBJECTS = clean-sat.o clean_sat_LDADD = $(LDADD) clean_sat_DEPENDENCIES = @@ -137,9 +145,10 @@ DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) TAR = tar GZIP = --best -DEP_FILES = .deps/bftest.P .deps/clean-sat.P .deps/mpicalc.P -SOURCES = $(mpicalc_SOURCES) $(bftest_SOURCES) $(clean_sat_SOURCES) -OBJECTS = $(mpicalc_OBJECTS) $(bftest_OBJECTS) $(clean_sat_OBJECTS) +DEP_FILES = .deps/bftest.P .deps/cast5test.P .deps/clean-sat.P \ +.deps/mpicalc.P +SOURCES = $(mpicalc_SOURCES) $(bftest_SOURCES) $(cast5test_SOURCES) $(clean_sat_SOURCES) +OBJECTS = $(mpicalc_OBJECTS) $(bftest_OBJECTS) $(cast5test_OBJECTS) $(clean_sat_OBJECTS) default: all @@ -186,6 +195,10 @@ bftest: $(bftest_OBJECTS) $(bftest_DEPENDENCIES) @rm -f bftest $(LINK) $(bftest_LDFLAGS) $(bftest_OBJECTS) $(bftest_LDADD) $(LIBS) +cast5test: $(cast5test_OBJECTS) $(cast5test_DEPENDENCIES) + @rm -f cast5test + $(LINK) $(cast5test_LDFLAGS) $(cast5test_OBJECTS) $(cast5test_LDADD) $(LIBS) + clean-sat: $(clean_sat_OBJECTS) $(clean_sat_DEPENDENCIES) @rm -f clean-sat $(LINK) $(clean_sat_LDFLAGS) $(clean_sat_OBJECTS) $(clean_sat_LDADD) $(LIBS) @@ -320,7 +333,7 @@ installdirs mostlyclean-generic distclean-generic clean-generic \ maintainer-clean-generic clean mostlyclean distclean maintainer-clean -mpicalc bftest: $(needed_libs) +mpicalc bftest cast5test: $(needed_libs) # 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. diff --git a/tools/cast5test.c b/tools/cast5test.c new file mode 100644 index 000000000..04e24d7e5 --- /dev/null +++ b/tools/cast5test.c @@ -0,0 +1,108 @@ +/* cast5test.c - CAST5 test program + * Copyright (C) 1998 Free Software Foundation, Inc. + * + * This file is part of GNUPG. + * + * GNUPG is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * GNUPG is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +#include <config.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#ifdef __MINGW32__ + #include <io.h> + #include <fcntl.h> +#endif + +#include "util.h" +#include "cipher.h" +#include "i18n.h" + +static void +my_usage(void) +{ + fprintf(stderr, "usage: cast5test [-e][-d] key\n"); + exit(1); +} + +const char * +strusage( int level ) +{ + return default_strusage(level); +} + +static void +i18n_init(void) +{ + #ifdef ENABLE_NLS + #ifdef HAVE_LC_MESSAGES + setlocale( LC_MESSAGES, "" ); + #else + setlocale( LC_ALL, "" ); + #endif + bindtextdomain( PACKAGE, G10_LOCALEDIR ); + textdomain( PACKAGE ); + #endif +} + +int +main(int argc, char **argv) +{ + int encode=0; + CAST5_context ctx; + char buf[100]; + int n, size=100; + + #ifdef __MINGW32__ + setmode( fileno(stdin), O_BINARY ); + setmode( fileno(stdout), O_BINARY ); + #endif + + i18n_init(); + if( argc > 1 && !strcmp(argv[1], "-e") ) { + encode++; + argc--; argv++; + } + else if( argc > 1 && !strcmp(argv[1], "-E") ) { + encode++; + argc--; argv++; + size = 10; + } + else if( argc > 1 && !strcmp(argv[1], "-d") ) { + argc--; argv++; + } + else if( argc > 1 && !strcmp(argv[1], "-D") ) { + argc--; argv++; + size = 10; + } + if( argc != 2 ) + my_usage(); + argc--; argv++; + + cast5_setkey( &ctx, *argv, strlen(*argv) ); + cast5_setiv( &ctx, NULL ); + while( (n = fread( buf, 1, size, stdin )) > 0 ) { + if( encode ) + cast5_encode_cfb( &ctx, buf, buf, n ); + else + cast5_decode_cfb( &ctx, buf, buf, n ); + if( fwrite( buf, 1, n, stdout) != n ) + log_fatal("write error\n"); + } + + return 0; +} + |