File tree Expand file tree Collapse file tree 3 files changed +14
-10
lines changed Expand file tree Collapse file tree 3 files changed +14
-10
lines changed Original file line number Diff line number Diff line change @@ -49,6 +49,7 @@ std::string U16toU8(char16_t* src, size_t max);
49
49
size_t U8toU16 (std::string src, char16_t * des, size_t max); // returns number of char16_t that was written at des
50
50
time_t getTime ();
51
51
time_t getTimestamp ();
52
+ int timingSafeStrcmp (const char * a, const char * b);
52
53
void terminate (int );
53
54
54
55
// The PROTOCOL_VERSION definition can be defined by the build system.
Original file line number Diff line number Diff line change
1
+ #include " core/CNStructs.hpp"
2
+
1
3
#include " db/internal.hpp"
2
4
3
5
#include " bcrypt/BCrypt.hpp"
4
6
5
- static int timingSafeStrcmp (const char * a, const char * b) {
6
- int diff = 0 ;
7
- while (*a && *b) {
8
- diff |= *a++ ^ *b++;
9
- }
10
- diff |= *a;
11
- diff |= *b;
12
- return diff;
13
- }
14
-
15
7
void Database::findAccount (Account* account, std::string login) {
16
8
std::lock_guard<std::mutex> lock (dbCrit);
17
9
Original file line number Diff line number Diff line change @@ -222,6 +222,17 @@ time_t getTimestamp() {
222
222
return (time_t )value.count ();
223
223
}
224
224
225
+ // timing safe strcmp implementation for e.g. cookie validation
226
+ int timingSafeStrcmp (const char * a, const char * b) {
227
+ int diff = 0 ;
228
+ while (*a && *b) {
229
+ diff |= *a++ ^ *b++;
230
+ }
231
+ diff |= *a;
232
+ diff |= *b;
233
+ return diff;
234
+ }
235
+
225
236
// convert integer timestamp (in s) to FF systime struct
226
237
sSYSTEMTIME timeStampToStruct (uint64_t time) {
227
238
You can’t perform that action at this time.
0 commit comments