Lines Matching full:req
68 static inline u64 safexcel_queued_len(struct safexcel_ahash_req *req) in safexcel_queued_len() argument
70 return req->len - req->processed; in safexcel_queued_len()
107 struct safexcel_ahash_req *req, in safexcel_context_control() argument
121 if (unlikely(req->digest == CONTEXT_CONTROL_DIGEST_XCM)) { in safexcel_context_control()
122 if (req->xcbcmac) in safexcel_context_control()
125 memcpy(ctx->base.ctxr->data, req->state, req->state_sz); in safexcel_context_control()
127 if (!req->finish && req->xcbcmac) in safexcel_context_control()
132 CONTEXT_CONTROL_SIZE(req->state_sz / in safexcel_context_control()
138 CONTEXT_CONTROL_SIZE(req->state_sz / in safexcel_context_control()
141 } else if (!req->processed) { in safexcel_context_control()
143 if (req->finish) in safexcel_context_control()
144 cdesc->control_data.control0 |= req->digest | in safexcel_context_control()
150 cdesc->control_data.control0 |= req->digest | in safexcel_context_control()
160 memcpy(ctx->base.ctxr->data, req->state, req->state_sz); in safexcel_context_control()
162 if (req->finish) { in safexcel_context_control()
164 if ((req->digest == CONTEXT_CONTROL_DIGEST_PRECOMPUTED) || in safexcel_context_control()
165 req->hmac_zlen || (req->processed != req->block_sz)) { in safexcel_context_control()
166 count = req->processed / EIP197_COUNTER_BLOCK_SIZE; in safexcel_context_control()
180 if ((req->digest == CONTEXT_CONTROL_DIGEST_PRECOMPUTED) || in safexcel_context_control()
182 req->hmac_zlen || in safexcel_context_control()
184 (req->processed != req->block_sz)) { in safexcel_context_control()
187 CONTEXT_CONTROL_SIZE((req->state_sz >> 2) + 1) | in safexcel_context_control()
191 if (req->hmac_zlen) in safexcel_context_control()
196 ctx->base.ctxr->data[req->state_sz >> 2] = in safexcel_context_control()
198 req->digest = CONTEXT_CONTROL_DIGEST_PRECOMPUTED; in safexcel_context_control()
201 req->hmac_zlen = false; in safexcel_context_control()
204 memcpy(ctx->base.ctxr->data + (req->state_sz >> 2), in safexcel_context_control()
205 &ctx->base.opad, req->state_sz); in safexcel_context_control()
209 CONTEXT_CONTROL_SIZE(req->state_sz >> 1) | in safexcel_context_control()
215 CONTEXT_CONTROL_SIZE(req->state_sz >> 2) | in safexcel_context_control()
313 struct safexcel_ahash_req *req = ahash_request_ctx(areq); in safexcel_ahash_send_req() local
323 queued = safexcel_queued_len(req); in safexcel_ahash_send_req()
329 if (!req->finish && !req->last_req) { in safexcel_ahash_send_req()
342 req->cache_next, extra, in safexcel_ahash_send_req()
356 if (unlikely(req->xcbcmac && req->processed > AES_BLOCK_SIZE)) { in safexcel_ahash_send_req()
369 req->cache + cache_len, in safexcel_ahash_send_req()
373 memset(req->cache + cache_len + skip, 0, extra); in safexcel_ahash_send_req()
376 req->cache[cache_len + skip] = 0x80; in safexcel_ahash_send_req()
379 u32 *cache = (void *)req->cache; in safexcel_ahash_send_req()
392 crypto_xor(req->cache, (const u8 *)req->state, AES_BLOCK_SIZE); in safexcel_ahash_send_req()
398 req->cache_dma = dma_map_single(priv->dev, req->cache, in safexcel_ahash_send_req()
400 if (dma_mapping_error(priv->dev, req->cache_dma)) in safexcel_ahash_send_req()
403 req->cache_sz = cache_len; in safexcel_ahash_send_req()
406 req->cache_dma, cache_len, in safexcel_ahash_send_req()
421 req->nents = dma_map_sg(priv->dev, areq->src, in safexcel_ahash_send_req()
425 if (!req->nents) { in safexcel_ahash_send_req()
430 for_each_sg(areq->src, sg, req->nents, i) { in safexcel_ahash_send_req()
465 safexcel_context_control(ctx, req, first_cdesc); in safexcel_ahash_send_req()
468 safexcel_hash_token(first_cdesc, len, req->digest_sz, ctx->cbcmac); in safexcel_ahash_send_req()
470 req->result_dma = dma_map_single(priv->dev, req->state, req->digest_sz, in safexcel_ahash_send_req()
472 if (dma_mapping_error(priv->dev, req->result_dma)) { in safexcel_ahash_send_req()
478 rdesc = safexcel_add_rdesc(priv, ring, 1, 1, req->result_dma, in safexcel_ahash_send_req()
479 req->digest_sz); in safexcel_ahash_send_req()
487 req->processed += len - extra; in safexcel_ahash_send_req()
494 dma_unmap_single(priv->dev, req->result_dma, req->digest_sz, in safexcel_ahash_send_req()
497 if (req->nents) { in safexcel_ahash_send_req()
498 dma_unmap_sg(priv->dev, areq->src, req->nents, DMA_TO_DEVICE); in safexcel_ahash_send_req()
499 req->nents = 0; in safexcel_ahash_send_req()
505 if (req->cache_dma) { in safexcel_ahash_send_req()
506 dma_unmap_single(priv->dev, req->cache_dma, req->cache_sz, in safexcel_ahash_send_req()
508 req->cache_dma = 0; in safexcel_ahash_send_req()
509 req->cache_sz = 0; in safexcel_ahash_send_req()
570 struct safexcel_ahash_req *req = ahash_request_ctx(areq); in safexcel_handle_result() local
573 BUG_ON(!(priv->flags & EIP197_TRC_CACHE) && req->needs_inv); in safexcel_handle_result()
575 if (req->needs_inv) { in safexcel_handle_result()
576 req->needs_inv = false; in safexcel_handle_result()
609 struct safexcel_ahash_req *req = ahash_request_ctx(areq); in safexcel_ahash_send() local
612 if (req->needs_inv) in safexcel_ahash_send()
624 EIP197_REQUEST_ON_STACK(req, ahash, EIP197_AHASH_REQ_SIZE); in safexcel_ahash_exit_inv()
625 struct safexcel_ahash_req *rctx = ahash_request_ctx(req); in safexcel_ahash_exit_inv()
629 memset(req, 0, EIP197_AHASH_REQ_SIZE); in safexcel_ahash_exit_inv()
633 ahash_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG, in safexcel_ahash_exit_inv()
636 ahash_request_set_tfm(req, __crypto_ahash_cast(tfm)); in safexcel_ahash_exit_inv()
637 ctx = crypto_tfm_ctx(req->base.tfm); in safexcel_ahash_exit_inv()
642 crypto_enqueue_request(&priv->ring[ring].queue, &req->base); in safexcel_ahash_exit_inv()
664 struct safexcel_ahash_req *req = ahash_request_ctx(areq); in safexcel_ahash_cache() local
668 * tot sz handled by update() - last req sz - tot sz handled by send() in safexcel_ahash_cache()
670 cache_len = safexcel_queued_len(req); in safexcel_ahash_cache()
678 req->cache + cache_len, in safexcel_ahash_cache()
690 struct safexcel_ahash_req *req = ahash_request_ctx(areq); in safexcel_ahash_enqueue() local
694 req->needs_inv = false; in safexcel_ahash_enqueue()
699 ((req->not_first && !req->xcbcmac) || in safexcel_ahash_enqueue()
701 memcmp(ctx->base.ctxr->data, req->state, req->state_sz) || in safexcel_ahash_enqueue()
703 (req->finish && req->hmac && in safexcel_ahash_enqueue()
704 memcmp(ctx->base.ctxr->data + (req->state_sz>>2), in safexcel_ahash_enqueue()
705 &ctx->base.opad, req->state_sz)))) in safexcel_ahash_enqueue()
716 req->needs_inv = true; in safexcel_ahash_enqueue()
726 req->not_first = true; in safexcel_ahash_enqueue()
742 struct safexcel_ahash_req *req = ahash_request_ctx(areq); in safexcel_ahash_update() local
753 req->len += areq->nbytes; in safexcel_ahash_update()
759 if ((ret && !req->finish) || req->last_req) in safexcel_ahash_update()
767 struct safexcel_ahash_req *req = ahash_request_ctx(areq); in safexcel_ahash_final() local
770 req->finish = true; in safexcel_ahash_final()
772 if (unlikely(!req->len && !areq->nbytes)) { in safexcel_ahash_final()
802 } else if (unlikely(req->digest == CONTEXT_CONTROL_DIGEST_XCM && in safexcel_ahash_final()
804 req->len == sizeof(u32) && !areq->nbytes)) { in safexcel_ahash_final()
808 } else if (unlikely(ctx->cbcmac && req->len == AES_BLOCK_SIZE && in safexcel_ahash_final()
813 } else if (unlikely(req->xcbcmac && req->len == AES_BLOCK_SIZE && in safexcel_ahash_final()
827 } else if (unlikely(req->hmac && in safexcel_ahash_final()
828 (req->len == req->block_sz) && in safexcel_ahash_final()
838 memset(req->cache, 0, req->block_sz); in safexcel_ahash_final()
840 req->cache[0] = 0x80; in safexcel_ahash_final()
842 if (req->len_is_le) { in safexcel_ahash_final()
844 req->cache[req->block_sz-8] = (req->block_sz << 3) & in safexcel_ahash_final()
846 req->cache[req->block_sz-7] = (req->block_sz >> 5); in safexcel_ahash_final()
849 req->cache[req->block_sz-2] = (req->block_sz >> 5); in safexcel_ahash_final()
850 req->cache[req->block_sz-1] = (req->block_sz << 3) & in safexcel_ahash_final()
854 req->len += req->block_sz; /* plus 1 hash block */ in safexcel_ahash_final()
857 req->hmac_zlen = true; in safexcel_ahash_final()
860 req->digest = CONTEXT_CONTROL_DIGEST_HMAC; in safexcel_ahash_final()
861 } else if (req->hmac) { in safexcel_ahash_final()
863 req->digest = CONTEXT_CONTROL_DIGEST_HMAC; in safexcel_ahash_final()
871 struct safexcel_ahash_req *req = ahash_request_ctx(areq); in safexcel_ahash_finup() local
873 req->finish = true; in safexcel_ahash_finup()
881 struct safexcel_ahash_req *req = ahash_request_ctx(areq); in safexcel_ahash_export() local
884 export->len = req->len; in safexcel_ahash_export()
885 export->processed = req->processed; in safexcel_ahash_export()
887 export->digest = req->digest; in safexcel_ahash_export()
889 memcpy(export->state, req->state, req->state_sz); in safexcel_ahash_export()
890 memcpy(export->cache, req->cache, HASH_CACHE_SIZE); in safexcel_ahash_export()
897 struct safexcel_ahash_req *req = ahash_request_ctx(areq); in safexcel_ahash_import() local
905 req->len = export->len; in safexcel_ahash_import()
906 req->processed = export->processed; in safexcel_ahash_import()
908 req->digest = export->digest; in safexcel_ahash_import()
910 memcpy(req->cache, export->cache, HASH_CACHE_SIZE); in safexcel_ahash_import()
911 memcpy(req->state, export->state, req->state_sz); in safexcel_ahash_import()
936 struct safexcel_ahash_req *req = ahash_request_ctx(areq); in safexcel_sha1_init() local
938 memset(req, 0, sizeof(*req)); in safexcel_sha1_init()
941 req->digest = CONTEXT_CONTROL_DIGEST_PRECOMPUTED; in safexcel_sha1_init()
942 req->state_sz = SHA1_DIGEST_SIZE; in safexcel_sha1_init()
943 req->digest_sz = SHA1_DIGEST_SIZE; in safexcel_sha1_init()
944 req->block_sz = SHA1_BLOCK_SIZE; in safexcel_sha1_init()
1013 struct safexcel_ahash_req *req = ahash_request_ctx(areq); in safexcel_hmac_sha1_init() local
1015 memset(req, 0, sizeof(*req)); in safexcel_hmac_sha1_init()
1018 memcpy(req->state, &ctx->base.ipad, SHA1_DIGEST_SIZE); in safexcel_hmac_sha1_init()
1020 req->len = SHA1_BLOCK_SIZE; in safexcel_hmac_sha1_init()
1021 req->processed = SHA1_BLOCK_SIZE; in safexcel_hmac_sha1_init()
1024 req->digest = CONTEXT_CONTROL_DIGEST_PRECOMPUTED; in safexcel_hmac_sha1_init()
1025 req->state_sz = SHA1_DIGEST_SIZE; in safexcel_hmac_sha1_init()
1026 req->digest_sz = SHA1_DIGEST_SIZE; in safexcel_hmac_sha1_init()
1027 req->block_sz = SHA1_BLOCK_SIZE; in safexcel_hmac_sha1_init()
1028 req->hmac = true; in safexcel_hmac_sha1_init()
1048 static void safexcel_ahash_complete(struct crypto_async_request *req, int error) in safexcel_ahash_complete() argument
1050 struct safexcel_ahash_result *result = req->data; in safexcel_ahash_complete()
1111 struct safexcel_ahash_req *req; in safexcel_hmac_init_iv() local
1125 req = ahash_request_ctx(areq); in safexcel_hmac_init_iv()
1126 req->hmac = true; in safexcel_hmac_init_iv()
1127 req->last_req = true; in safexcel_hmac_init_iv()
1265 struct safexcel_ahash_req *req = ahash_request_ctx(areq); in safexcel_sha256_init() local
1267 memset(req, 0, sizeof(*req)); in safexcel_sha256_init()
1270 req->digest = CONTEXT_CONTROL_DIGEST_PRECOMPUTED; in safexcel_sha256_init()
1271 req->state_sz = SHA256_DIGEST_SIZE; in safexcel_sha256_init()
1272 req->digest_sz = SHA256_DIGEST_SIZE; in safexcel_sha256_init()
1273 req->block_sz = SHA256_BLOCK_SIZE; in safexcel_sha256_init()
1322 struct safexcel_ahash_req *req = ahash_request_ctx(areq); in safexcel_sha224_init() local
1324 memset(req, 0, sizeof(*req)); in safexcel_sha224_init()
1327 req->digest = CONTEXT_CONTROL_DIGEST_PRECOMPUTED; in safexcel_sha224_init()
1328 req->state_sz = SHA256_DIGEST_SIZE; in safexcel_sha224_init()
1329 req->digest_sz = SHA256_DIGEST_SIZE; in safexcel_sha224_init()
1330 req->block_sz = SHA256_BLOCK_SIZE; in safexcel_sha224_init()
1386 struct safexcel_ahash_req *req = ahash_request_ctx(areq); in safexcel_hmac_sha224_init() local
1388 memset(req, 0, sizeof(*req)); in safexcel_hmac_sha224_init()
1391 memcpy(req->state, &ctx->base.ipad, SHA256_DIGEST_SIZE); in safexcel_hmac_sha224_init()
1393 req->len = SHA256_BLOCK_SIZE; in safexcel_hmac_sha224_init()
1394 req->processed = SHA256_BLOCK_SIZE; in safexcel_hmac_sha224_init()
1397 req->digest = CONTEXT_CONTROL_DIGEST_PRECOMPUTED; in safexcel_hmac_sha224_init()
1398 req->state_sz = SHA256_DIGEST_SIZE; in safexcel_hmac_sha224_init()
1399 req->digest_sz = SHA256_DIGEST_SIZE; in safexcel_hmac_sha224_init()
1400 req->block_sz = SHA256_BLOCK_SIZE; in safexcel_hmac_sha224_init()
1401 req->hmac = true; in safexcel_hmac_sha224_init()
1458 struct safexcel_ahash_req *req = ahash_request_ctx(areq); in safexcel_hmac_sha256_init() local
1460 memset(req, 0, sizeof(*req)); in safexcel_hmac_sha256_init()
1463 memcpy(req->state, &ctx->base.ipad, SHA256_DIGEST_SIZE); in safexcel_hmac_sha256_init()
1465 req->len = SHA256_BLOCK_SIZE; in safexcel_hmac_sha256_init()
1466 req->processed = SHA256_BLOCK_SIZE; in safexcel_hmac_sha256_init()
1469 req->digest = CONTEXT_CONTROL_DIGEST_PRECOMPUTED; in safexcel_hmac_sha256_init()
1470 req->state_sz = SHA256_DIGEST_SIZE; in safexcel_hmac_sha256_init()
1471 req->digest_sz = SHA256_DIGEST_SIZE; in safexcel_hmac_sha256_init()
1472 req->block_sz = SHA256_BLOCK_SIZE; in safexcel_hmac_sha256_init()
1473 req->hmac = true; in safexcel_hmac_sha256_init()
1523 struct safexcel_ahash_req *req = ahash_request_ctx(areq); in safexcel_sha512_init() local
1525 memset(req, 0, sizeof(*req)); in safexcel_sha512_init()
1528 req->digest = CONTEXT_CONTROL_DIGEST_PRECOMPUTED; in safexcel_sha512_init()
1529 req->state_sz = SHA512_DIGEST_SIZE; in safexcel_sha512_init()
1530 req->digest_sz = SHA512_DIGEST_SIZE; in safexcel_sha512_init()
1531 req->block_sz = SHA512_BLOCK_SIZE; in safexcel_sha512_init()
1580 struct safexcel_ahash_req *req = ahash_request_ctx(areq); in safexcel_sha384_init() local
1582 memset(req, 0, sizeof(*req)); in safexcel_sha384_init()
1585 req->digest = CONTEXT_CONTROL_DIGEST_PRECOMPUTED; in safexcel_sha384_init()
1586 req->state_sz = SHA512_DIGEST_SIZE; in safexcel_sha384_init()
1587 req->digest_sz = SHA512_DIGEST_SIZE; in safexcel_sha384_init()
1588 req->block_sz = SHA512_BLOCK_SIZE; in safexcel_sha384_init()
1644 struct safexcel_ahash_req *req = ahash_request_ctx(areq); in safexcel_hmac_sha512_init() local
1646 memset(req, 0, sizeof(*req)); in safexcel_hmac_sha512_init()
1649 memcpy(req->state, &ctx->base.ipad, SHA512_DIGEST_SIZE); in safexcel_hmac_sha512_init()
1651 req->len = SHA512_BLOCK_SIZE; in safexcel_hmac_sha512_init()
1652 req->processed = SHA512_BLOCK_SIZE; in safexcel_hmac_sha512_init()
1655 req->digest = CONTEXT_CONTROL_DIGEST_PRECOMPUTED; in safexcel_hmac_sha512_init()
1656 req->state_sz = SHA512_DIGEST_SIZE; in safexcel_hmac_sha512_init()
1657 req->digest_sz = SHA512_DIGEST_SIZE; in safexcel_hmac_sha512_init()
1658 req->block_sz = SHA512_BLOCK_SIZE; in safexcel_hmac_sha512_init()
1659 req->hmac = true; in safexcel_hmac_sha512_init()
1716 struct safexcel_ahash_req *req = ahash_request_ctx(areq); in safexcel_hmac_sha384_init() local
1718 memset(req, 0, sizeof(*req)); in safexcel_hmac_sha384_init()
1721 memcpy(req->state, &ctx->base.ipad, SHA512_DIGEST_SIZE); in safexcel_hmac_sha384_init()
1723 req->len = SHA512_BLOCK_SIZE; in safexcel_hmac_sha384_init()
1724 req->processed = SHA512_BLOCK_SIZE; in safexcel_hmac_sha384_init()
1727 req->digest = CONTEXT_CONTROL_DIGEST_PRECOMPUTED; in safexcel_hmac_sha384_init()
1728 req->state_sz = SHA512_DIGEST_SIZE; in safexcel_hmac_sha384_init()
1729 req->digest_sz = SHA512_DIGEST_SIZE; in safexcel_hmac_sha384_init()
1730 req->block_sz = SHA512_BLOCK_SIZE; in safexcel_hmac_sha384_init()
1731 req->hmac = true; in safexcel_hmac_sha384_init()
1781 struct safexcel_ahash_req *req = ahash_request_ctx(areq); in safexcel_md5_init() local
1783 memset(req, 0, sizeof(*req)); in safexcel_md5_init()
1786 req->digest = CONTEXT_CONTROL_DIGEST_PRECOMPUTED; in safexcel_md5_init()
1787 req->state_sz = MD5_DIGEST_SIZE; in safexcel_md5_init()
1788 req->digest_sz = MD5_DIGEST_SIZE; in safexcel_md5_init()
1789 req->block_sz = MD5_HMAC_BLOCK_SIZE; in safexcel_md5_init()
1838 struct safexcel_ahash_req *req = ahash_request_ctx(areq); in safexcel_hmac_md5_init() local
1840 memset(req, 0, sizeof(*req)); in safexcel_hmac_md5_init()
1843 memcpy(req->state, &ctx->base.ipad, MD5_DIGEST_SIZE); in safexcel_hmac_md5_init()
1845 req->len = MD5_HMAC_BLOCK_SIZE; in safexcel_hmac_md5_init()
1846 req->processed = MD5_HMAC_BLOCK_SIZE; in safexcel_hmac_md5_init()
1849 req->digest = CONTEXT_CONTROL_DIGEST_PRECOMPUTED; in safexcel_hmac_md5_init()
1850 req->state_sz = MD5_DIGEST_SIZE; in safexcel_hmac_md5_init()
1851 req->digest_sz = MD5_DIGEST_SIZE; in safexcel_hmac_md5_init()
1852 req->block_sz = MD5_HMAC_BLOCK_SIZE; in safexcel_hmac_md5_init()
1853 req->len_is_le = true; /* MD5 is little endian! ... */ in safexcel_hmac_md5_init()
1854 req->hmac = true; in safexcel_hmac_md5_init()
1921 struct safexcel_ahash_req *req = ahash_request_ctx(areq); in safexcel_crc32_init() local
1923 memset(req, 0, sizeof(*req)); in safexcel_crc32_init()
1926 req->state[0] = cpu_to_le32(~ctx->base.ipad.word[0]); in safexcel_crc32_init()
1928 req->len = sizeof(u32); in safexcel_crc32_init()
1929 req->processed = sizeof(u32); in safexcel_crc32_init()
1932 req->digest = CONTEXT_CONTROL_DIGEST_XCM; in safexcel_crc32_init()
1933 req->state_sz = sizeof(u32); in safexcel_crc32_init()
1934 req->digest_sz = sizeof(u32); in safexcel_crc32_init()
1935 req->block_sz = sizeof(u32); in safexcel_crc32_init()
1993 struct safexcel_ahash_req *req = ahash_request_ctx(areq); in safexcel_cbcmac_init() local
1995 memset(req, 0, sizeof(*req)); in safexcel_cbcmac_init()
1998 memcpy(req->state, &ctx->base.ipad, ctx->key_sz); in safexcel_cbcmac_init()
2000 req->len = AES_BLOCK_SIZE; in safexcel_cbcmac_init()
2001 req->processed = AES_BLOCK_SIZE; in safexcel_cbcmac_init()
2003 req->digest = CONTEXT_CONTROL_DIGEST_XCM; in safexcel_cbcmac_init()
2004 req->state_sz = ctx->key_sz; in safexcel_cbcmac_init()
2005 req->digest_sz = AES_BLOCK_SIZE; in safexcel_cbcmac_init()
2006 req->block_sz = AES_BLOCK_SIZE; in safexcel_cbcmac_init()
2007 req->xcbcmac = true; in safexcel_cbcmac_init()
2274 struct safexcel_ahash_req *req = ahash_request_ctx(areq); in safexcel_sm3_init() local
2276 memset(req, 0, sizeof(*req)); in safexcel_sm3_init()
2279 req->digest = CONTEXT_CONTROL_DIGEST_PRECOMPUTED; in safexcel_sm3_init()
2280 req->state_sz = SM3_DIGEST_SIZE; in safexcel_sm3_init()
2281 req->digest_sz = SM3_DIGEST_SIZE; in safexcel_sm3_init()
2282 req->block_sz = SM3_BLOCK_SIZE; in safexcel_sm3_init()
2338 struct safexcel_ahash_req *req = ahash_request_ctx(areq); in safexcel_hmac_sm3_init() local
2340 memset(req, 0, sizeof(*req)); in safexcel_hmac_sm3_init()
2343 memcpy(req->state, &ctx->base.ipad, SM3_DIGEST_SIZE); in safexcel_hmac_sm3_init()
2345 req->len = SM3_BLOCK_SIZE; in safexcel_hmac_sm3_init()
2346 req->processed = SM3_BLOCK_SIZE; in safexcel_hmac_sm3_init()
2349 req->digest = CONTEXT_CONTROL_DIGEST_PRECOMPUTED; in safexcel_hmac_sm3_init()
2350 req->state_sz = SM3_DIGEST_SIZE; in safexcel_hmac_sm3_init()
2351 req->digest_sz = SM3_DIGEST_SIZE; in safexcel_hmac_sm3_init()
2352 req->block_sz = SM3_BLOCK_SIZE; in safexcel_hmac_sm3_init()
2353 req->hmac = true; in safexcel_hmac_sm3_init()
2404 struct safexcel_ahash_req *req = ahash_request_ctx(areq); in safexcel_sha3_224_init() local
2406 memset(req, 0, sizeof(*req)); in safexcel_sha3_224_init()
2409 req->digest = CONTEXT_CONTROL_DIGEST_INITIAL; in safexcel_sha3_224_init()
2410 req->state_sz = SHA3_224_DIGEST_SIZE; in safexcel_sha3_224_init()
2411 req->digest_sz = SHA3_224_DIGEST_SIZE; in safexcel_sha3_224_init()
2412 req->block_sz = SHA3_224_BLOCK_SIZE; in safexcel_sha3_224_init()
2418 static int safexcel_sha3_fbcheck(struct ahash_request *req) in safexcel_sha3_fbcheck() argument
2420 struct crypto_ahash *tfm = crypto_ahash_reqtfm(req); in safexcel_sha3_fbcheck()
2422 struct ahash_request *subreq = ahash_request_ctx(req); in safexcel_sha3_fbcheck()
2427 ahash_request_set_callback(subreq, req->base.flags, in safexcel_sha3_fbcheck()
2428 req->base.complete, req->base.data); in safexcel_sha3_fbcheck()
2429 ahash_request_set_crypt(subreq, req->src, req->result, in safexcel_sha3_fbcheck()
2430 req->nbytes); in safexcel_sha3_fbcheck()
2455 static int safexcel_sha3_update(struct ahash_request *req) in safexcel_sha3_update() argument
2457 struct crypto_ahash *tfm = crypto_ahash_reqtfm(req); in safexcel_sha3_update()
2459 struct ahash_request *subreq = ahash_request_ctx(req); in safexcel_sha3_update()
2462 return safexcel_sha3_fbcheck(req) ?: crypto_ahash_update(subreq); in safexcel_sha3_update()
2465 static int safexcel_sha3_final(struct ahash_request *req) in safexcel_sha3_final() argument
2467 struct crypto_ahash *tfm = crypto_ahash_reqtfm(req); in safexcel_sha3_final()
2469 struct ahash_request *subreq = ahash_request_ctx(req); in safexcel_sha3_final()
2472 return safexcel_sha3_fbcheck(req) ?: crypto_ahash_final(subreq); in safexcel_sha3_final()
2475 static int safexcel_sha3_finup(struct ahash_request *req) in safexcel_sha3_finup() argument
2477 struct crypto_ahash *tfm = crypto_ahash_reqtfm(req); in safexcel_sha3_finup()
2479 struct ahash_request *subreq = ahash_request_ctx(req); in safexcel_sha3_finup()
2481 ctx->do_fallback |= !req->nbytes; in safexcel_sha3_finup()
2484 return safexcel_sha3_fbcheck(req) ?: in safexcel_sha3_finup()
2487 return safexcel_ahash_finup(req); in safexcel_sha3_finup()
2490 static int safexcel_sha3_digest_fallback(struct ahash_request *req) in safexcel_sha3_digest_fallback() argument
2492 struct crypto_ahash *tfm = crypto_ahash_reqtfm(req); in safexcel_sha3_digest_fallback()
2494 struct ahash_request *subreq = ahash_request_ctx(req); in safexcel_sha3_digest_fallback()
2498 return safexcel_sha3_fbcheck(req) ?: crypto_ahash_finup(subreq); in safexcel_sha3_digest_fallback()
2501 static int safexcel_sha3_224_digest(struct ahash_request *req) in safexcel_sha3_224_digest() argument
2503 if (req->nbytes) in safexcel_sha3_224_digest()
2504 return safexcel_sha3_224_init(req) ?: safexcel_ahash_finup(req); in safexcel_sha3_224_digest()
2507 return safexcel_sha3_digest_fallback(req); in safexcel_sha3_224_digest()
2510 static int safexcel_sha3_export(struct ahash_request *req, void *out) in safexcel_sha3_export() argument
2512 struct crypto_ahash *tfm = crypto_ahash_reqtfm(req); in safexcel_sha3_export()
2514 struct ahash_request *subreq = ahash_request_ctx(req); in safexcel_sha3_export()
2517 return safexcel_sha3_fbcheck(req) ?: crypto_ahash_export(subreq, out); in safexcel_sha3_export()
2520 static int safexcel_sha3_import(struct ahash_request *req, const void *in) in safexcel_sha3_import() argument
2522 struct crypto_ahash *tfm = crypto_ahash_reqtfm(req); in safexcel_sha3_import()
2524 struct ahash_request *subreq = ahash_request_ctx(req); in safexcel_sha3_import()
2527 return safexcel_sha3_fbcheck(req) ?: crypto_ahash_import(subreq, in); in safexcel_sha3_import()
2528 // return safexcel_ahash_import(req, in); in safexcel_sha3_import()
2597 struct safexcel_ahash_req *req = ahash_request_ctx(areq); in safexcel_sha3_256_init() local
2599 memset(req, 0, sizeof(*req)); in safexcel_sha3_256_init()
2602 req->digest = CONTEXT_CONTROL_DIGEST_INITIAL; in safexcel_sha3_256_init()
2603 req->state_sz = SHA3_256_DIGEST_SIZE; in safexcel_sha3_256_init()
2604 req->digest_sz = SHA3_256_DIGEST_SIZE; in safexcel_sha3_256_init()
2605 req->block_sz = SHA3_256_BLOCK_SIZE; in safexcel_sha3_256_init()
2611 static int safexcel_sha3_256_digest(struct ahash_request *req) in safexcel_sha3_256_digest() argument
2613 if (req->nbytes) in safexcel_sha3_256_digest()
2614 return safexcel_sha3_256_init(req) ?: safexcel_ahash_finup(req); in safexcel_sha3_256_digest()
2617 return safexcel_sha3_digest_fallback(req); in safexcel_sha3_256_digest()
2655 struct safexcel_ahash_req *req = ahash_request_ctx(areq); in safexcel_sha3_384_init() local
2657 memset(req, 0, sizeof(*req)); in safexcel_sha3_384_init()
2660 req->digest = CONTEXT_CONTROL_DIGEST_INITIAL; in safexcel_sha3_384_init()
2661 req->state_sz = SHA3_384_DIGEST_SIZE; in safexcel_sha3_384_init()
2662 req->digest_sz = SHA3_384_DIGEST_SIZE; in safexcel_sha3_384_init()
2663 req->block_sz = SHA3_384_BLOCK_SIZE; in safexcel_sha3_384_init()
2669 static int safexcel_sha3_384_digest(struct ahash_request *req) in safexcel_sha3_384_digest() argument
2671 if (req->nbytes) in safexcel_sha3_384_digest()
2672 return safexcel_sha3_384_init(req) ?: safexcel_ahash_finup(req); in safexcel_sha3_384_digest()
2675 return safexcel_sha3_digest_fallback(req); in safexcel_sha3_384_digest()
2713 struct safexcel_ahash_req *req = ahash_request_ctx(areq); in safexcel_sha3_512_init() local
2715 memset(req, 0, sizeof(*req)); in safexcel_sha3_512_init()
2718 req->digest = CONTEXT_CONTROL_DIGEST_INITIAL; in safexcel_sha3_512_init()
2719 req->state_sz = SHA3_512_DIGEST_SIZE; in safexcel_sha3_512_init()
2720 req->digest_sz = SHA3_512_DIGEST_SIZE; in safexcel_sha3_512_init()
2721 req->block_sz = SHA3_512_BLOCK_SIZE; in safexcel_sha3_512_init()
2727 static int safexcel_sha3_512_digest(struct ahash_request *req) in safexcel_sha3_512_digest() argument
2729 if (req->nbytes) in safexcel_sha3_512_digest()
2730 return safexcel_sha3_512_init(req) ?: safexcel_ahash_finup(req); in safexcel_sha3_512_digest()
2733 return safexcel_sha3_digest_fallback(req); in safexcel_sha3_512_digest()
2863 struct safexcel_ahash_req *req = ahash_request_ctx(areq); in safexcel_hmac_sha3_224_init() local
2865 memset(req, 0, sizeof(*req)); in safexcel_hmac_sha3_224_init()
2868 memcpy(req->state, &ctx->base.ipad, SHA3_224_BLOCK_SIZE / 2); in safexcel_hmac_sha3_224_init()
2870 req->len = SHA3_224_BLOCK_SIZE; in safexcel_hmac_sha3_224_init()
2871 req->processed = SHA3_224_BLOCK_SIZE; in safexcel_hmac_sha3_224_init()
2873 req->digest = CONTEXT_CONTROL_DIGEST_HMAC; in safexcel_hmac_sha3_224_init()
2874 req->state_sz = SHA3_224_BLOCK_SIZE / 2; in safexcel_hmac_sha3_224_init()
2875 req->digest_sz = SHA3_224_DIGEST_SIZE; in safexcel_hmac_sha3_224_init()
2876 req->block_sz = SHA3_224_BLOCK_SIZE; in safexcel_hmac_sha3_224_init()
2877 req->hmac = true; in safexcel_hmac_sha3_224_init()
2883 static int safexcel_hmac_sha3_224_digest(struct ahash_request *req) in safexcel_hmac_sha3_224_digest() argument
2885 if (req->nbytes) in safexcel_hmac_sha3_224_digest()
2886 return safexcel_hmac_sha3_224_init(req) ?: in safexcel_hmac_sha3_224_digest()
2887 safexcel_ahash_finup(req); in safexcel_hmac_sha3_224_digest()
2890 return safexcel_sha3_digest_fallback(req); in safexcel_hmac_sha3_224_digest()
2934 struct safexcel_ahash_req *req = ahash_request_ctx(areq); in safexcel_hmac_sha3_256_init() local
2936 memset(req, 0, sizeof(*req)); in safexcel_hmac_sha3_256_init()
2939 memcpy(req->state, &ctx->base.ipad, SHA3_256_BLOCK_SIZE / 2); in safexcel_hmac_sha3_256_init()
2941 req->len = SHA3_256_BLOCK_SIZE; in safexcel_hmac_sha3_256_init()
2942 req->processed = SHA3_256_BLOCK_SIZE; in safexcel_hmac_sha3_256_init()
2944 req->digest = CONTEXT_CONTROL_DIGEST_HMAC; in safexcel_hmac_sha3_256_init()
2945 req->state_sz = SHA3_256_BLOCK_SIZE / 2; in safexcel_hmac_sha3_256_init()
2946 req->digest_sz = SHA3_256_DIGEST_SIZE; in safexcel_hmac_sha3_256_init()
2947 req->block_sz = SHA3_256_BLOCK_SIZE; in safexcel_hmac_sha3_256_init()
2948 req->hmac = true; in safexcel_hmac_sha3_256_init()
2954 static int safexcel_hmac_sha3_256_digest(struct ahash_request *req) in safexcel_hmac_sha3_256_digest() argument
2956 if (req->nbytes) in safexcel_hmac_sha3_256_digest()
2957 return safexcel_hmac_sha3_256_init(req) ?: in safexcel_hmac_sha3_256_digest()
2958 safexcel_ahash_finup(req); in safexcel_hmac_sha3_256_digest()
2961 return safexcel_sha3_digest_fallback(req); in safexcel_hmac_sha3_256_digest()
3005 struct safexcel_ahash_req *req = ahash_request_ctx(areq); in safexcel_hmac_sha3_384_init() local
3007 memset(req, 0, sizeof(*req)); in safexcel_hmac_sha3_384_init()
3010 memcpy(req->state, &ctx->base.ipad, SHA3_384_BLOCK_SIZE / 2); in safexcel_hmac_sha3_384_init()
3012 req->len = SHA3_384_BLOCK_SIZE; in safexcel_hmac_sha3_384_init()
3013 req->processed = SHA3_384_BLOCK_SIZE; in safexcel_hmac_sha3_384_init()
3015 req->digest = CONTEXT_CONTROL_DIGEST_HMAC; in safexcel_hmac_sha3_384_init()
3016 req->state_sz = SHA3_384_BLOCK_SIZE / 2; in safexcel_hmac_sha3_384_init()
3017 req->digest_sz = SHA3_384_DIGEST_SIZE; in safexcel_hmac_sha3_384_init()
3018 req->block_sz = SHA3_384_BLOCK_SIZE; in safexcel_hmac_sha3_384_init()
3019 req->hmac = true; in safexcel_hmac_sha3_384_init()
3025 static int safexcel_hmac_sha3_384_digest(struct ahash_request *req) in safexcel_hmac_sha3_384_digest() argument
3027 if (req->nbytes) in safexcel_hmac_sha3_384_digest()
3028 return safexcel_hmac_sha3_384_init(req) ?: in safexcel_hmac_sha3_384_digest()
3029 safexcel_ahash_finup(req); in safexcel_hmac_sha3_384_digest()
3032 return safexcel_sha3_digest_fallback(req); in safexcel_hmac_sha3_384_digest()
3076 struct safexcel_ahash_req *req = ahash_request_ctx(areq); in safexcel_hmac_sha3_512_init() local
3078 memset(req, 0, sizeof(*req)); in safexcel_hmac_sha3_512_init()
3081 memcpy(req->state, &ctx->base.ipad, SHA3_512_BLOCK_SIZE / 2); in safexcel_hmac_sha3_512_init()
3083 req->len = SHA3_512_BLOCK_SIZE; in safexcel_hmac_sha3_512_init()
3084 req->processed = SHA3_512_BLOCK_SIZE; in safexcel_hmac_sha3_512_init()
3086 req->digest = CONTEXT_CONTROL_DIGEST_HMAC; in safexcel_hmac_sha3_512_init()
3087 req->state_sz = SHA3_512_BLOCK_SIZE / 2; in safexcel_hmac_sha3_512_init()
3088 req->digest_sz = SHA3_512_DIGEST_SIZE; in safexcel_hmac_sha3_512_init()
3089 req->block_sz = SHA3_512_BLOCK_SIZE; in safexcel_hmac_sha3_512_init()
3090 req->hmac = true; in safexcel_hmac_sha3_512_init()
3096 static int safexcel_hmac_sha3_512_digest(struct ahash_request *req) in safexcel_hmac_sha3_512_digest() argument
3098 if (req->nbytes) in safexcel_hmac_sha3_512_digest()
3099 return safexcel_hmac_sha3_512_init(req) ?: in safexcel_hmac_sha3_512_digest()
3100 safexcel_ahash_finup(req); in safexcel_hmac_sha3_512_digest()
3103 return safexcel_sha3_digest_fallback(req); in safexcel_hmac_sha3_512_digest()