xref: /titanic_41/usr/src/lib/libnsl/include/rpcsvc/nis_dhext.h (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
25*7c478bd9Sstevel@tonic-gate  */
26*7c478bd9Sstevel@tonic-gate 
27*7c478bd9Sstevel@tonic-gate /*
28*7c478bd9Sstevel@tonic-gate  *	nis_dhext.h: NIS+ extended Diffie-Hellman interface.
29*7c478bd9Sstevel@tonic-gate  */
30*7c478bd9Sstevel@tonic-gate 
31*7c478bd9Sstevel@tonic-gate #ifndef _NIS_DHEXT_H
32*7c478bd9Sstevel@tonic-gate #define	_NIS_DHEXT_H
33*7c478bd9Sstevel@tonic-gate 
34*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
35*7c478bd9Sstevel@tonic-gate 
36*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus
37*7c478bd9Sstevel@tonic-gate extern "C" {
38*7c478bd9Sstevel@tonic-gate #endif
39*7c478bd9Sstevel@tonic-gate 
40*7c478bd9Sstevel@tonic-gate #include <rpc/rpc.h>
41*7c478bd9Sstevel@tonic-gate #include <rpc/key_prot.h>
42*7c478bd9Sstevel@tonic-gate #include <rpcsvc/nis.h>   /* to get nis_server */
43*7c478bd9Sstevel@tonic-gate 
44*7c478bd9Sstevel@tonic-gate 
45*7c478bd9Sstevel@tonic-gate #define	AUTH_DES_KEYLEN  192
46*7c478bd9Sstevel@tonic-gate #define	AUTH_DES_ALGTYPE 0
47*7c478bd9Sstevel@tonic-gate #define	AUTH_DES_AUTH_TYPE "DES"
48*7c478bd9Sstevel@tonic-gate 
49*7c478bd9Sstevel@tonic-gate #define	AUTH_DES_KEY(k, a) (((k) == AUTH_DES_KEYLEN) && \
50*7c478bd9Sstevel@tonic-gate 			    ((a) == AUTH_DES_ALGTYPE))
51*7c478bd9Sstevel@tonic-gate 
52*7c478bd9Sstevel@tonic-gate #define	BITS2NIBBLES(b)	((b)/4)
53*7c478bd9Sstevel@tonic-gate 
54*7c478bd9Sstevel@tonic-gate #define	NIS_SVCNAME_NISD	"nisd"
55*7c478bd9Sstevel@tonic-gate #define	NIS_SVCNAME_NISPASSWD	"nispasswd"
56*7c478bd9Sstevel@tonic-gate 
57*7c478bd9Sstevel@tonic-gate typedef struct extdhkey {
58*7c478bd9Sstevel@tonic-gate 	ushort_t	keylen;
59*7c478bd9Sstevel@tonic-gate 	ushort_t	algtype;
60*7c478bd9Sstevel@tonic-gate 	uchar_t		key[1];
61*7c478bd9Sstevel@tonic-gate } extdhkey_t;
62*7c478bd9Sstevel@tonic-gate 
63*7c478bd9Sstevel@tonic-gate char *__nis_dhext_extract_pkey(netobj *, keylen_t, algtype_t);
64*7c478bd9Sstevel@tonic-gate int __nis_dhext_extract_keyinfo(nis_server *, extdhkey_t **);
65*7c478bd9Sstevel@tonic-gate 
66*7c478bd9Sstevel@tonic-gate 
67*7c478bd9Sstevel@tonic-gate /*
68*7c478bd9Sstevel@tonic-gate  * NIS+ Security conf file
69*7c478bd9Sstevel@tonic-gate  */
70*7c478bd9Sstevel@tonic-gate 
71*7c478bd9Sstevel@tonic-gate #define	NIS_SEC_CF_PATHNAME		"/etc/rpcsec/nisplussec.conf"
72*7c478bd9Sstevel@tonic-gate #define	NIS_SEC_CF_MAX_FLDLEN		MAX_GSS_NAME
73*7c478bd9Sstevel@tonic-gate 
74*7c478bd9Sstevel@tonic-gate 
75*7c478bd9Sstevel@tonic-gate typedef struct {
76*7c478bd9Sstevel@tonic-gate 		char			*mechname;
77*7c478bd9Sstevel@tonic-gate 		char			*alias;
78*7c478bd9Sstevel@tonic-gate 		keylen_t		keylen;
79*7c478bd9Sstevel@tonic-gate 		algtype_t		algtype;
80*7c478bd9Sstevel@tonic-gate 		char			*qop;
81*7c478bd9Sstevel@tonic-gate 		rpc_gss_service_t	secserv;
82*7c478bd9Sstevel@tonic-gate } mechanism_t;
83*7c478bd9Sstevel@tonic-gate 
84*7c478bd9Sstevel@tonic-gate /* The string that indicates AUTH_DES compat in the nis sec conf file. */
85*7c478bd9Sstevel@tonic-gate #define	NIS_SEC_CF_DES_ALIAS		"des"
86*7c478bd9Sstevel@tonic-gate 
87*7c478bd9Sstevel@tonic-gate /*
88*7c478bd9Sstevel@tonic-gate  * The value a keylen or algtype mechanism_t element will be set
89*7c478bd9Sstevel@tonic-gate  * to if the conf file indicates "not applicable" for that field.
90*7c478bd9Sstevel@tonic-gate  * Except if the alias is equal to NIS_SEC_CF_DES_ALIAS,
91*7c478bd9Sstevel@tonic-gate  * then the keylen is set to 192 and the algtype to 0.
92*7c478bd9Sstevel@tonic-gate  */
93*7c478bd9Sstevel@tonic-gate #define	NIS_SEC_CF_NA_KA		-1
94*7c478bd9Sstevel@tonic-gate 
95*7c478bd9Sstevel@tonic-gate /* Is the NIS+ security conf file mech entry a real live GSS mech? */
96*7c478bd9Sstevel@tonic-gate #define	NIS_SEC_CF_GSS_MECH(mp)	((mp)->mechname != NULL)
97*7c478bd9Sstevel@tonic-gate 
98*7c478bd9Sstevel@tonic-gate #define	AUTH_DES_COMPAT_CHK(mp)	((mp)->alias && \
99*7c478bd9Sstevel@tonic-gate 					(strncasecmp(NIS_SEC_CF_DES_ALIAS, \
100*7c478bd9Sstevel@tonic-gate 					(mp)->alias,\
101*7c478bd9Sstevel@tonic-gate 					sizeof (NIS_SEC_CF_DES_ALIAS) + 1) \
102*7c478bd9Sstevel@tonic-gate 					== 0))
103*7c478bd9Sstevel@tonic-gate 
104*7c478bd9Sstevel@tonic-gate #define	VALID_GSS_MECH(m)	((m) != NULL)
105*7c478bd9Sstevel@tonic-gate 
106*7c478bd9Sstevel@tonic-gate /* valid keylen and algtype check */
107*7c478bd9Sstevel@tonic-gate #define	VALID_KEYALG(k, a)	((k) != NIS_SEC_CF_NA_KA && \
108*7c478bd9Sstevel@tonic-gate 					(a) != NIS_SEC_CF_NA_KA)
109*7c478bd9Sstevel@tonic-gate 
110*7c478bd9Sstevel@tonic-gate #define	VALID_ALIAS(a)	((a) != NULL)
111*7c478bd9Sstevel@tonic-gate 
112*7c478bd9Sstevel@tonic-gate #define	VALID_MECH_ENTRY(mp) (VALID_GSS_MECH((mp)->mechname) && \
113*7c478bd9Sstevel@tonic-gate 				VALID_KEYALG((mp)->keylen, (mp)->algtype) &&\
114*7c478bd9Sstevel@tonic-gate 				VALID_ALIAS((mp)->alias))
115*7c478bd9Sstevel@tonic-gate 
116*7c478bd9Sstevel@tonic-gate /* Is the mech entry of the public key crypto variety? */
117*7c478bd9Sstevel@tonic-gate #define	MECH_PK_TECH(mp)  (((mp)->alias)[0] == 'd' && ((mp)->alias)[1] == 'h')
118*7c478bd9Sstevel@tonic-gate 
119*7c478bd9Sstevel@tonic-gate #define	MECH_MAXATNAME 32	/* Mechanism max size of auth_type name */
120*7c478bd9Sstevel@tonic-gate #define	MECH_MAXALIASNAME 32	/* Mechanism max size of mech alias name */
121*7c478bd9Sstevel@tonic-gate 
122*7c478bd9Sstevel@tonic-gate mechanism_t ** __nis_get_mechanisms(bool_t);
123*7c478bd9Sstevel@tonic-gate int __nis_translate_mechanism(const char *, int *, int *);
124*7c478bd9Sstevel@tonic-gate void __nis_release_mechanisms(mechanism_t **);
125*7c478bd9Sstevel@tonic-gate char *__nis_mechname2alias(const char *, char *, size_t);
126*7c478bd9Sstevel@tonic-gate char *__nis_authtype2mechalias(const char *, char *, size_t);
127*7c478bd9Sstevel@tonic-gate char *__nis_mechalias2authtype(const char *, char *, size_t);
128*7c478bd9Sstevel@tonic-gate char *__nis_keyalg2mechalias(keylen_t, algtype_t, char *, size_t);
129*7c478bd9Sstevel@tonic-gate char *__nis_keyalg2authtype(keylen_t, algtype_t, char *, size_t);
130*7c478bd9Sstevel@tonic-gate 
131*7c478bd9Sstevel@tonic-gate 
132*7c478bd9Sstevel@tonic-gate /*
133*7c478bd9Sstevel@tonic-gate  * NIS+ GSS Mech Dynamic Library Loading
134*7c478bd9Sstevel@tonic-gate  */
135*7c478bd9Sstevel@tonic-gate 
136*7c478bd9Sstevel@tonic-gate #define	MAXDHNAME	64
137*7c478bd9Sstevel@tonic-gate 
138*7c478bd9Sstevel@tonic-gate char *__nis_get_mechanism_library(keylen_t keylen, algtype_t algtype,
139*7c478bd9Sstevel@tonic-gate 					char *buffer, size_t buflen);
140*7c478bd9Sstevel@tonic-gate 
141*7c478bd9Sstevel@tonic-gate void *__nis_get_mechanism_symbol(keylen_t keylen, algtype_t algtype,
142*7c478bd9Sstevel@tonic-gate 					const char *);
143*7c478bd9Sstevel@tonic-gate 
144*7c478bd9Sstevel@tonic-gate 
145*7c478bd9Sstevel@tonic-gate /*
146*7c478bd9Sstevel@tonic-gate  * misc prototypes
147*7c478bd9Sstevel@tonic-gate  */
148*7c478bd9Sstevel@tonic-gate 
149*7c478bd9Sstevel@tonic-gate CLIENT *nis_make_rpchandle_gss_svc(nis_server *, int, rpcprog_t, rpcvers_t,
150*7c478bd9Sstevel@tonic-gate 					uint_t, int, int, char *, char *);
151*7c478bd9Sstevel@tonic-gate CLIENT *nis_make_rpchandle_gss_svc_ruid(nis_server *, int, rpcprog_t, rpcvers_t,
152*7c478bd9Sstevel@tonic-gate 					uint_t, int, int, char *, char *);
153*7c478bd9Sstevel@tonic-gate nis_server *__nis_host2nis_server_g(const char *, bool_t, bool_t, int *);
154*7c478bd9Sstevel@tonic-gate int __nis_gssprin2netname(rpc_gss_principal_t, char []);
155*7c478bd9Sstevel@tonic-gate void __nis_auth2princ_rpcgss(char *, struct svc_req *, bool_t, int);
156*7c478bd9Sstevel@tonic-gate 
157*7c478bd9Sstevel@tonic-gate void des_setparity_g(des_block *);
158*7c478bd9Sstevel@tonic-gate int passwd2des_g(const char *, const char *, int, des_block *, bool_t);
159*7c478bd9Sstevel@tonic-gate int getpublickey_g(const char [], keylen_t, algtype_t, char *, size_t);
160*7c478bd9Sstevel@tonic-gate int getsecretkey_g(const char *, keylen_t, algtype_t, char *, size_t,
161*7c478bd9Sstevel@tonic-gate 			const char *);
162*7c478bd9Sstevel@tonic-gate int __getpublickey_cached_g(const char [], keylen_t, algtype_t, char *, size_t,
163*7c478bd9Sstevel@tonic-gate 					int *);
164*7c478bd9Sstevel@tonic-gate void __getpublickey_flush_g(const char *, keylen_t, algtype_t);
165*7c478bd9Sstevel@tonic-gate int __gen_dhkeys_g(char *, char *, keylen_t, algtype_t, char *);
166*7c478bd9Sstevel@tonic-gate int __gen_common_dhkeys_g(char *, char *, keylen_t, algtype_t, des_block [],
167*7c478bd9Sstevel@tonic-gate 	keynum_t);
168*7c478bd9Sstevel@tonic-gate int __cbc_triple_crypt(des_block [], char *, uint_t, uint_t, char *);
169*7c478bd9Sstevel@tonic-gate int key_get_conv_g(const char *, keylen_t, algtype_t, des_block [], keynum_t);
170*7c478bd9Sstevel@tonic-gate int key_secretkey_is_set_g(keylen_t, algtype_t);
171*7c478bd9Sstevel@tonic-gate int key_removesecret_g(void);
172*7c478bd9Sstevel@tonic-gate int key_setnet_g(const char *, const char *, keylen_t, const char *,
173*7c478bd9Sstevel@tonic-gate 			keylen_t, algtype_t);
174*7c478bd9Sstevel@tonic-gate int xencrypt_g(char *, keylen_t, algtype_t, const char *, const char [],
175*7c478bd9Sstevel@tonic-gate 		char **, bool_t);
176*7c478bd9Sstevel@tonic-gate int xdecrypt_g(char *, keylen_t, algtype_t, const char *, const char [],
177*7c478bd9Sstevel@tonic-gate 		bool_t);
178*7c478bd9Sstevel@tonic-gate 
179*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus
180*7c478bd9Sstevel@tonic-gate }
181*7c478bd9Sstevel@tonic-gate #endif
182*7c478bd9Sstevel@tonic-gate 
183*7c478bd9Sstevel@tonic-gate #endif /* !_NIS_DHEXT_H */
184