master xplshn/aruu / cmd / pseudo / sha512-224sum.c
 1/* See LICENSE file for copyright and license details. */
 2
 3
 4#include <stdint.h>
 5#include <stdio.h>
 6
 7#include "crypt.h"
 8#include "sha512-224.h"
 9#include "util.h"
10
11static struct sha512_224 s;
12struct crypt_ops sha512_224_ops = {
13	sha512_224_init,
14	sha512_224_update,
15	sha512_224_sum,
16	&s,
17};
18
19static void
20usage(void)
21{
22	eprintf("usage: %s [-c] [file ...]\n", argv0);
23}
24
25// ?man sha512-224sum: compute sha512/224 checksums
26// ?man arguments: file ...
27// ?man compute and check sha512/224 message digests
28int
29main(int argc, char *argv[])
30{
31	int ret = 0, (*cryptfunc)(int, char **, struct crypt_ops *, uint8_t *, size_t) = cryptmain;
32	uint8_t md[SHA512_224_DIGEST_LENGTH];
33
34	ARGBEGIN {
35	// ?man -b: specify block size or base directory
36	case 'b':
37	// ?man -t: sort or specify timestamp
38	case 't':
39		/* ignore */
40		break;
41	// ?man -c: print count or perform stdout action
42	case 'c':
43		cryptfunc = cryptcheck;
44		break;
45	default:
46		usage();
47	} ARGEND
48
49	ret |= cryptfunc(argc, argv, &sha512_224_ops, md, sizeof(md));
50	ret |= fshut(stdin, "<stdin>") | fshut(stdout, "<stdout>");
51
52	return ret;
53}