diff options
| -rw-r--r-- | drivers/md/dm-crypt.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c index 91e1bf91769..a93637223c8 100644 --- a/drivers/md/dm-crypt.c +++ b/drivers/md/dm-crypt.c | |||
| @@ -158,6 +158,9 @@ static void kcryptd_queue_crypt(struct dm_crypt_io *io); | |||
| 158 | * plain: the initial vector is the 32-bit little-endian version of the sector | 158 | * plain: the initial vector is the 32-bit little-endian version of the sector |
| 159 | * number, padded with zeros if necessary. | 159 | * number, padded with zeros if necessary. |
| 160 | * | 160 | * |
| 161 | * plain64: the initial vector is the 64-bit little-endian version of the sector | ||
| 162 | * number, padded with zeros if necessary. | ||
| 163 | * | ||
| 161 | * essiv: "encrypted sector|salt initial vector", the sector number is | 164 | * essiv: "encrypted sector|salt initial vector", the sector number is |
| 162 | * encrypted with the bulk cipher using a salt as key. The salt | 165 | * encrypted with the bulk cipher using a salt as key. The salt |
| 163 | * should be derived from the bulk cipher's key via hashing. | 166 | * should be derived from the bulk cipher's key via hashing. |
| @@ -180,6 +183,15 @@ static int crypt_iv_plain_gen(struct crypt_config *cc, u8 *iv, sector_t sector) | |||
| 180 | return 0; | 183 | return 0; |
| 181 | } | 184 | } |
| 182 | 185 | ||
| 186 | static int crypt_iv_plain64_gen(struct crypt_config *cc, u8 *iv, | ||
| 187 | sector_t sector) | ||
| 188 | { | ||
| 189 | memset(iv, 0, cc->iv_size); | ||
| 190 | *(u64 *)iv = cpu_to_le64(sector); | ||
| 191 | |||
| 192 | return 0; | ||
| 193 | } | ||
| 194 | |||
| 183 | /* Initialise ESSIV - compute salt but no local memory allocations */ | 195 | /* Initialise ESSIV - compute salt but no local memory allocations */ |
| 184 | static int crypt_iv_essiv_init(struct crypt_config *cc) | 196 | static int crypt_iv_essiv_init(struct crypt_config *cc) |
| 185 | { | 197 | { |
| @@ -342,6 +354,10 @@ static struct crypt_iv_operations crypt_iv_plain_ops = { | |||
| 342 | .generator = crypt_iv_plain_gen | 354 | .generator = crypt_iv_plain_gen |
| 343 | }; | 355 | }; |
| 344 | 356 | ||
| 357 | static struct crypt_iv_operations crypt_iv_plain64_ops = { | ||
| 358 | .generator = crypt_iv_plain64_gen | ||
| 359 | }; | ||
| 360 | |||
| 345 | static struct crypt_iv_operations crypt_iv_essiv_ops = { | 361 | static struct crypt_iv_operations crypt_iv_essiv_ops = { |
| 346 | .ctr = crypt_iv_essiv_ctr, | 362 | .ctr = crypt_iv_essiv_ctr, |
| 347 | .dtr = crypt_iv_essiv_dtr, | 363 | .dtr = crypt_iv_essiv_dtr, |
| @@ -1063,6 +1079,8 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv) | |||
| 1063 | cc->iv_gen_ops = NULL; | 1079 | cc->iv_gen_ops = NULL; |
| 1064 | else if (strcmp(ivmode, "plain") == 0) | 1080 | else if (strcmp(ivmode, "plain") == 0) |
| 1065 | cc->iv_gen_ops = &crypt_iv_plain_ops; | 1081 | cc->iv_gen_ops = &crypt_iv_plain_ops; |
| 1082 | else if (strcmp(ivmode, "plain64") == 0) | ||
| 1083 | cc->iv_gen_ops = &crypt_iv_plain64_ops; | ||
| 1066 | else if (strcmp(ivmode, "essiv") == 0) | 1084 | else if (strcmp(ivmode, "essiv") == 0) |
| 1067 | cc->iv_gen_ops = &crypt_iv_essiv_ops; | 1085 | cc->iv_gen_ops = &crypt_iv_essiv_ops; |
| 1068 | else if (strcmp(ivmode, "benbi") == 0) | 1086 | else if (strcmp(ivmode, "benbi") == 0) |
