version 1.51, 2005/07/06 22:15:11 |
version 1.52, 2013/11/28 18:24:55 |
|
|
if (gethostname(hostname, sizeof(hostname)) < 0) |
if (gethostname(hostname, sizeof(hostname)) < 0) |
err(1, "gethostname"); |
err(1, "gethostname"); |
for (i = 0, p = seed; hostname[i] && i < SKEY_NAMELEN; i++) { |
for (i = 0, p = seed; hostname[i] && i < SKEY_NAMELEN; i++) { |
if (isalpha(hostname[i])) { |
if (isalpha((unsigned char)hostname[i])) { |
if (isupper(hostname[i])) |
if (isupper((unsigned char)hostname[i])) |
hostname[i] = tolower(hostname[i]); |
hostname[i] = tolower((unsigned char)hostname[i]); |
*p++ = hostname[i]; |
*p++ = hostname[i]; |
} else if (isdigit(hostname[i])) |
} else if (isdigit((unsigned char)hostname[i])) |
*p++ = hostname[i]; |
*p++ = hostname[i]; |
} |
} |
noise = arc4random(); |
noise = arc4random(); |
|
|
*/ |
*/ |
l = strlen(skey.seed); |
l = strlen(skey.seed); |
for (p = skey.seed; *p; p++) { |
for (p = skey.seed; *p; p++) { |
if (isalpha(*p)) { |
if (isalpha((unsigned char)*p)) { |
if (isupper(*p)) |
if (isupper((unsigned char)*p)) |
*p = tolower(*p); |
*p = tolower((unsigned char)*p); |
} else if (!isdigit(*p)) { |
} else if (!isdigit((unsigned char)*p)) { |
memmove(p, p + 1, l - (p - skey.seed)); |
memmove(p, p + 1, l - (p - skey.seed)); |
l--; |
l--; |
} |
} |
|
|
/* If the seed ends in 0-8 just add one. */ |
/* If the seed ends in 0-8 just add one. */ |
if (l > 0) { |
if (l > 0) { |
lastc = skey.seed[l - 1]; |
lastc = skey.seed[l - 1]; |
if (isdigit(lastc) && lastc != '9') { |
if (isdigit((unsigned char)lastc) && |
|
lastc != '9') { |
(void)strlcpy(seed, skey.seed, |
(void)strlcpy(seed, skey.seed, |
sizeof seed); |
sizeof seed); |
seed[l - 1] = lastc + 1; |
seed[l - 1] = lastc + 1; |
} |
} |
if (isdigit(lastc) && lastc == '9' && l < 16) { |
if (isdigit((unsigned char)lastc) && |
|
lastc == '9' && l < 16) { |
(void)strlcpy(seed, skey.seed, |
(void)strlcpy(seed, skey.seed, |
sizeof seed); |
sizeof seed); |
seed[l - 1] = '0'; |
seed[l - 1] = '0'; |
|
|
continue; |
continue; |
} |
} |
for (p = newseed; *p; p++) { |
for (p = newseed; *p; p++) { |
if (isspace(*p)) { |
if (isspace((unsigned char)*p)) { |
(void)fputs("ERROR: Seed must not contain " |
(void)fputs("ERROR: Seed must not contain " |
"any spaces\n", stderr); |
"any spaces\n", stderr); |
break; |
break; |
} else if (isalpha(*p)) { |
} else if (isalpha((unsigned char)*p)) { |
if (isupper(*p)) |
if (isupper((unsigned char)*p)) |
*p = tolower(*p); |
*p = tolower((unsigned char)*p); |
} else if (!isdigit(*p)) { |
} else if (!isdigit((unsigned char)*p)) { |
(void)fputs("ERROR: Seed must be purely " |
(void)fputs("ERROR: Seed must be purely " |
"alphanumeric\n", stderr); |
"alphanumeric\n", stderr); |
break; |
break; |
|
|
continue; |
continue; |
if ((cp = strtok(NULL, " \t")) == NULL) |
if ((cp = strtok(NULL, " \t")) == NULL) |
continue; |
continue; |
if (isalpha(*cp)) { |
if (isalpha((unsigned char)*cp)) { |
hashtype = cp; |
hashtype = cp; |
if ((cp = strtok(NULL, " \t")) == NULL) |
if ((cp = strtok(NULL, " \t")) == NULL) |
continue; |
continue; |