void a78_partialhash(util::hash_collection &dest, const unsigned char *data, unsigned long length, const char *functions) { if (length <= 128) return; dest.compute(&data[128], length - 128, functions); }
void device_image_interface::device_compute_hash(util::hash_collection &hashes, const void *data, size_t length, const char *types) const { /* retrieve the partial hash func */ device_image_partialhash_func partialhash = get_partial_hash(); /* compute the hash */ if (partialhash) partialhash(hashes, (const unsigned char*)data, length, types); else hashes.compute(reinterpret_cast<const UINT8 *>(data), length, types); }
void device_image_interface::run_hash(void (*partialhash)(util::hash_collection &, const unsigned char *, unsigned long, const char *), util::hash_collection &hashes, const char *types) { UINT32 size; dynamic_buffer buf; hashes.reset(); size = (UINT32) length(); buf.resize(size); memset(&buf[0], 0, size); // read the file fseek(0, SEEK_SET); fread(&buf[0], size); if (partialhash) partialhash(hashes, &buf[0], size, types); else hashes.compute(&buf[0], size, types); // cleanup fseek(0, SEEK_SET); }