summaryrefslogtreecommitdiff
path: root/key.c
diff options
context:
space:
mode:
authorDarren Tucker <dtucker@zip.com.au>2008-06-13 04:43:51 +1000
committerDarren Tucker <dtucker@zip.com.au>2008-06-13 04:43:51 +1000
commit014d76fa7294db63e37c642556008206f0179622 (patch)
tree1759afec65fbf0d48fd6561cd53275828fce3408 /key.c
parent35c45535ea1812ecc2d2655f068a103e57f3dfb5 (diff)
- otto@cvs.openbsd.org 2008/06/11 23:02:22
[key.c] simpler way of computing the augmentations; ok grunk@
Diffstat (limited to 'key.c')
-rw-r--r--key.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/key.c b/key.c
index 5d357a8d6..80ce855d8 100644
--- a/key.c
+++ b/key.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: key.c,v 1.70 2008/06/11 21:01:35 grunk Exp $ */ 1/* $OpenBSD: key.c,v 1.71 2008/06/11 23:02:22 otto 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
@@ -330,17 +330,18 @@ key_fingerprint_randomart(u_char *dgst_raw, u_int dgst_raw_len)
330 */ 330 */
331 char *augmentation_string = " .o+=*BOX@%&#/^"; 331 char *augmentation_string = " .o+=*BOX@%&#/^";
332 char *retval, *p; 332 char *retval, *p;
333 char field[FLDSIZE_X][FLDSIZE_Y]; 333 u_char field[FLDSIZE_X][FLDSIZE_Y];
334 u_int i, b; 334 u_int i, b;
335 int x, y; 335 int x, y;
336 size_t len = strlen(augmentation_string);
336 337
337 retval = xcalloc(1, (FLDSIZE_X + 3) * (FLDSIZE_Y + 2)); 338 retval = xcalloc(1, (FLDSIZE_X + 3) * (FLDSIZE_Y + 2));
338 339
339 /* initialize field */ 340 /* initialize field */
340 memset(field, ' ', FLDSIZE_X * FLDSIZE_Y * sizeof(char)); 341 memset(field, 0, FLDSIZE_X * FLDSIZE_Y * sizeof(char));
341 x = FLDSIZE_X / 2; 342 x = FLDSIZE_X / 2;
342 y = FLDSIZE_Y / 2; 343 y = FLDSIZE_Y / 2;
343 field[x][y] = '.'; 344 field[x][y] = 1;
344 345
345 /* process raw key */ 346 /* process raw key */
346 for (i = 0; i < dgst_raw_len; i++) { 347 for (i = 0; i < dgst_raw_len; i++) {
@@ -359,10 +360,7 @@ key_fingerprint_randomart(u_char *dgst_raw, u_int dgst_raw_len)
359 y = MIN(y, FLDSIZE_Y - 1); 360 y = MIN(y, FLDSIZE_Y - 1);
360 361
361 /* augment the field */ 362 /* augment the field */
362 p = strchr(augmentation_string, field[x][y]); 363 field[x][y]++;
363 if (*++p != '\0')
364 field[x][y] = *p;
365
366 input = input >> 2; 364 input = input >> 2;
367 } 365 }
368 } 366 }
@@ -381,7 +379,7 @@ key_fingerprint_randomart(u_char *dgst_raw, u_int dgst_raw_len)
381 for (y = 0; y < FLDSIZE_Y; y++) { 379 for (y = 0; y < FLDSIZE_Y; y++) {
382 *p++ = '|'; 380 *p++ = '|';
383 for (x = 0; x < FLDSIZE_X; x++) 381 for (x = 0; x < FLDSIZE_X; x++)
384 *p++ = field[x][y]; 382 *p++ = augmentation_string[MIN(field[x][y], len - 1)];
385 *p++ = '|'; 383 *p++ = '|';
386 *p++ = '\n'; 384 *p++ = '\n';
387 } 385 }