• Home
  • Raw
  • Download

Lines Matching refs:req

44 	struct ahash_request req; /* must be last member */  member
50 struct skcipher_request req; /* must be last member */ member
72 static inline void async_done_continue(struct aead_request *req, int err, in async_done_continue() argument
76 struct chachapoly_req_ctx *rctx = aead_request_ctx(req); in async_done_continue()
79 err = cont(req); in async_done_continue()
83 aead_request_complete(req, err); in async_done_continue()
86 static void chacha_iv(u8 *iv, struct aead_request *req, u32 icb) in chacha_iv() argument
88 struct chachapoly_ctx *ctx = crypto_aead_ctx(crypto_aead_reqtfm(req)); in chacha_iv()
93 memcpy(iv + sizeof(leicb) + ctx->saltlen, req->iv, in chacha_iv()
97 static int poly_verify_tag(struct aead_request *req) in poly_verify_tag() argument
99 struct chachapoly_req_ctx *rctx = aead_request_ctx(req); in poly_verify_tag()
102 scatterwalk_map_and_copy(tag, req->src, in poly_verify_tag()
103 req->assoclen + rctx->cryptlen, in poly_verify_tag()
110 static int poly_copy_tag(struct aead_request *req) in poly_copy_tag() argument
112 struct chachapoly_req_ctx *rctx = aead_request_ctx(req); in poly_copy_tag()
114 scatterwalk_map_and_copy(rctx->tag, req->dst, in poly_copy_tag()
115 req->assoclen + rctx->cryptlen, in poly_copy_tag()
125 static int chacha_decrypt(struct aead_request *req) in chacha_decrypt() argument
127 struct chachapoly_ctx *ctx = crypto_aead_ctx(crypto_aead_reqtfm(req)); in chacha_decrypt()
128 struct chachapoly_req_ctx *rctx = aead_request_ctx(req); in chacha_decrypt()
136 chacha_iv(creq->iv, req, 1); in chacha_decrypt()
138 src = scatterwalk_ffwd(rctx->src, req->src, req->assoclen); in chacha_decrypt()
140 if (req->src != req->dst) in chacha_decrypt()
141 dst = scatterwalk_ffwd(rctx->dst, req->dst, req->assoclen); in chacha_decrypt()
143 skcipher_request_set_callback(&creq->req, rctx->flags, in chacha_decrypt()
144 chacha_decrypt_done, req); in chacha_decrypt()
145 skcipher_request_set_tfm(&creq->req, ctx->chacha); in chacha_decrypt()
146 skcipher_request_set_crypt(&creq->req, src, dst, in chacha_decrypt()
148 err = crypto_skcipher_decrypt(&creq->req); in chacha_decrypt()
153 return poly_verify_tag(req); in chacha_decrypt()
156 static int poly_tail_continue(struct aead_request *req) in poly_tail_continue() argument
158 struct chachapoly_req_ctx *rctx = aead_request_ctx(req); in poly_tail_continue()
160 if (rctx->cryptlen == req->cryptlen) /* encrypting */ in poly_tail_continue()
161 return poly_copy_tag(req); in poly_tail_continue()
163 return chacha_decrypt(req); in poly_tail_continue()
171 static int poly_tail(struct aead_request *req) in poly_tail() argument
173 struct crypto_aead *tfm = crypto_aead_reqtfm(req); in poly_tail()
175 struct chachapoly_req_ctx *rctx = aead_request_ctx(req); in poly_tail()
183 ahash_request_set_callback(&preq->req, rctx->flags, in poly_tail()
184 poly_tail_done, req); in poly_tail()
185 ahash_request_set_tfm(&preq->req, ctx->poly); in poly_tail()
186 ahash_request_set_crypt(&preq->req, preq->src, in poly_tail()
189 err = crypto_ahash_finup(&preq->req); in poly_tail()
193 return poly_tail_continue(req); in poly_tail()
201 static int poly_cipherpad(struct aead_request *req) in poly_cipherpad() argument
203 struct chachapoly_ctx *ctx = crypto_aead_ctx(crypto_aead_reqtfm(req)); in poly_cipherpad()
204 struct chachapoly_req_ctx *rctx = aead_request_ctx(req); in poly_cipherpad()
213 ahash_request_set_callback(&preq->req, rctx->flags, in poly_cipherpad()
214 poly_cipherpad_done, req); in poly_cipherpad()
215 ahash_request_set_tfm(&preq->req, ctx->poly); in poly_cipherpad()
216 ahash_request_set_crypt(&preq->req, preq->src, NULL, padlen); in poly_cipherpad()
218 err = crypto_ahash_update(&preq->req); in poly_cipherpad()
222 return poly_tail(req); in poly_cipherpad()
230 static int poly_cipher(struct aead_request *req) in poly_cipher() argument
232 struct chachapoly_ctx *ctx = crypto_aead_ctx(crypto_aead_reqtfm(req)); in poly_cipher()
233 struct chachapoly_req_ctx *rctx = aead_request_ctx(req); in poly_cipher()
235 struct scatterlist *crypt = req->src; in poly_cipher()
238 if (rctx->cryptlen == req->cryptlen) /* encrypting */ in poly_cipher()
239 crypt = req->dst; in poly_cipher()
241 crypt = scatterwalk_ffwd(rctx->src, crypt, req->assoclen); in poly_cipher()
243 ahash_request_set_callback(&preq->req, rctx->flags, in poly_cipher()
244 poly_cipher_done, req); in poly_cipher()
245 ahash_request_set_tfm(&preq->req, ctx->poly); in poly_cipher()
246 ahash_request_set_crypt(&preq->req, crypt, NULL, rctx->cryptlen); in poly_cipher()
248 err = crypto_ahash_update(&preq->req); in poly_cipher()
252 return poly_cipherpad(req); in poly_cipher()
260 static int poly_adpad(struct aead_request *req) in poly_adpad() argument
262 struct chachapoly_ctx *ctx = crypto_aead_ctx(crypto_aead_reqtfm(req)); in poly_adpad()
263 struct chachapoly_req_ctx *rctx = aead_request_ctx(req); in poly_adpad()
272 ahash_request_set_callback(&preq->req, rctx->flags, in poly_adpad()
273 poly_adpad_done, req); in poly_adpad()
274 ahash_request_set_tfm(&preq->req, ctx->poly); in poly_adpad()
275 ahash_request_set_crypt(&preq->req, preq->src, NULL, padlen); in poly_adpad()
277 err = crypto_ahash_update(&preq->req); in poly_adpad()
281 return poly_cipher(req); in poly_adpad()
289 static int poly_ad(struct aead_request *req) in poly_ad() argument
291 struct chachapoly_ctx *ctx = crypto_aead_ctx(crypto_aead_reqtfm(req)); in poly_ad()
292 struct chachapoly_req_ctx *rctx = aead_request_ctx(req); in poly_ad()
296 ahash_request_set_callback(&preq->req, rctx->flags, in poly_ad()
297 poly_ad_done, req); in poly_ad()
298 ahash_request_set_tfm(&preq->req, ctx->poly); in poly_ad()
299 ahash_request_set_crypt(&preq->req, req->src, NULL, rctx->assoclen); in poly_ad()
301 err = crypto_ahash_update(&preq->req); in poly_ad()
305 return poly_adpad(req); in poly_ad()
313 static int poly_setkey(struct aead_request *req) in poly_setkey() argument
315 struct chachapoly_ctx *ctx = crypto_aead_ctx(crypto_aead_reqtfm(req)); in poly_setkey()
316 struct chachapoly_req_ctx *rctx = aead_request_ctx(req); in poly_setkey()
322 ahash_request_set_callback(&preq->req, rctx->flags, in poly_setkey()
323 poly_setkey_done, req); in poly_setkey()
324 ahash_request_set_tfm(&preq->req, ctx->poly); in poly_setkey()
325 ahash_request_set_crypt(&preq->req, preq->src, NULL, sizeof(rctx->key)); in poly_setkey()
327 err = crypto_ahash_update(&preq->req); in poly_setkey()
331 return poly_ad(req); in poly_setkey()
339 static int poly_init(struct aead_request *req) in poly_init() argument
341 struct chachapoly_ctx *ctx = crypto_aead_ctx(crypto_aead_reqtfm(req)); in poly_init()
342 struct chachapoly_req_ctx *rctx = aead_request_ctx(req); in poly_init()
346 ahash_request_set_callback(&preq->req, rctx->flags, in poly_init()
347 poly_init_done, req); in poly_init()
348 ahash_request_set_tfm(&preq->req, ctx->poly); in poly_init()
350 err = crypto_ahash_init(&preq->req); in poly_init()
354 return poly_setkey(req); in poly_init()
362 static int poly_genkey(struct aead_request *req) in poly_genkey() argument
364 struct crypto_aead *tfm = crypto_aead_reqtfm(req); in poly_genkey()
366 struct chachapoly_req_ctx *rctx = aead_request_ctx(req); in poly_genkey()
370 rctx->assoclen = req->assoclen; in poly_genkey()
381 chacha_iv(creq->iv, req, 0); in poly_genkey()
383 skcipher_request_set_callback(&creq->req, rctx->flags, in poly_genkey()
384 poly_genkey_done, req); in poly_genkey()
385 skcipher_request_set_tfm(&creq->req, ctx->chacha); in poly_genkey()
386 skcipher_request_set_crypt(&creq->req, creq->src, creq->src, in poly_genkey()
389 err = crypto_skcipher_decrypt(&creq->req); in poly_genkey()
393 return poly_init(req); in poly_genkey()
401 static int chacha_encrypt(struct aead_request *req) in chacha_encrypt() argument
403 struct chachapoly_ctx *ctx = crypto_aead_ctx(crypto_aead_reqtfm(req)); in chacha_encrypt()
404 struct chachapoly_req_ctx *rctx = aead_request_ctx(req); in chacha_encrypt()
409 if (req->cryptlen == 0) in chacha_encrypt()
412 chacha_iv(creq->iv, req, 1); in chacha_encrypt()
414 src = scatterwalk_ffwd(rctx->src, req->src, req->assoclen); in chacha_encrypt()
416 if (req->src != req->dst) in chacha_encrypt()
417 dst = scatterwalk_ffwd(rctx->dst, req->dst, req->assoclen); in chacha_encrypt()
419 skcipher_request_set_callback(&creq->req, rctx->flags, in chacha_encrypt()
420 chacha_encrypt_done, req); in chacha_encrypt()
421 skcipher_request_set_tfm(&creq->req, ctx->chacha); in chacha_encrypt()
422 skcipher_request_set_crypt(&creq->req, src, dst, in chacha_encrypt()
423 req->cryptlen, creq->iv); in chacha_encrypt()
424 err = crypto_skcipher_encrypt(&creq->req); in chacha_encrypt()
429 return poly_genkey(req); in chacha_encrypt()
432 static int chachapoly_encrypt(struct aead_request *req) in chachapoly_encrypt() argument
434 struct chachapoly_req_ctx *rctx = aead_request_ctx(req); in chachapoly_encrypt()
436 rctx->cryptlen = req->cryptlen; in chachapoly_encrypt()
437 rctx->flags = aead_request_flags(req); in chachapoly_encrypt()
451 return chacha_encrypt(req); in chachapoly_encrypt()
454 static int chachapoly_decrypt(struct aead_request *req) in chachapoly_decrypt() argument
456 struct chachapoly_req_ctx *rctx = aead_request_ctx(req); in chachapoly_decrypt()
458 rctx->cryptlen = req->cryptlen - POLY1305_DIGEST_SIZE; in chachapoly_decrypt()
459 rctx->flags = aead_request_flags(req); in chachapoly_decrypt()
473 return poly_genkey(req); in chachapoly_decrypt()
535 max(offsetof(struct chacha_req, req) + in chachapoly_init()
538 offsetof(struct poly_req, req) + in chachapoly_init()