diff options
author | Jakob Schlyter <jakob@cvs.openbsd.org> | 2001-03-11 15:13:10 +0000 |
---|---|---|
committer | Jakob Schlyter <jakob@cvs.openbsd.org> | 2001-03-11 15:13:10 +0000 |
commit | ccfa929b1ee876741fba3b71fd015c99a97ec4a5 (patch) | |
tree | 89affeaffcd508de7244af355bc553ad2194b16e /usr.bin/ssh/key.c | |
parent | 076ed6569271018f457390ebda2c0be6cb0eb2d8 (diff) |
cleanup & shorten some var names key_fingerprint_bubblebabble.
Diffstat (limited to 'usr.bin/ssh/key.c')
-rw-r--r-- | usr.bin/ssh/key.c | 50 |
1 files changed, 24 insertions, 26 deletions
diff --git a/usr.bin/ssh/key.c b/usr.bin/ssh/key.c index d8f994b5fc4..17a6c787dc8 100644 --- a/usr.bin/ssh/key.c +++ b/usr.bin/ssh/key.c @@ -32,7 +32,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "includes.h" -RCSID("$OpenBSD: key.c,v 1.19 2001/03/11 15:03:15 jakob Exp $"); +RCSID("$OpenBSD: key.c,v 1.20 2001/03/11 15:13:09 jakob Exp $"); #include <openssl/evp.h> @@ -236,46 +236,44 @@ key_fingerprint_bubblebabble(u_char* dgst_raw, size_t dgst_raw_len) char vowels[] = { 'a', 'e', 'i', 'o', 'u', 'y' }; char consonants[] = { 'b', 'c', 'd', 'f', 'g', 'h', 'k', 'l', 'm', 'n', 'p', 'r', 's', 't', 'v', 'z', 'x' }; - u_int rounds, idx, retval_idx, seed; + u_int i, j = 0, rounds, seed = 1; char *retval; rounds = (dgst_raw_len / 2) + 1; retval = xmalloc(sizeof(char) * (rounds*6)); - seed = 1; - retval_idx = 0; - retval[retval_idx++] = 'x'; - for (idx=0;idx<rounds;idx++) { + retval[j++] = 'x'; + for (i = 0; i < rounds; i++) { u_int idx0, idx1, idx2, idx3, idx4; - if ((idx + 1 < rounds) || (dgst_raw_len % 2 != 0)) { - idx0 = (((((u_int)(dgst_raw[2 * idx])) >> 6) & 3) + + if ((i + 1 < rounds) || (dgst_raw_len % 2 != 0)) { + idx0 = (((((u_int)(dgst_raw[2 * i])) >> 6) & 3) + seed) % 6; - idx1 = (((u_int)(dgst_raw[2 * idx])) >> 2) & 15; - idx2 = ((((u_int)(dgst_raw[2 * idx])) & 3) + + idx1 = (((u_int)(dgst_raw[2 * i])) >> 2) & 15; + idx2 = ((((u_int)(dgst_raw[2 * i])) & 3) + (seed / 6)) % 6; - retval[retval_idx++] = vowels[idx0]; - retval[retval_idx++] = consonants[idx1]; - retval[retval_idx++] = vowels[idx2]; - if ((idx + 1) < rounds) { - idx3 = (((u_int)(dgst_raw[(2 * idx) + 1])) >> 4) & 15; - idx4 = (((u_int)(dgst_raw[(2 * idx) + 1]))) & 15; - retval[retval_idx++] = consonants[idx3]; - retval[retval_idx++] = '-'; - retval[retval_idx++] = consonants[idx4]; + retval[j++] = vowels[idx0]; + retval[j++] = consonants[idx1]; + retval[j++] = vowels[idx2]; + if ((i + 1) < rounds) { + idx3 = (((u_int)(dgst_raw[(2 * i) + 1])) >> 4) & 15; + idx4 = (((u_int)(dgst_raw[(2 * i) + 1]))) & 15; + retval[j++] = consonants[idx3]; + retval[j++] = '-'; + retval[j++] = consonants[idx4]; seed = ((seed * 5) + - ((((u_int)(dgst_raw[2 * idx])) * 7) + - ((u_int)(dgst_raw[(2 * idx) + 1])))) % 36; + ((((u_int)(dgst_raw[2 * i])) * 7) + + ((u_int)(dgst_raw[(2 * i) + 1])))) % 36; } } else { idx0 = seed % 6; idx1 = 16; idx2 = seed / 6; - retval[retval_idx++] = vowels[idx0]; - retval[retval_idx++] = consonants[idx1]; - retval[retval_idx++] = vowels[idx2]; + retval[j++] = vowels[idx0]; + retval[j++] = consonants[idx1]; + retval[j++] = vowels[idx2]; } } - retval[retval_idx++] = 'x'; - retval[retval_idx++] = '\0'; + retval[j++] = 'x'; + retval[j++] = '\0'; return retval; } |