'Look for the required hashes in the file.'

def _HashFile(self, fd):

    hashes = fd.Get(fd.Schema.HASH)
    if hashes:
        found_all = True
        for (fingerprint_type, hash_types) in self.HASH_TYPES.iteritems():
            for hash_type in hash_types:
                if (fingerprint_type == 'pecoff'):
                    hash_type = ('pecoff_%s' % hash_type)
                if (not hashes.HasField(hash_type)):
                    found_all = False
                    break
            if (not found_all):
                break
        if found_all:
            return hashes
    fingerprinter = fingerprint.Fingerprinter(fd)
    if ('generic' in self.HASH_TYPES):
        hashers = self._GetHashers(self.HASH_TYPES['generic'])
        fingerprinter.EvalGeneric(hashers=hashers)
    if ('pecoff' in self.HASH_TYPES):
        hashers = self._GetHashers(self.HASH_TYPES['pecoff'])
        if hashers:
            fingerprinter.EvalPecoff(hashers=hashers)
    if (not hashes):
        hashes = fd.Schema.HASH()
    for result in fingerprinter.HashIt():
        fingerprint_type = result['name']
        for hash_type in self.HASH_TYPES[fingerprint_type]:
            if (hash_type not in result):
                continue
            if (hash_type == 'SignedData'):
                for signed_data in result[hash_type]:
                    hashes.signed_data.Append(revision=signed_data[0], cert_type=signed_data[1], certificate=signed_data[2])
                continue
            if (fingerprint_type == 'generic'):
                hashes.Set(hash_type, result[hash_type])
            elif (fingerprint_type == 'pecoff'):
                hashes.Set(('pecoff_%s' % hash_type), result[hash_type])
            else:
                logging.error('Unknown    fingerprint_type    %s.', fingerprint_type)
    try:
        fd.Set(hashes)
    except IOError:
        pass
    return hashes
