Lines Matching refs:req
548 static void sahara_aes_cbc_update_iv(struct skcipher_request *req)
550 struct crypto_skcipher *skcipher = crypto_skcipher_reqtfm(req);
551 struct sahara_aes_reqctx *rctx = skcipher_request_ctx(req);
556 sg_pcopy_to_buffer(req->dst, sg_nents(req->dst), req->iv,
557 ivsize, req->cryptlen - ivsize);
559 memcpy(req->iv, rctx->iv_out, ivsize);
563 static int sahara_aes_process(struct skcipher_request *req)
565 struct crypto_skcipher *skcipher = crypto_skcipher_reqtfm(req);
575 req->cryptlen, req->src, req->dst);
578 dev->total = req->cryptlen;
579 dev->in_sg = req->src;
580 dev->out_sg = req->dst;
582 rctx = skcipher_request_ctx(req);
583 ctx = crypto_skcipher_ctx(crypto_skcipher_reqtfm(req));
587 if ((dev->flags & FLAGS_CBC) && req->iv) {
590 memcpy(dev->iv_base, req->iv, ivsize);
593 sg_pcopy_to_buffer(req->src, sg_nents(req->src),
595 req->cryptlen - ivsize);
621 if ((dev->flags & FLAGS_CBC) && req->iv)
622 sahara_aes_cbc_update_iv(req);
652 static int sahara_aes_fallback(struct skcipher_request *req, unsigned long mode)
654 struct sahara_aes_reqctx *rctx = skcipher_request_ctx(req);
656 crypto_skcipher_reqtfm(req));
660 req->base.flags,
661 req->base.complete,
662 req->base.data);
663 skcipher_request_set_crypt(&rctx->fallback_req, req->src,
664 req->dst, req->cryptlen, req->iv);
672 static int sahara_aes_crypt(struct skcipher_request *req, unsigned long mode)
674 struct sahara_aes_reqctx *rctx = skcipher_request_ctx(req);
676 crypto_skcipher_reqtfm(req));
680 if (!req->cryptlen)
684 return sahara_aes_fallback(req, mode);
687 req->cryptlen, !!(mode & FLAGS_ENCRYPT), !!(mode & FLAGS_CBC));
689 if (!IS_ALIGNED(req->cryptlen, AES_BLOCK_SIZE)) {
698 err = crypto_enqueue_request(&dev->queue, &req->base);
706 static int sahara_aes_ecb_encrypt(struct skcipher_request *req)
708 return sahara_aes_crypt(req, FLAGS_ENCRYPT);
711 static int sahara_aes_ecb_decrypt(struct skcipher_request *req)
713 return sahara_aes_crypt(req, 0);
716 static int sahara_aes_cbc_encrypt(struct skcipher_request *req)
718 return sahara_aes_crypt(req, FLAGS_ENCRYPT | FLAGS_CBC);
721 static int sahara_aes_cbc_decrypt(struct skcipher_request *req)
723 return sahara_aes_crypt(req, FLAGS_CBC);
819 struct ahash_request *req,
872 struct ahash_request *req,
889 static int sahara_sha_prepare_request(struct ahash_request *req)
891 struct crypto_ahash *tfm = crypto_ahash_reqtfm(req);
892 struct sahara_sha_reqctx *rctx = ahash_request_ctx(req);
900 len = rctx->buf_cnt + req->nbytes;
905 scatterwalk_map_and_copy(rctx->buf + rctx->buf_cnt, req->src,
906 0, req->nbytes, 0);
907 rctx->buf_cnt += req->nbytes;
919 unsigned int offset = req->nbytes - hash_later;
921 scatterwalk_map_and_copy(rctx->buf, req->src, offset,
927 if (rctx->buf_cnt && req->nbytes) {
930 sg_chain(rctx->in_sg_chain, 2, req->src);
938 rctx->in_sg = req->src;
947 static int sahara_sha_process(struct ahash_request *req)
950 struct sahara_sha_reqctx *rctx = ahash_request_ctx(req);
954 ret = sahara_sha_prepare_request(req);
959 ret = sahara_sha_hw_data_descriptor_create(dev, rctx, req, 0);
968 sahara_sha_hw_context_descriptor_create(dev, rctx, req, 0);
970 ret = sahara_sha_hw_data_descriptor_create(dev, rctx, req, 1);
998 if (req->result && rctx->last)
999 memcpy(req->result, rctx->context, rctx->digest_size);
1025 struct ahash_request *req =
1028 ret = sahara_sha_process(req);
1030 struct skcipher_request *req =
1033 ret = sahara_aes_process(req);
1047 static int sahara_sha_enqueue(struct ahash_request *req, int last)
1049 struct sahara_sha_reqctx *rctx = ahash_request_ctx(req);
1053 if (!req->nbytes && !last)
1064 ret = crypto_enqueue_request(&dev->queue, &req->base);
1072 static int sahara_sha_init(struct ahash_request *req)
1074 struct crypto_ahash *tfm = crypto_ahash_reqtfm(req);
1075 struct sahara_sha_reqctx *rctx = ahash_request_ctx(req);
1098 static int sahara_sha_update(struct ahash_request *req)
1100 return sahara_sha_enqueue(req, 0);
1103 static int sahara_sha_final(struct ahash_request *req)
1105 req->nbytes = 0;
1106 return sahara_sha_enqueue(req, 1);
1109 static int sahara_sha_finup(struct ahash_request *req)
1111 return sahara_sha_enqueue(req, 1);
1114 static int sahara_sha_digest(struct ahash_request *req)
1116 sahara_sha_init(req);
1118 return sahara_sha_finup(req);
1121 static int sahara_sha_export(struct ahash_request *req, void *out)
1123 struct sahara_sha_reqctx *rctx = ahash_request_ctx(req);
1130 static int sahara_sha_import(struct ahash_request *req, const void *in)
1132 struct sahara_sha_reqctx *rctx = ahash_request_ctx(req);