net.c \
backuppcd-common.c
+backuppcd_passwd_LDADD = lib/libgnu.a
#backuppcd_passwd_SOURCES = backuppcd-passwd.c \
#
\ No newline at end of file
#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;
exit(EXIT_FAILURE);
}
- printf("%s\n", SHA1sum(plaintext));
+ printf("%s\n", sha1sum(plaintext));
return(EXIT_SUCCESS);
}
#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)
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);
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: