blob: 459c5fc11d5182c3c313e0b573e41817baa1652e [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Uwe Zeisbergerf30c2262006-10-03 23:01:26 +02002 * linux/include/linux/sunrpc/gss_api.h
Linus Torvalds1da177e2005-04-16 15:20:36 -07003 *
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: */
22struct 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. */
36int 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);
41u32 gss_get_mic(
42 struct gss_ctx *ctx_id,
Linus Torvalds1da177e2005-04-16 15:20:36 -070043 struct xdr_buf *message,
44 struct xdr_netobj *mic_token);
45u32 gss_verify_mic(
46 struct gss_ctx *ctx_id,
47 struct xdr_buf *message,
J. Bruce Fields00fd6e12005-10-13 16:55:18 -040048 struct xdr_netobj *mic_token);
J. Bruce Fields293f1eb2005-10-13 16:54:37 -040049u32 gss_wrap(
50 struct gss_ctx *ctx_id,
J. Bruce Fields293f1eb2005-10-13 16:54:37 -040051 int offset,
52 struct xdr_buf *outbuf,
53 struct page **inpages);
54u32 gss_unwrap(
55 struct gss_ctx *ctx_id,
J. Bruce Fields293f1eb2005-10-13 16:54:37 -040056 int offset,
57 struct xdr_buf *inbuf);
Linus Torvalds1da177e2005-04-16 15:20:36 -070058u32 gss_delete_sec_context(
59 struct gss_ctx **ctx_id);
60
Andy Adamsonc4170583f2007-07-17 04:04:42 -070061u32 gss_svc_to_pseudoflavor(struct gss_api_mech *, u32 service);
Linus Torvalds1da177e2005-04-16 15:20:36 -070062u32 gss_pseudoflavor_to_service(struct gss_api_mech *, u32 pseudoflavor);
63char *gss_service_to_auth_domain_name(struct gss_api_mech *, u32 service);
64
65struct pf_desc {
66 u32 pseudoflavor;
Linus Torvalds1da177e2005-04-16 15:20:36 -070067 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: */
76struct gss_api_mech {
77 struct list_head gm_list;
78 struct module *gm_owner;
79 struct xdr_netobj gm_oid;
80 char *gm_name;
Trond Myklebustf1c0a862007-06-23 20:17:58 -040081 const struct gss_api_ops *gm_ops;
Linus Torvalds1da177e2005-04-16 15:20:36 -070082 /* pseudoflavors supported by this mechanism: */
83 int gm_pf_num;
84 struct pf_desc * gm_pfs;
85};
86
87/* and must provide the following operations: */
88struct gss_api_ops {
89 int (*gss_import_sec_context)(
90 const void *input_token,
91 size_t bufsize,
92 struct gss_ctx *ctx_id);
93 u32 (*gss_get_mic)(
94 struct gss_ctx *ctx_id,
Linus Torvalds1da177e2005-04-16 15:20:36 -070095 struct xdr_buf *message,
96 struct xdr_netobj *mic_token);
97 u32 (*gss_verify_mic)(
98 struct gss_ctx *ctx_id,
99 struct xdr_buf *message,
J. Bruce Fields00fd6e12005-10-13 16:55:18 -0400100 struct xdr_netobj *mic_token);
J. Bruce Fields293f1eb2005-10-13 16:54:37 -0400101 u32 (*gss_wrap)(
102 struct gss_ctx *ctx_id,
J. Bruce Fields293f1eb2005-10-13 16:54:37 -0400103 int offset,
104 struct xdr_buf *outbuf,
105 struct page **inpages);
106 u32 (*gss_unwrap)(
107 struct gss_ctx *ctx_id,
J. Bruce Fields293f1eb2005-10-13 16:54:37 -0400108 int offset,
109 struct xdr_buf *buf);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700110 void (*gss_delete_sec_context)(
111 void *internal_ctx_id);
112};
113
114int gss_mech_register(struct gss_api_mech *);
115void gss_mech_unregister(struct gss_api_mech *);
116
117/* returns a mechanism descriptor given an OID, and increments the mechanism's
118 * reference count. */
119struct gss_api_mech * gss_mech_get_by_OID(struct xdr_netobj *);
120
121/* Returns a reference to a mechanism, given a name like "krb5" etc. */
122struct gss_api_mech *gss_mech_get_by_name(const char *);
123
124/* Similar, but get by pseudoflavor. */
125struct gss_api_mech *gss_mech_get_by_pseudoflavor(u32);
126
127/* Just increments the mechanism's reference count and returns its input: */
128struct gss_api_mech * gss_mech_get(struct gss_api_mech *);
129
Andreas Mohrd6e05ed2006-06-26 18:35:02 +0200130/* For every successful gss_mech_get or gss_mech_get_by_* call there must be a
Linus Torvalds1da177e2005-04-16 15:20:36 -0700131 * corresponding call to gss_mech_put. */
132void gss_mech_put(struct gss_api_mech *);
133
134#endif /* __KERNEL__ */
135#endif /* _LINUX_SUNRPC_GSS_API_H */
136