userver: crypto::algorithm Namespace Reference
Loading...
Searching...
No Matches
crypto::algorithm Namespace Reference

Miscellaneous cryptographic routines. More...

Classes

struct  StringsEqualConstTimeComparator
 Performs constant-time string comparison comparator. More...
 

Functions

bool AreStringsEqualConstTime (std::string_view str1, std::string_view str2) noexcept
 

Detailed Description

Miscellaneous cryptographic routines.

Function Documentation

◆ AreStringsEqualConstTime()

bool crypto::algorithm::AreStringsEqualConstTime ( std::string_view  str1,
std::string_view  str2 
)
noexcept

Performs constant-time string comparison if the strings are of equal size

#include <userver/storages/secdist/provider_component.hpp>
class UserPasswords {
public:
UserPasswords(const formats::json::Value& doc)
: user_password_(doc["user-passwords"].As<Storage>()) {}
bool IsMatching(const std::string& user, const Password& password) const {
const auto* ptr = utils::FindOrNullptr(user_password_, user);
ptr->GetUnderlying(), password.GetUnderlying());
}
private:
using Storage = std::unordered_map<std::string, Password>;
Storage user_password_;
};