Fabcoin Core  0.16.2
P2P Digital Currency
slowequals.c
Go to the documentation of this file.
1 #include <string.h>
2 
3 /* Implements a constant time version of strcmp()
4  * Will return 1 if a and b are equal, 0 if they are not */
5 int slow_equals(const char* a, const char* b)
6 {
7  size_t lena, lenb, diff, i;
8  lena = strlen(a);
9  lenb = strlen(b);
10  diff = strlen(a) ^ strlen(b);
11 
12  for(i=0; i<lena && i<lenb; i++)
13  {
14  diff |= a[i] ^ b[i];
15  }
16  if (diff == 0)
17  {
18  return 1;
19  }
20  else
21  {
22  return 0;
23  }
24 }
25 
26 
#define a(i)
#define b(i, j)
N diff(N const &_a, N const &_b)
Definition: Common.h:212
int slow_equals(const char *a, const char *b)
Definition: slowequals.c:5