diff options
author | Uros Majstorovic <majstor@majstor.org> | 2024-04-23 18:07:21 +0200 |
---|---|---|
committer | Uros Majstorovic <majstor@majstor.org> | 2024-04-23 18:07:21 +0200 |
commit | 503ac614ea91b4fdd9d5f6f467a2efcad900a7e1 (patch) | |
tree | 43db3f29292cbce58ab32667f722e3eed316ca7f /ecp/util/mknode.c | |
parent | 40f4f88f04e834a9b9849dd6bcda78c1a1893506 (diff) |
added string key utilities
Diffstat (limited to 'ecp/util/mknode.c')
-rw-r--r-- | ecp/util/mknode.c | 63 |
1 files changed, 0 insertions, 63 deletions
diff --git a/ecp/util/mknode.c b/ecp/util/mknode.c deleted file mode 100644 index bc66da0..0000000 --- a/ecp/util/mknode.c +++ /dev/null @@ -1,63 +0,0 @@ -#include <stdlib.h> -#include <fcntl.h> -#include <unistd.h> -#include <stdio.h> -#include <string.h> - -#include <ecp/core.h> - -#include "util.h" - -#define FN_LEN 256 - -static char fn_key[FN_LEN]; -static char fn_node[FN_LEN]; - -static void usage(char *arg) { - fprintf(stderr, "Usage: %s <name> [address]\n", arg); - exit(1); -} - -int main(int argc, char *argv[]) { - char *addr; - ECPDHKey key; - ECPNode node; - int rv; - - if ((argc < 2) || (argc > 3)) usage(argv[0]); - - addr = NULL; - if (argc == 3) addr = argv[2]; - - if (strlen(argv[1]) > FN_LEN - 6) usage(argv[0]); - strcpy(fn_node, argv[1]); - strcpy(fn_key, argv[1]); - strcat(fn_key, ".priv"); - strcat(fn_node, ".pub"); - - rv = ecp_dhkey_gen(&key); - if (rv) goto err; - - ecp_node_init(&node, &key.public, NULL); - if (addr) { - rv = ecp_node_set_addr(&node, addr); - if (rv) goto err; - } - - rv = ecp_util_save_key(&key.public, &key.private, fn_key); - if (rv) goto err; - - if (addr) { - rv = ecp_util_save_node(&node, fn_node); - if (rv) goto err; - } else { - rv = ecp_util_save_pub(&key.public, fn_node); - if (rv) goto err; - } - - return 0; - -err: - printf("ERR:%d\n", rv); - return 1; -}
\ No newline at end of file |