+ void *p = io_u_verify_off(hdr, io_u, header_num);
+ struct vhdr_crc16 *vh = hdr_priv(hdr);
+ unsigned short c;
+
+ c = crc16(p, hdr->len - hdr_size(hdr));
+
+ if (c != vh->crc16) {
+ log_err("crc16: verify failed at %llu/%u\n",
+ io_u->offset + header_num * hdr->len,
+ hdr->len);
+ log_err("crc16: wanted %x, got %x\n", vh->crc16, c);
+ return EIO;
+ }
+
+ return 0;
+}
+
+static int verify_io_u_crc64(struct verify_header *hdr, struct io_u *io_u,
+ unsigned int header_num)
+{
+ void *p = io_u_verify_off(hdr, io_u, header_num);
+ struct vhdr_crc64 *vh = hdr_priv(hdr);
+ unsigned long long c;
+
+ c = crc64(p, hdr->len - hdr_size(hdr));
+
+ if (c != vh->crc64) {
+ log_err("crc64: verify failed at %llu/%u\n",
+ io_u->offset + header_num * hdr->len,
+ hdr->len);
+ log_err("crc64: wanted %llx, got %llx\n", (unsigned long long) vh->crc64, c);
+ return EIO;
+ }
+
+ return 0;
+}
+
+static int verify_io_u_crc32(struct verify_header *hdr, struct io_u *io_u,
+ unsigned int header_num)
+{
+ void *p = io_u_verify_off(hdr, io_u, header_num);
+ struct vhdr_crc32 *vh = hdr_priv(hdr);
+ uint32_t c;
+
+ c = crc32(p, hdr->len - hdr_size(hdr));
+
+ if (c != vh->crc32) {
+ log_err("crc32: verify failed at %llu/%u\n",
+ io_u->offset + header_num * hdr->len,
+ hdr->len);
+ log_err("crc32: wanted %x, got %x\n", vh->crc32, c);
+ return EIO;
+ }
+
+ return 0;
+}
+
+static int verify_io_u_md5(struct verify_header *hdr, struct io_u *io_u,
+ unsigned int header_num)
+{
+ void *p = io_u_verify_off(hdr, io_u, header_num);
+ struct vhdr_md5 *vh = hdr_priv(hdr);
+ uint32_t hash[MD5_HASH_WORDS];
+ struct md5_ctx md5_ctx = {
+ .hash = hash,
+ };
+
+ md5_init(&md5_ctx);
+ md5_update(&md5_ctx, p, hdr->len - hdr_size(hdr));
+
+ if (memcmp(vh->md5_digest, md5_ctx.hash, sizeof(hash))) {
+ log_err("md5: verify failed at %llu/%u\n",
+ io_u->offset + header_num * hdr->len,
+ hdr->len);
+ hexdump(vh->md5_digest, sizeof(vh->md5_digest));
+ hexdump(md5_ctx.hash, sizeof(hash));
+ return EIO;
+ }