summaryrefslogtreecommitdiff
path: root/key.c
diff options
context:
space:
mode:
Diffstat (limited to 'key.c')
-rw-r--r--key.c25
1 files changed, 22 insertions, 3 deletions
diff --git a/key.c b/key.c
index 583c52901..ae355a3fc 100644
--- a/key.c
+++ b/key.c
@@ -255,6 +255,10 @@ key_read(Key *ret, char **cpp)
255 len = 2*strlen(cp); 255 len = 2*strlen(cp);
256 blob = xmalloc(len); 256 blob = xmalloc(len);
257 n = uudecode(cp, blob, len); 257 n = uudecode(cp, blob, len);
258 if (n < 0) {
259 error("uudecode %s failed", cp);
260 return 0;
261 }
258 k = dsa_key_from_blob(blob, n); 262 k = dsa_key_from_blob(blob, n);
259 if (k == NULL) 263 if (k == NULL)
260 return 0; 264 return 0;
@@ -297,11 +301,26 @@ key_write(Key *key, FILE *f)
297 unsigned char *blob, *uu; 301 unsigned char *blob, *uu;
298 dsa_make_key_blob(key, &blob, &len); 302 dsa_make_key_blob(key, &blob, &len);
299 uu = xmalloc(2*len); 303 uu = xmalloc(2*len);
300 n = uuencode(blob, len, uu); 304 n = uuencode(blob, len, uu, 2*len);
301 fprintf(f, "%s %s", SSH_DSS, uu); 305 if (n > 0) {
306 fprintf(f, "%s %s", SSH_DSS, uu);
307 success = 1;
308 }
302 xfree(blob); 309 xfree(blob);
303 xfree(uu); 310 xfree(uu);
304 success = 1;
305 } 311 }
306 return success; 312 return success;
307} 313}
314char *
315key_type(Key *k)
316{
317 switch (k->type) {
318 case KEY_RSA:
319 return "RSA";
320 break;
321 case KEY_DSA:
322 return "DSA";
323 break;
324 }
325 return "unknown";
326}