LEFT | RIGHT |
(no file at all) | |
1 #include <u.h> | 1 #include <u.h> |
2 #include <libc.h> | 2 #include <libc.h> |
3 #include <bio.h> | 3 #include <bio.h> |
4 #include <auth.h> | 4 #include <auth.h> |
5 #include <mp.h> | 5 #include <mp.h> |
6 #include <libsec.h> | 6 #include <libsec.h> |
7 #include "rsa2any.h" | 7 #include "rsa2any.h" |
8 | 8 |
9 RSApriv* | 9 RSApriv* |
10 getkey(int argc, char **argv, int needprivate, Attr **pa) | 10 getkey(int argc, char **argv, int needprivate, Attr **pa) |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 *pa = a; | 157 *pa = a; |
158 return key; | 158 return key; |
159 } | 159 } |
160 | 160 |
161 DSApriv* | 161 DSApriv* |
162 getdsakey(int argc, char **argv, int needprivate, Attr **pa) | 162 getdsakey(int argc, char **argv, int needprivate, Attr **pa) |
163 { | 163 { |
164 char *file, *s, *p; | 164 char *file, *s, *p; |
165 DSApriv *key; | 165 DSApriv *key; |
166 Biobuf *b; | 166 Biobuf *b; |
167 int regen; | |
168 Attr *a; | 167 Attr *a; |
169 | 168 |
170 if(argc == 0) | 169 if(argc == 0) |
171 file = "/dev/stdin"; | 170 file = "/dev/stdin"; |
172 else | 171 else |
173 file = argv[0]; | 172 file = argv[0]; |
174 | 173 |
175 key = mallocz(sizeof(RSApriv), 1); | 174 key = mallocz(sizeof(RSApriv), 1); |
176 if(key == nil) | 175 if(key == nil) |
177 return nil; | 176 return nil; |
178 | 177 |
179 if((b = Bopen(file, OREAD)) == nil){ | 178 if((b = Bopen(file, OREAD)) == nil){ |
180 werrstr("open %s: %r", file); | 179 werrstr("open %s: %r", file); |
181 return nil; | 180 return nil; |
182 } | 181 } |
183 s = Brdstr(b, '\n', 1); | 182 s = Brdstr(b, '\n', 1); |
184 if(s == nil){ | 183 if(s == nil){ |
185 werrstr("read %s: %r", file); | 184 werrstr("read %s: %r", file); |
186 return nil; | 185 return nil; |
187 } | 186 } |
188 if(strncmp(s, "key ", 4) != 0){ | 187 if(strncmp(s, "key ", 4) != 0){ |
189 werrstr("bad key format"); | 188 werrstr("bad key format"); |
190 return nil; | 189 return nil; |
191 } | 190 } |
192 | 191 |
193 regen = 0; | |
194 a = _parseattr(s+4); | 192 a = _parseattr(s+4); |
195 if(a == nil){ | 193 if(a == nil){ |
196 werrstr("empty key"); | 194 werrstr("empty key"); |
197 return nil; | 195 return nil; |
198 } | 196 } |
199 if((p = _strfindattr(a, "proto")) == nil){ | 197 if((p = _strfindattr(a, "proto")) == nil){ |
200 werrstr("no proto"); | 198 werrstr("no proto"); |
201 return nil; | 199 return nil; |
202 } | 200 } |
203 if(strcmp(p, "dsa") != 0){ | 201 if(strcmp(p, "dsa") != 0){ |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 n = (bits+7)/8; | 292 n = (bits+7)/8; |
295 if(bits%8 == 0){ | 293 if(bits%8 == 0){ |
296 p = put4(p, n+1); | 294 p = put4(p, n+1); |
297 *p++ = 0; | 295 *p++ = 0; |
298 }else | 296 }else |
299 p = put4(p, n); | 297 p = put4(p, n); |
300 mptobe(b, p, n, nil); | 298 mptobe(b, p, n, nil); |
301 p += n; | 299 p += n; |
302 return p; | 300 return p; |
303 } | 301 } |
LEFT | RIGHT |