Mercurial > dropbear
annotate gensignkey.c @ 1336:efad433418c4
Use atomic key generation in all cases
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Sat, 19 Nov 2016 00:31:21 +0800 |
parents | 2bb4c662d1c2 |
children | 8747c2b19152 |
rev | line source |
---|---|
846
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1 #include "includes.h" |
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2 #include "dbutil.h" |
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
3 #include "buffer.h" |
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
4 #include "ecdsa.h" |
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
5 #include "genrsa.h" |
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
6 #include "gendss.h" |
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
7 #include "signkey.h" |
858
220f55d540ae
rename random.h to dbrandom.h since some OSes have a system random.h
Matt Johnston <matt@ucc.asn.au>
parents:
857
diff
changeset
|
8 #include "dbrandom.h" |
846
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
9 |
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
10 #define RSA_DEFAULT_SIZE 2048 |
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
11 #define DSS_DEFAULT_SIZE 1024 |
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
12 |
857 | 13 /* Returns DROPBEAR_SUCCESS or DROPBEAR_FAILURE */ |
846
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
14 static int buf_writefile(buffer * buf, const char * filename) { |
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
15 int ret = DROPBEAR_FAILURE; |
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
16 int fd = -1; |
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
17 |
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
18 fd = open(filename, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR); |
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
19 if (fd < 0) { |
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
20 dropbear_log(LOG_ERR, "Couldn't create new file %s: %s", |
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
21 filename, strerror(errno)); |
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
22 goto out; |
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
23 } |
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
24 |
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
25 /* write the file now */ |
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
26 while (buf->pos != buf->len) { |
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
27 int len = write(fd, buf_getptr(buf, buf->len - buf->pos), |
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
28 buf->len - buf->pos); |
888 | 29 if (len == -1 && errno == EINTR) { |
846
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
30 continue; |
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
31 } |
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
32 if (len <= 0) { |
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
33 dropbear_log(LOG_ERR, "Failed writing file %s: %s", |
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
34 filename, strerror(errno)); |
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
35 goto out; |
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
36 } |
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
37 buf_incrpos(buf, len); |
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
38 } |
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
39 |
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
40 ret = DROPBEAR_SUCCESS; |
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
41 |
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
42 out: |
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
43 if (fd >= 0) { |
983
2b62f26cf808
Open directories O_RDONLY for fsync, add debugging if it fails
Matt Johnston <matt@ucc.asn.au>
parents:
982
diff
changeset
|
44 if (fsync(fd) != 0) { |
2b62f26cf808
Open directories O_RDONLY for fsync, add debugging if it fails
Matt Johnston <matt@ucc.asn.au>
parents:
982
diff
changeset
|
45 dropbear_log(LOG_ERR, "fsync of %s failed: %s", filename, strerror(errno)); |
2b62f26cf808
Open directories O_RDONLY for fsync, add debugging if it fails
Matt Johnston <matt@ucc.asn.au>
parents:
982
diff
changeset
|
46 } |
846
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
47 m_close(fd); |
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
48 } |
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
49 return ret; |
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
50 } |
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
51 |
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
52 /* returns 0 on failure */ |
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
53 static int get_default_bits(enum signkey_type keytype) |
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
54 { |
1250 | 55 switch (keytype) { |
846
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
56 #ifdef DROPBEAR_RSA |
1250 | 57 case DROPBEAR_SIGNKEY_RSA: |
58 return RSA_DEFAULT_SIZE; | |
846
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
59 #endif |
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
60 #ifdef DROPBEAR_DSS |
1250 | 61 case DROPBEAR_SIGNKEY_DSS: |
62 return DSS_DEFAULT_SIZE; | |
846
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
63 #endif |
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
64 #ifdef DROPBEAR_ECDSA |
1250 | 65 case DROPBEAR_SIGNKEY_ECDSA_KEYGEN: |
66 return ECDSA_DEFAULT_SIZE; | |
67 case DROPBEAR_SIGNKEY_ECDSA_NISTP521: | |
68 return 521; | |
69 case DROPBEAR_SIGNKEY_ECDSA_NISTP384: | |
70 return 384; | |
71 case DROPBEAR_SIGNKEY_ECDSA_NISTP256: | |
72 return 256; | |
846
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
73 #endif |
1250 | 74 default: |
75 return 0; | |
76 } | |
846
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
77 } |
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
78 |
1336
efad433418c4
Use atomic key generation in all cases
Matt Johnston <matt@ucc.asn.au>
parents:
1250
diff
changeset
|
79 /* if skip_exist is set it will silently return if the key file exists */ |
efad433418c4
Use atomic key generation in all cases
Matt Johnston <matt@ucc.asn.au>
parents:
1250
diff
changeset
|
80 int signkey_generate(enum signkey_type keytype, int bits, const char* filename, int skip_exist) |
846
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
81 { |
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
82 sign_key * key = NULL; |
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
83 buffer *buf = NULL; |
1336
efad433418c4
Use atomic key generation in all cases
Matt Johnston <matt@ucc.asn.au>
parents:
1250
diff
changeset
|
84 char *fn_temp = NULL; |
846
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
85 int ret = DROPBEAR_FAILURE; |
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
86 if (bits == 0) |
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
87 { |
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
88 bits = get_default_bits(keytype); |
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
89 } |
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
90 |
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
91 /* now we can generate the key */ |
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
92 key = new_sign_key(); |
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
93 |
852
7540c0822374
Various cleanups and fixes for warnings
Matt Johnston <matt@ucc.asn.au>
parents:
847
diff
changeset
|
94 seedrandom(); |
7540c0822374
Various cleanups and fixes for warnings
Matt Johnston <matt@ucc.asn.au>
parents:
847
diff
changeset
|
95 |
846
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
96 switch(keytype) { |
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
97 #ifdef DROPBEAR_RSA |
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
98 case DROPBEAR_SIGNKEY_RSA: |
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
99 key->rsakey = gen_rsa_priv_key(bits); |
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
100 break; |
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
101 #endif |
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
102 #ifdef DROPBEAR_DSS |
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
103 case DROPBEAR_SIGNKEY_DSS: |
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
104 key->dsskey = gen_dss_priv_key(bits); |
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
105 break; |
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
106 #endif |
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
107 #ifdef DROPBEAR_ECDSA |
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
108 case DROPBEAR_SIGNKEY_ECDSA_KEYGEN: |
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
109 case DROPBEAR_SIGNKEY_ECDSA_NISTP521: |
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
110 case DROPBEAR_SIGNKEY_ECDSA_NISTP384: |
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
111 case DROPBEAR_SIGNKEY_ECDSA_NISTP256: |
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
112 { |
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
113 ecc_key *ecckey = gen_ecdsa_priv_key(bits); |
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
114 keytype = ecdsa_signkey_type(ecckey); |
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
115 *signkey_key_ptr(key, keytype) = ecckey; |
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
116 } |
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
117 break; |
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
118 #endif |
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
119 default: |
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
120 dropbear_exit("Internal error"); |
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
121 } |
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
122 |
852
7540c0822374
Various cleanups and fixes for warnings
Matt Johnston <matt@ucc.asn.au>
parents:
847
diff
changeset
|
123 seedrandom(); |
7540c0822374
Various cleanups and fixes for warnings
Matt Johnston <matt@ucc.asn.au>
parents:
847
diff
changeset
|
124 |
846
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
125 buf = buf_new(MAX_PRIVKEY_SIZE); |
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
126 |
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
127 buf_put_priv_key(buf, key, keytype); |
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
128 sign_key_free(key); |
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
129 key = NULL; |
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
130 buf_setpos(buf, 0); |
1336
efad433418c4
Use atomic key generation in all cases
Matt Johnston <matt@ucc.asn.au>
parents:
1250
diff
changeset
|
131 |
efad433418c4
Use atomic key generation in all cases
Matt Johnston <matt@ucc.asn.au>
parents:
1250
diff
changeset
|
132 fn_temp = m_malloc(strlen(filename) + 30); |
efad433418c4
Use atomic key generation in all cases
Matt Johnston <matt@ucc.asn.au>
parents:
1250
diff
changeset
|
133 snprintf(fn_temp, strlen(filename)+30, "%s.tmp%d", filename, getpid()); |
efad433418c4
Use atomic key generation in all cases
Matt Johnston <matt@ucc.asn.au>
parents:
1250
diff
changeset
|
134 ret = buf_writefile(buf, fn_temp); |
efad433418c4
Use atomic key generation in all cases
Matt Johnston <matt@ucc.asn.au>
parents:
1250
diff
changeset
|
135 |
efad433418c4
Use atomic key generation in all cases
Matt Johnston <matt@ucc.asn.au>
parents:
1250
diff
changeset
|
136 if (ret == DROPBEAR_FAILURE) { |
efad433418c4
Use atomic key generation in all cases
Matt Johnston <matt@ucc.asn.au>
parents:
1250
diff
changeset
|
137 goto out; |
efad433418c4
Use atomic key generation in all cases
Matt Johnston <matt@ucc.asn.au>
parents:
1250
diff
changeset
|
138 } |
846
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
139 |
1336
efad433418c4
Use atomic key generation in all cases
Matt Johnston <matt@ucc.asn.au>
parents:
1250
diff
changeset
|
140 if (link(fn_temp, filename) < 0) { |
efad433418c4
Use atomic key generation in all cases
Matt Johnston <matt@ucc.asn.au>
parents:
1250
diff
changeset
|
141 /* If generating keys on connection (skipexist) it's OK to get EEXIST |
efad433418c4
Use atomic key generation in all cases
Matt Johnston <matt@ucc.asn.au>
parents:
1250
diff
changeset
|
142 - we probably just lost a race with another connection to generate the key */ |
efad433418c4
Use atomic key generation in all cases
Matt Johnston <matt@ucc.asn.au>
parents:
1250
diff
changeset
|
143 if (!(skip_exist && errno == EEXIST)) { |
efad433418c4
Use atomic key generation in all cases
Matt Johnston <matt@ucc.asn.au>
parents:
1250
diff
changeset
|
144 dropbear_log(LOG_ERR, "Failed moving key file to %s: %s", filename, |
efad433418c4
Use atomic key generation in all cases
Matt Johnston <matt@ucc.asn.au>
parents:
1250
diff
changeset
|
145 strerror(errno)); |
efad433418c4
Use atomic key generation in all cases
Matt Johnston <matt@ucc.asn.au>
parents:
1250
diff
changeset
|
146 /* XXX fallback to non-atomic copy for some filesystems? */ |
efad433418c4
Use atomic key generation in all cases
Matt Johnston <matt@ucc.asn.au>
parents:
1250
diff
changeset
|
147 ret = DROPBEAR_FAILURE; |
efad433418c4
Use atomic key generation in all cases
Matt Johnston <matt@ucc.asn.au>
parents:
1250
diff
changeset
|
148 goto out; |
efad433418c4
Use atomic key generation in all cases
Matt Johnston <matt@ucc.asn.au>
parents:
1250
diff
changeset
|
149 } |
efad433418c4
Use atomic key generation in all cases
Matt Johnston <matt@ucc.asn.au>
parents:
1250
diff
changeset
|
150 } |
efad433418c4
Use atomic key generation in all cases
Matt Johnston <matt@ucc.asn.au>
parents:
1250
diff
changeset
|
151 |
efad433418c4
Use atomic key generation in all cases
Matt Johnston <matt@ucc.asn.au>
parents:
1250
diff
changeset
|
152 out: |
efad433418c4
Use atomic key generation in all cases
Matt Johnston <matt@ucc.asn.au>
parents:
1250
diff
changeset
|
153 if (buf) { |
efad433418c4
Use atomic key generation in all cases
Matt Johnston <matt@ucc.asn.au>
parents:
1250
diff
changeset
|
154 buf_burn(buf); |
efad433418c4
Use atomic key generation in all cases
Matt Johnston <matt@ucc.asn.au>
parents:
1250
diff
changeset
|
155 buf_free(buf); |
efad433418c4
Use atomic key generation in all cases
Matt Johnston <matt@ucc.asn.au>
parents:
1250
diff
changeset
|
156 } |
efad433418c4
Use atomic key generation in all cases
Matt Johnston <matt@ucc.asn.au>
parents:
1250
diff
changeset
|
157 |
efad433418c4
Use atomic key generation in all cases
Matt Johnston <matt@ucc.asn.au>
parents:
1250
diff
changeset
|
158 if (fn_temp) { |
efad433418c4
Use atomic key generation in all cases
Matt Johnston <matt@ucc.asn.au>
parents:
1250
diff
changeset
|
159 unlink(fn_temp); |
efad433418c4
Use atomic key generation in all cases
Matt Johnston <matt@ucc.asn.au>
parents:
1250
diff
changeset
|
160 m_free(fn_temp); |
efad433418c4
Use atomic key generation in all cases
Matt Johnston <matt@ucc.asn.au>
parents:
1250
diff
changeset
|
161 } |
efad433418c4
Use atomic key generation in all cases
Matt Johnston <matt@ucc.asn.au>
parents:
1250
diff
changeset
|
162 |
846
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
163 return ret; |
b298bb438625
refactor key generation, make it generate as required.
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
164 } |