static CFHashCode _auth_item_hash(CFTypeRef value) { auth_item_t item = (auth_item_t)value; uint64_t crc = crc64_init(); crc = crc64_update(crc, item->data.name, strlen(item->data.name)); if (item->data.value) { crc = crc64_update(crc, item->data.value, item->data.valueLength); } crc = crc64_update(crc, &item->data.flags, sizeof(item->data.flags)); crc = crc64_final(crc); return crc; }
static CFHashCode _mechanism_hash(CFTypeRef value) { uint64_t crc = crc64_init(); mechanism_t mech = (mechanism_t)value; const char * str = mechanism_get_plugin(mech); crc = crc64_update(crc, str, strlen(str)); str = mechanism_get_plugin(mech); crc = crc64_update(crc, str, strlen(str)); bool priv = mechanism_is_privileged(mech); crc = crc64_update(crc, &priv, sizeof(priv)); crc = crc64_final(crc); return crc; }
DVDID_API(dvdid_status_t) dvdid_calculate2(uint64_t *discid, const dvdid_hashinfo_t *hi) { int i; const dvdid__fileinfo_t *fi; crc64_init(discid); for (i = 0; i < DVDID_MAX_DIRS; i++) { fi = hi->fi_first[i]; while (fi != NULL) { #ifdef DVDID_DEBUG fprintf(stderr, "fi: %s %ld %lld\n", fi->name, (long) (fi->size), (long long) (fi->creation_time)); #endif crc64_fileinfo(discid, fi); fi = fi->next; } } for (i = 0; i < DVDID_MAX_FILES; i++) { if (hi->data_buf[i] != NULL) { #ifdef DVDID_DEBUG fprintf(stderr, "fd: %02x %02x %02x %02x ... (%ld bytes)\n" , (unsigned int) (hi->data_buf[i][0]) , (unsigned int) (hi->data_buf[i][1]) , (unsigned int) (hi->data_buf[i][2]) , (unsigned int) (hi->data_buf[i][3]) , (long) (hi->data_size[i])); #endif crc64_buf(discid, hi->data_buf[i], hi->data_size[i]); } } crc64_done(discid); return DVDID_STATUS_OK; }