Add a third default.
[oweals/gnunet.git] / src / util / crypto_crc.c
index f86fe56969ba5785ccfc2ad1005253504c687506..cda6243bee2723d88494dba18397cd187aba4efc 100644 (file)
@@ -4,7 +4,7 @@
 
      GNUnet is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published
-     by the Free Software Foundation; either version 2, or (at your
+     by the Free Software Foundation; either version 3, or (at your
      option) any later version.
 
      GNUnet is distributed in the hope that it will be useful, but
  * @brief implementation of CRC16 and CRC32
  * @author Christian Grothoff
  */
-
 #include "platform.h"
-#include "gnunet_common.h"
-#include "gnunet_crypto_lib.h"
+#include "gnunet_util_lib.h"
 
 #define LOG(kind,...) GNUNET_log_from (kind, "util", __VA_ARGS__)
 
@@ -51,7 +49,7 @@ static uLong crc_table[256];
 
 /*
  * This routine writes each crc_table entry exactly once,
- * with the ccorrect final value.  Thus, it is safe to call
+ * with the correct final value.  Thus, it is safe to call
  * even on a table that someone else is using concurrently.
  */
 static void
@@ -129,10 +127,11 @@ GNUNET_CRYPTO_crc16_step (uint32_t sum, const void *buf, size_t len)
   for (; len >= 2; len -= 2)
     sum += *(hdr++);
   if (len == 1)
-    sum += *((unsigned char *) hdr);
+    sum += (*hdr) & ntohs(0xFF00);
   return sum;
 }
 
+
 /**
  * Convert results from GNUNET_CRYPTO_crc16_step to final crc16.
  *