Source
38
38
39
39
static int
40
40
cryptoloop_init(struct loop_device *lo, const struct loop_info64 *info)
41
41
{
42
42
int err = -EINVAL;
43
43
int cipher_len;
44
44
int mode_len;
45
45
char cms[LO_NAME_SIZE]; /* cipher-mode string */
46
46
char *mode;
47
47
char *cmsp = cms; /* c-m string pointer */
48
-
struct crypto_skcipher *tfm;
48
+
struct crypto_sync_skcipher *tfm;
49
49
50
50
/* encryption breaks for non sector aligned offsets */
51
51
52
52
if (info->lo_offset % LOOP_IV_SECTOR_SIZE)
53
53
goto out;
54
54
55
55
strncpy(cms, info->lo_crypt_name, LO_NAME_SIZE);
56
56
cms[LO_NAME_SIZE - 1] = 0;
57
57
58
58
cipher_len = strcspn(cmsp, "-");
73
73
return -EINVAL;
74
74
75
75
memmove(cms, mode, mode_len);
76
76
cmsp = cms + mode_len;
77
77
*cmsp++ = '(';
78
78
memcpy(cmsp, info->lo_crypt_name, cipher_len);
79
79
cmsp += cipher_len;
80
80
*cmsp++ = ')';
81
81
*cmsp = 0;
82
82
83
-
tfm = crypto_alloc_skcipher(cms, 0, CRYPTO_ALG_ASYNC);
83
+
tfm = crypto_alloc_sync_skcipher(cms, 0, 0);
84
84
if (IS_ERR(tfm))
85
85
return PTR_ERR(tfm);
86
86
87
-
err = crypto_skcipher_setkey(tfm, info->lo_encrypt_key,
88
-
info->lo_encrypt_key_size);
89
-
87
+
err = crypto_sync_skcipher_setkey(tfm, info->lo_encrypt_key,
88
+
info->lo_encrypt_key_size);
89
+
90
90
if (err != 0)
91
91
goto out_free_tfm;
92
92
93
93
lo->key_data = tfm;
94
94
return 0;
95
95
96
96
out_free_tfm:
97
-
crypto_free_skcipher(tfm);
97
+
crypto_free_sync_skcipher(tfm);
98
98
99
99
out:
100
100
return err;
101
101
}
102
102
103
103
104
104
typedef int (*encdec_cbc_t)(struct skcipher_request *req);
105
105
106
106
static int
107
107
cryptoloop_transfer(struct loop_device *lo, int cmd,
108
108
struct page *raw_page, unsigned raw_off,
109
109
struct page *loop_page, unsigned loop_off,
110
110
int size, sector_t IV)
111
111
{
112
-
struct crypto_skcipher *tfm = lo->key_data;
113
-
SKCIPHER_REQUEST_ON_STACK(req, tfm);
112
+
struct crypto_sync_skcipher *tfm = lo->key_data;
113
+
SYNC_SKCIPHER_REQUEST_ON_STACK(req, tfm);
114
114
struct scatterlist sg_out;
115
115
struct scatterlist sg_in;
116
116
117
117
encdec_cbc_t encdecfunc;
118
118
struct page *in_page, *out_page;
119
119
unsigned in_offs, out_offs;
120
120
int err;
121
121
122
-
skcipher_request_set_tfm(req, tfm);
122
+
skcipher_request_set_sync_tfm(req, tfm);
123
123
skcipher_request_set_callback(req, CRYPTO_TFM_REQ_MAY_SLEEP,
124
124
NULL, NULL);
125
125
126
126
sg_init_table(&sg_out, 1);
127
127
sg_init_table(&sg_in, 1);
128
128
129
129
if (cmd == READ) {
130
130
in_page = raw_page;
131
131
in_offs = raw_off;
132
132
out_page = loop_page;
168
168
169
169
static int
170
170
cryptoloop_ioctl(struct loop_device *lo, int cmd, unsigned long arg)
171
171
{
172
172
return -EINVAL;
173
173
}
174
174
175
175
static int
176
176
cryptoloop_release(struct loop_device *lo)
177
177
{
178
-
struct crypto_skcipher *tfm = lo->key_data;
178
+
struct crypto_sync_skcipher *tfm = lo->key_data;
179
179
if (tfm != NULL) {
180
-
crypto_free_skcipher(tfm);
180
+
crypto_free_sync_skcipher(tfm);
181
181
lo->key_data = NULL;
182
182
return 0;
183
183
}
184
184
printk(KERN_ERR "cryptoloop_release(): tfm == NULL?\n");
185
185
return -EINVAL;
186
186
}
187
187
188
188
static struct loop_func_table cryptoloop_funcs = {
189
189
.number = LO_CRYPT_CRYPTOAPI,
190
190
.init = cryptoloop_init,