Lines Matching full:req
78 static inline int crypto4xx_crypt(struct skcipher_request *req, in crypto4xx_crypt() argument
82 struct crypto_skcipher *cipher = crypto_skcipher_reqtfm(req); in crypto4xx_crypt()
86 if (check_blocksize && !IS_ALIGNED(req->cryptlen, AES_BLOCK_SIZE)) in crypto4xx_crypt()
90 crypto4xx_memcpy_to_le32(iv, req->iv, ivlen); in crypto4xx_crypt()
92 return crypto4xx_build_pd(&req->base, ctx, req->src, req->dst, in crypto4xx_crypt()
93 req->cryptlen, iv, ivlen, decrypt ? ctx->sa_in : ctx->sa_out, in crypto4xx_crypt()
97 int crypto4xx_encrypt_noiv_block(struct skcipher_request *req) in crypto4xx_encrypt_noiv_block() argument
99 return crypto4xx_crypt(req, 0, false, true); in crypto4xx_encrypt_noiv_block()
102 int crypto4xx_encrypt_iv_stream(struct skcipher_request *req) in crypto4xx_encrypt_iv_stream() argument
104 return crypto4xx_crypt(req, AES_IV_SIZE, false, false); in crypto4xx_encrypt_iv_stream()
107 int crypto4xx_decrypt_noiv_block(struct skcipher_request *req) in crypto4xx_decrypt_noiv_block() argument
109 return crypto4xx_crypt(req, 0, true, true); in crypto4xx_decrypt_noiv_block()
112 int crypto4xx_decrypt_iv_stream(struct skcipher_request *req) in crypto4xx_decrypt_iv_stream() argument
114 return crypto4xx_crypt(req, AES_IV_SIZE, true, false); in crypto4xx_decrypt_iv_stream()
117 int crypto4xx_encrypt_iv_block(struct skcipher_request *req) in crypto4xx_encrypt_iv_block() argument
119 return crypto4xx_crypt(req, AES_IV_SIZE, false, true); in crypto4xx_encrypt_iv_block()
122 int crypto4xx_decrypt_iv_block(struct skcipher_request *req) in crypto4xx_decrypt_iv_block() argument
124 return crypto4xx_crypt(req, AES_IV_SIZE, true, true); in crypto4xx_decrypt_iv_block()
234 int crypto4xx_rfc3686_encrypt(struct skcipher_request *req) in crypto4xx_rfc3686_encrypt() argument
236 struct crypto_skcipher *cipher = crypto_skcipher_reqtfm(req); in crypto4xx_rfc3686_encrypt()
240 cpu_to_le32p((u32 *) req->iv), in crypto4xx_rfc3686_encrypt()
241 cpu_to_le32p((u32 *) (req->iv + 4)), in crypto4xx_rfc3686_encrypt()
244 return crypto4xx_build_pd(&req->base, ctx, req->src, req->dst, in crypto4xx_rfc3686_encrypt()
245 req->cryptlen, iv, AES_IV_SIZE, in crypto4xx_rfc3686_encrypt()
249 int crypto4xx_rfc3686_decrypt(struct skcipher_request *req) in crypto4xx_rfc3686_decrypt() argument
251 struct crypto_skcipher *cipher = crypto_skcipher_reqtfm(req); in crypto4xx_rfc3686_decrypt()
255 cpu_to_le32p((u32 *) req->iv), in crypto4xx_rfc3686_decrypt()
256 cpu_to_le32p((u32 *) (req->iv + 4)), in crypto4xx_rfc3686_decrypt()
259 return crypto4xx_build_pd(&req->base, ctx, req->src, req->dst, in crypto4xx_rfc3686_decrypt()
260 req->cryptlen, iv, AES_IV_SIZE, in crypto4xx_rfc3686_decrypt()
265 crypto4xx_ctr_crypt(struct skcipher_request *req, bool encrypt) in crypto4xx_ctr_crypt() argument
267 struct crypto_skcipher *cipher = crypto_skcipher_reqtfm(req); in crypto4xx_ctr_crypt()
270 unsigned int counter = be32_to_cpup((__be32 *)(req->iv + iv_len - 4)); in crypto4xx_ctr_crypt()
271 unsigned int nblks = ALIGN(req->cryptlen, AES_BLOCK_SIZE) / in crypto4xx_ctr_crypt()
281 struct skcipher_request *subreq = skcipher_request_ctx(req); in crypto4xx_ctr_crypt()
285 skcipher_request_set_callback(subreq, req->base.flags, in crypto4xx_ctr_crypt()
287 skcipher_request_set_crypt(subreq, req->src, req->dst, in crypto4xx_ctr_crypt()
288 req->cryptlen, req->iv); in crypto4xx_ctr_crypt()
295 return encrypt ? crypto4xx_encrypt_iv_stream(req) in crypto4xx_ctr_crypt()
296 : crypto4xx_decrypt_iv_stream(req); in crypto4xx_ctr_crypt()
333 int crypto4xx_encrypt_ctr(struct skcipher_request *req) in crypto4xx_encrypt_ctr() argument
335 return crypto4xx_ctr_crypt(req, true); in crypto4xx_encrypt_ctr()
338 int crypto4xx_decrypt_ctr(struct skcipher_request *req) in crypto4xx_decrypt_ctr() argument
340 return crypto4xx_ctr_crypt(req, false); in crypto4xx_decrypt_ctr()
343 static inline bool crypto4xx_aead_need_fallback(struct aead_request *req, in crypto4xx_aead_need_fallback() argument
347 struct crypto_aead *aead = crypto_aead_reqtfm(req); in crypto4xx_aead_need_fallback()
361 if (req->assoclen & 0x3 || req->assoclen > 1020) in crypto4xx_aead_need_fallback()
365 if (is_ccm && !(req->iv[0] == 1 || req->iv[0] == 3)) in crypto4xx_aead_need_fallback()
371 static int crypto4xx_aead_fallback(struct aead_request *req, in crypto4xx_aead_fallback() argument
374 struct aead_request *subreq = aead_request_ctx(req); in crypto4xx_aead_fallback()
377 aead_request_set_callback(subreq, req->base.flags, in crypto4xx_aead_fallback()
378 req->base.complete, req->base.data); in crypto4xx_aead_fallback()
379 aead_request_set_crypt(subreq, req->src, req->dst, req->cryptlen, in crypto4xx_aead_fallback()
380 req->iv); in crypto4xx_aead_fallback()
381 aead_request_set_ad(subreq, req->assoclen); in crypto4xx_aead_fallback()
469 static int crypto4xx_crypt_aes_ccm(struct aead_request *req, bool decrypt) in crypto4xx_crypt_aes_ccm() argument
471 struct crypto4xx_ctx *ctx = crypto_tfm_ctx(req->base.tfm); in crypto4xx_crypt_aes_ccm()
472 struct crypto4xx_aead_reqctx *rctx = aead_request_ctx(req); in crypto4xx_crypt_aes_ccm()
473 struct crypto_aead *aead = crypto_aead_reqtfm(req); in crypto4xx_crypt_aes_ccm()
477 unsigned int len = req->cryptlen; in crypto4xx_crypt_aes_ccm()
482 if (crypto4xx_aead_need_fallback(req, len, true, decrypt)) in crypto4xx_crypt_aes_ccm()
483 return crypto4xx_aead_fallback(req, ctx, decrypt); in crypto4xx_crypt_aes_ccm()
488 if (req->iv[0] == 1) { in crypto4xx_crypt_aes_ccm()
494 crypto4xx_memcpy_to_le32(iv, req->iv, 16 - (req->iv[0] + 1)); in crypto4xx_crypt_aes_ccm()
496 return crypto4xx_build_pd(&req->base, ctx, req->src, req->dst, in crypto4xx_crypt_aes_ccm()
498 sa, ctx->sa_len, req->assoclen, rctx->dst); in crypto4xx_crypt_aes_ccm()
501 int crypto4xx_encrypt_aes_ccm(struct aead_request *req) in crypto4xx_encrypt_aes_ccm() argument
503 return crypto4xx_crypt_aes_ccm(req, false); in crypto4xx_encrypt_aes_ccm()
506 int crypto4xx_decrypt_aes_ccm(struct aead_request *req) in crypto4xx_decrypt_aes_ccm() argument
508 return crypto4xx_crypt_aes_ccm(req, true); in crypto4xx_decrypt_aes_ccm()
626 static inline int crypto4xx_crypt_aes_gcm(struct aead_request *req, in crypto4xx_crypt_aes_gcm() argument
629 struct crypto4xx_ctx *ctx = crypto_tfm_ctx(req->base.tfm); in crypto4xx_crypt_aes_gcm()
630 struct crypto4xx_aead_reqctx *rctx = aead_request_ctx(req); in crypto4xx_crypt_aes_gcm()
632 unsigned int len = req->cryptlen; in crypto4xx_crypt_aes_gcm()
635 len -= crypto_aead_authsize(crypto_aead_reqtfm(req)); in crypto4xx_crypt_aes_gcm()
637 if (crypto4xx_aead_need_fallback(req, len, false, decrypt)) in crypto4xx_crypt_aes_gcm()
638 return crypto4xx_aead_fallback(req, ctx, decrypt); in crypto4xx_crypt_aes_gcm()
640 crypto4xx_memcpy_to_le32(iv, req->iv, GCM_AES_IV_SIZE); in crypto4xx_crypt_aes_gcm()
643 return crypto4xx_build_pd(&req->base, ctx, req->src, req->dst, in crypto4xx_crypt_aes_gcm()
646 ctx->sa_len, req->assoclen, rctx->dst); in crypto4xx_crypt_aes_gcm()
649 int crypto4xx_encrypt_aes_gcm(struct aead_request *req) in crypto4xx_encrypt_aes_gcm() argument
651 return crypto4xx_crypt_aes_gcm(req, false); in crypto4xx_encrypt_aes_gcm()
654 int crypto4xx_decrypt_aes_gcm(struct aead_request *req) in crypto4xx_decrypt_aes_gcm() argument
656 return crypto4xx_crypt_aes_gcm(req, true); in crypto4xx_decrypt_aes_gcm()
705 int crypto4xx_hash_init(struct ahash_request *req) in crypto4xx_hash_init() argument
707 struct crypto4xx_ctx *ctx = crypto_tfm_ctx(req->base.tfm); in crypto4xx_hash_init()
713 __crypto_ahash_cast(req->base.tfm)); in crypto4xx_hash_init()
720 int crypto4xx_hash_update(struct ahash_request *req) in crypto4xx_hash_update() argument
722 struct crypto_ahash *ahash = crypto_ahash_reqtfm(req); in crypto4xx_hash_update()
723 struct crypto4xx_ctx *ctx = crypto_tfm_ctx(req->base.tfm); in crypto4xx_hash_update()
727 sg_init_one(&dst, req->result, ds); in crypto4xx_hash_update()
729 return crypto4xx_build_pd(&req->base, ctx, req->src, &dst, in crypto4xx_hash_update()
730 req->nbytes, NULL, 0, ctx->sa_in, in crypto4xx_hash_update()
734 int crypto4xx_hash_final(struct ahash_request *req) in crypto4xx_hash_final() argument
739 int crypto4xx_hash_digest(struct ahash_request *req) in crypto4xx_hash_digest() argument
741 struct crypto_ahash *ahash = crypto_ahash_reqtfm(req); in crypto4xx_hash_digest()
742 struct crypto4xx_ctx *ctx = crypto_tfm_ctx(req->base.tfm); in crypto4xx_hash_digest()
746 sg_init_one(&dst, req->result, ds); in crypto4xx_hash_digest()
748 return crypto4xx_build_pd(&req->base, ctx, req->src, &dst, in crypto4xx_hash_digest()
749 req->nbytes, NULL, 0, ctx->sa_in, in crypto4xx_hash_digest()