crypto_verify_bytes.c 467 B

12345678910111213141516171819202122
  1. #include <stddef.h>
  2. #include <stdint.h>
  3. #include "crypto_verify_bytes.h"
  4. /**
  5. * crypto_verify_bytes(buf0, buf1, len):
  6. * Return zero if and only if ${buf0[0 .. len - 1]} and ${buf1[0 .. len - 1]}
  7. * are identical. Do not leak any information via timing side channels.
  8. */
  9. uint8_t
  10. crypto_verify_bytes(const uint8_t * buf0, const uint8_t * buf1, size_t len)
  11. {
  12. uint8_t rc = 0;
  13. size_t i;
  14. for (i = 0; i < len; i++)
  15. rc = rc | (buf0[i] ^ buf1[i]);
  16. return (rc);
  17. }