Lines Matching refs:req

35 	struct skcipher_request req; /* must be last member */  member
56 static inline void async_done_continue(struct aead_request *req, int err, in async_done_continue() argument
60 struct chachapoly_req_ctx *rctx = aead_request_ctx(req); in async_done_continue()
63 err = cont(req); in async_done_continue()
67 aead_request_complete(req, err); in async_done_continue()
70 static void chacha_iv(u8 *iv, struct aead_request *req, u32 icb) in chacha_iv() argument
72 struct chachapoly_ctx *ctx = crypto_aead_ctx(crypto_aead_reqtfm(req)); in chacha_iv()
77 memcpy(iv + sizeof(leicb) + ctx->saltlen, req->iv, in chacha_iv()
81 static int poly_verify_tag(struct aead_request *req) in poly_verify_tag() argument
83 struct chachapoly_req_ctx *rctx = aead_request_ctx(req); in poly_verify_tag()
86 scatterwalk_map_and_copy(tag, req->src, in poly_verify_tag()
87 req->assoclen + rctx->cryptlen, in poly_verify_tag()
99 static int chacha_decrypt(struct aead_request *req) in chacha_decrypt() argument
101 struct chachapoly_ctx *ctx = crypto_aead_ctx(crypto_aead_reqtfm(req)); in chacha_decrypt()
102 struct chachapoly_req_ctx *rctx = aead_request_ctx(req); in chacha_decrypt()
110 chacha_iv(creq->iv, req, 1); in chacha_decrypt()
112 src = scatterwalk_ffwd(rctx->src, req->src, req->assoclen); in chacha_decrypt()
114 if (req->src != req->dst) in chacha_decrypt()
115 dst = scatterwalk_ffwd(rctx->dst, req->dst, req->assoclen); in chacha_decrypt()
117 skcipher_request_set_callback(&creq->req, rctx->flags, in chacha_decrypt()
118 chacha_decrypt_done, req); in chacha_decrypt()
119 skcipher_request_set_tfm(&creq->req, ctx->chacha); in chacha_decrypt()
120 skcipher_request_set_crypt(&creq->req, src, dst, in chacha_decrypt()
122 err = crypto_skcipher_decrypt(&creq->req); in chacha_decrypt()
127 return poly_verify_tag(req); in chacha_decrypt()
130 static int poly_hash(struct aead_request *req) in poly_hash() argument
132 struct chachapoly_req_ctx *rctx = aead_request_ctx(req); in poly_hash()
134 struct scatterlist *sg = req->src; in poly_hash()
149 if (sg != req->dst) in poly_hash()
150 memcpy_sglist(req->dst, sg, req->assoclen); in poly_hash()
152 if (rctx->cryptlen == req->cryptlen) /* encrypting */ in poly_hash()
153 sg = req->dst; in poly_hash()
170 scatterwalk_skip(&walk, req->assoclen - rctx->assoclen); in poly_hash()
190 if (rctx->cryptlen != req->cryptlen) in poly_hash()
191 return chacha_decrypt(req); in poly_hash()
202 static int poly_genkey(struct aead_request *req) in poly_genkey() argument
204 struct crypto_aead *tfm = crypto_aead_reqtfm(req); in poly_genkey()
206 struct chachapoly_req_ctx *rctx = aead_request_ctx(req); in poly_genkey()
210 rctx->assoclen = req->assoclen; in poly_genkey()
221 chacha_iv(creq->iv, req, 0); in poly_genkey()
223 skcipher_request_set_callback(&creq->req, rctx->flags, in poly_genkey()
224 poly_genkey_done, req); in poly_genkey()
225 skcipher_request_set_tfm(&creq->req, ctx->chacha); in poly_genkey()
226 skcipher_request_set_crypt(&creq->req, creq->src, creq->src, in poly_genkey()
229 err = crypto_skcipher_decrypt(&creq->req); in poly_genkey()
233 return poly_hash(req); in poly_genkey()
241 static int chacha_encrypt(struct aead_request *req) in chacha_encrypt() argument
243 struct chachapoly_ctx *ctx = crypto_aead_ctx(crypto_aead_reqtfm(req)); in chacha_encrypt()
244 struct chachapoly_req_ctx *rctx = aead_request_ctx(req); in chacha_encrypt()
249 if (req->cryptlen == 0) in chacha_encrypt()
252 chacha_iv(creq->iv, req, 1); in chacha_encrypt()
254 src = scatterwalk_ffwd(rctx->src, req->src, req->assoclen); in chacha_encrypt()
256 if (req->src != req->dst) in chacha_encrypt()
257 dst = scatterwalk_ffwd(rctx->dst, req->dst, req->assoclen); in chacha_encrypt()
259 skcipher_request_set_callback(&creq->req, rctx->flags, in chacha_encrypt()
260 chacha_encrypt_done, req); in chacha_encrypt()
261 skcipher_request_set_tfm(&creq->req, ctx->chacha); in chacha_encrypt()
262 skcipher_request_set_crypt(&creq->req, src, dst, in chacha_encrypt()
263 req->cryptlen, creq->iv); in chacha_encrypt()
264 err = crypto_skcipher_encrypt(&creq->req); in chacha_encrypt()
269 return poly_genkey(req); in chacha_encrypt()
272 static int chachapoly_encrypt(struct aead_request *req) in chachapoly_encrypt() argument
274 struct chachapoly_req_ctx *rctx = aead_request_ctx(req); in chachapoly_encrypt()
276 rctx->cryptlen = req->cryptlen; in chachapoly_encrypt()
277 rctx->flags = aead_request_flags(req); in chachapoly_encrypt()
284 return chacha_encrypt(req); in chachapoly_encrypt()
287 static int chachapoly_decrypt(struct aead_request *req) in chachapoly_decrypt() argument
289 struct chachapoly_req_ctx *rctx = aead_request_ctx(req); in chachapoly_decrypt()
291 rctx->cryptlen = req->cryptlen - POLY1305_DIGEST_SIZE; in chachapoly_decrypt()
292 rctx->flags = aead_request_flags(req); in chachapoly_decrypt()
300 return poly_genkey(req); in chachapoly_decrypt()
349 offsetof(struct chacha_req, req) + in chachapoly_init()