gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r23370 - in libmicrohttpd/src: daemon include


From: gnunet
Subject: [GNUnet-SVN] r23370 - in libmicrohttpd/src: daemon include
Date: Thu, 23 Aug 2012 00:44:35 +0200

Author: grothoff
Date: 2012-08-23 00:44:35 +0200 (Thu, 23 Aug 2012)
New Revision: 23370

Modified:
   libmicrohttpd/src/daemon/base64.c
   libmicrohttpd/src/daemon/base64.h
   libmicrohttpd/src/daemon/md5.c
   libmicrohttpd/src/daemon/md5.h
   libmicrohttpd/src/include/platform.h
Log:
fixing #2511

Modified: libmicrohttpd/src/daemon/base64.c
===================================================================
--- libmicrohttpd/src/daemon/base64.c   2012-08-22 19:18:55 UTC (rev 23369)
+++ libmicrohttpd/src/daemon/base64.c   2012-08-22 22:44:35 UTC (rev 23370)
@@ -6,55 +6,57 @@
  * @brief This code implements the BASE64 algorithm
  * @author Matthieu Speder
  */
-
-#include <memory.h>
-#include <stdlib.h>
 #include "base64.h"
 
 static const char base64_chars[] =
-               
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+  "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
 
-static const char base64_digits[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-               0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0,
-               0, 0, 0, 0, 0, 62, 0, 0, 0, 63, 52, 53, 54, 55, 56, 57, 58, 59, 
60, 61,
-               0, 0, 0, -1, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 
13,
-               14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 0, 0, 0, 0, 0, 
0, 26,
-               27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 
43, 44,
-               45, 46, 47, 48, 49, 50, 51, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0,
-               0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0,
-               0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0,
-               0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0,
-               0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0,
-               0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0 };
+static const char base64_digits[] =
+  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+    0, 0, 0, 0, 0, 62, 0, 0, 0, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61,
+    0, 0, 0, -1, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
+    14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 0, 0, 0, 0, 0, 0, 26,
+    27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
+    45, 46, 47, 48, 49, 50, 51, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
 
 
-char* BASE64Decode(const char* src) {
-       unsigned int in_len = strlen(src);
-       char* dest;
-       char* result;
-
-       if (in_len % 4) {
-               /* Wrong base64 string length */
-               return NULL;
-       }
-       result = dest = malloc(in_len / 4 * 3 + 1);
-       if (result == NULL)
-          return NULL; /* out of memory */
-       while (*src) {
-               char a = base64_digits[(unsigned char)*(src++)];
-               char b = base64_digits[(unsigned char)*(src++)];
-               char c = base64_digits[(unsigned char)*(src++)];
-               char d = base64_digits[(unsigned char)*(src++)];
-               *(dest++) = (a << 2) | ((b & 0x30) >> 4);
-               if (c == (char)-1)
-                       break;
-               *(dest++) = ((b & 0x0f) << 4) | ((c & 0x3c) >> 2);
-               if (d == (char)-1)
-                       break;
-               *(dest++) = ((c & 0x03) << 6) | d;
-       }
-       *dest = 0;
-       return result;
+char * 
+BASE64Decode(const char* src) 
+{
+  size_t in_len = strlen (src);
+  char* dest;
+  char* result;
+  
+  if (in_len % 4) 
+    {
+      /* Wrong base64 string length */
+      return NULL;
+    }
+  result = dest = malloc(in_len / 4 * 3 + 1);
+  if (result == NULL)
+    return NULL; /* out of memory */
+  while (*src) {
+    char a = base64_digits[(unsigned char)*(src++)];
+    char b = base64_digits[(unsigned char)*(src++)];
+    char c = base64_digits[(unsigned char)*(src++)];
+    char d = base64_digits[(unsigned char)*(src++)];
+    *(dest++) = (a << 2) | ((b & 0x30) >> 4);
+    if (c == (char)-1)
+      break;
+    *(dest++) = ((b & 0x0f) << 4) | ((c & 0x3c) >> 2);
+    if (d == (char)-1)
+      break;
+    *(dest++) = ((c & 0x03) << 6) | d;
+  }
+  *dest = 0;
+  return result;
 }
 
+
 /* end of base64.c */

Modified: libmicrohttpd/src/daemon/base64.h
===================================================================
--- libmicrohttpd/src/daemon/base64.h   2012-08-22 19:18:55 UTC (rev 23369)
+++ libmicrohttpd/src/daemon/base64.h   2012-08-22 22:44:35 UTC (rev 23370)
@@ -1,9 +1,17 @@
+/*
+ * This code implements the BASE64 algorithm.
+ * This code is in the public domain; do with it what you wish.
+ *
+ * @file base64.c
+ * @brief This code implements the BASE64 algorithm
+ * @author Matthieu Speder
+ */
 #ifndef BASE64_H
 #define BASE64_H
 
-#include "MHD_config.h"
+#include "platform.h"
 
-char* BASE64Encode(const char* src);
-char* BASE64Decode(const char* src);
+char * 
+BASE64Decode(const char* src);
 
 #endif /* !BASE64_H */

Modified: libmicrohttpd/src/daemon/md5.c
===================================================================
--- libmicrohttpd/src/daemon/md5.c      2012-08-22 19:18:55 UTC (rev 23369)
+++ libmicrohttpd/src/daemon/md5.c      2012-08-22 22:44:35 UTC (rev 23370)
@@ -19,10 +19,9 @@
    prototypes) to maintain the tradition that Netfone will compile
    with Sun's original "cc". */
 
