Lines Matching refs:rctx

31 	struct ccp_sha_req_ctx *rctx = ahash_request_ctx_dma(req);  in ccp_sha_complete()  local
37 if (rctx->hash_rem) { in ccp_sha_complete()
39 unsigned int offset = rctx->nbytes - rctx->hash_rem; in ccp_sha_complete()
41 scatterwalk_map_and_copy(rctx->buf, rctx->src, in ccp_sha_complete()
42 offset, rctx->hash_rem, 0); in ccp_sha_complete()
43 rctx->buf_count = rctx->hash_rem; in ccp_sha_complete()
45 rctx->buf_count = 0; in ccp_sha_complete()
49 if (req->result && rctx->final) in ccp_sha_complete()
50 memcpy(req->result, rctx->ctx, digest_size); in ccp_sha_complete()
53 sg_free_table(&rctx->data_sg); in ccp_sha_complete()
63 struct ccp_sha_req_ctx *rctx = ahash_request_ctx_dma(req); in ccp_do_sha_update() local
72 len = (u64)rctx->buf_count + (u64)nbytes; in ccp_do_sha_update()
75 scatterwalk_map_and_copy(rctx->buf + rctx->buf_count, req->src, in ccp_do_sha_update()
77 rctx->buf_count += nbytes; in ccp_do_sha_update()
82 rctx->src = req->src; in ccp_do_sha_update()
83 rctx->nbytes = nbytes; in ccp_do_sha_update()
85 rctx->final = final; in ccp_do_sha_update()
86 rctx->hash_rem = final ? 0 : len & (block_size - 1); in ccp_do_sha_update()
87 rctx->hash_cnt = len - rctx->hash_rem; in ccp_do_sha_update()
88 if (!final && !rctx->hash_rem) { in ccp_do_sha_update()
90 rctx->hash_cnt -= block_size; in ccp_do_sha_update()
91 rctx->hash_rem = block_size; in ccp_do_sha_update()
95 sg_init_one(&rctx->ctx_sg, rctx->ctx, sizeof(rctx->ctx)); in ccp_do_sha_update()
98 if (rctx->buf_count && nbytes) { in ccp_do_sha_update()
105 ret = sg_alloc_table(&rctx->data_sg, sg_count, gfp); in ccp_do_sha_update()
109 sg_init_one(&rctx->buf_sg, rctx->buf, rctx->buf_count); in ccp_do_sha_update()
110 sg = ccp_crypto_sg_table_add(&rctx->data_sg, &rctx->buf_sg); in ccp_do_sha_update()
115 sg = ccp_crypto_sg_table_add(&rctx->data_sg, req->src); in ccp_do_sha_update()
122 sg = rctx->data_sg.sgl; in ccp_do_sha_update()
123 } else if (rctx->buf_count) { in ccp_do_sha_update()
124 sg_init_one(&rctx->buf_sg, rctx->buf, rctx->buf_count); in ccp_do_sha_update()
126 sg = &rctx->buf_sg; in ccp_do_sha_update()
131 rctx->msg_bits += (rctx->hash_cnt << 3); /* Total in bits */ in ccp_do_sha_update()
133 memset(&rctx->cmd, 0, sizeof(rctx->cmd)); in ccp_do_sha_update()
134 INIT_LIST_HEAD(&rctx->cmd.entry); in ccp_do_sha_update()
135 rctx->cmd.engine = CCP_ENGINE_SHA; in ccp_do_sha_update()
136 rctx->cmd.u.sha.type = rctx->type; in ccp_do_sha_update()
137 rctx->cmd.u.sha.ctx = &rctx->ctx_sg; in ccp_do_sha_update()
139 switch (rctx->type) { in ccp_do_sha_update()
141 rctx->cmd.u.sha.ctx_len = SHA1_DIGEST_SIZE; in ccp_do_sha_update()
144 rctx->cmd.u.sha.ctx_len = SHA224_DIGEST_SIZE; in ccp_do_sha_update()
147 rctx->cmd.u.sha.ctx_len = SHA256_DIGEST_SIZE; in ccp_do_sha_update()
150 rctx->cmd.u.sha.ctx_len = SHA384_DIGEST_SIZE; in ccp_do_sha_update()
153 rctx->cmd.u.sha.ctx_len = SHA512_DIGEST_SIZE; in ccp_do_sha_update()
160 rctx->cmd.u.sha.src = sg; in ccp_do_sha_update()
161 rctx->cmd.u.sha.src_len = rctx->hash_cnt; in ccp_do_sha_update()
162 rctx->cmd.u.sha.opad = ctx->u.sha.key_len ? in ccp_do_sha_update()
164 rctx->cmd.u.sha.opad_len = ctx->u.sha.key_len ? in ccp_do_sha_update()
166 rctx->cmd.u.sha.first = rctx->first; in ccp_do_sha_update()
167 rctx->cmd.u.sha.final = rctx->final; in ccp_do_sha_update()
168 rctx->cmd.u.sha.msg_bits = rctx->msg_bits; in ccp_do_sha_update()
170 rctx->first = 0; in ccp_do_sha_update()
172 ret = ccp_crypto_enqueue_request(&req->base, &rctx->cmd); in ccp_do_sha_update()
177 sg_free_table(&rctx->data_sg); in ccp_do_sha_update()
186 struct ccp_sha_req_ctx *rctx = ahash_request_ctx_dma(req); in ccp_sha_init() local
192 memset(rctx, 0, sizeof(*rctx)); in ccp_sha_init()
194 rctx->type = alg->type; in ccp_sha_init()
195 rctx->first = 1; in ccp_sha_init()
199 memcpy(rctx->buf, ctx->u.sha.ipad, block_size); in ccp_sha_init()
200 rctx->buf_count = block_size; in ccp_sha_init()
234 struct ccp_sha_req_ctx *rctx = ahash_request_ctx_dma(req); in ccp_sha_export() local
240 state.type = rctx->type; in ccp_sha_export()
241 state.msg_bits = rctx->msg_bits; in ccp_sha_export()
242 state.first = rctx->first; in ccp_sha_export()
243 memcpy(state.ctx, rctx->ctx, sizeof(state.ctx)); in ccp_sha_export()
244 state.buf_count = rctx->buf_count; in ccp_sha_export()
245 memcpy(state.buf, rctx->buf, sizeof(state.buf)); in ccp_sha_export()
255 struct ccp_sha_req_ctx *rctx = ahash_request_ctx_dma(req); in ccp_sha_import() local
261 memset(rctx, 0, sizeof(*rctx)); in ccp_sha_import()
262 rctx->type = state.type; in ccp_sha_import()
263 rctx->msg_bits = state.msg_bits; in ccp_sha_import()
264 rctx->first = state.first; in ccp_sha_import()
265 memcpy(rctx->ctx, state.ctx, sizeof(rctx->ctx)); in ccp_sha_import()
266 rctx->buf_count = state.buf_count; in ccp_sha_import()
267 memcpy(rctx->buf, state.buf, sizeof(rctx->buf)); in ccp_sha_import()