blob: 68ec78c1aa48e1ec3e4b285420a69732a2b05c6a [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
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 */
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>
Chuck Lever6a1a1e32012-07-11 16:31:08 -040017#include <linux/sunrpc/msg_prot.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070018#include <linux/uio.h>
19
20/* The mechanism-independent gss-api context: */
21struct 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)
Chuck Lever83523d02013-03-16 15:55:01 -040028#define GSS_C_QOP_DEFAULT (0)
Linus Torvalds1da177e2005-04-16 15:20:36 -070029
30/*XXX arbitrary length - is this set somewhere? */
31#define GSS_OID_MAX_LEN 32
Chuck Leverfb15b262013-03-16 15:54:34 -040032struct rpcsec_gss_oid {
33 unsigned int len;
34 u8 data[GSS_OID_MAX_LEN];
35};
36
37/* From RFC 3530 */
38struct rpcsec_gss_info {
39 struct rpcsec_gss_oid oid;
40 u32 qop;
41 u32 service;
42};
Linus Torvalds1da177e2005-04-16 15:20:36 -070043
44/* gss-api prototypes; note that these are somewhat simplified versions of
45 * the prototypes specified in RFC 2744. */
46int gss_import_sec_context(
47 const void* input_token,
48 size_t bufsize,
49 struct gss_api_mech *mech,
Trond Myklebust1f4c86c2010-05-13 12:51:02 -040050 struct gss_ctx **ctx_id,
Simo Sorce400f26b2012-05-25 18:09:53 -040051 time_t *endtime,
Trond Myklebust1f4c86c2010-05-13 12:51:02 -040052 gfp_t gfp_mask);
Linus Torvalds1da177e2005-04-16 15:20:36 -070053u32 gss_get_mic(
54 struct gss_ctx *ctx_id,
Linus Torvalds1da177e2005-04-16 15:20:36 -070055 struct xdr_buf *message,
56 struct xdr_netobj *mic_token);
57u32 gss_verify_mic(
58 struct gss_ctx *ctx_id,
59 struct xdr_buf *message,
J. Bruce Fields00fd6e12005-10-13 16:55:18 -040060 struct xdr_netobj *mic_token);
J. Bruce Fields293f1eb2005-10-13 16:54:37 -040061u32 gss_wrap(
62 struct gss_ctx *ctx_id,
J. Bruce Fields293f1eb2005-10-13 16:54:37 -040063 int offset,
64 struct xdr_buf *outbuf,
65 struct page **inpages);
66u32 gss_unwrap(
67 struct gss_ctx *ctx_id,
J. Bruce Fields293f1eb2005-10-13 16:54:37 -040068 int offset,
69 struct xdr_buf *inbuf);
Linus Torvalds1da177e2005-04-16 15:20:36 -070070u32 gss_delete_sec_context(
71 struct gss_ctx **ctx_id);
72
Chuck Lever83523d02013-03-16 15:55:01 -040073rpc_authflavor_t gss_svc_to_pseudoflavor(struct gss_api_mech *, u32 qop,
74 u32 service);
Linus Torvalds1da177e2005-04-16 15:20:36 -070075u32 gss_pseudoflavor_to_service(struct gss_api_mech *, u32 pseudoflavor);
Chuck Lever65b80172016-06-29 13:55:06 -040076bool gss_pseudoflavor_to_datatouch(struct gss_api_mech *, u32 pseudoflavor);
Linus Torvalds1da177e2005-04-16 15:20:36 -070077char *gss_service_to_auth_domain_name(struct gss_api_mech *, u32 service);
78
79struct pf_desc {
80 u32 pseudoflavor;
Chuck Lever83523d02013-03-16 15:55:01 -040081 u32 qop;
Linus Torvalds1da177e2005-04-16 15:20:36 -070082 u32 service;
83 char *name;
84 char *auth_domain_name;
Chuck Lever65b80172016-06-29 13:55:06 -040085 bool datatouch;
Linus Torvalds1da177e2005-04-16 15:20:36 -070086};
87
88/* Different mechanisms (e.g., krb5 or spkm3) may implement gss-api, and
89 * mechanisms may be dynamically registered or unregistered by modules. */
90
91/* Each mechanism is described by the following struct: */
92struct gss_api_mech {
93 struct list_head gm_list;
94 struct module *gm_owner;
Chuck Leverfb15b262013-03-16 15:54:34 -040095 struct rpcsec_gss_oid gm_oid;
Linus Torvalds1da177e2005-04-16 15:20:36 -070096 char *gm_name;
Trond Myklebustf1c0a862007-06-23 20:17:58 -040097 const struct gss_api_ops *gm_ops;
Linus Torvalds1da177e2005-04-16 15:20:36 -070098 /* pseudoflavors supported by this mechanism: */
99 int gm_pf_num;
100 struct pf_desc * gm_pfs;
Trond Myklebust683ac662010-04-08 14:09:58 -0400101 /* Should the following be a callback operation instead? */
102 const char *gm_upcall_enctypes;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103};
104
105/* and must provide the following operations: */
106struct gss_api_ops {
107 int (*gss_import_sec_context)(
108 const void *input_token,
109 size_t bufsize,
Trond Myklebust1f4c86c2010-05-13 12:51:02 -0400110 struct gss_ctx *ctx_id,
Simo Sorce400f26b2012-05-25 18:09:53 -0400111 time_t *endtime,
Trond Myklebust1f4c86c2010-05-13 12:51:02 -0400112 gfp_t gfp_mask);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700113 u32 (*gss_get_mic)(
114 struct gss_ctx *ctx_id,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115 struct xdr_buf *message,
116 struct xdr_netobj *mic_token);
117 u32 (*gss_verify_mic)(
118 struct gss_ctx *ctx_id,
119 struct xdr_buf *message,
J. Bruce Fields00fd6e12005-10-13 16:55:18 -0400120 struct xdr_netobj *mic_token);
J. Bruce Fields293f1eb2005-10-13 16:54:37 -0400121 u32 (*gss_wrap)(
122 struct gss_ctx *ctx_id,
J. Bruce Fields293f1eb2005-10-13 16:54:37 -0400123 int offset,
124 struct xdr_buf *outbuf,
125 struct page **inpages);
126 u32 (*gss_unwrap)(
127 struct gss_ctx *ctx_id,
J. Bruce Fields293f1eb2005-10-13 16:54:37 -0400128 int offset,
129 struct xdr_buf *buf);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700130 void (*gss_delete_sec_context)(
131 void *internal_ctx_id);
132};
133
134int gss_mech_register(struct gss_api_mech *);
135void gss_mech_unregister(struct gss_api_mech *);
136
137/* returns a mechanism descriptor given an OID, and increments the mechanism's
138 * reference count. */
J. Bruce Fieldsb1df7632013-04-29 14:03:30 -0400139struct gss_api_mech * gss_mech_get_by_OID(struct rpcsec_gss_oid *);
140
Chuck Lever9568c5e2013-03-16 15:54:43 -0400141/* Given a GSS security tuple, look up a pseudoflavor */
142rpc_authflavor_t gss_mech_info2flavor(struct rpcsec_gss_info *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700143
Chuck Levera77c8062013-03-16 15:55:10 -0400144/* Given a pseudoflavor, look up a GSS security tuple */
145int gss_mech_flavor2info(rpc_authflavor_t, struct rpcsec_gss_info *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146
147/* Returns a reference to a mechanism, given a name like "krb5" etc. */
148struct gss_api_mech *gss_mech_get_by_name(const char *);
149
150/* Similar, but get by pseudoflavor. */
151struct gss_api_mech *gss_mech_get_by_pseudoflavor(u32);
152
Bryan Schumaker8f70e952011-03-24 17:12:31 +0000153/* Fill in an array with a list of supported pseudoflavors */
Chuck Lever6a1a1e32012-07-11 16:31:08 -0400154int gss_mech_list_pseudoflavors(rpc_authflavor_t *, int);
Bryan Schumaker8f70e952011-03-24 17:12:31 +0000155
J. Bruce Fields0dc15312013-05-14 16:07:13 -0400156struct gss_api_mech * gss_mech_get(struct gss_api_mech *);
157
Andreas Mohrd6e05ed2006-06-26 18:35:02 +0200158/* For every successful gss_mech_get or gss_mech_get_by_* call there must be a
Linus Torvalds1da177e2005-04-16 15:20:36 -0700159 * corresponding call to gss_mech_put. */
160void gss_mech_put(struct gss_api_mech *);
161
162#endif /* __KERNEL__ */
163#endif /* _LINUX_SUNRPC_GSS_API_H */
164