[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
CVS gsasl/lib/digest-md5
From: |
gsasl-commit |
Subject: |
CVS gsasl/lib/digest-md5 |
Date: |
Thu, 23 Sep 2004 02:20:56 +0200 |
Update of /home/cvs/gsasl/lib/digest-md5
In directory dopio:/tmp/cvs-serv16592/lib/digest-md5
Modified Files:
client.c digest-md5.h server.c
Log Message:
(gsasl_encode. gsasl_decode): Allocate OUTPUT buffer. Change in prototype.
Update types and callers.
--- /home/cvs/gsasl/lib/digest-md5/client.c 2004/09/18 16:50:46 1.1
+++ /home/cvs/gsasl/lib/digest-md5/client.c 2004/09/23 00:20:55 1.2
@@ -801,25 +801,21 @@
void *mech_data,
const char *input,
size_t input_len,
- char *output, size_t * output_len)
+ char **output, size_t * output_len)
{
_Gsasl_digest_md5_client_state *state = mech_data;
int res;
if (state && state->step == 3 && state->qop & GSASL_QOP_AUTH_CONF)
{
- /* XXX */
+ return GSASL_INTEGRITY_ERROR;
}
else if (state && state->step == 3 && state->qop & GSASL_QOP_AUTH_INT)
{
char *seqnumin;
char *hash;
uint32_t tmp;
-
- if (output &&
- MAC_DATA_LEN + input_len + MAC_HMAC_LEN +
- MAC_MSG_TYPE_LEN + MAC_SEQNUM_LEN > *output_len)
- return GSASL_TOO_SMALL_BUFFER;
+ size_t len;
seqnumin = malloc (MAC_SEQNUM_LEN + input_len);
if (seqnumin == NULL)
@@ -836,34 +832,35 @@
if (res != GSASL_OK || hash == NULL)
return GSASL_CRYPTO_ERROR;
- if (output)
- {
- *output_len = MAC_DATA_LEN;
- memcpy (output + *output_len, input, input_len);
- *output_len += input_len;
- memcpy (output + *output_len, hash, MAC_HMAC_LEN);
- *output_len += MAC_HMAC_LEN;
- memcpy (output + *output_len, MAC_MSG_TYPE, MAC_MSG_TYPE_LEN);
- *output_len += MAC_MSG_TYPE_LEN;
- tmp = htonl (state->sendseqnum);
- memcpy (output + *output_len, &tmp, MAC_SEQNUM_LEN);
- *output_len += MAC_SEQNUM_LEN;
- tmp = htonl (*output_len - MAC_DATA_LEN);
- memcpy (output, &tmp, MAC_DATA_LEN);
- state->sendseqnum++;
- }
- else
- *output_len = MAC_DATA_LEN + input_len + MAC_HMAC_LEN
- + MAC_MSG_TYPE_LEN + MAC_SEQNUM_LEN;
+ *output_len = MAC_DATA_LEN + input_len + MAC_HMAC_LEN +
+ MAC_MSG_TYPE_LEN + MAC_SEQNUM_LEN;
+ *output = malloc (*output_len);
+ if (!*output)
+ return GSASL_MALLOC_ERROR;
+
+ len = MAC_DATA_LEN;
+ memcpy (output + len, input, input_len);
+ len += input_len;
+ memcpy (output + len, hash, MAC_HMAC_LEN);
+ len += MAC_HMAC_LEN;
+ memcpy (output + len, MAC_MSG_TYPE, MAC_MSG_TYPE_LEN);
+ len += MAC_MSG_TYPE_LEN;
+ tmp = htonl (state->sendseqnum);
+ memcpy (output + len, &tmp, MAC_SEQNUM_LEN);
+ len += MAC_SEQNUM_LEN;
+ tmp = htonl (len - MAC_DATA_LEN);
+ memcpy (output, &tmp, MAC_DATA_LEN);
+ state->sendseqnum++;
free (hash);
}
else
{
*output_len = input_len;
- if (output)
- memcpy (output, input, input_len);
- return GSASL_OK;
+ *output = malloc (input_len);
+ if (!*output)
+ return GSASL_MALLOC_ERROR;
+ memcpy (*output, input, input_len);
}
return GSASL_OK;
@@ -874,13 +871,13 @@
void *mech_data,
const char *input,
size_t input_len,
- char *output, size_t * output_len)
+ char **output, size_t * output_len)
{
_Gsasl_digest_md5_client_state *state = mech_data;
if (state && state->step == 3 && state->qop & GSASL_QOP_AUTH_CONF)
{
- /* XXX */
+ return GSASL_INTEGRITY_ERROR;
}
else if (state && state->step == 3 && state->qop & GSASL_QOP_AUTH_INT)
{
@@ -926,11 +923,11 @@
MAC_SEQNUM_LEN) == 0)
{
*output_len = len;
- if (output)
- {
- memcpy (output, input + MAC_DATA_LEN, len);
- state->readseqnum++;
- }
+ *output = malloc (*output_len);
+ if (!*output)
+ return GSASL_MALLOC_ERROR;
+ memcpy (*output, input + MAC_DATA_LEN, len);
+ state->readseqnum++;
}
else
return GSASL_INTEGRITY_ERROR;
@@ -940,9 +937,10 @@
else
{
*output_len = input_len;
- if (output)
- memcpy (output, input, input_len);
- return GSASL_OK;
+ *output = malloc (input_len);
+ if (!*output)
+ return GSASL_MALLOC_ERROR;
+ memcpy (*output, input, input_len);
}
--- /home/cvs/gsasl/lib/digest-md5/digest-md5.h 2004/09/17 20:52:42 1.3
+++ /home/cvs/gsasl/lib/digest-md5/digest-md5.h 2004/09/23 00:20:55 1.4
@@ -20,8 +20,8 @@
*
*/
-#ifndef _DIGEST_MD5_H
-#define _DIGEST_MD5_H
+#ifndef DIGEST_MD5_H
+#define DIGEST_MD5_H
#include "internal.h"
@@ -40,13 +40,13 @@
void *mech_data,
const char *input,
size_t input_len,
- char *output,
+ char **output,
size_t * output_len);
extern int _gsasl_digest_md5_client_decode (Gsasl_session_ctx * sctx,
void *mech_data,
const char *input,
size_t input_len,
- char *output,
+ char **output,
size_t * output_len);
extern int _gsasl_digest_md5_server_start (Gsasl_session_ctx * sctx,
@@ -62,13 +62,13 @@
void *mech_data,
const char *input,
size_t input_len,
- char *output,
+ char **output,
size_t * output_len);
extern int _gsasl_digest_md5_server_decode (Gsasl_session_ctx * sctx,
void *mech_data,
const char *input,
size_t input_len,
- char *output,
+ char **output,
size_t * output_len);
-#endif /* _DIGEST_MD5_H */
+#endif /* DIGEST_MD5_H */
--- /home/cvs/gsasl/lib/digest-md5/server.c 2004/09/18 16:50:46 1.1
+++ /home/cvs/gsasl/lib/digest-md5/server.c 2004/09/23 00:20:56 1.2
@@ -742,25 +742,21 @@
void *mech_data,
const char *input,
size_t input_len,
- char *output, size_t * output_len)
+ char **output, size_t * output_len)
{
_Gsasl_digest_md5_server_state *state = mech_data;
int res;
if (state && state->step == 3 && state->qop & GSASL_QOP_AUTH_CONF)
{
- /* XXX */
+ return GSASL_INTEGRITY_ERROR;
}
else if (state && state->step == 3 && state->qop & GSASL_QOP_AUTH_INT)
{
char *seqnumin;
char *hash;
uint32_t tmp;
-
- if (output &&
- MAC_DATA_LEN + input_len + MAC_HMAC_LEN +
- MAC_MSG_TYPE_LEN + MAC_SEQNUM_LEN > *output_len)
- return GSASL_TOO_SMALL_BUFFER;
+ size_t len;
seqnumin = malloc (MAC_SEQNUM_LEN + input_len);
if (seqnumin == NULL)
@@ -777,34 +773,35 @@
if (res != GSASL_OK || hash == NULL)
return GSASL_CRYPTO_ERROR;
- if (output)
- {
- *output_len = MAC_DATA_LEN;
- memcpy (output + *output_len, input, input_len);
- *output_len += input_len;
- memcpy (output + *output_len, hash, MAC_HMAC_LEN);
- *output_len += MAC_HMAC_LEN;
- memcpy (output + *output_len, MAC_MSG_TYPE, MAC_MSG_TYPE_LEN);
- *output_len += MAC_MSG_TYPE_LEN;
- tmp = htonl (state->sendseqnum);
- memcpy (output + *output_len, &tmp, MAC_SEQNUM_LEN);
- *output_len += MAC_SEQNUM_LEN;
- tmp = htonl (*output_len - MAC_DATA_LEN);
- memcpy (output, &tmp, MAC_DATA_LEN);
- state->sendseqnum++;
- }
- else
- *output_len = MAC_DATA_LEN + input_len + MAC_HMAC_LEN
- + MAC_MSG_TYPE_LEN + MAC_SEQNUM_LEN;
+ *output_len = MAC_DATA_LEN + input_len + MAC_HMAC_LEN +
+ MAC_MSG_TYPE_LEN + MAC_SEQNUM_LEN;
+ *output = malloc (*output_len);
+ if (!*output)
+ return GSASL_MALLOC_ERROR;
+
+ len = MAC_DATA_LEN;
+ memcpy (output + len, input, input_len);
+ len += input_len;
+ memcpy (output + len, hash, MAC_HMAC_LEN);
+ len += MAC_HMAC_LEN;
+ memcpy (output + len, MAC_MSG_TYPE, MAC_MSG_TYPE_LEN);
+ len += MAC_MSG_TYPE_LEN;
+ tmp = htonl (state->sendseqnum);
+ memcpy (output + len, &tmp, MAC_SEQNUM_LEN);
+ len += MAC_SEQNUM_LEN;
+ tmp = htonl (len - MAC_DATA_LEN);
+ memcpy (output, &tmp, MAC_DATA_LEN);
+ state->sendseqnum++;
free (hash);
}
else
{
*output_len = input_len;
- if (output)
- memcpy (output, input, input_len);
- return GSASL_OK;
+ *output = malloc (input_len);
+ if (!*output)
+ return GSASL_MALLOC_ERROR;
+ memcpy (*output, input, input_len);
}
return GSASL_OK;
@@ -815,13 +812,13 @@
void *mech_data,
const char *input,
size_t input_len,
- char *output, size_t * output_len)
+ char **output, size_t * output_len)
{
_Gsasl_digest_md5_server_state *state = mech_data;
if (state && state->step == 3 && state->qop & GSASL_QOP_AUTH_CONF)
{
- /* XXX */
+ return GSASL_INTEGRITY_ERROR;
}
else if (state && state->step == 3 && state->qop & GSASL_QOP_AUTH_INT)
{
@@ -867,11 +864,11 @@
MAC_SEQNUM_LEN) == 0)
{
*output_len = len;
- if (output)
- {
- memcpy (output, input + MAC_DATA_LEN, len);
- state->readseqnum++;
- }
+ *output = malloc (*output_len);
+ if (!*output)
+ return GSASL_MALLOC_ERROR;
+ memcpy (*output, input + MAC_DATA_LEN, len);
+ state->readseqnum++;
}
else
return GSASL_INTEGRITY_ERROR;
@@ -881,9 +878,10 @@
else
{
*output_len = input_len;
- if (output)
- memcpy (output, input, input_len);
- return GSASL_OK;
+ *output = malloc (input_len);
+ if (!*output)
+ return GSASL_MALLOC_ERROR;
+ memcpy (*output, input, input_len);
}
- CVS gsasl/lib/digest-md5, gsasl-commit, 2004/09/17
- CVS gsasl/lib/digest-md5, gsasl-commit, 2004/09/18
- CVS gsasl/lib/digest-md5, gsasl-commit, 2004/09/22
- CVS gsasl/lib/digest-md5,
gsasl-commit <=
- CVS gsasl/lib/digest-md5, gsasl-commit, 2004/09/23
- CVS gsasl/lib/digest-md5, gsasl-commit, 2004/09/23
- CVS gsasl/lib/digest-md5, gsasl-commit, 2004/09/23
- CVS gsasl/lib/digest-md5, gsasl-commit, 2004/09/23
- CVS gsasl/lib/digest-md5, gsasl-commit, 2004/09/24
- CVS gsasl/lib/digest-md5, gsasl-commit, 2004/09/24
- CVS gsasl/lib/digest-md5, gsasl-commit, 2004/09/24
- CVS gsasl/lib/digest-md5, gsasl-commit, 2004/09/24
- CVS gsasl/lib/digest-md5, gsasl-commit, 2004/09/26