17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*503a2b89SPeter Shoults  * Common Development and Distribution License (the "License").
6*503a2b89SPeter Shoults  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
22*503a2b89SPeter Shoults  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
23*503a2b89SPeter Shoults  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate /*
277c478bd9Sstevel@tonic-gate  * glue routine gss_export_name
287c478bd9Sstevel@tonic-gate  *
297c478bd9Sstevel@tonic-gate  * Will either call the mechanism defined gss_export_name, or if one is
307c478bd9Sstevel@tonic-gate  * not defined will call a generic_gss_export_name routine.
317c478bd9Sstevel@tonic-gate  */
327c478bd9Sstevel@tonic-gate 
337c478bd9Sstevel@tonic-gate #include <mechglueP.h>
347c478bd9Sstevel@tonic-gate #ifdef HAVE_STDLIB_H
357c478bd9Sstevel@tonic-gate #include <stdlib.h>
367c478bd9Sstevel@tonic-gate #endif
377c478bd9Sstevel@tonic-gate #include <string.h>
387c478bd9Sstevel@tonic-gate #include <errno.h>
397c478bd9Sstevel@tonic-gate 
407c478bd9Sstevel@tonic-gate OM_uint32
gss_export_name(minor_status,input_name,exported_name)417c478bd9Sstevel@tonic-gate gss_export_name(minor_status,
427c478bd9Sstevel@tonic-gate 			input_name,
437c478bd9Sstevel@tonic-gate 			exported_name)
447c478bd9Sstevel@tonic-gate OM_uint32 *		minor_status;
457c478bd9Sstevel@tonic-gate const gss_name_t	input_name;
467c478bd9Sstevel@tonic-gate gss_buffer_t		exported_name;
477c478bd9Sstevel@tonic-gate {
487c478bd9Sstevel@tonic-gate 	gss_union_name_t		union_name;
497c478bd9Sstevel@tonic-gate 
50*503a2b89SPeter Shoults 	/* Initialize outputs. */
517c478bd9Sstevel@tonic-gate 
52*503a2b89SPeter Shoults 	if (minor_status != NULL)
537c478bd9Sstevel@tonic-gate 		*minor_status = 0;
547c478bd9Sstevel@tonic-gate 
55*503a2b89SPeter Shoults 	if (exported_name != GSS_C_NO_BUFFER) {
56*503a2b89SPeter Shoults 		exported_name->value = NULL;
57*503a2b89SPeter Shoults 		exported_name->length = 0;
58*503a2b89SPeter Shoults 	}
597c478bd9Sstevel@tonic-gate 
60*503a2b89SPeter Shoults 	/* Validate arguments. */
61*503a2b89SPeter Shoults 
62*503a2b89SPeter Shoults 	if (minor_status == NULL || exported_name == GSS_C_NO_BUFFER)
63*503a2b89SPeter Shoults 		return (GSS_S_CALL_INACCESSIBLE_WRITE);
647c478bd9Sstevel@tonic-gate 
65*503a2b89SPeter Shoults 	if (input_name == GSS_C_NO_NAME)
667c478bd9Sstevel@tonic-gate 		return (GSS_S_CALL_INACCESSIBLE_READ | GSS_S_BAD_NAME);
677c478bd9Sstevel@tonic-gate 
687c478bd9Sstevel@tonic-gate 	union_name = (gss_union_name_t)input_name;
697c478bd9Sstevel@tonic-gate 
707c478bd9Sstevel@tonic-gate 	/* the name must be in mechanism specific format */
717c478bd9Sstevel@tonic-gate 	if (!union_name->mech_type)
727c478bd9Sstevel@tonic-gate 		return (GSS_S_NAME_NOT_MN);
737c478bd9Sstevel@tonic-gate 
747c478bd9Sstevel@tonic-gate 	return __gss_export_internal_name(minor_status, union_name->mech_type,
757c478bd9Sstevel@tonic-gate 					union_name->mech_name, exported_name);
767c478bd9Sstevel@tonic-gate }
77