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