- if (lte->unhashed) {
- if (ctx->flags & COMPUTE_MISSING_STREAM_HASHES) {
- /* No SHA1 message digest was previously present for the
- * stream. Set it to the one just calculated. */
- DEBUG("Set SHA1 message digest for stream "
- "(size=%"PRIu64").", lte->size);
- copy_hash(lte->hash, hash);
- }
- } else {
- if (ctx->flags & VERIFY_STREAM_HASHES) {
- /* The stream already had a SHA1 message digest present. Verify
- * that it is the same as the calculated value. */
- if (!hashes_equal(hash, lte->hash)) {
- if (wimlib_print_errors) {
- tchar expected_hashstr[SHA1_HASH_SIZE * 2 + 1];
- tchar actual_hashstr[SHA1_HASH_SIZE * 2 + 1];
- sprint_hash(lte->hash, expected_hashstr);
- sprint_hash(hash, actual_hashstr);
- ERROR("The stream is corrupted!\n"
- " (Expected SHA1=%"TS",\n"
- " got SHA1=%"TS")",
- expected_hashstr, actual_hashstr);
- }
- ret = WIMLIB_ERR_INVALID_RESOURCE_HASH;
- errno = EINVAL;
- goto out_next_cb;
- }
- DEBUG("SHA1 message digest okay for "
- "stream (size=%"PRIu64").", lte->size);
+ /* Set the SHA-1 message digest of the blob, or compare the calculated
+ * value with stored value. */
+ if (blob->unhashed) {
+ if (ctx->flags & COMPUTE_MISSING_BLOB_HASHES)
+ copy_hash(blob->hash, hash);
+ } else if ((ctx->flags & VERIFY_BLOB_HASHES) &&
+ unlikely(!hashes_equal(hash, blob->hash)))
+ {
+ if (wimlib_print_errors) {
+ tchar expected_hashstr[SHA1_HASH_SIZE * 2 + 1];
+ tchar actual_hashstr[SHA1_HASH_SIZE * 2 + 1];
+ sprint_hash(blob->hash, expected_hashstr);
+ sprint_hash(hash, actual_hashstr);
+ ERROR("The data is corrupted!\n"
+ " (Expected SHA-1=%"TS", got SHA-1=%"TS")",
+ expected_hashstr, actual_hashstr);