utils: Add a constant time memeq() variant for cryptographic purposes

This commit is contained in:
Martin Willi
2015-04-14 11:51:54 +02:00
parent 39e1ddec2e
commit b833963270
4 changed files with 79 additions and 1 deletions
+5
View File
@@ -184,6 +184,11 @@ static inline bool memeq(const void *x, const void *y, size_t len)
return memcmp(x, y, len) == 0;
}
/**
* Same as memeq(), but with a constant runtime, safe for cryptographic use.
*/
bool memeq_const(const void *x, const void *y, size_t len);
/**
* Calling memcpy() with NULL pointers, even with n == 0, results in undefined
* behavior according to the C standard. This version is guaranteed to not