-#endif /* WITH_LIBCRYPTO */
-
-static int sha1_stream(FILE *fp, void *md)
-{
- 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 given the name of a file.
- * @buf must point to a buffer of length 20 bytes into which the message digest
- * is written.
- */
-int sha1sum(const char *filename, void *md)
-{
- FILE *fp;
- int ret;
-
- fp = fopen(filename, "rb");
- if (!fp) {
- ERROR("Cannot open the file `%s' for reading: %m\n", filename);
- return WIMLIB_ERR_OPEN;
- }
- ret = sha1_stream(fp, md);
- fclose(fp);
- return ret;
-}