10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*9698SPeter.Shoults@Sun.COM * Common Development and Distribution License (the "License"). 6*9698SPeter.Shoults@Sun.COM * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 210Sstevel@tonic-gate /* 22*9698SPeter.Shoults@Sun.COM * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 23*9698SPeter.Shoults@Sun.COM * Use is subject to license terms. 240Sstevel@tonic-gate */ 250Sstevel@tonic-gate 260Sstevel@tonic-gate /* 270Sstevel@tonic-gate * glue routine for gss_seal 280Sstevel@tonic-gate */ 290Sstevel@tonic-gate 300Sstevel@tonic-gate #include <mechglueP.h> 310Sstevel@tonic-gate 32*9698SPeter.Shoults@Sun.COM static OM_uint32 33*9698SPeter.Shoults@Sun.COM val_seal_args( 34*9698SPeter.Shoults@Sun.COM OM_uint32 *minor_status, 35*9698SPeter.Shoults@Sun.COM gss_ctx_id_t context_handle, 36*9698SPeter.Shoults@Sun.COM gss_buffer_t input_message_buffer, 37*9698SPeter.Shoults@Sun.COM gss_buffer_t output_message_buffer) 38*9698SPeter.Shoults@Sun.COM { 39*9698SPeter.Shoults@Sun.COM 40*9698SPeter.Shoults@Sun.COM /* Initialize outputs. */ 41*9698SPeter.Shoults@Sun.COM 42*9698SPeter.Shoults@Sun.COM if (minor_status != NULL) 43*9698SPeter.Shoults@Sun.COM *minor_status = 0; 44*9698SPeter.Shoults@Sun.COM 45*9698SPeter.Shoults@Sun.COM if (output_message_buffer != GSS_C_NO_BUFFER) { 46*9698SPeter.Shoults@Sun.COM output_message_buffer->length = 0; 47*9698SPeter.Shoults@Sun.COM output_message_buffer->value = NULL; 48*9698SPeter.Shoults@Sun.COM } 49*9698SPeter.Shoults@Sun.COM 50*9698SPeter.Shoults@Sun.COM /* Validate arguments. */ 51*9698SPeter.Shoults@Sun.COM 52*9698SPeter.Shoults@Sun.COM if (minor_status == NULL) 53*9698SPeter.Shoults@Sun.COM return (GSS_S_CALL_INACCESSIBLE_WRITE); 54*9698SPeter.Shoults@Sun.COM 55*9698SPeter.Shoults@Sun.COM if (context_handle == GSS_C_NO_CONTEXT) 56*9698SPeter.Shoults@Sun.COM return (GSS_S_CALL_INACCESSIBLE_READ | GSS_S_NO_CONTEXT); 57*9698SPeter.Shoults@Sun.COM 58*9698SPeter.Shoults@Sun.COM if (input_message_buffer == GSS_C_NO_BUFFER) 59*9698SPeter.Shoults@Sun.COM return (GSS_S_CALL_INACCESSIBLE_READ); 60*9698SPeter.Shoults@Sun.COM 61*9698SPeter.Shoults@Sun.COM if (output_message_buffer == GSS_C_NO_BUFFER) 62*9698SPeter.Shoults@Sun.COM return (GSS_S_CALL_INACCESSIBLE_WRITE); 63*9698SPeter.Shoults@Sun.COM 64*9698SPeter.Shoults@Sun.COM return (GSS_S_COMPLETE); 65*9698SPeter.Shoults@Sun.COM } 66*9698SPeter.Shoults@Sun.COM 670Sstevel@tonic-gate /*ARGSUSED*/ 680Sstevel@tonic-gate OM_uint32 690Sstevel@tonic-gate gss_seal(minor_status, 700Sstevel@tonic-gate context_handle, 710Sstevel@tonic-gate conf_req_flag, 720Sstevel@tonic-gate qop_req, 730Sstevel@tonic-gate input_message_buffer, 740Sstevel@tonic-gate conf_state, 750Sstevel@tonic-gate output_message_buffer) 760Sstevel@tonic-gate 770Sstevel@tonic-gate OM_uint32 * minor_status; 780Sstevel@tonic-gate gss_ctx_id_t context_handle; 790Sstevel@tonic-gate int conf_req_flag; 800Sstevel@tonic-gate int qop_req; 810Sstevel@tonic-gate gss_buffer_t input_message_buffer; 820Sstevel@tonic-gate int * conf_state; 830Sstevel@tonic-gate gss_buffer_t output_message_buffer; 840Sstevel@tonic-gate { 850Sstevel@tonic-gate /* EXPORT DELETE START */ 860Sstevel@tonic-gate 870Sstevel@tonic-gate OM_uint32 status; 880Sstevel@tonic-gate gss_union_ctx_id_t ctx; 890Sstevel@tonic-gate gss_mechanism mech; 900Sstevel@tonic-gate 91*9698SPeter.Shoults@Sun.COM status = val_seal_args(minor_status, 92*9698SPeter.Shoults@Sun.COM context_handle, 93*9698SPeter.Shoults@Sun.COM input_message_buffer, 94*9698SPeter.Shoults@Sun.COM output_message_buffer); 95*9698SPeter.Shoults@Sun.COM if (status != GSS_S_COMPLETE) 96*9698SPeter.Shoults@Sun.COM return (status); 970Sstevel@tonic-gate 980Sstevel@tonic-gate /* 990Sstevel@tonic-gate * select the approprate underlying mechanism routine and 1000Sstevel@tonic-gate * call it. 1010Sstevel@tonic-gate */ 1020Sstevel@tonic-gate 1030Sstevel@tonic-gate ctx = (gss_union_ctx_id_t) context_handle; 1040Sstevel@tonic-gate mech = __gss_get_mechanism(ctx->mech_type); 1050Sstevel@tonic-gate 1060Sstevel@tonic-gate if (mech) { 1070Sstevel@tonic-gate if (mech->gss_seal) 1080Sstevel@tonic-gate status = mech->gss_seal( 1090Sstevel@tonic-gate mech->context, 1100Sstevel@tonic-gate minor_status, 1110Sstevel@tonic-gate ctx->internal_ctx_id, 1120Sstevel@tonic-gate conf_req_flag, 1130Sstevel@tonic-gate qop_req, 1140Sstevel@tonic-gate input_message_buffer, 1150Sstevel@tonic-gate conf_state, 1160Sstevel@tonic-gate output_message_buffer); 1170Sstevel@tonic-gate else 1180Sstevel@tonic-gate status = GSS_S_UNAVAILABLE; 1190Sstevel@tonic-gate 1200Sstevel@tonic-gate return (status); 1210Sstevel@tonic-gate } 1220Sstevel@tonic-gate /* EXPORT DELETE END */ 1230Sstevel@tonic-gate 1240Sstevel@tonic-gate return (GSS_S_BAD_MECH); 1250Sstevel@tonic-gate } 1260Sstevel@tonic-gate 1270Sstevel@tonic-gate OM_uint32 1280Sstevel@tonic-gate gss_wrap(minor_status, 1290Sstevel@tonic-gate context_handle, 1300Sstevel@tonic-gate conf_req_flag, 1310Sstevel@tonic-gate qop_req, 1320Sstevel@tonic-gate input_message_buffer, 1330Sstevel@tonic-gate conf_state, 1340Sstevel@tonic-gate output_message_buffer) 1350Sstevel@tonic-gate 1360Sstevel@tonic-gate OM_uint32 * minor_status; 1370Sstevel@tonic-gate const gss_ctx_id_t context_handle; 1380Sstevel@tonic-gate int conf_req_flag; 1390Sstevel@tonic-gate gss_qop_t qop_req; 1400Sstevel@tonic-gate const gss_buffer_t input_message_buffer; 1410Sstevel@tonic-gate int * conf_state; 1420Sstevel@tonic-gate gss_buffer_t output_message_buffer; 1430Sstevel@tonic-gate 1440Sstevel@tonic-gate { 1450Sstevel@tonic-gate return gss_seal(minor_status, (gss_ctx_id_t)context_handle, 1460Sstevel@tonic-gate conf_req_flag, (int) qop_req, 1470Sstevel@tonic-gate (gss_buffer_t)input_message_buffer, conf_state, 1480Sstevel@tonic-gate output_message_buffer); 1490Sstevel@tonic-gate } 1500Sstevel@tonic-gate 1510Sstevel@tonic-gate /* 1520Sstevel@tonic-gate * New for V2 1530Sstevel@tonic-gate */ 1540Sstevel@tonic-gate OM_uint32 1550Sstevel@tonic-gate gss_wrap_size_limit(minor_status, context_handle, conf_req_flag, 1560Sstevel@tonic-gate qop_req, req_output_size, max_input_size) 1570Sstevel@tonic-gate OM_uint32 *minor_status; 1580Sstevel@tonic-gate const gss_ctx_id_t context_handle; 1590Sstevel@tonic-gate int conf_req_flag; 1600Sstevel@tonic-gate gss_qop_t qop_req; 1610Sstevel@tonic-gate OM_uint32 req_output_size; 1620Sstevel@tonic-gate OM_uint32 *max_input_size; 1630Sstevel@tonic-gate { 1640Sstevel@tonic-gate gss_union_ctx_id_t ctx; 1650Sstevel@tonic-gate gss_mechanism mech; 1660Sstevel@tonic-gate 1670Sstevel@tonic-gate if (minor_status == NULL) 1680Sstevel@tonic-gate return (GSS_S_CALL_INACCESSIBLE_WRITE); 1690Sstevel@tonic-gate *minor_status = 0; 1700Sstevel@tonic-gate 1710Sstevel@tonic-gate if (context_handle == GSS_C_NO_CONTEXT) 1720Sstevel@tonic-gate return (GSS_S_CALL_INACCESSIBLE_READ | GSS_S_NO_CONTEXT); 1730Sstevel@tonic-gate 1740Sstevel@tonic-gate if (max_input_size == NULL) 1750Sstevel@tonic-gate return (GSS_S_CALL_INACCESSIBLE_WRITE); 1760Sstevel@tonic-gate 1770Sstevel@tonic-gate /* 1780Sstevel@tonic-gate * select the approprate underlying mechanism routine and 1790Sstevel@tonic-gate * call it. 1800Sstevel@tonic-gate */ 1810Sstevel@tonic-gate 1820Sstevel@tonic-gate ctx = (gss_union_ctx_id_t) context_handle; 1830Sstevel@tonic-gate mech = __gss_get_mechanism(ctx->mech_type); 1840Sstevel@tonic-gate 1850Sstevel@tonic-gate if (!mech) 1860Sstevel@tonic-gate return (GSS_S_BAD_MECH); 1870Sstevel@tonic-gate 1880Sstevel@tonic-gate if (!mech->gss_wrap_size_limit) 1890Sstevel@tonic-gate return (GSS_S_UNAVAILABLE); 1900Sstevel@tonic-gate 1910Sstevel@tonic-gate return (mech->gss_wrap_size_limit(mech->context, minor_status, 1920Sstevel@tonic-gate ctx->internal_ctx_id, conf_req_flag, qop_req, 1930Sstevel@tonic-gate req_output_size, max_input_size)); 1940Sstevel@tonic-gate } 195