1 /* 2 * Copyright 2009 by the Massachusetts Institute of Technology. 3 * All Rights Reserved. 4 * 5 * Export of this software from the United States of America may 6 * require a specific license from the United States Government. 7 * It is the responsibility of any person or organization contemplating 8 * export to obtain such a license before exporting. 9 * 10 * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and 11 * distribute this software and its documentation for any purpose and 12 * without fee is hereby granted, provided that the above copyright 13 * notice appear in all copies and that both that copyright notice and 14 * this permission notice appear in supporting documentation, and that 15 * the name of M.I.T. not be used in advertising or publicity pertaining 16 * to distribution of the software without specific, written prior 17 * permission. Furthermore if you modify this software you must label 18 * your software as modified software and not distribute it in such a 19 * fashion that it might be confused with the original M.I.T. software. 20 * M.I.T. makes no representations about the suitability of 21 * this software for any purpose. It is provided "as is" without express 22 * or implied warranty. 23 */ 24 25 /* Glue routine for gss_pseudo_random */ 26 27 #include "mglueP.h" 28 29 OM_uint32 KRB5_CALLCONV 30 gss_pseudo_random (OM_uint32 *minor_status, 31 gss_ctx_id_t context_handle, 32 int prf_key, 33 const gss_buffer_t prf_in, 34 ssize_t desired_output_len, 35 gss_buffer_t prf_out) 36 { 37 OM_uint32 status; 38 gss_union_ctx_id_t ctx; 39 gss_mechanism mech; 40 41 if (minor_status != NULL) 42 *minor_status = 0; 43 44 if (prf_out != GSS_C_NO_BUFFER) { 45 prf_out->length = 0; 46 prf_out->value = NULL; 47 } 48 49 if (minor_status == NULL) 50 return GSS_S_CALL_INACCESSIBLE_WRITE; 51 52 if (context_handle == GSS_C_NO_CONTEXT) 53 return GSS_S_CALL_INACCESSIBLE_READ | GSS_S_NO_CONTEXT; 54 55 if (prf_in == GSS_C_NO_BUFFER) 56 return GSS_S_CALL_INACCESSIBLE_READ; 57 58 if (prf_out == GSS_C_NO_BUFFER) 59 return GSS_S_CALL_INACCESSIBLE_WRITE; 60 61 prf_out->length = 0; 62 prf_out->value = NULL; 63 64 /* 65 * select the approprate underlying mechanism routine and 66 * call it. 67 */ 68 69 ctx = (gss_union_ctx_id_t) context_handle; 70 if (ctx->internal_ctx_id == GSS_C_NO_CONTEXT) 71 return GSS_S_NO_CONTEXT; 72 mech = gssint_get_mechanism (ctx->mech_type); 73 74 if (mech != NULL) { 75 if (mech->gss_pseudo_random != NULL) { 76 status = mech->gss_pseudo_random(minor_status, 77 ctx->internal_ctx_id, 78 prf_key, 79 prf_in, 80 desired_output_len, 81 prf_out); 82 if (status != GSS_S_COMPLETE) 83 map_error(minor_status, mech); 84 } else 85 status = GSS_S_UNAVAILABLE; 86 87 return status; 88 } 89 90 return GSS_S_BAD_MECH; 91 } 92