Whamcloud - gitweb
b=16098
[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                 rawobj_t                *mic_token);
55 __u32 lgss_verify_mic(
56                 struct gss_ctx          *ctx,
57                 int                      msgcnt,
58                 rawobj_t                *msgs,
59                 rawobj_t                *mic_token);
60 __u32 lgss_wrap(
61                 struct gss_ctx          *ctx,
62                 rawobj_t                *gsshdr,
63                 rawobj_t                *msg,
64                 int                      msg_buflen,
65                 rawobj_t                *out_token);
66 __u32 lgss_unwrap(
67                 struct gss_ctx          *ctx,
68                 rawobj_t                *gsshdr,
69                 rawobj_t                *token,
70                 rawobj_t                *out_msg);
71 __u32 lgss_plain_encrypt(
72                 struct gss_ctx          *ctx,
73                 int                      decrypt,
74                 int                      length,
75                 void                    *in_buf,
76                 void                    *out_buf);
77 __u32 lgss_delete_sec_context(
78                 struct gss_ctx         **ctx);
79 int lgss_display(
80                 struct gss_ctx          *ctx,
81                 char                    *buf,
82                 int                      bufsize);
83
84 struct subflavor_desc {
85         __u32           sf_subflavor;
86         __u32           sf_qop;
87         __u32           sf_service;
88         char           *sf_name;
89 };
90
91 /* Each mechanism is described by the following struct: */
92 struct gss_api_mech {
93         struct list_head        gm_list;
94         struct module          *gm_owner;
95         char                   *gm_name;
96         rawobj_t                gm_oid;
97         atomic_t                gm_count;
98         struct gss_api_ops     *gm_ops;
99         int                     gm_sf_num;
100         struct subflavor_desc  *gm_sfs;
101 };
102
103 /* and must provide the following operations: */
104 struct gss_api_ops {
105         __u32 (*gss_import_sec_context)(
106                         rawobj_t               *input_token,
107                         struct gss_ctx         *ctx);
108         __u32 (*gss_copy_reverse_context)(
109                         struct gss_ctx         *ctx,
110                         struct gss_ctx         *ctx_new);
111         __u32 (*gss_inquire_context)(
112                         struct gss_ctx         *ctx,
113                         unsigned long          *endtime);
114         __u32 (*gss_get_mic)(
115                         struct gss_ctx         *ctx,
116                         int                     msgcnt,
117                         rawobj_t               *msgs,
118                         rawobj_t               *mic_token);
119         __u32 (*gss_verify_mic)(
120                         struct gss_ctx         *ctx,
121                         int                     msgcnt,
122                         rawobj_t               *msgs,
123                         rawobj_t               *mic_token);
124         __u32 (*gss_wrap)(
125                         struct gss_ctx         *ctx,
126                         rawobj_t               *gsshdr,
127                         rawobj_t               *msg,
128                         int                     msg_buflen,
129                         rawobj_t               *out_token);
130         __u32 (*gss_unwrap)(
131                         struct gss_ctx         *ctx,
132                         rawobj_t               *gsshdr,
133                         rawobj_t               *token,
134                         rawobj_t               *out_msg);
135         __u32 (*gss_plain_encrypt)(
136                         struct gss_ctx         *ctx,
137                         int                     decrypt,
138                         int                     length,
139                         void                   *in_buf,
140                         void                   *out_buf);
141         void (*gss_delete_sec_context)(
142                         void                   *ctx);
143         int  (*gss_display)(
144                         struct gss_ctx         *ctx,
145                         char                   *buf,
146                         int                     bufsize);
147 };
148
149 int lgss_mech_register(struct gss_api_mech *mech);
150 void lgss_mech_unregister(struct gss_api_mech *mech);
151
152 struct gss_api_mech * lgss_OID_to_mech(rawobj_t *oid);
153 struct gss_api_mech * lgss_name_to_mech(char *name);
154 struct gss_api_mech * lgss_subflavor_to_mech(__u32 subflavor);
155
156 struct gss_api_mech * lgss_mech_get(struct gss_api_mech *mech);
157 void lgss_mech_put(struct gss_api_mech *mech);
158
159 #endif /* __PTLRPC_GSS_GSS_API_H_ */