mirror of
https://github.com/esp8266/Arduino.git
synced 2025-07-27 18:02:17 +03:00
Added constant time string comparison to avoid possible time-based attacks. (#3836)
* Added constant time strings comparison to avoid possible time-based attacks * Fixed data types * Fixed indentation * Moved string comnparison in constant time to String class; modified function body to assure constant time comparison despite compiler optimizations * Removed wrong code * Fixed error and prevented compiler optimization to delete u1 local variable * Avoid timing attacks on string comparison * Minor * changed counter names, removed else
This commit is contained in:
@ -229,7 +229,7 @@ void ArduinoOTAClass::_onRx(){
|
||||
String result = _challengemd5.toString();
|
||||
|
||||
ota_ip.addr = (uint32_t)_ota_ip;
|
||||
if(result.equals(response)){
|
||||
if(result.equalsConstantTime(response)) {
|
||||
_state = OTA_RUNUPDATE;
|
||||
} else {
|
||||
_udp_ota->append("Authentication Failed", 21);
|
||||
|
@ -119,7 +119,7 @@ bool ESP8266WebServer::authenticate(const char * username, const char * password
|
||||
return false;
|
||||
}
|
||||
sprintf(toencode, "%s:%s", username, password);
|
||||
if(base64_encode_chars(toencode, toencodeLen, encoded) > 0 && authReq.equals(encoded)){
|
||||
if(base64_encode_chars(toencode, toencodeLen, encoded) > 0 && authReq.equalsConstantTime(encoded)) {
|
||||
authReq = String();
|
||||
delete[] toencode;
|
||||
delete[] encoded;
|
||||
|
Reference in New Issue
Block a user