From 6761a0be6fb8e64f7c7e7ba5d7c0fc756f176a54 Mon Sep 17 00:00:00 2001 From: Richard Basch Date: Mon, 6 May 1996 16:25:53 +0000 Subject: [PATCH] Fixed the abstraction violation, where the code knew the details about the cryptosystem structure. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@7907 dc483132-0cff-0310-8789-dd5450dbe970 --- src/kdc/ChangeLog | 5 +++++ src/kdc/main.c | 22 ++++++++++------------ src/tests/create/ChangeLog | 5 +++++ src/tests/create/kdb5_mkdums.c | 21 +++++++++------------ src/tests/verify/ChangeLog | 5 +++++ src/tests/verify/kdb5_verify.c | 21 +++++++++------------ 6 files changed, 43 insertions(+), 36 deletions(-) diff --git a/src/kdc/ChangeLog b/src/kdc/ChangeLog index ec59d747a..4e0096aa1 100644 --- a/src/kdc/ChangeLog +++ b/src/kdc/ChangeLog @@ -1,3 +1,8 @@ +Mon May 6 12:15:36 1996 Richard Basch + + * main.c: Fixed various abstraction violations where the code knew + the internals of eblock->crypto_entry. + Wed Feb 28 13:07:28 1996 Ezra Peisach * main.c: Move com_err.h after k5-int.h include. diff --git a/src/kdc/main.c b/src/kdc/main.c index bd4aba9d2..443acecb5 100644 --- a/src/kdc/main.c +++ b/src/kdc/main.c @@ -619,9 +619,9 @@ goto whoops; } if (!rkey_init_done) { krb5_enctype enctype; + krb5_encrypt_block temp_eblock; #ifdef KRB5_KRB4_COMPAT krb5_keyblock *temp_key; - krb5_encrypt_block temp_eblock; #endif /* * If all that worked, then initialize the random key @@ -630,10 +630,11 @@ goto whoops; for (enctype = 0; enctype <= krb5_max_enctype; enctype++) { if (krb5_enctype_array[enctype] && !krb5_enctype_array[enctype]->random_sequence) { - if ((kret = (*krb5_enctype_array[enctype]->system-> - init_random_key) - (&rdp->realm_mkey, - &krb5_enctype_array[enctype]->random_sequence))) { + krb5_use_enctype(rdp->realm_context, &temp_eblock, enctype); + if ((kret = krb5_init_random_key( + rdp->realm_context, &temp_eblock, + &rdp->realm_mkey, + &krb5_enctype_array[enctype]->random_sequence))) { com_err(progname, kret, "while setting up random key generator for enctype %d--enctype disabled", enctype); @@ -641,13 +642,10 @@ goto whoops; } else { #ifdef KRB5_KRB4_COMPAT if (enctype == ENCTYPE_DES_CBC_CRC) { - krb5_use_enctype(rdp->realm_context, - &temp_eblock, enctype); - if ((kret = (*krb5_enctype_array[enctype]-> - system->random_key) - (&temp_eblock, - krb5_enctype_array[enctype]->random_sequence, - &temp_key))) + if ((kret = krb5_random_key( + rdp->realm_context, &temp_eblock, + krb5_enctype_array[enctype]->random_sequence, + &temp_key))) com_err(progname, kret, "while initializing V4 random key generator"); else { diff --git a/src/tests/create/ChangeLog b/src/tests/create/ChangeLog index 847f83a41..2d7720c07 100644 --- a/src/tests/create/ChangeLog +++ b/src/tests/create/ChangeLog @@ -1,3 +1,8 @@ +Thu May 2 21:17:27 1996 Richard Basch + + * kdb5_mkdums.c: fixed various abstraction violations where the + code "knew" the cryptosystem_entry structure + Sat Dec 23 01:04:40 1995 * configure.in: Add check for DBM/db libraries diff --git a/src/tests/create/kdb5_mkdums.c b/src/tests/create/kdb5_mkdums.c index 52ee8f290..df11ddb24 100644 --- a/src/tests/create/kdb5_mkdums.c +++ b/src/tests/create/kdb5_mkdums.c @@ -102,7 +102,6 @@ char *argv[]; krb5_error_code retval; char *dbname = 0; int enctypedone = 0; - register krb5_cryptosystem_entry *csentry; extern krb5_kt_ops krb5_ktf_writable_ops; int num_to_create; char principal_string[BUFSIZ]; @@ -178,7 +177,6 @@ char *argv[]; } krb5_use_enctype(test_context, &master_encblock, master_keyblock.enctype); - csentry = master_encblock.crypto_entry; if (!dbname) dbname = DEFAULT_KDB_FILE; /* XXX? */ @@ -210,8 +208,9 @@ char *argv[]; } } - (void) (*csentry->finish_key)(&master_encblock); - (void) (*csentry->finish_random_key)(&master_random); + krb5_finish_random_key(test_context, &master_encblock, &master_random); + krb5_finish_key(test_context, &master_encblock); + retval = krb5_db_fini(test_context); memset((char *)master_keyblock.contents, 0, master_keyblock.length); if (retval && retval != KRB5_KDB_DBNOTINITED) { @@ -333,11 +332,8 @@ char *dbname; krb5_error_code retval; int nentries; krb5_boolean more; - register krb5_cryptosystem_entry *csentry; krb5_data pwd, scratch; - csentry = master_encblock.crypto_entry; - if (retval = krb5_db_set_name(test_context, dbname)) { com_err(pname, retval, "while setting active database to '%s'", dbname); @@ -400,16 +396,17 @@ char *dbname; return(1); } - if (retval = (*csentry->process_key)(&master_encblock, - &master_keyblock)) { + if (retval = krb5_process_key(test_context, + &master_encblock, &master_keyblock)) { com_err(pname, retval, "while processing master key"); (void) krb5_db_fini(test_context); return(1); } - if (retval = (*csentry->init_random_key)(&master_keyblock, - &master_random)) { + if (retval = krb5_init_random_key(test_context, + &master_encblock, &master_keyblock, + &master_random)) { com_err(pname, retval, "while initializing random key generator"); - (void) (*csentry->finish_key)(&master_encblock); + krb5_finish_key(test_context, &master_encblock); (void) krb5_db_fini(test_context); return(1); } diff --git a/src/tests/verify/ChangeLog b/src/tests/verify/ChangeLog index eeafcf245..96182d999 100644 --- a/src/tests/verify/ChangeLog +++ b/src/tests/verify/ChangeLog @@ -1,3 +1,8 @@ +Thu May 2 21:16:40 1996 Richard Basch + + * kdb5_verify.c: fixed various abstraction violations where the + code "knew" the cryptosystem_entry structure + Sat Dec 23 01:05:33 1995 * configure.in (withval): Add check for DBM/db libraries. diff --git a/src/tests/verify/kdb5_verify.c b/src/tests/verify/kdb5_verify.c index 1684ea5ba..fed870a7e 100644 --- a/src/tests/verify/kdb5_verify.c +++ b/src/tests/verify/kdb5_verify.c @@ -103,7 +103,6 @@ char *argv[]; krb5_error_code retval; char *dbname = 0; int enctypedone = 0; - register krb5_cryptosystem_entry *csentry; int num_to_check; char principal_string[BUFSIZ]; char *suffix = 0; @@ -171,7 +170,6 @@ char *argv[]; } krb5_use_enctype(context, &master_encblock, master_keyblock.enctype); - csentry = master_encblock.crypto_entry; if (!dbname) dbname = DEFAULT_KDB_FILE; /* XXX? */ @@ -212,8 +210,9 @@ char *argv[]; else fprintf(stdout, "\nNo errors.\n"); - (void) (*csentry->finish_key)(&master_encblock); - (void) (*csentry->finish_random_key)(&master_random); + krb5_finish_random_key(context, &master_encblock, &master_random); + krb5_finish_key(context, &master_encblock); + retval = krb5_db_fini(context); memset((char *)master_keyblock.contents, 0, master_keyblock.length); if (retval && retval != KRB5_KDB_DBNOTINITED) { @@ -357,11 +356,8 @@ set_dbname_help(context, pname, dbname) krb5_error_code retval; int nentries; krb5_boolean more; - register krb5_cryptosystem_entry *csentry; krb5_data pwd, scratch; - csentry = master_encblock.crypto_entry; - if (retval = krb5_db_set_name(context, dbname)) { com_err(pname, retval, "while setting active database to '%s'", dbname); @@ -430,16 +426,17 @@ set_dbname_help(context, pname, dbname) return(1); } - if (retval = (*csentry->process_key)(&master_encblock, - &master_keyblock)) { + if (retval = krb5_process_key(context, + &master_encblock, &master_keyblock)) { com_err(pname, retval, "while processing master key"); (void) krb5_db_fini(context); return(1); } - if (retval = (*csentry->init_random_key)(&master_keyblock, - &master_random)) { + if (retval = krb5_init_random_key(context, + &master_encblock, &master_keyblock, + &master_random)) { com_err(pname, retval, "while initializing random key generator"); - (void) (*csentry->finish_key)(&master_encblock); + krb5_finish_key(context, &master_encblock); (void) krb5_db_fini(context); return(1); } -- 2.26.2