Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Revert "crypto: scatterwalk - Move skcipher walk and use it for memcpy_sglist"

This reverts commit 0f8d42bf128d349ad490e87d5574d211245e40f1, with the
memcpy_sglist() part dropped.

Now that memcpy_sglist() no longer uses the skcipher_walk code, the
skcipher_walk code can be moved back to where it belongs.

Signed-off-by: Eric Biggers <ebiggers@kernel.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Eric Biggers and committed by
Herbert Xu
20d868a7 4dffc9bb

+316 -318
-248
crypto/scatterwalk.c
··· 10 10 */ 11 11 12 12 #include <crypto/scatterwalk.h> 13 - #include <linux/crypto.h> 14 - #include <linux/errno.h> 15 13 #include <linux/kernel.h> 16 14 #include <linux/mm.h> 17 15 #include <linux/module.h> 18 16 #include <linux/scatterlist.h> 19 - #include <linux/slab.h> 20 - 21 - enum { 22 - SKCIPHER_WALK_SLOW = 1 << 0, 23 - SKCIPHER_WALK_COPY = 1 << 1, 24 - SKCIPHER_WALK_DIFF = 1 << 2, 25 - SKCIPHER_WALK_SLEEP = 1 << 3, 26 - }; 27 - 28 - static inline gfp_t skcipher_walk_gfp(struct skcipher_walk *walk) 29 - { 30 - return walk->flags & SKCIPHER_WALK_SLEEP ? GFP_KERNEL : GFP_ATOMIC; 31 - } 32 17 33 18 void scatterwalk_skip(struct scatter_walk *walk, unsigned int nbytes) 34 19 { ··· 202 217 return dst; 203 218 } 204 219 EXPORT_SYMBOL_GPL(scatterwalk_ffwd); 205 - 206 - static int skcipher_next_slow(struct skcipher_walk *walk, unsigned int bsize) 207 - { 208 - unsigned alignmask = walk->alignmask; 209 - unsigned n; 210 - void *buffer; 211 - 212 - if (!walk->buffer) 213 - walk->buffer = walk->page; 214 - buffer = walk->buffer; 215 - if (!buffer) { 216 - /* Min size for a buffer of bsize bytes aligned to alignmask */ 217 - n = bsize + (alignmask & ~(crypto_tfm_ctx_alignment() - 1)); 218 - 219 - buffer = kzalloc(n, skcipher_walk_gfp(walk)); 220 - if (!buffer) 221 - return skcipher_walk_done(walk, -ENOMEM); 222 - walk->buffer = buffer; 223 - } 224 - 225 - buffer = PTR_ALIGN(buffer, alignmask + 1); 226 - memcpy_from_scatterwalk(buffer, &walk->in, bsize); 227 - walk->out.__addr = buffer; 228 - walk->in.__addr = walk->out.addr; 229 - 230 - walk->nbytes = bsize; 231 - walk->flags |= SKCIPHER_WALK_SLOW; 232 - 233 - return 0; 234 - } 235 - 236 - static int skcipher_next_copy(struct skcipher_walk *walk) 237 - { 238 - void *tmp = walk->page; 239 - 240 - scatterwalk_map(&walk->in); 241 - memcpy(tmp, walk->in.addr, walk->nbytes); 242 - scatterwalk_unmap(&walk->in); 243 - /* 244 - * walk->in is advanced later when the number of bytes actually 245 - * processed (which might be less than walk->nbytes) is known. 246 - */ 247 - 248 - walk->in.__addr = tmp; 249 - walk->out.__addr = tmp; 250 - return 0; 251 - } 252 - 253 - static int skcipher_next_fast(struct skcipher_walk *walk) 254 - { 255 - unsigned long diff; 256 - 257 - diff = offset_in_page(walk->in.offset) - 258 - offset_in_page(walk->out.offset); 259 - diff |= (u8 *)(sg_page(walk->in.sg) + (walk->in.offset >> PAGE_SHIFT)) - 260 - (u8 *)(sg_page(walk->out.sg) + (walk->out.offset >> PAGE_SHIFT)); 261 - 262 - scatterwalk_map(&walk->out); 263 - walk->in.__addr = walk->out.__addr; 264 - 265 - if (diff) { 266 - walk->flags |= SKCIPHER_WALK_DIFF; 267 - scatterwalk_map(&walk->in); 268 - } 269 - 270 - return 0; 271 - } 272 - 273 - static int skcipher_walk_next(struct skcipher_walk *walk) 274 - { 275 - unsigned int bsize; 276 - unsigned int n; 277 - 278 - n = walk->total; 279 - bsize = min(walk->stride, max(n, walk->blocksize)); 280 - n = scatterwalk_clamp(&walk->in, n); 281 - n = scatterwalk_clamp(&walk->out, n); 282 - 283 - if (unlikely(n < bsize)) { 284 - if (unlikely(walk->total < walk->blocksize)) 285 - return skcipher_walk_done(walk, -EINVAL); 286 - 287 - slow_path: 288 - return skcipher_next_slow(walk, bsize); 289 - } 290 - walk->nbytes = n; 291 - 292 - if (unlikely((walk->in.offset | walk->out.offset) & walk->alignmask)) { 293 - if (!walk->page) { 294 - gfp_t gfp = skcipher_walk_gfp(walk); 295 - 296 - walk->page = (void *)__get_free_page(gfp); 297 - if (!walk->page) 298 - goto slow_path; 299 - } 300 - walk->flags |= SKCIPHER_WALK_COPY; 301 - return skcipher_next_copy(walk); 302 - } 303 - 304 - return skcipher_next_fast(walk); 305 - } 306 - 307 - static int skcipher_copy_iv(struct skcipher_walk *walk) 308 - { 309 - unsigned alignmask = walk->alignmask; 310 - unsigned ivsize = walk->ivsize; 311 - unsigned aligned_stride = ALIGN(walk->stride, alignmask + 1); 312 - unsigned size; 313 - u8 *iv; 314 - 315 - /* Min size for a buffer of stride + ivsize, aligned to alignmask */ 316 - size = aligned_stride + ivsize + 317 - (alignmask & ~(crypto_tfm_ctx_alignment() - 1)); 318 - 319 - walk->buffer = kmalloc(size, skcipher_walk_gfp(walk)); 320 - if (!walk->buffer) 321 - return -ENOMEM; 322 - 323 - iv = PTR_ALIGN(walk->buffer, alignmask + 1) + aligned_stride; 324 - 325 - walk->iv = memcpy(iv, walk->iv, walk->ivsize); 326 - return 0; 327 - } 328 - 329 - int skcipher_walk_first(struct skcipher_walk *walk, bool atomic) 330 - { 331 - if (WARN_ON_ONCE(in_hardirq())) 332 - return -EDEADLK; 333 - 334 - walk->flags = atomic ? 0 : SKCIPHER_WALK_SLEEP; 335 - 336 - walk->buffer = NULL; 337 - if (unlikely(((unsigned long)walk->iv & walk->alignmask))) { 338 - int err = skcipher_copy_iv(walk); 339 - if (err) 340 - return err; 341 - } 342 - 343 - walk->page = NULL; 344 - 345 - return skcipher_walk_next(walk); 346 - } 347 - EXPORT_SYMBOL_GPL(skcipher_walk_first); 348 - 349 - /** 350 - * skcipher_walk_done() - finish one step of a skcipher_walk 351 - * @walk: the skcipher_walk 352 - * @res: number of bytes *not* processed (>= 0) from walk->nbytes, 353 - * or a -errno value to terminate the walk due to an error 354 - * 355 - * This function cleans up after one step of walking through the source and 356 - * destination scatterlists, and advances to the next step if applicable. 357 - * walk->nbytes is set to the number of bytes available in the next step, 358 - * walk->total is set to the new total number of bytes remaining, and 359 - * walk->{src,dst}.virt.addr is set to the next pair of data pointers. If there 360 - * is no more data, or if an error occurred (i.e. -errno return), then 361 - * walk->nbytes and walk->total are set to 0 and all resources owned by the 362 - * skcipher_walk are freed. 363 - * 364 - * Return: 0 or a -errno value. If @res was a -errno value then it will be 365 - * returned, but other errors may occur too. 366 - */ 367 - int skcipher_walk_done(struct skcipher_walk *walk, int res) 368 - { 369 - unsigned int n = walk->nbytes; /* num bytes processed this step */ 370 - unsigned int total = 0; /* new total remaining */ 371 - 372 - if (!n) 373 - goto finish; 374 - 375 - if (likely(res >= 0)) { 376 - n -= res; /* subtract num bytes *not* processed */ 377 - total = walk->total - n; 378 - } 379 - 380 - if (likely(!(walk->flags & (SKCIPHER_WALK_SLOW | 381 - SKCIPHER_WALK_COPY | 382 - SKCIPHER_WALK_DIFF)))) { 383 - scatterwalk_advance(&walk->in, n); 384 - } else if (walk->flags & SKCIPHER_WALK_DIFF) { 385 - scatterwalk_done_src(&walk->in, n); 386 - } else if (walk->flags & SKCIPHER_WALK_COPY) { 387 - scatterwalk_advance(&walk->in, n); 388 - scatterwalk_map(&walk->out); 389 - memcpy(walk->out.addr, walk->page, n); 390 - } else { /* SKCIPHER_WALK_SLOW */ 391 - if (res > 0) { 392 - /* 393 - * Didn't process all bytes. Either the algorithm is 394 - * broken, or this was the last step and it turned out 395 - * the message wasn't evenly divisible into blocks but 396 - * the algorithm requires it. 397 - */ 398 - res = -EINVAL; 399 - total = 0; 400 - } else 401 - memcpy_to_scatterwalk(&walk->out, walk->out.addr, n); 402 - goto dst_done; 403 - } 404 - 405 - scatterwalk_done_dst(&walk->out, n); 406 - dst_done: 407 - 408 - if (res > 0) 409 - res = 0; 410 - 411 - walk->total = total; 412 - walk->nbytes = 0; 413 - 414 - if (total) { 415 - if (walk->flags & SKCIPHER_WALK_SLEEP) 416 - cond_resched(); 417 - walk->flags &= ~(SKCIPHER_WALK_SLOW | SKCIPHER_WALK_COPY | 418 - SKCIPHER_WALK_DIFF); 419 - return skcipher_walk_next(walk); 420 - } 421 - 422 - finish: 423 - /* Short-circuit for the common/fast path. */ 424 - if (!((unsigned long)walk->buffer | (unsigned long)walk->page)) 425 - goto out; 426 - 427 - if (walk->iv != walk->oiv) 428 - memcpy(walk->oiv, walk->iv, walk->ivsize); 429 - if (walk->buffer != walk->page) 430 - kfree(walk->buffer); 431 - if (walk->page) 432 - free_page((unsigned long)walk->page); 433 - 434 - out: 435 - return res; 436 - } 437 - EXPORT_SYMBOL_GPL(skcipher_walk_done);
+255 -6
crypto/skcipher.c
··· 17 17 #include <linux/cryptouser.h> 18 18 #include <linux/err.h> 19 19 #include <linux/kernel.h> 20 + #include <linux/mm.h> 20 21 #include <linux/module.h> 21 22 #include <linux/seq_file.h> 22 23 #include <linux/slab.h> ··· 28 27 29 28 #define CRYPTO_ALG_TYPE_SKCIPHER_MASK 0x0000000e 30 29 30 + enum { 31 + SKCIPHER_WALK_SLOW = 1 << 0, 32 + SKCIPHER_WALK_COPY = 1 << 1, 33 + SKCIPHER_WALK_DIFF = 1 << 2, 34 + SKCIPHER_WALK_SLEEP = 1 << 3, 35 + }; 36 + 31 37 static const struct crypto_type crypto_skcipher_type; 38 + 39 + static int skcipher_walk_next(struct skcipher_walk *walk); 40 + 41 + static inline gfp_t skcipher_walk_gfp(struct skcipher_walk *walk) 42 + { 43 + return walk->flags & SKCIPHER_WALK_SLEEP ? GFP_KERNEL : GFP_ATOMIC; 44 + } 32 45 33 46 static inline struct skcipher_alg *__crypto_skcipher_alg( 34 47 struct crypto_alg *alg) 35 48 { 36 49 return container_of(alg, struct skcipher_alg, base); 50 + } 51 + 52 + /** 53 + * skcipher_walk_done() - finish one step of a skcipher_walk 54 + * @walk: the skcipher_walk 55 + * @res: number of bytes *not* processed (>= 0) from walk->nbytes, 56 + * or a -errno value to terminate the walk due to an error 57 + * 58 + * This function cleans up after one step of walking through the source and 59 + * destination scatterlists, and advances to the next step if applicable. 60 + * walk->nbytes is set to the number of bytes available in the next step, 61 + * walk->total is set to the new total number of bytes remaining, and 62 + * walk->{src,dst}.virt.addr is set to the next pair of data pointers. If there 63 + * is no more data, or if an error occurred (i.e. -errno return), then 64 + * walk->nbytes and walk->total are set to 0 and all resources owned by the 65 + * skcipher_walk are freed. 66 + * 67 + * Return: 0 or a -errno value. If @res was a -errno value then it will be 68 + * returned, but other errors may occur too. 69 + */ 70 + int skcipher_walk_done(struct skcipher_walk *walk, int res) 71 + { 72 + unsigned int n = walk->nbytes; /* num bytes processed this step */ 73 + unsigned int total = 0; /* new total remaining */ 74 + 75 + if (!n) 76 + goto finish; 77 + 78 + if (likely(res >= 0)) { 79 + n -= res; /* subtract num bytes *not* processed */ 80 + total = walk->total - n; 81 + } 82 + 83 + if (likely(!(walk->flags & (SKCIPHER_WALK_SLOW | 84 + SKCIPHER_WALK_COPY | 85 + SKCIPHER_WALK_DIFF)))) { 86 + scatterwalk_advance(&walk->in, n); 87 + } else if (walk->flags & SKCIPHER_WALK_DIFF) { 88 + scatterwalk_done_src(&walk->in, n); 89 + } else if (walk->flags & SKCIPHER_WALK_COPY) { 90 + scatterwalk_advance(&walk->in, n); 91 + scatterwalk_map(&walk->out); 92 + memcpy(walk->out.addr, walk->page, n); 93 + } else { /* SKCIPHER_WALK_SLOW */ 94 + if (res > 0) { 95 + /* 96 + * Didn't process all bytes. Either the algorithm is 97 + * broken, or this was the last step and it turned out 98 + * the message wasn't evenly divisible into blocks but 99 + * the algorithm requires it. 100 + */ 101 + res = -EINVAL; 102 + total = 0; 103 + } else 104 + memcpy_to_scatterwalk(&walk->out, walk->out.addr, n); 105 + goto dst_done; 106 + } 107 + 108 + scatterwalk_done_dst(&walk->out, n); 109 + dst_done: 110 + 111 + if (res > 0) 112 + res = 0; 113 + 114 + walk->total = total; 115 + walk->nbytes = 0; 116 + 117 + if (total) { 118 + if (walk->flags & SKCIPHER_WALK_SLEEP) 119 + cond_resched(); 120 + walk->flags &= ~(SKCIPHER_WALK_SLOW | SKCIPHER_WALK_COPY | 121 + SKCIPHER_WALK_DIFF); 122 + return skcipher_walk_next(walk); 123 + } 124 + 125 + finish: 126 + /* Short-circuit for the common/fast path. */ 127 + if (!((unsigned long)walk->buffer | (unsigned long)walk->page)) 128 + goto out; 129 + 130 + if (walk->iv != walk->oiv) 131 + memcpy(walk->oiv, walk->iv, walk->ivsize); 132 + if (walk->buffer != walk->page) 133 + kfree(walk->buffer); 134 + if (walk->page) 135 + free_page((unsigned long)walk->page); 136 + 137 + out: 138 + return res; 139 + } 140 + EXPORT_SYMBOL_GPL(skcipher_walk_done); 141 + 142 + static int skcipher_next_slow(struct skcipher_walk *walk, unsigned int bsize) 143 + { 144 + unsigned alignmask = walk->alignmask; 145 + unsigned n; 146 + void *buffer; 147 + 148 + if (!walk->buffer) 149 + walk->buffer = walk->page; 150 + buffer = walk->buffer; 151 + if (!buffer) { 152 + /* Min size for a buffer of bsize bytes aligned to alignmask */ 153 + n = bsize + (alignmask & ~(crypto_tfm_ctx_alignment() - 1)); 154 + 155 + buffer = kzalloc(n, skcipher_walk_gfp(walk)); 156 + if (!buffer) 157 + return skcipher_walk_done(walk, -ENOMEM); 158 + walk->buffer = buffer; 159 + } 160 + 161 + buffer = PTR_ALIGN(buffer, alignmask + 1); 162 + memcpy_from_scatterwalk(buffer, &walk->in, bsize); 163 + walk->out.__addr = buffer; 164 + walk->in.__addr = walk->out.addr; 165 + 166 + walk->nbytes = bsize; 167 + walk->flags |= SKCIPHER_WALK_SLOW; 168 + 169 + return 0; 170 + } 171 + 172 + static int skcipher_next_copy(struct skcipher_walk *walk) 173 + { 174 + void *tmp = walk->page; 175 + 176 + scatterwalk_map(&walk->in); 177 + memcpy(tmp, walk->in.addr, walk->nbytes); 178 + scatterwalk_unmap(&walk->in); 179 + /* 180 + * walk->in is advanced later when the number of bytes actually 181 + * processed (which might be less than walk->nbytes) is known. 182 + */ 183 + 184 + walk->in.__addr = tmp; 185 + walk->out.__addr = tmp; 186 + return 0; 187 + } 188 + 189 + static int skcipher_next_fast(struct skcipher_walk *walk) 190 + { 191 + unsigned long diff; 192 + 193 + diff = offset_in_page(walk->in.offset) - 194 + offset_in_page(walk->out.offset); 195 + diff |= (u8 *)(sg_page(walk->in.sg) + (walk->in.offset >> PAGE_SHIFT)) - 196 + (u8 *)(sg_page(walk->out.sg) + (walk->out.offset >> PAGE_SHIFT)); 197 + 198 + scatterwalk_map(&walk->out); 199 + walk->in.__addr = walk->out.__addr; 200 + 201 + if (diff) { 202 + walk->flags |= SKCIPHER_WALK_DIFF; 203 + scatterwalk_map(&walk->in); 204 + } 205 + 206 + return 0; 207 + } 208 + 209 + static int skcipher_walk_next(struct skcipher_walk *walk) 210 + { 211 + unsigned int bsize; 212 + unsigned int n; 213 + 214 + n = walk->total; 215 + bsize = min(walk->stride, max(n, walk->blocksize)); 216 + n = scatterwalk_clamp(&walk->in, n); 217 + n = scatterwalk_clamp(&walk->out, n); 218 + 219 + if (unlikely(n < bsize)) { 220 + if (unlikely(walk->total < walk->blocksize)) 221 + return skcipher_walk_done(walk, -EINVAL); 222 + 223 + slow_path: 224 + return skcipher_next_slow(walk, bsize); 225 + } 226 + walk->nbytes = n; 227 + 228 + if (unlikely((walk->in.offset | walk->out.offset) & walk->alignmask)) { 229 + if (!walk->page) { 230 + gfp_t gfp = skcipher_walk_gfp(walk); 231 + 232 + walk->page = (void *)__get_free_page(gfp); 233 + if (!walk->page) 234 + goto slow_path; 235 + } 236 + walk->flags |= SKCIPHER_WALK_COPY; 237 + return skcipher_next_copy(walk); 238 + } 239 + 240 + return skcipher_next_fast(walk); 241 + } 242 + 243 + static int skcipher_copy_iv(struct skcipher_walk *walk) 244 + { 245 + unsigned alignmask = walk->alignmask; 246 + unsigned ivsize = walk->ivsize; 247 + unsigned aligned_stride = ALIGN(walk->stride, alignmask + 1); 248 + unsigned size; 249 + u8 *iv; 250 + 251 + /* Min size for a buffer of stride + ivsize, aligned to alignmask */ 252 + size = aligned_stride + ivsize + 253 + (alignmask & ~(crypto_tfm_ctx_alignment() - 1)); 254 + 255 + walk->buffer = kmalloc(size, skcipher_walk_gfp(walk)); 256 + if (!walk->buffer) 257 + return -ENOMEM; 258 + 259 + iv = PTR_ALIGN(walk->buffer, alignmask + 1) + aligned_stride; 260 + 261 + walk->iv = memcpy(iv, walk->iv, walk->ivsize); 262 + return 0; 263 + } 264 + 265 + static int skcipher_walk_first(struct skcipher_walk *walk) 266 + { 267 + if (WARN_ON_ONCE(in_hardirq())) 268 + return -EDEADLK; 269 + 270 + walk->buffer = NULL; 271 + if (unlikely(((unsigned long)walk->iv & walk->alignmask))) { 272 + int err = skcipher_copy_iv(walk); 273 + if (err) 274 + return err; 275 + } 276 + 277 + walk->page = NULL; 278 + 279 + return skcipher_walk_next(walk); 37 280 } 38 281 39 282 int skcipher_walk_virt(struct skcipher_walk *__restrict walk, ··· 294 49 walk->nbytes = 0; 295 50 walk->iv = req->iv; 296 51 walk->oiv = req->iv; 297 - if (!(req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP)) 298 - atomic = true; 52 + if ((req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP) && !atomic) 53 + walk->flags = SKCIPHER_WALK_SLEEP; 54 + else 55 + walk->flags = 0; 299 56 300 57 if (unlikely(!walk->total)) 301 58 return 0; ··· 314 67 else 315 68 walk->stride = alg->walksize; 316 69 317 - return skcipher_walk_first(walk, atomic); 70 + return skcipher_walk_first(walk); 318 71 } 319 72 EXPORT_SYMBOL_GPL(skcipher_walk_virt); 320 73 ··· 327 80 walk->nbytes = 0; 328 81 walk->iv = req->iv; 329 82 walk->oiv = req->iv; 330 - if (!(req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP)) 331 - atomic = true; 83 + if ((req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP) && !atomic) 84 + walk->flags = SKCIPHER_WALK_SLEEP; 85 + else 86 + walk->flags = 0; 332 87 333 88 if (unlikely(!walk->total)) 334 89 return 0; ··· 343 94 walk->ivsize = crypto_aead_ivsize(tfm); 344 95 walk->alignmask = crypto_aead_alignmask(tfm); 345 96 346 - return skcipher_walk_first(walk, atomic); 97 + return skcipher_walk_first(walk); 347 98 } 348 99 349 100 int skcipher_walk_aead_encrypt(struct skcipher_walk *__restrict walk,
+12
include/crypto/algapi.h
··· 107 107 unsigned int max_qlen; 108 108 }; 109 109 110 + struct scatter_walk { 111 + /* Must be the first member, see struct skcipher_walk. */ 112 + union { 113 + void *const addr; 114 + 115 + /* Private API field, do not touch. */ 116 + union crypto_no_such_thing *__addr; 117 + }; 118 + struct scatterlist *sg; 119 + unsigned int offset; 120 + }; 121 + 110 122 struct crypto_attr_alg { 111 123 char name[CRYPTO_MAX_ALG_NAME]; 112 124 };
+47 -1
include/crypto/internal/skcipher.h
··· 10 10 11 11 #include <crypto/algapi.h> 12 12 #include <crypto/internal/cipher.h> 13 - #include <crypto/scatterwalk.h> 14 13 #include <crypto/skcipher.h> 15 14 #include <linux/types.h> 16 15 ··· 52 53 53 54 struct crypto_lskcipher_spawn { 54 55 struct crypto_spawn base; 56 + }; 57 + 58 + struct skcipher_walk { 59 + union { 60 + /* Virtual address of the source. */ 61 + struct { 62 + struct { 63 + const void *const addr; 64 + } virt; 65 + } src; 66 + 67 + /* Private field for the API, do not use. */ 68 + struct scatter_walk in; 69 + }; 70 + 71 + union { 72 + /* Virtual address of the destination. */ 73 + struct { 74 + struct { 75 + void *const addr; 76 + } virt; 77 + } dst; 78 + 79 + /* Private field for the API, do not use. */ 80 + struct scatter_walk out; 81 + }; 82 + 83 + unsigned int nbytes; 84 + unsigned int total; 85 + 86 + u8 *page; 87 + u8 *buffer; 88 + u8 *oiv; 89 + void *iv; 90 + 91 + unsigned int ivsize; 92 + 93 + int flags; 94 + unsigned int blocksize; 95 + unsigned int stride; 96 + unsigned int alignmask; 55 97 }; 56 98 57 99 static inline struct crypto_instance *skcipher_crypto_instance( ··· 211 171 int lskcipher_register_instance(struct crypto_template *tmpl, 212 172 struct lskcipher_instance *inst); 213 173 174 + int skcipher_walk_done(struct skcipher_walk *walk, int res); 214 175 int skcipher_walk_virt(struct skcipher_walk *__restrict walk, 215 176 struct skcipher_request *__restrict req, 216 177 bool atomic); ··· 221 180 int skcipher_walk_aead_decrypt(struct skcipher_walk *__restrict walk, 222 181 struct aead_request *__restrict req, 223 182 bool atomic); 183 + 184 + static inline void skcipher_walk_abort(struct skcipher_walk *walk) 185 + { 186 + skcipher_walk_done(walk, -ECANCELED); 187 + } 224 188 225 189 static inline void *crypto_skcipher_ctx(struct crypto_skcipher *tfm) 226 190 {
+2 -63
include/crypto/scatterwalk.h
··· 11 11 #ifndef _CRYPTO_SCATTERWALK_H 12 12 #define _CRYPTO_SCATTERWALK_H 13 13 14 - #include <linux/errno.h> 14 + #include <crypto/algapi.h> 15 + 15 16 #include <linux/highmem.h> 16 17 #include <linux/mm.h> 17 18 #include <linux/scatterlist.h> 18 - #include <linux/types.h> 19 - 20 - struct scatter_walk { 21 - /* Must be the first member, see struct skcipher_walk. */ 22 - union { 23 - void *const addr; 24 - 25 - /* Private API field, do not touch. */ 26 - union crypto_no_such_thing *__addr; 27 - }; 28 - struct scatterlist *sg; 29 - unsigned int offset; 30 - }; 31 - 32 - struct skcipher_walk { 33 - union { 34 - /* Virtual address of the source. */ 35 - struct { 36 - struct { 37 - const void *const addr; 38 - } virt; 39 - } src; 40 - 41 - /* Private field for the API, do not use. */ 42 - struct scatter_walk in; 43 - }; 44 - 45 - union { 46 - /* Virtual address of the destination. */ 47 - struct { 48 - struct { 49 - void *const addr; 50 - } virt; 51 - } dst; 52 - 53 - /* Private field for the API, do not use. */ 54 - struct scatter_walk out; 55 - }; 56 - 57 - unsigned int nbytes; 58 - unsigned int total; 59 - 60 - u8 *page; 61 - u8 *buffer; 62 - u8 *oiv; 63 - void *iv; 64 - 65 - unsigned int ivsize; 66 - 67 - int flags; 68 - unsigned int blocksize; 69 - unsigned int stride; 70 - unsigned int alignmask; 71 - }; 72 19 73 20 static inline void scatterwalk_crypto_chain(struct scatterlist *head, 74 21 struct scatterlist *sg, int num) ··· 252 305 struct scatterlist *scatterwalk_ffwd(struct scatterlist dst[2], 253 306 struct scatterlist *src, 254 307 unsigned int len); 255 - 256 - int skcipher_walk_first(struct skcipher_walk *walk, bool atomic); 257 - int skcipher_walk_done(struct skcipher_walk *walk, int res); 258 - 259 - static inline void skcipher_walk_abort(struct skcipher_walk *walk) 260 - { 261 - skcipher_walk_done(walk, -ECANCELED); 262 - } 263 308 264 309 #endif /* _CRYPTO_SCATTERWALK_H */