You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
645 B
C++
20 lines
645 B
C++
2 years ago
|
// This file is under GNU General Public License 3.0
|
||
|
// see LICENSE.txt
|
||
|
|
||
|
#ifndef LIBPEPADAPTER_CONSTANT_TIME_ALGO_HH
|
||
|
#define LIBPEPADAPTER_CONSTANT_TIME_ALGO_HH
|
||
3 years ago
|
|
||
|
#include <string>
|
||
|
|
||
2 years ago
|
namespace pEp {
|
||
3 years ago
|
// Returns false if a.size() != b.size().
|
||
|
// Compares always _all_ characters of 'a' and 'b' so runtime does not
|
||
|
// depends on the character position where the strings differ.
|
||
|
// Use this function instead of operator== if timing sidechannel attack
|
||
|
// might be a security problem.
|
||
2 years ago
|
bool constant_time_equal(const std::string &a, const std::string &b);
|
||
3 years ago
|
|
||
|
} // end of namespace pEp
|
||
2 years ago
|
|
||
|
#endif // LIBPEPADAPTER_CONSTANT_TIME_ALGO_HH
|