Browse Source

More crypto work in progress...

pull/1/head
Adam Ierymenko 13 years ago
parent
commit
0b94a04914
  1. 1941
      node/C25519.cpp
  2. 32
      node/Utils.hpp

1941
node/C25519.cpp

File diff suppressed because it is too large Load Diff

32
node/Utils.hpp

@ -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…
Cancel
Save