diff options
Diffstat (limited to 'key.c')
-rw-r--r-- | key.c | 16 |
1 files changed, 7 insertions, 9 deletions
@@ -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 | } |