2N/A/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2N/A/*
2N/A * lib/krb5/krb/decode_kdc.c
2N/A *
2N/A * Copyright 1990 by the Massachusetts Institute of Technology.
2N/A * All Rights Reserved.
2N/A *
2N/A * Export of this software from the United States of America may
2N/A * require a specific license from the United States Government.
2N/A * It is the responsibility of any person or organization contemplating
2N/A * export to obtain such a license before exporting.
2N/A *
2N/A * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
2N/A * distribute this software and its documentation for any purpose and
2N/A * without fee is hereby granted, provided that the above copyright
2N/A * notice appear in all copies and that both that copyright notice and
2N/A * this permission notice appear in supporting documentation, and that
2N/A * the name of M.I.T. not be used in advertising or publicity pertaining
2N/A * to distribution of the software without specific, written prior
2N/A * permission. Furthermore if you modify this software you must label
2N/A * your software as modified software and not distribute it in such a
2N/A * fashion that it might be confused with the original M.I.T. software.
2N/A * M.I.T. makes no representations about the suitability of
2N/A * this software for any purpose. It is provided "as is" without express
2N/A * or implied warranty.
2N/A *
2N/A *
2N/A * krb5_decode_kdc_rep() function.
2N/A */
2N/A
2N/A/*
2N/A * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
2N/A */
2N/A
2N/A#include "k5-int.h"
2N/A#include "int-proto.h"
2N/A/* Solaris Kerberos */
2N/A#include "kerberos_dtrace.h"
2N/A
2N/A/*
2N/A Takes a KDC_REP message and decrypts encrypted part using etype and
2N/A *key, putting result in *rep.
2N/A dec_rep->client,ticket,session,last_req,server,caddrs
2N/A are all set to allocated storage which should be freed by the caller
2N/A when finished with the response.
2N/A
2N/A If the response isn't a KDC_REP (tgs or as), it returns an error from
2N/A the decoding routines.
2N/A
2N/A returns errors from encryption routines, system errors
2N/A*/
2N/A
2N/Akrb5_error_code
2N/Akrb5int_decode_tgs_rep(krb5_context context, krb5_data *enc_rep, const krb5_keyblock *key,
2N/A krb5_keyusage usage, krb5_kdc_rep **dec_rep)
2N/A{
2N/A krb5_error_code retval;
2N/A krb5_kdc_rep *local_dec_rep;
2N/A
2N/A if (krb5_is_as_rep(enc_rep)) {
2N/A retval = decode_krb5_as_rep(enc_rep, &local_dec_rep);
2N/A } else if (krb5_is_tgs_rep(enc_rep)) {
2N/A retval = decode_krb5_tgs_rep(enc_rep, &local_dec_rep);
2N/A } else {
2N/A return KRB5KRB_AP_ERR_MSG_TYPE;
2N/A }
2N/A
2N/A if (retval) {
2N/A /* Solaris Kerberos: for dtrace */
2N/A k5_trace_kdc_rep_read(enc_rep, NULL);
2N/A return retval;
2N/A }
2N/A
2N/A if ((retval = krb5_kdc_rep_decrypt_proc(context, key, &usage,
2N/A local_dec_rep)))
2N/A krb5_free_kdc_rep(context, local_dec_rep);
2N/A else
2N/A *dec_rep = local_dec_rep;
2N/A
2N/A /* Solaris Kerberos: for dtrace */
2N/A k5_trace_kdc_rep_read(enc_rep, retval == 0 ? *dec_rep : NULL);
2N/A
2N/A return(retval);
2N/A}