Lines Matching refs:req
42 struct ahash_request req; /* must be last member */ member
48 struct skcipher_request req; /* must be last member */ member
70 static inline void async_done_continue(struct aead_request *req, int err, in async_done_continue() argument
74 struct chachapoly_req_ctx *rctx = aead_request_ctx(req); in async_done_continue()
77 err = cont(req); in async_done_continue()
81 aead_request_complete(req, err); in async_done_continue()
84 static void chacha_iv(u8 *iv, struct aead_request *req, u32 icb) in chacha_iv() argument
86 struct chachapoly_ctx *ctx = crypto_aead_ctx(crypto_aead_reqtfm(req)); in chacha_iv()
91 memcpy(iv + sizeof(leicb) + ctx->saltlen, req->iv, in chacha_iv()
95 static int poly_verify_tag(struct aead_request *req) in poly_verify_tag() argument
97 struct chachapoly_req_ctx *rctx = aead_request_ctx(req); in poly_verify_tag()
100 scatterwalk_map_and_copy(tag, req->src, in poly_verify_tag()
101 req->assoclen + rctx->cryptlen, in poly_verify_tag()
108 static int poly_copy_tag(struct aead_request *req) in poly_copy_tag() argument
110 struct chachapoly_req_ctx *rctx = aead_request_ctx(req); in poly_copy_tag()
112 scatterwalk_map_and_copy(rctx->tag, req->dst, in poly_copy_tag()
113 req->assoclen + rctx->cryptlen, in poly_copy_tag()
123 static int chacha_decrypt(struct aead_request *req) in chacha_decrypt() argument
125 struct chachapoly_ctx *ctx = crypto_aead_ctx(crypto_aead_reqtfm(req)); in chacha_decrypt()
126 struct chachapoly_req_ctx *rctx = aead_request_ctx(req); in chacha_decrypt()
134 chacha_iv(creq->iv, req, 1); in chacha_decrypt()
136 src = scatterwalk_ffwd(rctx->src, req->src, req->assoclen); in chacha_decrypt()
138 if (req->src != req->dst) in chacha_decrypt()
139 dst = scatterwalk_ffwd(rctx->dst, req->dst, req->assoclen); in chacha_decrypt()
141 skcipher_request_set_callback(&creq->req, rctx->flags, in chacha_decrypt()
142 chacha_decrypt_done, req); in chacha_decrypt()
143 skcipher_request_set_tfm(&creq->req, ctx->chacha); in chacha_decrypt()
144 skcipher_request_set_crypt(&creq->req, src, dst, in chacha_decrypt()
146 err = crypto_skcipher_decrypt(&creq->req); in chacha_decrypt()
151 return poly_verify_tag(req); in chacha_decrypt()
154 static int poly_tail_continue(struct aead_request *req) in poly_tail_continue() argument
156 struct chachapoly_req_ctx *rctx = aead_request_ctx(req); in poly_tail_continue()
158 if (rctx->cryptlen == req->cryptlen) /* encrypting */ in poly_tail_continue()
159 return poly_copy_tag(req); in poly_tail_continue()
161 return chacha_decrypt(req); in poly_tail_continue()
169 static int poly_tail(struct aead_request *req) in poly_tail() argument
171 struct crypto_aead *tfm = crypto_aead_reqtfm(req); in poly_tail()
173 struct chachapoly_req_ctx *rctx = aead_request_ctx(req); in poly_tail()
181 ahash_request_set_callback(&preq->req, rctx->flags, in poly_tail()
182 poly_tail_done, req); in poly_tail()
183 ahash_request_set_tfm(&preq->req, ctx->poly); in poly_tail()
184 ahash_request_set_crypt(&preq->req, preq->src, in poly_tail()
187 err = crypto_ahash_finup(&preq->req); in poly_tail()
191 return poly_tail_continue(req); in poly_tail()
199 static int poly_cipherpad(struct aead_request *req) in poly_cipherpad() argument
201 struct chachapoly_ctx *ctx = crypto_aead_ctx(crypto_aead_reqtfm(req)); in poly_cipherpad()
202 struct chachapoly_req_ctx *rctx = aead_request_ctx(req); in poly_cipherpad()
211 ahash_request_set_callback(&preq->req, rctx->flags, in poly_cipherpad()
212 poly_cipherpad_done, req); in poly_cipherpad()
213 ahash_request_set_tfm(&preq->req, ctx->poly); in poly_cipherpad()
214 ahash_request_set_crypt(&preq->req, preq->src, NULL, padlen); in poly_cipherpad()
216 err = crypto_ahash_update(&preq->req); in poly_cipherpad()
220 return poly_tail(req); in poly_cipherpad()
228 static int poly_cipher(struct aead_request *req) in poly_cipher() argument
230 struct chachapoly_ctx *ctx = crypto_aead_ctx(crypto_aead_reqtfm(req)); in poly_cipher()
231 struct chachapoly_req_ctx *rctx = aead_request_ctx(req); in poly_cipher()
233 struct scatterlist *crypt = req->src; in poly_cipher()
236 if (rctx->cryptlen == req->cryptlen) /* encrypting */ in poly_cipher()
237 crypt = req->dst; in poly_cipher()
239 crypt = scatterwalk_ffwd(rctx->src, crypt, req->assoclen); in poly_cipher()
241 ahash_request_set_callback(&preq->req, rctx->flags, in poly_cipher()
242 poly_cipher_done, req); in poly_cipher()
243 ahash_request_set_tfm(&preq->req, ctx->poly); in poly_cipher()
244 ahash_request_set_crypt(&preq->req, crypt, NULL, rctx->cryptlen); in poly_cipher()
246 err = crypto_ahash_update(&preq->req); in poly_cipher()
250 return poly_cipherpad(req); in poly_cipher()
258 static int poly_adpad(struct aead_request *req) in poly_adpad() argument
260 struct chachapoly_ctx *ctx = crypto_aead_ctx(crypto_aead_reqtfm(req)); in poly_adpad()
261 struct chachapoly_req_ctx *rctx = aead_request_ctx(req); in poly_adpad()
270 ahash_request_set_callback(&preq->req, rctx->flags, in poly_adpad()
271 poly_adpad_done, req); in poly_adpad()
272 ahash_request_set_tfm(&preq->req, ctx->poly); in poly_adpad()
273 ahash_request_set_crypt(&preq->req, preq->src, NULL, padlen); in poly_adpad()
275 err = crypto_ahash_update(&preq->req); in poly_adpad()
279 return poly_cipher(req); in poly_adpad()
287 static int poly_ad(struct aead_request *req) in poly_ad() argument
289 struct chachapoly_ctx *ctx = crypto_aead_ctx(crypto_aead_reqtfm(req)); in poly_ad()
290 struct chachapoly_req_ctx *rctx = aead_request_ctx(req); in poly_ad()
294 ahash_request_set_callback(&preq->req, rctx->flags, in poly_ad()
295 poly_ad_done, req); in poly_ad()
296 ahash_request_set_tfm(&preq->req, ctx->poly); in poly_ad()
297 ahash_request_set_crypt(&preq->req, req->src, NULL, rctx->assoclen); in poly_ad()
299 err = crypto_ahash_update(&preq->req); in poly_ad()
303 return poly_adpad(req); in poly_ad()
311 static int poly_setkey(struct aead_request *req) in poly_setkey() argument
313 struct chachapoly_ctx *ctx = crypto_aead_ctx(crypto_aead_reqtfm(req)); in poly_setkey()
314 struct chachapoly_req_ctx *rctx = aead_request_ctx(req); in poly_setkey()
320 ahash_request_set_callback(&preq->req, rctx->flags, in poly_setkey()
321 poly_setkey_done, req); in poly_setkey()
322 ahash_request_set_tfm(&preq->req, ctx->poly); in poly_setkey()
323 ahash_request_set_crypt(&preq->req, preq->src, NULL, sizeof(rctx->key)); in poly_setkey()
325 err = crypto_ahash_update(&preq->req); in poly_setkey()
329 return poly_ad(req); in poly_setkey()
337 static int poly_init(struct aead_request *req) in poly_init() argument
339 struct chachapoly_ctx *ctx = crypto_aead_ctx(crypto_aead_reqtfm(req)); in poly_init()
340 struct chachapoly_req_ctx *rctx = aead_request_ctx(req); in poly_init()
344 ahash_request_set_callback(&preq->req, rctx->flags, in poly_init()
345 poly_init_done, req); in poly_init()
346 ahash_request_set_tfm(&preq->req, ctx->poly); in poly_init()
348 err = crypto_ahash_init(&preq->req); in poly_init()
352 return poly_setkey(req); in poly_init()
360 static int poly_genkey(struct aead_request *req) in poly_genkey() argument
362 struct crypto_aead *tfm = crypto_aead_reqtfm(req); in poly_genkey()
364 struct chachapoly_req_ctx *rctx = aead_request_ctx(req); in poly_genkey()
368 rctx->assoclen = req->assoclen; in poly_genkey()
379 chacha_iv(creq->iv, req, 0); in poly_genkey()
381 skcipher_request_set_callback(&creq->req, rctx->flags, in poly_genkey()
382 poly_genkey_done, req); in poly_genkey()
383 skcipher_request_set_tfm(&creq->req, ctx->chacha); in poly_genkey()
384 skcipher_request_set_crypt(&creq->req, creq->src, creq->src, in poly_genkey()
387 err = crypto_skcipher_decrypt(&creq->req); in poly_genkey()
391 return poly_init(req); in poly_genkey()
399 static int chacha_encrypt(struct aead_request *req) in chacha_encrypt() argument
401 struct chachapoly_ctx *ctx = crypto_aead_ctx(crypto_aead_reqtfm(req)); in chacha_encrypt()
402 struct chachapoly_req_ctx *rctx = aead_request_ctx(req); in chacha_encrypt()
407 if (req->cryptlen == 0) in chacha_encrypt()
410 chacha_iv(creq->iv, req, 1); in chacha_encrypt()
412 src = scatterwalk_ffwd(rctx->src, req->src, req->assoclen); in chacha_encrypt()
414 if (req->src != req->dst) in chacha_encrypt()
415 dst = scatterwalk_ffwd(rctx->dst, req->dst, req->assoclen); in chacha_encrypt()
417 skcipher_request_set_callback(&creq->req, rctx->flags, in chacha_encrypt()
418 chacha_encrypt_done, req); in chacha_encrypt()
419 skcipher_request_set_tfm(&creq->req, ctx->chacha); in chacha_encrypt()
420 skcipher_request_set_crypt(&creq->req, src, dst, in chacha_encrypt()
421 req->cryptlen, creq->iv); in chacha_encrypt()
422 err = crypto_skcipher_encrypt(&creq->req); in chacha_encrypt()
427 return poly_genkey(req); in chacha_encrypt()
430 static int chachapoly_encrypt(struct aead_request *req) in chachapoly_encrypt() argument
432 struct chachapoly_req_ctx *rctx = aead_request_ctx(req); in chachapoly_encrypt()
434 rctx->cryptlen = req->cryptlen; in chachapoly_encrypt()
435 rctx->flags = aead_request_flags(req); in chachapoly_encrypt()
449 return chacha_encrypt(req); in chachapoly_encrypt()
452 static int chachapoly_decrypt(struct aead_request *req) in chachapoly_decrypt() argument
454 struct chachapoly_req_ctx *rctx = aead_request_ctx(req); in chachapoly_decrypt()
456 rctx->cryptlen = req->cryptlen - POLY1305_DIGEST_SIZE; in chachapoly_decrypt()
457 rctx->flags = aead_request_flags(req); in chachapoly_decrypt()
471 return poly_genkey(req); in chachapoly_decrypt()
528 max(offsetof(struct chacha_req, req) + in chachapoly_init()
531 offsetof(struct poly_req, req) + in chachapoly_init()