Commit | Line | Data |
---|---|---|
1da177e4 | 1 | /* |
f30c2269 | 2 | * linux/include/linux/sunrpc/gss_api.h |
1da177e4 LT |
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 | |
1da177e4 LT |
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> | |
6a1a1e34 | 17 | #include <linux/sunrpc/msg_prot.h> |
1da177e4 LT |
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 | #define GSS_C_NULL_OID ((struct xdr_netobj) 0) | |
29 | ||
30 | /*XXX arbitrary length - is this set somewhere? */ | |
31 | #define GSS_OID_MAX_LEN 32 | |
32 | ||
33 | /* gss-api prototypes; note that these are somewhat simplified versions of | |
34 | * the prototypes specified in RFC 2744. */ | |
35 | int gss_import_sec_context( | |
36 | const void* input_token, | |
37 | size_t bufsize, | |
38 | struct gss_api_mech *mech, | |
1f4c86c0 TM |
39 | struct gss_ctx **ctx_id, |
40 | gfp_t gfp_mask); | |
1da177e4 LT |
41 | u32 gss_get_mic( |
42 | struct gss_ctx *ctx_id, | |
1da177e4 LT |
43 | struct xdr_buf *message, |
44 | struct xdr_netobj *mic_token); | |
45 | u32 gss_verify_mic( | |
46 | struct gss_ctx *ctx_id, | |
47 | struct xdr_buf *message, | |
00fd6e14 | 48 | struct xdr_netobj *mic_token); |
293f1eb5 BF |
49 | u32 gss_wrap( |
50 | struct gss_ctx *ctx_id, | |
293f1eb5 BF |
51 | int offset, |
52 | struct xdr_buf *outbuf, | |
53 | struct page **inpages); | |
54 | u32 gss_unwrap( | |
55 | struct gss_ctx *ctx_id, | |
293f1eb5 BF |
56 | int offset, |
57 | struct xdr_buf *inbuf); | |
1da177e4 LT |
58 | u32 gss_delete_sec_context( |
59 | struct gss_ctx **ctx_id); | |
60 | ||
c4170583 | 61 | u32 gss_svc_to_pseudoflavor(struct gss_api_mech *, u32 service); |
1da177e4 LT |
62 | u32 gss_pseudoflavor_to_service(struct gss_api_mech *, u32 pseudoflavor); |
63 | char *gss_service_to_auth_domain_name(struct gss_api_mech *, u32 service); | |
64 | ||
65 | struct pf_desc { | |
66 | u32 pseudoflavor; | |
1da177e4 LT |
67 | u32 service; |
68 | char *name; | |
69 | char *auth_domain_name; | |
70 | }; | |
71 | ||
72 | /* Different mechanisms (e.g., krb5 or spkm3) may implement gss-api, and | |
73 | * mechanisms may be dynamically registered or unregistered by modules. */ | |
74 | ||
75 | /* Each mechanism is described by the following struct: */ | |
76 | struct gss_api_mech { | |
77 | struct list_head gm_list; | |
78 | struct module *gm_owner; | |
79 | struct xdr_netobj gm_oid; | |
80 | char *gm_name; | |
f1c0a861 | 81 | const struct gss_api_ops *gm_ops; |
1da177e4 LT |
82 | /* pseudoflavors supported by this mechanism: */ |
83 | int gm_pf_num; | |
84 | struct pf_desc * gm_pfs; | |
683ac665 TM |
85 | /* Should the following be a callback operation instead? */ |
86 | const char *gm_upcall_enctypes; | |
1da177e4 LT |
87 | }; |
88 | ||
89 | /* and must provide the following operations: */ | |
90 | struct gss_api_ops { | |
91 | int (*gss_import_sec_context)( | |
92 | const void *input_token, | |
93 | size_t bufsize, | |
1f4c86c0 TM |
94 | struct gss_ctx *ctx_id, |
95 | gfp_t gfp_mask); | |
1da177e4 LT |
96 | u32 (*gss_get_mic)( |
97 | struct gss_ctx *ctx_id, | |
1da177e4 LT |
98 | struct xdr_buf *message, |
99 | struct xdr_netobj *mic_token); | |
100 | u32 (*gss_verify_mic)( | |
101 | struct gss_ctx *ctx_id, | |
102 | struct xdr_buf *message, | |
00fd6e14 | 103 | struct xdr_netobj *mic_token); |
293f1eb5 BF |
104 | u32 (*gss_wrap)( |
105 | struct gss_ctx *ctx_id, | |
293f1eb5 BF |
106 | int offset, |
107 | struct xdr_buf *outbuf, | |
108 | struct page **inpages); | |
109 | u32 (*gss_unwrap)( | |
110 | struct gss_ctx *ctx_id, | |
293f1eb5 BF |
111 | int offset, |
112 | struct xdr_buf *buf); | |
1da177e4 LT |
113 | void (*gss_delete_sec_context)( |
114 | void *internal_ctx_id); | |
115 | }; | |
116 | ||
117 | int gss_mech_register(struct gss_api_mech *); | |
118 | void gss_mech_unregister(struct gss_api_mech *); | |
119 | ||
120 | /* returns a mechanism descriptor given an OID, and increments the mechanism's | |
121 | * reference count. */ | |
122 | struct gss_api_mech * gss_mech_get_by_OID(struct xdr_netobj *); | |
123 | ||
124 | /* Returns a reference to a mechanism, given a name like "krb5" etc. */ | |
125 | struct gss_api_mech *gss_mech_get_by_name(const char *); | |
126 | ||
127 | /* Similar, but get by pseudoflavor. */ | |
128 | struct gss_api_mech *gss_mech_get_by_pseudoflavor(u32); | |
129 | ||
8f70e95f | 130 | /* Fill in an array with a list of supported pseudoflavors */ |
6a1a1e34 | 131 | int gss_mech_list_pseudoflavors(rpc_authflavor_t *, int); |
8f70e95f | 132 | |
1da177e4 LT |
133 | /* Just increments the mechanism's reference count and returns its input: */ |
134 | struct gss_api_mech * gss_mech_get(struct gss_api_mech *); | |
135 | ||
d6e05edc | 136 | /* For every successful gss_mech_get or gss_mech_get_by_* call there must be a |
1da177e4 LT |
137 | * corresponding call to gss_mech_put. */ |
138 | void gss_mech_put(struct gss_api_mech *); | |
139 | ||
140 | #endif /* __KERNEL__ */ | |
141 | #endif /* _LINUX_SUNRPC_GSS_API_H */ | |
142 |