+static int verify_io_u_sha1(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_sha1 *vh = hdr_priv(hdr);
+ uint32_t sha1[5];
+ struct sha1_ctx sha1_ctx = {
+ .H = sha1,
+ };
+
+ dprint(FD_VERIFY, "sha1 verify io_u %p, len %u\n", io_u, hdr->len);
+
+ sha1_init(&sha1_ctx);
+ sha1_update(&sha1_ctx, p, hdr->len - hdr_size(hdr));
+
+ if (memcmp(vh->sha1, sha1_ctx.H, sizeof(sha1))) {
+ log_err("sha1: verify failed at %llu/%u\n",
+ io_u->offset + header_num * hdr->len, hdr->len);
+ hexdump(vh->sha1, sizeof(vh->sha1));
+ hexdump(sha1_ctx.H, sizeof(sha1));
+ return EILSEQ;
+ }
+
+ return 0;
+}
+
+static int verify_io_u_crc7(struct verify_header *hdr, struct io_u *io_u,
+ unsigned char header_num)
+{
+ void *p = io_u_verify_off(hdr, io_u, header_num);
+ struct vhdr_crc7 *vh = hdr_priv(hdr);
+ unsigned char c;
+
+ dprint(FD_VERIFY, "crc7 verify io_u %p, len %u\n", io_u, hdr->len);
+
+ c = crc7(p, hdr->len - hdr_size(hdr));
+
+ if (c != vh->crc7) {
+ log_err("crc7: verify failed at %llu/%u\n",
+ io_u->offset + header_num * hdr->len, hdr->len);
+ log_err("crc7: wanted %x, got %x\n", vh->crc7, c);
+ return EILSEQ;
+ }
+
+ return 0;
+}
+
+static int verify_io_u_crc16(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_crc16 *vh = hdr_priv(hdr);
+ unsigned short c;
+
+ dprint(FD_VERIFY, "crc16 verify io_u %p, len %u\n", io_u, hdr->len);
+
+ 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 EILSEQ;
+ }
+
+ 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;
+
+ dprint(FD_VERIFY, "crc64 verify io_u %p, len %u\n", io_u, hdr->len);
+
+ 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 EILSEQ;
+ }
+
+ 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;
+
+ dprint(FD_VERIFY, "crc32 verify io_u %p, len %u\n", io_u, hdr->len);
+
+ 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 EILSEQ;