]> pd.if.org Git - zpackage/blobdiff - lib/zpm.c
switch to blake2
[zpackage] / lib / zpm.c
index 3cc7632d76280dacb9e4be3957a1794415a7d4a5..63ecc17632c46eefb37aa5137abe22421cb38c28 100644 (file)
--- a/lib/zpm.c
+++ b/lib/zpm.c
@@ -581,11 +581,9 @@ int zpm_import(struct zpm *zpm, char *path, uint32_t flags, char *hash) {
        int fd;
        void *content = 0;
        struct stat sbuf;
-       unsigned char tmp[32];
-       struct sha256_state md;
        sqlite3_stmt *ifile = 0;
        int haverow = 0,havedata = 0;
-       int j,rc,type;
+       int rc,type;
        char hashbuf[65];
 
        /* xz compress it */
@@ -642,13 +640,7 @@ int zpm_import(struct zpm *zpm, char *path, uint32_t flags, char *hash) {
                return 0;
        }
 
-       /* get hash */
-       sha256_init(&md);
-       sha256_process(&md, content, sbuf.st_size);
-       sha256_done(&md, tmp);
-       for (j=0;j<32;j++) {
-               sprintf(hash+j*2, "%02x", (unsigned)tmp[j]);
-       }
+       zpm_hash_mem(content, sbuf.st_size, hash);
        hash[64] = 0;
 
        /* TODO check null */