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