diff --git a/src/ESP32React/ArduinoJsonJWT.cpp b/src/ESP32React/ArduinoJsonJWT.cpp index bbc2b11ac..7e7676af5 100644 --- a/src/ESP32React/ArduinoJsonJWT.cpp +++ b/src/ESP32React/ArduinoJsonJWT.cpp @@ -70,12 +70,16 @@ void ArduinoJsonJWT::parseJWT(String jwt, JsonDocument & jsonDocument) { */ String ArduinoJsonJWT::sign(String & payload) { std::array hmacResult{}; - mbedtls_md_hmac(mbedtls_md_info_from_type(MBEDTLS_MD_SHA256), - reinterpret_cast(_secret.c_str()), - _secret.length(), - reinterpret_cast(payload.c_str()), - payload.length(), - hmacResult.data()); + { + mbedtls_md_context_t ctx; + mbedtls_md_type_t md_type = MBEDTLS_MD_SHA256; + mbedtls_md_init(&ctx); + mbedtls_md_setup(&ctx, mbedtls_md_info_from_type(md_type), 1); + mbedtls_md_hmac_starts(&ctx, reinterpret_cast(_secret.c_str()), _secret.length()); + mbedtls_md_hmac_update(&ctx, reinterpret_cast(payload.c_str()), payload.length()); + mbedtls_md_hmac_finish(&ctx, hmacResult.data()); + mbedtls_md_free(&ctx); + } return encode(reinterpret_cast(hmacResult.data()), hmacResult.size()); } diff --git a/src/emsesp_version.h b/src/emsesp_version.h index 445611505..8bac1722e 100644 --- a/src/emsesp_version.h +++ b/src/emsesp_version.h @@ -1 +1 @@ -#define EMSESP_APP_VERSION "3.8.2-dev.14" +#define EMSESP_APP_VERSION "3.8.2-dev.15"