Path: blob/main/crypto/krb5/src/tests/gssapi/common.h
34907 views
/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */1/* tests/gssapi/common.h - Declarations for GSSAPI test utility functions */2/*3* Copyright (C) 2012 by the Massachusetts Institute of Technology.4* All rights reserved.5*6* Redistribution and use in source and binary forms, with or without7* modification, are permitted provided that the following conditions8* are met:9*10* * Redistributions of source code must retain the above copyright11* notice, this list of conditions and the following disclaimer.12*13* * Redistributions in binary form must reproduce the above copyright14* notice, this list of conditions and the following disclaimer in15* the documentation and/or other materials provided with the16* distribution.17*18* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS19* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT20* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS21* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE22* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,23* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES24* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR25* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)26* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,27* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)28* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED29* OF THE POSSIBILITY OF SUCH DAMAGE.30*/3132#ifndef COMMON_H33#define COMMON_H3435#include <gssapi/gssapi_krb5.h>3637extern gss_OID_desc mech_krb5;38extern gss_OID_desc mech_spnego;39extern gss_OID_desc mech_iakerb;40extern gss_OID_set_desc mechset_krb5;41extern gss_OID_set_desc mechset_spnego;42extern gss_OID_set_desc mechset_iakerb;4344/* Display an error message (containing msg) and exit if major is an error. */45void check_gsserr(const char *msg, OM_uint32 major, OM_uint32 minor);4647/* Display an error message (containing msg) and exit if code is an error. */48void check_k5err(krb5_context context, const char *msg, krb5_error_code code);4950/* Display an error message containing msg and exit. */51void errout(const char *msg);5253/* Import a GSSAPI name based on a string of the form 'u:username',54* 'p:principalname', or 'h:host@service' (or just 'h:service'). */55gss_name_t import_name(const char *str);5657/* Establish contexts using gss_init_sec_context and gss_accept_sec_context. */58void establish_contexts(gss_OID imech, gss_cred_id_t icred,59gss_cred_id_t acred, gss_name_t tname, OM_uint32 flags,60gss_ctx_id_t *ictx, gss_ctx_id_t *actx,61gss_name_t *src_name, gss_OID *amech,62gss_cred_id_t *deleg_cred);6364/* Establish contexts with channel bindings. */65void establish_contexts_ex(gss_OID imech, gss_cred_id_t icred,66gss_cred_id_t acred, gss_name_t tname,67OM_uint32 flags, gss_ctx_id_t *ictx,68gss_ctx_id_t *actx, gss_channel_bindings_t icb,69gss_channel_bindings_t acb, OM_uint32 *aret_flags,70gss_name_t *src_name, gss_OID *amech,71gss_cred_id_t *deleg_cred);7273/* Export *cred to a token, then release *cred and replace it by re-importing74* the token. */75void export_import_cred(gss_cred_id_t *cred);7677/* Display name as canonicalized to mech, preceded by tag. */78void display_canon_name(const char *tag, gss_name_t name, gss_OID mech);7980/* Display oid in printable form, preceded by tag (if not NULL). */81void display_oid(const char *tag, gss_OID oid);8283/* Display attributes of name, including hex value if noisy is true. */84void enumerate_attributes(gss_name_t name, int noisy);8586/* Display the contents of buf to fp in hex, followed by a newline. */87void print_hex(FILE *fp, gss_buffer_t buf);8889#endif /* COMMON_H */909192