Explorar el Código

Hashing: removed support for zero-sized data portion

Evgeny Grin (Karlson2k) hace 1 año
padre
commit
fc49e62fbe
Se han modificado 5 ficheros con 6 adiciones y 18 borrados
  1. 1 0
      src/mhd2/md5_ext.c
  2. 1 6
      src/mhd2/md5_int.c
  3. 2 0
      src/mhd2/sha256_ext.c
  4. 1 6
      src/mhd2/sha256_int.c
  5. 1 6
      src/mhd2/sha512_256_int.c

+ 1 - 0
src/mhd2/md5_ext.c

@@ -69,6 +69,7 @@ mhd_MD5_update (struct mhd_Md5CtxExt *ctx,
                 size_t size,
                 const uint8_t *data)
 {
+  mhd_assert (0 != size);
   if (0 == ctx->ext_error)
     ctx->ext_error = gnutls_hash (ctx->handle, data, size);
 }

+ 1 - 6
src/mhd2/md5_int.c

@@ -387,12 +387,7 @@ mhd_MD5_update (struct mhd_Md5CtxInt *restrict ctx,
 {
   unsigned int bytes_have; /**< Number of bytes in the context buffer */
 
-  mhd_assert ((data != NULL) || (size == 0));
-
-#ifndef MHD_FAVOR_SMALL_CODE
-  if (0 == size)
-    return; /* Shortcut, do nothing */
-#endif /* MHD_FAVOR_SMALL_CODE */
+  mhd_assert (0 != size);
 
   /* Note: (count & (mhd_MD5_BLOCK_SIZE-1))
            equals (count % mhd_MD5_BLOCK_SIZE) for this block size. */

+ 2 - 0
src/mhd2/sha256_ext.c

@@ -68,6 +68,8 @@ mhd_SHA256_update (struct mhd_Sha256CtxExt *ctx,
                    size_t size,
                    const uint8_t *data)
 {
+  mhd_assert (0 != size);
+
   if (0 == ctx->ext_error)
     ctx->ext_error = gnutls_hash (ctx->handle, data, size);
 }

+ 1 - 6
src/mhd2/sha256_int.c

@@ -399,12 +399,7 @@ mhd_SHA256_update (struct mhd_Sha256CtxInt *restrict ctx,
 {
   unsigned bytes_have; /**< Number of bytes in buffer */
 
-  mhd_assert ((data != NULL) || (size == 0));
-
-#ifndef MHD_FAVOR_SMALL_CODE
-  if (0 == size)
-    return; /* Shortcut, do nothing */
-#endif /* MHD_FAVOR_SMALL_CODE */
+  mhd_assert (0 != size);
 
   /* Note: (count & (mhd_SHA256_BLOCK_SIZE-1))
            equals (count % mhd_SHA256_BLOCK_SIZE) for this block size. */

+ 1 - 6
src/mhd2/sha512_256_int.c

@@ -458,12 +458,7 @@ mhd_SHA512_256_update (struct mhd_Sha512_256CtxInt *restrict ctx,
   unsigned int bytes_have; /**< Number of bytes in the context buffer */
   uint64_t count_hi; /**< The high part to be moved to another variable */
 
-  mhd_assert ((data != NULL) || (size == 0));
-
-#ifndef MHD_FAVOR_SMALL_CODE
-  if (0 == size)
-    return; /* Shortcut, do nothing */
-#endif /* ! MHD_FAVOR_SMALL_CODE */
+  mhd_assert (0 != size);
 
   /* Note: (count & (mhd_SHA512_256_BLOCK_SIZE-1))
            equals (count % mhd_SHA512_256_BLOCK_SIZE) for this block size. */