morpheus-base

morpheus base system
git clone git://git.2f30.org/morpheus-base
Log | Files | Refs

sha512sum.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 "sha512.h"
      8 #include "util.h"
      9 
     10 static struct sha512 s;
     11 struct crypt_ops sha512_ops = {
     12 	sha512_init,
     13 	sha512_update,
     14 	sha512_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[SHA512_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, &sha512_ops, md, sizeof(md));
     42 	return cryptmain(argc, argv, &sha512_ops, md, sizeof(md));
     43 }