1*7f2fe78bSCy Schubert /* include/gssrpc/auth_gss.h */ 2*7f2fe78bSCy Schubert /* 3*7f2fe78bSCy Schubert Copyright (c) 2000 The Regents of the University of Michigan. 4*7f2fe78bSCy Schubert All rights reserved. 5*7f2fe78bSCy Schubert 6*7f2fe78bSCy Schubert Copyright (c) 2000 Dug Song <dugsong@UMICH.EDU>. 7*7f2fe78bSCy Schubert All rights reserved, all wrongs reversed. 8*7f2fe78bSCy Schubert 9*7f2fe78bSCy Schubert Redistribution and use in source and binary forms, with or without 10*7f2fe78bSCy Schubert modification, are permitted provided that the following conditions 11*7f2fe78bSCy Schubert are met: 12*7f2fe78bSCy Schubert 13*7f2fe78bSCy Schubert 1. Redistributions of source code must retain the above copyright 14*7f2fe78bSCy Schubert notice, this list of conditions and the following disclaimer. 15*7f2fe78bSCy Schubert 2. Redistributions in binary form must reproduce the above copyright 16*7f2fe78bSCy Schubert notice, this list of conditions and the following disclaimer in the 17*7f2fe78bSCy Schubert documentation and/or other materials provided with the distribution. 18*7f2fe78bSCy Schubert 3. Neither the name of the University nor the names of its 19*7f2fe78bSCy Schubert contributors may be used to endorse or promote products derived 20*7f2fe78bSCy Schubert from this software without specific prior written permission. 21*7f2fe78bSCy Schubert 22*7f2fe78bSCy Schubert THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED 23*7f2fe78bSCy Schubert WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 24*7f2fe78bSCy Schubert MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 25*7f2fe78bSCy Schubert DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 26*7f2fe78bSCy Schubert FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 27*7f2fe78bSCy Schubert CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 28*7f2fe78bSCy Schubert SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 29*7f2fe78bSCy Schubert BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 30*7f2fe78bSCy Schubert LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 31*7f2fe78bSCy Schubert NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 32*7f2fe78bSCy Schubert SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33*7f2fe78bSCy Schubert 34*7f2fe78bSCy Schubert Id: auth_gss.h,v 1.13 2002/05/08 16:54:33 andros Exp 35*7f2fe78bSCy Schubert */ 36*7f2fe78bSCy Schubert 37*7f2fe78bSCy Schubert #ifndef GSSRPC_AUTH_GSS_H 38*7f2fe78bSCy Schubert #define GSSRPC_AUTH_GSS_H 39*7f2fe78bSCy Schubert 40*7f2fe78bSCy Schubert #include <gssrpc/rpc.h> 41*7f2fe78bSCy Schubert #include <gssrpc/clnt.h> 42*7f2fe78bSCy Schubert #ifdef HAVE_HEIMDAL 43*7f2fe78bSCy Schubert #include <gssapi.h> 44*7f2fe78bSCy Schubert #else 45*7f2fe78bSCy Schubert #include <gssapi/gssapi.h> 46*7f2fe78bSCy Schubert #endif 47*7f2fe78bSCy Schubert 48*7f2fe78bSCy Schubert GSSRPC__BEGIN_DECLS 49*7f2fe78bSCy Schubert 50*7f2fe78bSCy Schubert /* RPCSEC_GSS control procedures. */ 51*7f2fe78bSCy Schubert typedef enum { 52*7f2fe78bSCy Schubert RPCSEC_GSS_DATA = 0, 53*7f2fe78bSCy Schubert RPCSEC_GSS_INIT = 1, 54*7f2fe78bSCy Schubert RPCSEC_GSS_CONTINUE_INIT = 2, 55*7f2fe78bSCy Schubert RPCSEC_GSS_DESTROY = 3 56*7f2fe78bSCy Schubert } rpc_gss_proc_t; 57*7f2fe78bSCy Schubert 58*7f2fe78bSCy Schubert /* RPCSEC_GSS services. */ 59*7f2fe78bSCy Schubert typedef enum { 60*7f2fe78bSCy Schubert RPCSEC_GSS_SVC_NONE = 1, 61*7f2fe78bSCy Schubert RPCSEC_GSS_SVC_INTEGRITY = 2, 62*7f2fe78bSCy Schubert RPCSEC_GSS_SVC_PRIVACY = 3 63*7f2fe78bSCy Schubert } rpc_gss_svc_t; 64*7f2fe78bSCy Schubert 65*7f2fe78bSCy Schubert #define RPCSEC_GSS_VERSION 1 66*7f2fe78bSCy Schubert 67*7f2fe78bSCy Schubert /* RPCSEC_GSS security triple. */ 68*7f2fe78bSCy Schubert struct rpc_gss_sec { 69*7f2fe78bSCy Schubert gss_OID mech; /* mechanism */ 70*7f2fe78bSCy Schubert gss_qop_t qop; /* quality of protection */ 71*7f2fe78bSCy Schubert rpc_gss_svc_t svc; /* service */ 72*7f2fe78bSCy Schubert gss_cred_id_t cred; /* cred handle */ 73*7f2fe78bSCy Schubert uint32_t req_flags; /* req flags for init_sec_context */ 74*7f2fe78bSCy Schubert }; 75*7f2fe78bSCy Schubert 76*7f2fe78bSCy Schubert /* Private data required for kernel implementation */ 77*7f2fe78bSCy Schubert struct authgss_private_data { 78*7f2fe78bSCy Schubert gss_ctx_id_t pd_ctx; /* Session context handle */ 79*7f2fe78bSCy Schubert gss_buffer_desc pd_ctx_hndl; /* Credentials context handle */ 80*7f2fe78bSCy Schubert uint32_t pd_seq_win; /* Sequence window */ 81*7f2fe78bSCy Schubert }; 82*7f2fe78bSCy Schubert 83*7f2fe78bSCy Schubert /* Krb 5 default mechanism 84*7f2fe78bSCy Schubert #define KRB5OID "1.2.840.113554.1.2.2" 85*7f2fe78bSCy Schubert 86*7f2fe78bSCy Schubert gss_OID_desc krb5oid = { 87*7f2fe78bSCy Schubert 20, KRB5OID 88*7f2fe78bSCy Schubert }; 89*7f2fe78bSCy Schubert */ 90*7f2fe78bSCy Schubert 91*7f2fe78bSCy Schubert /* 92*7f2fe78bSCy Schubert struct rpc_gss_sec krb5mech = { 93*7f2fe78bSCy Schubert (gss_OID)&krb5oid, 94*7f2fe78bSCy Schubert GSS_QOP_DEFAULT, 95*7f2fe78bSCy Schubert RPCSEC_GSS_SVC_NONE 96*7f2fe78bSCy Schubert }; 97*7f2fe78bSCy Schubert */ 98*7f2fe78bSCy Schubert 99*7f2fe78bSCy Schubert /* Credentials. */ 100*7f2fe78bSCy Schubert struct rpc_gss_cred { 101*7f2fe78bSCy Schubert u_int gc_v; /* version */ 102*7f2fe78bSCy Schubert rpc_gss_proc_t gc_proc; /* control procedure */ 103*7f2fe78bSCy Schubert uint32_t gc_seq; /* sequence number */ 104*7f2fe78bSCy Schubert rpc_gss_svc_t gc_svc; /* service */ 105*7f2fe78bSCy Schubert gss_buffer_desc gc_ctx; /* context handle */ 106*7f2fe78bSCy Schubert }; 107*7f2fe78bSCy Schubert 108*7f2fe78bSCy Schubert /* Context creation response. */ 109*7f2fe78bSCy Schubert struct rpc_gss_init_res { 110*7f2fe78bSCy Schubert gss_buffer_desc gr_ctx; /* context handle */ 111*7f2fe78bSCy Schubert uint32_t gr_major; /* major status */ 112*7f2fe78bSCy Schubert uint32_t gr_minor; /* minor status */ 113*7f2fe78bSCy Schubert uint32_t gr_win; /* sequence window */ 114*7f2fe78bSCy Schubert gss_buffer_desc gr_token; /* token */ 115*7f2fe78bSCy Schubert }; 116*7f2fe78bSCy Schubert 117*7f2fe78bSCy Schubert /* Maximum sequence number value. */ 118*7f2fe78bSCy Schubert #define MAXSEQ 0x80000000 119*7f2fe78bSCy Schubert 120*7f2fe78bSCy Schubert /* Prototypes. */ 121*7f2fe78bSCy Schubert bool_t xdr_rpc_gss_buf (XDR *xdrs, gss_buffer_t, u_int maxsize); 122*7f2fe78bSCy Schubert bool_t xdr_rpc_gss_cred (XDR *xdrs, struct rpc_gss_cred *p); 123*7f2fe78bSCy Schubert bool_t xdr_rpc_gss_init_args (XDR *xdrs, gss_buffer_desc *p); 124*7f2fe78bSCy Schubert bool_t xdr_rpc_gss_init_res (XDR *xdrs, struct rpc_gss_init_res *p); 125*7f2fe78bSCy Schubert bool_t xdr_rpc_gss_data (XDR *xdrs, xdrproc_t xdr_func, 126*7f2fe78bSCy Schubert caddr_t xdr_ptr, gss_ctx_id_t ctx, 127*7f2fe78bSCy Schubert gss_qop_t qop, rpc_gss_svc_t svc, 128*7f2fe78bSCy Schubert uint32_t seq); 129*7f2fe78bSCy Schubert bool_t xdr_rpc_gss_wrap_data (XDR *xdrs, xdrproc_t xdr_func, caddr_t 130*7f2fe78bSCy Schubert xdr_ptr, gss_ctx_id_t ctx, gss_qop_t qop, 131*7f2fe78bSCy Schubert rpc_gss_svc_t svc, uint32_t seq); 132*7f2fe78bSCy Schubert bool_t xdr_rpc_gss_unwrap_data (XDR *xdrs, xdrproc_t xdr_func, caddr_t 133*7f2fe78bSCy Schubert xdr_ptr, gss_ctx_id_t ctx, gss_qop_t qop, 134*7f2fe78bSCy Schubert rpc_gss_svc_t svc, uint32_t seq); 135*7f2fe78bSCy Schubert 136*7f2fe78bSCy Schubert AUTH *authgss_create (CLIENT *, gss_name_t, struct rpc_gss_sec *); 137*7f2fe78bSCy Schubert AUTH *authgss_create_default (CLIENT *, char *, struct rpc_gss_sec *); 138*7f2fe78bSCy Schubert bool_t authgss_service (AUTH *auth, int svc); 139*7f2fe78bSCy Schubert bool_t authgss_get_private_data (AUTH *auth, struct authgss_private_data *); 140*7f2fe78bSCy Schubert 141*7f2fe78bSCy Schubert #ifdef GSSRPC__IMPL 142*7f2fe78bSCy Schubert void log_debug (const char *fmt, ...); 143*7f2fe78bSCy Schubert void log_status (char *m, OM_uint32 major, OM_uint32 minor); 144*7f2fe78bSCy Schubert void log_hexdump (const u_char *buf, int len, int offset); 145*7f2fe78bSCy Schubert #endif 146*7f2fe78bSCy Schubert 147*7f2fe78bSCy Schubert GSSRPC__END_DECLS 148*7f2fe78bSCy Schubert #endif /* !defined(GSSRPC_AUTH_GSS_H) */ 149