[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
CVS gsasl/lib/cram-md5
From: |
gsasl-commit |
Subject: |
CVS gsasl/lib/cram-md5 |
Date: |
Tue, 21 Sep 2004 03:29:15 +0200 |
Update of /home/cvs/gsasl/lib/cram-md5
In directory dopio:/tmp/cvs-serv17034/lib/cram-md5
Modified Files:
client.c cram-md5.h
Log Message:
Make CRAM-MD5 client use new allocating API, and new callback interface.
--- /home/cvs/gsasl/lib/cram-md5/client.c 2004/09/18 17:36:46 1.3
+++ /home/cvs/gsasl/lib/cram-md5/client.c 2004/09/21 01:29:14 1.4
@@ -31,31 +31,16 @@
int
_gsasl_cram_md5_client_start (Gsasl_session_ctx * sctx, void **mech_data)
{
- Gsasl_ctx *ctx;
-
- ctx = gsasl_client_ctx_get (sctx);
- if (ctx == NULL)
- return GSASL_CANNOT_GET_CTX;
-
- if (gsasl_client_callback_authentication_id_get (ctx) == NULL)
- return GSASL_NEED_CLIENT_AUTHENTICATION_ID_CALLBACK;
-
- if (gsasl_client_callback_password_get (ctx) == NULL)
- return GSASL_NEED_CLIENT_PASSWORD_CALLBACK;
-
return GSASL_OK;
}
int
_gsasl_cram_md5_client_step (Gsasl_session_ctx * sctx,
void *mech_data,
- const char *input,
- size_t input_len,
- char *output, size_t * output_len)
+ const char *input, size_t input_len,
+ char **output, size_t * output_len)
{
- Gsasl_ctx *ctx;
- Gsasl_client_callback_authentication_id cb_authentication_id;
- Gsasl_client_callback_password cb_password;
+ const char *p;
char *hash;
size_t len;
char *tmp;
@@ -65,57 +50,58 @@
if (input_len == 0)
{
*output_len = 0;
+ *output = NULL;
return GSASL_NEEDS_MORE;
}
- ctx = gsasl_client_ctx_get (sctx);
- if (ctx == NULL)
- return GSASL_CANNOT_GET_CTX;
-
- cb_authentication_id = gsasl_client_callback_authentication_id_get (ctx);
- if (cb_authentication_id == NULL)
- return GSASL_NEED_CLIENT_AUTHENTICATION_ID_CALLBACK;
-
- cb_password = gsasl_client_callback_password_get (ctx);
- if (cb_password == NULL)
- return GSASL_NEED_CLIENT_PASSWORD_CALLBACK;
-
- /* XXX? password stored in callee's output buffer */
- len = *output_len - 1;
- res = cb_password (sctx, output, &len);
- if (res != GSASL_OK && res != GSASL_NEEDS_MORE)
- return res;
- output[len] = '\0';
- tmp = gsasl_stringprep_saslprep (output, NULL);
+ p = gsasl_property_get (sctx, GSASL_PASSWORD);
+ if (!p)
+ return GSASL_NO_PASSWORD;
+
+ tmp = gsasl_stringprep_saslprep (p, NULL);
if (tmp == NULL)
return GSASL_SASLPREP_ERROR;
res = gsasl_hmac_md5 (tmp, strlen (tmp), input, input_len, &hash);
free (tmp);
if (res != GSASL_OK)
- return GSASL_CRYPTO_ERROR;
+ {
+ free (hash);
+ return GSASL_CRYPTO_ERROR;
+ }
+
+ p = gsasl_property_get (sctx, GSASL_AUTHID);
+ if (!p)
+ {
+ free (hash);
+ return GSASL_NO_AUTHID;
+ }
- len = *output_len - 1;
- res = cb_authentication_id (sctx, output, &len);
- if (res != GSASL_OK && res != GSASL_NEEDS_MORE)
- return res;
- output[len] = '\0';
- tmp = gsasl_stringprep_saslprep (output, NULL);
+ tmp = gsasl_stringprep_saslprep (p, NULL);
if (tmp == NULL)
- return GSASL_SASLPREP_ERROR;
- if (strlen (tmp) + strlen (" ") + 2 * MD5LEN >= *output_len)
{
- free (tmp);
- return GSASL_TOO_SMALL_BUFFER;
+ free (hash);
+ return GSASL_SASLPREP_ERROR;
}
+
len = strlen (tmp);
- memcpy (output, tmp, len);
+
+ *output_len = len + strlen (" ") + 2 * MD5LEN;
+ *output = malloc (*output_len);
+ if (!*output)
+ {
+ free (tmp);
+ free (hash);
+ return GSASL_MALLOC_ERROR;
+ }
+
+ memcpy (*output, tmp, len);
free (tmp);
- output[len++] = ' ';
+ (*output)[len++] = ' ';
for (i = 0; i < MD5LEN; i++)
{
- output[len + 2 * i + 1] = HEXCHAR (hash[i]);
- output[len + 2 * i + 0] = HEXCHAR (hash[i] >> 4);
+ (*output)[len + 2 * i + 1] = HEXCHAR (hash[i]);
+ (*output)[len + 2 * i + 0] = HEXCHAR (hash[i] >> 4);
}
*output_len = len + 2 * MD5LEN;
--- /home/cvs/gsasl/lib/cram-md5/cram-md5.h 2004/09/18 16:39:22 1.4
+++ /home/cvs/gsasl/lib/cram-md5/cram-md5.h 2004/09/21 01:29:14 1.5
@@ -31,9 +31,8 @@
void **mech_data);
extern int _gsasl_cram_md5_client_step (Gsasl_session_ctx * sctx,
void *mech_data,
- const char *input,
- size_t input_len,
- char *output, size_t * output_len);
+ const char *input, size_t input_len,
+ char **output, size_t * output_len);
extern int _gsasl_cram_md5_server_start (Gsasl_session_ctx * sctx,
void **mech_data);
- CVS gsasl/lib/cram-md5, gsasl-commit, 2004/09/17
- CVS gsasl/lib/cram-md5, gsasl-commit, 2004/09/17
- CVS gsasl/lib/cram-md5, gsasl-commit, 2004/09/17
- CVS gsasl/lib/cram-md5, gsasl-commit, 2004/09/18
- CVS gsasl/lib/cram-md5, gsasl-commit, 2004/09/18
- CVS gsasl/lib/cram-md5, gsasl-commit, 2004/09/18
- CVS gsasl/lib/cram-md5,
gsasl-commit <=
- CVS gsasl/lib/cram-md5, gsasl-commit, 2004/09/20
- CVS gsasl/lib/cram-md5, gsasl-commit, 2004/09/20
- CVS gsasl/lib/cram-md5, gsasl-commit, 2004/09/23
- CVS gsasl/lib/cram-md5, gsasl-commit, 2004/09/23
- CVS gsasl/lib/cram-md5, gsasl-commit, 2004/09/23
- CVS gsasl/lib/cram-md5, gsasl-commit, 2004/09/24
- CVS gsasl/lib/cram-md5, gsasl-commit, 2004/09/24
- CVS gsasl/lib/cram-md5, gsasl-commit, 2004/09/24
- CVS gsasl/lib/cram-md5, gsasl-commit, 2004/09/26