move decrypt out to separate function
authorJohn Kohl <jtkohl@mit.edu>
Wed, 7 Feb 1990 17:49:23 +0000 (17:49 +0000)
committerJohn Kohl <jtkohl@mit.edu>
Wed, 7 Feb 1990 17:49:23 +0000 (17:49 +0000)
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@314 dc483132-0cff-0310-8789-dd5450dbe970

src/lib/krb5/krb/decode_kdc.c

index 6281e86bebb19f47cb8f42b66b25e486b85208ab..8c26e4cc682f15505ded0b244dd5123c7fcf03a0 100644 (file)
@@ -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;
 }