aboutsummaryrefslogtreecommitdiffstats
path: root/cipher
diff options
context:
space:
mode:
Diffstat (limited to 'cipher')
-rw-r--r--cipher/ChangeLog9
-rw-r--r--cipher/md5.c17
-rw-r--r--cipher/rmd160.c17
-rw-r--r--cipher/sha1.c17
-rw-r--r--cipher/tiger.c17
5 files changed, 45 insertions, 32 deletions
diff --git a/cipher/ChangeLog b/cipher/ChangeLog
index 74bafed4b..778517628 100644
--- a/cipher/ChangeLog
+++ b/cipher/ChangeLog
@@ -1,3 +1,12 @@
+2001-03-28 Werner Koch <[email protected]>
+
+ * md5.c (md5_final): Fixed calculation of hashed length. Thanks
+ to [email protected] for pointing out that it was horrible wrong
+ for more than 512MB of input.
+ * sha1.c (sha1_final): Ditto.
+ * rmd160.c (rmd160_final): Ditto.
+ * tiger.c (tiger_final): Ditto.
+
2001-03-19 Werner Koch <[email protected]>
* blowfish.c (encrypt,do_encrypt): Changed name to do_encrypt to
diff --git a/cipher/md5.c b/cipher/md5.c
index eb09d261c..9bba57641 100644
--- a/cipher/md5.c
+++ b/cipher/md5.c
@@ -258,18 +258,19 @@ md5_final( MD5_CONTEXT *hd )
md5_write(hd, NULL, 0); /* flush */;
- msb = 0;
t = hd->nblocks;
- if( (lsb = t << 6) < t ) /* multiply by 64 to make a byte count */
- msb++;
- msb += t >> 26;
+ /* multiply by 64 to make a byte count */
+ lsb = t << 6;
+ msb = t >> 26;
+ /* add the count */
t = lsb;
- if( (lsb = t + hd->count) < t ) /* add the count */
+ if( (lsb += hd->count) < t )
msb++;
+ /* multiply by 8 to make a bit count */
t = lsb;
- if( (lsb = t << 3) < t ) /* multiply by 8 to make a bit count */
- msb++;
- msb += t >> 29;
+ lsb <<= 3;
+ msb <<= 3;
+ msb |= t >> 29;
if( hd->count < 56 ) { /* enough room */
hd->buf[hd->count++] = 0x80; /* pad */
diff --git a/cipher/rmd160.c b/cipher/rmd160.c
index fba910d7e..94e3ece0b 100644
--- a/cipher/rmd160.c
+++ b/cipher/rmd160.c
@@ -461,18 +461,19 @@ rmd160_final( RMD160_CONTEXT *hd )
rmd160_write(hd, NULL, 0); /* flush */;
- msb = 0;
t = hd->nblocks;
- if( (lsb = t << 6) < t ) /* multiply by 64 to make a byte count */
- msb++;
- msb += t >> 26;
+ /* multiply by 64 to make a byte count */
+ lsb = t << 6;
+ msb = t >> 26;
+ /* add the count */
t = lsb;
- if( (lsb = t + hd->count) < t ) /* add the count */
+ if( (lsb += hd->count) < t )
msb++;
+ /* multiply by 8 to make a bit count */
t = lsb;
- if( (lsb = t << 3) < t ) /* multiply by 8 to make a bit count */
- msb++;
- msb += t >> 29;
+ lsb <<= 3;
+ msb <<= 3;
+ msb |= t >> 29;
if( hd->count < 56 ) { /* enough room */
hd->buf[hd->count++] = 0x80; /* pad */
diff --git a/cipher/sha1.c b/cipher/sha1.c
index bd21aeea4..9160bc260 100644
--- a/cipher/sha1.c
+++ b/cipher/sha1.c
@@ -254,18 +254,19 @@ sha1_final(SHA1_CONTEXT *hd)
sha1_write(hd, NULL, 0); /* flush */;
- msb = 0;
t = hd->nblocks;
- if( (lsb = t << 6) < t ) /* multiply by 64 to make a byte count */
- msb++;
- msb += t >> 26;
+ /* multiply by 64 to make a byte count */
+ lsb = t << 6;
+ msb = t >> 26;
+ /* add the count */
t = lsb;
- if( (lsb = t + hd->count) < t ) /* add the count */
+ if( (lsb += hd->count) < t )
msb++;
+ /* multiply by 8 to make a bit count */
t = lsb;
- if( (lsb = t << 3) < t ) /* multiply by 8 to make a bit count */
- msb++;
- msb += t >> 29;
+ lsb <<= 3;
+ msb <<= 3;
+ msb |= t >> 29;
if( hd->count < 56 ) { /* enough room */
hd->buf[hd->count++] = 0x80; /* pad */
diff --git a/cipher/tiger.c b/cipher/tiger.c
index 193017076..adc23c85c 100644
--- a/cipher/tiger.c
+++ b/cipher/tiger.c
@@ -805,18 +805,19 @@ tiger_final( TIGER_CONTEXT *hd )
tiger_write(hd, NULL, 0); /* flush */;
- msb = 0;
t = hd->nblocks;
- if( (lsb = t << 6) < t ) /* multiply by 64 to make a byte count */
- msb++;
- msb += t >> 26;
+ /* multiply by 64 to make a byte count */
+ lsb = t << 6;
+ msb = t >> 26;
+ /* add the count */
t = lsb;
- if( (lsb = t + hd->count) < t ) /* add the count */
+ if( (lsb += hd->count) < t )
msb++;
+ /* multiply by 8 to make a bit count */
t = lsb;
- if( (lsb = t << 3) < t ) /* multiply by 8 to make a bit count */
- msb++;
- msb += t >> 29;
+ lsb <<= 3;
+ msb <<= 3;
+ msb |= t >> 29;
if( hd->count < 56 ) { /* enough room */
hd->buf[hd->count++] = 0x01; /* pad */