WPS: Convert WEP key to hex

Use of hex is safer since the enrollee may configure AP with 5 or 13
random octets of binary data as the key.
This commit is contained in:
Jouni Malinen 2009-02-27 17:08:17 +02:00 committed by Jouni Malinen
parent d7e9a48f66
commit 24466b188a

View file

@ -333,12 +333,15 @@ static int hostapd_wps_cred_cb(void *ctx, const struct wps_credential *cred)
key_idx--;
fprintf(nconf, "wep_default_key=%d\n", key_idx);
fprintf(nconf, "wep_key%d=", key_idx);
if (cred->key_len != 10 && cred->key_len != 26)
fputc('"', nconf);
for (i = 0; i < cred->key_len; i++)
fputc(cred->key[i], nconf);
if (cred->key_len != 10 && cred->key_len != 26)
fputc('"', nconf);
if (cred->key_len == 10 || cred->key_len == 26) {
/* WEP key as a hex string */
for (i = 0; i < cred->key_len; i++)
fputc(cred->key[i], nconf);
} else {
/* Raw WEP key; convert to hex */
for (i = 0; i < cred->key_len; i++)
fprintf(nconf, "%02x", cred->key[i]);
}
fprintf(nconf, "\n");
}
}