aruu

[MIRROR] Actual replacement for Busybox | suckless
git clone https://git.daat.foo/aruu.git
Log | Files | Refs | README | LICENSE

sha512-224sum.c (1159B)


      1 /* see LICENSE file for copyright and license details */
      2 
      3 #include <stdint.h>
      4 #include <stdio.h>
      5 
      6 #include "crypt.h"
      7 #include "sha512-224.h"
      8 #include "util.h"
      9 
     10 static struct sha512_224 s;
     11 struct crypt_ops         sha512_224_ops = {
     12     sha512_224_init,
     13     sha512_224_update,
     14     sha512_224_sum,
     15     &s,
     16 };
     17 
     18 static void
     19 usage(void)
     20 {
     21   eprintf("usage: %s [-c] [file ...]\n", argv0);
     22 }
     23 
     24 // ?man sha512-224sum: compute sha512/224 checksums
     25 // ?man arguments: file ...
     26 // ?man compute and check sha512/224 message digests
     27 int
     28 main(int argc, char *argv[])
     29 {
     30   int     ret = 0, (*cryptfunc)(int, char **, struct crypt_ops *, uint8_t *, size_t) = cryptmain;
     31   uint8_t md[SHA512_224_DIGEST_LENGTH];
     32 
     33   ARGBEGIN
     34   {
     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   }
     48   ARGEND
     49 
     50   ret |= cryptfunc(argc, argv, &sha512_224_ops, md, sizeof(md));
     51   ret |= fshut(stdin, "<stdin>") | fshut(stdout, "<stdout>");
     52 
     53   return ret;
     54 }