Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 46b47730 authored by Ludwig Nussel's avatar Ludwig Nussel Committed by Linus Torvalds
Browse files

dm crypt: add null iv



Add a new IV generation method 'null' to read old filesystem images created
with SuSE's loop_fish2 module.

Signed-off-by: default avatarLudwig Nussel <ludwig.nussel@suse.de>
Acked-By: default avatarChristophe Saout <christophe@saout.de>
Signed-off-by: default avatarAlasdair G Kergon <agk@redhat.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent f97380bc
Loading
Loading
Loading
Loading
+17 −1
Original line number Original line Diff line number Diff line
@@ -121,6 +121,9 @@ static void clone_init(struct crypt_io *, struct bio *);
 * benbi: the 64-bit "big-endian 'narrow block'-count", starting at 1
 * benbi: the 64-bit "big-endian 'narrow block'-count", starting at 1
 *        (needed for LRW-32-AES and possible other narrow block modes)
 *        (needed for LRW-32-AES and possible other narrow block modes)
 *
 *
 * null: the initial vector is always zero.  Provides compatibility with
 *       obsolete loop_fish2 devices.  Do not use for new devices.
 *
 * plumb: unimplemented, see:
 * plumb: unimplemented, see:
 * http://article.gmane.org/gmane.linux.kernel.device-mapper.dm-crypt/454
 * http://article.gmane.org/gmane.linux.kernel.device-mapper.dm-crypt/454
 */
 */
@@ -257,6 +260,13 @@ static int crypt_iv_benbi_gen(struct crypt_config *cc, u8 *iv, sector_t sector)
	return 0;
	return 0;
}
}


static int crypt_iv_null_gen(struct crypt_config *cc, u8 *iv, sector_t sector)
{
	memset(iv, 0, cc->iv_size);

	return 0;
}

static struct crypt_iv_operations crypt_iv_plain_ops = {
static struct crypt_iv_operations crypt_iv_plain_ops = {
	.generator = crypt_iv_plain_gen
	.generator = crypt_iv_plain_gen
};
};
@@ -273,6 +283,10 @@ static struct crypt_iv_operations crypt_iv_benbi_ops = {
	.generator = crypt_iv_benbi_gen
	.generator = crypt_iv_benbi_gen
};
};


static struct crypt_iv_operations crypt_iv_null_ops = {
	.generator = crypt_iv_null_gen
};

static int
static int
crypt_convert_scatterlist(struct crypt_config *cc, struct scatterlist *out,
crypt_convert_scatterlist(struct crypt_config *cc, struct scatterlist *out,
                          struct scatterlist *in, unsigned int length,
                          struct scatterlist *in, unsigned int length,
@@ -803,6 +817,8 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv)
		cc->iv_gen_ops = &crypt_iv_essiv_ops;
		cc->iv_gen_ops = &crypt_iv_essiv_ops;
	else if (strcmp(ivmode, "benbi") == 0)
	else if (strcmp(ivmode, "benbi") == 0)
		cc->iv_gen_ops = &crypt_iv_benbi_ops;
		cc->iv_gen_ops = &crypt_iv_benbi_ops;
	else if (strcmp(ivmode, "null") == 0)
		cc->iv_gen_ops = &crypt_iv_null_ops;
	else {
	else {
		ti->error = "Invalid IV mode";
		ti->error = "Invalid IV mode";
		goto bad2;
		goto bad2;
@@ -1030,7 +1046,7 @@ static int crypt_message(struct dm_target *ti, unsigned argc, char **argv)


static struct target_type crypt_target = {
static struct target_type crypt_target = {
	.name   = "crypt",
	.name   = "crypt",
	.version= {1, 3, 0},
	.version= {1, 5, 0},
	.module = THIS_MODULE,
	.module = THIS_MODULE,
	.ctr    = crypt_ctr,
	.ctr    = crypt_ctr,
	.dtr    = crypt_dtr,
	.dtr    = crypt_dtr,