17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5503a2b89SPeter Shoults * Common Development and Distribution License (the "License"). 6503a2b89SPeter Shoults * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 22*5e01956fSGlenn Barry * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. 237c478bd9Sstevel@tonic-gate */ 247c478bd9Sstevel@tonic-gate 257c478bd9Sstevel@tonic-gate /* 267c478bd9Sstevel@tonic-gate * glue routine for gss_seal 277c478bd9Sstevel@tonic-gate */ 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate #include <mechglueP.h> 30*5e01956fSGlenn Barry #include "gssapiP_generic.h" 31*5e01956fSGlenn Barry 327c478bd9Sstevel@tonic-gate 33503a2b89SPeter Shoults static OM_uint32 34503a2b89SPeter Shoults val_seal_args( 35503a2b89SPeter Shoults OM_uint32 *minor_status, 36503a2b89SPeter Shoults gss_ctx_id_t context_handle, 37503a2b89SPeter Shoults gss_buffer_t input_message_buffer, 38503a2b89SPeter Shoults gss_buffer_t output_message_buffer) 39503a2b89SPeter Shoults { 40503a2b89SPeter Shoults 41503a2b89SPeter Shoults /* Initialize outputs. */ 42503a2b89SPeter Shoults 43503a2b89SPeter Shoults if (minor_status != NULL) 44503a2b89SPeter Shoults *minor_status = 0; 45503a2b89SPeter Shoults 46503a2b89SPeter Shoults if (output_message_buffer != GSS_C_NO_BUFFER) { 47503a2b89SPeter Shoults output_message_buffer->length = 0; 48503a2b89SPeter Shoults output_message_buffer->value = NULL; 49503a2b89SPeter Shoults } 50503a2b89SPeter Shoults 51503a2b89SPeter Shoults /* Validate arguments. */ 52503a2b89SPeter Shoults 53503a2b89SPeter Shoults if (minor_status == NULL) 54503a2b89SPeter Shoults return (GSS_S_CALL_INACCESSIBLE_WRITE); 55503a2b89SPeter Shoults 56503a2b89SPeter Shoults if (context_handle == GSS_C_NO_CONTEXT) 57503a2b89SPeter Shoults return (GSS_S_CALL_INACCESSIBLE_READ | GSS_S_NO_CONTEXT); 58503a2b89SPeter Shoults 59503a2b89SPeter Shoults if (input_message_buffer == GSS_C_NO_BUFFER) 60503a2b89SPeter Shoults return (GSS_S_CALL_INACCESSIBLE_READ); 61503a2b89SPeter Shoults 62503a2b89SPeter Shoults if (output_message_buffer == GSS_C_NO_BUFFER) 63503a2b89SPeter Shoults return (GSS_S_CALL_INACCESSIBLE_WRITE); 64503a2b89SPeter Shoults 65503a2b89SPeter Shoults return (GSS_S_COMPLETE); 66503a2b89SPeter Shoults } 67503a2b89SPeter Shoults 687c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 697c478bd9Sstevel@tonic-gate OM_uint32 707c478bd9Sstevel@tonic-gate gss_seal(minor_status, 717c478bd9Sstevel@tonic-gate context_handle, 727c478bd9Sstevel@tonic-gate conf_req_flag, 737c478bd9Sstevel@tonic-gate qop_req, 747c478bd9Sstevel@tonic-gate input_message_buffer, 757c478bd9Sstevel@tonic-gate conf_state, 767c478bd9Sstevel@tonic-gate output_message_buffer) 777c478bd9Sstevel@tonic-gate 787c478bd9Sstevel@tonic-gate OM_uint32 * minor_status; 797c478bd9Sstevel@tonic-gate gss_ctx_id_t context_handle; 807c478bd9Sstevel@tonic-gate int conf_req_flag; 817c478bd9Sstevel@tonic-gate int qop_req; 827c478bd9Sstevel@tonic-gate gss_buffer_t input_message_buffer; 837c478bd9Sstevel@tonic-gate int * conf_state; 847c478bd9Sstevel@tonic-gate gss_buffer_t output_message_buffer; 857c478bd9Sstevel@tonic-gate { 867c478bd9Sstevel@tonic-gate /* EXPORT DELETE START */ 877c478bd9Sstevel@tonic-gate 887c478bd9Sstevel@tonic-gate OM_uint32 status; 897c478bd9Sstevel@tonic-gate gss_union_ctx_id_t ctx; 907c478bd9Sstevel@tonic-gate gss_mechanism mech; 917c478bd9Sstevel@tonic-gate 92503a2b89SPeter Shoults status = val_seal_args(minor_status, 93503a2b89SPeter Shoults context_handle, 94503a2b89SPeter Shoults input_message_buffer, 95503a2b89SPeter Shoults output_message_buffer); 96503a2b89SPeter Shoults if (status != GSS_S_COMPLETE) 97503a2b89SPeter Shoults return (status); 987c478bd9Sstevel@tonic-gate 997c478bd9Sstevel@tonic-gate /* 1007c478bd9Sstevel@tonic-gate * select the approprate underlying mechanism routine and 1017c478bd9Sstevel@tonic-gate * call it. 1027c478bd9Sstevel@tonic-gate */ 1037c478bd9Sstevel@tonic-gate 1047c478bd9Sstevel@tonic-gate ctx = (gss_union_ctx_id_t) context_handle; 1057c478bd9Sstevel@tonic-gate mech = __gss_get_mechanism(ctx->mech_type); 1067c478bd9Sstevel@tonic-gate 1077c478bd9Sstevel@tonic-gate if (mech) { 108*5e01956fSGlenn Barry if (mech->gss_seal) { 1097c478bd9Sstevel@tonic-gate status = mech->gss_seal( 1107c478bd9Sstevel@tonic-gate mech->context, 1117c478bd9Sstevel@tonic-gate minor_status, 1127c478bd9Sstevel@tonic-gate ctx->internal_ctx_id, 1137c478bd9Sstevel@tonic-gate conf_req_flag, 1147c478bd9Sstevel@tonic-gate qop_req, 1157c478bd9Sstevel@tonic-gate input_message_buffer, 1167c478bd9Sstevel@tonic-gate conf_state, 1177c478bd9Sstevel@tonic-gate output_message_buffer); 118*5e01956fSGlenn Barry if (status != GSS_S_COMPLETE) 119*5e01956fSGlenn Barry map_error(minor_status, mech); 120*5e01956fSGlenn Barry } else 1217c478bd9Sstevel@tonic-gate status = GSS_S_UNAVAILABLE; 1227c478bd9Sstevel@tonic-gate 1237c478bd9Sstevel@tonic-gate return (status); 1247c478bd9Sstevel@tonic-gate } 1257c478bd9Sstevel@tonic-gate /* EXPORT DELETE END */ 1267c478bd9Sstevel@tonic-gate 1277c478bd9Sstevel@tonic-gate return (GSS_S_BAD_MECH); 1287c478bd9Sstevel@tonic-gate } 1297c478bd9Sstevel@tonic-gate 1307c478bd9Sstevel@tonic-gate OM_uint32 1317c478bd9Sstevel@tonic-gate gss_wrap(minor_status, 1327c478bd9Sstevel@tonic-gate context_handle, 1337c478bd9Sstevel@tonic-gate conf_req_flag, 1347c478bd9Sstevel@tonic-gate qop_req, 1357c478bd9Sstevel@tonic-gate input_message_buffer, 1367c478bd9Sstevel@tonic-gate conf_state, 1377c478bd9Sstevel@tonic-gate output_message_buffer) 1387c478bd9Sstevel@tonic-gate 1397c478bd9Sstevel@tonic-gate OM_uint32 * minor_status; 1407c478bd9Sstevel@tonic-gate const gss_ctx_id_t context_handle; 1417c478bd9Sstevel@tonic-gate int conf_req_flag; 1427c478bd9Sstevel@tonic-gate gss_qop_t qop_req; 1437c478bd9Sstevel@tonic-gate const gss_buffer_t input_message_buffer; 1447c478bd9Sstevel@tonic-gate int * conf_state; 1457c478bd9Sstevel@tonic-gate gss_buffer_t output_message_buffer; 1467c478bd9Sstevel@tonic-gate 1477c478bd9Sstevel@tonic-gate { 1487c478bd9Sstevel@tonic-gate return gss_seal(minor_status, (gss_ctx_id_t)context_handle, 1497c478bd9Sstevel@tonic-gate conf_req_flag, (int) qop_req, 1507c478bd9Sstevel@tonic-gate (gss_buffer_t)input_message_buffer, conf_state, 1517c478bd9Sstevel@tonic-gate output_message_buffer); 1527c478bd9Sstevel@tonic-gate } 1537c478bd9Sstevel@tonic-gate 1547c478bd9Sstevel@tonic-gate /* 1557c478bd9Sstevel@tonic-gate * New for V2 1567c478bd9Sstevel@tonic-gate */ 1577c478bd9Sstevel@tonic-gate OM_uint32 1587c478bd9Sstevel@tonic-gate gss_wrap_size_limit(minor_status, context_handle, conf_req_flag, 1597c478bd9Sstevel@tonic-gate qop_req, req_output_size, max_input_size) 1607c478bd9Sstevel@tonic-gate OM_uint32 *minor_status; 1617c478bd9Sstevel@tonic-gate const gss_ctx_id_t context_handle; 1627c478bd9Sstevel@tonic-gate int conf_req_flag; 1637c478bd9Sstevel@tonic-gate gss_qop_t qop_req; 1647c478bd9Sstevel@tonic-gate OM_uint32 req_output_size; 1657c478bd9Sstevel@tonic-gate OM_uint32 *max_input_size; 1667c478bd9Sstevel@tonic-gate { 1677c478bd9Sstevel@tonic-gate gss_union_ctx_id_t ctx; 1687c478bd9Sstevel@tonic-gate gss_mechanism mech; 169*5e01956fSGlenn Barry OM_uint32 major_status; 1707c478bd9Sstevel@tonic-gate 1717c478bd9Sstevel@tonic-gate if (minor_status == NULL) 1727c478bd9Sstevel@tonic-gate return (GSS_S_CALL_INACCESSIBLE_WRITE); 1737c478bd9Sstevel@tonic-gate *minor_status = 0; 1747c478bd9Sstevel@tonic-gate 1757c478bd9Sstevel@tonic-gate if (context_handle == GSS_C_NO_CONTEXT) 1767c478bd9Sstevel@tonic-gate return (GSS_S_CALL_INACCESSIBLE_READ | GSS_S_NO_CONTEXT); 1777c478bd9Sstevel@tonic-gate 1787c478bd9Sstevel@tonic-gate if (max_input_size == NULL) 1797c478bd9Sstevel@tonic-gate return (GSS_S_CALL_INACCESSIBLE_WRITE); 1807c478bd9Sstevel@tonic-gate 1817c478bd9Sstevel@tonic-gate /* 1827c478bd9Sstevel@tonic-gate * select the approprate underlying mechanism routine and 1837c478bd9Sstevel@tonic-gate * call it. 1847c478bd9Sstevel@tonic-gate */ 1857c478bd9Sstevel@tonic-gate 1867c478bd9Sstevel@tonic-gate ctx = (gss_union_ctx_id_t) context_handle; 1877c478bd9Sstevel@tonic-gate mech = __gss_get_mechanism(ctx->mech_type); 1887c478bd9Sstevel@tonic-gate 1897c478bd9Sstevel@tonic-gate if (!mech) 1907c478bd9Sstevel@tonic-gate return (GSS_S_BAD_MECH); 1917c478bd9Sstevel@tonic-gate 192*5e01956fSGlenn Barry if (mech->gss_wrap_size_limit) 193*5e01956fSGlenn Barry major_status = mech->gss_wrap_size_limit(mech->context, 194*5e01956fSGlenn Barry minor_status, 195*5e01956fSGlenn Barry ctx->internal_ctx_id, 196*5e01956fSGlenn Barry conf_req_flag, qop_req, 197*5e01956fSGlenn Barry req_output_size, 198*5e01956fSGlenn Barry max_input_size); 199*5e01956fSGlenn Barry else 200*5e01956fSGlenn Barry major_status = GSS_S_UNAVAILABLE; 201*5e01956fSGlenn Barry if (major_status != GSS_S_COMPLETE) 202*5e01956fSGlenn Barry map_error(minor_status, mech); 203*5e01956fSGlenn Barry return major_status; 2047c478bd9Sstevel@tonic-gate } 205