Path: blob/main/crypto/krb5/src/lib/gssapi/mechglue/g_prf.c
39586 views
/*1* Copyright 2009 by the Massachusetts Institute of Technology.2* All Rights Reserved.3*4* Export of this software from the United States of America may5* require a specific license from the United States Government.6* It is the responsibility of any person or organization contemplating7* export to obtain such a license before exporting.8*9* WITHIN THAT CONSTRAINT, permission to use, copy, modify, and10* distribute this software and its documentation for any purpose and11* without fee is hereby granted, provided that the above copyright12* notice appear in all copies and that both that copyright notice and13* this permission notice appear in supporting documentation, and that14* the name of M.I.T. not be used in advertising or publicity pertaining15* to distribution of the software without specific, written prior16* permission. Furthermore if you modify this software you must label17* your software as modified software and not distribute it in such a18* fashion that it might be confused with the original M.I.T. software.19* M.I.T. makes no representations about the suitability of20* this software for any purpose. It is provided "as is" without express21* or implied warranty.22*/2324/* Glue routine for gss_pseudo_random */2526#include "mglueP.h"2728OM_uint32 KRB5_CALLCONV29gss_pseudo_random (OM_uint32 *minor_status,30gss_ctx_id_t context_handle,31int prf_key,32const gss_buffer_t prf_in,33ssize_t desired_output_len,34gss_buffer_t prf_out)35{36OM_uint32 status;37gss_union_ctx_id_t ctx;38gss_mechanism mech;3940if (minor_status != NULL)41*minor_status = 0;4243if (prf_out != GSS_C_NO_BUFFER) {44prf_out->length = 0;45prf_out->value = NULL;46}4748if (minor_status == NULL)49return GSS_S_CALL_INACCESSIBLE_WRITE;5051if (context_handle == GSS_C_NO_CONTEXT)52return GSS_S_CALL_INACCESSIBLE_READ | GSS_S_NO_CONTEXT;5354if (prf_in == GSS_C_NO_BUFFER)55return GSS_S_CALL_INACCESSIBLE_READ;5657if (prf_out == GSS_C_NO_BUFFER)58return GSS_S_CALL_INACCESSIBLE_WRITE;5960prf_out->length = 0;61prf_out->value = NULL;6263/*64* select the approprate underlying mechanism routine and65* call it.66*/6768ctx = (gss_union_ctx_id_t) context_handle;69if (ctx->internal_ctx_id == GSS_C_NO_CONTEXT)70return GSS_S_NO_CONTEXT;71mech = gssint_get_mechanism (ctx->mech_type);7273if (mech != NULL) {74if (mech->gss_pseudo_random != NULL) {75status = mech->gss_pseudo_random(minor_status,76ctx->internal_ctx_id,77prf_key,78prf_in,79desired_output_len,80prf_out);81if (status != GSS_S_COMPLETE)82map_error(minor_status, mech);83} else84status = GSS_S_UNAVAILABLE;8586return status;87}8889return GSS_S_BAD_MECH;90}919293