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 2005 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 /* 28*0Sstevel@tonic-gate * nis_dhext.h: NIS+ extended Diffie-Hellman interface. 29*0Sstevel@tonic-gate */ 30*0Sstevel@tonic-gate 31*0Sstevel@tonic-gate #ifndef _NIS_DHEXT_H 32*0Sstevel@tonic-gate #define _NIS_DHEXT_H 33*0Sstevel@tonic-gate 34*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 35*0Sstevel@tonic-gate 36*0Sstevel@tonic-gate #ifdef __cplusplus 37*0Sstevel@tonic-gate extern "C" { 38*0Sstevel@tonic-gate #endif 39*0Sstevel@tonic-gate 40*0Sstevel@tonic-gate #include <rpc/rpc.h> 41*0Sstevel@tonic-gate #include <rpc/key_prot.h> 42*0Sstevel@tonic-gate #include <rpcsvc/nis.h> /* to get nis_server */ 43*0Sstevel@tonic-gate 44*0Sstevel@tonic-gate 45*0Sstevel@tonic-gate #define AUTH_DES_KEYLEN 192 46*0Sstevel@tonic-gate #define AUTH_DES_ALGTYPE 0 47*0Sstevel@tonic-gate #define AUTH_DES_AUTH_TYPE "DES" 48*0Sstevel@tonic-gate 49*0Sstevel@tonic-gate #define AUTH_DES_KEY(k, a) (((k) == AUTH_DES_KEYLEN) && \ 50*0Sstevel@tonic-gate ((a) == AUTH_DES_ALGTYPE)) 51*0Sstevel@tonic-gate 52*0Sstevel@tonic-gate #define BITS2NIBBLES(b) ((b)/4) 53*0Sstevel@tonic-gate 54*0Sstevel@tonic-gate #define NIS_SVCNAME_NISD "nisd" 55*0Sstevel@tonic-gate #define NIS_SVCNAME_NISPASSWD "nispasswd" 56*0Sstevel@tonic-gate 57*0Sstevel@tonic-gate typedef struct extdhkey { 58*0Sstevel@tonic-gate ushort_t keylen; 59*0Sstevel@tonic-gate ushort_t algtype; 60*0Sstevel@tonic-gate uchar_t key[1]; 61*0Sstevel@tonic-gate } extdhkey_t; 62*0Sstevel@tonic-gate 63*0Sstevel@tonic-gate char *__nis_dhext_extract_pkey(netobj *, keylen_t, algtype_t); 64*0Sstevel@tonic-gate int __nis_dhext_extract_keyinfo(nis_server *, extdhkey_t **); 65*0Sstevel@tonic-gate 66*0Sstevel@tonic-gate 67*0Sstevel@tonic-gate /* 68*0Sstevel@tonic-gate * NIS+ Security conf file 69*0Sstevel@tonic-gate */ 70*0Sstevel@tonic-gate 71*0Sstevel@tonic-gate #define NIS_SEC_CF_PATHNAME "/etc/rpcsec/nisplussec.conf" 72*0Sstevel@tonic-gate #define NIS_SEC_CF_MAX_FLDLEN MAX_GSS_NAME 73*0Sstevel@tonic-gate 74*0Sstevel@tonic-gate 75*0Sstevel@tonic-gate typedef struct { 76*0Sstevel@tonic-gate char *mechname; 77*0Sstevel@tonic-gate char *alias; 78*0Sstevel@tonic-gate keylen_t keylen; 79*0Sstevel@tonic-gate algtype_t algtype; 80*0Sstevel@tonic-gate char *qop; 81*0Sstevel@tonic-gate rpc_gss_service_t secserv; 82*0Sstevel@tonic-gate } mechanism_t; 83*0Sstevel@tonic-gate 84*0Sstevel@tonic-gate /* The string that indicates AUTH_DES compat in the nis sec conf file. */ 85*0Sstevel@tonic-gate #define NIS_SEC_CF_DES_ALIAS "des" 86*0Sstevel@tonic-gate 87*0Sstevel@tonic-gate /* 88*0Sstevel@tonic-gate * The value a keylen or algtype mechanism_t element will be set 89*0Sstevel@tonic-gate * to if the conf file indicates "not applicable" for that field. 90*0Sstevel@tonic-gate * Except if the alias is equal to NIS_SEC_CF_DES_ALIAS, 91*0Sstevel@tonic-gate * then the keylen is set to 192 and the algtype to 0. 92*0Sstevel@tonic-gate */ 93*0Sstevel@tonic-gate #define NIS_SEC_CF_NA_KA -1 94*0Sstevel@tonic-gate 95*0Sstevel@tonic-gate /* Is the NIS+ security conf file mech entry a real live GSS mech? */ 96*0Sstevel@tonic-gate #define NIS_SEC_CF_GSS_MECH(mp) ((mp)->mechname != NULL) 97*0Sstevel@tonic-gate 98*0Sstevel@tonic-gate #define AUTH_DES_COMPAT_CHK(mp) ((mp)->alias && \ 99*0Sstevel@tonic-gate (strncasecmp(NIS_SEC_CF_DES_ALIAS, \ 100*0Sstevel@tonic-gate (mp)->alias,\ 101*0Sstevel@tonic-gate sizeof (NIS_SEC_CF_DES_ALIAS) + 1) \ 102*0Sstevel@tonic-gate == 0)) 103*0Sstevel@tonic-gate 104*0Sstevel@tonic-gate #define VALID_GSS_MECH(m) ((m) != NULL) 105*0Sstevel@tonic-gate 106*0Sstevel@tonic-gate /* valid keylen and algtype check */ 107*0Sstevel@tonic-gate #define VALID_KEYALG(k, a) ((k) != NIS_SEC_CF_NA_KA && \ 108*0Sstevel@tonic-gate (a) != NIS_SEC_CF_NA_KA) 109*0Sstevel@tonic-gate 110*0Sstevel@tonic-gate #define VALID_ALIAS(a) ((a) != NULL) 111*0Sstevel@tonic-gate 112*0Sstevel@tonic-gate #define VALID_MECH_ENTRY(mp) (VALID_GSS_MECH((mp)->mechname) && \ 113*0Sstevel@tonic-gate VALID_KEYALG((mp)->keylen, (mp)->algtype) &&\ 114*0Sstevel@tonic-gate VALID_ALIAS((mp)->alias)) 115*0Sstevel@tonic-gate 116*0Sstevel@tonic-gate /* Is the mech entry of the public key crypto variety? */ 117*0Sstevel@tonic-gate #define MECH_PK_TECH(mp) (((mp)->alias)[0] == 'd' && ((mp)->alias)[1] == 'h') 118*0Sstevel@tonic-gate 119*0Sstevel@tonic-gate #define MECH_MAXATNAME 32 /* Mechanism max size of auth_type name */ 120*0Sstevel@tonic-gate #define MECH_MAXALIASNAME 32 /* Mechanism max size of mech alias name */ 121*0Sstevel@tonic-gate 122*0Sstevel@tonic-gate mechanism_t ** __nis_get_mechanisms(bool_t); 123*0Sstevel@tonic-gate int __nis_translate_mechanism(const char *, int *, int *); 124*0Sstevel@tonic-gate void __nis_release_mechanisms(mechanism_t **); 125*0Sstevel@tonic-gate char *__nis_mechname2alias(const char *, char *, size_t); 126*0Sstevel@tonic-gate char *__nis_authtype2mechalias(const char *, char *, size_t); 127*0Sstevel@tonic-gate char *__nis_mechalias2authtype(const char *, char *, size_t); 128*0Sstevel@tonic-gate char *__nis_keyalg2mechalias(keylen_t, algtype_t, char *, size_t); 129*0Sstevel@tonic-gate char *__nis_keyalg2authtype(keylen_t, algtype_t, char *, size_t); 130*0Sstevel@tonic-gate 131*0Sstevel@tonic-gate 132*0Sstevel@tonic-gate /* 133*0Sstevel@tonic-gate * NIS+ GSS Mech Dynamic Library Loading 134*0Sstevel@tonic-gate */ 135*0Sstevel@tonic-gate 136*0Sstevel@tonic-gate #define MAXDHNAME 64 137*0Sstevel@tonic-gate 138*0Sstevel@tonic-gate char *__nis_get_mechanism_library(keylen_t keylen, algtype_t algtype, 139*0Sstevel@tonic-gate char *buffer, size_t buflen); 140*0Sstevel@tonic-gate 141*0Sstevel@tonic-gate void *__nis_get_mechanism_symbol(keylen_t keylen, algtype_t algtype, 142*0Sstevel@tonic-gate const char *); 143*0Sstevel@tonic-gate 144*0Sstevel@tonic-gate 145*0Sstevel@tonic-gate /* 146*0Sstevel@tonic-gate * misc prototypes 147*0Sstevel@tonic-gate */ 148*0Sstevel@tonic-gate 149*0Sstevel@tonic-gate CLIENT *nis_make_rpchandle_gss_svc(nis_server *, int, rpcprog_t, rpcvers_t, 150*0Sstevel@tonic-gate uint_t, int, int, char *, char *); 151*0Sstevel@tonic-gate CLIENT *nis_make_rpchandle_gss_svc_ruid(nis_server *, int, rpcprog_t, rpcvers_t, 152*0Sstevel@tonic-gate uint_t, int, int, char *, char *); 153*0Sstevel@tonic-gate nis_server *__nis_host2nis_server_g(const char *, bool_t, bool_t, int *); 154*0Sstevel@tonic-gate int __nis_gssprin2netname(rpc_gss_principal_t, char []); 155*0Sstevel@tonic-gate void __nis_auth2princ_rpcgss(char *, struct svc_req *, bool_t, int); 156*0Sstevel@tonic-gate 157*0Sstevel@tonic-gate void des_setparity_g(des_block *); 158*0Sstevel@tonic-gate int passwd2des_g(const char *, const char *, int, des_block *, bool_t); 159*0Sstevel@tonic-gate int getpublickey_g(const char [], keylen_t, algtype_t, char *, size_t); 160*0Sstevel@tonic-gate int getsecretkey_g(const char *, keylen_t, algtype_t, char *, size_t, 161*0Sstevel@tonic-gate const char *); 162*0Sstevel@tonic-gate int __getpublickey_cached_g(const char [], keylen_t, algtype_t, char *, size_t, 163*0Sstevel@tonic-gate int *); 164*0Sstevel@tonic-gate void __getpublickey_flush_g(const char *, keylen_t, algtype_t); 165*0Sstevel@tonic-gate int __gen_dhkeys_g(char *, char *, keylen_t, algtype_t, char *); 166*0Sstevel@tonic-gate int __gen_common_dhkeys_g(char *, char *, keylen_t, algtype_t, des_block [], 167*0Sstevel@tonic-gate keynum_t); 168*0Sstevel@tonic-gate int __cbc_triple_crypt(des_block [], char *, uint_t, uint_t, char *); 169*0Sstevel@tonic-gate int key_get_conv_g(const char *, keylen_t, algtype_t, des_block [], keynum_t); 170*0Sstevel@tonic-gate int key_secretkey_is_set_g(keylen_t, algtype_t); 171*0Sstevel@tonic-gate int key_removesecret_g(void); 172*0Sstevel@tonic-gate int key_setnet_g(const char *, const char *, keylen_t, const char *, 173*0Sstevel@tonic-gate keylen_t, algtype_t); 174*0Sstevel@tonic-gate int xencrypt_g(char *, keylen_t, algtype_t, const char *, const char [], 175*0Sstevel@tonic-gate char **, bool_t); 176*0Sstevel@tonic-gate int xdecrypt_g(char *, keylen_t, algtype_t, const char *, const char [], 177*0Sstevel@tonic-gate bool_t); 178*0Sstevel@tonic-gate 179*0Sstevel@tonic-gate #ifdef __cplusplus 180*0Sstevel@tonic-gate } 181*0Sstevel@tonic-gate #endif 182*0Sstevel@tonic-gate 183*0Sstevel@tonic-gate #endif /* !_NIS_DHEXT_H */ 184