Whamcloud - gitweb
land b_colibri_devel on 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  * Copyright 2004, Cluster File Systems, Inc.
6  * All rights reserved
7  * Author: Eric Mei <ericm@clusterfs.com>
8  */
9
10 /*
11  * Somewhat simplified version of the gss api.
12  *
13  * Dug Song <dugsong@monkey.org>
14  * Andy Adamson <andros@umich.edu>
15  * Bruce Fields <bfields@umich.edu>
16  * Copyright (c) 2000 The Regents of the University of Michigan
17  *
18  */
19
20 #ifndef __PTLRPC_GSS_GSS_API_H_
21 #define __PTLRPC_GSS_GSS_API_H_
22
23 struct gss_api_mech;
24
25 /* The mechanism-independent gss-api context: */
26 struct gss_ctx {
27         struct gss_api_mech    *mech_type;
28         void                   *internal_ctx_id;
29 };
30
31 #define GSS_C_NO_BUFFER         ((rawobj_t) 0)
32 #define GSS_C_NO_CONTEXT        ((struct gss_ctx *) 0)
33 #define GSS_C_NULL_OID          ((rawobj_t) 0)
34
35 /*
36  * gss-api prototypes; note that these are somewhat simplified versions of
37  * the prototypes specified in RFC 2744.
38  */
39 __u32 lgss_import_sec_context(
40                 rawobj_t                *input_token,
41                 struct gss_api_mech     *mech,
42                 struct gss_ctx         **ctx);
43 __u32 lgss_copy_reverse_context(
44                 struct gss_ctx          *ctx,
45                 struct gss_ctx         **ctx_new);
46 __u32 lgss_inquire_context(
47                 struct gss_ctx          *ctx,
48                 unsigned long           *endtime);
49 __u32 lgss_get_mic(
50                 struct gss_ctx          *ctx,
51                 int                      msgcnt,
52                 rawobj_t                *msgs,
53                 rawobj_t                *mic_token);
54 __u32 lgss_verify_mic(
55                 struct gss_ctx          *ctx,
56                 int                      msgcnt,
57                 rawobj_t                *msgs,
58                 rawobj_t                *mic_token);
59 __u32 lgss_wrap(
60                 struct gss_ctx          *ctx,
61                 rawobj_t                *msg,
62                 int                      msg_buflen,
63                 rawobj_t                *out_token);
64 __u32 lgss_unwrap(
65                 struct gss_ctx          *ctx,
66                 rawobj_t                *token,
67                 rawobj_t                *out_msg);
68 __u32 lgss_plain_encrypt(
69                 struct gss_ctx          *ctx,
70                 int                      decrypt,
71                 int                      length,
72                 void                    *in_buf,
73                 void                    *out_buf);
74 __u32 lgss_delete_sec_context(
75                 struct gss_ctx         **ctx);
76 int lgss_display(
77                 struct gss_ctx          *ctx,
78                 char                    *buf,
79                 int                      bufsize);
80
81 struct subflavor_desc {
82         __u32           sf_subflavor;
83         __u32           sf_qop;
84         __u32           sf_service;
85         char           *sf_name;
86 };
87
88 /* Each mechanism is described by the following struct: */
89 struct gss_api_mech {
90         struct list_head        gm_list;
91         struct module          *gm_owner;
92         char                   *gm_name;
93         rawobj_t                gm_oid;
94         atomic_t                gm_count;
95         struct gss_api_ops     *gm_ops;
96         int                     gm_sf_num;
97         struct subflavor_desc  *gm_sfs;
98 };
99
100 /* and must provide the following operations: */
101 struct gss_api_ops {
102         __u32 (*gss_import_sec_context)(
103                         rawobj_t               *input_token,
104                         struct gss_ctx         *ctx);
105         __u32 (*gss_copy_reverse_context)(
106                         struct gss_ctx         *ctx,
107                         struct gss_ctx         *ctx_new);
108         __u32 (*gss_inquire_context)(
109                         struct gss_ctx         *ctx,
110                         unsigned long          *endtime);
111         __u32 (*gss_get_mic)(
112                         struct gss_ctx         *ctx,
113                         int                     msgcnt,
114                         rawobj_t               *msgs,
115                         rawobj_t               *mic_token);
116         __u32 (*gss_verify_mic)(
117                         struct gss_ctx         *ctx,
118                         int                     msgcnt,
119                         rawobj_t               *msgs,
120                         rawobj_t               *mic_token);
121         __u32 (*gss_wrap)(
122                         struct gss_ctx         *ctx,
123                         rawobj_t               *msg,
124                         int                     msg_buflen,
125                         rawobj_t               *out_token);
126         __u32 (*gss_unwrap)(
127                         struct gss_ctx         *ctx,
128                         rawobj_t               *token,
129                         rawobj_t               *out_msg);
130         __u32 (*gss_plain_encrypt)(
131                         struct gss_ctx         *ctx,
132                         int                     decrypt,
133                         int                     length,
134                         void                   *in_buf,
135                         void                   *out_buf);
136         void (*gss_delete_sec_context)(
137                         void                   *ctx);
138         int  (*gss_display)(
139                         struct gss_ctx         *ctx,
140                         char                   *buf,
141                         int                     bufsize);
142 };
143
144 int lgss_mech_register(struct gss_api_mech *mech);
145 void lgss_mech_unregister(struct gss_api_mech *mech);
146
147 struct gss_api_mech * lgss_OID_to_mech(rawobj_t *oid);
148 struct gss_api_mech * lgss_name_to_mech(char *name);
149 struct gss_api_mech * lgss_subflavor_to_mech(__u32 subflavor);
150
151 struct gss_api_mech * lgss_mech_get(struct gss_api_mech *mech);
152 void lgss_mech_put(struct gss_api_mech *mech);
153
154 #endif /* __PTLRPC_GSS_GSS_API_H_ */