1
0
Fork 0
mirror of git://git.gnupg.org/gnupg.git synced 2025-07-02 22:46:30 +02:00

Changed keyring handling - saving still does not work.

Added new cipher mode and updated cipher test program.
This commit is contained in:
Werner Koch 2000-10-10 12:58:43 +00:00
parent b75f734a11
commit 5a9ea8ff5c
17 changed files with 322 additions and 198 deletions

View file

@ -1,3 +1,7 @@
2000-10-10 Werner Koch <wk@gnupg.org>
* bftest.c (main): Allow selection of cipher mode.
Mon Sep 18 16:35:45 CEST 2000 Werner Koch <wk@openit.de>
* ring-a-party: substr starts at offset 1 not 0. Many thanks to Mike

View file

@ -34,7 +34,7 @@
static void
my_usage(void)
{
fprintf(stderr, "usage: bftest [-e][-d] algo key\n");
fprintf(stderr, "usage: bftest [-e][-d] algo mode key\n");
exit(1);
}
@ -59,9 +59,10 @@ main(int argc, char **argv)
int encode=0;
GCRY_CIPHER_HD hd;
char buf[4096];
int n, size=4096;
int algo;
int rc, n, size=4096;
int algo, mode;
const char *s;
#ifdef HAVE_DOSISH_SYSTEM
setmode( fileno(stdin), O_BINARY );
setmode( fileno(stdout), O_BINARY );
@ -84,14 +85,34 @@ main(int argc, char **argv)
argc--; argv++;
size = 10;
}
if( argc != 3 )
if( argc != 4 )
my_usage();
argc--; argv++;
algo = gcry_cipher_map_name( *argv );
argc--; argv++;
s = *argv; argc--; argv++;
if ( !strcasecmp( s, "cfb" ) )
mode = GCRY_CIPHER_MODE_CFB;
else if ( !strcasecmp( s, "cbc" ) )
mode = GCRY_CIPHER_MODE_CBC;
else if ( !strcasecmp( s, "ebc" ) )
mode = GCRY_CIPHER_MODE_ECB;
else if ( !strcasecmp( s, "none" ) )
mode = GCRY_CIPHER_MODE_NONE;
else if ( !strcasecmp( s, "stream" ) )
mode = GCRY_CIPHER_MODE_STREAM;
else {
fprintf( stderr,
"wrong mode; use one of: none, ecb, cbc, cfb, stream\n");
return 1;
}
hd = gcry_cipher_open( algo, GCRY_CIPHER_MODE_CFB, 0 );
gcry_cipher_setkey( hd, *argv, strlen(*argv) );
hd = gcry_cipher_open( algo, mode, 0 );
if (!hd )
log_fatal("cipher open failed: %s\n", gcry_strerror(-1) );
rc = gcry_cipher_setkey( hd, *argv, strlen(*argv) );
if ( rc )
log_fatal("setkey failed: %s\n", gcry_strerror(rc) );
gcry_cipher_setiv( hd, NULL, 0 );
while( (n = fread( buf, 1, size, stdin )) > 0 ) {
if( encode )
@ -105,3 +126,15 @@ main(int argc, char **argv)
return 0;
}