FreeBSD/contrib/ntp/ntpd/ntp_crypto.c
/*
 * crypto_ident - construct extension field for identity scheme
 *
 * This routine determines which identity scheme is in use and
 * constructs an extension field for that scheme.
 *
 * Returns
 * CRYTPO_IFF	IFF scheme
 * CRYPTO_GQ	GQ scheme
 * CRYPTO_MV	MV scheme
 * CRYPTO_NULL	no available scheme
 */
construct extension field for identity scheme
This routine determines which identity scheme is in use and
constructs an extension field for that scheme.


construct extension field for identity scheme This routine determines which identity scheme is in use and constructs an extension field for that scheme .
u_int
crypto_ident(
	struct peer *peer	
	)
{
	char		filename[MAXFILENAME];
	const char *	scheme_name;
	u_int		scheme_id;
	scheme_name = NULL;
	if (peer->crypto & CRYPTO_FLAG_IFF) {
		scheme_name = "iff";
		scheme_id = CRYPTO_IFF;
	} else if (peer->crypto & CRYPTO_FLAG_GQ) {
		scheme_name = "gq";
		scheme_id = CRYPTO_GQ;
	} else if (peer->crypto & CRYPTO_FLAG_MV) {
		scheme_name = "mv";
		scheme_id = CRYPTO_MV;
	}
	if (scheme_name != NULL) {
		snprintf(filename, sizeof(filename), "ntpkey_%spar_%s",
		    scheme_name, peer->ident);
		peer->ident_pkey = crypto_key(filename, NULL,
		    &peer->srcadr);
		if (peer->ident_pkey != NULL)
			return scheme_id;
	}
	msyslog(LOG_NOTICE,
	    "crypto_ident: no identity parameters found for group %s",
	    peer->ident);
	return CRYPTO_NULL;
}
u_int crypto_ident ( struct peer * peer ) { char filename [ MAXFILENAME ] ; const char * scheme_name ; u_int scheme_id ; scheme_name = NULL ; if ( peer -> crypto & CRYPTO_FLAG_IFF ) { scheme_name = " " ; scheme_id = CRYPTO_IFF ; } else if ( peer -> crypto & CRYPTO_FLAG_GQ ) { scheme_name = " " ; scheme_id = CRYPTO_GQ ; } else if ( peer -> crypto & CRYPTO_FLAG_MV ) { scheme_name = " " ; scheme_id = CRYPTO_MV ; } if ( scheme_name != NULL ) { snprintf ( filename , sizeof ( filename ) , " " , scheme_name , peer -> ident ) ; peer -> ident_pkey = crypto_key ( filename , NULL , & peer -> srcadr ) ; if ( peer -> ident_pkey != NULL ) return scheme_id ; } msyslog ( LOG_NOTICE , " " , peer -> ident ) ; return CRYPTO_NULL ; }
crypto_ident - construct extension field for identity scheme
 This routine determines which identity scheme is in use and
 constructs an extension field for that scheme.
crypto_ident - construct extension field for identity scheme This routine determines which identity scheme is in use and constructs an extension field for that scheme .
/* peer structure pointer */ /*
	 * We come here after the group trusted host has been found; its
	 * name defines the group name. Search the key cache for all
	 * keys matching the same group name in order IFF, GQ and MV.
	 * Use the first one available.
	 */