Parcourir la source

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.
Jouni Malinen il y a 16 ans
Parent
commit
24466b188a
1 fichiers modifiés avec 9 ajouts et 6 suppressions
  1. 9 6
      hostapd/wps_hostapd.c

+ 9 - 6
hostapd/wps_hostapd.c

@@ -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");
 		}
 	}