1 /* SPDX-License-Identifier: GPL-2.0 */
3 * linux/include/linux/sunrpc/gss_api.h
5 * Somewhat simplified version of the gss api.
7 * Dug Song <dugsong@monkey.org>
8 * Andy Adamson <andros@umich.edu>
9 * Bruce Fields <bfields@umich.edu>
10 * Copyright (c) 2000 The Regents of the University of Michigan
13 #ifndef _LINUX_SUNRPC_GSS_API_H
14 #define _LINUX_SUNRPC_GSS_API_H
17 #include <linux/sunrpc/xdr.h>
18 #include <linux/sunrpc/msg_prot.h>
19 #include <linux/uio.h>
21 /* The mechanism-independent gss-api context: */
23 struct gss_api_mech
*mech_type
;
24 void *internal_ctx_id
;
27 #define GSS_C_NO_BUFFER ((struct xdr_netobj) 0)
28 #define GSS_C_NO_CONTEXT ((struct gss_ctx *) 0)
29 #define GSS_C_QOP_DEFAULT (0)
31 /*XXX arbitrary length - is this set somewhere? */
32 #define GSS_OID_MAX_LEN 32
33 struct rpcsec_gss_oid
{
35 u8 data
[GSS_OID_MAX_LEN
];
39 struct rpcsec_gss_info
{
40 struct rpcsec_gss_oid oid
;
45 /* gss-api prototypes; note that these are somewhat simplified versions of
46 * the prototypes specified in RFC 2744. */
47 int gss_import_sec_context(
48 const void* input_token
,
50 struct gss_api_mech
*mech
,
51 struct gss_ctx
**ctx_id
,
55 struct gss_ctx
*ctx_id
,
56 struct xdr_buf
*message
,
57 struct xdr_netobj
*mic_token
);
59 struct gss_ctx
*ctx_id
,
60 struct xdr_buf
*message
,
61 struct xdr_netobj
*mic_token
);
63 struct gss_ctx
*ctx_id
,
65 struct xdr_buf
*outbuf
,
66 struct page
**inpages
);
68 struct gss_ctx
*ctx_id
,
70 struct xdr_buf
*inbuf
);
71 u32
gss_delete_sec_context(
72 struct gss_ctx
**ctx_id
);
74 rpc_authflavor_t
gss_svc_to_pseudoflavor(struct gss_api_mech
*, u32 qop
,
76 u32
gss_pseudoflavor_to_service(struct gss_api_mech
*, u32 pseudoflavor
);
77 bool gss_pseudoflavor_to_datatouch(struct gss_api_mech
*, u32 pseudoflavor
);
78 char *gss_service_to_auth_domain_name(struct gss_api_mech
*, u32 service
);
85 char *auth_domain_name
;
89 /* Different mechanisms (e.g., krb5 or spkm3) may implement gss-api, and
90 * mechanisms may be dynamically registered or unregistered by modules. */
92 /* Each mechanism is described by the following struct: */
94 struct list_head gm_list
;
95 struct module
*gm_owner
;
96 struct rpcsec_gss_oid gm_oid
;
98 const struct gss_api_ops
*gm_ops
;
99 /* pseudoflavors supported by this mechanism: */
101 struct pf_desc
* gm_pfs
;
102 /* Should the following be a callback operation instead? */
103 const char *gm_upcall_enctypes
;
106 /* and must provide the following operations: */
108 int (*gss_import_sec_context
)(
109 const void *input_token
,
111 struct gss_ctx
*ctx_id
,
115 struct gss_ctx
*ctx_id
,
116 struct xdr_buf
*message
,
117 struct xdr_netobj
*mic_token
);
118 u32 (*gss_verify_mic
)(
119 struct gss_ctx
*ctx_id
,
120 struct xdr_buf
*message
,
121 struct xdr_netobj
*mic_token
);
123 struct gss_ctx
*ctx_id
,
125 struct xdr_buf
*outbuf
,
126 struct page
**inpages
);
128 struct gss_ctx
*ctx_id
,
130 struct xdr_buf
*buf
);
131 void (*gss_delete_sec_context
)(
132 void *internal_ctx_id
);
135 int gss_mech_register(struct gss_api_mech
*);
136 void gss_mech_unregister(struct gss_api_mech
*);
138 /* returns a mechanism descriptor given an OID, and increments the mechanism's
139 * reference count. */
140 struct gss_api_mech
* gss_mech_get_by_OID(struct rpcsec_gss_oid
*);
142 /* Given a GSS security tuple, look up a pseudoflavor */
143 rpc_authflavor_t
gss_mech_info2flavor(struct rpcsec_gss_info
*);
145 /* Given a pseudoflavor, look up a GSS security tuple */
146 int gss_mech_flavor2info(rpc_authflavor_t
, struct rpcsec_gss_info
*);
148 /* Returns a reference to a mechanism, given a name like "krb5" etc. */
149 struct gss_api_mech
*gss_mech_get_by_name(const char *);
151 /* Similar, but get by pseudoflavor. */
152 struct gss_api_mech
*gss_mech_get_by_pseudoflavor(u32
);
154 /* Fill in an array with a list of supported pseudoflavors */
155 int gss_mech_list_pseudoflavors(rpc_authflavor_t
*, int);
157 struct gss_api_mech
* gss_mech_get(struct gss_api_mech
*);
159 /* For every successful gss_mech_get or gss_mech_get_by_* call there must be a
160 * corresponding call to gss_mech_put. */
161 void gss_mech_put(struct gss_api_mech
*);
163 #endif /* __KERNEL__ */
164 #endif /* _LINUX_SUNRPC_GSS_API_H */