|
Packit |
fd8b60 |
/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
|
|
Packit |
fd8b60 |
/* tests/gssapi/common.h - Declarations for GSSAPI test utility functions */
|
|
Packit |
fd8b60 |
/*
|
|
Packit |
fd8b60 |
* Copyright (C) 2012 by the Massachusetts Institute of Technology.
|
|
Packit |
fd8b60 |
* All rights reserved.
|
|
Packit |
fd8b60 |
*
|
|
Packit |
fd8b60 |
* Redistribution and use in source and binary forms, with or without
|
|
Packit |
fd8b60 |
* modification, are permitted provided that the following conditions
|
|
Packit |
fd8b60 |
* are met:
|
|
Packit |
fd8b60 |
*
|
|
Packit |
fd8b60 |
* * Redistributions of source code must retain the above copyright
|
|
Packit |
fd8b60 |
* notice, this list of conditions and the following disclaimer.
|
|
Packit |
fd8b60 |
*
|
|
Packit |
fd8b60 |
* * Redistributions in binary form must reproduce the above copyright
|
|
Packit |
fd8b60 |
* notice, this list of conditions and the following disclaimer in
|
|
Packit |
fd8b60 |
* the documentation and/or other materials provided with the
|
|
Packit |
fd8b60 |
* distribution.
|
|
Packit |
fd8b60 |
*
|
|
Packit |
fd8b60 |
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
Packit |
fd8b60 |
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
Packit |
fd8b60 |
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
Packit |
fd8b60 |
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
Packit |
fd8b60 |
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
|
Packit |
fd8b60 |
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
Packit |
fd8b60 |
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
Packit |
fd8b60 |
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
Packit |
fd8b60 |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
Packit |
fd8b60 |
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
Packit |
fd8b60 |
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
|
Packit |
fd8b60 |
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
Packit |
fd8b60 |
*/
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
#ifndef COMMON_H
|
|
Packit |
fd8b60 |
#define COMMON_H
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
#include <gssapi/gssapi_krb5.h>
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
extern gss_OID_desc mech_krb5;
|
|
Packit |
fd8b60 |
extern gss_OID_desc mech_spnego;
|
|
Packit |
fd8b60 |
extern gss_OID_desc mech_iakerb;
|
|
Packit |
fd8b60 |
extern gss_OID_set_desc mechset_krb5;
|
|
Packit |
fd8b60 |
extern gss_OID_set_desc mechset_spnego;
|
|
Packit |
fd8b60 |
extern gss_OID_set_desc mechset_iakerb;
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
/* Display an error message (containing msg) and exit if major is an error. */
|
|
Packit |
fd8b60 |
void check_gsserr(const char *msg, OM_uint32 major, OM_uint32 minor);
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
/* Display an error message (containing msg) and exit if code is an error. */
|
|
Packit |
fd8b60 |
void check_k5err(krb5_context context, const char *msg, krb5_error_code code);
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
/* Display an error message containing msg and exit. */
|
|
Packit |
fd8b60 |
void errout(const char *msg);
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
/* Import a GSSAPI name based on a string of the form 'u:username',
|
|
Packit |
fd8b60 |
* 'p:principalname', or 'h:host@service' (or just 'h:service'). */
|
|
Packit |
fd8b60 |
gss_name_t import_name(const char *str);
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
/* Establish contexts using gss_init_sec_context and gss_accept_sec_context. */
|
|
Packit |
fd8b60 |
void establish_contexts(gss_OID imech, gss_cred_id_t icred,
|
|
Packit |
fd8b60 |
gss_cred_id_t acred, gss_name_t tname, OM_uint32 flags,
|
|
Packit |
fd8b60 |
gss_ctx_id_t *ictx, gss_ctx_id_t *actx,
|
|
Packit |
fd8b60 |
gss_name_t *src_name, gss_OID *amech,
|
|
Packit |
fd8b60 |
gss_cred_id_t *deleg_cred);
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
/* Export *cred to a token, then release *cred and replace it by re-importing
|
|
Packit |
fd8b60 |
* the token. */
|
|
Packit |
fd8b60 |
void export_import_cred(gss_cred_id_t *cred);
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
/* Display name as canonicalized to mech, preceded by tag. */
|
|
Packit |
fd8b60 |
void display_canon_name(const char *tag, gss_name_t name, gss_OID mech);
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
/* Display oid in printable form, preceded by tag (if not NULL). */
|
|
Packit |
fd8b60 |
void display_oid(const char *tag, gss_OID oid);
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
/* Display attributes of name, including hex value if noisy is true. */
|
|
Packit |
fd8b60 |
void enumerate_attributes(gss_name_t name, int noisy);
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
/* Display the contents of buf to fp in hex, followed by a newline. */
|
|
Packit |
fd8b60 |
void print_hex(FILE *fp, gss_buffer_t buf);
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
#endif /* COMMON_H */
|