Lines Matching full:req
50 struct ahash_request req; /* must be last member */ member
56 struct skcipher_request req; /* must be last member */ member
78 static inline void async_done_continue(struct aead_request *req, int err, in async_done_continue() argument
82 struct chachapoly_req_ctx *rctx = aead_request_ctx(req); in async_done_continue()
85 err = cont(req); in async_done_continue()
89 aead_request_complete(req, err); in async_done_continue()
92 static void chacha_iv(u8 *iv, struct aead_request *req, u32 icb) in chacha_iv() argument
94 struct chachapoly_ctx *ctx = crypto_aead_ctx(crypto_aead_reqtfm(req)); in chacha_iv()
99 memcpy(iv + sizeof(leicb) + ctx->saltlen, req->iv, in chacha_iv()
103 static int poly_verify_tag(struct aead_request *req) in poly_verify_tag() argument
105 struct chachapoly_req_ctx *rctx = aead_request_ctx(req); in poly_verify_tag()
108 scatterwalk_map_and_copy(tag, req->src, in poly_verify_tag()
109 req->assoclen + rctx->cryptlen, in poly_verify_tag()
116 static int poly_copy_tag(struct aead_request *req) in poly_copy_tag() argument
118 struct chachapoly_req_ctx *rctx = aead_request_ctx(req); in poly_copy_tag()
120 scatterwalk_map_and_copy(rctx->tag, req->dst, in poly_copy_tag()
121 req->assoclen + rctx->cryptlen, in poly_copy_tag()
131 static int chacha_decrypt(struct aead_request *req) in chacha_decrypt() argument
133 struct chachapoly_ctx *ctx = crypto_aead_ctx(crypto_aead_reqtfm(req)); in chacha_decrypt()
134 struct chachapoly_req_ctx *rctx = aead_request_ctx(req); in chacha_decrypt()
142 chacha_iv(creq->iv, req, 1); in chacha_decrypt()
145 src = scatterwalk_ffwd(rctx->src, req->src, req->assoclen); in chacha_decrypt()
148 if (req->src != req->dst) { in chacha_decrypt()
150 dst = scatterwalk_ffwd(rctx->dst, req->dst, req->assoclen); in chacha_decrypt()
153 skcipher_request_set_callback(&creq->req, rctx->flags, in chacha_decrypt()
154 chacha_decrypt_done, req); in chacha_decrypt()
155 skcipher_request_set_tfm(&creq->req, ctx->chacha); in chacha_decrypt()
156 skcipher_request_set_crypt(&creq->req, src, dst, in chacha_decrypt()
158 err = crypto_skcipher_decrypt(&creq->req); in chacha_decrypt()
163 return poly_verify_tag(req); in chacha_decrypt()
166 static int poly_tail_continue(struct aead_request *req) in poly_tail_continue() argument
168 struct chachapoly_req_ctx *rctx = aead_request_ctx(req); in poly_tail_continue()
170 if (rctx->cryptlen == req->cryptlen) /* encrypting */ in poly_tail_continue()
171 return poly_copy_tag(req); in poly_tail_continue()
173 return chacha_decrypt(req); in poly_tail_continue()
181 static int poly_tail(struct aead_request *req) in poly_tail() argument
183 struct crypto_aead *tfm = crypto_aead_reqtfm(req); in poly_tail()
185 struct chachapoly_req_ctx *rctx = aead_request_ctx(req); in poly_tail()
197 ahash_request_set_callback(&preq->req, rctx->flags, in poly_tail()
198 poly_tail_done, req); in poly_tail()
199 ahash_request_set_tfm(&preq->req, ctx->poly); in poly_tail()
200 ahash_request_set_crypt(&preq->req, preq->src, in poly_tail()
203 err = crypto_ahash_finup(&preq->req); in poly_tail()
207 return poly_tail_continue(req); in poly_tail()
215 static int poly_cipherpad(struct aead_request *req) in poly_cipherpad() argument
217 struct chachapoly_ctx *ctx = crypto_aead_ctx(crypto_aead_reqtfm(req)); in poly_cipherpad()
218 struct chachapoly_req_ctx *rctx = aead_request_ctx(req); in poly_cipherpad()
228 ahash_request_set_callback(&preq->req, rctx->flags, in poly_cipherpad()
229 poly_cipherpad_done, req); in poly_cipherpad()
230 ahash_request_set_tfm(&preq->req, ctx->poly); in poly_cipherpad()
231 ahash_request_set_crypt(&preq->req, preq->src, NULL, padlen); in poly_cipherpad()
233 err = crypto_ahash_update(&preq->req); in poly_cipherpad()
237 return poly_tail(req); in poly_cipherpad()
245 static int poly_cipher(struct aead_request *req) in poly_cipher() argument
247 struct chachapoly_ctx *ctx = crypto_aead_ctx(crypto_aead_reqtfm(req)); in poly_cipher()
248 struct chachapoly_req_ctx *rctx = aead_request_ctx(req); in poly_cipher()
250 struct scatterlist *crypt = req->src; in poly_cipher()
253 if (rctx->cryptlen == req->cryptlen) /* encrypting */ in poly_cipher()
254 crypt = req->dst; in poly_cipher()
257 crypt = scatterwalk_ffwd(rctx->src, crypt, req->assoclen); in poly_cipher()
259 ahash_request_set_callback(&preq->req, rctx->flags, in poly_cipher()
260 poly_cipher_done, req); in poly_cipher()
261 ahash_request_set_tfm(&preq->req, ctx->poly); in poly_cipher()
262 ahash_request_set_crypt(&preq->req, crypt, NULL, rctx->cryptlen); in poly_cipher()
264 err = crypto_ahash_update(&preq->req); in poly_cipher()
268 return poly_cipherpad(req); in poly_cipher()
276 static int poly_adpad(struct aead_request *req) in poly_adpad() argument
278 struct chachapoly_ctx *ctx = crypto_aead_ctx(crypto_aead_reqtfm(req)); in poly_adpad()
279 struct chachapoly_req_ctx *rctx = aead_request_ctx(req); in poly_adpad()
289 ahash_request_set_callback(&preq->req, rctx->flags, in poly_adpad()
290 poly_adpad_done, req); in poly_adpad()
291 ahash_request_set_tfm(&preq->req, ctx->poly); in poly_adpad()
292 ahash_request_set_crypt(&preq->req, preq->src, NULL, padlen); in poly_adpad()
294 err = crypto_ahash_update(&preq->req); in poly_adpad()
298 return poly_cipher(req); in poly_adpad()
306 static int poly_ad(struct aead_request *req) in poly_ad() argument
308 struct chachapoly_ctx *ctx = crypto_aead_ctx(crypto_aead_reqtfm(req)); in poly_ad()
309 struct chachapoly_req_ctx *rctx = aead_request_ctx(req); in poly_ad()
313 ahash_request_set_callback(&preq->req, rctx->flags, in poly_ad()
314 poly_ad_done, req); in poly_ad()
315 ahash_request_set_tfm(&preq->req, ctx->poly); in poly_ad()
316 ahash_request_set_crypt(&preq->req, req->src, NULL, rctx->assoclen); in poly_ad()
318 err = crypto_ahash_update(&preq->req); in poly_ad()
322 return poly_adpad(req); in poly_ad()
330 static int poly_setkey(struct aead_request *req) in poly_setkey() argument
332 struct chachapoly_ctx *ctx = crypto_aead_ctx(crypto_aead_reqtfm(req)); in poly_setkey()
333 struct chachapoly_req_ctx *rctx = aead_request_ctx(req); in poly_setkey()
340 ahash_request_set_callback(&preq->req, rctx->flags, in poly_setkey()
341 poly_setkey_done, req); in poly_setkey()
342 ahash_request_set_tfm(&preq->req, ctx->poly); in poly_setkey()
343 ahash_request_set_crypt(&preq->req, preq->src, NULL, sizeof(rctx->key)); in poly_setkey()
345 err = crypto_ahash_update(&preq->req); in poly_setkey()
349 return poly_ad(req); in poly_setkey()
357 static int poly_init(struct aead_request *req) in poly_init() argument
359 struct chachapoly_ctx *ctx = crypto_aead_ctx(crypto_aead_reqtfm(req)); in poly_init()
360 struct chachapoly_req_ctx *rctx = aead_request_ctx(req); in poly_init()
364 ahash_request_set_callback(&preq->req, rctx->flags, in poly_init()
365 poly_init_done, req); in poly_init()
366 ahash_request_set_tfm(&preq->req, ctx->poly); in poly_init()
368 err = crypto_ahash_init(&preq->req); in poly_init()
372 return poly_setkey(req); in poly_init()
380 static int poly_genkey(struct aead_request *req) in poly_genkey() argument
382 struct crypto_aead *tfm = crypto_aead_reqtfm(req); in poly_genkey()
384 struct chachapoly_req_ctx *rctx = aead_request_ctx(req); in poly_genkey()
388 rctx->assoclen = req->assoclen; in poly_genkey()
400 chacha_iv(creq->iv, req, 0); in poly_genkey()
402 skcipher_request_set_callback(&creq->req, rctx->flags, in poly_genkey()
403 poly_genkey_done, req); in poly_genkey()
404 skcipher_request_set_tfm(&creq->req, ctx->chacha); in poly_genkey()
405 skcipher_request_set_crypt(&creq->req, creq->src, creq->src, in poly_genkey()
408 err = crypto_skcipher_decrypt(&creq->req); in poly_genkey()
412 return poly_init(req); in poly_genkey()
420 static int chacha_encrypt(struct aead_request *req) in chacha_encrypt() argument
422 struct chachapoly_ctx *ctx = crypto_aead_ctx(crypto_aead_reqtfm(req)); in chacha_encrypt()
423 struct chachapoly_req_ctx *rctx = aead_request_ctx(req); in chacha_encrypt()
428 if (req->cryptlen == 0) in chacha_encrypt()
431 chacha_iv(creq->iv, req, 1); in chacha_encrypt()
434 src = scatterwalk_ffwd(rctx->src, req->src, req->assoclen); in chacha_encrypt()
437 if (req->src != req->dst) { in chacha_encrypt()
439 dst = scatterwalk_ffwd(rctx->dst, req->dst, req->assoclen); in chacha_encrypt()
442 skcipher_request_set_callback(&creq->req, rctx->flags, in chacha_encrypt()
443 chacha_encrypt_done, req); in chacha_encrypt()
444 skcipher_request_set_tfm(&creq->req, ctx->chacha); in chacha_encrypt()
445 skcipher_request_set_crypt(&creq->req, src, dst, in chacha_encrypt()
446 req->cryptlen, creq->iv); in chacha_encrypt()
447 err = crypto_skcipher_encrypt(&creq->req); in chacha_encrypt()
452 return poly_genkey(req); in chacha_encrypt()
455 static int chachapoly_encrypt(struct aead_request *req) in chachapoly_encrypt() argument
457 struct chachapoly_req_ctx *rctx = aead_request_ctx(req); in chachapoly_encrypt()
459 rctx->cryptlen = req->cryptlen; in chachapoly_encrypt()
460 rctx->flags = aead_request_flags(req); in chachapoly_encrypt()
474 return chacha_encrypt(req); in chachapoly_encrypt()
477 static int chachapoly_decrypt(struct aead_request *req) in chachapoly_decrypt() argument
479 struct chachapoly_req_ctx *rctx = aead_request_ctx(req); in chachapoly_decrypt()
481 rctx->cryptlen = req->cryptlen - POLY1305_DIGEST_SIZE; in chachapoly_decrypt()
482 rctx->flags = aead_request_flags(req); in chachapoly_decrypt()
496 return poly_genkey(req); in chachapoly_decrypt()
558 max(offsetof(struct chacha_req, req) + in chachapoly_init()
561 offsetof(struct poly_req, req) + in chachapoly_init()