From c31854e2b34a65c93466adbb8d4d88165b7d21cb Mon Sep 17 00:00:00 2001 From: Milan Broz Date: Tue, 22 Mar 2011 08:51:00 +0000 Subject: [PATCH] Check for plain64 IV support in DM backend. git-svn-id: https://cryptsetup.googlecode.com/svn/trunk@477 36d66b0a-2a48-0410-832c-cd162a569da5 --- lib/internal.h | 1 + lib/libdevmapper.c | 4 ++++ lib/loopaes/loopaes.c | 10 +++++++--- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/internal.h b/lib/internal.h index 8e32749..6ffae93 100644 --- a/lib/internal.h +++ b/lib/internal.h @@ -62,6 +62,7 @@ const char *get_error(void); #define DM_KEY_WIPE_SUPPORTED (1 << 0) /* key wipe message */ #define DM_LMK_SUPPORTED (1 << 1) /* lmk mode */ #define DM_SECURE_SUPPORTED (1 << 2) /* wipe (secure) buffer flag */ +#define DM_PLAIN64_SUPPORTED (1 << 3) /* plain64 IV */ uint32_t dm_flags(void); const char *dm_get_dir(void); diff --git a/lib/libdevmapper.c b/lib/libdevmapper.c index a20a8db..cf8ccda 100644 --- a/lib/libdevmapper.c +++ b/lib/libdevmapper.c @@ -115,6 +115,10 @@ static void _dm_set_crypt_compat(const char *dm_version, unsigned crypt_maj, if (dm_maj >= 4 && dm_min >= 20) _dm_crypt_flags |= DM_SECURE_SUPPORTED; + /* not perfect, 2.6.33 supports with 1.7.0 */ + if (crypt_maj >= 1 && crypt_min >= 8) + _dm_crypt_flags |= DM_PLAIN64_SUPPORTED; + /* Repeat test if dm-crypt is not present */ if (crypt_maj > 0) _dm_crypt_checked = 1; diff --git a/lib/loopaes/loopaes.c b/lib/loopaes/loopaes.c index a378956..aaa9a94 100644 --- a/lib/loopaes/loopaes.c +++ b/lib/loopaes/loopaes.c @@ -181,6 +181,7 @@ int LOOPAES_activate(struct crypt_device *cd, uint32_t flags) { uint64_t size, offset; + uint32_t req_flags; char *cipher; const char *device; int read_only, r; @@ -195,10 +196,13 @@ int LOOPAES_activate(struct crypt_device *cd, if (r) return r; - if (keys_count == 1) + if (keys_count == 1) { + req_flags = DM_PLAIN64_SUPPORTED; r = asprintf(&cipher, "%s-%s", base_cipher, "cbc-plain64"); - else + } else { + req_flags = DM_LMK_SUPPORTED; r = asprintf(&cipher, "%s:%d-%s", base_cipher, 64, "cbc-lmk"); + } if (r < 0) return -ENOMEM; @@ -209,7 +213,7 @@ int LOOPAES_activate(struct crypt_device *cd, size, offset, offset, vk->keylength, vk->key, read_only, 0); - if (!r && keys_count != 1 && !(dm_flags() & DM_LMK_SUPPORTED)) { + if (!r && !(dm_flags() & req_flags)) { log_err(cd, _("Kernel doesn't support loop-AES compatible mapping.\n")); r = -ENOTSUP; } -- 2.7.4