Detect presence of TCW mode support in kernel dmcrypt.

This commit is contained in:
Milan Broz
2013-10-20 13:20:22 +02:00
parent a7e2809466
commit 54c1f71bd3
3 changed files with 12 additions and 2 deletions

View File

@@ -129,6 +129,9 @@ static void _dm_set_crypt_compat(const char *dm_version, unsigned crypt_maj,
if (crypt_maj >= 1 && crypt_min >= 11)
_dm_crypt_flags |= DM_DISCARDS_SUPPORTED;
//if (crypt_maj >= 1 && crypt_min >= 13)
// _dm_crypt_flags |= DM_TCW_SUPPORTED;
/* Repeat test if dm-crypt is not present */
if (crypt_maj > 0)
_dm_crypt_checked = 1;

View File

@@ -655,6 +655,7 @@ int TCRYPT_activate(struct crypt_device *cd,
struct device *device = NULL, *part_device = NULL;
unsigned int i;
int r;
uint32_t req_flags;
struct tcrypt_algs *algs;
enum devcheck device_check;
struct crypt_dm_active_device dmd = {
@@ -684,6 +685,11 @@ int TCRYPT_activate(struct crypt_device *cd,
return -ENOTSUP;
}
if (strstr(params->mode, "-tcw"))
req_flags = DM_TCW_SUPPORTED;
else
req_flags = DM_PLAIN64_SUPPORTED;
algs = TCRYPT_get_algs(params->cipher, params->mode);
if (!algs)
return -EINVAL;
@@ -763,8 +769,8 @@ int TCRYPT_activate(struct crypt_device *cd,
break;
}
if (r < 0 && !(dm_flags() & DM_PLAIN64_SUPPORTED)) {
log_err(cd, _("Kernel doesn't support plain64 IV.\n"));
if (r < 0 && !(dm_flags() & req_flags)) {
log_err(cd, _("Kernel doesn't support TCRYPT compatible mapping.\n"));
r = -ENOTSUP;
}

View File

@@ -39,6 +39,7 @@ struct device;
#define DM_PLAIN64_SUPPORTED (1 << 3) /* plain64 IV */
#define DM_DISCARDS_SUPPORTED (1 << 4) /* discards/TRIM option is supported */
#define DM_VERITY_SUPPORTED (1 << 5) /* dm-verity target supported */
#define DM_TCW_SUPPORTED (1 << 6) /* tcw (TCRYPT CBC with whitening) */
uint32_t dm_flags(void);
#define DM_ACTIVE_DEVICE (1 << 0)