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 __u32 lgss_delete_sec_context(
88                 struct gss_ctx         **ctx);
89 int lgss_display(
90                 struct gss_ctx          *ctx,
91                 char                    *buf,
92                 int                      bufsize);
93
94 struct subflavor_desc {
95         __u32           sf_subflavor;
96         __u32           sf_qop;
97         __u32           sf_service;
98         char           *sf_name;
99 };
100
101 /* Each mechanism is described by the following struct: */
102 struct gss_api_mech {
103         struct list_head        gm_list;
104         struct module          *gm_owner;
105         char                   *gm_name;
106         rawobj_t                gm_oid;
107         atomic_t                gm_count;
108         struct gss_api_ops     *gm_ops;
109         int                     gm_sf_num;
110         struct subflavor_desc  *gm_sfs;
111 };
112
113 /* and must provide the following operations: */
114 struct gss_api_ops {
115         __u32 (*gss_import_sec_context)(
116                         rawobj_t               *input_token,
117                         struct gss_ctx         *ctx);
118         __u32 (*gss_copy_reverse_context)(
119                         struct gss_ctx         *ctx,
120                         struct gss_ctx         *ctx_new);
121         __u32 (*gss_inquire_context)(
122                         struct gss_ctx         *ctx,
123                         unsigned long          *endtime);
124         __u32 (*gss_get_mic)(
125                         struct gss_ctx         *ctx,
126                         int                     msgcnt,
127                         rawobj_t               *msgs,
128                         int                     iovcnt,
129                         lnet_kiov_t            *iovs,
130                         rawobj_t               *mic_token);
131         __u32 (*gss_verify_mic)(
132                         struct gss_ctx         *ctx,
133                         int                     msgcnt,
134                         rawobj_t               *msgs,
135                         int                     iovcnt,
136                         lnet_kiov_t            *iovs,
137                         rawobj_t               *mic_token);
138         __u32 (*gss_wrap)(
139                         struct gss_ctx         *ctx,
140                         rawobj_t               *gsshdr,
141                         rawobj_t               *msg,
142                         int                     msg_buflen,
143                         rawobj_t               *out_token);
144         __u32 (*gss_unwrap)(
145                         struct gss_ctx         *ctx,
146                         rawobj_t               *gsshdr,
147                         rawobj_t               *token,
148                         rawobj_t               *out_msg);
149         __u32 (*gss_prep_bulk)(
150                         struct gss_ctx         *gctx,
151                         struct ptlrpc_bulk_desc *desc);
152         __u32 (*gss_wrap_bulk)(
153                         struct gss_ctx         *gctx,
154                         struct ptlrpc_bulk_desc *desc,
155                         rawobj_t               *token,
156                         int                     adj_nob);
157         __u32 (*gss_unwrap_bulk)(
158                         struct gss_ctx         *gctx,
159                         struct ptlrpc_bulk_desc *desc,
160                         rawobj_t               *token);
161         void (*gss_delete_sec_context)(
162                         void                   *ctx);
163         int  (*gss_display)(
164                         struct gss_ctx         *ctx,
165                         char                   *buf,
166                         int                     bufsize);
167 };
168
169 int lgss_mech_register(struct gss_api_mech *mech);
170 void lgss_mech_unregister(struct gss_api_mech *mech);
171
172 struct gss_api_mech * lgss_OID_to_mech(rawobj_t *oid);
173 struct gss_api_mech * lgss_name_to_mech(char *name);
174 struct gss_api_mech * lgss_subflavor_to_mech(__u32 subflavor);
175
176 struct gss_api_mech * lgss_mech_get(struct gss_api_mech *mech);
177 void lgss_mech_put(struct gss_api_mech *mech);
178
179 #endif /* __PTLRPC_GSS_GSS_API_H_ */