1226031Sstas/*- 2226031Sstas * Copyright (c) 2005 Doug Rabson 3226031Sstas * All rights reserved. 4226031Sstas * 5226031Sstas * Redistribution and use in source and binary forms, with or without 6226031Sstas * modification, are permitted provided that the following conditions 7226031Sstas * are met: 8226031Sstas * 1. Redistributions of source code must retain the above copyright 9226031Sstas * notice, this list of conditions and the following disclaimer. 10226031Sstas * 2. Redistributions in binary form must reproduce the above copyright 11226031Sstas * notice, this list of conditions and the following disclaimer in the 12226031Sstas * documentation and/or other materials provided with the distribution. 13226031Sstas * 14226031Sstas * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15226031Sstas * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16226031Sstas * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17226031Sstas * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18226031Sstas * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19226031Sstas * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20226031Sstas * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21226031Sstas * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22226031Sstas * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23226031Sstas * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24226031Sstas * SUCH DAMAGE. 25226031Sstas * 26226031Sstas * $FreeBSD: src/lib/libgssapi/gss_wrap.c,v 1.1 2005/12/29 14:40:20 dfr Exp $ 27226031Sstas */ 28226031Sstas 29226031Sstas#include "mech_locl.h" 30226031Sstas 31226031Sstas/** 32226031Sstas * Wrap a message using either confidentiality (encryption + 33226031Sstas * signature) or sealing (signature). 34226031Sstas * 35226031Sstas * @param minor_status minor status code. 36226031Sstas * @param context_handle context handle. 37226031Sstas * @param conf_req_flag if non zero, confidentiality is requestd. 38226031Sstas * @param qop_req type of protection needed, in most cases it GSS_C_QOP_DEFAULT should be passed in. 39226031Sstas * @param input_message_buffer messages to wrap 40226031Sstas * @param conf_state returns non zero if confidentiality was honoured. 41226031Sstas * @param output_message_buffer the resulting buffer, release with gss_release_buffer(). 42226031Sstas * 43226031Sstas * @ingroup gssapi 44226031Sstas */ 45226031Sstas 46226031SstasGSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL 47226031Sstasgss_wrap(OM_uint32 *minor_status, 48226031Sstas const gss_ctx_id_t context_handle, 49226031Sstas int conf_req_flag, 50226031Sstas gss_qop_t qop_req, 51226031Sstas const gss_buffer_t input_message_buffer, 52226031Sstas int *conf_state, 53226031Sstas gss_buffer_t output_message_buffer) 54226031Sstas{ 55226031Sstas struct _gss_context *ctx = (struct _gss_context *) context_handle; 56226031Sstas gssapi_mech_interface m; 57226031Sstas 58226031Sstas if (conf_state) 59226031Sstas *conf_state = 0; 60226031Sstas _mg_buffer_zero(output_message_buffer); 61226031Sstas if (ctx == NULL) { 62226031Sstas *minor_status = 0; 63226031Sstas return GSS_S_NO_CONTEXT; 64226031Sstas } 65226031Sstas 66226031Sstas m = ctx->gc_mech; 67226031Sstas 68226031Sstas return (m->gm_wrap(minor_status, ctx->gc_ctx, 69226031Sstas conf_req_flag, qop_req, input_message_buffer, 70226031Sstas conf_state, output_message_buffer)); 71226031Sstas} 72