X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=secnet.git;a=blobdiff_plain;f=md5.c;h=738d81a824bf1ebb4593c60f46d65596084a1458;hp=8c962d9a4bac76ee2bf09f9230964c5c14b6f8f0;hb=ee2536e4af21ca16d5711d1b848b04d0958f481b;hpb=3454dce4c6909648b711a59b57c5a527036b2a8e diff --git a/md5.c b/md5.c index 8c962d9..738d81a 100644 --- a/md5.c +++ b/md5.c @@ -3,6 +3,7 @@ * The algorithm is due to Ron Rivest. This code was * written by Colin Plumb in 1993, no copyright is claimed. * This code is in the public domain; do with it what you wish. + * [I interpet this as a blanket permision -iwj.] * * Equivalent code is available from RSA Data Security, Inc. * This code has been tested against that, and is equivalent, @@ -26,7 +27,7 @@ #ifdef WORDS_BIGENDIAN static void -byteSwap(uint32_t *buf, unsigned words) +byteSwap(uint32_t *buf, int words) { md5byte *p = (md5byte *)buf; @@ -129,7 +130,7 @@ MD5Final(md5byte digest[16], struct MD5Context *ctx) byteSwap(ctx->buf, 4); memcpy(digest, ctx->buf, 16); - memset(ctx, 0, sizeof(ctx)); /* In case it's sensitive */ + memset(ctx, 0, sizeof *ctx); /* In case it's sensitive */ } #ifndef ASM_MD5 @@ -241,13 +242,13 @@ static void *md5_init(void) { struct MD5Context *ctx; - ctx=safe_malloc(sizeof(*ctx),"md5_init"); + NEW(ctx); MD5Init(ctx); return ctx; } -static void md5_update(void *sst, uint8_t const *buf, uint32_t len) +static void md5_update(void *sst, const void *buf, int32_t len) { struct MD5Context *ctx=sst; @@ -267,19 +268,18 @@ struct md5 { struct hash_if ops; }; -init_module md5_module; void md5_module(dict_t *dict) { struct md5 *st; void *ctx; - string_t testinput="12345\n"; + cstring_t testinput="12345\n"; uint8_t expected[16]= {0xd5,0x77,0x27,0x3f,0xf8,0x85,0xc3,0xf8, 0x4d,0xad,0xb8,0x57,0x8b,0xb4,0x13,0x99}; uint8_t digest[16]; int i; - st=safe_malloc(sizeof(*st),"md5_module"); + NEW(st); st->cl.description="md5"; st->cl.type=CL_HASH; st->cl.apply=NULL; @@ -296,7 +296,7 @@ void md5_module(dict_t *dict) md5_final(ctx,digest); for (i=0; i<16; i++) { if (digest[i]!=expected[i]) { - fatal("md5 module failed self-test\n"); + fatal("md5 module failed self-test"); } } }