blob: aba7687ca884555cd314ec579b174e1037460283 [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)
Linus Torvalds1da177e2005-04-16 15:20:36 -070028
29/*XXX arbitrary length - is this set somewhere? */
30#define GSS_OID_MAX_LEN 32
Chuck Leverfb15b262013-03-16 15:54:34 -040031struct rpcsec_gss_oid {
32 unsigned int len;
33 u8 data[GSS_OID_MAX_LEN];
34};
35
36/* From RFC 3530 */
37struct rpcsec_gss_info {
38 struct rpcsec_gss_oid oid;
39 u32 qop;
40 u32 service;
41};
Linus Torvalds1da177e2005-04-16 15:20:36 -070042
43/* gss-api prototypes; note that these are somewhat simplified versions of
44 * the prototypes specified in RFC 2744. */
45int gss_import_sec_context(
46 const void* input_token,
47 size_t bufsize,
48 struct gss_api_mech *mech,
Trond Myklebust1f4c86c2010-05-13 12:51:02 -040049 struct gss_ctx **ctx_id,
50 gfp_t gfp_mask);
Linus Torvalds1da177e2005-04-16 15:20:36 -070051u32 gss_get_mic(
52 struct gss_ctx *ctx_id,
Linus Torvalds1da177e2005-04-16 15:20:36 -070053 struct xdr_buf *message,
54 struct xdr_netobj *mic_token);
55u32 gss_verify_mic(
56 struct gss_ctx *ctx_id,
57 struct xdr_buf *message,
J. Bruce Fields00fd6e12005-10-13 16:55:18 -040058 struct xdr_netobj *mic_token);
J. Bruce Fields293f1eb2005-10-13 16:54:37 -040059u32 gss_wrap(
60 struct gss_ctx *ctx_id,
J. Bruce Fields293f1eb2005-10-13 16:54:37 -040061 int offset,
62 struct xdr_buf *outbuf,
63 struct page **inpages);
64u32 gss_unwrap(
65 struct gss_ctx *ctx_id,
J. Bruce Fields293f1eb2005-10-13 16:54:37 -040066 int offset,
67 struct xdr_buf *inbuf);
Linus Torvalds1da177e2005-04-16 15:20:36 -070068u32 gss_delete_sec_context(
69 struct gss_ctx **ctx_id);
70
Andy Adamsonc4170582007-07-17 04:04:42 -070071u32 gss_svc_to_pseudoflavor(struct gss_api_mech *, u32 service);
Linus Torvalds1da177e2005-04-16 15:20:36 -070072u32 gss_pseudoflavor_to_service(struct gss_api_mech *, u32 pseudoflavor);
73char *gss_service_to_auth_domain_name(struct gss_api_mech *, u32 service);
74
75struct pf_desc {
76 u32 pseudoflavor;
Linus Torvalds1da177e2005-04-16 15:20:36 -070077 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: */
86struct gss_api_mech {
87 struct list_head gm_list;
88 struct module *gm_owner;
Chuck Leverfb15b262013-03-16 15:54:34 -040089 struct rpcsec_gss_oid gm_oid;
Linus Torvalds1da177e2005-04-16 15:20:36 -070090 char *gm_name;
Trond Myklebustf1c0a862007-06-23 20:17:58 -040091 const struct gss_api_ops *gm_ops;
Linus Torvalds1da177e2005-04-16 15:20:36 -070092 /* pseudoflavors supported by this mechanism: */
93 int gm_pf_num;
94 struct pf_desc * gm_pfs;
Trond Myklebust683ac662010-04-08 14:09:58 -040095 /* Should the following be a callback operation instead? */
96 const char *gm_upcall_enctypes;
Linus Torvalds1da177e2005-04-16 15:20:36 -070097};
98
99/* and must provide the following operations: */
100struct gss_api_ops {
101 int (*gss_import_sec_context)(
102 const void *input_token,
103 size_t bufsize,
Trond Myklebust1f4c86c2010-05-13 12:51:02 -0400104 struct gss_ctx *ctx_id,
105 gfp_t gfp_mask);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700106 u32 (*gss_get_mic)(
107 struct gss_ctx *ctx_id,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700108 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,
J. Bruce Fields00fd6e12005-10-13 16:55:18 -0400113 struct xdr_netobj *mic_token);
J. Bruce Fields293f1eb2005-10-13 16:54:37 -0400114 u32 (*gss_wrap)(
115 struct gss_ctx *ctx_id,
J. Bruce Fields293f1eb2005-10-13 16:54:37 -0400116 int offset,
117 struct xdr_buf *outbuf,
118 struct page **inpages);
119 u32 (*gss_unwrap)(
120 struct gss_ctx *ctx_id,
J. Bruce Fields293f1eb2005-10-13 16:54:37 -0400121 int offset,
122 struct xdr_buf *buf);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700123 void (*gss_delete_sec_context)(
124 void *internal_ctx_id);
125};
126
127int gss_mech_register(struct gss_api_mech *);
128void gss_mech_unregister(struct gss_api_mech *);
129
Chuck Lever9568c5e2013-03-16 15:54:43 -0400130/* Given a GSS security tuple, look up a pseudoflavor */
131rpc_authflavor_t gss_mech_info2flavor(struct rpcsec_gss_info *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700132
133/* Returns a reference to a mechanism, given a name like "krb5" etc. */
134struct gss_api_mech *gss_mech_get_by_name(const char *);
135
136/* Similar, but get by pseudoflavor. */
137struct gss_api_mech *gss_mech_get_by_pseudoflavor(u32);
138
Bryan Schumaker8f70e952011-03-24 17:12:31 +0000139/* Fill in an array with a list of supported pseudoflavors */
Chuck Lever6a1a1e32012-07-11 16:31:08 -0400140int gss_mech_list_pseudoflavors(rpc_authflavor_t *, int);
Bryan Schumaker8f70e952011-03-24 17:12:31 +0000141
Linus Torvalds1da177e2005-04-16 15:20:36 -0700142/* Just increments the mechanism's reference count and returns its input: */
143struct gss_api_mech * gss_mech_get(struct gss_api_mech *);
144
Andreas Mohrd6e05ed2006-06-26 18:35:02 +0200145/* For every successful gss_mech_get or gss_mech_get_by_* call there must be a
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146 * corresponding call to gss_mech_put. */
147void gss_mech_put(struct gss_api_mech *);
148
149#endif /* __KERNEL__ */
150#endif /* _LINUX_SUNRPC_GSS_API_H */
151