From: Daniel Hartwig <mandyke@gmail.com>
To: guile-devel@gnu.org
Subject: [PATCH] md5: fix errors when input size modulo 64 is > 55 bytes
Date: Sat, 12 Jan 2013 14:43:34 +0800 [thread overview]
Message-ID: <877gnikijt.fsf@gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1286 bytes --]
Originally reported as <http://bugs.debian.org/437214>.
Triggered when input has size modulo 64 is 56–63 bytes.
scheme@(guile-user)> (use-modules (md5))
scheme@(guile-user)> (md5 (open-input-string (make-string 60 #\0)))
ERROR: In procedure string-set!:
ERROR: In procedure string-set!: Wrong type argument in position 1 (expecting string): #f
Entering a new prompt. Type `,bt' for a backtrace or `,q' to continue.
scheme@(guile-user) [1]> ,bt
In /usr/share/guile/site/md5.scm:
349:10 1 (md5-finalize ((values (a . 1732584193) (b . 4023233417) (c . 2562383102) (. #)) # …))
In unknown file:
0 (string-set! #f #f #\200)
Two errors in that section of the file. The first is a simple typo:
context → 'context.
The second required looking up the libgcrypt source (the basis of this
module) to repair. Lines 322–380 of md5.scm are equivalent to lines
288–301 of cipher/md5.c. Attached patch repairs this part of the file
based on the algorithm in libgcrypt.
$ guile -c '(display (make-string 60 #\0))' | md5sum
5b19445b70b493c78f3bc06eb7962315 -
$ guile
[…]
scheme@(guile-user)> (use-modules (md5))
scheme@(guile-user)> (md5 (open-input-string (make-string 60 #\0)))
$1 = "5b19445b70b493c78f3bc06eb7962315"
Regards
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-md5-fix-errors-when-input-size-modulo-64-is-55-bytes.patch --]
[-- Type: text/x-diff, Size: 1409 bytes --]
From 47c92db862ce846dbcc5d27843bc9d26b7708d5d Mon Sep 17 00:00:00 2001
From: Daniel Hartwig <mandyke@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
next reply other threads:[~2013-01-12 6:43 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-12 6:43 Daniel Hartwig [this message]
2013-01-12 6:56 ` [PATCH] md5: fix errors when input size modulo 64 is > 55 bytes Daniel Hartwig
2013-01-12 8:35 ` Nala Ginrut
2013-01-21 21:16 ` Andy Wingo
2013-01-31 5:31 ` Daniel Hartwig
2013-01-31 5:31 ` Daniel Hartwig
2013-01-31 10:09 ` Andy Wingo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=877gnikijt.fsf@gmail.com \
--to=mandyke@gmail.com \
--cc=guile-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).