From: John Kohl Date: Wed, 7 Feb 1990 17:49:23 +0000 (+0000) Subject: move decrypt out to separate function X-Git-Tag: krb5-1.0-alpha2~1070 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=6628a5fd5f603491b9cf7a64cbcd5e1e2e3df20f;p=krb5.git move decrypt out to separate function git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@314 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/lib/krb5/krb/decode_kdc.c b/src/lib/krb5/krb/decode_kdc.c index 6281e86be..8c26e4cc6 100644 --- a/src/lib/krb5/krb/decode_kdc.c +++ b/src/lib/krb5/krb/decode_kdc.c @@ -48,9 +48,6 @@ krb5_kdc_rep **dec_rep; { krb5_error_code retval; krb5_kdc_rep *local_dec_rep; - krb5_encrypt_block eblock; - krb5_data scratch; - krb5_enc_kdc_rep_part *local_encpart; /* XXX maybe caller should specify type expected? */ @@ -69,50 +66,14 @@ krb5_kdc_rep **dec_rep; default: return (retval); } - scratch.length = local_dec_rep->enc_part.length; - if (!(scratch.data = malloc(local_dec_rep->enc_part.length))) { - krb5_free_kdc_rep(local_dec_rep); - return(ENOMEM); - } - - if (!valid_etype(etype)) - return KRB5KDC_ERR_ETYPE_NOSUPP; - - /* put together an eblock for this encryption */ - - eblock.crypto_entry = krb5_csarray[etype]->system; - - /* do any necessary key pre-processing */ - if (retval = (*eblock.crypto_entry->process_key)(&eblock, key)) { - krb5_free_kdc_rep(local_dec_rep); - free(scratch.data); - return(retval); - } - /* call the encryption routine */ - if (retval = - (*eblock.crypto_entry->decrypt_func)((krb5_pointer) local_dec_rep->enc_part.data, - (krb5_pointer) scratch.data, - scratch.length, &eblock)) { - (void) (*eblock.crypto_entry->finish_key)(&eblock); - krb5_free_kdc_rep(local_dec_rep); - free(scratch.data); - return retval; + if (local_dec_rep->etype != etype) { + return KRB5KDC_ERR_ETYPE_NOSUPP; /* XXX */ } -#define clean_scratch() {bzero(scratch.data, scratch.length); free(scratch.data);} - if (retval = (*eblock.crypto_entry->finish_key)(&eblock)) { + if (retval = krb5_kdc_rep_decrypt_proc(local_dec_rep, key, 0)) { krb5_free_kdc_rep(local_dec_rep); - clean_scratch(); - return retval; - } - if (retval = decode_krb5_enc_kdc_rep_part(&scratch, &local_encpart)) { - krb5_free_kdc_rep(local_dec_rep); - clean_scratch(); - return retval; + return(retval); } - clean_scratch(); - - local_dec_rep->enc_part2 = local_encpart; *dec_rep = local_dec_rep; return 0; }