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 * Private extensions and utilities to the GSS-API. 27*0Sstevel@tonic-gate * These are not part of the GSS-API specification 28*0Sstevel@tonic-gate * but may be useful to GSS-API users. 29*0Sstevel@tonic-gate */ 30*0Sstevel@tonic-gate 31*0Sstevel@tonic-gate #ifndef _GSSAPI_EXT_H 32*0Sstevel@tonic-gate #define _GSSAPI_EXT_H 33*0Sstevel@tonic-gate 34*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 35*0Sstevel@tonic-gate 36*0Sstevel@tonic-gate #include <gssapi/gssapi.h> 37*0Sstevel@tonic-gate #ifdef _KERNEL 38*0Sstevel@tonic-gate #include <sys/systm.h> 39*0Sstevel@tonic-gate #else 40*0Sstevel@tonic-gate #include <strings.h> 41*0Sstevel@tonic-gate #endif 42*0Sstevel@tonic-gate 43*0Sstevel@tonic-gate 44*0Sstevel@tonic-gate #ifdef __cplusplus 45*0Sstevel@tonic-gate extern "C" { 46*0Sstevel@tonic-gate #endif 47*0Sstevel@tonic-gate 48*0Sstevel@tonic-gate /* MACRO for comparison of gss_OID's */ 49*0Sstevel@tonic-gate #define g_OID_equal(o1, o2) \ 50*0Sstevel@tonic-gate (((o1)->length == (o2)->length) && \ 51*0Sstevel@tonic-gate (memcmp((o1)->elements, (o2)->elements, (int)(o1)->length) == 0)) 52*0Sstevel@tonic-gate 53*0Sstevel@tonic-gate 54*0Sstevel@tonic-gate /* 55*0Sstevel@tonic-gate * MACRO for copying of OIDs - memory must already be allocated 56*0Sstevel@tonic-gate * o2 is copied to o1 57*0Sstevel@tonic-gate */ 58*0Sstevel@tonic-gate #define g_OID_copy(o1, o2) \ 59*0Sstevel@tonic-gate bcopy((o2)->elements, (o1)->elements, (o2)->length);\ 60*0Sstevel@tonic-gate (o1)->length = (o2)->length; 61*0Sstevel@tonic-gate 62*0Sstevel@tonic-gate 63*0Sstevel@tonic-gate /* MACRO to check if input buffer is valid */ 64*0Sstevel@tonic-gate #define GSS_EMPTY_BUFFER(buf) ((buf) == NULL ||\ 65*0Sstevel@tonic-gate (buf)->value == NULL || (buf)->length == 0) 66*0Sstevel@tonic-gate 67*0Sstevel@tonic-gate 68*0Sstevel@tonic-gate /* 69*0Sstevel@tonic-gate * GSSAPI Extension functions -- these functions aren't 70*0Sstevel@tonic-gate * in the GSSAPI specification, but are provided in our 71*0Sstevel@tonic-gate * GSS library. 72*0Sstevel@tonic-gate */ 73*0Sstevel@tonic-gate 74*0Sstevel@tonic-gate #ifndef _KERNEL 75*0Sstevel@tonic-gate 76*0Sstevel@tonic-gate /* 77*0Sstevel@tonic-gate * qop configuration file handling. 78*0Sstevel@tonic-gate */ 79*0Sstevel@tonic-gate #define MAX_QOP_NUM_PAIRS 128 80*0Sstevel@tonic-gate #define MAX_QOPS_PER_MECH 128 81*0Sstevel@tonic-gate 82*0Sstevel@tonic-gate typedef struct _qop_num { 83*0Sstevel@tonic-gate char *qop; 84*0Sstevel@tonic-gate OM_uint32 num; 85*0Sstevel@tonic-gate char *mech; 86*0Sstevel@tonic-gate } qop_num; 87*0Sstevel@tonic-gate 88*0Sstevel@tonic-gate OM_uint32 89*0Sstevel@tonic-gate __gss_qop_to_num( 90*0Sstevel@tonic-gate char *qop, /* input qop string */ 91*0Sstevel@tonic-gate char *mech, /* input mech string */ 92*0Sstevel@tonic-gate OM_uint32 *num /* output qop num */ 93*0Sstevel@tonic-gate ); 94*0Sstevel@tonic-gate 95*0Sstevel@tonic-gate OM_uint32 96*0Sstevel@tonic-gate __gss_num_to_qop( 97*0Sstevel@tonic-gate char *mech, /* input mech string */ 98*0Sstevel@tonic-gate OM_uint32 num, /* input qop num */ 99*0Sstevel@tonic-gate char **qop /* output qop name */ 100*0Sstevel@tonic-gate ); 101*0Sstevel@tonic-gate 102*0Sstevel@tonic-gate OM_uint32 103*0Sstevel@tonic-gate __gss_get_mech_info( 104*0Sstevel@tonic-gate char *mech, /* input mech string */ 105*0Sstevel@tonic-gate char **qops /* buffer for return qops */ 106*0Sstevel@tonic-gate ); 107*0Sstevel@tonic-gate 108*0Sstevel@tonic-gate OM_uint32 109*0Sstevel@tonic-gate __gss_mech_qops( 110*0Sstevel@tonic-gate char *mech, /* input mech */ 111*0Sstevel@tonic-gate qop_num *mech_qops, /* mech qops buffer */ 112*0Sstevel@tonic-gate int *numqops /* buffer to return numqops */ 113*0Sstevel@tonic-gate ); 114*0Sstevel@tonic-gate 115*0Sstevel@tonic-gate OM_uint32 116*0Sstevel@tonic-gate __gss_mech_to_oid( 117*0Sstevel@tonic-gate const char *mech, /* mechanism string name */ 118*0Sstevel@tonic-gate gss_OID *oid /* mechanism oid */ 119*0Sstevel@tonic-gate ); 120*0Sstevel@tonic-gate 121*0Sstevel@tonic-gate const char * 122*0Sstevel@tonic-gate __gss_oid_to_mech( 123*0Sstevel@tonic-gate const gss_OID oid /* mechanism oid */ 124*0Sstevel@tonic-gate ); 125*0Sstevel@tonic-gate 126*0Sstevel@tonic-gate OM_uint32 127*0Sstevel@tonic-gate __gss_get_mechanisms( 128*0Sstevel@tonic-gate char *mechArray[], /* array to populate with mechs */ 129*0Sstevel@tonic-gate int arrayLen /* length of passed in array */ 130*0Sstevel@tonic-gate ); 131*0Sstevel@tonic-gate 132*0Sstevel@tonic-gate OM_uint32 133*0Sstevel@tonic-gate __gss_get_mech_type( 134*0Sstevel@tonic-gate gss_OID oid, /* mechanism oid */ 135*0Sstevel@tonic-gate const gss_buffer_t token /* token */ 136*0Sstevel@tonic-gate ); 137*0Sstevel@tonic-gate 138*0Sstevel@tonic-gate OM_uint32 139*0Sstevel@tonic-gate __gss_userok( 140*0Sstevel@tonic-gate OM_uint32 *, /* minor status */ 141*0Sstevel@tonic-gate const gss_name_t, /* remote user principal name */ 142*0Sstevel@tonic-gate const char *, /* local unix user name */ 143*0Sstevel@tonic-gate int *); /* remote principal ok to login w/out pw? */ 144*0Sstevel@tonic-gate 145*0Sstevel@tonic-gate OM_uint32 146*0Sstevel@tonic-gate gsscred_expname_to_unix_cred( 147*0Sstevel@tonic-gate const gss_buffer_t, /* export name */ 148*0Sstevel@tonic-gate uid_t *, /* uid out */ 149*0Sstevel@tonic-gate gid_t *, /* gid out */ 150*0Sstevel@tonic-gate gid_t *[], /* gid array out */ 151*0Sstevel@tonic-gate int *); /* gid array length */ 152*0Sstevel@tonic-gate 153*0Sstevel@tonic-gate OM_uint32 154*0Sstevel@tonic-gate gsscred_name_to_unix_cred( 155*0Sstevel@tonic-gate const gss_name_t, /* gss name */ 156*0Sstevel@tonic-gate const gss_OID, /* mechanim type */ 157*0Sstevel@tonic-gate uid_t *, /* uid out */ 158*0Sstevel@tonic-gate gid_t *, /* gid out */ 159*0Sstevel@tonic-gate gid_t *[], /* gid array out */ 160*0Sstevel@tonic-gate int *); /* gid array length */ 161*0Sstevel@tonic-gate 162*0Sstevel@tonic-gate 163*0Sstevel@tonic-gate /* 164*0Sstevel@tonic-gate * The following function will be used to resolve group 165*0Sstevel@tonic-gate * ids from a UNIX uid. 166*0Sstevel@tonic-gate */ 167*0Sstevel@tonic-gate OM_uint32 168*0Sstevel@tonic-gate gss_get_group_info( 169*0Sstevel@tonic-gate const uid_t, /* entity UNIX uid */ 170*0Sstevel@tonic-gate gid_t *, /* gid out */ 171*0Sstevel@tonic-gate gid_t *[], /* gid array */ 172*0Sstevel@tonic-gate int *); /* length of the gid array */ 173*0Sstevel@tonic-gate 174*0Sstevel@tonic-gate 175*0Sstevel@tonic-gate 176*0Sstevel@tonic-gate OM_uint32 177*0Sstevel@tonic-gate gss_acquire_cred_with_password( 178*0Sstevel@tonic-gate OM_uint32 * minor_status, 179*0Sstevel@tonic-gate const gss_name_t desired_name, 180*0Sstevel@tonic-gate const gss_buffer_t password, 181*0Sstevel@tonic-gate OM_uint32 time_req, 182*0Sstevel@tonic-gate const gss_OID_set desired_mechs, 183*0Sstevel@tonic-gate int cred_usage, 184*0Sstevel@tonic-gate gss_cred_id_t *output_cred_handle, 185*0Sstevel@tonic-gate gss_OID_set * actual_mechs, 186*0Sstevel@tonic-gate OM_uint32 * time_rec); 187*0Sstevel@tonic-gate 188*0Sstevel@tonic-gate OM_uint32 189*0Sstevel@tonic-gate gss_add_cred_with_password( 190*0Sstevel@tonic-gate OM_uint32 *minor_status, 191*0Sstevel@tonic-gate const gss_cred_id_t input_cred_handle, 192*0Sstevel@tonic-gate const gss_name_t desired_name, 193*0Sstevel@tonic-gate const gss_OID desired_mech, 194*0Sstevel@tonic-gate const gss_buffer_t password, 195*0Sstevel@tonic-gate gss_cred_usage_t cred_usage, 196*0Sstevel@tonic-gate OM_uint32 initiator_time_req, 197*0Sstevel@tonic-gate OM_uint32 acceptor_time_req, 198*0Sstevel@tonic-gate gss_cred_id_t *output_cred_handle, 199*0Sstevel@tonic-gate gss_OID_set *actual_mechs, 200*0Sstevel@tonic-gate OM_uint32 *initiator_time_rec, 201*0Sstevel@tonic-gate OM_uint32 *acceptor_time_rec); 202*0Sstevel@tonic-gate 203*0Sstevel@tonic-gate #else /* _KERNEL */ 204*0Sstevel@tonic-gate 205*0Sstevel@tonic-gate OM_uint32 206*0Sstevel@tonic-gate kgsscred_expname_to_unix_cred( 207*0Sstevel@tonic-gate const gss_buffer_t expName, 208*0Sstevel@tonic-gate uid_t *uidOut, 209*0Sstevel@tonic-gate gid_t *gidOut, 210*0Sstevel@tonic-gate gid_t *gids[], 211*0Sstevel@tonic-gate int *gidsLen, 212*0Sstevel@tonic-gate uid_t uid); 213*0Sstevel@tonic-gate 214*0Sstevel@tonic-gate OM_uint32 215*0Sstevel@tonic-gate kgsscred_name_to_unix_cred( 216*0Sstevel@tonic-gate const gss_name_t intName, 217*0Sstevel@tonic-gate const gss_OID mechType, 218*0Sstevel@tonic-gate uid_t *uidOut, 219*0Sstevel@tonic-gate gid_t *gidOut, 220*0Sstevel@tonic-gate gid_t *gids[], 221*0Sstevel@tonic-gate int *gidsLen, 222*0Sstevel@tonic-gate uid_t uid); 223*0Sstevel@tonic-gate 224*0Sstevel@tonic-gate OM_uint32 225*0Sstevel@tonic-gate kgss_get_group_info( 226*0Sstevel@tonic-gate const uid_t puid, 227*0Sstevel@tonic-gate gid_t *gidOut, 228*0Sstevel@tonic-gate gid_t *gids[], 229*0Sstevel@tonic-gate int *gidsLen, 230*0Sstevel@tonic-gate uid_t uid); 231*0Sstevel@tonic-gate 232*0Sstevel@tonic-gate #endif 233*0Sstevel@tonic-gate 234*0Sstevel@tonic-gate 235*0Sstevel@tonic-gate #ifdef __cplusplus 236*0Sstevel@tonic-gate } 237*0Sstevel@tonic-gate #endif 238*0Sstevel@tonic-gate 239*0Sstevel@tonic-gate #endif /* _GSSAPI_EXT_H */ 240