From f50656d00cac5125b0fd8ae7dbfa314b83597ad4 Mon Sep 17 00:00:00 2001 From: Jouke Witteveen Date: Mon, 21 Oct 2013 16:47:21 +0200 Subject: Better detection of hex keys 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. --- src/lib/wpa | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/lib') 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")" -- cgit v1.2.3-24-g4f1b