X-Git-Url: https://wimlib.net/git/?p=wimlib;a=blobdiff_plain;f=src%2Fsha1.c;h=f09008d1f4a647dce61753ea8334a4a45be028ea;hp=6fb18c4d10983462a002cd752dc42c2a74ae27b8;hb=18b97ba5b37c0134513886062946d0fd521a9b5e;hpb=650997e4865a090b6856c7ca34b02f42994e8e29 diff --git a/src/sha1.c b/src/sha1.c index 6fb18c4d..f09008d1 100644 --- a/src/sha1.c +++ b/src/sha1.c @@ -210,47 +210,3 @@ sha1_buffer(const void *buffer, size_t len, u8 md[SHA1_HASH_SIZE]) } #endif /* !WITH_LIBCRYPTO */ - -static int -sha1_stream(FILE *fp, u8 md[SHA1_HASH_SIZE]) -{ - char buf[BUFFER_SIZE]; - size_t bytes_read; - SHA_CTX ctx; - sha1_init(&ctx); - while (1) { - bytes_read = fread(buf, 1, sizeof(buf), fp); - sha1_update(&ctx, buf, bytes_read); - if (bytes_read < sizeof(buf)) { - if (ferror(fp)) - return WIMLIB_ERR_READ; - break; - } - } - sha1_final(md, &ctx); - return 0; - -} - -/* Calculates the SHA1 message digest of a file. @md must point to a buffer of - * length 20 bytes into which the message digest is written. */ -int -sha1sum(const tchar *filename, u8 md[SHA1_HASH_SIZE]) -{ - FILE *fp; - int ret; - - fp = tfopen(filename, T("rb")); - if (!fp) { - ERROR_WITH_ERRNO("Cannot open the file `%"TS"' for reading", - filename); - return WIMLIB_ERR_OPEN; - } - ret = sha1_stream(fp, md); - if (ret != 0) { - ERROR_WITH_ERRNO("Error calculating SHA1 message digest of " - "`%"TS"'", filename); - } - fclose(fp); - return ret; -}