Skip to content
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
17 changes: 17 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,23 @@ if(ESP_IDF_BUILD)
# Apply ESP-IDF configuration
sendspin_configure_esp_idf(${COMPONENT_LIB} ${COMPONENT_DIR})

# esphome__noise-c disables protocol name tables by default (NOISE_USE_PROTOCOL_NAME_TABLE=0),
# which pins noise-c to only Noise_NNpsk0 for the ESPHome native API.
# Sendspin uses Noise_KKpsk2, so re-enable the protocol name tables and full pattern expansion.
foreach(_noise_target esphome__noise-c __idf_esphome__noise-c)
if(TARGET ${_noise_target})
get_target_property(_noise_defs ${_noise_target} COMPILE_DEFINITIONS)
if(_noise_defs)
list(REMOVE_ITEM _noise_defs "NOISE_USE_PROTOCOL_NAME_TABLE=0")
list(APPEND _noise_defs "NOISE_USE_PROTOCOL_NAME_TABLE=1")
set_target_properties(${_noise_target} PROPERTIES COMPILE_DEFINITIONS "${_noise_defs}")
else()
target_compile_definitions(${_noise_target} PRIVATE NOISE_USE_PROTOCOL_NAME_TABLE=1)
endif()
target_compile_options(${_noise_target} PRIVATE "-DNOISE_USE_PROTOCOL_NAME_TABLE=1")
endif()
endforeach()

# ==============================================================================
# Host Build
# ==============================================================================
Expand Down
7 changes: 4 additions & 3 deletions src/noise_session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,10 @@ static NoiseHandshakeState* build_responder_hs(const std::string& suite_name,
const uint8_t* prologue, size_t prologue_len,
const uint8_t* psk) {
NoiseHandshakeState* hs = nullptr;
if (noise_handshakestate_new_by_name(&hs, suite_name.c_str(), NOISE_ROLE_RESPONDER) !=
NOISE_ERROR_NONE) {
SS_LOGE(TAG, "noise_handshakestate_new_by_name failed for suite %s", suite_name.c_str());
int err = noise_handshakestate_new_by_name(&hs, suite_name.c_str(), NOISE_ROLE_RESPONDER);
if (err != NOISE_ERROR_NONE) {
SS_LOGE(TAG, "noise_handshakestate_new_by_name failed for suite %s (error 0x%04x: %d)",
suite_name.c_str(), err, err);
return nullptr;
}

Expand Down