verify.c 668 B

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