X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=secnet.git;a=blobdiff_plain;f=md5.c;h=343ad8fc893cdd29bbc208c74b7e044f7499d857;hp=ab00d26efb41028978569fefe86d0adae1022a23;hb=1ce2f8bc69bc1bef98b48f450081d96e2c29cc00;hpb=2fe58dfd10216a37f1ece081f926971882de112e diff --git a/md5.c b/md5.c index ab00d26..343ad8f 100644 --- a/md5.c +++ b/md5.c @@ -20,17 +20,13 @@ * Still in the public domain. */ -#include /* for memcpy() */ -#include /* for stupid systems */ -#include /* for ntohl() */ - #include "secnet.h" -#include "config.h" +#include /* for memcpy() */ #include "md5.h" #ifdef WORDS_BIGENDIAN static void -byteSwap(uint32_t *buf, unsigned words) +byteSwap(uint32_t *buf, int words) { md5byte *p = (md5byte *)buf; @@ -133,7 +129,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 @@ -251,7 +247,7 @@ static void *md5_init(void) 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; @@ -271,19 +267,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),"netlink_module"); + st=safe_malloc(sizeof(*st),"md5_module"); st->cl.description="md5"; st->cl.type=CL_HASH; st->cl.apply=NULL; @@ -300,7 +295,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"); } } }