Whamcloud - gitweb
branch: HEAD
[fs/lustre-release.git] / lustre / ptlrpc / gss / gss_api.h
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  * Modifications for Lustre
5  *
6  * Copyright  2008 Sun Microsystems, Inc. All rights reserved
7  *
8  * Author: Eric Mei <ericm@clusterfs.com>
9  */
10
11 /*
12  * Somewhat simplified version of the gss api.
13  *
14  * Dug Song <dugsong@monkey.org>
15  * Andy Adamson <andros@umich.edu>
16  * Bruce Fields <bfields@umich.edu>
17  * Copyright (c) 2000 The Regents of the University of Michigan
18  *
19  */
20
21 #ifndef __PTLRPC_GSS_GSS_API_H_
22 #define __PTLRPC_GSS_GSS_API_H_
23
24 struct gss_api_mech;
25
26 /* The mechanism-independent gss-api context: */
27 struct gss_ctx {
28         struct gss_api_mech    *mech_type;
29         void                   *internal_ctx_id;
30 };
31
32 #define GSS_C_NO_BUFFER         ((rawobj_t) 0)
33 #define GSS_C_NO_CONTEXT        ((struct gss_ctx *) 0)
34 #define GSS_C_NULL_OID          ((rawobj_t) 0)
35
36 /*
37  * gss-api prototypes; note that these are somewhat simplified versions of
38  * the prototypes specified in RFC 2744.
39  */
40 __u32 lgss_import_sec_context(
41                 rawobj_t                *input_token,
42                 struct gss_api_mech     *mech,
43                 struct gss_ctx         **ctx);
44 __u32 lgss_copy_reverse_context(
45                 struct gss_ctx          *ctx,
46                 struct gss_ctx         **ctx_new);
47 __u32 lgss_inquire_context(
48                 struct gss_ctx          *ctx,
49                 unsigned long           *endtime);
50 __u32 lgss_get_mic(
51                 struct gss_ctx          *ctx,
52                 int                      msgcnt,
53                 rawobj_t                *msgs,
54                 int                      iovcnt,
55                 lnet_kiov_t             *iovs,
56                 rawobj_t                *mic_token);
57 __u32 lgss_verify_mic(
58                 struct gss_ctx          *ctx,
59                 int                      msgcnt,
60                 rawobj_t                *msgs,
61                 int                      iovcnt,
62                 lnet_kiov_t             *iovs,
63                 rawobj_t                *mic_token);
64 __u32 lgss_wrap(
65                 struct gss_ctx          *ctx,
66                 rawobj_t                *gsshdr,
67                 rawobj_t                *msg,
68                 int                      msg_buflen,
69                 rawobj_t                *out_token);
70 __u32 lgss_unwrap(
71                 struct gss_ctx          *ctx,
72                 rawobj_t                *gsshdr,
73                 rawobj_t                *token,
74                 rawobj_t                *out_msg);
75 __u32 lgss_prep_bulk(
76                 struct gss_ctx          *gctx,
77                 struct ptlrpc_bulk_desc *desc);
78 __u32 lgss_wrap_bulk(
79                 struct gss_ctx          *gctx,
80                 struct ptlrpc_bulk_desc *desc,
81                 rawobj_t                *token,
82                 int                      adj_nob);
83 __u32 lgss_unwrap_bulk(
84                 struct gss_ctx          *gctx,
85                 struct ptlrpc_bulk_desc *desc,
86                 rawobj_t                *token,
87                 int                      adj_nob);
88 __u32 lgss_delete_sec_context(
89                 struct gss_ctx         **ctx);
90 int lgss_display(
91                 struct gss_ctx          *ctx,
92                 char                    *buf,
93                 int                      bufsize);
94
95 struct subflavor_desc {
96         __u32           sf_subflavor;
97         __u32           sf_qop;
98         __u32           sf_service;
99         char           *sf_name;
100 };
101
102 /* Each mechanism is described by the following struct: */
103 struct gss_api_mech {
104         struct list_head        gm_list;
105         struct module          *gm_owner;
106         char                   *gm_name;
107         rawobj_t                gm_oid;
108         atomic_t                gm_count;
109         struct gss_api_ops     *gm_ops;
110         int                     gm_sf_num;
111         struct subflavor_desc  *gm_sfs;
112 };
113
114 /* and must provide the following operations: */
115 struct gss_api_ops {
116         __u32 (*gss_import_sec_context)(
117                         rawobj_t               *input_token,
118                         struct gss_ctx         *ctx);
119         __u32 (*gss_copy_reverse_context)(
120                         struct gss_ctx         *ctx,
121                         struct gss_ctx         *ctx_new);
122         __u32 (*gss_inquire_context)(
123                         struct gss_ctx         *ctx,
124                         unsigned long          *endtime);
125         __u32 (*gss_get_mic)(
126                         struct gss_ctx         *ctx,
127                         int                     msgcnt,
128                         rawobj_t               *msgs,
129                         int                     iovcnt,
130                         lnet_kiov_t            *iovs,
131                         rawobj_t               *mic_token);
132         __u32 (*gss_verify_mic)(
133                         struct gss_ctx         *ctx,
134                         int                     msgcnt,
135                         rawobj_t               *msgs,
136                         int                     iovcnt,
137                         lnet_kiov_t            *iovs,
138                         rawobj_t               *mic_token);
139         __u32 (*gss_wrap)(
140                         struct gss_ctx         *ctx,
141                         rawobj_t               *gsshdr,
142                         rawobj_t               *msg,
143                         int                     msg_buflen,
144                         rawobj_t               *out_token);
145         __u32 (*gss_unwrap)(
146                         struct gss_ctx         *ctx,
147                         rawobj_t               *gsshdr,
148                         rawobj_t               *token,
149                         rawobj_t               *out_msg);
150         __u32 (*gss_prep_bulk)(
151                         struct gss_ctx         *gctx,
152                         struct ptlrpc_bulk_desc *desc);
153         __u32 (*gss_wrap_bulk)(
154                         struct gss_ctx         *gctx,
155                         struct ptlrpc_bulk_desc *desc,
156                         rawobj_t               *token,
157                         int                     adj_nob);
158         __u32 (*gss_unwrap_bulk)(
159                         struct gss_ctx         *gctx,
160                         struct ptlrpc_bulk_desc *desc,
161                         rawobj_t               *token,
162                         int                     adj_nob);
163         void (*gss_delete_sec_context)(
164                         void                   *ctx);
165         int  (*gss_display)(
166                         struct gss_ctx         *ctx,
167                         char                   *buf,
168                         int                     bufsize);
169 };
170
171 int lgss_mech_register(struct gss_api_mech *mech);
172 void lgss_mech_unregister(struct gss_api_mech *mech);
173
174 struct gss_api_mech * lgss_OID_to_mech(rawobj_t *oid);
175 struct gss_api_mech * lgss_name_to_mech(char *name);
176 struct gss_api_mech * lgss_subflavor_to_mech(__u32 subflavor);
177
178 struct gss_api_mech * lgss_mech_get(struct gss_api_mech *mech);
179 void lgss_mech_put(struct gss_api_mech *mech);
180
181 #endif /* __PTLRPC_GSS_GSS_API_H_ */