mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-05 20:13:44 +02:00
More crypto work in progress...
This commit is contained in:
parent
032ce498c4
commit
0b94a04914
2 changed files with 1973 additions and 0 deletions
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
|
class Utils
|
||||||
{
|
{
|
||||||
public:
|
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
|
* Delete a file
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Reference in a new issue