build_ap_req.c revision 103423
175584Sru/* 275584Sru * Copyright (c) 1997 - 2002 Kungliga Tekniska H�gskolan 375584Sru * (Royal Institute of Technology, Stockholm, Sweden). 4104862Sru * All rights reserved. 575584Sru * 675584Sru * Redistribution and use in source and binary forms, with or without 775584Sru * modification, are permitted provided that the following conditions 875584Sru * are met: 975584Sru * 1075584Sru * 1. Redistributions of source code must retain the above copyright 1175584Sru * notice, this list of conditions and the following disclaimer. 1275584Sru * 1375584Sru * 2. Redistributions in binary form must reproduce the above copyright 1475584Sru * notice, this list of conditions and the following disclaimer in the 15104862Sru * documentation and/or other materials provided with the distribution. 1675584Sru * 1775584Sru * 3. Neither the name of the Institute nor the names of its contributors 1875584Sru * may be used to endorse or promote products derived from this software 1975584Sru * without specific prior written permission. 2075584Sru * 2175584Sru * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 2275584Sru * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2375584Sru * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2475584Sru * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 2575584Sru * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2675584Sru * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2775584Sru * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2875584Sru * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2975584Sru * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3075584Sru * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3175584Sru * SUCH DAMAGE. 3275584Sru */ 3375584Sru 3475584Sru#include <krb5_locl.h> 3575584Sru 3675584SruRCSID("$Id: build_ap_req.c,v 1.18 2002/09/04 16:26:04 joda Exp $"); 3775584Sru 3875584Srukrb5_error_code 3975584Srukrb5_build_ap_req (krb5_context context, 4075584Sru krb5_enctype enctype, 4175584Sru krb5_creds *cred, 4275584Sru krb5_flags ap_options, 4375584Sru krb5_data authenticator, 4475584Sru krb5_data *retdata) 4575584Sru{ 4675584Sru krb5_error_code ret = 0; 4775584Sru AP_REQ ap; 4875584Sru Ticket t; 4975584Sru size_t len; 5075584Sru 5175584Sru ap.pvno = 5; 5275584Sru ap.msg_type = krb_ap_req; 5375584Sru memset(&ap.ap_options, 0, sizeof(ap.ap_options)); 5475584Sru ap.ap_options.use_session_key = (ap_options & AP_OPTS_USE_SESSION_KEY) > 0; 5575584Sru ap.ap_options.mutual_required = (ap_options & AP_OPTS_MUTUAL_REQUIRED) > 0; 5675584Sru 5775584Sru ap.ticket.tkt_vno = 5; 5875584Sru copy_Realm(&cred->server->realm, &ap.ticket.realm); 5975584Sru copy_PrincipalName(&cred->server->name, &ap.ticket.sname); 6075584Sru 6175584Sru decode_Ticket(cred->ticket.data, cred->ticket.length, &t, &len); 6275584Sru copy_EncryptedData(&t.enc_part, &ap.ticket.enc_part); 6375584Sru free_Ticket(&t); 6475584Sru 6575584Sru ap.authenticator.etype = enctype; 6675584Sru ap.authenticator.kvno = NULL; 6775584Sru ap.authenticator.cipher = authenticator; 6875584Sru 6975584Sru ASN1_MALLOC_ENCODE(AP_REQ, retdata->data, retdata->length, 7075584Sru &ap, &len, ret); 7175584Sru 7275584Sru free_AP_REQ(&ap); 7375584Sru return ret; 7475584Sru 7575584Sru} 7675584Sru