summaryrefslogtreecommitdiffstats
path: root/src/lib-otp/otp-parity.h
blob: 86ea18fef940440fe80e0975c6d20dd004c3cd33 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#ifndef OTP_PARITY_H
#define OTP_PARITY_H

extern const unsigned char parity_table[256];

static inline unsigned int otp_parity(unsigned char *data)
{
	unsigned int i, parity = 0;

	for (i = 0; i < OTP_HASH_SIZE; i++)
		parity += parity_table[*data++];

	return parity & 3;
}

#endif