SUNRPC: Define rpcsec_gss_info structure
[firefly-linux-kernel-4.4.55.git] / include / linux / sunrpc / gss_api.h
1 /*
2  * linux/include/linux/sunrpc/gss_api.h
3  *
4  * Somewhat simplified version of the gss api.
5  *
6  * Dug Song <dugsong@monkey.org>
7  * Andy Adamson <andros@umich.edu>
8  * Bruce Fields <bfields@umich.edu>
9  * Copyright (c) 2000 The Regents of the University of Michigan
10  */
11
12 #ifndef _LINUX_SUNRPC_GSS_API_H
13 #define _LINUX_SUNRPC_GSS_API_H
14
15 #ifdef __KERNEL__
16 #include <linux/sunrpc/xdr.h>
17 #include <linux/sunrpc/msg_prot.h>
18 #include <linux/uio.h>
19
20 /* The mechanism-independent gss-api context: */
21 struct gss_ctx {
22         struct gss_api_mech     *mech_type;
23         void                    *internal_ctx_id;
24 };
25
26 #define GSS_C_NO_BUFFER         ((struct xdr_netobj) 0)
27 #define GSS_C_NO_CONTEXT        ((struct gss_ctx *) 0)
28
29 /*XXX  arbitrary length - is this set somewhere? */
30 #define GSS_OID_MAX_LEN 32
31 struct rpcsec_gss_oid {
32         unsigned int    len;
33         u8              data[GSS_OID_MAX_LEN];
34 };
35
36 /* From RFC 3530 */
37 struct rpcsec_gss_info {
38         struct rpcsec_gss_oid   oid;
39         u32                     qop;
40         u32                     service;
41 };
42
43 /* gss-api prototypes; note that these are somewhat simplified versions of
44  * the prototypes specified in RFC 2744. */
45 int gss_import_sec_context(
46                 const void*             input_token,
47                 size_t                  bufsize,
48                 struct gss_api_mech     *mech,
49                 struct gss_ctx          **ctx_id,
50                 gfp_t                   gfp_mask);
51 u32 gss_get_mic(
52                 struct gss_ctx          *ctx_id,
53                 struct xdr_buf          *message,
54                 struct xdr_netobj       *mic_token);
55 u32 gss_verify_mic(
56                 struct gss_ctx          *ctx_id,
57                 struct xdr_buf          *message,
58                 struct xdr_netobj       *mic_token);
59 u32 gss_wrap(
60                 struct gss_ctx          *ctx_id,
61                 int                     offset,
62                 struct xdr_buf          *outbuf,
63                 struct page             **inpages);
64 u32 gss_unwrap(
65                 struct gss_ctx          *ctx_id,
66                 int                     offset,
67                 struct xdr_buf          *inbuf);
68 u32 gss_delete_sec_context(
69                 struct gss_ctx          **ctx_id);
70
71 u32 gss_svc_to_pseudoflavor(struct gss_api_mech *, u32 service);
72 u32 gss_pseudoflavor_to_service(struct gss_api_mech *, u32 pseudoflavor);
73 char *gss_service_to_auth_domain_name(struct gss_api_mech *, u32 service);
74
75 struct pf_desc {
76         u32     pseudoflavor;
77         u32     service;
78         char    *name;
79         char    *auth_domain_name;
80 };
81
82 /* Different mechanisms (e.g., krb5 or spkm3) may implement gss-api, and
83  * mechanisms may be dynamically registered or unregistered by modules. */
84
85 /* Each mechanism is described by the following struct: */
86 struct gss_api_mech {
87         struct list_head        gm_list;
88         struct module           *gm_owner;
89         struct rpcsec_gss_oid   gm_oid;
90         char                    *gm_name;
91         const struct gss_api_ops *gm_ops;
92         /* pseudoflavors supported by this mechanism: */
93         int                     gm_pf_num;
94         struct pf_desc *        gm_pfs;
95         /* Should the following be a callback operation instead? */
96         const char              *gm_upcall_enctypes;
97 };
98
99 /* and must provide the following operations: */
100 struct gss_api_ops {
101         int (*gss_import_sec_context)(
102                         const void              *input_token,
103                         size_t                  bufsize,
104                         struct gss_ctx          *ctx_id,
105                         gfp_t                   gfp_mask);
106         u32 (*gss_get_mic)(
107                         struct gss_ctx          *ctx_id,
108                         struct xdr_buf          *message,
109                         struct xdr_netobj       *mic_token);
110         u32 (*gss_verify_mic)(
111                         struct gss_ctx          *ctx_id,
112                         struct xdr_buf          *message,
113                         struct xdr_netobj       *mic_token);
114         u32 (*gss_wrap)(
115                         struct gss_ctx          *ctx_id,
116                         int                     offset,
117                         struct xdr_buf          *outbuf,
118                         struct page             **inpages);
119         u32 (*gss_unwrap)(
120                         struct gss_ctx          *ctx_id,
121                         int                     offset,
122                         struct xdr_buf          *buf);
123         void (*gss_delete_sec_context)(
124                         void                    *internal_ctx_id);
125 };
126
127 int gss_mech_register(struct gss_api_mech *);
128 void gss_mech_unregister(struct gss_api_mech *);
129
130 /* returns a mechanism descriptor given an OID, and increments the mechanism's
131  * reference count. */
132 struct gss_api_mech * gss_mech_get_by_OID(struct xdr_netobj *);
133
134 /* Returns a reference to a mechanism, given a name like "krb5" etc. */
135 struct gss_api_mech *gss_mech_get_by_name(const char *);
136
137 /* Similar, but get by pseudoflavor. */
138 struct gss_api_mech *gss_mech_get_by_pseudoflavor(u32);
139
140 /* Fill in an array with a list of supported pseudoflavors */
141 int gss_mech_list_pseudoflavors(rpc_authflavor_t *, int);
142
143 /* Just increments the mechanism's reference count and returns its input: */
144 struct gss_api_mech * gss_mech_get(struct gss_api_mech *);
145
146 /* For every successful gss_mech_get or gss_mech_get_by_* call there must be a
147  * corresponding call to gss_mech_put. */
148 void gss_mech_put(struct gss_api_mech *);
149
150 #endif /* __KERNEL__ */
151 #endif /* _LINUX_SUNRPC_GSS_API_H */
152