[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#909116: ITP: libmd5-rfc -- RFC1321-based (RSA-free) MD5 library



On Fri, 2018-09-21 at 01:13:31 +0200, Guillem Jover wrote:
> Hi!
> 
> On Wed, 2018-09-19 at 00:31:26 +0800, Yangfl wrote:
> > Package: wnpp
> > Severity: wishlist
> > Owner: Yangfl <mmyangfl@gmail.com>
> > 
> > * Package name    : libmd5-rfc
> >   Version         : 0.0+20020413
> >   Upstream Author : Aladdin Enterprises
> > * URL             : https://sourceforge.net/projects/libmd5-rfc/
> > * License         : zlib
> >   Programming Lang: C
> >   Description     : RFC1321-based (RSA-free) MD5 library
> >  This is a very small C library implementing RFC1321, the MD5 message digest
> >  function. Unlike the existing W3C libmd5, it was written from the
> >  specifications (not the sample code) in RFC1321, and therefore is not required
> >  to acknowledge RSA in any way.
> 
> There's already libmd in the archive which contains an RSA-free MD5
> implementation. I see the interface is not exactly the same, but I
> think a handful of macros would easily take care of that, and I'd be
> happy to include those in libmd's md5.h.
> 
> Also the current package provides /usr/include/md5.h which will
> conflict with libmd-dev.

Something like the attached patch would do I guess? I'm not sure if
I'd want to expose those unconditionally, as that might pollute the
namespace.

Thanks,
Guillem
diff --git i/include/md5.h w/include/md5.h
index dee2bf4..72912b5 100644
--- i/include/md5.h
+++ w/include/md5.h
@@ -47,4 +47,17 @@ char	*MD5Data(const uint8_t *, size_t, char *);
 }
 #endif
 
+/*
+ * Interface compatibility with Aladdin Enterprises independent
+ * implemntation from RFC 1321.
+ */
+
+typedef uint8_t md5_byte_t;
+typedef uint32_t md5_word_t;
+typedef MD5_CTX md5_state_t;
+
+#define md5_init(pms) MD5Init(pms)
+#define md5_append(pms, data, nbytes) MD5Update(pms, data, nbytes)
+#define md5_finish(pms, digest) MD5End(pms, digest)
+
 #endif /* _MD5_H_ */
diff --git i/test/md5.c w/test/md5.c
index 5dac6e1..2bf6cb4 100644
--- i/test/md5.c
+++ w/test/md5.c
@@ -34,8 +34,20 @@ void
 test_md5(const char *digest, const char *string)
 {
 	char result[MD5_DIGEST_STRING_LENGTH];
+	MD5_CTX ctx;
+	md5_state_t pms;
 
 	assert(strcmp(digest, MD5Data(string, strlen(string), result)) == 0);
+
+	MD5Init(&ctx);
+	MD5Update(&ctx, string, strlen(string));
+	MD5End(&ctx, result);
+	assert(strcmp(digest, result) == 0);
+
+	md5_init(&pms);
+	md5_append(&pms, string, strlen(string));
+	md5_finish(&pms, result);
+	assert(strcmp(digest, result) == 0);
 }
 
 int

Reply to: