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/keygen.c | |
parent | 40f4f88f04e834a9b9849dd6bcda78c1a1893506 (diff) |
added string key utilities
Diffstat (limited to 'ecp/util/keygen.c')
-rw-r--r-- | ecp/util/keygen.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/ecp/util/keygen.c b/ecp/util/keygen.c new file mode 100644 index 0000000..a0a1507 --- /dev/null +++ b/ecp/util/keygen.c @@ -0,0 +1,37 @@ +#include <stdlib.h> +#include <fcntl.h> +#include <unistd.h> +#include <stdio.h> +#include <string.h> + +#include <ecp/core.h> + +#include "util.h" + +static void usage(char *arg) { + fprintf(stderr, "Usage: %s <pub> <priv>\n", arg); + exit(1); +} + +int main(int argc, char *argv[]) { + ECPDHKey key; + int rv; + + if (argc != 3) usage(argv[0]); + printf("keygen: public=%p, private=%p\n", key.public, key.private); + + rv = ecp_dhkey_gen(&key); + if (rv) goto err; + + rv = ecp_util_save_key(argv[1], &key.public, NULL); + if (rv) goto err; + + rv = ecp_util_save_key(argv[2], &key.public, &key.private); + if (rv) goto err; + + return 0; + +err: + printf("ERR:%d\n", rv); + return 1; +}
\ No newline at end of file |