]> andersk Git - openssh.git/commitdiff
- otto@cvs.openbsd.org 2008/06/11 23:02:22
authordtucker <dtucker>
Thu, 12 Jun 2008 18:43:51 +0000 (18:43 +0000)
committerdtucker <dtucker>
Thu, 12 Jun 2008 18:43:51 +0000 (18:43 +0000)
     [key.c]
     simpler way of computing the augmentations; ok grunk@

ChangeLog
key.c

index 0e932fe2d686ad7aab7cd1c452be13ce152cb5d2..bcf956084f58612536e001d85a5e643565f2cbe1 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -34,6 +34,9 @@
      that is not how it was envisioned.
      Also correct manpage saying that -v is needed along with -l for it to work.
      spotted by naddy@
+   - otto@cvs.openbsd.org 2008/06/11 23:02:22
+     [key.c]
+     simpler way of computing the augmentations; ok grunk@
 
 20080611
  - (djm) [channels.c configure.ac]
diff --git a/key.c b/key.c
index 5d357a8d6b22995112812408cde646b856dae6fa..80ce855d867679b78f80f5ecfccb14f4583b53f3 100644 (file)
--- a/key.c
+++ b/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
@@ -330,17 +330,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++) {
@@ -359,10 +360,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;
                }
        }
@@ -381,7 +379,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';
        }
This page took 0.557201 seconds and 5 git commands to generate.