summaryrefslogtreecommitdiff
path: root/key.c
diff options
context:
space:
mode:
authorDarren Tucker <dtucker@zip.com.au>2008-06-13 04:54:40 +1000
committerDarren Tucker <dtucker@zip.com.au>2008-06-13 04:54:40 +1000
commit987ac84a1777fe4c4ce2424f6d5b0d127083fd54 (patch)
tree1c9edb479759b7383f807096556f66d0501f2845 /key.c
parentba69c7a987ea42b6e26ce512a483d6ba44e3df0c (diff)
- grunk@cvs.openbsd.org 2008/06/12 05:42:46
[key.c] supply the key type (rsa1, rsa, dsa) as a caption in the frame of the random art. while there, stress the fact that the field base should at least be 8 characters for the pictures to make sense. comment and ok djm@
Diffstat (limited to 'key.c')
-rw-r--r--key.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/key.c b/key.c
index 1f27926d1..c1dadb52c 100644
--- a/key.c
+++ b/key.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: key.c,v 1.73 2008/06/12 00:13:13 otto Exp $ */ 1/* $OpenBSD: key.c,v 1.74 2008/06/12 05:42:46 grunk Exp $ */
2/* 2/*
3 * read_bignum(): 3 * read_bignum():
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -319,10 +319,18 @@ key_fingerprint_bubblebabble(u_char *dgst_raw, u_int dgst_raw_len)
319 * Graphs are not unambiguous, because circles in graphs can be 319 * Graphs are not unambiguous, because circles in graphs can be
320 * walked in either direction. 320 * walked in either direction.
321 */ 321 */
322#define FLDSIZE_Y (8 + 1) 322
323#define FLDSIZE_X (8 * 2 + 1) 323/*
324 * Field sizes for the random art. Have to be odd, so the starting point
325 * can be in the exact middle of the picture, and FLDBASE should be >=8 .
326 * Else pictures would be too dense, and drawing the frame would
327 * fail, too, because the key type would not fit in anymore.
328 */
329#define FLDBASE 8
330#define FLDSIZE_Y (FLDBASE + 1)
331#define FLDSIZE_X (FLDBASE * 2 + 1)
324static char * 332static char *
325key_fingerprint_randomart(u_char *dgst_raw, u_int dgst_raw_len) 333key_fingerprint_randomart(u_char *dgst_raw, u_int dgst_raw_len, const Key *k)
326{ 334{
327 /* 335 /*
328 * Chars to be used after each other every time the worm 336 * Chars to be used after each other every time the worm
@@ -366,11 +374,11 @@ key_fingerprint_randomart(u_char *dgst_raw, u_int dgst_raw_len)
366 field[FLDSIZE_X / 2][FLDSIZE_Y / 2] = len; 374 field[FLDSIZE_X / 2][FLDSIZE_Y / 2] = len;
367 375
368 /* fill in retval */ 376 /* fill in retval */
369 p = retval; 377 snprintf(retval, 10, "+--[%4s]", key_type(k));
378 p = strchr(retval, '\0');
370 379
371 /* output upper border */ 380 /* output upper border */
372 *p++ = '+'; 381 for (i = 0; i < FLDSIZE_X - 8; i++)
373 for (i = 0; i < FLDSIZE_X; i++)
374 *p++ = '-'; 382 *p++ = '-';
375 *p++ = '+'; 383 *p++ = '+';
376 *p++ = '\n'; 384 *p++ = '\n';
@@ -411,7 +419,7 @@ key_fingerprint(const Key *k, enum fp_type dgst_type, enum fp_rep dgst_rep)
411 retval = key_fingerprint_bubblebabble(dgst_raw, dgst_raw_len); 419 retval = key_fingerprint_bubblebabble(dgst_raw, dgst_raw_len);
412 break; 420 break;
413 case SSH_FP_RANDOMART: 421 case SSH_FP_RANDOMART:
414 retval = key_fingerprint_randomart(dgst_raw, dgst_raw_len); 422 retval = key_fingerprint_randomart(dgst_raw, dgst_raw_len, k);
415 break; 423 break;
416 default: 424 default:
417 fatal("key_fingerprint_ex: bad digest representation %d", 425 fatal("key_fingerprint_ex: bad digest representation %d",