3eca8453 |
1 | /* |
a52f067e |
2 | * Generic SSH public-key handling operations. In particular, |
3 | * reading of SSH public-key files, and also the generic `sign' |
4 | * operation for ssh2 (which checks the type of the key and |
5 | * dispatches to the appropriate key-type specific function). |
3eca8453 |
6 | */ |
7 | |
8 | #include <stdio.h> |
a52f067e |
9 | #include <stdlib.h> |
65a22376 |
10 | #include <assert.h> |
3eca8453 |
11 | |
3eca8453 |
12 | #include "ssh.h" |
7bedb13c |
13 | #include "misc.h" |
3eca8453 |
14 | |
6e522441 |
15 | #define PUT_32BIT(cp, value) do { \ |
16 | (cp)[3] = (value); \ |
17 | (cp)[2] = (value) >> 8; \ |
18 | (cp)[1] = (value) >> 16; \ |
19 | (cp)[0] = (value) >> 24; } while (0) |
20 | |
3eca8453 |
21 | #define GET_32BIT(cp) \ |
22 | (((unsigned long)(unsigned char)(cp)[0] << 24) | \ |
23 | ((unsigned long)(unsigned char)(cp)[1] << 16) | \ |
24 | ((unsigned long)(unsigned char)(cp)[2] << 8) | \ |
25 | ((unsigned long)(unsigned char)(cp)[3])) |
26 | |
27 | #define rsa_signature "SSH PRIVATE KEY FILE FORMAT 1.1\n" |
28 | |
a52f067e |
29 | #define BASE64_TOINT(x) ( (x)-'A'<26 ? (x)-'A'+0 :\ |
30 | (x)-'a'<26 ? (x)-'a'+26 :\ |
31 | (x)-'0'<10 ? (x)-'0'+52 :\ |
32 | (x)=='+' ? 62 : \ |
33 | (x)=='/' ? 63 : 0 ) |
34 | |
3f2d010c |
35 | static int loadrsakey_main(FILE * fp, struct RSAKey *key, int pub_only, |
32874aea |
36 | char **commentptr, char *passphrase) |
37 | { |
3eca8453 |
38 | unsigned char buf[16384]; |
39 | unsigned char keybuf[16]; |
40 | int len; |
41 | int i, j, ciphertype; |
42 | int ret = 0; |
43 | struct MD5Context md5c; |
a52f067e |
44 | char *comment; |
3eca8453 |
45 | |
a52f067e |
46 | /* Slurp the whole file (minus the header) into a buffer. */ |
3eca8453 |
47 | len = fread(buf, 1, sizeof(buf), fp); |
48 | fclose(fp); |
49 | if (len < 0 || len == sizeof(buf)) |
32874aea |
50 | goto end; /* file too big or not read */ |
3eca8453 |
51 | |
a52f067e |
52 | i = 0; |
3eca8453 |
53 | |
a52f067e |
54 | /* |
55 | * A zero byte. (The signature includes a terminating NUL.) |
56 | */ |
32874aea |
57 | if (len - i < 1 || buf[i] != 0) |
58 | goto end; |
a52f067e |
59 | i++; |
3eca8453 |
60 | |
a52f067e |
61 | /* One byte giving encryption type, and one reserved uint32. */ |
32874aea |
62 | if (len - i < 1) |
63 | goto end; |
3eca8453 |
64 | ciphertype = buf[i]; |
65 | if (ciphertype != 0 && ciphertype != SSH_CIPHER_3DES) |
32874aea |
66 | goto end; |
3eca8453 |
67 | i++; |
32874aea |
68 | if (len - i < 4) |
69 | goto end; /* reserved field not present */ |
70 | if (buf[i] != 0 || buf[i + 1] != 0 || buf[i + 2] != 0 |
71 | || buf[i + 3] != 0) goto end; /* reserved field nonzero, panic! */ |
3eca8453 |
72 | i += 4; |
73 | |
74 | /* Now the serious stuff. An ordinary SSH 1 public key. */ |
32874aea |
75 | i += makekey(buf + i, key, NULL, 1); |
76 | if (len - i < 0) |
77 | goto end; /* overran */ |
3eca8453 |
78 | |
3f2d010c |
79 | if (pub_only) { |
80 | ret = 1; |
81 | goto end; |
82 | } |
83 | |
3eca8453 |
84 | /* Next, the comment field. */ |
32874aea |
85 | j = GET_32BIT(buf + i); |
5c58ad2d |
86 | i += 4; |
32874aea |
87 | if (len - i < j) |
88 | goto end; |
89 | comment = smalloc(j + 1); |
a52f067e |
90 | if (comment) { |
32874aea |
91 | memcpy(comment, buf + i, j); |
92 | comment[j] = '\0'; |
5c58ad2d |
93 | } |
94 | i += j; |
a52f067e |
95 | if (commentptr) |
32874aea |
96 | *commentptr = comment; |
a52f067e |
97 | if (key) |
32874aea |
98 | key->comment = comment; |
a52f067e |
99 | if (!key) { |
32874aea |
100 | return ciphertype != 0; |
a52f067e |
101 | } |
3eca8453 |
102 | |
103 | /* |
104 | * Decrypt remainder of buffer. |
105 | */ |
106 | if (ciphertype) { |
32874aea |
107 | MD5Init(&md5c); |
2247e107 |
108 | MD5Update(&md5c, (unsigned char *)passphrase, strlen(passphrase)); |
32874aea |
109 | MD5Final(keybuf, &md5c); |
110 | des3_decrypt_pubkey(keybuf, buf + i, (len - i + 7) & ~7); |
111 | memset(keybuf, 0, sizeof(keybuf)); /* burn the evidence */ |
3eca8453 |
112 | } |
113 | |
114 | /* |
115 | * We are now in the secret part of the key. The first four |
116 | * bytes should be of the form a, b, a, b. |
117 | */ |
32874aea |
118 | if (len - i < 4) |
119 | goto end; |
120 | if (buf[i] != buf[i + 2] || buf[i + 1] != buf[i + 3]) { |
121 | ret = -1; |
122 | goto end; |
123 | } |
3eca8453 |
124 | i += 4; |
125 | |
126 | /* |
127 | * After that, we have one further bignum which is our |
6e522441 |
128 | * decryption exponent, and then the three auxiliary values |
129 | * (iqmp, q, p). |
3eca8453 |
130 | */ |
32874aea |
131 | i += makeprivate(buf + i, key); |
132 | if (len - i < 0) |
133 | goto end; |
134 | i += ssh1_read_bignum(buf + i, &key->iqmp); |
135 | if (len - i < 0) |
136 | goto end; |
137 | i += ssh1_read_bignum(buf + i, &key->q); |
138 | if (len - i < 0) |
139 | goto end; |
140 | i += ssh1_read_bignum(buf + i, &key->p); |
141 | if (len - i < 0) |
142 | goto end; |
3eca8453 |
143 | |
98f022f5 |
144 | if (!rsa_verify(key)) { |
145 | freersakey(key); |
146 | ret = 0; |
147 | } else |
148 | ret = 1; |
149 | |
32874aea |
150 | end: |
3eca8453 |
151 | memset(buf, 0, sizeof(buf)); /* burn the evidence */ |
152 | return ret; |
153 | } |
154 | |
32874aea |
155 | int loadrsakey(char *filename, struct RSAKey *key, char *passphrase) |
156 | { |
3eca8453 |
157 | FILE *fp; |
2247e107 |
158 | char buf[64]; |
3eca8453 |
159 | |
160 | fp = fopen(filename, "rb"); |
161 | if (!fp) |
32874aea |
162 | return 0; /* doesn't even exist */ |
3eca8453 |
163 | |
a52f067e |
164 | /* |
165 | * Read the first line of the file and see if it's a v1 private |
166 | * key file. |
167 | */ |
32874aea |
168 | if (fgets(buf, sizeof(buf), fp) && !strcmp(buf, rsa_signature)) { |
3f2d010c |
169 | return loadrsakey_main(fp, key, FALSE, NULL, passphrase); |
a52f067e |
170 | } |
171 | |
172 | /* |
173 | * Otherwise, we have nothing. Return empty-handed. |
174 | */ |
3eca8453 |
175 | fclose(fp); |
3eca8453 |
176 | return 0; |
177 | } |
a52f067e |
178 | |
179 | /* |
180 | * See whether an RSA key is encrypted. Return its comment field as |
181 | * well. |
182 | */ |
32874aea |
183 | int rsakey_encrypted(char *filename, char **comment) |
184 | { |
a52f067e |
185 | FILE *fp; |
2247e107 |
186 | char buf[64]; |
a52f067e |
187 | |
188 | fp = fopen(filename, "rb"); |
189 | if (!fp) |
32874aea |
190 | return 0; /* doesn't even exist */ |
a52f067e |
191 | |
192 | /* |
193 | * Read the first line of the file and see if it's a v1 private |
194 | * key file. |
195 | */ |
32874aea |
196 | if (fgets(buf, sizeof(buf), fp) && !strcmp(buf, rsa_signature)) { |
3f2d010c |
197 | return loadrsakey_main(fp, NULL, FALSE, comment, NULL); |
a52f067e |
198 | } |
404f728b |
199 | fclose(fp); |
32874aea |
200 | return 0; /* wasn't the right kind of file */ |
a52f067e |
201 | } |
6e522441 |
202 | |
203 | /* |
3f2d010c |
204 | * Return a malloc'ed chunk of memory containing the public blob of |
205 | * an RSA key, as given in the agent protocol (modulus bits, |
206 | * exponent, modulus). |
207 | */ |
208 | int rsakey_pubblob(char *filename, void **blob, int *bloblen) |
209 | { |
210 | FILE *fp; |
2247e107 |
211 | char buf[64]; |
3f2d010c |
212 | struct RSAKey key; |
213 | int ret; |
214 | |
215 | /* Default return if we fail. */ |
216 | *blob = NULL; |
217 | *bloblen = 0; |
218 | ret = 0; |
219 | |
220 | fp = fopen(filename, "rb"); |
221 | if (!fp) |
222 | return 0; /* doesn't even exist */ |
223 | |
224 | /* |
225 | * Read the first line of the file and see if it's a v1 private |
226 | * key file. |
227 | */ |
228 | if (fgets(buf, sizeof(buf), fp) && !strcmp(buf, rsa_signature)) { |
229 | memset(&key, 0, sizeof(key)); |
230 | if (loadrsakey_main(fp, &key, TRUE, NULL, NULL)) { |
231 | *blob = rsa_public_blob(&key, bloblen); |
232 | freersakey(&key); |
233 | ret = 1; |
234 | } |
235 | } |
236 | fclose(fp); |
237 | return ret; |
238 | } |
239 | |
240 | /* |
6e522441 |
241 | * Save an RSA key file. Return nonzero on success. |
242 | */ |
32874aea |
243 | int saversakey(char *filename, struct RSAKey *key, char *passphrase) |
244 | { |
6e522441 |
245 | unsigned char buf[16384]; |
246 | unsigned char keybuf[16]; |
247 | struct MD5Context md5c; |
49bad831 |
248 | unsigned char *p, *estart; |
6e522441 |
249 | FILE *fp; |
250 | |
251 | /* |
252 | * Write the initial signature. |
253 | */ |
254 | p = buf; |
255 | memcpy(p, rsa_signature, sizeof(rsa_signature)); |
256 | p += sizeof(rsa_signature); |
257 | |
258 | /* |
259 | * One byte giving encryption type, and one reserved (zero) |
260 | * uint32. |
261 | */ |
262 | *p++ = (passphrase ? SSH_CIPHER_3DES : 0); |
32874aea |
263 | PUT_32BIT(p, 0); |
264 | p += 4; |
6e522441 |
265 | |
266 | /* |
267 | * An ordinary SSH 1 public key consists of: a uint32 |
268 | * containing the bit count, then two bignums containing the |
269 | * modulus and exponent respectively. |
270 | */ |
32874aea |
271 | PUT_32BIT(p, bignum_bitcount(key->modulus)); |
272 | p += 4; |
6e522441 |
273 | p += ssh1_write_bignum(p, key->modulus); |
274 | p += ssh1_write_bignum(p, key->exponent); |
275 | |
276 | /* |
277 | * A string containing the comment field. |
278 | */ |
279 | if (key->comment) { |
32874aea |
280 | PUT_32BIT(p, strlen(key->comment)); |
281 | p += 4; |
282 | memcpy(p, key->comment, strlen(key->comment)); |
283 | p += strlen(key->comment); |
6e522441 |
284 | } else { |
32874aea |
285 | PUT_32BIT(p, 0); |
286 | p += 4; |
6e522441 |
287 | } |
288 | |
289 | /* |
290 | * The encrypted portion starts here. |
291 | */ |
292 | estart = p; |
293 | |
294 | /* |
295 | * Two bytes, then the same two bytes repeated. |
296 | */ |
297 | *p++ = random_byte(); |
298 | *p++ = random_byte(); |
32874aea |
299 | p[0] = p[-2]; |
300 | p[1] = p[-1]; |
301 | p += 2; |
6e522441 |
302 | |
303 | /* |
304 | * Four more bignums: the decryption exponent, then iqmp, then |
305 | * q, then p. |
306 | */ |
307 | p += ssh1_write_bignum(p, key->private_exponent); |
65a22376 |
308 | p += ssh1_write_bignum(p, key->iqmp); |
309 | p += ssh1_write_bignum(p, key->q); |
310 | p += ssh1_write_bignum(p, key->p); |
6e522441 |
311 | |
312 | /* |
313 | * Now write zeros until the encrypted portion is a multiple of |
314 | * 8 bytes. |
315 | */ |
32874aea |
316 | while ((p - estart) % 8) |
317 | *p++ = '\0'; |
6e522441 |
318 | |
319 | /* |
320 | * Now encrypt the encrypted portion. |
321 | */ |
322 | if (passphrase) { |
32874aea |
323 | MD5Init(&md5c); |
2247e107 |
324 | MD5Update(&md5c, (unsigned char *)passphrase, strlen(passphrase)); |
32874aea |
325 | MD5Final(keybuf, &md5c); |
326 | des3_encrypt_pubkey(keybuf, estart, p - estart); |
327 | memset(keybuf, 0, sizeof(keybuf)); /* burn the evidence */ |
6e522441 |
328 | } |
329 | |
330 | /* |
331 | * Done. Write the result to the file. |
332 | */ |
333 | fp = fopen(filename, "wb"); |
334 | if (fp) { |
32874aea |
335 | int ret = (fwrite(buf, 1, p - buf, fp) == (size_t) (p - buf)); |
336 | ret = ret && (fclose(fp) == 0); |
337 | return ret; |
6e522441 |
338 | } else |
32874aea |
339 | return 0; |
6e522441 |
340 | } |
65a22376 |
341 | |
342 | /* ---------------------------------------------------------------------- |
343 | * SSH2 private key load/store functions. |
344 | */ |
345 | |
346 | /* |
347 | * PuTTY's own format for SSH2 keys is as follows: |
5c72ca61 |
348 | * |
65a22376 |
349 | * The file is text. Lines are terminated by CRLF, although CR-only |
350 | * and LF-only are tolerated on input. |
5c72ca61 |
351 | * |
7bedb13c |
352 | * The first line says "PuTTY-User-Key-File-2: " plus the name of the |
5c72ca61 |
353 | * algorithm ("ssh-dss", "ssh-rsa" etc). |
354 | * |
65a22376 |
355 | * The next line says "Encryption: " plus an encryption type. |
356 | * Currently the only supported encryption types are "aes256-cbc" |
357 | * and "none". |
5c72ca61 |
358 | * |
65a22376 |
359 | * The next line says "Comment: " plus the comment string. |
5c72ca61 |
360 | * |
65a22376 |
361 | * Next there is a line saying "Public-Lines: " plus a number N. |
362 | * The following N lines contain a base64 encoding of the public |
363 | * part of the key. This is encoded as the standard SSH2 public key |
364 | * blob (with no initial length): so for RSA, for example, it will |
365 | * read |
5c72ca61 |
366 | * |
65a22376 |
367 | * string "ssh-rsa" |
368 | * mpint exponent |
369 | * mpint modulus |
5c72ca61 |
370 | * |
65a22376 |
371 | * Next, there is a line saying "Private-Lines: " plus a number N, |
372 | * and then N lines containing the (potentially encrypted) private |
373 | * part of the key. For the key type "ssh-rsa", this will be |
374 | * composed of |
5c72ca61 |
375 | * |
65a22376 |
376 | * mpint private_exponent |
377 | * mpint p (the larger of the two primes) |
378 | * mpint q (the smaller prime) |
379 | * mpint iqmp (the inverse of q modulo p) |
380 | * data padding (to reach a multiple of the cipher block size) |
5c72ca61 |
381 | * |
382 | * And for "ssh-dss", it will be composed of |
383 | * |
384 | * mpint x (the private key parameter) |
7bedb13c |
385 | * [ string hash 20-byte hash of mpints p || q || g only in old format ] |
5c72ca61 |
386 | * |
7bedb13c |
387 | * Finally, there is a line saying "Private-MAC: " plus a hex |
388 | * representation of a HMAC-SHA-1 of: |
389 | * |
390 | * string name of algorithm ("ssh-dss", "ssh-rsa") |
391 | * string encryption type |
392 | * string comment |
393 | * string public-blob |
394 | * string private-plaintext (the plaintext version of the |
395 | * private part, including the final |
396 | * padding) |
65a22376 |
397 | * |
5c72ca61 |
398 | * The key to the MAC is itself a SHA-1 hash of: |
65a22376 |
399 | * |
5c72ca61 |
400 | * data "putty-private-key-file-mac-key" |
401 | * data passphrase |
402 | * |
403 | * Encrypted keys should have a MAC, whereas unencrypted ones must |
404 | * have a hash. |
405 | * |
65a22376 |
406 | * If the key is encrypted, the encryption key is derived from the |
407 | * passphrase by means of a succession of SHA-1 hashes. Each hash |
408 | * is the hash of: |
5c72ca61 |
409 | * |
65a22376 |
410 | * uint32 sequence-number |
5c72ca61 |
411 | * data passphrase |
412 | * |
65a22376 |
413 | * where the sequence-number increases from zero. As many of these |
414 | * hashes are used as necessary. |
5c72ca61 |
415 | * |
7bedb13c |
416 | * For backwards compatibility with snapshots between 0.51 and |
417 | * 0.52, we also support the older key file format, which begins |
418 | * with "PuTTY-User-Key-File-1" (version number differs). In this |
419 | * format the Private-MAC: field only covers the private-plaintext |
420 | * field and nothing else (and without the 4-byte string length on |
421 | * the front too). Moreover, for RSA keys the Private-MAC: field |
422 | * can be replaced with a Private-Hash: field which is a plain |
423 | * SHA-1 hash instead of an HMAC. This is not allowable in DSA |
424 | * keys. (Yes, the old format was a mess. Guess why it changed :-) |
65a22376 |
425 | */ |
426 | |
32874aea |
427 | static int read_header(FILE * fp, char *header) |
428 | { |
65a22376 |
429 | int len = 39; |
430 | int c; |
431 | |
432 | while (len > 0) { |
433 | c = fgetc(fp); |
434 | if (c == '\n' || c == '\r' || c == EOF) |
435 | return 0; /* failure */ |
436 | if (c == ':') { |
437 | c = fgetc(fp); |
438 | if (c != ' ') |
439 | return 0; |
440 | *header = '\0'; |
441 | return 1; /* success! */ |
442 | } |
443 | if (len == 0) |
444 | return 0; /* failure */ |
445 | *header++ = c; |
446 | len--; |
447 | } |
448 | return 0; /* failure */ |
449 | } |
450 | |
32874aea |
451 | static char *read_body(FILE * fp) |
452 | { |
65a22376 |
453 | char *text; |
454 | int len; |
455 | int size; |
456 | int c; |
457 | |
458 | size = 128; |
459 | text = smalloc(size); |
460 | len = 0; |
461 | text[len] = '\0'; |
462 | |
463 | while (1) { |
464 | c = fgetc(fp); |
465 | if (c == '\r' || c == '\n') { |
466 | c = fgetc(fp); |
467 | if (c != '\r' && c != '\n' && c != EOF) |
468 | ungetc(c, fp); |
469 | return text; |
470 | } |
471 | if (c == EOF) { |
472 | sfree(text); |
473 | return NULL; |
474 | } |
475 | if (len + 1 > size) { |
476 | size += 128; |
477 | text = srealloc(text, size); |
478 | } |
479 | text[len++] = c; |
480 | text[len] = '\0'; |
481 | } |
482 | } |
483 | |
32874aea |
484 | int base64_decode_atom(char *atom, unsigned char *out) |
485 | { |
65a22376 |
486 | int vals[4]; |
487 | int i, v, len; |
488 | unsigned word; |
489 | char c; |
32874aea |
490 | |
65a22376 |
491 | for (i = 0; i < 4; i++) { |
492 | c = atom[i]; |
493 | if (c >= 'A' && c <= 'Z') |
494 | v = c - 'A'; |
495 | else if (c >= 'a' && c <= 'z') |
496 | v = c - 'a' + 26; |
497 | else if (c >= '0' && c <= '9') |
498 | v = c - '0' + 52; |
499 | else if (c == '+') |
500 | v = 62; |
501 | else if (c == '/') |
502 | v = 63; |
503 | else if (c == '=') |
504 | v = -1; |
505 | else |
506 | return 0; /* invalid atom */ |
507 | vals[i] = v; |
508 | } |
509 | |
510 | if (vals[0] == -1 || vals[1] == -1) |
511 | return 0; |
512 | if (vals[2] == -1 && vals[3] != -1) |
513 | return 0; |
514 | |
515 | if (vals[3] != -1) |
516 | len = 3; |
517 | else if (vals[2] != -1) |
518 | len = 2; |
519 | else |
520 | len = 1; |
521 | |
522 | word = ((vals[0] << 18) | |
32874aea |
523 | (vals[1] << 12) | ((vals[2] & 0x3F) << 6) | (vals[3] & 0x3F)); |
65a22376 |
524 | out[0] = (word >> 16) & 0xFF; |
525 | if (len > 1) |
526 | out[1] = (word >> 8) & 0xFF; |
527 | if (len > 2) |
528 | out[2] = word & 0xFF; |
529 | return len; |
530 | } |
531 | |
2247e107 |
532 | static unsigned char *read_blob(FILE * fp, int nlines, int *bloblen) |
32874aea |
533 | { |
65a22376 |
534 | unsigned char *blob; |
535 | char *line; |
536 | int linelen, len; |
537 | int i, j, k; |
538 | |
539 | /* We expect at most 64 base64 characters, ie 48 real bytes, per line. */ |
540 | blob = smalloc(48 * nlines); |
541 | len = 0; |
542 | for (i = 0; i < nlines; i++) { |
543 | line = read_body(fp); |
544 | if (!line) { |
545 | sfree(blob); |
546 | return NULL; |
547 | } |
548 | linelen = strlen(line); |
549 | if (linelen % 4 != 0 || linelen > 64) { |
550 | sfree(blob); |
551 | sfree(line); |
552 | return NULL; |
553 | } |
554 | for (j = 0; j < linelen; j += 4) { |
32874aea |
555 | k = base64_decode_atom(line + j, blob + len); |
65a22376 |
556 | if (!k) { |
557 | sfree(line); |
558 | sfree(blob); |
559 | return NULL; |
560 | } |
561 | len += k; |
562 | } |
563 | sfree(line); |
564 | } |
565 | *bloblen = len; |
566 | return blob; |
567 | } |
568 | |
569 | /* |
570 | * Magic error return value for when the passphrase is wrong. |
571 | */ |
572 | struct ssh2_userkey ssh2_wrong_passphrase = { |
573 | NULL, NULL, NULL |
574 | }; |
575 | |
32874aea |
576 | struct ssh2_userkey *ssh2_load_userkey(char *filename, char *passphrase) |
577 | { |
65a22376 |
578 | FILE *fp; |
7bedb13c |
579 | char header[40], *b, *encryption, *comment, *mac; |
65a22376 |
580 | const struct ssh_signkey *alg; |
581 | struct ssh2_userkey *ret; |
582 | int cipher, cipherblk; |
583 | unsigned char *public_blob, *private_blob; |
584 | int public_blob_len, private_blob_len; |
7bedb13c |
585 | int i, is_mac, old_fmt; |
5c72ca61 |
586 | int passlen = passphrase ? strlen(passphrase) : 0; |
65a22376 |
587 | |
588 | ret = NULL; /* return NULL for most errors */ |
5c72ca61 |
589 | comment = mac = NULL; |
65a22376 |
590 | public_blob = private_blob = NULL; |
591 | |
592 | fp = fopen(filename, "rb"); |
593 | if (!fp) |
594 | goto error; |
595 | |
596 | /* Read the first header line which contains the key type. */ |
7bedb13c |
597 | if (!read_header(fp, header)) |
598 | goto error; |
599 | if (0 == strcmp(header, "PuTTY-User-Key-File-2")) { |
600 | old_fmt = 0; |
601 | } else if (0 == strcmp(header, "PuTTY-User-Key-File-1")) { |
602 | /* this is an old key file; warn and then continue */ |
603 | old_keyfile_warning(); |
604 | old_fmt = 1; |
605 | } else |
65a22376 |
606 | goto error; |
607 | if ((b = read_body(fp)) == NULL) |
608 | goto error; |
5c72ca61 |
609 | /* Select key algorithm structure. */ |
65a22376 |
610 | if (!strcmp(b, "ssh-rsa")) |
611 | alg = &ssh_rsa; |
5c72ca61 |
612 | else if (!strcmp(b, "ssh-dss")) |
613 | alg = &ssh_dss; |
65a22376 |
614 | else { |
615 | sfree(b); |
616 | goto error; |
617 | } |
618 | sfree(b); |
32874aea |
619 | |
65a22376 |
620 | /* Read the Encryption header line. */ |
32874aea |
621 | if (!read_header(fp, header) || 0 != strcmp(header, "Encryption")) |
65a22376 |
622 | goto error; |
7bedb13c |
623 | if ((encryption = read_body(fp)) == NULL) |
65a22376 |
624 | goto error; |
7bedb13c |
625 | if (!strcmp(encryption, "aes256-cbc")) { |
32874aea |
626 | cipher = 1; |
627 | cipherblk = 16; |
7bedb13c |
628 | } else if (!strcmp(encryption, "none")) { |
32874aea |
629 | cipher = 0; |
630 | cipherblk = 1; |
65a22376 |
631 | } else { |
7bedb13c |
632 | sfree(encryption); |
65a22376 |
633 | goto error; |
634 | } |
65a22376 |
635 | |
636 | /* Read the Comment header line. */ |
32874aea |
637 | if (!read_header(fp, header) || 0 != strcmp(header, "Comment")) |
65a22376 |
638 | goto error; |
639 | if ((comment = read_body(fp)) == NULL) |
640 | goto error; |
641 | |
642 | /* Read the Public-Lines header line and the public blob. */ |
32874aea |
643 | if (!read_header(fp, header) || 0 != strcmp(header, "Public-Lines")) |
65a22376 |
644 | goto error; |
645 | if ((b = read_body(fp)) == NULL) |
646 | goto error; |
647 | i = atoi(b); |
648 | sfree(b); |
649 | if ((public_blob = read_blob(fp, i, &public_blob_len)) == NULL) |
650 | goto error; |
651 | |
652 | /* Read the Private-Lines header line and the Private blob. */ |
32874aea |
653 | if (!read_header(fp, header) || 0 != strcmp(header, "Private-Lines")) |
65a22376 |
654 | goto error; |
655 | if ((b = read_body(fp)) == NULL) |
656 | goto error; |
657 | i = atoi(b); |
658 | sfree(b); |
659 | if ((private_blob = read_blob(fp, i, &private_blob_len)) == NULL) |
660 | goto error; |
661 | |
5c72ca61 |
662 | /* Read the Private-MAC or Private-Hash header line. */ |
663 | if (!read_header(fp, header)) |
65a22376 |
664 | goto error; |
5c72ca61 |
665 | if (0 == strcmp(header, "Private-MAC")) { |
666 | if ((mac = read_body(fp)) == NULL) |
667 | goto error; |
668 | is_mac = 1; |
7bedb13c |
669 | } else if (0 == strcmp(header, "Private-Hash") && |
670 | alg == &ssh_rsa && old_fmt) { |
5c72ca61 |
671 | if ((mac = read_body(fp)) == NULL) |
672 | goto error; |
673 | is_mac = 0; |
674 | } else |
65a22376 |
675 | goto error; |
676 | |
677 | fclose(fp); |
678 | fp = NULL; |
679 | |
680 | /* |
681 | * Decrypt the private blob. |
682 | */ |
683 | if (cipher) { |
684 | unsigned char key[40]; |
685 | SHA_State s; |
65a22376 |
686 | |
687 | if (!passphrase) |
688 | goto error; |
689 | if (private_blob_len % cipherblk) |
690 | goto error; |
691 | |
65a22376 |
692 | SHA_Init(&s); |
693 | SHA_Bytes(&s, "\0\0\0\0", 4); |
694 | SHA_Bytes(&s, passphrase, passlen); |
32874aea |
695 | SHA_Final(&s, key + 0); |
65a22376 |
696 | SHA_Init(&s); |
697 | SHA_Bytes(&s, "\0\0\0\1", 4); |
698 | SHA_Bytes(&s, passphrase, passlen); |
32874aea |
699 | SHA_Final(&s, key + 20); |
65a22376 |
700 | aes256_decrypt_pubkey(key, private_blob, private_blob_len); |
701 | } |
702 | |
703 | /* |
7bedb13c |
704 | * Verify the MAC. |
65a22376 |
705 | */ |
706 | { |
5c72ca61 |
707 | char realmac[41]; |
65a22376 |
708 | unsigned char binary[20]; |
7bedb13c |
709 | unsigned char *macdata; |
710 | int maclen; |
711 | int free_macdata; |
712 | |
713 | if (old_fmt) { |
714 | /* MAC (or hash) only covers the private blob. */ |
715 | macdata = private_blob; |
716 | maclen = private_blob_len; |
717 | free_macdata = 0; |
718 | } else { |
719 | unsigned char *p; |
720 | int namelen = strlen(alg->name); |
721 | int enclen = strlen(encryption); |
722 | int commlen = strlen(comment); |
723 | maclen = (4 + namelen + |
724 | 4 + enclen + |
725 | 4 + commlen + |
726 | 4 + public_blob_len + |
727 | 4 + private_blob_len); |
728 | macdata = smalloc(maclen); |
729 | p = macdata; |
730 | #define DO_STR(s,len) PUT_32BIT(p,(len));memcpy(p+4,(s),(len));p+=4+(len) |
731 | DO_STR(alg->name, namelen); |
732 | DO_STR(encryption, enclen); |
733 | DO_STR(comment, commlen); |
734 | DO_STR(public_blob, public_blob_len); |
735 | DO_STR(private_blob, private_blob_len); |
736 | |
737 | free_macdata = 1; |
738 | } |
65a22376 |
739 | |
5c72ca61 |
740 | if (is_mac) { |
741 | SHA_State s; |
742 | unsigned char mackey[20]; |
743 | char header[] = "putty-private-key-file-mac-key"; |
744 | |
5c72ca61 |
745 | SHA_Init(&s); |
746 | SHA_Bytes(&s, header, sizeof(header)-1); |
7bedb13c |
747 | if (passphrase) |
748 | SHA_Bytes(&s, passphrase, passlen); |
5c72ca61 |
749 | SHA_Final(&s, mackey); |
750 | |
7bedb13c |
751 | hmac_sha1_simple(mackey, 20, macdata, maclen, binary); |
5c72ca61 |
752 | |
753 | memset(mackey, 0, sizeof(mackey)); |
754 | memset(&s, 0, sizeof(s)); |
755 | } else { |
7bedb13c |
756 | SHA_Simple(macdata, maclen, binary); |
5c72ca61 |
757 | } |
7bedb13c |
758 | |
759 | if (free_macdata) { |
760 | memset(macdata, 0, maclen); |
761 | sfree(macdata); |
762 | } |
763 | |
65a22376 |
764 | for (i = 0; i < 20; i++) |
5c72ca61 |
765 | sprintf(realmac + 2 * i, "%02x", binary[i]); |
65a22376 |
766 | |
5c72ca61 |
767 | if (strcmp(mac, realmac)) { |
768 | /* An incorrect MAC is an unconditional Error if the key is |
65a22376 |
769 | * unencrypted. Otherwise, it means Wrong Passphrase. */ |
770 | ret = cipher ? SSH2_WRONG_PASSPHRASE : NULL; |
771 | goto error; |
772 | } |
773 | } |
5c72ca61 |
774 | sfree(mac); |
65a22376 |
775 | |
776 | /* |
777 | * Create and return the key. |
778 | */ |
779 | ret = smalloc(sizeof(struct ssh2_userkey)); |
780 | ret->alg = alg; |
781 | ret->comment = comment; |
782 | ret->data = alg->createkey(public_blob, public_blob_len, |
783 | private_blob, private_blob_len); |
98f022f5 |
784 | if (!ret->data) { |
785 | sfree(ret->comment); |
786 | sfree(ret); |
787 | ret = NULL; |
788 | } |
65a22376 |
789 | sfree(public_blob); |
790 | sfree(private_blob); |
7bedb13c |
791 | sfree(encryption); |
65a22376 |
792 | return ret; |
793 | |
794 | /* |
795 | * Error processing. |
796 | */ |
32874aea |
797 | error: |
798 | if (fp) |
799 | fclose(fp); |
800 | if (comment) |
801 | sfree(comment); |
7bedb13c |
802 | if (encryption) |
803 | sfree(encryption); |
5c72ca61 |
804 | if (mac) |
805 | sfree(mac); |
32874aea |
806 | if (public_blob) |
807 | sfree(public_blob); |
808 | if (private_blob) |
809 | sfree(private_blob); |
65a22376 |
810 | return ret; |
811 | } |
812 | |
32874aea |
813 | char *ssh2_userkey_loadpub(char *filename, char **algorithm, |
814 | int *pub_blob_len) |
815 | { |
65a22376 |
816 | FILE *fp; |
817 | char header[40], *b; |
818 | const struct ssh_signkey *alg; |
65a22376 |
819 | unsigned char *public_blob; |
820 | int public_blob_len; |
821 | int i; |
822 | |
823 | public_blob = NULL; |
824 | |
825 | fp = fopen(filename, "rb"); |
826 | if (!fp) |
827 | goto error; |
828 | |
829 | /* Read the first header line which contains the key type. */ |
32874aea |
830 | if (!read_header(fp, header) |
7bedb13c |
831 | || (0 != strcmp(header, "PuTTY-User-Key-File-2") && |
832 | 0 != strcmp(header, "PuTTY-User-Key-File-1"))) |
65a22376 |
833 | goto error; |
834 | if ((b = read_body(fp)) == NULL) |
835 | goto error; |
836 | /* Select key algorithm structure. Currently only ssh-rsa. */ |
837 | if (!strcmp(b, "ssh-rsa")) |
838 | alg = &ssh_rsa; |
5c72ca61 |
839 | else if (!strcmp(b, "ssh-dss")) |
840 | alg = &ssh_dss; |
65a22376 |
841 | else { |
842 | sfree(b); |
843 | goto error; |
844 | } |
845 | sfree(b); |
32874aea |
846 | |
65a22376 |
847 | /* Read the Encryption header line. */ |
32874aea |
848 | if (!read_header(fp, header) || 0 != strcmp(header, "Encryption")) |
65a22376 |
849 | goto error; |
850 | if ((b = read_body(fp)) == NULL) |
851 | goto error; |
852 | sfree(b); /* we don't care */ |
853 | |
854 | /* Read the Comment header line. */ |
32874aea |
855 | if (!read_header(fp, header) || 0 != strcmp(header, "Comment")) |
65a22376 |
856 | goto error; |
857 | if ((b = read_body(fp)) == NULL) |
858 | goto error; |
859 | sfree(b); /* we don't care */ |
860 | |
861 | /* Read the Public-Lines header line and the public blob. */ |
32874aea |
862 | if (!read_header(fp, header) || 0 != strcmp(header, "Public-Lines")) |
65a22376 |
863 | goto error; |
864 | if ((b = read_body(fp)) == NULL) |
865 | goto error; |
866 | i = atoi(b); |
867 | sfree(b); |
868 | if ((public_blob = read_blob(fp, i, &public_blob_len)) == NULL) |
869 | goto error; |
870 | |
871 | fclose(fp); |
3f2d010c |
872 | if (pub_blob_len) |
873 | *pub_blob_len = public_blob_len; |
874 | if (algorithm) |
875 | *algorithm = alg->name; |
2247e107 |
876 | return (char *)public_blob; |
65a22376 |
877 | |
878 | /* |
879 | * Error processing. |
880 | */ |
32874aea |
881 | error: |
882 | if (fp) |
883 | fclose(fp); |
884 | if (public_blob) |
885 | sfree(public_blob); |
65a22376 |
886 | return NULL; |
887 | } |
888 | |
32874aea |
889 | int ssh2_userkey_encrypted(char *filename, char **commentptr) |
890 | { |
65a22376 |
891 | FILE *fp; |
892 | char header[40], *b, *comment; |
893 | int ret; |
894 | |
32874aea |
895 | if (commentptr) |
896 | *commentptr = NULL; |
65a22376 |
897 | |
898 | fp = fopen(filename, "rb"); |
899 | if (!fp) |
900 | return 0; |
32874aea |
901 | if (!read_header(fp, header) |
7bedb13c |
902 | || (0 != strcmp(header, "PuTTY-User-Key-File-2") && |
903 | 0 != strcmp(header, "PuTTY-User-Key-File-1"))) { |
32874aea |
904 | fclose(fp); |
905 | return 0; |
65a22376 |
906 | } |
907 | if ((b = read_body(fp)) == NULL) { |
32874aea |
908 | fclose(fp); |
909 | return 0; |
65a22376 |
910 | } |
911 | sfree(b); /* we don't care about key type here */ |
912 | /* Read the Encryption header line. */ |
32874aea |
913 | if (!read_header(fp, header) || 0 != strcmp(header, "Encryption")) { |
914 | fclose(fp); |
915 | return 0; |
65a22376 |
916 | } |
917 | if ((b = read_body(fp)) == NULL) { |
32874aea |
918 | fclose(fp); |
919 | return 0; |
65a22376 |
920 | } |
921 | |
922 | /* Read the Comment header line. */ |
32874aea |
923 | if (!read_header(fp, header) || 0 != strcmp(header, "Comment")) { |
924 | fclose(fp); |
925 | sfree(b); |
926 | return 1; |
65a22376 |
927 | } |
928 | if ((comment = read_body(fp)) == NULL) { |
32874aea |
929 | fclose(fp); |
930 | sfree(b); |
931 | return 1; |
65a22376 |
932 | } |
933 | |
32874aea |
934 | if (commentptr) |
935 | *commentptr = comment; |
65a22376 |
936 | |
937 | fclose(fp); |
938 | if (!strcmp(b, "aes256-cbc")) |
939 | ret = 1; |
940 | else |
941 | ret = 0; |
942 | sfree(b); |
943 | return ret; |
944 | } |
945 | |
32874aea |
946 | int base64_lines(int datalen) |
947 | { |
65a22376 |
948 | /* When encoding, we use 64 chars/line, which equals 48 real chars. */ |
32874aea |
949 | return (datalen + 47) / 48; |
65a22376 |
950 | } |
951 | |
96d19bc9 |
952 | void base64_encode(FILE * fp, unsigned char *data, int datalen, int cpl) |
32874aea |
953 | { |
65a22376 |
954 | int linelen = 0; |
955 | char out[4]; |
96d19bc9 |
956 | int n, i; |
65a22376 |
957 | |
958 | while (datalen > 0) { |
65a22376 |
959 | n = (datalen < 3 ? datalen : 3); |
960 | base64_encode_atom(data, n, out); |
961 | data += n; |
962 | datalen -= n; |
96d19bc9 |
963 | for (i = 0; i < 4; i++) { |
964 | if (linelen >= cpl) { |
965 | linelen = 0; |
966 | fputc('\n', fp); |
967 | } |
968 | fputc(out[i], fp); |
969 | linelen++; |
970 | } |
65a22376 |
971 | } |
972 | fputc('\n', fp); |
973 | } |
974 | |
32874aea |
975 | int ssh2_save_userkey(char *filename, struct ssh2_userkey *key, |
976 | char *passphrase) |
977 | { |
65a22376 |
978 | FILE *fp; |
979 | unsigned char *pub_blob, *priv_blob, *priv_blob_encrypted; |
980 | int pub_blob_len, priv_blob_len, priv_encrypted_len; |
981 | int passlen; |
982 | int cipherblk; |
7bedb13c |
983 | int i; |
65a22376 |
984 | char *cipherstr; |
5c72ca61 |
985 | unsigned char priv_mac[20]; |
65a22376 |
986 | |
987 | /* |
988 | * Fetch the key component blobs. |
989 | */ |
990 | pub_blob = key->alg->public_blob(key->data, &pub_blob_len); |
991 | priv_blob = key->alg->private_blob(key->data, &priv_blob_len); |
992 | if (!pub_blob || !priv_blob) { |
993 | sfree(pub_blob); |
994 | sfree(priv_blob); |
995 | return 0; |
996 | } |
997 | |
998 | /* |
999 | * Determine encryption details, and encrypt the private blob. |
1000 | */ |
1001 | if (passphrase) { |
1002 | cipherstr = "aes256-cbc"; |
1003 | cipherblk = 16; |
1004 | } else { |
1005 | cipherstr = "none"; |
1006 | cipherblk = 1; |
1007 | } |
1008 | priv_encrypted_len = priv_blob_len + cipherblk - 1; |
1009 | priv_encrypted_len -= priv_encrypted_len % cipherblk; |
1010 | priv_blob_encrypted = smalloc(priv_encrypted_len); |
1011 | memset(priv_blob_encrypted, 0, priv_encrypted_len); |
1012 | memcpy(priv_blob_encrypted, priv_blob, priv_blob_len); |
1013 | /* Create padding based on the SHA hash of the unpadded blob. This prevents |
1014 | * too easy a known-plaintext attack on the last block. */ |
5c72ca61 |
1015 | SHA_Simple(priv_blob, priv_blob_len, priv_mac); |
65a22376 |
1016 | assert(priv_encrypted_len - priv_blob_len < 20); |
5c72ca61 |
1017 | memcpy(priv_blob_encrypted + priv_blob_len, priv_mac, |
65a22376 |
1018 | priv_encrypted_len - priv_blob_len); |
1019 | |
7bedb13c |
1020 | /* Now create the MAC. */ |
1021 | { |
1022 | unsigned char *macdata; |
1023 | int maclen; |
1024 | unsigned char *p; |
1025 | int namelen = strlen(key->alg->name); |
1026 | int enclen = strlen(cipherstr); |
1027 | int commlen = strlen(key->comment); |
5c72ca61 |
1028 | SHA_State s; |
1029 | unsigned char mackey[20]; |
1030 | char header[] = "putty-private-key-file-mac-key"; |
1031 | |
7bedb13c |
1032 | maclen = (4 + namelen + |
1033 | 4 + enclen + |
1034 | 4 + commlen + |
1035 | 4 + pub_blob_len + |
1036 | 4 + priv_encrypted_len); |
1037 | macdata = smalloc(maclen); |
1038 | p = macdata; |
1039 | #define DO_STR(s,len) PUT_32BIT(p,(len));memcpy(p+4,(s),(len));p+=4+(len) |
1040 | DO_STR(key->alg->name, namelen); |
1041 | DO_STR(cipherstr, enclen); |
1042 | DO_STR(key->comment, commlen); |
1043 | DO_STR(pub_blob, pub_blob_len); |
1044 | DO_STR(priv_blob_encrypted, priv_encrypted_len); |
5c72ca61 |
1045 | |
1046 | SHA_Init(&s); |
1047 | SHA_Bytes(&s, header, sizeof(header)-1); |
7bedb13c |
1048 | if (passphrase) |
1049 | SHA_Bytes(&s, passphrase, strlen(passphrase)); |
5c72ca61 |
1050 | SHA_Final(&s, mackey); |
7bedb13c |
1051 | hmac_sha1_simple(mackey, 20, macdata, maclen, priv_mac); |
1052 | memset(macdata, 0, maclen); |
1053 | sfree(macdata); |
5c72ca61 |
1054 | memset(mackey, 0, sizeof(mackey)); |
1055 | memset(&s, 0, sizeof(s)); |
5c72ca61 |
1056 | } |
65a22376 |
1057 | |
1058 | if (passphrase) { |
2247e107 |
1059 | unsigned char key[40]; |
65a22376 |
1060 | SHA_State s; |
1061 | |
1062 | passlen = strlen(passphrase); |
1063 | |
1064 | SHA_Init(&s); |
1065 | SHA_Bytes(&s, "\0\0\0\0", 4); |
1066 | SHA_Bytes(&s, passphrase, passlen); |
32874aea |
1067 | SHA_Final(&s, key + 0); |
65a22376 |
1068 | SHA_Init(&s); |
1069 | SHA_Bytes(&s, "\0\0\0\1", 4); |
1070 | SHA_Bytes(&s, passphrase, passlen); |
32874aea |
1071 | SHA_Final(&s, key + 20); |
1072 | aes256_encrypt_pubkey(key, priv_blob_encrypted, |
1073 | priv_encrypted_len); |
5c72ca61 |
1074 | |
1075 | memset(key, 0, sizeof(key)); |
1076 | memset(&s, 0, sizeof(s)); |
65a22376 |
1077 | } |
1078 | |
1079 | fp = fopen(filename, "w"); |
1080 | if (!fp) |
1081 | return 0; |
7bedb13c |
1082 | fprintf(fp, "PuTTY-User-Key-File-2: %s\n", key->alg->name); |
65a22376 |
1083 | fprintf(fp, "Encryption: %s\n", cipherstr); |
1084 | fprintf(fp, "Comment: %s\n", key->comment); |
1085 | fprintf(fp, "Public-Lines: %d\n", base64_lines(pub_blob_len)); |
96d19bc9 |
1086 | base64_encode(fp, pub_blob, pub_blob_len, 64); |
65a22376 |
1087 | fprintf(fp, "Private-Lines: %d\n", base64_lines(priv_encrypted_len)); |
96d19bc9 |
1088 | base64_encode(fp, priv_blob_encrypted, priv_encrypted_len, 64); |
7bedb13c |
1089 | fprintf(fp, "Private-MAC: "); |
65a22376 |
1090 | for (i = 0; i < 20; i++) |
5c72ca61 |
1091 | fprintf(fp, "%02x", priv_mac[i]); |
65a22376 |
1092 | fprintf(fp, "\n"); |
1093 | fclose(fp); |
7bedb13c |
1094 | |
1095 | sfree(pub_blob); |
1096 | memset(priv_blob, 0, priv_blob_len); |
1097 | sfree(priv_blob); |
1098 | sfree(priv_blob_encrypted); |
65a22376 |
1099 | return 1; |
1100 | } |
1101 | |
1102 | /* ---------------------------------------------------------------------- |
231ee168 |
1103 | * A function to determine the type of a private key file. Returns |
1104 | * 0 on failure, 1 or 2 on success. |
65a22376 |
1105 | */ |
231ee168 |
1106 | int key_type(char *filename) |
32874aea |
1107 | { |
65a22376 |
1108 | FILE *fp; |
231ee168 |
1109 | char buf[32]; |
1110 | const char putty2_sig[] = "PuTTY-User-Key-File-"; |
1111 | const char sshcom_sig[] = "---- BEGIN SSH2 ENCRYPTED PRIVAT"; |
1112 | const char openssh_sig[] = "-----BEGIN "; |
65a22376 |
1113 | int i; |
1114 | |
1115 | fp = fopen(filename, "r"); |
1116 | if (!fp) |
231ee168 |
1117 | return SSH_KEYTYPE_UNOPENABLE; |
1118 | i = fread(buf, 1, sizeof(buf), fp); |
65a22376 |
1119 | fclose(fp); |
231ee168 |
1120 | if (i < 0) |
1121 | return SSH_KEYTYPE_UNOPENABLE; |
1122 | if (i < 32) |
1123 | return SSH_KEYTYPE_UNKNOWN; |
1124 | if (!memcmp(buf, rsa_signature, sizeof(rsa_signature)-1)) |
1125 | return SSH_KEYTYPE_SSH1; |
1126 | if (!memcmp(buf, putty2_sig, sizeof(putty2_sig)-1)) |
1127 | return SSH_KEYTYPE_SSH2; |
1128 | if (!memcmp(buf, openssh_sig, sizeof(openssh_sig)-1)) |
1129 | return SSH_KEYTYPE_OPENSSH; |
1130 | if (!memcmp(buf, sshcom_sig, sizeof(sshcom_sig)-1)) |
1131 | return SSH_KEYTYPE_SSHCOM; |
1132 | return SSH_KEYTYPE_UNKNOWN; /* unrecognised or EOF */ |
1133 | } |
1134 | |
1135 | /* |
1136 | * Convert the type word to a string, for `wrong type' error |
1137 | * messages. |
1138 | */ |
1139 | char *key_type_to_str(int type) |
1140 | { |
1141 | switch (type) { |
1142 | case SSH_KEYTYPE_UNOPENABLE: return "unable to open file"; break; |
1143 | case SSH_KEYTYPE_UNKNOWN: return "not a private key"; break; |
1144 | case SSH_KEYTYPE_SSH1: return "SSH1 private key"; break; |
1145 | case SSH_KEYTYPE_SSH2: return "PuTTY SSH2 private key"; break; |
1146 | case SSH_KEYTYPE_OPENSSH: return "OpenSSH SSH2 private key"; break; |
1147 | case SSH_KEYTYPE_SSHCOM: return "ssh.com SSH2 private key"; break; |
1148 | default: return "INTERNAL ERROR"; break; |
1149 | } |
65a22376 |
1150 | } |