Lines Matching full:req

69 static inline int crypto4xx_crypt(struct skcipher_request *req,  in crypto4xx_crypt()  argument
73 struct crypto_skcipher *cipher = crypto_skcipher_reqtfm(req); in crypto4xx_crypt()
77 if (check_blocksize && !IS_ALIGNED(req->cryptlen, AES_BLOCK_SIZE)) in crypto4xx_crypt()
81 crypto4xx_memcpy_to_le32(iv, req->iv, ivlen); in crypto4xx_crypt()
83 return crypto4xx_build_pd(&req->base, ctx, req->src, req->dst, in crypto4xx_crypt()
84 req->cryptlen, iv, ivlen, decrypt ? ctx->sa_in : ctx->sa_out, in crypto4xx_crypt()
88 int crypto4xx_encrypt_noiv_block(struct skcipher_request *req) in crypto4xx_encrypt_noiv_block() argument
90 return crypto4xx_crypt(req, 0, false, true); in crypto4xx_encrypt_noiv_block()
93 int crypto4xx_encrypt_iv_stream(struct skcipher_request *req) in crypto4xx_encrypt_iv_stream() argument
95 return crypto4xx_crypt(req, AES_IV_SIZE, false, false); in crypto4xx_encrypt_iv_stream()
98 int crypto4xx_decrypt_noiv_block(struct skcipher_request *req) in crypto4xx_decrypt_noiv_block() argument
100 return crypto4xx_crypt(req, 0, true, true); in crypto4xx_decrypt_noiv_block()
103 int crypto4xx_decrypt_iv_stream(struct skcipher_request *req) in crypto4xx_decrypt_iv_stream() argument
105 return crypto4xx_crypt(req, AES_IV_SIZE, true, false); in crypto4xx_decrypt_iv_stream()
108 int crypto4xx_encrypt_iv_block(struct skcipher_request *req) in crypto4xx_encrypt_iv_block() argument
110 return crypto4xx_crypt(req, AES_IV_SIZE, false, true); in crypto4xx_encrypt_iv_block()
113 int crypto4xx_decrypt_iv_block(struct skcipher_request *req) in crypto4xx_decrypt_iv_block() argument
115 return crypto4xx_crypt(req, AES_IV_SIZE, true, true); in crypto4xx_decrypt_iv_block()
222 int crypto4xx_rfc3686_encrypt(struct skcipher_request *req) in crypto4xx_rfc3686_encrypt() argument
224 struct crypto_skcipher *cipher = crypto_skcipher_reqtfm(req); in crypto4xx_rfc3686_encrypt()
228 cpu_to_le32p((u32 *) req->iv), in crypto4xx_rfc3686_encrypt()
229 cpu_to_le32p((u32 *) (req->iv + 4)), in crypto4xx_rfc3686_encrypt()
232 return crypto4xx_build_pd(&req->base, ctx, req->src, req->dst, in crypto4xx_rfc3686_encrypt()
233 req->cryptlen, iv, AES_IV_SIZE, in crypto4xx_rfc3686_encrypt()
237 int crypto4xx_rfc3686_decrypt(struct skcipher_request *req) in crypto4xx_rfc3686_decrypt() argument
239 struct crypto_skcipher *cipher = crypto_skcipher_reqtfm(req); in crypto4xx_rfc3686_decrypt()
243 cpu_to_le32p((u32 *) req->iv), in crypto4xx_rfc3686_decrypt()
244 cpu_to_le32p((u32 *) (req->iv + 4)), in crypto4xx_rfc3686_decrypt()
247 return crypto4xx_build_pd(&req->base, ctx, req->src, req->dst, in crypto4xx_rfc3686_decrypt()
248 req->cryptlen, iv, AES_IV_SIZE, in crypto4xx_rfc3686_decrypt()
253 crypto4xx_ctr_crypt(struct skcipher_request *req, bool encrypt) in crypto4xx_ctr_crypt() argument
255 struct crypto_skcipher *cipher = crypto_skcipher_reqtfm(req); in crypto4xx_ctr_crypt()
258 unsigned int counter = be32_to_cpup((__be32 *)(req->iv + iv_len - 4)); in crypto4xx_ctr_crypt()
259 unsigned int nblks = ALIGN(req->cryptlen, AES_BLOCK_SIZE) / in crypto4xx_ctr_crypt()
273 skcipher_request_set_callback(subreq, req->base.flags, in crypto4xx_ctr_crypt()
275 skcipher_request_set_crypt(subreq, req->src, req->dst, in crypto4xx_ctr_crypt()
276 req->cryptlen, req->iv); in crypto4xx_ctr_crypt()
283 return encrypt ? crypto4xx_encrypt_iv_stream(req) in crypto4xx_ctr_crypt()
284 : crypto4xx_decrypt_iv_stream(req); in crypto4xx_ctr_crypt()
313 int crypto4xx_encrypt_ctr(struct skcipher_request *req) in crypto4xx_encrypt_ctr() argument
315 return crypto4xx_ctr_crypt(req, true); in crypto4xx_encrypt_ctr()
318 int crypto4xx_decrypt_ctr(struct skcipher_request *req) in crypto4xx_decrypt_ctr() argument
320 return crypto4xx_ctr_crypt(req, false); in crypto4xx_decrypt_ctr()
323 static inline bool crypto4xx_aead_need_fallback(struct aead_request *req, in crypto4xx_aead_need_fallback() argument
327 struct crypto_aead *aead = crypto_aead_reqtfm(req); in crypto4xx_aead_need_fallback()
341 if (req->assoclen & 0x3 || req->assoclen > 1020) in crypto4xx_aead_need_fallback()
345 if (is_ccm && !(req->iv[0] == 1 || req->iv[0] == 3)) in crypto4xx_aead_need_fallback()
351 static int crypto4xx_aead_fallback(struct aead_request *req, in crypto4xx_aead_fallback() argument
354 struct aead_request *subreq = aead_request_ctx(req); in crypto4xx_aead_fallback()
357 aead_request_set_callback(subreq, req->base.flags, in crypto4xx_aead_fallback()
358 req->base.complete, req->base.data); in crypto4xx_aead_fallback()
359 aead_request_set_crypt(subreq, req->src, req->dst, req->cryptlen, in crypto4xx_aead_fallback()
360 req->iv); in crypto4xx_aead_fallback()
361 aead_request_set_ad(subreq, req->assoclen); in crypto4xx_aead_fallback()
441 static int crypto4xx_crypt_aes_ccm(struct aead_request *req, bool decrypt) in crypto4xx_crypt_aes_ccm() argument
443 struct crypto4xx_ctx *ctx = crypto_tfm_ctx(req->base.tfm); in crypto4xx_crypt_aes_ccm()
444 struct crypto4xx_aead_reqctx *rctx = aead_request_ctx(req); in crypto4xx_crypt_aes_ccm()
445 struct crypto_aead *aead = crypto_aead_reqtfm(req); in crypto4xx_crypt_aes_ccm()
449 unsigned int len = req->cryptlen; in crypto4xx_crypt_aes_ccm()
454 if (crypto4xx_aead_need_fallback(req, len, true, decrypt)) in crypto4xx_crypt_aes_ccm()
455 return crypto4xx_aead_fallback(req, ctx, decrypt); in crypto4xx_crypt_aes_ccm()
460 if (req->iv[0] == 1) { in crypto4xx_crypt_aes_ccm()
466 crypto4xx_memcpy_to_le32(iv, req->iv, 16 - (req->iv[0] + 1)); in crypto4xx_crypt_aes_ccm()
468 return crypto4xx_build_pd(&req->base, ctx, req->src, req->dst, in crypto4xx_crypt_aes_ccm()
470 sa, ctx->sa_len, req->assoclen, rctx->dst); in crypto4xx_crypt_aes_ccm()
473 int crypto4xx_encrypt_aes_ccm(struct aead_request *req) in crypto4xx_encrypt_aes_ccm() argument
475 return crypto4xx_crypt_aes_ccm(req, false); in crypto4xx_encrypt_aes_ccm()
478 int crypto4xx_decrypt_aes_ccm(struct aead_request *req) in crypto4xx_decrypt_aes_ccm() argument
480 return crypto4xx_crypt_aes_ccm(req, true); in crypto4xx_decrypt_aes_ccm()
587 static inline int crypto4xx_crypt_aes_gcm(struct aead_request *req, in crypto4xx_crypt_aes_gcm() argument
590 struct crypto4xx_ctx *ctx = crypto_tfm_ctx(req->base.tfm); in crypto4xx_crypt_aes_gcm()
591 struct crypto4xx_aead_reqctx *rctx = aead_request_ctx(req); in crypto4xx_crypt_aes_gcm()
593 unsigned int len = req->cryptlen; in crypto4xx_crypt_aes_gcm()
596 len -= crypto_aead_authsize(crypto_aead_reqtfm(req)); in crypto4xx_crypt_aes_gcm()
598 if (crypto4xx_aead_need_fallback(req, len, false, decrypt)) in crypto4xx_crypt_aes_gcm()
599 return crypto4xx_aead_fallback(req, ctx, decrypt); in crypto4xx_crypt_aes_gcm()
601 crypto4xx_memcpy_to_le32(iv, req->iv, GCM_AES_IV_SIZE); in crypto4xx_crypt_aes_gcm()
604 return crypto4xx_build_pd(&req->base, ctx, req->src, req->dst, in crypto4xx_crypt_aes_gcm()
607 ctx->sa_len, req->assoclen, rctx->dst); in crypto4xx_crypt_aes_gcm()
610 int crypto4xx_encrypt_aes_gcm(struct aead_request *req) in crypto4xx_encrypt_aes_gcm() argument
612 return crypto4xx_crypt_aes_gcm(req, false); in crypto4xx_encrypt_aes_gcm()
615 int crypto4xx_decrypt_aes_gcm(struct aead_request *req) in crypto4xx_decrypt_aes_gcm() argument
617 return crypto4xx_crypt_aes_gcm(req, true); in crypto4xx_decrypt_aes_gcm()
666 int crypto4xx_hash_init(struct ahash_request *req) in crypto4xx_hash_init() argument
668 struct crypto4xx_ctx *ctx = crypto_tfm_ctx(req->base.tfm); in crypto4xx_hash_init()
674 __crypto_ahash_cast(req->base.tfm)); in crypto4xx_hash_init()
681 int crypto4xx_hash_update(struct ahash_request *req) in crypto4xx_hash_update() argument
683 struct crypto_ahash *ahash = crypto_ahash_reqtfm(req); in crypto4xx_hash_update()
684 struct crypto4xx_ctx *ctx = crypto_tfm_ctx(req->base.tfm); in crypto4xx_hash_update()
688 sg_init_one(&dst, req->result, ds); in crypto4xx_hash_update()
690 return crypto4xx_build_pd(&req->base, ctx, req->src, &dst, in crypto4xx_hash_update()
691 req->nbytes, NULL, 0, ctx->sa_in, in crypto4xx_hash_update()
695 int crypto4xx_hash_final(struct ahash_request *req) in crypto4xx_hash_final() argument
700 int crypto4xx_hash_digest(struct ahash_request *req) in crypto4xx_hash_digest() argument
702 struct crypto_ahash *ahash = crypto_ahash_reqtfm(req); in crypto4xx_hash_digest()
703 struct crypto4xx_ctx *ctx = crypto_tfm_ctx(req->base.tfm); in crypto4xx_hash_digest()
707 sg_init_one(&dst, req->result, ds); in crypto4xx_hash_digest()
709 return crypto4xx_build_pd(&req->base, ctx, req->src, &dst, in crypto4xx_hash_digest()
710 req->nbytes, NULL, 0, ctx->sa_in, in crypto4xx_hash_digest()