]> err.no Git - backuppcd/commitdiff
More sha1 from gnulib updates; update the rest of the source tree too
authorTollef Fog Heen <tfheen@err.no>
Thu, 17 Jul 2008 18:20:54 +0000 (20:20 +0200)
committerTollef Fog Heen <tfheen@err.no>
Thu, 17 Jul 2008 18:20:54 +0000 (20:20 +0200)
Makefile.am
backuppcd-passwd.c
libbackuppcd.c

index 8b727503eac6e716e6eb49b340057cec3bc7a144..76b1c4845cc08f4fab44298952314b2097989522 100644 (file)
@@ -26,5 +26,6 @@ backuppcd_tar_SOURCES = backuppcd-tar.c \
        net.c \
        backuppcd-common.c
 
+backuppcd_passwd_LDADD = lib/libgnu.a
 #backuppcd_passwd_SOURCES = backuppcd-passwd.c \
 #
\ No newline at end of file
index b6ba4f17894602c0a60e05f68f44909782d18ab2..b05e38594969e8d99458865664b6524da3289e91 100644 (file)
@@ -1,7 +1,30 @@
 #include "compat.h"
-#include "sha1.h"
+#include "lib/sha1.h"
 #include <stdio.h>
 
+static char * sha1sum(char *string) {
+       unsigned char digest[20];
+       static char ret[(sizeof(digest) * 2) + 1] = {0};
+       static char hexabet[] = "0123456789abcdef";
+       struct sha1_ctx ctx;
+       int retcnt = 0, i;
+
+       sha1_init_ctx(&ctx);
+
+       sha1_process_bytes(string, strlen(string), &ctx);
+
+       sha1_finish_ctx(&ctx, digest);
+
+       for (i = 0; i < sizeof(digest); i++) {
+               ret[retcnt++] = hexabet[(digest[i] & 0xf0) >> 4];
+               ret[retcnt++] = hexabet[digest[i] & 0xf];
+       }
+
+       ret[retcnt] = '\0';
+
+       return(ret);
+}
+
 int main(int argc, char **argv) {
        char *plaintext;
        char *fgets_ret;
@@ -43,7 +66,7 @@ int main(int argc, char **argv) {
                exit(EXIT_FAILURE);
        }
 
-       printf("%s\n", SHA1sum(plaintext));
+       printf("%s\n", sha1sum(plaintext));
 
        return(EXIT_SUCCESS);
 }
index c123fcc23f607d221ec3b4f35ca0722eb7fb19a8..099735dde9e1cd8b09edbd546309a22f69679a76 100644 (file)
@@ -2,7 +2,7 @@
 #include "backuppcd.h"
 #include "backuppcd-common.h"
 #include "libbackuppcd.h"
-#include "sha1.h"
+#include "lib/sha1.h"
 #include "net.h"
 
 #define BPC_CMD_GET_DATA (BPC_CMD_GET | 0x100)
@@ -1525,7 +1525,7 @@ int bpc_rdiffget(BPC_CONN *handle, const char *remote_src, const char *dest) {
                        break;
                case BPC_HASH_SHA1:
                        hash_ent_size = (160 / 8);
-                       hash_handle = malloc(sizeof(SHA1_CTX));
+                       hash_handle = malloc(sizeof(struct sha1_ctx));
                        break;
                case BPC_HASH_BPC:
                        hash_ent_size = (128 / 8);
@@ -1567,8 +1567,8 @@ int bpc_rdiffget(BPC_CONN *handle, const char *remote_src, const char *dest) {
                        case BPC_HASH_NONE:
                                break;
                        case BPC_HASH_SHA1:
-                               SHA1Init(hash_handle);
-                               SHA1Update(hash_handle, buf, read_ret);
+                               sha1_init_ctx(hash_handle);
+                               sha1_process_bytes(buf, read_ret, hash_handle);
 //                             SHA1Final(digest[20], hash_handle);
                                break;
                        case BPC_HASH_MD5: