[arch-projects] [netctl][PATCH] Better detection of hex keys

Jouke Witteveen j.witteveen at gmail.com
Wed Oct 23 08:06:45 EDT 2013


Hex WEP keys are of even length, ASCII keys are of odd length.
Using this information we make wifi-menu work better for WEP networks.

Signed-off-by: Jouke Witteveen <j.witteveen at gmail.com>
---
 src/lib/wpa | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/lib/wpa b/src/lib/wpa
index d79fdbe..ff6d9ab 100644
--- a/src/lib/wpa
+++ b/src/lib/wpa
@@ -219,11 +219,15 @@ wpa_make_config_block() {
       wep)
         echo "key_mgmt=NONE"
         echo "wep_tx_keyidx=0"
-        echo "wep_key0=$(wpa_quote "$Key")"
+        if (( ${#Key} % 2 == 0 )) && [[ "$key" = +([[:xdigit:]]) ]]; then
+            echo "wep_key0=$Key"
+        else
+            echo "wep_key0=$(wpa_quote "$Key")"
+        fi
       ;;
       wpa)
         echo "proto=RSN WPA"
-        if [[ "${#Key}" -eq 64 ]]; then
+        if [[ "${#key}" -eq 64 && "$key" = +([[:xdigit:]]) ]]; then
             echo "psk=$Key"
         else
             echo "psk=$(wpa_quote "$Key")"
-- 
1.8.4.1



More information about the arch-projects mailing list