-#include <memory.h>
-#include <stdint.h>
 #include "md5.h"
 
+
 #ifndef HIGHFIRST
 #define byteReverse(buf, len)  /* Nothing */
 #else
@@ -151,7 +150,8 @@
  * Start MD5 accumulation.  Set bit count to 0 and buffer to mysterious
  * initialization constants.
  */
-void MD5Init(struct MD5Context *ctx)
+void
+MD5Init(struct MD5Context *ctx)
 {
     ctx->buf[0] = 0x67452301;
     ctx->buf[1] = 0xefcdab89;
@@ -218,46 +218,50 @@
  * Final wrapup - pad to 64-byte boundary with the bit pattern 
  * 1 0* (64-bit count of bits processed, MSB-first)
  */
-void MD5Final(unsigned char digest[16],
-             struct MD5Context *ctx)
+void 
+MD5Final(unsigned char digest[16],
+        struct MD5Context *ctx)
 {
-    unsigned count;
-    unsigned char *p;
+  unsigned count;
+  unsigned char *p;
 
-    /* Compute number of bytes mod 64 */
-    count = (ctx->bits[0] >> 3) & 0x3F;
-
-    /* Set the first char of padding to 0x80.  This is safe since there is
-       always at least one byte free */
-    p = ctx->in + count;
-    *p++ = 0x80;
-
-    /* Bytes of padding needed to make 64 bytes */
-    count = 64 - 1 - count;
-
-    /* Pad out to 56 mod 64 */
-    if (count < 8) {
-       /* Two lots of padding:  Pad the first block to 64 bytes */
-       memset(p, 0, count);
-       byteReverse(ctx->in, 16);
-       MD5Transform(ctx->buf, (uint32_t *) ctx->in);
-
-       /* Now fill the next block with 56 bytes */
-       memset(ctx->in, 0, 56);
-    } else {
-       /* Pad block to 56 bytes */
-       memset(p, 0, count - 8);
+  /* Compute number of bytes mod 64 */
+  count = (ctx->bits[0] >> 3) & 0x3F;
+  
+  /* Set the first char of padding to 0x80.  This is safe since there is
+     always at least one byte free */
+  p = ctx->in + count;
+  *p++ = 0x80;
+  
+  /* Bytes of padding needed to make 64 bytes */
+  count = 64 - 1 - count;
+  
+  /* Pad out to 56 mod 64 */
+  if (count < 8) 
+    {
+      /* Two lots of padding:  Pad the first block to 64 bytes */
+      memset(p, 0, count);
+      byteReverse(ctx->in, 16);
+      MD5Transform(ctx->buf, (uint32_t *) ctx->in);
+      
+      /* Now fill the next block with 56 bytes */
+      memset(ctx->in, 0, 56);
+    } 
+  else 
+    {
+      /* Pad block to 56 bytes */
+      memset(p, 0, count - 8);
     }
-    byteReverse(ctx->in, 14);
-
-    /* Append length in bits and transform */
-    ((uint32_t *) ctx->in)[14] = ctx->bits[0];
-    ((uint32_t *) ctx->in)[15] = ctx->bits[1];
-
-    MD5Transform(ctx->buf, (uint32_t *) ctx->in);
-    byteReverse((unsigned char *) ctx->buf, 4);
-    memcpy(digest, ctx->buf, 16);
-    memset(ctx, 0, sizeof(struct MD5Context));        /* In case it's 
sensitive */
+  byteReverse(ctx->in, 14);
+  
+  /* Append length in bits and transform */
+  ((uint32_t *) ctx->in)[14] = ctx->bits[0];
+  ((uint32_t *) ctx->in)[15] = ctx->bits[1];
+  
+  MD5Transform(ctx->buf, (uint32_t *) ctx->in);
+  byteReverse((unsigned char *) ctx->buf, 4);
+  memcpy(digest, ctx->buf, 16);
+  memset(ctx, 0, sizeof(struct MD5Context));        /* In case it's sensitive 
*/
 }
 
 /* end of md5.c */

Modified: libmicrohttpd/src/daemon/md5.h
===================================================================
--- libmicrohttpd/src/daemon/md5.h      2012-08-22 19:18:55 UTC (rev 23369)
+++ libmicrohttpd/src/daemon/md5.h      2012-08-22 22:44:35 UTC (rev 23370)
@@ -1,8 +1,28 @@
+/*
+ * This code implements the MD5 message-digest algorithm.
+ * The algorithm is due to Ron Rivest. This code was
+ * written by Colin Plumb in 1993, no copyright is claimed.
+ * This code is in the public domain; do with it what you wish.
+ *
+ * Equivalent code is available from RSA Data Security, Inc.
+ * This code has been tested against that, and is equivalent,
+ * except that you don't need to include two pages of legalese
+ * with every copy.
+ *
+ * To compute the message digest of a chunk of bytes, declare an
+ * MD5Context structure, pass it to MD5Init, call MD5Update as
+ * needed on buffers full of bytes, and then call MD5Final, which
+ * will fill a supplied 16-byte array with the digest.
+ */
+
+/* Brutally hacked by John Walker back from ANSI C to K&R (no
+   prototypes) to maintain the tradition that Netfone will compile
+   with Sun's original "cc". */
+
 #ifndef MD5_H
 #define MD5_H
 
-#include "MHD_config.h"
-
+#include "platform.h"
 #ifdef WORDS_BIGENDIAN
 #define HIGHFIRST
 #endif

Modified: libmicrohttpd/src/include/platform.h
===================================================================
--- libmicrohttpd/src/include/platform.h        2012-08-22 19:18:55 UTC (rev 
23369)
+++ libmicrohttpd/src/include/platform.h        2012-08-22 22:44:35 UTC (rev 
23370)
@@ -74,6 +74,9 @@
 #include <sys/mman.h>
 #define RESTRICT __restrict__
 #endif
+#if HAVE_MEMORY_H
+#include <memory.h>
+#endif
 
 #if HAVE_SYS_SELECT_H
 #include <sys/select.h>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]