FreeBSD/contrib/ntp/libntp/authkeys.c
/*
 * authtrust - declare a key to be trusted/untrusted
 */
declare a key to be trusted/untrusted
declare a key to be trusted / untrusted
void
authtrust(
	keyid_t		id,
	u_long		trust
	)
{
	symkey *	sk;
	u_long		lifetime;
	sk = auth_findkey(id);
	if (!trust && sk == NULL)
		return;
	if (sk != NULL) {
		authcache_flush_id(id);
		if (trust > 0) {
			sk->flags |= KEY_TRUSTED;
			if (trust > 1)
				sk->lifetime = current_time + trust;
			else
				sk->lifetime = 0;
		} else {
			freesymkey(sk);
		}
		return;
	}
	if (trust > 1) {
		lifetime = current_time + trust;
	} else {
		lifetime = 0;
	}
	allocsymkey(id, KEY_TRUSTED, 0, lifetime, 0, NULL, NULL);
}
void authtrust ( keyid_t id , u_long trust ) { symkey * sk ; u_long lifetime ; sk = auth_findkey ( id ) ; if ( ! trust && sk == NULL ) return ; if ( sk != NULL ) { authcache_flush_id ( id ) ; if ( trust > 0 ) { sk -> flags |= KEY_TRUSTED ; if ( trust > 1 ) sk -> lifetime = current_time + trust ; else sk -> lifetime = 0 ; } else { freesymkey ( sk ) ; } return ; } if ( trust > 1 ) { lifetime = current_time + trust ; } else { lifetime = 0 ; } allocsymkey ( id , KEY_TRUSTED , 0 , lifetime , 0 , NULL , NULL ) ; }
authtrust - declare a key to be trusted/untrusted
authtrust - declare a key to be trusted / untrusted
/*
	 * Search bin for key; if it does not exist and is untrusted,
	 * forget it.
	 */ /*
	 * There are two conditions remaining. Either it does not
	 * exist and is to be trusted or it does exist and is or is
	 * not to be trusted.
	 */ /*
		 * Key exists. If it is to be trusted, say so and update
		 * its lifetime. If no longer trusted, return it to the
		 * free list. Flush the cache first to be sure there are
		 * no discrepancies.
		 */ /*
	 * keyid is not present, but the is to be trusted.  We allocate
	 * a new key, but do not specify a key type or secret.
	 */