X-Git-Url: https://wimlib.net/git/?a=blobdiff_plain;f=src%2Fsha1.h;h=3f500b23b43b01e82fbeb7a1732e7f30e9af1fcb;hb=cbeb81145e2532bfcf3f5e58c6be000615f54953;hp=5238a92cc8ff93a7c29d8e13e27ee2f1995b9106;hpb=14baa6ae892debbaa18dba8119931580efd0e517;p=wimlib diff --git a/src/sha1.h b/src/sha1.h index 5238a92c..3f500b23 100644 --- a/src/sha1.h +++ b/src/sha1.h @@ -4,7 +4,7 @@ #include "config.h" #include #include -#include "string.h" +#include #include "util.h" #define SHA1_HASH_SIZE 20 @@ -37,9 +37,9 @@ hashes_cmp(const u8 h1[SHA1_HASH_SIZE], } static inline void -print_hash(const u8 hash[SHA1_HASH_SIZE]) +print_hash(const u8 hash[SHA1_HASH_SIZE], FILE *out) { - print_byte_field(hash, SHA1_HASH_SIZE); + print_byte_field(hash, SHA1_HASH_SIZE, out); } static inline bool @@ -47,7 +47,7 @@ is_zero_hash(const u8 hash[SHA1_HASH_SIZE]) { if (hash) for (u8 i = 0; i < SHA1_HASH_SIZE / 4; i++) - if (((u32*)hash)[i]) + if (((const u32*)hash)[i]) return false; return true; } @@ -62,7 +62,11 @@ zero_out_hash(u8 hash[SHA1_HASH_SIZE]) #ifdef WITH_LIBCRYPTO #include -#define sha1_buffer SHA1 +static inline void +sha1_buffer(const void *buffer, size_t len, u8 hash[SHA1_HASH_SIZE]) +{ + SHA1(buffer, len, hash); +} #define sha1_init SHA1_Init #define sha1_update SHA1_Update #define sha1_final SHA1_Final @@ -76,20 +80,17 @@ typedef struct { } SHA_CTX; extern void -sha1_buffer(const u8 buffer[], size_t len, u8 hash[SHA1_HASH_SIZE]); +sha1_buffer(const void *buffer, size_t len, u8 hash[SHA1_HASH_SIZE]); extern void sha1_init(SHA_CTX *ctx); extern void -sha1_update(SHA_CTX *ctx, const u8 data[], size_t len); +sha1_update(SHA_CTX *ctx, const void *data, size_t len); extern void sha1_final(u8 hash[SHA1_HASH_SIZE], SHA_CTX *ctx); #endif /* !WITH_LIBCRYPTO */ -extern int -sha1sum(const mbchar *filename, u8 hash[SHA1_HASH_SIZE]); - #endif /* _WIMLIB_SHA1_H */