diff options
Diffstat (limited to 'nacl/crypto_verify/16/ref')
-rw-r--r-- | nacl/crypto_verify/16/ref/api.h | 1 | ||||
-rw-r--r-- | nacl/crypto_verify/16/ref/verify.c | 24 |
2 files changed, 25 insertions, 0 deletions
diff --git a/nacl/crypto_verify/16/ref/api.h b/nacl/crypto_verify/16/ref/api.h new file mode 100644 index 00000000..32be2f97 --- /dev/null +++ b/nacl/crypto_verify/16/ref/api.h | |||
@@ -0,0 +1 @@ | |||
#define CRYPTO_BYTES 16 | |||
diff --git a/nacl/crypto_verify/16/ref/verify.c b/nacl/crypto_verify/16/ref/verify.c new file mode 100644 index 00000000..d356060c --- /dev/null +++ b/nacl/crypto_verify/16/ref/verify.c | |||
@@ -0,0 +1,24 @@ | |||
1 | #include "crypto_verify.h" | ||
2 | |||
3 | int 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 | return (1 & ((differentbits - 1) >> 8)) - 1; | ||
24 | } | ||