aboutsummaryrefslogtreecommitdiffstats
path: root/g10/cipher.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>1999-04-07 18:58:34 +0000
committerWerner Koch <[email protected]>1999-04-07 18:58:34 +0000
commit9f40263e56cc9ebe28016bb4588da3846342ba79 (patch)
tree1ca711569d0878d441798bf4f185036eda8fceda /g10/cipher.c
parentSee ChangeLog: Tue Apr 6 19:58:12 CEST 1999 Werner Koch (diff)
downloadgnupg-9f40263e56cc9ebe28016bb4588da3846342ba79.tar.gz
gnupg-9f40263e56cc9ebe28016bb4588da3846342ba79.zip
See ChangeLog: Wed Apr 7 20:51:39 CEST 1999 Werner Koch
Diffstat (limited to 'g10/cipher.c')
-rw-r--r--g10/cipher.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/g10/cipher.c b/g10/cipher.c
index 0d6e54ff2..98c5e8403 100644
--- a/g10/cipher.c
+++ b/g10/cipher.c
@@ -1,5 +1,5 @@
/* cipher.c - En-/De-ciphering filter
- * Copyright (C) 1998 Free Software Foundation, Inc.
+ * Copyright (C) 1998,1999 Free Software Foundation, Inc.
*
* This file is part of GnuPG.
*
@@ -45,6 +45,7 @@ write_header( cipher_filter_context_t *cfx, IOBUF a )
PKT_encrypted ed;
byte temp[18];
unsigned blocksize;
+ unsigned nprefix;
memset( &ed, 0, sizeof ed );
ed.len = cfx->datalen;
@@ -57,16 +58,22 @@ write_header( cipher_filter_context_t *cfx, IOBUF a )
blocksize = cipher_get_blocksize( cfx->dek->algo );
if( blocksize < 8 || blocksize > 16 )
log_fatal("unsupported blocksize %u\n", blocksize );
- randomize_buffer( temp, blocksize, 1 );
- temp[blocksize] = temp[blocksize-2];
- temp[blocksize+1] = temp[blocksize-1];
+ /* FIXME: remove the kludge for the experimental twofish128 mode:
+ * we always use the 10 byte prefix and not one depending on the blocksize
+ */
+ nprefix = cfx->dek->algo == CIPHER_ALGO_TWOFISH_OLD? blocksize : 8;
+ randomize_buffer( temp, nprefix, 1 );
+ temp[nprefix] = temp[nprefix-2];
+ temp[nprefix+1] = temp[nprefix-1];
print_cipher_algo_note( cfx->dek->algo );
cfx->cipher_hd = cipher_open( cfx->dek->algo, CIPHER_MODE_AUTO_CFB, 1 );
+ /*log_hexdump( "thekey", cfx->dek->key, cfx->dek->keylen );*/
cipher_setkey( cfx->cipher_hd, cfx->dek->key, cfx->dek->keylen );
cipher_setiv( cfx->cipher_hd, NULL );
- cipher_encrypt( cfx->cipher_hd, temp, temp, blocksize+2);
+ /* log_hexdump( "prefix", temp, nprefix+2 );*/
+ cipher_encrypt( cfx->cipher_hd, temp, temp, nprefix+2);
cipher_sync( cfx->cipher_hd );
- iobuf_write(a, temp, blocksize+2);
+ iobuf_write(a, temp, nprefix+2);
cfx->header=1;
}