userver
C++ Async Framework
Documentation
API Groups
Namespaces
Reference
Class List
Class Index
File List
Macros
All
e
i
l
r
t
u
Functions
Macros
e
i
l
r
t
u
Examples
Toggle main menu visibility
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Modules
Pages
Concepts
Loading...
Searching...
No Matches
All results
algorithm.hpp
Go to the documentation of this file.
1
#
pragma
once
2
3
/// @file userver/crypto/algorithm.hpp
4
/// @brief @copybrief crypto::algorithm
5
/// @ingroup userver_universal
6
7
#
include
<
string_view
>
8
9
USERVER_NAMESPACE_BEGIN
10
11
/// Miscellaneous cryptographic routines
12
namespace
crypto
::
algorithm
{
13
14
/// Performs constant-time string comparison if the strings are of equal size
15
///
16
/// @snippet storages/secdist/secdist_test.cpp UserPasswords
17
bool
AreStringsEqualConstTime
(std::string_view str1, std::string_view str2)
noexcept
;
18
19
/// Performs constant-time string comparison comparator
20
struct
StringsEqualConstTimeComparator
{
21
bool
operator()(std::string_view x, std::string_view y)
const
noexcept
{
22
return
algorithm
::
AreStringsEqualConstTime
(
x
,
y
)
;
23
}
24
25
/// Overload for utils::StrongTypedef that hold string like objects
26
template
<
typename
T>
27
auto
operator
()(
const
T& x,
const
T& y)
const
noexcept
28
->
decltype
(
algorithm
::
AreStringsEqualConstTime
(
x.GetUnderlying()
,
y.GetUnderlying()
)
) {
29
static_assert
(
30
noexcept
(
algorithm
::
AreStringsEqualConstTime
(
x.GetUnderlying()
,
y.GetUnderlying()
)
),
31
"The comparator should not throw as this affects efficiency "
32
"on some platforms"
33
);
34
35
return
algorithm
::
AreStringsEqualConstTime
(
x.GetUnderlying()
,
y.GetUnderlying()
)
;
36
}
27
auto
operator
()(
const
T& x,
const
T& y)
const
noexcept
{
…
}
37
};
20
struct
StringsEqualConstTimeComparator
{
…
};
38
39
}
// namespace crypto::algorithm
12
namespace
crypto
::
algorithm
{
…
}
40
41
USERVER_NAMESPACE_END
Docs version:
v1.0
,
v2.0
,
trunk/develop
userver
crypto
algorithm.hpp
Generated on Thu Apr 24 2025 12:22:07 for userver by
Doxygen
1.13.2