xref: /titanic_51/usr/src/lib/libgss/g_export_name.c (revision 8fd04b8338ed5093ec2d1e668fa620b7de44c177)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 /*
27  * glue routine gss_export_name
28  *
29  * Will either call the mechanism defined gss_export_name, or if one is
30  * not defined will call a generic_gss_export_name routine.
31  */
32 
33 #include <mechglueP.h>
34 #ifdef HAVE_STDLIB_H
35 #include <stdlib.h>
36 #endif
37 #include <string.h>
38 #include <errno.h>
39 
40 OM_uint32
41 gss_export_name(minor_status,
42 			input_name,
43 			exported_name)
44 OM_uint32 *		minor_status;
45 const gss_name_t	input_name;
46 gss_buffer_t		exported_name;
47 {
48 	gss_union_name_t		union_name;
49 
50 	/* Initialize outputs. */
51 
52 	if (minor_status != NULL)
53 		*minor_status = 0;
54 
55 	if (exported_name != GSS_C_NO_BUFFER) {
56 		exported_name->value = NULL;
57 		exported_name->length = 0;
58 	}
59 
60 	/* Validate arguments. */
61 
62 	if (minor_status == NULL || exported_name == GSS_C_NO_BUFFER)
63 		return (GSS_S_CALL_INACCESSIBLE_WRITE);
64 
65 	if (input_name == GSS_C_NO_NAME)
66 		return (GSS_S_CALL_INACCESSIBLE_READ | GSS_S_BAD_NAME);
67 
68 	union_name = (gss_union_name_t)input_name;
69 
70 	/* the name must be in mechanism specific format */
71 	if (!union_name->mech_type)
72 		return (GSS_S_NAME_NOT_MN);
73 
74 	return __gss_export_internal_name(minor_status, union_name->mech_type,
75 					union_name->mech_name, exported_name);
76 }
77