2 * lib/krb5/krb/kdc_rep_dc.c
4 * Copyright 1990 by the Massachusetts Institute of Technology.
7 * Export of this software from the United States of America may
8 * require a specific license from the United States Government.
9 * It is the responsibility of any person or organization contemplating
10 * export to obtain such a license before exporting.
12 * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
13 * distribute this software and its documentation for any purpose and
14 * without fee is hereby granted, provided that the above copyright
15 * notice appear in all copies and that both that copyright notice and
16 * this permission notice appear in supporting documentation, and that
17 * the name of M.I.T. not be used in advertising or publicity pertaining
18 * to distribution of the software without specific, written prior
19 * permission. M.I.T. makes no representations about the suitability of
20 * this software for any purpose. It is provided "as is" without express
21 * or implied warranty.
24 * krb5_kdc_rep_decrypt_proc()
30 * Decrypt the encrypted portion of the KDC_REP message, using the key
36 krb5_error_code INTERFACE
37 krb5_kdc_rep_decrypt_proc(context, key, decryptarg, dec_rep)
39 const krb5_keyblock * key;
40 krb5_const_pointer decryptarg;
41 krb5_kdc_rep * dec_rep;
43 krb5_error_code retval;
44 krb5_encrypt_block eblock;
46 krb5_enc_kdc_rep_part *local_encpart;
48 if (!valid_etype(dec_rep->enc_part.etype))
49 return KRB5_PROG_ETYPE_NOSUPP;
51 /* set up scratch decrypt/decode area */
53 scratch.length = dec_rep->enc_part.ciphertext.length;
54 if (!(scratch.data = malloc(dec_rep->enc_part.ciphertext.length))) {
58 /* put together an eblock for this encryption */
60 krb5_use_cstype(context, &eblock, dec_rep->enc_part.etype);
62 /* do any necessary key pre-processing */
63 if (retval = krb5_process_key(context, &eblock, key)) {
68 /* call the decryption routine */
69 if (retval = krb5_decrypt(context, (krb5_pointer) dec_rep->enc_part.ciphertext.data,
70 (krb5_pointer) scratch.data,
71 scratch.length, &eblock, 0)) {
72 (void) krb5_finish_key(context, &eblock);
76 #define clean_scratch() {memset(scratch.data, 0, scratch.length); \
78 if (retval = krb5_finish_key(context, &eblock)) {
83 /* and do the decode */
84 retval = decode_krb5_enc_kdc_rep_part(&scratch, &local_encpart);
89 dec_rep->enc_part2 = local_encpart;