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