diff options
author | Otto Moerbeek <otto@cvs.openbsd.org> | 2008-06-11 23:02:23 +0000 |
---|---|---|
committer | Otto Moerbeek <otto@cvs.openbsd.org> | 2008-06-11 23:02:23 +0000 |
commit | 052042940ee63db06760105bc832f184eb91fab2 (patch) | |
tree | 1fb005be7bbc419c66006420626e6eea15df1fb1 /usr.bin/ssh | |
parent | 21af0ea2c8433c8c539e5967ba1406de7278db31 (diff) |
simpler way of computing the augmentations; ok grunk@
Diffstat (limited to 'usr.bin/ssh')
-rw-r--r-- | usr.bin/ssh/key.c | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/usr.bin/ssh/key.c b/usr.bin/ssh/key.c index 40fe5b3108b..4b4dc017cc6 100644 --- a/usr.bin/ssh/key.c +++ b/usr.bin/ssh/key.c @@ -1,4 +1,4 @@ -/* $OpenBSD: key.c,v 1.70 2008/06/11 21:01:35 grunk Exp $ */ +/* $OpenBSD: key.c,v 1.71 2008/06/11 23:02:22 otto Exp $ */ /* * read_bignum(): * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland @@ -326,17 +326,18 @@ key_fingerprint_randomart(u_char *dgst_raw, u_int dgst_raw_len) */ char *augmentation_string = " .o+=*BOX@%&#/^"; char *retval, *p; - char field[FLDSIZE_X][FLDSIZE_Y]; + u_char field[FLDSIZE_X][FLDSIZE_Y]; u_int i, b; int x, y; + size_t len = strlen(augmentation_string); retval = xcalloc(1, (FLDSIZE_X + 3) * (FLDSIZE_Y + 2)); /* initialize field */ - memset(field, ' ', FLDSIZE_X * FLDSIZE_Y * sizeof(char)); + memset(field, 0, FLDSIZE_X * FLDSIZE_Y * sizeof(char)); x = FLDSIZE_X / 2; y = FLDSIZE_Y / 2; - field[x][y] = '.'; + field[x][y] = 1; /* process raw key */ for (i = 0; i < dgst_raw_len; i++) { @@ -355,10 +356,7 @@ key_fingerprint_randomart(u_char *dgst_raw, u_int dgst_raw_len) y = MIN(y, FLDSIZE_Y - 1); /* augment the field */ - p = strchr(augmentation_string, field[x][y]); - if (*++p != '\0') - field[x][y] = *p; - + field[x][y]++; input = input >> 2; } } @@ -377,7 +375,7 @@ key_fingerprint_randomart(u_char *dgst_raw, u_int dgst_raw_len) for (y = 0; y < FLDSIZE_Y; y++) { *p++ = '|'; for (x = 0; x < FLDSIZE_X; x++) - *p++ = field[x][y]; + *p++ = augmentation_string[MIN(field[x][y], len - 1)]; *p++ = '|'; *p++ = '\n'; } |