Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WiFi STA encryptionType() getter added #9114

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions libraries/ESP8266WiFi/src/ESP8266WiFi.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class ESP8266WiFiClass : public ESP8266WiFiGenericClass, public ESP8266WiFiSTACl
using ESP8266WiFiGenericClass::channel;

using ESP8266WiFiSTAClass::SSID;
using ESP8266WiFiSTAClass::encryptionType;
using ESP8266WiFiSTAClass::RSSI;
using ESP8266WiFiSTAClass::BSSID;
using ESP8266WiFiSTAClass::BSSIDstr;
Expand Down
1 change: 1 addition & 0 deletions libraries/ESP8266WiFi/src/ESP8266WiFiGeneric.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ void ESP8266WiFiGenericClass::_eventCallback(void* arg)

if (event->event == EVENT_STAMODE_AUTHMODE_CHANGE) {
auto& src = event->event_info.auth_change;
WiFi.authMode = src.new_mode;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this is a side-effect of attempted authmode (i.e. wpa3 downgrade to wpa2) or event that always happen every connection?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

after every connection.
src.old_mode is 0

if ((src.old_mode != AUTH_OPEN) && (src.new_mode == AUTH_OPEN)) {
// CVE-2020-12638 workaround. When we get a change to AUTH_OPEN from any other mode, drop the WiFi link because it's a downgrade attack
// TODO - When upgrading to 3.x.x with fix, remove this code
Expand Down
21 changes: 21 additions & 0 deletions libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,27 @@ String ESP8266WiFiSTAClass::psk() const {
return String(reinterpret_cast<char*>(tmp));
}

/**
* Return the encryption type of the network
* @return encryption type (enum wl_enc_type)
*/
uint8_t ESP8266WiFiSTAClass::encryptionType() {
switch(authMode) {
case AUTH_OPEN:
return ENC_TYPE_NONE;
case AUTH_WEP:
return ENC_TYPE_WEP;
case AUTH_WPA_PSK:
return ENC_TYPE_TKIP;
case AUTH_WPA2_PSK:
return ENC_TYPE_CCMP;
case AUTH_WPA_WPA2_PSK:
return ENC_TYPE_AUTO;
default:
return -1;
}
}

/**
* Return the current bssid / mac associated with the network if configured
* @return bssid uint8_t *
Expand Down
4 changes: 4 additions & 0 deletions libraries/ESP8266WiFi/src/ESP8266WiFiSTA.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ class ESP8266WiFiSTAClass: public LwipIntf {
wl_status_t status();
String SSID() const;
String psk() const;
uint8_t encryptionType();

uint8_t * BSSID();
uint8_t * BSSID(uint8_t* bssid);
Expand All @@ -94,6 +95,9 @@ class ESP8266WiFiSTAClass: public LwipIntf {
static void enableInsecureWEP (bool enable = true) { _useInsecureWEP = enable; }

protected:
friend class ESP8266WiFiGenericClass;

uint8_t authMode;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-1 default?
reset to -1 on disconnect?


static bool _useStaticIp;
static bool _useInsecureWEP;
Expand Down