5 * Copyright 1990 by the Massachusetts Institute of Technology.
7 * For copying and distribution information, please see the file
8 * <krb5/mit-copyright.h>.
10 * krb5_decode_kdc_rep() function.
13 #if !defined(lint) && !defined(SABER)
14 static char rcsid_decode_kdc_c[] =
16 #endif /* !lint & !SABER */
18 #include <krb5/copyright.h>
20 #include <krb5/krb5.h>
21 #include <krb5/krb5_err.h>
22 #include <krb5/isode_err.h>
23 #include <krb5/asn1.h>
27 #include <krb5/ext-proto.h>
30 Takes a KDC_REP message and decrypts encrypted part using etype and
31 *key, putting result in *rep.
32 dec_rep->client,ticket,session.last_req,server,caddrs
33 are all set to allocated storage which should be freed by the caller
34 when finished with the response.
36 If the response isn't a KDC_REP (tgs or as), it returns an error from
37 the decoding routines (usually ISODE_50_LOCAL_ERR_BADDECODE).
39 returns errors from encryption routines, system errors
43 krb5_decode_kdc_rep(DECLARG(krb5_data *, enc_rep),
44 DECLARG(krb5_keyblock *, key),
45 DECLARG(krb5_enctype, etype),
46 DECLARG(krb5_kdc_rep **, dec_rep))
47 OLDDECLARG(krb5_data *, enc_rep)
48 OLDDECLARG(krb5_keyblock *, key)
49 OLDDECLARG(krb5_enctype, etype)
50 OLDDECLARG(krb5_kdc_rep **, dec_rep)
52 krb5_error_code retval;
53 krb5_kdc_rep *local_dec_rep;
56 /* XXX maybe caller should specify type expected? */
57 retval = decode_krb5_as_rep(enc_rep, &local_dec_rep);
59 case ISODE_50_LOCAL_ERR_BADMSGTYPE:
60 retval = decode_krb5_tgs_rep(enc_rep, &local_dec_rep);
73 if (local_dec_rep->etype != etype) {
74 return KRB5KDC_ERR_ETYPE_NOSUPP; /* XXX */
76 if (retval = krb5_kdc_rep_decrypt_proc(key, 0, local_dec_rep)) {
77 krb5_free_kdc_rep(local_dec_rep);
80 *dec_rep = local_dec_rep;