sha256sum.c (719B)
1 /* See LICENSE file for copyright and license details. */ 2 #include <stdint.h> 3 #include <stdio.h> 4 #include <stdlib.h> 5 6 #include "crypt.h" 7 #include "sha256.h" 8 #include "util.h" 9 10 static struct sha256 s; 11 struct crypt_ops sha256_ops = { 12 sha256_init, 13 sha256_update, 14 sha256_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 uint8_t md[SHA256_DIGEST_LENGTH]; 28 char *checkfile = NULL; 29 int cflag = 0; 30 31 ARGBEGIN { 32 case 'c': 33 cflag = 1; 34 checkfile = ARGF(); 35 break; 36 default: 37 usage(); 38 } ARGEND; 39 40 if (cflag) 41 return cryptcheck(checkfile, argc, argv, &sha256_ops, md, sizeof(md)); 42 return cryptmain(argc, argv, &sha256_ops, md, sizeof(md)); 43 }