summaryrefslogtreecommitdiffstats
path: root/key.c
diff options
context:
space:
mode:
authorBen Lindstrom <mouring@eviladmin.org>2001-03-11 20:06:59 +0000
committerBen Lindstrom <mouring@eviladmin.org>2001-03-11 20:06:59 +0000
commitcbe3ad2f70e6682378cd06ce0c0236438e1ed581 (patch)
tree409793141653a53a39baa100970e70b873608031 /key.c
parenta8a73e62eda1c81e04c11099e0c0155164486992 (diff)
- jakob@cvs.openbsd.org 2001/03/11 15:13:09
[key.c] cleanup & shorten some var names key_fingerprint_bubblebabble.
Diffstat (limited to 'key.c')
-rw-r--r--key.c50
1 files changed, 24 insertions, 26 deletions
diff --git a/key.c b/key.c
index d8f994b5..17a6c787 100644
--- a/key.c
+++ b/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;
}