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.h"
9#include "util.h"
10
11static struct sha512 s;
12struct crypt_ops sha512_ops = {
13 sha512_init,
14 sha512_update,
15 sha512_sum,
16 &s,
17};
18
19static void
20usage(void)
21{
22 eprintf("usage: %s [-c] [file ...]\n", argv0);
23}
24
25// ?man sha512sum: compute sha512 checksums
26// ?man arguments: file ...
27// ?man compute and check sha512 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_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_ops, md, sizeof(md));
50 ret |= fshut(stdin, "<stdin>") | fshut(stdout, "<stdout>");
51
52 return ret;
53}