(_kdc_get_preferred_key): new function, Use the order list of
preferred encryption types and sort the available keys and return the most preferred key. git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@17907 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
36
kdc/misc.c
36
kdc/misc.c
@@ -84,3 +84,39 @@ _kdc_free_ent(krb5_context context, hdb_entry_ex *ent)
|
||||
free (ent);
|
||||
}
|
||||
|
||||
/*
|
||||
* Use the order list of preferred encryption types and sort the
|
||||
* available keys and return the most preferred key.
|
||||
*/
|
||||
|
||||
krb5_error_code
|
||||
_kdc_get_preferred_key(krb5_context context,
|
||||
krb5_kdc_configuration *config,
|
||||
hdb_entry_ex *h,
|
||||
const char *name,
|
||||
krb5_enctype *enctype,
|
||||
Key **key)
|
||||
{
|
||||
const krb5_enctype *p;
|
||||
krb5_error_code ret;
|
||||
int i;
|
||||
|
||||
p = krb5_kerberos_enctypes(context);
|
||||
|
||||
for (i = 0; p[i] != ETYPE_NULL; i++) {
|
||||
if (krb5_enctype_valid(context, p[i]) != 0)
|
||||
continue;
|
||||
ret = hdb_enctype2key(context,
|
||||
&h->entry,
|
||||
p[i],
|
||||
key);
|
||||
if (ret == 0) {
|
||||
*enctype = p[i];
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
krb5_set_error_string(context, "No valid kerberos key found for %s", name);
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user