diff options
Diffstat (limited to 'nacl/curvecp/curvecpmakekey.c')
-rw-r--r-- | nacl/curvecp/curvecpmakekey.c | 57 |
1 files changed, 0 insertions, 57 deletions
diff --git a/nacl/curvecp/curvecpmakekey.c b/nacl/curvecp/curvecpmakekey.c deleted file mode 100644 index dfa181b0..00000000 --- a/nacl/curvecp/curvecpmakekey.c +++ /dev/null | |||
@@ -1,57 +0,0 @@ | |||
1 | #include <sys/types.h> | ||
2 | #include <sys/stat.h> | ||
3 | #include <unistd.h> | ||
4 | #include "die.h" | ||
5 | #include "e.h" | ||
6 | #include "savesync.h" | ||
7 | #include "randombytes.h" | ||
8 | #include "crypto_box.h" | ||
9 | |||
10 | void die_usage(void) | ||
11 | { | ||
12 | die_1(111,"curvecpmakekey: usage: curvecpmakekey keydir\n"); | ||
13 | } | ||
14 | |||
15 | void die_fatal(const char *trouble,const char *d,const char *fn) | ||
16 | { | ||
17 | if (fn) die_9(111,"curvecpmakekey: fatal: ",trouble," ",d,"/",fn,": ",e_str(errno),"\n"); | ||
18 | die_7(111,"curvecpmakekey: fatal: ",trouble," ",d,": ",e_str(errno),"\n"); | ||
19 | } | ||
20 | |||
21 | unsigned char pk[crypto_box_PUBLICKEYBYTES]; | ||
22 | unsigned char sk[crypto_box_SECRETKEYBYTES]; | ||
23 | unsigned char lock[1]; | ||
24 | unsigned char noncekey[32]; | ||
25 | unsigned char noncecounter[8]; | ||
26 | |||
27 | void create(const char *d,const char *fn,const unsigned char *x,long long xlen) | ||
28 | { | ||
29 | if (savesync(fn,x,xlen) == -1) die_fatal("unable to create",d,fn); | ||
30 | } | ||
31 | |||
32 | int main(int argc,char **argv) | ||
33 | { | ||
34 | char *d; | ||
35 | |||
36 | if (!argv[0]) die_usage(); | ||
37 | if (!argv[1]) die_usage(); | ||
38 | d = argv[1]; | ||
39 | |||
40 | umask(022); | ||
41 | if (mkdir(d,0755) == -1) die_fatal("unable to create directory",d,0); | ||
42 | if (chdir(d) == -1) die_fatal("unable to chdir to directory",d,0); | ||
43 | if (mkdir(".expertsonly",0700) == -1) die_fatal("unable to create directory",d,".expertsonly"); | ||
44 | |||
45 | crypto_box_keypair(pk,sk); | ||
46 | create(d,"publickey",pk,sizeof pk); | ||
47 | |||
48 | randombytes(noncekey,sizeof noncekey); | ||
49 | |||
50 | umask(077); | ||
51 | create(d,".expertsonly/secretkey",sk,sizeof sk); | ||
52 | create(d,".expertsonly/lock",lock,sizeof lock); | ||
53 | create(d,".expertsonly/noncekey",noncekey,sizeof noncekey); | ||
54 | create(d,".expertsonly/noncecounter",noncecounter,sizeof noncecounter); | ||
55 | |||
56 | return 0; | ||
57 | } | ||