File: crypto_verify_bytes.c

package info (click to toggle)
python-scrypt 0.9.4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 832 kB
  • sloc: ansic: 6,290; python: 733; sh: 99; makefile: 5
file content (21 lines) | stat: -rw-r--r-- 467 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <stddef.h>
#include <stdint.h>

#include "crypto_verify_bytes.h"

/**
 * crypto_verify_bytes(buf0, buf1, len):
 * Return zero if and only if ${buf0[0 .. len - 1]} and ${buf1[0 .. len - 1]}
 * are identical.  Do not leak any information via timing side channels.
 */
uint8_t
crypto_verify_bytes(const uint8_t * buf0, const uint8_t * buf1, size_t len)
{
	uint8_t rc = 0;
	size_t i;

	for (i = 0; i < len; i++)
		rc = rc | (buf0[i] ^ buf1[i]);

	return (rc);
}