From af9554aa0031f7887fa6aba8a98ba1a586a9d3fc Mon Sep 17 00:00:00 2001 From: Paul Park Date: Tue, 15 Aug 1995 18:29:06 +0000 Subject: [PATCH] Replace key_name_to_data() with krb5_dbe_find_keytype() git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@6524 dc483132-0cff-0310-8789-dd5450dbe970 --- src/kadmin/v5server/ChangeLog | 5 +++ src/kadmin/v5server/admin.c | 30 ++++++++++--- src/kadmin/v5server/kadm5_defs.h | 4 -- src/kadmin/v5server/passwd.c | 10 +++-- src/kadmin/v5server/srv_key.c | 74 ++++++++------------------------ 5 files changed, 53 insertions(+), 70 deletions(-) diff --git a/src/kadmin/v5server/ChangeLog b/src/kadmin/v5server/ChangeLog index d473bb02d..b3d4d93b7 100644 --- a/src/kadmin/v5server/ChangeLog +++ b/src/kadmin/v5server/ChangeLog @@ -1,4 +1,9 @@ +Tue Aug 15 14:28:03 EDT 1995 Paul Park (pjpark@mit.edu) + * kadm5_defs.h, admin.c, passwd.c, srv_key.c - Replace key_name_to_data + with krb5_dbe_find_keytype(). + + Thu Aug 10 14:34:31 EDT 1995 Paul Park (pjpark@mit.edu) * srv_key.c - Consolidate handling of tagged database attributes here in key_update_tl_attrs(). Fix a bug which was never encountered diff --git a/src/kadmin/v5server/admin.c b/src/kadmin/v5server/admin.c index 37f9cbca2..e8cb854cf 100644 --- a/src/kadmin/v5server/admin.c +++ b/src/kadmin/v5server/admin.c @@ -228,10 +228,18 @@ admin_merge_keys(kcontext, dbentp, unique, xxx2.n_key_data = nkeys2; xxx2.key_data = in2; for (i=0; ikey_data_kvno > kp1->key_data_kvno) kp1 = kp2; @@ -1189,7 +1197,12 @@ admin_keysalt_verify(kcontext, debug_level, dbentp, should_be_there, DPRINT(DEBUG_CALLS, debug_level, ("* admin_keysalt_verify()\n")); for (i=0; in_key_data; for (i=0; ikey_data_contents[0]) krb5_xfree(kdata->key_data_contents[0]); if (kdata->key_data_contents[1]) diff --git a/src/kadmin/v5server/kadm5_defs.h b/src/kadmin/v5server/kadm5_defs.h index 676a56cd7..b2bfbf9cf 100644 --- a/src/kadmin/v5server/kadm5_defs.h +++ b/src/kadmin/v5server/kadm5_defs.h @@ -141,10 +141,6 @@ krb5_keyblock *key_admin_key(); krb5_encrypt_block *key_master_encblock(); void key_free_key_data KRB5_PROTOTYPE((krb5_key_data *, krb5_int32)); -krb5_error_code key_name_to_data KRB5_PROTOTYPE((krb5_db_entry *, - krb5_key_salt_tuple *, - krb5_int32, - krb5_key_data **)); krb5_error_code key_dbent_to_keysalts KRB5_PROTOTYPE((krb5_db_entry *, krb5_int32 *, diff --git a/src/kadmin/v5server/passwd.c b/src/kadmin/v5server/passwd.c index 33bda1cdb..7686a2317 100644 --- a/src/kadmin/v5server/passwd.c +++ b/src/kadmin/v5server/passwd.c @@ -116,7 +116,6 @@ passwd_check_opass_ok(kcontext, debug_level, princ, dbentp, pwdata) krb5_boolean pwret; krb5_int32 num_keys, num_dkeys, tmpn; krb5_key_data *key_list, *dkey_list, *kent, *tmp; - krb5_key_salt_tuple keysalt; krb5_error_code kret; krb5_key_data *skey_list; krb5_int16 nskeys; @@ -161,9 +160,12 @@ passwd_check_opass_ok(kcontext, debug_level, princ, dbentp, pwdata) dbentp->key_data = dkey_list; dbentp->n_key_data = num_dkeys; for (i=0; ikey_data_length[0]) || memcmp(key_list[i].key_data_contents[0], kent->key_data_contents[0], diff --git a/src/kadmin/v5server/srv_key.c b/src/kadmin/v5server/srv_key.c index e5dd60f88..d38eed7c9 100644 --- a/src/kadmin/v5server/srv_key.c +++ b/src/kadmin/v5server/srv_key.c @@ -305,7 +305,6 @@ key_get_admin_entry(kcontext) } if (!kret && madmin_num_keys && madmin_keys) { - krb5_key_salt_tuple kstmp; krb5_key_data *kdata; krb5_db_entry xxx; @@ -314,9 +313,12 @@ key_get_admin_entry(kcontext) */ xxx.n_key_data = (krb5_int16) madmin_num_keys; xxx.key_data = madmin_keys; - kstmp.ks_keytype = KEYTYPE_DES; /* XXX - how to specify? */ - kstmp.ks_salttype = -1; - if (key_name_to_data(&xxx, &kstmp, -1, &kdata)) + if (krb5_dbe_find_keytype(kcontext, + &xxx, + KEYTYPE_DES, + -1, + -1, + &kdata)) kdata = &madmin_keys[0]; memset(&madmin_key, 0, sizeof(krb5_keyblock)); @@ -650,7 +652,12 @@ key_string2key_keysalt(ksent, ptr) */ salted = 0; krb5_use_keytype(argp->context, &master_encblock, ksent->ks_keytype); - if (!key_name_to_data(argp->dbentry, ksent, -1, &kdata)) { + if (!krb5_dbe_find_keytype(argp->context, + argp->dbentry, + ksent->ks_keytype, + ksent->ks_salttype, + -1, + &kdata)) { if (kdata->key_data_length[1] && kdata->key_data_contents[1]) salted = 1; } @@ -835,7 +842,12 @@ key_randomkey_keysalt(ksent, ptr) kret = 0; krb5_use_keytype(argp->context, &master_encblock, ksent->ks_keytype); - if (key_name_to_data(argp->dbentry, ksent, -1, &kdata)) { + if (krb5_dbe_find_keytype(argp->context, + argp->dbentry, + ksent->ks_keytype, + ksent->ks_salttype, + -1, + &kdata)) { /* * Cannot find a name-to-data matching, so we must have to create a * new key entry. @@ -1184,56 +1196,6 @@ key_free_key_data(keys, nkeys) } } -/* - * key_name_to_data() - Find the appropriate krb5_key_data entry for a - * given name. - * - * Name consists of key/salt tuple and a kvno. If the kvno is negative, then - * this routine returns the key_data entry with the highest kvno. Otherwise, - * it searches for an exact match. - */ -krb5_error_code -key_name_to_data(dbentp, ksent, kvno, kdatap) - krb5_db_entry *dbentp; - krb5_key_salt_tuple *ksent; - krb5_int32 kvno; - krb5_key_data **kdatap; -{ - /* - * XXX - this should probably be a dbe routine. - */ - 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] == ksent->ks_keytype) && - ((dbentp->key_data[i].key_data_type[1] == ksent->ks_salttype) || - (ksent->ks_salttype < 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]; - } - } - } - } - if (maxkvno >= 0) { - *kdatap = datap; - return(0); - } - return(ENOENT); -} - /* * key_dbent_to_keysalts() - Generate a list of key/salt pairs. */ -- 2.26.2