summaryrefslogtreecommitdiff
path: root/nacl/crypto_verify/32/ref/verify.c
diff options
context:
space:
mode:
Diffstat (limited to 'nacl/crypto_verify/32/ref/verify.c')
-rw-r--r--nacl/crypto_verify/32/ref/verify.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/nacl/crypto_verify/32/ref/verify.c b/nacl/crypto_verify/32/ref/verify.c
new file mode 100644
index 00000000..a0e23afe
--- /dev/null
+++ b/nacl/crypto_verify/32/ref/verify.c
@@ -0,0 +1,40 @@
1#include "crypto_verify.h"
2
3int crypto_verify(const unsigned char *x,const unsigned char *y)
4{
5 unsigned int differentbits = 0;
6#define F(i) differentbits |= x[i] ^ y[i];
7 F(0)
8 F(1)
9 F(2)
10 F(3)
11 F(4)
12 F(5)
13 F(6)
14 F(7)
15 F(8)
16 F(9)
17 F(10)
18 F(11)
19 F(12)
20 F(13)
21 F(14)
22 F(15)
23 F(16)
24 F(17)
25 F(18)
26 F(19)
27 F(20)
28 F(21)
29 F(22)
30 F(23)
31 F(24)
32 F(25)
33 F(26)
34 F(27)
35 F(28)
36 F(29)
37 F(30)
38 F(31)
39 return (1 & ((differentbits - 1) >> 8)) - 1;
40}