sbase

suckless unix tools
git clone git@git.2f30.org/sbase.git
Log | Files | Refs | README | LICENSE

sha256sum.c (732B)


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