2N/A/*
2N/A * CDDL HEADER START
2N/A *
2N/A * The contents of this file are subject to the terms of the
2N/A * Common Development and Distribution License (the "License").
2N/A * You may not use this file except in compliance with the License.
2N/A *
2N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2N/A * or http://www.opensolaris.org/os/licensing.
2N/A * See the License for the specific language governing permissions
2N/A * and limitations under the License.
2N/A *
2N/A * When distributing Covered Code, include this CDDL HEADER in each
2N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2N/A * If applicable, add the following below this CDDL HEADER, with the
2N/A * fields enclosed by brackets "[]" replaced with your own identifying
2N/A * information: Portions Copyright [yyyy] [name of copyright owner]
2N/A *
2N/A * CDDL HEADER END
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
2N/Akrb5_error_code
2N/Akrb5_copy_kdc_req(krb5_context context, const krb5_kdc_req *in,
2N/A krb5_kdc_req **out)
2N/A{
2N/A krb5_kdc_req *req;
2N/A krb5_error_code code = 0;
2N/A
2N/A req = calloc(1, sizeof (krb5_kdc_req));
2N/A if (req == NULL)
2N/A return (ENOMEM);
2N/A
2N/A req->magic = in->magic;
2N/A req->msg_type = in->msg_type;
2N/A
2N/A if (in->padata != NULL) {
2N/A code = krb5_copy_pa_datas(context, in->padata, &req->padata);
2N/A if (code != 0)
2N/A goto out;
2N/A }
2N/A
2N/A req->kdc_options = in->kdc_options;
2N/A
2N/A if (in->client != NULL) {
2N/A code = krb5_copy_principal(context, in->client, &req->client);
2N/A if (code != 0)
2N/A goto out;
2N/A }
2N/A
2N/A if (in->server != NULL) {
2N/A code = krb5_copy_principal(context, in->server, &req->server);
2N/A if (code != 0)
2N/A goto out;
2N/A }
2N/A
2N/A req->from = in->from;
2N/A req->till = in->till;
2N/A req->rtime = in->rtime;
2N/A
2N/A req->nonce = in->nonce;
2N/A
2N/A if (in->nktypes != 0) {
2N/A req->ktype = calloc(in->nktypes, sizeof (krb5_enctype));
2N/A if (req->ktype == NULL) {
2N/A code = ENOMEM;
2N/A goto out;
2N/A }
2N/A memcpy(req->ktype, in->ktype,
2N/A in->nktypes * sizeof (krb5_enctype));
2N/A req->nktypes = in->nktypes;
2N/A }
2N/A
2N/A if (in->addresses != NULL) {
2N/A code = krb5_copy_addresses(context, in->addresses,
2N/A &req->addresses);
2N/A if (code != 0)
2N/A goto out;
2N/A }
2N/A
2N/A req->authorization_data.magic = in->authorization_data.magic;
2N/A req->authorization_data.enctype = in->authorization_data.enctype;
2N/A req->authorization_data.kvno = in->authorization_data.kvno;
2N/A if (in->authorization_data.ciphertext.data != NULL) {
2N/A code = krb5int_copy_data_contents(context,
2N/A &in->authorization_data.ciphertext,
2N/A &req->authorization_data.ciphertext);
2N/A if (code != 0)
2N/A goto out;
2N/A }
2N/A
2N/A if (in->unenc_authdata != NULL) {
2N/A code = krb5_copy_authdata(context, in->unenc_authdata,
2N/A &req->unenc_authdata);
2N/A if (code != 0)
2N/A goto out;
2N/A }
2N/A
2N/A if (in->second_ticket != NULL) {
2N/A code = krb5_copy_tickets(context, in->second_ticket,
2N/A &req->second_ticket);
2N/A if (code != 0)
2N/A goto out;
2N/A }
2N/A
2N/A req->kdc_state = in->kdc_state;
2N/A
2N/Aout:
2N/A if (code != 0)
2N/A krb5_free_kdc_req(context, req);
2N/A else
2N/A *out = req;
2N/A
2N/A return (code);
2N/A}