xref: /onnv-gate/usr/src/lib/gss_mechs/mech_dh/backend/mech/dhmech.c (revision 0:68f95e015346)
1*0Sstevel@tonic-gate /*
2*0Sstevel@tonic-gate  * CDDL HEADER START
3*0Sstevel@tonic-gate  *
4*0Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*0Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*0Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*0Sstevel@tonic-gate  * with the License.
8*0Sstevel@tonic-gate  *
9*0Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*0Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*0Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*0Sstevel@tonic-gate  * and limitations under the License.
13*0Sstevel@tonic-gate  *
14*0Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*0Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*0Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*0Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*0Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*0Sstevel@tonic-gate  *
20*0Sstevel@tonic-gate  * CDDL HEADER END
21*0Sstevel@tonic-gate  */
22*0Sstevel@tonic-gate /*
23*0Sstevel@tonic-gate  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24*0Sstevel@tonic-gate  * Use is subject to license terms.
25*0Sstevel@tonic-gate  */
26*0Sstevel@tonic-gate 
27*0Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
28*0Sstevel@tonic-gate 
29*0Sstevel@tonic-gate #include "dh_gssapi.h"
30*0Sstevel@tonic-gate #include <stdlib.h>
31*0Sstevel@tonic-gate 
32*0Sstevel@tonic-gate /*
33*0Sstevel@tonic-gate  * gss_config structure for Diffie-Hellman family of mechanisms.
34*0Sstevel@tonic-gate  * This structure is defined in mechglueP.h and defines the entry points
35*0Sstevel@tonic-gate  * that libgss uses to call a backend.
36*0Sstevel@tonic-gate  */
37*0Sstevel@tonic-gate static struct gss_config dh_mechanism = {
38*0Sstevel@tonic-gate 	{0, 0},				/* OID for mech type. */
39*0Sstevel@tonic-gate 	0,
40*0Sstevel@tonic-gate 	__dh_gss_acquire_cred,
41*0Sstevel@tonic-gate 	__dh_gss_release_cred,
42*0Sstevel@tonic-gate 	__dh_gss_init_sec_context,
43*0Sstevel@tonic-gate 	__dh_gss_accept_sec_context,
44*0Sstevel@tonic-gate /* EXPORT DELETE START */ /* CRYPT DELETE START */
45*0Sstevel@tonic-gate 	__dh_gss_unseal,
46*0Sstevel@tonic-gate /* EXPORT DELETE END */ /* CRYPT DELETE END */
47*0Sstevel@tonic-gate 	__dh_gss_process_context_token,
48*0Sstevel@tonic-gate 	__dh_gss_delete_sec_context,
49*0Sstevel@tonic-gate 	__dh_gss_context_time,
50*0Sstevel@tonic-gate 	__dh_gss_display_status,
51*0Sstevel@tonic-gate 	NULL, /* Back ends don't implement this */
52*0Sstevel@tonic-gate 	__dh_gss_compare_name,
53*0Sstevel@tonic-gate 	__dh_gss_display_name,
54*0Sstevel@tonic-gate 	__dh_gss_import_name,
55*0Sstevel@tonic-gate 	__dh_gss_release_name,
56*0Sstevel@tonic-gate 	__dh_gss_inquire_cred,
57*0Sstevel@tonic-gate 	NULL, /* Back ends don't implement this */
58*0Sstevel@tonic-gate /* EXPORT DELETE START */ /* CRYPT DELETE START */
59*0Sstevel@tonic-gate 	__dh_gss_seal,
60*0Sstevel@tonic-gate /* EXPORT DELETE END */ /* CRYPT DELETE END */
61*0Sstevel@tonic-gate 	__dh_gss_export_sec_context,
62*0Sstevel@tonic-gate 	__dh_gss_import_sec_context,
63*0Sstevel@tonic-gate 	__dh_gss_inquire_cred_by_mech,
64*0Sstevel@tonic-gate 	__dh_gss_inquire_names_for_mech,
65*0Sstevel@tonic-gate 	__dh_gss_inquire_context,
66*0Sstevel@tonic-gate 	__dh_gss_internal_release_oid,
67*0Sstevel@tonic-gate 	__dh_gss_wrap_size_limit,
68*0Sstevel@tonic-gate 	__dh_pname_to_uid,
69*0Sstevel@tonic-gate 	NULL,  /* __gss_userok */
70*0Sstevel@tonic-gate 	__dh_gss_export_name,
71*0Sstevel@tonic-gate /* EXPORT DELETE START */
72*0Sstevel@tonic-gate /* CRYPT DELETE START */
73*0Sstevel@tonic-gate /*
74*0Sstevel@tonic-gate  * This block comment is Sun Proprietary: Need-To-Know.
75*0Sstevel@tonic-gate  * What we are doing is leaving the seal and unseal entry points
76*0Sstevel@tonic-gate  * in an obvious place before sign and unsign for the Domestic customer
77*0Sstevel@tonic-gate  * of the Solaris Source Product. The Domestic customer of the Solaris Source
78*0Sstevel@tonic-gate  * Product will have to deal with the problem of creating exportable libgss
79*0Sstevel@tonic-gate  * binaries.
80*0Sstevel@tonic-gate  * In the binary product that Sun builds, these entry points are elsewhere,
81*0Sstevel@tonic-gate  * and bracketed with special comments so that the CRYPT_SRC and EXPORT_SRC
82*0Sstevel@tonic-gate  * targets delete them.
83*0Sstevel@tonic-gate  */
84*0Sstevel@tonic-gate #if 0
85*0Sstevel@tonic-gate /* CRYPT DELETE END */
86*0Sstevel@tonic-gate 	__dh_gss_seal,
87*0Sstevel@tonic-gate 	__dh_gss_unseal,
88*0Sstevel@tonic-gate /* CRYPT DELETE START */
89*0Sstevel@tonic-gate #endif /* 0 */
90*0Sstevel@tonic-gate /* CRYPT DELETE END */
91*0Sstevel@tonic-gate /* EXPORT DELETE END */
92*0Sstevel@tonic-gate 	__dh_gss_sign,
93*0Sstevel@tonic-gate 	__dh_gss_verify,
94*0Sstevel@tonic-gate 	NULL, /* gss_store_cred() -- DH lacks this for now */
95*0Sstevel@tonic-gate };
96*0Sstevel@tonic-gate 
97*0Sstevel@tonic-gate /*
98*0Sstevel@tonic-gate  * __dh_gss_initialize:
99*0Sstevel@tonic-gate  * Each mechanism in the Diffie-Hellman family of mechanisms calls this
100*0Sstevel@tonic-gate  * routine passing a pointer to a gss_config structure. This routine will
101*0Sstevel@tonic-gate  * then check that the mech is not already initialized (If so just return
102*0Sstevel@tonic-gate  * the mech). It will then assign the entry points that are common to the
103*0Sstevel@tonic-gate  * mechanism family to the uninitialized mech. After which, it allocate space
104*0Sstevel@tonic-gate  * for that mechanism's context. It will be up to the caller to fill in
105*0Sstevel@tonic-gate  * its mechanism OID and fill in the corresponding fields in mechanism
106*0Sstevel@tonic-gate  * specific context.
107*0Sstevel@tonic-gate  */
108*0Sstevel@tonic-gate gss_mechanism
__dh_gss_initialize(gss_mechanism mech)109*0Sstevel@tonic-gate __dh_gss_initialize(gss_mechanism mech)
110*0Sstevel@tonic-gate {
111*0Sstevel@tonic-gate 	if (mech->context != NULL)
112*0Sstevel@tonic-gate 		return (mech);    /* already initialized */
113*0Sstevel@tonic-gate 
114*0Sstevel@tonic-gate 	/* Copy the common entry points for this mechcanisms */
115*0Sstevel@tonic-gate 	*mech = dh_mechanism;
116*0Sstevel@tonic-gate 
117*0Sstevel@tonic-gate 	/* Allocate space for this mechanism's context */
118*0Sstevel@tonic-gate 	mech->context = New(dh_context_desc, 1);
119*0Sstevel@tonic-gate 	if (mech->context == NULL)
120*0Sstevel@tonic-gate 		return (NULL);
121*0Sstevel@tonic-gate 
122*0Sstevel@tonic-gate 	/* return the mech */
123*0Sstevel@tonic-gate 	return (mech);
124*0Sstevel@tonic-gate }
125