-/* $OpenBSD: md5.c,v 1.84 2015/12/09 19:36:17 mmcc Exp $ */
+/* $OpenBSD: md5.c,v 1.85 2016/07/29 18:35:45 tedu Exp $ */
/*
* Copyright (c) 2001,2003,2005-2007,2010,2013,2014
int base64;
void *ctx; /* XXX - only used by digest_file() */
void (*init)(void *);
- void (*update)(void *, const unsigned char *, unsigned int);
+ void (*update)(void *, const unsigned char *, size_t);
void (*final)(unsigned char *, void *);
char * (*end)(void *, char *);
TAILQ_ENTRY(hash_function) tailq;
-1,
NULL,
(void (*)(void *))CKSUM_Init,
- (void (*)(void *, const unsigned char *, unsigned int))CKSUM_Update,
+ (void (*)(void *, const unsigned char *, size_t))CKSUM_Update,
(void (*)(unsigned char *, void *))CKSUM_Final,
(char *(*)(void *, char *))CKSUM_End
},
0,
NULL,
(void (*)(void *))MD5Init,
- (void (*)(void *, const unsigned char *, unsigned int))MD5Update,
+ (void (*)(void *, const unsigned char *, size_t))MD5Update,
(void (*)(unsigned char *, void *))MD5Final,
(char *(*)(void *, char *))MD5End
},
0,
NULL,
(void (*)(void *))RMD160Init,
- (void (*)(void *, const unsigned char *, unsigned int))RMD160Update,
+ (void (*)(void *, const unsigned char *, size_t))RMD160Update,
(void (*)(unsigned char *, void *))RMD160Final,
(char *(*)(void *, char *))RMD160End
},
0,
NULL,
(void (*)(void *))SHA1Init,
- (void (*)(void *, const unsigned char *, unsigned int))SHA1Update,
+ (void (*)(void *, const unsigned char *, size_t))SHA1Update,
(void (*)(unsigned char *, void *))SHA1Final,
(char *(*)(void *, char *))SHA1End
},
0,
NULL,
(void (*)(void *))SHA224Init,
- (void (*)(void *, const unsigned char *, unsigned int))SHA224Update,
+ (void (*)(void *, const unsigned char *, size_t))SHA224Update,
(void (*)(unsigned char *, void *))SHA224Final,
(char *(*)(void *, char *))SHA224End
},
0,
NULL,
(void (*)(void *))SHA256Init,
- (void (*)(void *, const unsigned char *, unsigned int))SHA256Update,
+ (void (*)(void *, const unsigned char *, size_t))SHA256Update,
(void (*)(unsigned char *, void *))SHA256Final,
(char *(*)(void *, char *))SHA256End
},
0,
NULL,
(void (*)(void *))SHA384Init,
- (void (*)(void *, const unsigned char *, unsigned int))SHA384Update,
+ (void (*)(void *, const unsigned char *, size_t))SHA384Update,
(void (*)(unsigned char *, void *))SHA384Final,
(char *(*)(void *, char *))SHA384End
},
0,
NULL,
(void (*)(void *))SHA512Init,
- (void (*)(void *, const unsigned char *, unsigned int))SHA512Update,
+ (void (*)(void *, const unsigned char *, size_t))SHA512Update,
(void (*)(unsigned char *, void *))SHA512Final,
(char *(*)(void *, char *))SHA512End
},
TAILQ_FOREACH(hf, hl, tailq) {
hf->init(&context);
- hf->update(&context, string, (unsigned int)strlen(string));
+ hf->update(&context, string, strlen(string));
digest_end(hf, &context, digest, sizeof(digest),
hf->base64);
digest_printstr(hf, string, digest);
err(1, "stdout: write error");
}
TAILQ_FOREACH(hf, hl, tailq)
- hf->update(hf->ctx, data, (unsigned int)nread);
+ hf->update(hf->ctx, data, nread);
}
if (ferror(fp)) {
warn("%s: read error", file);
hf->init(&context);
while ((nread = fread(data, 1UL, sizeof(data), fp)) > 0)
- hf->update(&context, data, (unsigned int)nread);
+ hf->update(&context, data, nread);
if (ferror(fp)) {
warn("%s: read error", file);
error = 1;
gettimeofday(&start, NULL);
hf->init(&context);
for (i = 0; i < count; i++)
- hf->update(&context, data, TEST_BLOCK_LEN);
+ hf->update(&context, data, (size_t)TEST_BLOCK_LEN);
digest_end(hf, &context, digest, sizeof(digest), hf->base64);
gettimeofday(&stop, NULL);
timersub(&stop, &start, &res);
for (i = 0; i < 8; i++) {
hf->init(&context);
- hf->update((void *)&context, test_strings[i],
- (unsigned int)strlen(test_strings[i]));
+ hf->update(&context, test_strings[i],
+ strlen(test_strings[i]));
digest_end(hf, &context, digest, sizeof(digest),
hf->base64);
digest_printstr(hf, test_strings[i], digest);
memset(buf, 'a', sizeof(buf));
hf->init(&context);
for (i = 0; i < 1000; i++)
- hf->update(&context, buf,
- (unsigned int)sizeof(buf));
+ hf->update(&context, buf, sizeof(buf));
digest_end(hf, &context, digest, sizeof(digest), hf->base64);
digest_print(hf, "one million 'a' characters",
digest);