• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * linux/include/linux/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  * $Id$
12  */
13 
14 #ifndef _LINUX_SUNRPC_GSS_API_H
15 #define _LINUX_SUNRPC_GSS_API_H
16 
17 #ifdef __KERNEL__
18 #include <linux/sunrpc/xdr.h>
19 #include <linux/uio.h>
20 
21 /* The mechanism-independent gss-api context: */
22 struct gss_ctx {
23 	struct gss_api_mech	*mech_type;
24 	void			*internal_ctx_id;
25 };
26 
27 #define GSS_C_NO_BUFFER		((struct xdr_netobj) 0)
28 #define GSS_C_NO_CONTEXT	((struct gss_ctx *) 0)
29 #define GSS_C_NULL_OID		((struct xdr_netobj) 0)
30 
31 /*XXX  arbitrary length - is this set somewhere? */
32 #define GSS_OID_MAX_LEN 32
33 
34 /* gss-api prototypes; note that these are somewhat simplified versions of
35  * the prototypes specified in RFC 2744. */
36 int gss_import_sec_context(
37 		const void*		input_token,
38 		size_t			bufsize,
39 		struct gss_api_mech	*mech,
40 		struct gss_ctx		**ctx_id);
41 u32 gss_get_mic(
42 		struct gss_ctx		*ctx_id,
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,
48 		struct xdr_netobj	*mic_token);
49 u32 gss_wrap(
50 		struct gss_ctx		*ctx_id,
51 		int			offset,
52 		struct xdr_buf		*outbuf,
53 		struct page		**inpages);
54 u32 gss_unwrap(
55 		struct gss_ctx		*ctx_id,
56 		int			offset,
57 		struct xdr_buf		*inbuf);
58 u32 gss_delete_sec_context(
59 		struct gss_ctx		**ctx_id);
60 
61 u32 gss_pseudoflavor_to_service(struct gss_api_mech *, u32 pseudoflavor);
62 char *gss_service_to_auth_domain_name(struct gss_api_mech *, u32 service);
63 
64 struct pf_desc {
65 	u32	pseudoflavor;
66 	u32	service;
67 	char	*name;
68 	char	*auth_domain_name;
69 };
70 
71 /* Different mechanisms (e.g., krb5 or spkm3) may implement gss-api, and
72  * mechanisms may be dynamically registered or unregistered by modules. */
73 
74 /* Each mechanism is described by the following struct: */
75 struct gss_api_mech {
76 	struct list_head	gm_list;
77 	struct module		*gm_owner;
78 	struct xdr_netobj	gm_oid;
79 	char			*gm_name;
80 	struct gss_api_ops	*gm_ops;
81 	/* pseudoflavors supported by this mechanism: */
82 	int			gm_pf_num;
83 	struct pf_desc *	gm_pfs;
84 };
85 
86 /* and must provide the following operations: */
87 struct gss_api_ops {
88 	int (*gss_import_sec_context)(
89 			const void		*input_token,
90 			size_t			bufsize,
91 			struct gss_ctx		*ctx_id);
92 	u32 (*gss_get_mic)(
93 			struct gss_ctx		*ctx_id,
94 			struct xdr_buf		*message,
95 			struct xdr_netobj	*mic_token);
96 	u32 (*gss_verify_mic)(
97 			struct gss_ctx		*ctx_id,
98 			struct xdr_buf		*message,
99 			struct xdr_netobj	*mic_token);
100 	u32 (*gss_wrap)(
101 			struct gss_ctx		*ctx_id,
102 			int			offset,
103 			struct xdr_buf		*outbuf,
104 			struct page		**inpages);
105 	u32 (*gss_unwrap)(
106 			struct gss_ctx		*ctx_id,
107 			int			offset,
108 			struct xdr_buf		*buf);
109 	void (*gss_delete_sec_context)(
110 			void			*internal_ctx_id);
111 };
112 
113 int gss_mech_register(struct gss_api_mech *);
114 void gss_mech_unregister(struct gss_api_mech *);
115 
116 /* returns a mechanism descriptor given an OID, and increments the mechanism's
117  * reference count. */
118 struct gss_api_mech * gss_mech_get_by_OID(struct xdr_netobj *);
119 
120 /* Returns a reference to a mechanism, given a name like "krb5" etc. */
121 struct gss_api_mech *gss_mech_get_by_name(const char *);
122 
123 /* Similar, but get by pseudoflavor. */
124 struct gss_api_mech *gss_mech_get_by_pseudoflavor(u32);
125 
126 /* Just increments the mechanism's reference count and returns its input: */
127 struct gss_api_mech * gss_mech_get(struct gss_api_mech *);
128 
129 /* For every successful gss_mech_get or gss_mech_get_by_* call there must be a
130  * corresponding call to gss_mech_put. */
131 void gss_mech_put(struct gss_api_mech *);
132 
133 #endif /* __KERNEL__ */
134 #endif /* _LINUX_SUNRPC_GSS_API_H */
135 
136