You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
63 lines
1.3 KiB
63 lines
1.3 KiB
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
|
|
#include <info.h>
|
|
#include <pack.h>
|
|
#include <sign.h>
|
|
#include <unpack.h>
|
|
#include <verify.h>
|
|
|
|
struct entry {
|
|
const char *cmd;
|
|
int (* main)(int argc, char *argv[]);
|
|
char *desc;
|
|
};
|
|
|
|
struct entry entries[] = {
|
|
{ "get-offset", do_get_offset,
|
|
"print the offset of the payload within an image" },
|
|
{ "get-size", do_get_size,
|
|
"print the size of the payload within an image" },
|
|
{ "pack", do_pack,
|
|
"pack the payload within an image" },
|
|
{ "sign", do_sign,
|
|
"sign an image" },
|
|
{ "unpack", do_unpack,
|
|
"unpack the payload of an image" },
|
|
{ "verify", do_verify,
|
|
"verify the signatures of an image" },
|
|
{ NULL, NULL, NULL },
|
|
};
|
|
|
|
static void show_usage(const char *prog_name)
|
|
{
|
|
struct entry *entry;
|
|
|
|
fprintf(stderr, "usage: %s <command> ...\n\n"
|
|
"ROTS utilities to work with signed images\n\n"
|
|
"Available commands:\n", prog_name);
|
|
|
|
for (entry = entries; entry->cmd; ++entry) {
|
|
fprintf(stderr, "\t%-16s %-80s\n", entry->cmd, entry->desc);
|
|
}
|
|
}
|
|
|
|
int main(int argc, char *argv[])
|
|
{
|
|
struct entry *entry;
|
|
|
|
if (argc < 2) {
|
|
show_usage(argv[0]);
|
|
return -1;
|
|
}
|
|
|
|
for (entry = entries; entry->cmd; ++entry) {
|
|
if (strcmp(entry->cmd, argv[1]) == 0)
|
|
return entry->main(argc, argv);
|
|
}
|
|
|
|
show_usage(argv[0]);
|
|
|
|
return -1;
|
|
}
|
|
|