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--; key_idx--;
fprintf(nconf, "wep_default_key=%d\n", key_idx); fprintf(nconf, "wep_default_key=%d\n", key_idx);
fprintf(nconf, "wep_key%d=", key_idx); fprintf(nconf, "wep_key%d=", key_idx);
if (cred->key_len != 10 && cred->key_len != 26) if (cred->key_len == 10 || cred->key_len == 26) {
fputc('"', nconf); /* WEP key as a hex string */
for (i = 0; i < cred->key_len; i++) for (i = 0; i < cred->key_len; i++)
fputc(cred->key[i], nconf); fputc(cred->key[i], nconf);
if (cred->key_len != 10 && cred->key_len != 26) } else {
fputc('"', nconf); /* Raw WEP key; convert to hex */
for (i = 0; i < cred->key_len; i++)
fprintf(nconf, "%02x", cred->key[i]);
}
fprintf(nconf, "\n"); fprintf(nconf, "\n");
} }
} }