00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #if HAVE_CONFIG_H
00024 # include "config.h"
00025 #endif
00026
00027
00028 #include "plain.h"
00029
00030
00031 #include <string.h>
00032
00033
00034 #include <stdlib.h>
00035
00036 int
00037 _gsasl_plain_client_step (Gsasl_session * sctx,
00038 void *mech_data,
00039 const char *input, size_t input_len,
00040 char **output, size_t * output_len)
00041 {
00042 const char *authzid = gsasl_property_get (sctx, GSASL_AUTHZID);
00043 const char *authid = gsasl_property_get (sctx, GSASL_AUTHID);
00044 const char *password = gsasl_property_get (sctx, GSASL_PASSWORD);
00045 size_t authzidlen = 0, authidlen = 0, passwordlen = 0;
00046 char *out;
00047
00048 if (authzid)
00049 authzidlen = strlen (authzid);
00050
00051 if (authid)
00052 authidlen = strlen (authid);
00053 else
00054 return GSASL_NO_AUTHID;
00055
00056 if (password)
00057 passwordlen = strlen (password);
00058 else
00059 return GSASL_NO_PASSWORD;
00060
00061 *output_len = authzidlen + 1 + authidlen + 1 + passwordlen;
00062 *output = out = malloc (*output_len);
00063 if (!out)
00064 return GSASL_MALLOC_ERROR;
00065
00066 if (authzid)
00067 {
00068 memcpy (out, authzid, authzidlen);
00069 out += authzidlen;
00070 }
00071
00072 *out++ = '\0';
00073
00074 memcpy (out, authid, authidlen);
00075 out += authidlen;
00076
00077 *out++ = '\0';
00078
00079 memcpy (out, password, passwordlen);
00080
00081 return GSASL_OK;
00082 }