[PATCH 1/4] dm-crypt: clarify cipher vs. cipher mode

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The original code used cc->cipher for two things:

(a) It starts out containing the cipher mode string
("xts(aes)") used to get the ablkcipher.

(b) Then it gets overwritten to contain just the plain
cipher string ("aes") used to allocate the plain cipher
for essiv and for display by dm status.

So change it to be used only for the latter and put
cipher mode string on the stack.

Signed-off-by: Max Vozeler <max@xxxxxxxxxxxxx>
Cc: Milan Broz <mbroz@xxxxxxxxxx>
Cc: Jari Ruusu <jariruusu@xxxxxxxxxxxxxxxxxxxxx>
---
 drivers/md/dm-crypt.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
index a936372..e783f93 100644
--- a/drivers/md/dm-crypt.c
+++ b/drivers/md/dm-crypt.c
@@ -1014,6 +1014,7 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv)
 	char *ivopts;
 	unsigned int key_size;
 	unsigned long long tmpll;
+	char ciphermode[CRYPTO_MAX_ALG_NAME];
 
 	if (argc != 5) {
 		ti->error = "Not enough arguments";
@@ -1049,13 +1050,13 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv)
 		goto bad_cipher;
 	}
 
-	if (snprintf(cc->cipher, CRYPTO_MAX_ALG_NAME, "%s(%s)",
+	if (snprintf(ciphermode, CRYPTO_MAX_ALG_NAME, "%s(%s)",
 		     chainmode, cipher) >= CRYPTO_MAX_ALG_NAME) {
 		ti->error = "Chain mode + cipher name is too long";
 		goto bad_cipher;
 	}
 
-	tfm = crypto_alloc_ablkcipher(cc->cipher, 0, 0);
+	tfm = crypto_alloc_ablkcipher(ciphermode, 0, 0);
 	if (IS_ERR(tfm)) {
 		ti->error = "Error allocating crypto tfm";
 		goto bad_cipher;
-- 
1.6.5.4

--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Kernel]     [Gnu Classpath]     [Gnu Crypto]     [DM Crypt]     [Netfilter]     [Bugtraq]

  Powered by Linux