aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/dm-crypt.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/md/dm-crypt.c')
-rw-r--r--drivers/md/dm-crypt.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
index 28c1a628621f..cf6631056683 100644
--- a/drivers/md/dm-crypt.c
+++ b/drivers/md/dm-crypt.c
@@ -15,7 +15,7 @@
15#include <linux/crypto.h> 15#include <linux/crypto.h>
16#include <linux/workqueue.h> 16#include <linux/workqueue.h>
17#include <asm/atomic.h> 17#include <asm/atomic.h>
18#include <asm/scatterlist.h> 18#include <linux/scatterlist.h>
19#include <asm/page.h> 19#include <asm/page.h>
20 20
21#include "dm.h" 21#include "dm.h"
@@ -164,9 +164,7 @@ static int crypt_iv_essiv_ctr(struct crypt_config *cc, struct dm_target *ti,
164 return -ENOMEM; 164 return -ENOMEM;
165 } 165 }
166 166
167 sg.page = virt_to_page(cc->key); 167 sg_set_buf(&sg, cc->key, cc->key_size);
168 sg.offset = offset_in_page(cc->key);
169 sg.length = cc->key_size;
170 crypto_digest_digest(hash_tfm, &sg, 1, salt); 168 crypto_digest_digest(hash_tfm, &sg, 1, salt);
171 crypto_free_tfm(hash_tfm); 169 crypto_free_tfm(hash_tfm);
172 170
@@ -207,14 +205,12 @@ static void crypt_iv_essiv_dtr(struct crypt_config *cc)
207 205
208static int crypt_iv_essiv_gen(struct crypt_config *cc, u8 *iv, sector_t sector) 206static int crypt_iv_essiv_gen(struct crypt_config *cc, u8 *iv, sector_t sector)
209{ 207{
210 struct scatterlist sg = { NULL, }; 208 struct scatterlist sg;
211 209
212 memset(iv, 0, cc->iv_size); 210 memset(iv, 0, cc->iv_size);
213 *(u64 *)iv = cpu_to_le64(sector); 211 *(u64 *)iv = cpu_to_le64(sector);
214 212
215 sg.page = virt_to_page(iv); 213 sg_set_buf(&sg, iv, cc->iv_size);
216 sg.offset = offset_in_page(iv);
217 sg.length = cc->iv_size;
218 crypto_cipher_encrypt((struct crypto_tfm *)cc->iv_gen_private, 214 crypto_cipher_encrypt((struct crypto_tfm *)cc->iv_gen_private,
219 &sg, &sg, cc->iv_size); 215 &sg, &sg, cc->iv_size);
220 216