Lines Matching defs:req

540 static void sahara_aes_cbc_update_iv(struct skcipher_request *req)
542 struct crypto_skcipher *skcipher = crypto_skcipher_reqtfm(req);
543 struct sahara_aes_reqctx *rctx = skcipher_request_ctx(req);
548 sg_pcopy_to_buffer(req->dst, sg_nents(req->dst), req->iv,
549 ivsize, req->cryptlen - ivsize);
551 memcpy(req->iv, rctx->iv_out, ivsize);
555 static int sahara_aes_process(struct skcipher_request *req)
557 struct crypto_skcipher *skcipher = crypto_skcipher_reqtfm(req);
567 req->cryptlen, req->src, req->dst);
570 dev->total = req->cryptlen;
571 dev->in_sg = req->src;
572 dev->out_sg = req->dst;
574 rctx = skcipher_request_ctx(req);
575 ctx = crypto_skcipher_ctx(crypto_skcipher_reqtfm(req));
579 if ((dev->flags & FLAGS_CBC) && req->iv) {
582 memcpy(dev->iv_base, req->iv, ivsize);
585 sg_pcopy_to_buffer(req->src, sg_nents(req->src),
587 req->cryptlen - ivsize);
613 if ((dev->flags & FLAGS_CBC) && req->iv)
614 sahara_aes_cbc_update_iv(req);
644 static int sahara_aes_fallback(struct skcipher_request *req, unsigned long mode)
646 struct sahara_aes_reqctx *rctx = skcipher_request_ctx(req);
648 crypto_skcipher_reqtfm(req));
652 req->base.flags,
653 req->base.complete,
654 req->base.data);
655 skcipher_request_set_crypt(&rctx->fallback_req, req->src,
656 req->dst, req->cryptlen, req->iv);
664 static int sahara_aes_crypt(struct skcipher_request *req, unsigned long mode)
666 struct sahara_aes_reqctx *rctx = skcipher_request_ctx(req);
668 crypto_skcipher_reqtfm(req));
671 if (!req->cryptlen)
675 return sahara_aes_fallback(req, mode);
678 req->cryptlen, !!(mode & FLAGS_ENCRYPT), !!(mode & FLAGS_CBC));
680 if (!IS_ALIGNED(req->cryptlen, AES_BLOCK_SIZE))
685 return crypto_transfer_skcipher_request_to_engine(dev->engine, req);
688 static int sahara_aes_ecb_encrypt(struct skcipher_request *req)
690 return sahara_aes_crypt(req, FLAGS_ENCRYPT);
693 static int sahara_aes_ecb_decrypt(struct skcipher_request *req)
695 return sahara_aes_crypt(req, 0);
698 static int sahara_aes_cbc_encrypt(struct skcipher_request *req)
700 return sahara_aes_crypt(req, FLAGS_ENCRYPT | FLAGS_CBC);
703 static int sahara_aes_cbc_decrypt(struct skcipher_request *req)
705 return sahara_aes_crypt(req, FLAGS_CBC);
801 struct ahash_request *req,
854 struct ahash_request *req,
871 static int sahara_sha_prepare_request(struct ahash_request *req)
873 struct crypto_ahash *tfm = crypto_ahash_reqtfm(req);
874 struct sahara_sha_reqctx *rctx = ahash_request_ctx(req);
882 len = rctx->buf_cnt + req->nbytes;
887 scatterwalk_map_and_copy(rctx->buf + rctx->buf_cnt, req->src,
888 0, req->nbytes, 0);
889 rctx->buf_cnt += req->nbytes;
901 unsigned int offset = req->nbytes - hash_later;
903 scatterwalk_map_and_copy(rctx->buf, req->src, offset,
909 if (rctx->buf_cnt && req->nbytes) {
912 sg_chain(rctx->in_sg_chain, 2, req->src);
920 rctx->in_sg = req->src;
929 static int sahara_sha_process(struct ahash_request *req)
932 struct sahara_sha_reqctx *rctx = ahash_request_ctx(req);
936 ret = sahara_sha_prepare_request(req);
941 ret = sahara_sha_hw_data_descriptor_create(dev, rctx, req, 0);
950 sahara_sha_hw_context_descriptor_create(dev, rctx, req, 0);
952 ret = sahara_sha_hw_data_descriptor_create(dev, rctx, req, 1);
980 if (req->result && rctx->last)
981 memcpy(req->result, rctx->context, rctx->digest_size);
992 struct ahash_request *req = ahash_request_cast(async_req);
994 err = sahara_sha_process(req);
996 crypto_finalize_hash_request(engine, req, err);
999 struct skcipher_request *req = skcipher_request_cast(async_req);
1003 crypto_finalize_skcipher_request(engine, req, err);
1010 static int sahara_sha_enqueue(struct ahash_request *req, int last)
1012 struct sahara_sha_reqctx *rctx = ahash_request_ctx(req);
1015 if (!req->nbytes && !last)
1020 return crypto_transfer_hash_request_to_engine(dev->engine, req);
1023 static int sahara_sha_init(struct ahash_request *req)
1025 struct crypto_ahash *tfm = crypto_ahash_reqtfm(req);
1026 struct sahara_sha_reqctx *rctx = ahash_request_ctx(req);
1049 static int sahara_sha_update(struct ahash_request *req)
1051 return sahara_sha_enqueue(req, 0);
1054 static int sahara_sha_final(struct ahash_request *req)
1056 req->nbytes = 0;
1057 return sahara_sha_enqueue(req, 1);
1060 static int sahara_sha_finup(struct ahash_request *req)
1062 return sahara_sha_enqueue(req, 1);
1065 static int sahara_sha_digest(struct ahash_request *req)
1067 sahara_sha_init(req);
1069 return sahara_sha_finup(req);
1072 static int sahara_sha_export(struct ahash_request *req, void *out)
1074 struct sahara_sha_reqctx *rctx = ahash_request_ctx(req);
1081 static int sahara_sha_import(struct ahash_request *req, const void *in)
1083 struct sahara_sha_reqctx *rctx = ahash_request_ctx(req);