LIBGCRYPT-1-2-BRANCH libgcrypt/cipher (ChangeLog cipher.c)
cvs user mo
cvs at cvs.gnupg.org
Sat Mar 19 18:44:28 CET 2005
Date: Saturday, March 19, 2005 @ 18:58:13
Author: mo
Path: /cvs/libgcrypt/libgcrypt/cipher
Tag: LIBGCRYPT-1-2-BRANCH
Modified: ChangeLog cipher.c
2005-03-19 Moritz Schulte <moritz at g10code.com>
* cipher.c (do_cbc_encrypt): Be careful to not overwrite data,
which is to be used later on. This happend, in case CTS is
enabled and OUTBUF is equal to INBUF.
-----------+
ChangeLog | 13 +++++++++++++
cipher.c | 24 +++++++++++++++---------
2 files changed, 28 insertions(+), 9 deletions(-)
Index: libgcrypt/cipher/ChangeLog
diff -u libgcrypt/cipher/ChangeLog:1.211.2.9 libgcrypt/cipher/ChangeLog:1.211.2.10
--- libgcrypt/cipher/ChangeLog:1.211.2.9 Fri Feb 25 11:48:44 2005
+++ libgcrypt/cipher/ChangeLog Sat Mar 19 18:58:13 2005
@@ -1,3 +1,16 @@
+2005-03-19 Moritz Schulte <moritz at g10code.com>
+
+ * cipher.c (do_cbc_encrypt): Be careful to not overwrite data,
+ which is to be used later on. This happend, in case CTS is
+ enabled and OUTBUF is equal to INBUF.
+
+2005-03-19 Moritz Schulte <moritz at g10code.com>
+
+ * ac.c (gcry_ac_data_copy_internal): Use gcry_strdup instead of
+ strdup.
+ (gcry_ac_data_set): Likewise.
+ (gcry_ac_data_get_index): Likewise.
+
2005-02-25 Werner Koch <wk at g10code.com>
* pubkey.c (gcry_pk_get_keygrip): Allow for shadowed-private-key.
Index: libgcrypt/cipher/cipher.c
diff -u libgcrypt/cipher/cipher.c:1.69 libgcrypt/cipher/cipher.c:1.69.2.1
--- libgcrypt/cipher/cipher.c:1.69 Wed Feb 25 19:27:35 2004
+++ libgcrypt/cipher/cipher.c Sat Mar 19 18:58:13 2005
@@ -792,23 +792,29 @@
if ((c->flags & GCRY_CIPHER_CBC_CTS) && nbytes > blocksize)
{
+ /* We have to be careful here, since outbuf might be equal to
+ inbuf. */
+
int restbytes;
+ byte b;
if ((nbytes % blocksize) == 0)
restbytes = blocksize;
else
restbytes = nbytes % blocksize;
- memcpy(outbuf, outbuf - c->cipher->blocksize, restbytes);
- outbuf -= c->cipher->blocksize;
-
- for(ivp=c->iv,i=0; i < restbytes; i++ )
- outbuf[i] = inbuf[i] ^ *ivp++;
- for(; i < blocksize; i++ )
- outbuf[i] = 0 ^ *ivp++;
+ outbuf -= blocksize;
+ for (ivp = c->iv, i = 0; i < restbytes; i++)
+ {
+ b = inbuf[i];
+ outbuf[blocksize + i] = outbuf[i];
+ outbuf[i] = b ^ *ivp++;
+ }
+ for (; i < blocksize; i++)
+ outbuf[i] = 0 ^ *ivp++;
- c->cipher->encrypt ( &c->context.c, outbuf, outbuf );
- memcpy(c->iv, outbuf, blocksize );
+ c->cipher->encrypt (&c->context.c, outbuf, outbuf);
+ memcpy (c->iv, outbuf, blocksize);
}
}
More information about the Gnupg-commits
mailing list