void crypt_free(struct crypt_device *cd)
{
	if (!cd)
		return;

	log_dbg(cd, "Releasing crypt device %s context.", mdata_device_path(cd));

	dm_backend_exit(cd);
	crypt_free_volume_key(cd->volume_key);

	crypt_free_type(cd);

	device_free(cd, cd->device);
	device_free(cd, cd->metadata_device);

	free(CONST_CAST(void*)cd->pbkdf.type);
	free(CONST_CAST(void*)cd->pbkdf.hash);

	/* Some structures can contain keys (TCRYPT), wipe it */
	crypt_safe_memzero(cd, sizeof(*cd));
	free(cd);
}
void crypt_free(struct crypt_device *cd)
{
	if (!cd)
		return;

	log_dbg(cd, "Releasing crypt device %s context.", mdata_device_path(cd));

	dm_backend_exit(cd);
	crypt_free_volume_key(cd->volume_key);

	crypt_free_type(cd);

	device_free(cd, cd->device);
	device_free(cd, cd->metadata_device);

	free(CONST_CAST(void*)cd->pbkdf.type);
	free(CONST_CAST(void*)cd->pbkdf.hash);

	 
	crypt_safe_memzero(cd, sizeof(*cd));
	free(cd);
}