gss_get_mic.c revision 178828
1128080Semax/*-
2128080Semax * Copyright (c) 2005 Doug Rabson
3128080Semax * All rights reserved.
4162128Semax *
5162128Semax * Redistribution and use in source and binary forms, with or without
6162128Semax * modification, are permitted provided that the following conditions
7162128Semax * are met:
8128080Semax * 1. Redistributions of source code must retain the above copyright
9128080Semax *    notice, this list of conditions and the following disclaimer.
10128080Semax * 2. Redistributions in binary form must reproduce the above copyright
11128080Semax *    notice, this list of conditions and the following disclaimer in the
12128080Semax *    documentation and/or other materials provided with the distribution.
13128080Semax *
14128080Semax * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15128080Semax * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16128080Semax * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17128080Semax * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18128080Semax * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19128080Semax * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20128080Semax * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21128080Semax * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22128080Semax * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23128080Semax * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24128080Semax * SUCH DAMAGE.
25128080Semax *
26128080Semax *	$FreeBSD: head/lib/libgssapi/gss_get_mic.c 178828 2008-05-07 13:53:12Z dfr $
27128080Semax */
28128080Semax
29128080Semax#include <gssapi/gssapi.h>
30128080Semax
31162128Semax#include "mech_switch.h"
32128080Semax#include "context.h"
33128080Semax#include "utils.h"
34128080Semax
35128080SemaxOM_uint32
36128080Semaxgss_get_mic(OM_uint32 *minor_status,
37128080Semax    const gss_ctx_id_t context_handle,
38162128Semax    gss_qop_t qop_req,
39162128Semax    const gss_buffer_t message_buffer,
40250926Sjkim    gss_buffer_t message_token)
41250926Sjkim{
42128080Semax	struct _gss_context *ctx = (struct _gss_context *) context_handle;
43128080Semax	struct _gss_mech_switch *m = ctx->gc_mech;
44215676Sbrucec
45128080Semax	_gss_buffer_zero(message_token);
46128080Semax	if (ctx == NULL) {
47128080Semax		*minor_status = 0;
48128080Semax		return (GSS_S_NO_CONTEXT);
49128080Semax	}
50128080Semax
51128080Semax	return (m->gm_get_mic(minor_status, ctx->gc_ctx, qop_req,
52128080Semax		    message_buffer, message_token));
53128080Semax}
54128080Semax