1229784Suqs/*- 2229784Suqs * Copyright (c) 2007 Kungliga Tekniska H��gskolan 3178828Sdfr * (Royal Institute of Technology, Stockholm, Sweden). 4178828Sdfr * All rights reserved. 5178828Sdfr * 6178828Sdfr * Redistribution and use in source and binary forms, with or without 7178828Sdfr * modification, are permitted provided that the following conditions 8178828Sdfr * are met: 9178828Sdfr * 10178828Sdfr * 1. Redistributions of source code must retain the above copyright 11178828Sdfr * notice, this list of conditions and the following disclaimer. 12178828Sdfr * 13178828Sdfr * 2. Redistributions in binary form must reproduce the above copyright 14178828Sdfr * notice, this list of conditions and the following disclaimer in the 15178828Sdfr * documentation and/or other materials provided with the distribution. 16178828Sdfr * 17178828Sdfr * 3. Neither the name of the Institute nor the names of its contributors 18178828Sdfr * may be used to endorse or promote products derived from this software 19178828Sdfr * without specific prior written permission. 20178828Sdfr * 21178828Sdfr * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 22178828Sdfr * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23178828Sdfr * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24178828Sdfr * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 25178828Sdfr * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26178828Sdfr * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27178828Sdfr * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28178828Sdfr * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29178828Sdfr * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30178828Sdfr * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31178828Sdfr * SUCH DAMAGE. 32178828Sdfr */ 33178828Sdfr/* $FreeBSD$ */ 34178828Sdfr/* $Id: gss_pseudo_random.c 20053 2007-01-24 01:31:35Z lha $ */ 35178828Sdfr 36178828Sdfr#include <gssapi/gssapi.h> 37178828Sdfr 38178828Sdfr#include "mech_switch.h" 39178828Sdfr#include "context.h" 40178828Sdfr#include "utils.h" 41178828Sdfr 42178828SdfrOM_uint32 43178828Sdfrgss_pseudo_random(OM_uint32 *minor_status, 44178828Sdfr gss_ctx_id_t context, 45178828Sdfr int prf_key, 46178828Sdfr const gss_buffer_t prf_in, 47178828Sdfr ssize_t desired_output_len, 48178828Sdfr gss_buffer_t prf_out) 49178828Sdfr{ 50178828Sdfr struct _gss_context *ctx = (struct _gss_context *) context; 51178828Sdfr struct _gss_mech_switch *m = ctx->gc_mech; 52178828Sdfr OM_uint32 major_status; 53178828Sdfr 54178828Sdfr _gss_buffer_zero(prf_out); 55178828Sdfr *minor_status = 0; 56178828Sdfr 57178828Sdfr if (ctx == NULL) { 58178828Sdfr *minor_status = 0; 59178828Sdfr return GSS_S_NO_CONTEXT; 60178828Sdfr } 61178828Sdfr 62178828Sdfr if (m->gm_pseudo_random == NULL) 63178828Sdfr return GSS_S_UNAVAILABLE; 64178828Sdfr 65178828Sdfr major_status = (*m->gm_pseudo_random)(minor_status, ctx->gc_ctx, 66178828Sdfr prf_key, prf_in, desired_output_len, 67178828Sdfr prf_out); 68178828Sdfr if (major_status != GSS_S_COMPLETE) 69178828Sdfr _gss_mg_error(m, major_status, *minor_status); 70178828Sdfr 71178828Sdfr return major_status; 72178828Sdfr} 73