summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2014-07-03 21:22:22 +1000
committerDamien Miller <djm@mindrot.org>2014-07-03 21:22:22 +1000
commit61e28e55c3438d796b02ef878bcd28620d452670 (patch)
tree3c4623611ef0ce84e7e86bae7d86cdefc1f7f502
parent9eb4cd9a32c32d40d36450b68ed93badc6a94c68 (diff)
- djm@cvs.openbsd.org 2014/07/03 01:45:38
[sshkey.c] make Ed25519 keys' title fit properly in the randomart border; bz#2247 based on patch from Christian Hesse
-rw-r--r--ChangeLog5
-rw-r--r--sshkey.c25
2 files changed, 22 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index 64e342f43..e7715dafb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,11 @@
3 doesn't support it. 3 doesn't support it.
4 - (djm) [monitor_fdpass.c] Use sys/poll.h if poll.h doesn't exist; 4 - (djm) [monitor_fdpass.c] Use sys/poll.h if poll.h doesn't exist;
5 bz#2237 5 bz#2237
6 - OpenBSD CVS Sync
7 - djm@cvs.openbsd.org 2014/07/03 01:45:38
8 [sshkey.c]
9 make Ed25519 keys' title fit properly in the randomart border; bz#2247
10 based on patch from Christian Hesse
6 11
720140702 1220140702
8 - OpenBSD CVS Sync 13 - OpenBSD CVS Sync
diff --git a/sshkey.c b/sshkey.c
index c4a4b0461..f957b061f 100644
--- a/sshkey.c
+++ b/sshkey.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: sshkey.c,v 1.2 2014/06/27 18:50:39 markus Exp $ */ 1/* $OpenBSD: sshkey.c,v 1.3 2014/07/03 01:45:38 djm Exp $ */
2/* 2/*
3 * Copyright (c) 2000, 2001 Markus Friedl. All rights reserved. 3 * Copyright (c) 2000, 2001 Markus Friedl. All rights reserved.
4 * Copyright (c) 2008 Alexander von Gernler. All rights reserved. 4 * Copyright (c) 2008 Alexander von Gernler. All rights reserved.
@@ -1026,11 +1026,11 @@ fingerprint_randomart(u_char *dgst_raw, size_t dgst_raw_len,
1026 * intersects with itself. Matter of taste. 1026 * intersects with itself. Matter of taste.
1027 */ 1027 */
1028 char *augmentation_string = " .o+=*BOX@%&#/^SE"; 1028 char *augmentation_string = " .o+=*BOX@%&#/^SE";
1029 char *retval, *p; 1029 char *retval, *p, title[FLDSIZE_X];
1030 u_char field[FLDSIZE_X][FLDSIZE_Y]; 1030 u_char field[FLDSIZE_X][FLDSIZE_Y];
1031 size_t i; 1031 size_t i, tlen;
1032 u_int b; 1032 u_int b;
1033 int x, y; 1033 int x, y, r;
1034 size_t len = strlen(augmentation_string) - 1; 1034 size_t len = strlen(augmentation_string) - 1;
1035 1035
1036 if ((retval = calloc((FLDSIZE_X + 3), (FLDSIZE_Y + 2))) == NULL) 1036 if ((retval = calloc((FLDSIZE_X + 3), (FLDSIZE_Y + 2))) == NULL)
@@ -1068,12 +1068,21 @@ fingerprint_randomart(u_char *dgst_raw, size_t dgst_raw_len,
1068 field[FLDSIZE_X / 2][FLDSIZE_Y / 2] = len - 1; 1068 field[FLDSIZE_X / 2][FLDSIZE_Y / 2] = len - 1;
1069 field[x][y] = len; 1069 field[x][y] = len;
1070 1070
1071 /* fill in retval */ 1071 /* assemble title */
1072 snprintf(retval, FLDSIZE_X, "+--[%4s %4u]", 1072 r = snprintf(title, sizeof(title), "[%s %u]",
1073 sshkey_type(k), sshkey_size(k)); 1073 sshkey_type(k), sshkey_size(k));
1074 p = strchr(retval, '\0'); 1074 /* If [type size] won't fit, then try [type]; fits "[ED25519-CERT]" */
1075 if (r < 0 || r > (int)sizeof(title))
1076 snprintf(title, sizeof(title), "[%s]", sshkey_type(k));
1077 tlen = strlen(title);
1075 1078
1076 /* output upper border */ 1079 /* output upper border */
1080 p = retval;
1081 *p++ = '+';
1082 for (i = 0; i < (FLDSIZE_X - tlen) / 2; i++)
1083 *p++ = '-';
1084 memcpy(p, title, tlen);
1085 p += tlen;
1077 for (i = p - retval - 1; i < FLDSIZE_X; i++) 1086 for (i = p - retval - 1; i < FLDSIZE_X; i++)
1078 *p++ = '-'; 1087 *p++ = '-';
1079 *p++ = '+'; 1088 *p++ = '+';