blob: a0a15074e0ab0648da6d99733e653670ebd843da (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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;
}
|