mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-04-14 06:16:35 +00:00
More crypto work in progress...
This commit is contained in:
parent
032ce498c4
commit
0b94a04914
1941
node/C25519.cpp
1941
node/C25519.cpp
File diff suppressed because it is too large
Load Diff
@ -66,6 +66,38 @@ namespace ZeroTier {
|
||||
class Utils
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Perform a time-invariant binary comparison
|
||||
*
|
||||
* @param a First binary string
|
||||
* @param b Second binary string
|
||||
* @param len Length of strings
|
||||
* @return True if strings are equal
|
||||
*/
|
||||
static inline bool secureEq(const void *a,const void *b,unsigned int len)
|
||||
throw()
|
||||
{
|
||||
const char *p1 = (const char *)a;
|
||||
const char *p2 = (const char *)b;
|
||||
uint64_t diff = 0;
|
||||
|
||||
while (len >= 8) {
|
||||
diff |= (*((const uint64_t *)p1) ^ *((const uint64_t *)p2));
|
||||
p1 += 8;
|
||||
p2 += 8;
|
||||
len -= 8;
|
||||
}
|
||||
|
||||
while (len) {
|
||||
diff |= (uint64_t)(*p1 ^ *p2);
|
||||
++p1;
|
||||
++p2;
|
||||
--len;
|
||||
}
|
||||
|
||||
return (diff == 0ULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a file
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user