2 * Copyright 1993 by OpenVision Technologies, Inc.
4 * Permission to use, copy, modify, distribute, and sell this software
5 * and its documentation for any purpose is hereby granted without fee,
6 * provided that the above copyright notice appears in all copies and
7 * that both that copyright notice and this permission notice appear in
8 * supporting documentation, and that the name of OpenVision not be used
9 * in advertising or publicity pertaining to distribution of the software
10 * without specific, written prior permission. OpenVision makes no
11 * representations about the suitability of this software for any
12 * purpose. It is provided "as is" without express or implied warranty.
14 * OPENVISION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
15 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
16 * EVENT SHALL OPENVISION BE LIABLE FOR ANY SPECIAL, INDIRECT OR
17 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
18 * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
19 * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
20 * PERFORMANCE OF THIS SOFTWARE.
23 #ifndef _GSSAPIP_GENERIC_H_
24 #define _GSSAPIP_GENERIC_H_
28 #include "gssapi_err_generic.h"
30 #include <sys/types.h>
34 #define g_OID_equal(o1,o2) \
35 (((o1)->length == (o2)->length) && \
36 (memcmp((o1)->elements,(o2)->elements,(int) (o1)->length) == 0))
38 /* this code knows that an int on the wire is 32 bits. The type of
39 num should be at least this big, or the extra shifts may do weird
42 #define TWRITE_INT(ptr, num, bigend) \
43 (ptr)[0] = (char) ((bigend)?((num)>>24):((num)&0xff)); \
44 (ptr)[1] = (char) ((bigend)?(((num)>>16)&0xff):(((num)>>8)&0xff)); \
45 (ptr)[2] = (char) ((bigend)?(((num)>>8)&0xff):(((num)>>16)&0xff)); \
46 (ptr)[3] = (char) ((bigend)?((num)&0xff):((num)>>24)); \
49 #define TREAD_INT(ptr, num, bigend) \
50 (num) = (((ptr)[0]<<((bigend)?24: 0)) | \
51 ((ptr)[1]<<((bigend)?16: 8)) | \
52 ((ptr)[2]<<((bigend)? 8:16)) | \
53 ((ptr)[3]<<((bigend)? 0:24))); \
56 #define TWRITE_STR(ptr, str, len) \
57 memcpy((ptr), (char *) (str), (len)); \
60 #define TREAD_STR(ptr, str, len) \
64 #define TWRITE_BUF(ptr, buf, bigend) \
65 TWRITE_INT((ptr), (buf).length, (bigend)); \
66 TWRITE_STR((ptr), (buf).value, (buf).length);
68 /** malloc wrappers; these may actually do something later */
70 #define xmalloc(n) malloc(n)
71 #define xrealloc(p,n) realloc(p,n)
75 #define xfree(p) free(p)
77 /** helper functions **/
79 int INTERFACE g_save_name PROTOTYPE((void **vdb, gss_name_t *name));
80 int INTERFACE g_save_cred_id PROTOTYPE((void **vdb, gss_cred_id_t *cred));
81 int INTERFACE g_save_ctx_id PROTOTYPE((void **vdb, gss_ctx_id_t *ctx));
83 int INTERFACE g_validate_name PROTOTYPE((void **vdb, gss_name_t *name));
84 int INTERFACE g_validate_cred_id PROTOTYPE((void **vdb, gss_cred_id_t *cred));
85 int INTERFACE g_validate_ctx_id PROTOTYPE((void **vdb, gss_ctx_id_t *ctx));
87 int INTERFACE g_delete_name PROTOTYPE((void **vdb, gss_name_t *name));
88 int INTERFACE g_delete_cred_id PROTOTYPE((void **vdb, gss_cred_id_t *cred));
89 int INTERFACE g_delete_ctx_id PROTOTYPE((void **vdb, gss_ctx_id_t *ctx));
91 int INTERFACE g_make_string_buffer PROTOTYPE((const char *str, gss_buffer_t buffer));
93 int INTERFACE g_copy_OID_set PROTOTYPE((const gss_OID_set_desc * const in, gss_OID_set *out));
95 int INTERFACE g_token_size PROTOTYPE((const_gss_OID mech, unsigned int body_size));
97 void INTERFACE g_make_token_header PROTOTYPE((const_gss_OID mech, int body_size,
98 unsigned char **buf, int tok_type));
100 int INTERFACE g_verify_token_header PROTOTYPE((const_gss_OID mech, int *body_size,
101 unsigned char **buf, int tok_type, int toksize));
103 OM_uint32 INTERFACE g_display_major_status PROTOTYPE((OM_uint32 *minor_status,
104 OM_uint32 status_value,
105 int *message_context,
106 gss_buffer_t status_string));
108 OM_uint32 INTERFACE INTERFACE g_display_com_err_status PROTOTYPE((OM_uint32 *minor_status,
109 OM_uint32 status_value,
110 gss_buffer_t status_string));
112 char * INTERFACE g_canonicalize_host PROTOTYPE((char *hostname));
114 char * INTERFACE g_strdup PROTOTYPE((char *str));
116 /** declarations of internal name mechanism functions **/
118 OM_uint32 INTERFACE generic_gss_release_buffer
119 PROTOTYPE( (OM_uint32*, /* minor_status */
120 gss_buffer_t /* buffer */
123 OM_uint32 INTERFACE generic_gss_release_oid_set
124 PROTOTYPE( (OM_uint32*, /* minor_status */
125 gss_OID_set* /* set */
128 #endif /* _GSSAPIP_GENERIC_H_ */