cxxmcp 1.1.6
C++ MCP SDK
Loading...
Searching...
No Matches
constant_time.hpp File Reference

Constant-time comparison helpers for auth secrets and lookup keys. More...

#include <cstddef>
#include <string_view>

Go to the source code of this file.

Functions

bool mcp::auth::constant_time_string_equal (std::string_view lhs, std::string_view rhs) noexcept
 Compare two strings without data-dependent early exit.
 

Detailed Description

Constant-time comparison helpers for auth secrets and lookup keys.

Function Documentation

◆ constant_time_string_equal()

bool mcp::auth::constant_time_string_equal ( std::string_view  lhs,
std::string_view  rhs 
)
inlinenoexcept

Compare two strings without data-dependent early exit.

The loop covers the longer input so equal-prefix mismatches and length mismatches do not return early through std::string::operator==.