X-Git-Url: http://www.project-moonshot.org/gitweb/?a=blobdiff_plain;f=mech_eap%2Fpseudo_random.c;h=4bbf542789c87f6636ca4f9b5d6ee332aedbefe5;hb=refs%2Fheads%2Fddf-name;hp=ce93507590cefcbcd4636c4c6fdd6b45b648b549;hpb=08e7678a5243d69e65308657965593a6c007c560;p=moonshot.git diff --git a/mech_eap/pseudo_random.c b/mech_eap/pseudo_random.c index ce93507..4bbf542 100644 --- a/mech_eap/pseudo_random.c +++ b/mech_eap/pseudo_random.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, JANET(UK) + * Copyright (c) 2011, JANET(UK) * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -53,6 +53,10 @@ * or implied warranty. */ +/* + * PRF + */ + #include "gssapiP_eap.h" OM_uint32 @@ -74,8 +78,20 @@ gss_pseudo_random(OM_uint32 *minor, prf_out->length = 0; prf_out->value = NULL; - if (!CTX_IS_ESTABLISHED(ctx)) + if (ctx == GSS_C_NO_CONTEXT) { + *minor = EINVAL; + return GSS_S_CALL_INACCESSIBLE_READ | GSS_S_NO_CONTEXT; + } + + *minor = 0; + + GSSEAP_MUTEX_LOCK(&ctx->mutex); + + if (!CTX_IS_ESTABLISHED(ctx)) { + GSSEAP_MUTEX_UNLOCK(&ctx->mutex); + *minor = GSSEAP_CONTEXT_INCOMPLETE; return GSS_S_NO_CONTEXT; + } GSSEAP_KRB_INIT(&krbContext); @@ -85,9 +101,9 @@ gss_pseudo_random(OM_uint32 *minor, ns.length = 0; ns.data = NULL; - if (prf_key != GSS_C_PRF_KEY_FULL && + if (prf_key != GSS_C_PRF_KEY_PARTIAL && prf_key != GSS_C_PRF_KEY_FULL) { - code = EINVAL; + code = GSSEAP_BAD_PRF_KEY; goto cleanup; } @@ -136,12 +152,14 @@ gss_pseudo_random(OM_uint32 *minor, } cleanup: + GSSEAP_MUTEX_UNLOCK(&ctx->mutex); + if (code != 0) gss_release_buffer(&tmpMinor, prf_out); krb5_free_data_contents(krbContext, &ns); krb5_free_data_contents(krbContext, &t); *minor = code; + return (code == 0) ? GSS_S_COMPLETE : GSS_S_FAILURE; } -