Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-src
Path: blob/main/crypto/krb5/src/tests/gssapi/common.h
34907 views
1
/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
/* tests/gssapi/common.h - Declarations for GSSAPI test utility functions */
3
/*
4
* Copyright (C) 2012 by the Massachusetts Institute of Technology.
5
* All rights reserved.
6
*
7
* Redistribution and use in source and binary forms, with or without
8
* modification, are permitted provided that the following conditions
9
* are met:
10
*
11
* * Redistributions of source code must retain the above copyright
12
* notice, this list of conditions and the following disclaimer.
13
*
14
* * Redistributions in binary form must reproduce the above copyright
15
* notice, this list of conditions and the following disclaimer in
16
* the documentation and/or other materials provided with the
17
* distribution.
18
*
19
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
22
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
23
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
24
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
28
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
30
* OF THE POSSIBILITY OF SUCH DAMAGE.
31
*/
32
33
#ifndef COMMON_H
34
#define COMMON_H
35
36
#include <gssapi/gssapi_krb5.h>
37
38
extern gss_OID_desc mech_krb5;
39
extern gss_OID_desc mech_spnego;
40
extern gss_OID_desc mech_iakerb;
41
extern gss_OID_set_desc mechset_krb5;
42
extern gss_OID_set_desc mechset_spnego;
43
extern gss_OID_set_desc mechset_iakerb;
44
45
/* Display an error message (containing msg) and exit if major is an error. */
46
void check_gsserr(const char *msg, OM_uint32 major, OM_uint32 minor);
47
48
/* Display an error message (containing msg) and exit if code is an error. */
49
void check_k5err(krb5_context context, const char *msg, krb5_error_code code);
50
51
/* Display an error message containing msg and exit. */
52
void errout(const char *msg);
53
54
/* Import a GSSAPI name based on a string of the form 'u:username',
55
* 'p:principalname', or 'h:host@service' (or just 'h:service'). */
56
gss_name_t import_name(const char *str);
57
58
/* Establish contexts using gss_init_sec_context and gss_accept_sec_context. */
59
void establish_contexts(gss_OID imech, gss_cred_id_t icred,
60
gss_cred_id_t acred, gss_name_t tname, OM_uint32 flags,
61
gss_ctx_id_t *ictx, gss_ctx_id_t *actx,
62
gss_name_t *src_name, gss_OID *amech,
63
gss_cred_id_t *deleg_cred);
64
65
/* Establish contexts with channel bindings. */
66
void establish_contexts_ex(gss_OID imech, gss_cred_id_t icred,
67
gss_cred_id_t acred, gss_name_t tname,
68
OM_uint32 flags, gss_ctx_id_t *ictx,
69
gss_ctx_id_t *actx, gss_channel_bindings_t icb,
70
gss_channel_bindings_t acb, OM_uint32 *aret_flags,
71
gss_name_t *src_name, gss_OID *amech,
72
gss_cred_id_t *deleg_cred);
73
74
/* Export *cred to a token, then release *cred and replace it by re-importing
75
* the token. */
76
void export_import_cred(gss_cred_id_t *cred);
77
78
/* Display name as canonicalized to mech, preceded by tag. */
79
void display_canon_name(const char *tag, gss_name_t name, gss_OID mech);
80
81
/* Display oid in printable form, preceded by tag (if not NULL). */
82
void display_oid(const char *tag, gss_OID oid);
83
84
/* Display attributes of name, including hex value if noisy is true. */
85
void enumerate_attributes(gss_name_t name, int noisy);
86
87
/* Display the contents of buf to fp in hex, followed by a newline. */
88
void print_hex(FILE *fp, gss_buffer_t buf);
89
90
#endif /* COMMON_H */
91
92