Control: forwarded -1 mailto:guile-de...@gnu.org
Control: tags -1 + patch

>From 47c92db862ce846dbcc5d27843bc9d26b7708d5d Mon Sep 17 00:00:00 2001
From: Daniel Hartwig <mand...@gmail.com>
Date: Sat, 12 Jan 2013 14:34:26 +0800
Subject: [PATCH] md5: fix errors when input size modulo 64 is > 55 bytes

* src/md5.scm (md5-finalize): Fix typos and missing parts of algorithm
  based on cipher/md5.c in libgcrypt.
---
 src/md5.scm |   12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/md5.scm b/src/md5.scm
index 571c857..1acc78b 100644
--- a/src/md5.scm
+++ b/src/md5.scm
@@ -347,11 +347,17 @@ referenced C implementation into Scheme.
 					   'data-size)
 				 1)))))
 	(begin
-	  (string-set! (assq-ref (assq-ref 'context 'buffer)
+	  (string-set! (assq-ref (assq-ref context 'buffer)
 				 'space)
-		       (assq-ref (assq-ref 'context 'buffer)
+		       (assq-ref (assq-ref context 'buffer)
 				 'data-size)
 		       (integer->char #x80))
+	  (assq-set! (assq-ref context 'buffer)
+		     'data-size
+		     (+ (assq-ref (assq-ref context 'buffer)
+				  'data-size)
+			1))
+
 	  (while (< (assq-ref (assq-ref context 'buffer)
 			      'data-size)
 		    64)
@@ -360,7 +366,7 @@ referenced C implementation into Scheme.
 					  'space)
 				(assq-ref (assq-ref context 'buffer)
 					  'data-size)
-				0)
+				#\nul)
 		   (assq-set! (assq-ref context 'buffer)
 			      'data-size
 			      (+ (assq-ref (assq-ref context 'buffer)
-- 
1.7.10.4

Reply via email to