static int _compare_crypt_devices(struct crypt_device *cd,
			       const struct dm_target *src,
			       const struct dm_target *tgt)
{
	/* for crypt devices keys are mandatory */
	if (!src->u.crypt.vk || !tgt->u.crypt.vk)
		return -EINVAL;

	/* CIPHER checks */
	if (!src->u.crypt.cipher || !tgt->u.crypt.cipher)
		return -EINVAL;
	if (strcmp(src->u.crypt.cipher, tgt->u.crypt.cipher)) {
		log_dbg(cd, "Cipher specs do not match.");
		return -EINVAL;
	}

	if (tgt->u.crypt.vk->keylength == 0 && crypt_is_cipher_null(tgt->u.crypt.cipher))
		log_dbg(cd, "Existing device uses cipher null. Skipping key comparison.");
	else if (_compare_volume_keys(src->u.crypt.vk, 0, tgt->u.crypt.vk, tgt->u.crypt.vk->key_description != NULL)) {
		log_dbg(cd, "Keys in context and target device do not match.");
		return -EINVAL;
	}

	if (crypt_strcmp(src->u.crypt.integrity, tgt->u.crypt.integrity)) {
		log_dbg(cd, "Integrity parameters do not match.");
		return -EINVAL;
	}

	if (src->u.crypt.offset      != tgt->u.crypt.offset ||
	    src->u.crypt.sector_size != tgt->u.crypt.sector_size ||
	    src->u.crypt.iv_offset   != tgt->u.crypt.iv_offset ||
	    src->u.crypt.tag_size    != tgt->u.crypt.tag_size) {
		log_dbg(cd, "Integer parameters do not match.");
		return -EINVAL;
	}

	if (device_is_identical(src->data_device, tgt->data_device) <= 0) {
		log_dbg(cd, "Data devices do not match.");
		return -EINVAL;
	}

	return 0;
}
static int _compare_crypt_devices(struct crypt_device *cd,
			       const struct dm_target *src,
			       const struct dm_target *tgt)
{
	 
	if (!src->u.crypt.vk || !tgt->u.crypt.vk)
		return -EINVAL;

	 
	if (!src->u.crypt.cipher || !tgt->u.crypt.cipher)
		return -EINVAL;
	if (strcmp(src->u.crypt.cipher, tgt->u.crypt.cipher)) {
		log_dbg(cd, "Cipher specs do not match.");
		return -EINVAL;
	}

	if (tgt->u.crypt.vk->keylength == 0 && crypt_is_cipher_null(tgt->u.crypt.cipher))
		log_dbg(cd, "Existing device uses cipher null. Skipping key comparison.");
	else if (_compare_volume_keys(src->u.crypt.vk, 0, tgt->u.crypt.vk, tgt->u.crypt.vk->key_description != NULL)) {
		log_dbg(cd, "Keys in context and target device do not match.");
		return -EINVAL;
	}

	if (crypt_strcmp(src->u.crypt.integrity, tgt->u.crypt.integrity)) {
		log_dbg(cd, "Integrity parameters do not match.");
		return -EINVAL;
	}

	if (src->u.crypt.offset      != tgt->u.crypt.offset ||
	    src->u.crypt.sector_size != tgt->u.crypt.sector_size ||
	    src->u.crypt.iv_offset   != tgt->u.crypt.iv_offset ||
	    src->u.crypt.tag_size    != tgt->u.crypt.tag_size) {
		log_dbg(cd, "Integer parameters do not match.");
		return -EINVAL;
	}

	if (device_is_identical(src->data_device, tgt->data_device) <= 0) {
		log_dbg(cd, "Data devices do not match.");
		return -EINVAL;
	}

	return 0;
}