2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
4 * Copyright (c) 2008 Doug Rabson
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 #include <gssapi/gssapi.h>
37 #define MAX_GSS_MECH 64
41 * Define the types of security service required for rpc_gss_seccreate().
44 rpc_gss_svc_default = 0,
46 rpc_gss_svc_integrity = 2,
47 rpc_gss_svc_privacy = 3
51 * Structure containing options for rpc_gss_seccreate().
54 int req_flags; /* GSS request bits */
55 int time_req; /* requested credential lifetime */
56 gss_cred_id_t my_cred; /* GSS credential */
57 gss_channel_bindings_t input_channel_bindings;
58 } rpc_gss_options_req_t;
61 * Structure containing options returned by rpc_gss_seccreate().
69 gss_ctx_id_t gss_context;
70 char actual_mechanism[MAX_GSS_MECH];
71 } rpc_gss_options_ret_t;
74 * Client principal type. Used as an argument to
75 * rpc_gss_get_principal_name(). Also referenced by the
76 * rpc_gss_rawcred_t structure.
81 } *rpc_gss_principal_t;
84 * Structure for raw credentials used by rpc_gss_getcred() and
85 * rpc_gss_set_callback().
88 u_int version; /* RPC version number */
89 const char *mechanism; /* security mechanism */
90 const char *qop; /* quality of protection */
91 rpc_gss_principal_t client_principal; /* client name */
92 const char *svc_principal; /* server name */
93 rpc_gss_service_t service; /* service type */
97 * Unix credentials derived from raw credentials. Returned by
101 uid_t uid; /* user ID */
102 gid_t gid; /* group ID */
104 gid_t *gidlist; /* list of groups */
108 * Structure used to enforce a particular QOP and service.
112 rpc_gss_rawcred_t *raw_cred;
116 * Callback structure used by rpc_gss_set_callback().
119 u_int program; /* RPC program number */
120 u_int version; /* RPC version number */
121 /* user defined callback */
122 bool_t (*callback)(struct svc_req *req,
124 gss_ctx_id_t gss_context,
125 rpc_gss_lock_t *lock,
127 } rpc_gss_callback_t;
130 * Structure used to return error information by rpc_gss_get_error()
134 int system_error; /* same as errno */
138 * Values for rpc_gss_error
140 #define RPC_GSS_ER_SUCCESS 0 /* no error */
141 #define RPC_GSS_ER_SYSTEMERROR 1 /* system error */
145 AUTH *rpc_gss_seccreate(CLIENT *clnt, const char *principal,
146 const char *mechanism, rpc_gss_service_t service, const char *qop,
147 rpc_gss_options_req_t *options_req, rpc_gss_options_ret_t *options_ret);
148 bool_t rpc_gss_set_defaults(AUTH *auth, rpc_gss_service_t service,
150 int rpc_gss_max_data_length(AUTH *handle, int max_tp_unit_len);
151 void rpc_gss_get_error(rpc_gss_error_t *error);
153 bool_t rpc_gss_mech_to_oid(const char *mech, gss_OID *oid_ret);
154 bool_t rpc_gss_oid_to_mech(gss_OID oid, const char **mech_ret);
155 bool_t rpc_gss_qop_to_num(const char *qop, const char *mech, u_int *num_ret);
156 const char **rpc_gss_get_mechanisms(void);
157 const char **rpc_gss_get_mech_info(const char *mech, rpc_gss_service_t *service);
158 bool_t rpc_gss_get_versions(u_int *vers_hi, u_int *vers_lo);
159 bool_t rpc_gss_is_installed(const char *mech);
161 bool_t rpc_gss_set_svc_name(const char *principal, const char *mechanism,
162 u_int req_time, u_int program, u_int version);
163 bool_t rpc_gss_getcred(struct svc_req *req, rpc_gss_rawcred_t **rcred,
164 rpc_gss_ucred_t **ucred, void **cookie);
165 bool_t rpc_gss_set_callback(rpc_gss_callback_t *cb);
166 bool_t rpc_gss_get_principal_name(rpc_gss_principal_t *principal,
167 const char *mech, const char *name, const char *node, const char *domain);
168 int rpc_gss_svc_max_data_length(struct svc_req *req, int max_tp_unit_len);
171 * Internal interface from the RPC implementation.
173 bool_t __rpc_gss_wrap(AUTH *auth, void *header, size_t headerlen,
174 XDR* xdrs, xdrproc_t xdr_args, void *args_ptr);
175 bool_t __rpc_gss_unwrap(AUTH *auth, XDR* xdrs, xdrproc_t xdr_args,
177 bool_t __rpc_gss_set_error(int rpc_gss_error, int system_error);
181 #endif /* !_RPCSEC_GSS_H */