Add cryptmain() and factor out the code from the crypt tools
This commit is contained in:
22
util/crypt.c
22
util/crypt.c
@@ -4,6 +4,28 @@
|
||||
#include "../util.h"
|
||||
#include "../crypt.h"
|
||||
|
||||
int
|
||||
cryptmain(int argc, char *argv[],
|
||||
struct crypt_ops *ops, uint8_t *md, size_t sz)
|
||||
{
|
||||
FILE *fp;
|
||||
|
||||
if (argc == 0) {
|
||||
cryptsum(ops, stdin, "<stdin>", md);
|
||||
mdprint(md, "<stdin>", sz);
|
||||
} else {
|
||||
for (; argc > 0; argc--) {
|
||||
if ((fp = fopen(*argv, "r")) == NULL)
|
||||
eprintf("fopen %s:", *argv);
|
||||
cryptsum(ops, fp, *argv, md);
|
||||
mdprint(md, *argv, sz);
|
||||
fclose(fp);
|
||||
argv++;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
cryptsum(struct crypt_ops *ops, FILE *fp, const char *f,
|
||||
uint8_t *md)
|
||||
|
Reference in New Issue
Block a user