On Sat, 2018-09-22 at 00:13:47 +0800, Yangfl wrote: > Guillem Jover <guil...@debian.org> 于2018年9月21日周五 上午7:42写道: > > 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. > > Please find the attached md5main-md.c, taken from libmd5-rfc but > modified to be compiled with -lmd. Notice the segfault here. Clearly > MD5End supplies the hash in ASCII hex string, but md5_finish in raw > char array. That's not the same.
Ah indeed sorry, I used initially MD5Final() which is the correct one here, but switched to MD5End() because it was failing the libmd test suite. Patch updated, I'll fix the test suite later today. Thanks, Guillem
diff --git i/include/md5.h w/include/md5.h index dee2bf4..2f8b167 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) MD5Final(digest, pms) + #endif /* _MD5_H_ */