xref: /curl/tests/libtest/stub_gssapi.h (revision 2bc1d775)
1 #ifndef HEADER_CURL_GSSAPI_STUBS_H
2 #define HEADER_CURL_GSSAPI_STUBS_H
3 /***************************************************************************
4  *                                  _   _ ____  _
5  *  Project                     ___| | | |  _ \| |
6  *                             / __| | | | |_) | |
7  *                            | (__| |_| |  _ <| |___
8  *                             \___|\___/|_| \_\_____|
9  *
10  * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
11  *
12  * This software is licensed as described in the file COPYING, which
13  * you should have received as part of this distribution. The terms
14  * are also available at https://curl.se/docs/copyright.html.
15  *
16  * You may opt to use, copy, modify, merge, publish, distribute and/or sell
17  * copies of the Software, and permit persons to whom the Software is
18  * furnished to do so, under the terms of the COPYING file.
19  *
20  * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
21  * KIND, either express or implied.
22  *
23  * SPDX-License-Identifier: curl
24  *
25  ***************************************************************************/
26 
27 /* Roughly based on Heimdal's gssapi.h */
28 
29 #include <stdint.h>
30 #include <stddef.h>
31 
32 #define GSS_ERROR(status) (status & 0x80000000)
33 
34 #define GSS_S_COMPLETE 0
35 #define GSS_S_FAILURE (0x80000000)
36 #define GSS_S_CONTINUE_NEEDED (1ul)
37 
38 #define GSS_C_QOP_DEFAULT 0
39 #define GSS_C_NO_OID ((gss_OID) 0)
40 #define GSS_C_NO_NAME ((gss_name_t) 0)
41 #define GSS_C_NO_BUFFER ((gss_buffer_t) 0)
42 #define GSS_C_NO_CONTEXT ((gss_ctx_id_t) 0)
43 #define GSS_C_NO_CREDENTIAL ((gss_cred_id_t) 0)
44 #define GSS_C_NO_CHANNEL_BINDINGS ((gss_channel_bindings_t) 0)
45 
46 #define GSS_C_NULL_OID GSS_C_NO_OID
47 
48 #define GSS_C_EMPTY_BUFFER {0, NULL}
49 
50 #define GSS_C_AF_INET 2
51 
52 #define GSS_C_GSS_CODE 1
53 #define GSS_C_MECH_CODE 2
54 
55 #define GSS_C_DELEG_FLAG 1
56 #define GSS_C_MUTUAL_FLAG 2
57 #define GSS_C_REPLAY_FLAG 4
58 #define GSS_C_CONF_FLAG 16
59 #define GSS_C_INTEG_FLAG 32
60 
61 /*
62  * Expiration time of 2^32-1 seconds means infinite lifetime for a
63  * credential or security context
64  */
65 #define GSS_C_INDEFINITE 0xfffffffful
66 
67 #define GSS_C_NT_HOSTBASED_SERVICE NULL
68 
69 typedef uint32_t OM_uint32;
70 
71 typedef OM_uint32 gss_qop_t;
72 
73 typedef struct gss_buffer_desc_struct {
74   size_t length;
75   void *value;
76 } gss_buffer_desc, *gss_buffer_t;
77 
78 struct gss_cred_id_t_desc_struct;
79 typedef struct gss_cred_id_t_desc_struct *gss_cred_id_t;
80 typedef const struct gss_cred_id_t_desc_struct *gss_const_cred_id_t;
81 
82 struct gss_ctx_id_t_desc_struct;
83 typedef struct gss_ctx_id_t_desc_struct *gss_ctx_id_t;
84 typedef const struct gss_ctx_id_t_desc_struct *gss_const_ctx_id_t;
85 
86 struct gss_name_t_desc_struct;
87 typedef struct gss_name_t_desc_struct *gss_name_t;
88 typedef const struct gss_name_t_desc_struct *gss_const_name_t;
89 
90 typedef struct gss_OID_desc_struct {
91   OM_uint32 length;
92   void      *elements;
93 } gss_OID_desc, *gss_OID;
94 
95 typedef struct gss_channel_bindings_struct {
96   OM_uint32 initiator_addrtype;
97   gss_buffer_desc initiator_address;
98   OM_uint32 acceptor_addrtype;
99   gss_buffer_desc acceptor_address;
100   gss_buffer_desc application_data;
101 } *gss_channel_bindings_t;
102 
103 OM_uint32 gss_release_buffer(OM_uint32 * /* minor_status */,
104                              gss_buffer_t /* buffer */);
105 
106 OM_uint32 gss_init_sec_context(OM_uint32 * /* minor_status */,
107             gss_const_cred_id_t /* initiator_cred_handle */,
108             gss_ctx_id_t * /* context_handle */,
109             gss_const_name_t /* target_name */,
110             const gss_OID /* mech_type */,
111             OM_uint32 /* req_flags */,
112             OM_uint32 /* time_req */,
113             const gss_channel_bindings_t /* input_chan_bindings */,
114             const gss_buffer_t /* input_token */,
115             gss_OID * /* actual_mech_type */,
116             gss_buffer_t /* output_token */,
117             OM_uint32 * /* ret_flags */,
118             OM_uint32 * /* time_rec */);
119 
120 OM_uint32 gss_delete_sec_context(OM_uint32 * /* minor_status */,
121                                  gss_ctx_id_t * /* context_handle */,
122                                  gss_buffer_t /* output_token */);
123 
124 OM_uint32 gss_inquire_context(OM_uint32 * /* minor_status */,
125                               gss_const_ctx_id_t /* context_handle */,
126                               gss_name_t * /* src_name */,
127                               gss_name_t * /* targ_name */,
128                               OM_uint32 * /* lifetime_rec */,
129                               gss_OID * /* mech_type */,
130                               OM_uint32 * /* ctx_flags */,
131                               int * /* locally_initiated */,
132                               int * /* open_context */);
133 
134 OM_uint32 gss_wrap(OM_uint32 * /* minor_status */,
135                    gss_const_ctx_id_t /* context_handle */,
136                    int /* conf_req_flag */,
137                    gss_qop_t /* qop_req */,
138                    const gss_buffer_t /* input_message_buffer */,
139                    int * /* conf_state */,
140                    gss_buffer_t /* output_message_buffer */);
141 
142 OM_uint32 gss_unwrap(OM_uint32 * /* minor_status */,
143                      gss_const_ctx_id_t /* context_handle */,
144                      const gss_buffer_t /* input_message_buffer */,
145                      gss_buffer_t /* output_message_buffer */,
146                      int * /* conf_state */,
147                      gss_qop_t * /* qop_state */);
148 
149 OM_uint32 gss_seal(OM_uint32 * /* minor_status */,
150                    gss_ctx_id_t /* context_handle n */,
151                    int /* conf_req_flag */,
152                    int /* qop_req */,
153                    gss_buffer_t /* input_message_buffer */,
154                    int * /* conf_state */,
155                    gss_buffer_t /* output_message_buffer */);
156 
157 OM_uint32 gss_unseal(OM_uint32 * /* minor_status */,
158                      gss_ctx_id_t /* context_handle */,
159                      gss_buffer_t /* input_message_buffer */,
160                      gss_buffer_t /* output_message_buffer */,
161                      int * /* conf_state */,
162                      int * /* qop_state */);
163 
164 OM_uint32 gss_import_name(OM_uint32 * /* minor_status */,
165                           const gss_buffer_t /* input_name_buffer */,
166                           const gss_OID /* input_name_type */,
167                           gss_name_t * /* output_name */);
168 
169 OM_uint32 gss_release_name(OM_uint32 * /* minor_status */,
170                            gss_name_t * /* input_name */);
171 
172 OM_uint32 gss_display_name(OM_uint32 * /* minor_status */,
173                            gss_const_name_t /* input_name */,
174                            gss_buffer_t /* output_name_buffer */,
175                            gss_OID * /* output_name_type */);
176 
177 OM_uint32 gss_display_status(OM_uint32 * /* minor_status */,
178                              OM_uint32 /* status_value */,
179                              int /* status_type */,
180                              const gss_OID /* mech_type */,
181                              OM_uint32 * /* message_context */,
182                              gss_buffer_t /* status_string */);
183 
184 #endif /* HEADER_CURL_GSSAPI_STUBS_H */
185