1 |
|
|
/* $OpenBSD: verify.c,v 1.3 2013/12/09 11:03:45 markus Exp $ */ |
2 |
|
|
|
3 |
|
|
/* |
4 |
|
|
* Public Domain, Author: Daniel J. Bernstein |
5 |
|
|
* Copied from nacl-20110221/crypto_verify/32/ref/verify.c |
6 |
|
|
*/ |
7 |
|
|
|
8 |
|
|
#include "crypto_api.h" |
9 |
|
|
|
10 |
|
|
int crypto_verify_32(const unsigned char *x,const unsigned char *y) |
11 |
|
|
{ |
12 |
|
|
unsigned int differentbits = 0; |
13 |
|
|
#define F(i) differentbits |= x[i] ^ y[i]; |
14 |
|
|
F(0) |
15 |
|
|
F(1) |
16 |
|
|
F(2) |
17 |
|
|
F(3) |
18 |
|
|
F(4) |
19 |
|
|
F(5) |
20 |
|
|
F(6) |
21 |
|
|
F(7) |
22 |
|
|
F(8) |
23 |
|
|
F(9) |
24 |
|
|
F(10) |
25 |
|
|
F(11) |
26 |
|
|
F(12) |
27 |
|
|
F(13) |
28 |
|
|
F(14) |
29 |
|
|
F(15) |
30 |
|
|
F(16) |
31 |
|
|
F(17) |
32 |
|
|
F(18) |
33 |
|
|
F(19) |
34 |
|
|
F(20) |
35 |
|
|
F(21) |
36 |
|
|
F(22) |
37 |
|
|
F(23) |
38 |
|
|
F(24) |
39 |
|
|
F(25) |
40 |
|
|
F(26) |
41 |
|
|
F(27) |
42 |
|
|
F(28) |
43 |
|
|
F(29) |
44 |
|
|
F(30) |
45 |
|
|
F(31) |
46 |
|
|
return (1 & ((differentbits - 1) >> 8)) - 1; |
47 |
|
|
} |