static int _keyslot_for_segment(struct luks2_hdr *hdr, int keyslot, int segment)
{
	int keyslot_digest, count = 0;
	unsigned s;

	keyslot_digest = LUKS2_digest_by_keyslot(hdr, keyslot);
	if (keyslot_digest < 0)
		return keyslot_digest;

	if (segment >= 0)
		return keyslot_digest == LUKS2_digest_by_segment(hdr, segment);

	for (s = 0; s < json_segments_count(LUKS2_get_segments_jobj(hdr)); s++) {
		if (keyslot_digest == LUKS2_digest_by_segment(hdr, s))
			count++;
	}

	return count;
}
static int _keyslot_for_segment(struct luks2_hdr *hdr, int keyslot, int segment)
{
	int keyslot_digest, count = 0;
	unsigned s;

	keyslot_digest = LUKS2_digest_by_keyslot(hdr, keyslot);
	if (keyslot_digest < 0)
		return keyslot_digest;

	if (segment >= 0)
		return keyslot_digest == LUKS2_digest_by_segment(hdr, segment);

	for (s = 0; s < json_segments_count(LUKS2_get_segments_jobj(hdr)); s++) {
		if (keyslot_digest == LUKS2_digest_by_segment(hdr, s))
			count++;
	}

	return count;
}