More crypto work in progress...

This commit is contained in:
Adam Ierymenko 2013-09-13 16:53:47 -04:00
parent 032ce498c4
commit 0b94a04914
2 changed files with 1973 additions and 0 deletions

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
*