|
gsasl
1.7.6
|
00001 /* xstep.c --- Perform one SASL authentication step. 00002 * Copyright (C) 2002-2012 Simon Josefsson 00003 * 00004 * This file is part of GNU SASL Library. 00005 * 00006 * GNU SASL Library is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU Lesser General Public License 00008 * as published by the Free Software Foundation; either version 2.1 of 00009 * the License, or (at your option) any later version. 00010 * 00011 * GNU SASL Library is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 * Lesser General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Lesser General Public 00017 * License License along with GNU SASL Library; if not, write to the 00018 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00019 * Boston, MA 02110-1301, USA. 00020 * 00021 */ 00022 00023 #include "internal.h" 00024 00050 int 00051 gsasl_step (Gsasl_session * sctx, 00052 const char *input, size_t input_len, 00053 char **output, size_t * output_len) 00054 { 00055 Gsasl_step_function step; 00056 00057 if (sctx->clientp) 00058 step = sctx->mech->client.step; 00059 else 00060 step = sctx->mech->server.step; 00061 00062 return step (sctx, sctx->mech_data, input, input_len, output, output_len); 00063 } 00064 00085 int 00086 gsasl_step64 (Gsasl_session * sctx, const char *b64input, char **b64output) 00087 { 00088 size_t input_len = 0, output_len = 0; 00089 char *input = NULL, *output = NULL; 00090 int res; 00091 00092 if (b64input) 00093 { 00094 res = gsasl_base64_from (b64input, strlen (b64input), 00095 &input, &input_len); 00096 if (res != GSASL_OK) 00097 return GSASL_BASE64_ERROR; 00098 } 00099 00100 res = gsasl_step (sctx, input, input_len, &output, &output_len); 00101 00102 free (input); 00103 00104 if (res == GSASL_OK || res == GSASL_NEEDS_MORE) 00105 { 00106 int tmpres = gsasl_base64_to (output, output_len, b64output, NULL); 00107 00108 free (output); 00109 00110 if (tmpres != GSASL_OK) 00111 return tmpres; 00112 } 00113 00114 return res; 00115 }
1.7.6.1