md5sum.c (774B)
1 /* See LICENSE file for copyright and license details. */ 2 #include <stdio.h> 3 #include <stdlib.h> 4 #include <stdint.h> 5 6 #include "crypt.h" 7 #include "md5.h" 8 #include "util.h" 9 10 static struct md5 s; 11 struct crypt_ops md5_ops = { 12 md5_init, 13 md5_update, 14 md5_sum, 15 &s, 16 }; 17 18 static void 19 usage(void) 20 { 21 eprintf("usage: %s [-c] [file ...]\n", argv0); 22 } 23 24 int 25 main(int argc, char *argv[]) 26 { 27 int ret = 0, (*cryptfunc)(int, char **, struct crypt_ops *, uint8_t *, size_t) = cryptmain; 28 uint8_t md[MD5_DIGEST_LENGTH]; 29 30 ARGBEGIN { 31 case 'b': 32 case 't': 33 /* ignore */ 34 break; 35 case 'c': 36 cryptfunc = cryptcheck; 37 break; 38 default: 39 usage(); 40 } ARGEND 41 42 ret |= cryptfunc(argc, argv, &md5_ops, md, sizeof(md)); 43 ret |= fshut(stdin, "<stdin>") | fshut(stdout, "<stdout>"); 44 45 return ret; 46 }