xref: /onnv-gate/usr/src/lib/libgss/g_export_name.c (revision 9698:357f1a679fc4)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*9698SPeter.Shoults@Sun.COM  * Common Development and Distribution License (the "License").
6*9698SPeter.Shoults@Sun.COM  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*
22*9698SPeter.Shoults@Sun.COM  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
23*9698SPeter.Shoults@Sun.COM  * Use is subject to license terms.
240Sstevel@tonic-gate  */
250Sstevel@tonic-gate 
260Sstevel@tonic-gate /*
270Sstevel@tonic-gate  * glue routine gss_export_name
280Sstevel@tonic-gate  *
290Sstevel@tonic-gate  * Will either call the mechanism defined gss_export_name, or if one is
300Sstevel@tonic-gate  * not defined will call a generic_gss_export_name routine.
310Sstevel@tonic-gate  */
320Sstevel@tonic-gate 
330Sstevel@tonic-gate #include <mechglueP.h>
340Sstevel@tonic-gate #ifdef HAVE_STDLIB_H
350Sstevel@tonic-gate #include <stdlib.h>
360Sstevel@tonic-gate #endif
370Sstevel@tonic-gate #include <string.h>
380Sstevel@tonic-gate #include <errno.h>
390Sstevel@tonic-gate 
400Sstevel@tonic-gate OM_uint32
gss_export_name(minor_status,input_name,exported_name)410Sstevel@tonic-gate gss_export_name(minor_status,
420Sstevel@tonic-gate 			input_name,
430Sstevel@tonic-gate 			exported_name)
440Sstevel@tonic-gate OM_uint32 *		minor_status;
450Sstevel@tonic-gate const gss_name_t	input_name;
460Sstevel@tonic-gate gss_buffer_t		exported_name;
470Sstevel@tonic-gate {
480Sstevel@tonic-gate 	gss_union_name_t		union_name;
490Sstevel@tonic-gate 
50*9698SPeter.Shoults@Sun.COM 	/* Initialize outputs. */
510Sstevel@tonic-gate 
52*9698SPeter.Shoults@Sun.COM 	if (minor_status != NULL)
530Sstevel@tonic-gate 		*minor_status = 0;
540Sstevel@tonic-gate 
55*9698SPeter.Shoults@Sun.COM 	if (exported_name != GSS_C_NO_BUFFER) {
56*9698SPeter.Shoults@Sun.COM 		exported_name->value = NULL;
57*9698SPeter.Shoults@Sun.COM 		exported_name->length = 0;
58*9698SPeter.Shoults@Sun.COM 	}
59*9698SPeter.Shoults@Sun.COM 
60*9698SPeter.Shoults@Sun.COM 	/* Validate arguments. */
61*9698SPeter.Shoults@Sun.COM 
62*9698SPeter.Shoults@Sun.COM 	if (minor_status == NULL || exported_name == GSS_C_NO_BUFFER)
630Sstevel@tonic-gate 		return (GSS_S_CALL_INACCESSIBLE_WRITE);
640Sstevel@tonic-gate 
65*9698SPeter.Shoults@Sun.COM 	if (input_name == GSS_C_NO_NAME)
660Sstevel@tonic-gate 		return (GSS_S_CALL_INACCESSIBLE_READ | GSS_S_BAD_NAME);
670Sstevel@tonic-gate 
680Sstevel@tonic-gate 	union_name = (gss_union_name_t)input_name;
690Sstevel@tonic-gate 
700Sstevel@tonic-gate 	/* the name must be in mechanism specific format */
710Sstevel@tonic-gate 	if (!union_name->mech_type)
720Sstevel@tonic-gate 		return (GSS_S_NAME_NOT_MN);
730Sstevel@tonic-gate 
740Sstevel@tonic-gate 	return __gss_export_internal_name(minor_status, union_name->mech_type,
750Sstevel@tonic-gate 					union_name->mech_name, exported_name);
760Sstevel@tonic-gate }
77