2 * Copyright (C) 2018 Daniel Golle <daniel@makrotopia.org>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3
6 * as published by the Free Software Foundation
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
29 #include <json-c/json.h>
30 #include <libubox/blob.h>
31 #include <libubox/list.h>
32 #include <libubox/vlist.h>
33 #include <libubox/blobmsg_json.h>
46 static int cert_append(const char *certfile
, const char *pubkeyfile
, const char *sigfile
) {
47 fprintf(stderr
, "not implemented\n");
51 static int cert_dump(const char *certfile
) {
52 fprintf(stderr
, "not implemented\n");
56 static int cert_issue(const char *certfile
, const char *pubkeyfile
, const char *seckeyfile
) {
57 fprintf(stderr
, "not implemented\n");
61 static int cert_process_revoker(const char *certfile
) {
62 fprintf(stderr
, "not implemented\n");
66 static int cert_verify(const char *certfile
, const char *pubkeyfile
, const char *pubkeydir
, const char *msgfile
) {
67 fprintf(stderr
, "not implemented\n");
71 static int usage(const char *cmd
)
74 "Usage: %s <command> <options>\n"
76 " -A: append (needs -c and -p and/or -x)\n"
78 " -I: issue cert and revoker (needs -c and -p and -s)\n"
79 " -R: process revoker certificate (needs -c)\n"
80 " -V: verify (needs -c and -p|-P)\n"
82 " -c <file>: certificate file\n"
83 " -m <file>: message file (verify only)\n"
84 " -p <file>: public key file\n"
85 " -P <path>: public key directory (verify only)\n"
86 " -q: quiet (do not print verification result, use return code only)\n"
87 " -s <file>: secret key file (issue only)\n"
88 " -x <file>: signature file\n"
94 int main(int argc
, char *argv
[]) {
96 const char *msgfile
= NULL
;
97 const char *sigfile
= NULL
;
98 const char *pubkeyfile
= NULL
;
99 const char *pubkeydir
= NULL
;
100 const char *certfile
= NULL
;
101 const char *seckeyfile
= NULL
;
104 while ((ch
= getopt(argc
, argv
, "ADIRVc:m:p:P:qs:x:")) != -1) {
143 return usage(argv
[0]);
149 if (certfile
&& (pubkeyfile
|| sigfile
))
150 return cert_append(certfile
, pubkeyfile
, sigfile
);
152 return usage(argv
[0]);
155 return cert_dump(certfile
);
157 return usage(argv
[0]);
159 if (certfile
&& pubkeyfile
&& seckeyfile
)
160 return cert_issue(certfile
, pubkeyfile
, seckeyfile
);
162 return usage(argv
[0]);
165 return cert_process_revoker(certfile
);
167 return usage(argv
[0]);
169 if (certfile
&& (pubkeyfile
|| pubkeydir
))
170 return cert_verify(certfile
, pubkeyfile
, pubkeydir
, msgfile
);
172 return usage(argv
[0]);
174 return usage(argv
[0]);
178 return usage(argv
[0]);