mdfour_update(&md, NULL, 0);
mdfour_result(&md, out);
}
-
-#ifdef TEST_MDFOUR
-static void file_checksum1(char *fname)
-{
- int fd, i;
- struct mdfour md;
- unsigned char buf[1024], sum[16];
- unsigned chunk;
-
- fd = open(fname,O_RDONLY|O_BINARY);
- if (fd == -1) {
- perror("fname");
- exit(1);
- }
-
- chunk = 1 + random() % (sizeof(buf) - 1);
-
- mdfour_begin(&md);
-
- while (1) {
- int n = read(fd, buf, chunk);
- if (n >= 0) {
- mdfour_update(&md, buf, n);
- }
- if (n < chunk) break;
- }
-
- close(fd);
-
- mdfour_update(&md, NULL, 0);
-
- mdfour_result(&md, sum);
-
- for (i=0;i<16;i++)
- printf("%02x", sum[i]);
- printf("\n");
-}
-
-#if 0
-#include "../md4.h"
-
-static void file_checksum2(char *fname)
-{
- int fd, i;
- MDstruct md;
- unsigned char buf[64], sum[16];
-
- fd = open(fname,O_RDONLY|O_BINARY);
- if (fd == -1) {
- perror("fname");
- exit(1);
- }
-
- MDbegin(&md);
-
- while (1) {
- int n = read(fd, buf, sizeof(buf));
- if (n <= 0) break;
- MDupdate(&md, buf, n*8);
- }
-
- if (!md.done) {
- MDupdate(&md, buf, 0);
- }
-
- close(fd);
-
- memcpy(sum, md.buffer, 16);
-
- for (i=0;i<16;i++)
- printf("%02x", sum[i]);
- printf("\n");
-}
-#endif
-
-int main(int argc, char *argv[])
-{
- file_checksum1(argv[1]);
-#if 0
- file_checksum2(argv[1]);
-#endif
- return 0;
-}
-#endif