FreeBSD/contrib/ntp/sntp/crypto.c
/* Generates a md5 digest of the key specified in keyid concatenated with the 
 * ntp packet (exluding the MAC) and compares this digest to the digest in
 * the packet's MAC. If they're equal this function returns 1 (packet is 
 * authentic) or else 0 (not authentic).
 */
Generates a md5 digest of the key specified in keyid concatenated with the
ntp packet (exluding the MAC) and compares this digest to the digest in
the packet's MAC. If they're equal this function returns 1 (packet is
authentic) or else 0 (not authentic).
Generates a md5 digest of the key specified in keyid concatenated with the ntp packet ( exluding the MAC ) and compares this digest to the digest in the packet ' s MAC . If they ' re equal this function returns 1 ( packet is authentic ) or else 0 ( not authentic ) .
int
auth_md5(
	const void *pkt_data,
	int pkt_size,
	int mac_size,
	const struct key *cmp_key
	)
{
	int  hash_len;
	int  authentic;
	char digest[20];
	const u_char *pkt_ptr; 
	if (mac_size > (int)sizeof(digest))
		return 0;
	pkt_ptr = pkt_data;
	hash_len = make_mac(pkt_ptr, pkt_size, sizeof(digest), cmp_key,
			    digest);
	if (!hash_len) {
		authentic = FALSE;
	} else {
		authentic = !memcmp(digest, (const char*)pkt_data + pkt_size + 4,
				    hash_len);
	}
	return authentic;
}
int auth_md5 ( const void * pkt_data , int pkt_size , int mac_size , const struct key * cmp_key ) { int hash_len ; int authentic ; char digest [ 20 ] ; const u_char * pkt_ptr ; if ( mac_size > ( int ) sizeof ( digest ) ) return 0 ; pkt_ptr = pkt_data ; hash_len = make_mac ( pkt_ptr , pkt_size , sizeof ( digest ) , cmp_key , digest ) ; if ( ! hash_len ) { authentic = FALSE ; } else { authentic = ! memcmp ( digest , ( const char * ) pkt_data + pkt_size + 4 , hash_len ) ; } return authentic ; }
Generates a md5 digest of the key specified in keyid concatenated with the
 ntp packet (exluding the MAC) and compares this digest to the digest in
 the packet's MAC.
Generates a md5 digest of the key specified in keyid concatenated with the ntp packet ( exluding the MAC ) and compares this digest to the digest in the packet ' s MAC .
/* isc_tsmemcmp will be better when its easy to link
		 * with.  sntp is a 1-shot program, so snooping for
		 * timing attacks is Harder.
		 */