[key.c]
     cleanup & shorten some var names key_fingerprint_bubblebabble.
This commit is contained in:
Ben Lindstrom 2001-03-11 20:06:59 +00:00
Родитель a8a73e62ed
Коммит cbe3ad2f70
2 изменённых файлов: 28 добавлений и 27 удалений

Просмотреть файл

@ -11,6 +11,9 @@
[ssh-keygen.1 ssh-keygen.c]
print both md5, sha1 and bubblebabble fingerprints when using
ssh-keygen -l -v. ok markus@.
- jakob@cvs.openbsd.org 2001/03/11 15:13:09
[key.c]
cleanup & shorten some var names key_fingerprint_bubblebabble.
20010311
- OpenBSD CVS Sync
@ -4504,4 +4507,4 @@
- Wrote replacements for strlcpy and mkdtemp
- Released 1.0pre1
$Id: ChangeLog,v 1.942 2001/03/11 20:05:19 mouring Exp $
$Id: ChangeLog,v 1.943 2001/03/11 20:06:59 mouring Exp $

50
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;
}