diff options
author | Werner Koch <wk@gnupg.org> | 1998-04-07 20:16:10 +0200 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 1998-04-07 20:16:10 +0200 |
commit | 86f261dbc50544d73e4b9ae71fcbc2c6df5b9612 (patch) | |
tree | d3ba75484a73e1fe891f7ff862ab1f3722cb126c /tools | |
parent | cast5 does now work (diff) | |
download | gnupg2-86f261dbc50544d73e4b9ae71fcbc2c6df5b9612.tar.xz gnupg2-86f261dbc50544d73e4b9ae71fcbc2c6df5b9612.zip |
cipher reorganisiert
Diffstat (limited to 'tools')
-rw-r--r-- | tools/ChangeLog | 5 | ||||
-rw-r--r-- | tools/Makefile.am | 7 | ||||
-rw-r--r-- | tools/Makefile.in | 22 | ||||
-rw-r--r-- | tools/bftest.c | 22 | ||||
-rw-r--r-- | tools/cast5test.c | 108 |
5 files changed, 24 insertions, 140 deletions
diff --git a/tools/ChangeLog b/tools/ChangeLog index e69de29bb..ccea6da89 100644 --- a/tools/ChangeLog +++ b/tools/ChangeLog @@ -0,0 +1,5 @@ +Tue Apr 7 19:50:41 1998 Werner Koch (wk@isil.d.shuttle.de) + + * bftest.c: Now supports all availabe ciphers. + + diff --git a/tools/Makefile.am b/tools/Makefile.am index e9bf4782e..2a33a0adb 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -4,20 +4,17 @@ 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 -noinst_PROGRAMS = mpicalc bftest cast5test clean-sat +noinst_PROGRAMS = mpicalc bftest 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 cast5test: $(needed_libs) +mpicalc bftest: $(needed_libs) diff --git a/tools/Makefile.in b/tools/Makefile.in index 9b99174e0..6920c4cbe 100644 --- a/tools/Makefile.in +++ b/tools/Makefile.in @@ -96,19 +96,16 @@ 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 -noinst_PROGRAMS = mpicalc bftest cast5test clean-sat +noinst_PROGRAMS = mpicalc bftest 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 = @@ -127,10 +124,6 @@ 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 = @@ -145,10 +138,9 @@ DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) TAR = tar GZIP = --best -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) +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) default: all @@ -195,10 +187,6 @@ 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) @@ -333,7 +321,7 @@ installdirs mostlyclean-generic distclean-generic clean-generic \ maintainer-clean-generic clean mostlyclean distclean maintainer-clean -mpicalc bftest cast5test: $(needed_libs) +mpicalc bftest: $(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/bftest.c b/tools/bftest.c index 9657be350..a6816e19f 100644 --- a/tools/bftest.c +++ b/tools/bftest.c @@ -34,7 +34,7 @@ static void my_usage(void) { - fprintf(stderr, "usage: bftest [-e][-d] key\n"); + fprintf(stderr, "usage: bftest [-e][-d] algo key\n"); exit(1); } @@ -62,10 +62,10 @@ int main(int argc, char **argv) { int encode=0; - BLOWFISH_context ctx; + CIPHER_HANDLE hd; char buf[100]; - char iv[BLOWFISH_BLOCKSIZE]; int n, size=8; + int algo; #ifdef __MINGW32__ setmode( fileno(stdin), O_BINARY ); @@ -89,22 +89,24 @@ main(int argc, char **argv) argc--; argv++; size = 10; } - if( argc != 2 ) + if( argc != 3 ) my_usage(); argc--; argv++; + algo = string_to_cipher_algo( *argv ); + argc--; argv++; - blowfish_setkey( &ctx, *argv, strlen(*argv) ); - memset(iv,0, BLOWFISH_BLOCKSIZE); - blowfish_setiv( &ctx, iv ); + hd = cipher_open( algo, CIPHER_MODE_CFB, 0 ); + cipher_setkey( hd, *argv, strlen(*argv) ); + cipher_setiv( hd, NULL ); while( (n = fread( buf, 1, size, stdin )) > 0 ) { if( encode ) - blowfish_encode_cfb( &ctx, buf, buf, n ); + cipher_encrypt( hd, buf, buf, n ); else - blowfish_decode_cfb( &ctx, buf, buf, n ); + cipher_decrypt( hd, buf, buf, n ); if( fwrite( buf, 1, n, stdout) != n ) log_fatal("write error\n"); } - + cipher_close(hd); return 0; } diff --git a/tools/cast5test.c b/tools/cast5test.c deleted file mode 100644 index 04e24d7e5..000000000 --- a/tools/cast5test.c +++ /dev/null @@ -1,108 +0,0 @@ -/* 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; -} - |