1*7f2fe78bSCy Schubert /* #pragma ident "@(#)g_seal.c 1.19 98/04/21 SMI" */
2*7f2fe78bSCy Schubert
3*7f2fe78bSCy Schubert /*
4*7f2fe78bSCy Schubert * Copyright 1996 by Sun Microsystems, Inc.
5*7f2fe78bSCy Schubert *
6*7f2fe78bSCy Schubert * Permission to use, copy, modify, distribute, and sell this software
7*7f2fe78bSCy Schubert * and its documentation for any purpose is hereby granted without fee,
8*7f2fe78bSCy Schubert * provided that the above copyright notice appears in all copies and
9*7f2fe78bSCy Schubert * that both that copyright notice and this permission notice appear in
10*7f2fe78bSCy Schubert * supporting documentation, and that the name of Sun Microsystems not be used
11*7f2fe78bSCy Schubert * in advertising or publicity pertaining to distribution of the software
12*7f2fe78bSCy Schubert * without specific, written prior permission. Sun Microsystems makes no
13*7f2fe78bSCy Schubert * representations about the suitability of this software for any
14*7f2fe78bSCy Schubert * purpose. It is provided "as is" without express or implied warranty.
15*7f2fe78bSCy Schubert *
16*7f2fe78bSCy Schubert * SUN MICROSYSTEMS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
17*7f2fe78bSCy Schubert * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
18*7f2fe78bSCy Schubert * EVENT SHALL SUN MICROSYSTEMS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
19*7f2fe78bSCy Schubert * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
20*7f2fe78bSCy Schubert * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
21*7f2fe78bSCy Schubert * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
22*7f2fe78bSCy Schubert * PERFORMANCE OF THIS SOFTWARE.
23*7f2fe78bSCy Schubert */
24*7f2fe78bSCy Schubert
25*7f2fe78bSCy Schubert /*
26*7f2fe78bSCy Schubert * glue routine for gss_unwrap_iov
27*7f2fe78bSCy Schubert */
28*7f2fe78bSCy Schubert
29*7f2fe78bSCy Schubert #include "mglueP.h"
30*7f2fe78bSCy Schubert
31*7f2fe78bSCy Schubert static OM_uint32
val_unwrap_iov_args(OM_uint32 * minor_status,gss_ctx_id_t context_handle,int * conf_state,gss_qop_t * qop_state,gss_iov_buffer_desc * iov,int iov_count)32*7f2fe78bSCy Schubert val_unwrap_iov_args(
33*7f2fe78bSCy Schubert OM_uint32 *minor_status,
34*7f2fe78bSCy Schubert gss_ctx_id_t context_handle,
35*7f2fe78bSCy Schubert int *conf_state,
36*7f2fe78bSCy Schubert gss_qop_t *qop_state,
37*7f2fe78bSCy Schubert gss_iov_buffer_desc *iov,
38*7f2fe78bSCy Schubert int iov_count)
39*7f2fe78bSCy Schubert {
40*7f2fe78bSCy Schubert
41*7f2fe78bSCy Schubert /* Initialize outputs. */
42*7f2fe78bSCy Schubert
43*7f2fe78bSCy Schubert if (minor_status != NULL)
44*7f2fe78bSCy Schubert *minor_status = 0;
45*7f2fe78bSCy Schubert
46*7f2fe78bSCy Schubert /* Validate arguments. */
47*7f2fe78bSCy Schubert
48*7f2fe78bSCy Schubert if (minor_status == NULL)
49*7f2fe78bSCy Schubert return (GSS_S_CALL_INACCESSIBLE_WRITE);
50*7f2fe78bSCy Schubert
51*7f2fe78bSCy Schubert if (context_handle == GSS_C_NO_CONTEXT)
52*7f2fe78bSCy Schubert return (GSS_S_CALL_INACCESSIBLE_READ | GSS_S_NO_CONTEXT);
53*7f2fe78bSCy Schubert
54*7f2fe78bSCy Schubert if (iov == GSS_C_NO_IOV_BUFFER)
55*7f2fe78bSCy Schubert return (GSS_S_CALL_INACCESSIBLE_READ);
56*7f2fe78bSCy Schubert
57*7f2fe78bSCy Schubert return (GSS_S_COMPLETE);
58*7f2fe78bSCy Schubert }
59*7f2fe78bSCy Schubert
60*7f2fe78bSCy Schubert
61*7f2fe78bSCy Schubert OM_uint32 KRB5_CALLCONV
gss_unwrap_iov(minor_status,context_handle,conf_state,qop_state,iov,iov_count)62*7f2fe78bSCy Schubert gss_unwrap_iov (minor_status,
63*7f2fe78bSCy Schubert context_handle,
64*7f2fe78bSCy Schubert conf_state,
65*7f2fe78bSCy Schubert qop_state,
66*7f2fe78bSCy Schubert iov,
67*7f2fe78bSCy Schubert iov_count)
68*7f2fe78bSCy Schubert OM_uint32 * minor_status;
69*7f2fe78bSCy Schubert gss_ctx_id_t context_handle;
70*7f2fe78bSCy Schubert int * conf_state;
71*7f2fe78bSCy Schubert gss_qop_t *qop_state;
72*7f2fe78bSCy Schubert gss_iov_buffer_desc * iov;
73*7f2fe78bSCy Schubert int iov_count;
74*7f2fe78bSCy Schubert {
75*7f2fe78bSCy Schubert /* EXPORT DELETE START */
76*7f2fe78bSCy Schubert
77*7f2fe78bSCy Schubert OM_uint32 status;
78*7f2fe78bSCy Schubert gss_union_ctx_id_t ctx;
79*7f2fe78bSCy Schubert gss_mechanism mech;
80*7f2fe78bSCy Schubert
81*7f2fe78bSCy Schubert status = val_unwrap_iov_args(minor_status, context_handle,
82*7f2fe78bSCy Schubert conf_state, qop_state, iov, iov_count);
83*7f2fe78bSCy Schubert if (status != GSS_S_COMPLETE)
84*7f2fe78bSCy Schubert return (status);
85*7f2fe78bSCy Schubert
86*7f2fe78bSCy Schubert /*
87*7f2fe78bSCy Schubert * select the approprate underlying mechanism routine and
88*7f2fe78bSCy Schubert * call it.
89*7f2fe78bSCy Schubert */
90*7f2fe78bSCy Schubert
91*7f2fe78bSCy Schubert ctx = (gss_union_ctx_id_t) context_handle;
92*7f2fe78bSCy Schubert if (ctx->internal_ctx_id == GSS_C_NO_CONTEXT)
93*7f2fe78bSCy Schubert return (GSS_S_NO_CONTEXT);
94*7f2fe78bSCy Schubert mech = gssint_get_mechanism (ctx->mech_type);
95*7f2fe78bSCy Schubert
96*7f2fe78bSCy Schubert if (mech) {
97*7f2fe78bSCy Schubert if (mech->gss_unwrap_iov) {
98*7f2fe78bSCy Schubert status = mech->gss_unwrap_iov(
99*7f2fe78bSCy Schubert minor_status,
100*7f2fe78bSCy Schubert ctx->internal_ctx_id,
101*7f2fe78bSCy Schubert conf_state,
102*7f2fe78bSCy Schubert qop_state,
103*7f2fe78bSCy Schubert iov,
104*7f2fe78bSCy Schubert iov_count);
105*7f2fe78bSCy Schubert if (status != GSS_S_COMPLETE)
106*7f2fe78bSCy Schubert map_error(minor_status, mech);
107*7f2fe78bSCy Schubert } else
108*7f2fe78bSCy Schubert status = GSS_S_UNAVAILABLE;
109*7f2fe78bSCy Schubert
110*7f2fe78bSCy Schubert return(status);
111*7f2fe78bSCy Schubert }
112*7f2fe78bSCy Schubert /* EXPORT DELETE END */
113*7f2fe78bSCy Schubert
114*7f2fe78bSCy Schubert return (GSS_S_BAD_MECH);
115*7f2fe78bSCy Schubert }
116*7f2fe78bSCy Schubert
117*7f2fe78bSCy Schubert OM_uint32 KRB5_CALLCONV
gss_verify_mic_iov(OM_uint32 * minor_status,gss_ctx_id_t context_handle,gss_qop_t * qop_state,gss_iov_buffer_desc * iov,int iov_count)118*7f2fe78bSCy Schubert gss_verify_mic_iov(OM_uint32 *minor_status, gss_ctx_id_t context_handle,
119*7f2fe78bSCy Schubert gss_qop_t *qop_state, gss_iov_buffer_desc *iov,
120*7f2fe78bSCy Schubert int iov_count)
121*7f2fe78bSCy Schubert {
122*7f2fe78bSCy Schubert OM_uint32 status;
123*7f2fe78bSCy Schubert gss_union_ctx_id_t ctx;
124*7f2fe78bSCy Schubert gss_mechanism mech;
125*7f2fe78bSCy Schubert
126*7f2fe78bSCy Schubert status = val_unwrap_iov_args(minor_status, context_handle, NULL,
127*7f2fe78bSCy Schubert qop_state, iov, iov_count);
128*7f2fe78bSCy Schubert if (status != GSS_S_COMPLETE)
129*7f2fe78bSCy Schubert return status;
130*7f2fe78bSCy Schubert
131*7f2fe78bSCy Schubert /* Select the approprate underlying mechanism routine and call it. */
132*7f2fe78bSCy Schubert ctx = (gss_union_ctx_id_t)context_handle;
133*7f2fe78bSCy Schubert if (ctx->internal_ctx_id == GSS_C_NO_CONTEXT)
134*7f2fe78bSCy Schubert return GSS_S_NO_CONTEXT;
135*7f2fe78bSCy Schubert mech = gssint_get_mechanism(ctx->mech_type);
136*7f2fe78bSCy Schubert if (mech == NULL)
137*7f2fe78bSCy Schubert return GSS_S_BAD_MECH;
138*7f2fe78bSCy Schubert if (mech->gss_verify_mic_iov == NULL)
139*7f2fe78bSCy Schubert return GSS_S_UNAVAILABLE;
140*7f2fe78bSCy Schubert status = mech->gss_verify_mic_iov(minor_status, ctx->internal_ctx_id,
141*7f2fe78bSCy Schubert qop_state, iov, iov_count);
142*7f2fe78bSCy Schubert if (status != GSS_S_COMPLETE)
143*7f2fe78bSCy Schubert map_error(minor_status, mech);
144*7f2fe78bSCy Schubert return status;
145*7f2fe78bSCy Schubert }
146