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 5*503a2b89SPeter Shoults * Common Development and Distribution License (the "License"). 6*503a2b89SPeter 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*503a2b89SPeter Shoults * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 23*503a2b89SPeter Shoults * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate /* 277c478bd9Sstevel@tonic-gate * glue routine gss_sign 287c478bd9Sstevel@tonic-gate */ 297c478bd9Sstevel@tonic-gate 307c478bd9Sstevel@tonic-gate #include <mechglueP.h> 317c478bd9Sstevel@tonic-gate 32*503a2b89SPeter Shoults static OM_uint32 33*503a2b89SPeter Shoults val_sign_args( 34*503a2b89SPeter Shoults OM_uint32 *minor_status, 35*503a2b89SPeter Shoults gss_ctx_id_t context_handle, 36*503a2b89SPeter Shoults gss_buffer_t message_buffer, 37*503a2b89SPeter Shoults gss_buffer_t msg_token) 38*503a2b89SPeter Shoults { 39*503a2b89SPeter Shoults 40*503a2b89SPeter Shoults /* Initialize outputs. */ 41*503a2b89SPeter Shoults 42*503a2b89SPeter Shoults if (minor_status != NULL) 43*503a2b89SPeter Shoults *minor_status = 0; 44*503a2b89SPeter Shoults 45*503a2b89SPeter Shoults if (msg_token != GSS_C_NO_BUFFER) { 46*503a2b89SPeter Shoults msg_token->value = NULL; 47*503a2b89SPeter Shoults msg_token->length = 0; 48*503a2b89SPeter Shoults } 49*503a2b89SPeter Shoults 50*503a2b89SPeter Shoults /* Validate arguments. */ 51*503a2b89SPeter Shoults 52*503a2b89SPeter Shoults if (minor_status == NULL) 53*503a2b89SPeter Shoults return (GSS_S_CALL_INACCESSIBLE_WRITE); 54*503a2b89SPeter Shoults 55*503a2b89SPeter Shoults if (context_handle == GSS_C_NO_CONTEXT) 56*503a2b89SPeter Shoults return (GSS_S_CALL_INACCESSIBLE_READ | GSS_S_NO_CONTEXT); 57*503a2b89SPeter Shoults 58*503a2b89SPeter Shoults if (message_buffer == GSS_C_NO_BUFFER) 59*503a2b89SPeter Shoults return (GSS_S_CALL_INACCESSIBLE_READ); 60*503a2b89SPeter Shoults 61*503a2b89SPeter Shoults if (msg_token == GSS_C_NO_BUFFER) 62*503a2b89SPeter Shoults return (GSS_S_CALL_INACCESSIBLE_WRITE); 63*503a2b89SPeter Shoults 64*503a2b89SPeter Shoults return (GSS_S_COMPLETE); 65*503a2b89SPeter Shoults } 66*503a2b89SPeter Shoults 677c478bd9Sstevel@tonic-gate OM_uint32 687c478bd9Sstevel@tonic-gate gss_sign(minor_status, 697c478bd9Sstevel@tonic-gate context_handle, 707c478bd9Sstevel@tonic-gate qop_req, 717c478bd9Sstevel@tonic-gate message_buffer, 727c478bd9Sstevel@tonic-gate msg_token) 737c478bd9Sstevel@tonic-gate 747c478bd9Sstevel@tonic-gate OM_uint32 * minor_status; 757c478bd9Sstevel@tonic-gate gss_ctx_id_t context_handle; 767c478bd9Sstevel@tonic-gate int qop_req; 777c478bd9Sstevel@tonic-gate gss_buffer_t message_buffer; 787c478bd9Sstevel@tonic-gate gss_buffer_t msg_token; 797c478bd9Sstevel@tonic-gate 807c478bd9Sstevel@tonic-gate { 817c478bd9Sstevel@tonic-gate OM_uint32 status; 827c478bd9Sstevel@tonic-gate gss_union_ctx_id_t ctx; 837c478bd9Sstevel@tonic-gate gss_mechanism mech; 847c478bd9Sstevel@tonic-gate 85*503a2b89SPeter Shoults status = val_sign_args(minor_status, context_handle, 86*503a2b89SPeter Shoults message_buffer, msg_token); 87*503a2b89SPeter Shoults if (status != GSS_S_COMPLETE) 88*503a2b89SPeter Shoults return (status); 897c478bd9Sstevel@tonic-gate 907c478bd9Sstevel@tonic-gate /* 917c478bd9Sstevel@tonic-gate * select the approprate underlying mechanism routine and 927c478bd9Sstevel@tonic-gate * call it. 937c478bd9Sstevel@tonic-gate */ 947c478bd9Sstevel@tonic-gate 957c478bd9Sstevel@tonic-gate ctx = (gss_union_ctx_id_t) context_handle; 967c478bd9Sstevel@tonic-gate mech = __gss_get_mechanism(ctx->mech_type); 977c478bd9Sstevel@tonic-gate 987c478bd9Sstevel@tonic-gate if (mech) { 997c478bd9Sstevel@tonic-gate if (mech->gss_sign) 1007c478bd9Sstevel@tonic-gate status = mech->gss_sign( 1017c478bd9Sstevel@tonic-gate mech->context, 1027c478bd9Sstevel@tonic-gate minor_status, 1037c478bd9Sstevel@tonic-gate ctx->internal_ctx_id, 1047c478bd9Sstevel@tonic-gate qop_req, 1057c478bd9Sstevel@tonic-gate message_buffer, 1067c478bd9Sstevel@tonic-gate msg_token); 1077c478bd9Sstevel@tonic-gate else 1087c478bd9Sstevel@tonic-gate status = GSS_S_UNAVAILABLE; 1097c478bd9Sstevel@tonic-gate 1107c478bd9Sstevel@tonic-gate return (status); 1117c478bd9Sstevel@tonic-gate } 1127c478bd9Sstevel@tonic-gate 1137c478bd9Sstevel@tonic-gate return (GSS_S_BAD_MECH); 1147c478bd9Sstevel@tonic-gate } 1157c478bd9Sstevel@tonic-gate 1167c478bd9Sstevel@tonic-gate OM_uint32 1177c478bd9Sstevel@tonic-gate gss_get_mic(minor_status, 1187c478bd9Sstevel@tonic-gate context_handle, 1197c478bd9Sstevel@tonic-gate qop_req, 1207c478bd9Sstevel@tonic-gate message_buffer, 1217c478bd9Sstevel@tonic-gate msg_token) 1227c478bd9Sstevel@tonic-gate 1237c478bd9Sstevel@tonic-gate OM_uint32 * minor_status; 1247c478bd9Sstevel@tonic-gate const gss_ctx_id_t context_handle; 1257c478bd9Sstevel@tonic-gate gss_qop_t qop_req; 1267c478bd9Sstevel@tonic-gate const gss_buffer_t message_buffer; 1277c478bd9Sstevel@tonic-gate gss_buffer_t msg_token; 1287c478bd9Sstevel@tonic-gate 1297c478bd9Sstevel@tonic-gate { 1307c478bd9Sstevel@tonic-gate return (gss_sign(minor_status, (gss_ctx_id_t)context_handle, 1317c478bd9Sstevel@tonic-gate (int) qop_req, (gss_buffer_t)message_buffer, msg_token)); 1327c478bd9Sstevel@tonic-gate } 133