From bf3be9cc87754334a2fdc6df655a638cfc65b529 Mon Sep 17 00:00:00 2001 From: Paul Park Date: Tue, 15 Aug 1995 18:26:40 +0000 Subject: [PATCH] Add krb5_dbe_find_keytype() and clean up gcc -Wall complaints git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@6522 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/kdb/ChangeLog | 5 +++++ src/lib/kdb/kdb_xdr.c | 51 +++++++++++++++++++++++++++++++++++++++---- 2 files changed, 52 insertions(+), 4 deletions(-) diff --git a/src/lib/kdb/ChangeLog b/src/lib/kdb/ChangeLog index 415fc4148..53ea664a3 100644 --- a/src/lib/kdb/ChangeLog +++ b/src/lib/kdb/ChangeLog @@ -1,4 +1,9 @@ +Tue Aug 15 14:25:42 EDT 1995 Paul Park (pjpark@mit.edu) + * kdb_xdr.c - Add krb5_dbe_find_keytype() and clean up gcc -Wall + complaints. + + Wed Aug 9 17:17:36 EDT 1995 Paul Park (pjpark@mit.edu) * kdb_cpw.c - Add check for uniqueness of key or key/salt combo. Don't generate a new key_data entry if one already exists. Also, diff --git a/src/lib/kdb/kdb_xdr.c b/src/lib/kdb/kdb_xdr.c index 76286490e..66cc23a34 100644 --- a/src/lib/kdb/kdb_xdr.c +++ b/src/lib/kdb/kdb_xdr.c @@ -47,6 +47,7 @@ krb5_dbe_create_key_data(context, entry) return 0; } +krb5_error_code krb5_dbe_encode_mod_princ_data(context, mod_princ, entry) krb5_context context; krb5_tl_mod_princ * mod_princ; @@ -103,6 +104,7 @@ krb5_dbe_encode_mod_princ_data(context, mod_princ, entry) return ENOMEM; } +krb5_error_code krb5_dbe_decode_mod_princ_data(context, entry, mod_princ) krb5_context context; krb5_db_entry * entry; @@ -141,6 +143,7 @@ krb5_dbe_decode_mod_princ_data(context, entry, mod_princ) return retval; } +krb5_error_code krb5_encode_princ_dbmkey(context, key, principal) krb5_context context; datum *key; @@ -181,8 +184,6 @@ krb5_encode_princ_contents(context, content, entry) krb5_error_code retval; krb5_int16 psize16; - krb5_db_entry copy_princ; - /* * Generate one lump of data from the krb5_db_entry. * This data must be independent of byte order of the machine, @@ -373,9 +374,7 @@ krb5_decode_princ_contents(context, content, entry) krb5_tl_data ** tl_data; krb5_int16 i16; - krb5_principal princ; krb5_error_code retval; - int major_version = 0, minor_version = 0; /* Zero out entry and NULL pointers */ memset(entry, 0, sizeof(krb5_db_entry)); @@ -616,3 +615,47 @@ krb5_dbe_free_contents(context, entry) return; } +/* + * Given a particular keytype and optional salttype and kvno, find the + * most appropriate krb5_key_data entry of the database entry. + * + * If stype or kvno is negative, it is ignored. + */ +krb5_error_code +krb5_dbe_find_keytype(kcontext, dbentp, ktype, stype, kvno, kdatap) + krb5_context kcontext; + krb5_db_entry *dbentp; + krb5_keytype ktype; + krb5_int32 stype; + krb5_int32 kvno; + krb5_key_data **kdatap; +{ + int i; + int maxkvno; + krb5_key_data *datap; + + maxkvno = -1; + datap = (krb5_key_data *) NULL; + for (i=0; in_key_data; i++) { + if ((dbentp->key_data[i].key_data_type[0] == ktype) && + ((dbentp->key_data[i].key_data_type[1] == stype) || + (stype < 0))) { + if (kvno >= 0) { + if (kvno == dbentp->key_data[i].key_data_kvno) { + maxkvno = kvno; + datap = &dbentp->key_data[i]; + break; + } + } + else { + if (dbentp->key_data[i].key_data_kvno > maxkvno) { + maxkvno = dbentp->key_data[i].key_data_kvno; + datap = &dbentp->key_data[i]; + } + } + } + } + *kdatap = datap; + return((maxkvno >= 0) ? 0 : ENOENT); +} + -- 2.26.2