]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/contrib/sha1.cc
The entire concept of PendingError() is flawed :/.
[apt.git] / apt-pkg / contrib / sha1.cc
index 9416895ac8d5afa0dd7245cb3d579e882b87365f..298a7799bda9e5c23713958ecf5517f0f079d25b 100644 (file)
 #include <config.h>
 
 #include <apt-pkg/sha1.h>
-#include <apt-pkg/strutl.h>
-#include <apt-pkg/macros.h>
 
+#include <stdint.h>
 #include <string.h>
-#include <unistd.h>
-#include <inttypes.h>
                                                                        /*}}}*/
 
 // SHA1Transform - Alters an existing SHA-1 hash                       /*{{{*/
@@ -75,10 +72,9 @@ static void SHA1Transform(uint32_t state[5],uint8_t const buffer[64])
       uint32_t l[16];
    }
    CHAR64LONG16;
-   CHAR64LONG16 *block;
+   CHAR64LONG16 workspace, *block;
 
-   uint8_t workspace[64];
-   block = (CHAR64LONG16 *)workspace;
+   block = &workspace;
    memcpy(block,buffer,sizeof(workspace));
 
    /* Copy context->state[] to working vars */
@@ -243,10 +239,12 @@ SHA1SumValue SHA1Summation::Result()
 // SHA1Summation::Add - Adds content of buffer into the checksum        /*{{{*/
 // ---------------------------------------------------------------------
 /* May not be called after Result() is called */
-bool SHA1Summation::Add(const unsigned char *data,unsigned long len)
+bool SHA1Summation::Add(const unsigned char *data,unsigned long long len)
 {
    if (Done)
       return false;
+   if (len == 0)
+      return true;
 
    uint32_t *state = (uint32_t *)State;
    uint32_t *count = (uint32_t *)Count;