network: support more encryptions methods
This commit is contained in:
parent
d9eeec3cba
commit
4dc364a5c6
@ -21,39 +21,49 @@ from sdbus import sd_bus_open_system, set_default_bus
|
|||||||
from gi.repository import GLib
|
from gi.repository import GLib
|
||||||
from uuid import uuid4
|
from uuid import uuid4
|
||||||
|
|
||||||
NM_802_11_AP_SEC_NONE = 0
|
NONE = 0 # The access point has no special security requirements.
|
||||||
NM_802_11_AP_SEC_PAIR_WEP40 = 1
|
PAIR_WEP40 = 1 # 40/64-bit WEP is supported for pairwise/unicast encryption.
|
||||||
NM_802_11_AP_SEC_PAIR_WEP104 = 2
|
PAIR_WEP104 = 2 # 104/128-bit WEP is supported for pairwise/unicast encryption.
|
||||||
NM_802_11_AP_SEC_PAIR_TKIP = 4
|
PAIR_TKIP = 4 # TKIP is supported for pairwise/unicast encryption.
|
||||||
NM_802_11_AP_SEC_PAIR_CCMP = 8
|
PAIR_CCMP = 8 # AES/CCMP is supported for pairwise/unicast encryption.
|
||||||
NM_802_11_AP_SEC_GROUP_WEP40 = 16
|
GROUP_WEP40 = 16 # 40/64-bit WEP is supported for group/broadcast encryption.
|
||||||
NM_802_11_AP_SEC_GROUP_WEP104 = 32
|
GROUP_WEP104 = 32 # 104/128-bit WEP is supported for group/broadcast encryption.
|
||||||
NM_802_11_AP_SEC_GROUP_TKIP = 64
|
GROUP_TKIP = 64 # TKIP is supported for group/broadcast encryption.
|
||||||
NM_802_11_AP_SEC_GROUP_CCMP = 128
|
GROUP_CCMP = 128 # AES/CCMP is supported for group/broadcast encryption.
|
||||||
NM_802_11_AP_SEC_KEY_MGMT_PSK = 256
|
KEY_MGMT_PSK = 256 # WPA/RSN Pre-Shared Key encryption
|
||||||
NM_802_11_AP_SEC_KEY_MGMT_802_1X = 512
|
KEY_MGMT_802_1X = 512 # 802.1x authentication and key management
|
||||||
|
KEY_MGMT_SAE = 1024 # WPA/RSN Simultaneous Authentication of Equals
|
||||||
|
KEY_MGMT_OWE = 2048 # WPA/RSN Opportunistic Wireless Encryption
|
||||||
|
KEY_MGMT_OWE_TM = 4096 # WPA/RSN Opportunistic Wireless Encryption transition mode
|
||||||
|
KEY_MGMT_EAP_SUITE_B_192 = 8192 # WPA3 Enterprise Suite-B 192
|
||||||
|
|
||||||
|
|
||||||
def get_encryption(flags):
|
def get_encryption(flags):
|
||||||
encryption = ""
|
if flags == 0:
|
||||||
if (
|
return "Open"
|
||||||
flags & NM_802_11_AP_SEC_PAIR_WEP40
|
|
||||||
or flags & NM_802_11_AP_SEC_PAIR_WEP104
|
encryption_mapping = {
|
||||||
or flags & NM_802_11_AP_SEC_GROUP_WEP40
|
PAIR_WEP40: "WEP",
|
||||||
or flags & NM_802_11_AP_SEC_GROUP_WEP104
|
PAIR_WEP104: "WEP",
|
||||||
):
|
PAIR_TKIP: "TKIP",
|
||||||
encryption += "WEP "
|
PAIR_CCMP: "AES",
|
||||||
if flags & NM_802_11_AP_SEC_PAIR_TKIP or flags & NM_802_11_AP_SEC_GROUP_TKIP:
|
GROUP_WEP40: "WEP",
|
||||||
encryption += "TKIP "
|
GROUP_WEP104: "WEP",
|
||||||
if flags & NM_802_11_AP_SEC_PAIR_CCMP or flags & NM_802_11_AP_SEC_GROUP_CCMP:
|
GROUP_TKIP: "TKIP",
|
||||||
encryption += "AES "
|
GROUP_CCMP: "AES",
|
||||||
if flags & NM_802_11_AP_SEC_KEY_MGMT_PSK:
|
KEY_MGMT_PSK: "WPA-PSK",
|
||||||
encryption += "WPA-PSK "
|
KEY_MGMT_802_1X: "802.1x",
|
||||||
if flags & NM_802_11_AP_SEC_KEY_MGMT_802_1X:
|
KEY_MGMT_SAE: "WPA-SAE",
|
||||||
encryption += "802.1x "
|
KEY_MGMT_OWE: "OWE",
|
||||||
if not encryption:
|
KEY_MGMT_OWE_TM: "OWE-TM",
|
||||||
encryption += "Open"
|
KEY_MGMT_EAP_SUITE_B_192: "WPA3-B192",
|
||||||
return encryption
|
}
|
||||||
|
|
||||||
|
encryption_methods = []
|
||||||
|
for flag, method_name in encryption_mapping.items():
|
||||||
|
if flags & flag and method_name not in encryption_methods:
|
||||||
|
encryption_methods.append(method_name)
|
||||||
|
return " ".join(encryption_methods)
|
||||||
|
|
||||||
|
|
||||||
def WifiChannels(freq: str):
|
def WifiChannels(freq: str):
|
||||||
@ -242,28 +252,46 @@ class SdbusNm:
|
|||||||
"ipv6": {"method": ("s", "auto")},
|
"ipv6": {"method": ("s", "auto")},
|
||||||
}
|
}
|
||||||
|
|
||||||
if "WPA-PSK" in security_type:
|
if security_type != "Open":
|
||||||
properties["802-11-wireless"]["security"] = (
|
properties["802-11-wireless"]["security"] = (
|
||||||
"s",
|
"s",
|
||||||
"802-11-wireless-security",
|
"802-11-wireless-security",
|
||||||
)
|
)
|
||||||
|
if "WPA-PSK" in security_type:
|
||||||
properties["802-11-wireless-security"] = {
|
properties["802-11-wireless-security"] = {
|
||||||
"key-mgmt": ("s", "wpa-psk"),
|
"key-mgmt": ("s", "wpa-psk"),
|
||||||
"auth-alg": ("s", "open"),
|
|
||||||
"psk": ("s", psk),
|
"psk": ("s", psk),
|
||||||
}
|
}
|
||||||
|
elif "SAE" in security_type:
|
||||||
|
properties["802-11-wireless-security"] = {
|
||||||
|
"key-mgmt": ("s", "sae"),
|
||||||
|
"psk": ("s", psk),
|
||||||
|
}
|
||||||
|
elif "WPA3-B192" in security_type:
|
||||||
|
properties["802-11-wireless-security"] = {
|
||||||
|
"key-mgmt": ("s", "wpa-eap-suite-b-192"),
|
||||||
|
"psk": ("s", psk),
|
||||||
|
}
|
||||||
|
elif "OWE" in security_type:
|
||||||
|
properties["802-11-wireless-security"] = {
|
||||||
|
"key-mgmt": ("s", "owe"),
|
||||||
|
"psk": ("s", psk),
|
||||||
|
}
|
||||||
|
elif "802.1x" in security_type:
|
||||||
|
properties["802-11-wireless-security"] = {
|
||||||
|
"key-mgmt": ("s", "ieee8021x"),
|
||||||
|
"wep-key-type": ("s", 2),
|
||||||
|
"wep-key0": ("s", psk),
|
||||||
|
"auth-alg": ("s", "shared"),
|
||||||
|
}
|
||||||
elif "WEP" in security_type:
|
elif "WEP" in security_type:
|
||||||
properties["802-11-wireless"]["security"] = (
|
|
||||||
"s",
|
|
||||||
"802-11-wireless-security",
|
|
||||||
)
|
|
||||||
properties["802-11-wireless-security"] = {
|
properties["802-11-wireless-security"] = {
|
||||||
"key-mgmt": ("s", "none"),
|
"key-mgmt": ("s", "none"),
|
||||||
"wep-key-type": ("s", "key"),
|
"wep-key-type": ("s", 2),
|
||||||
"wep-key0": ("s", psk),
|
"wep-key0": ("s", psk),
|
||||||
"auth-alg": ("s", "open"),
|
"auth-alg": ("s", "shared"),
|
||||||
}
|
}
|
||||||
elif security_type != "Open":
|
else:
|
||||||
return {
|
return {
|
||||||
"error": "unknown_security_type",
|
"error": "unknown_security_type",
|
||||||
"message": _("Unknown security type"),
|
"message": _("Unknown security type"),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user