Lines Matching refs:req
70 static inline u64 safexcel_queued_len(struct safexcel_ahash_req *req) in safexcel_queued_len() argument
72 return req->len - req->processed; in safexcel_queued_len()
109 struct safexcel_ahash_req *req, in safexcel_context_control() argument
123 if (unlikely(req->digest == CONTEXT_CONTROL_DIGEST_XCM)) { in safexcel_context_control()
124 if (req->xcbcmac) in safexcel_context_control()
127 memcpy(ctx->base.ctxr->data, req->state, req->state_sz); in safexcel_context_control()
129 if (!req->finish && req->xcbcmac) in safexcel_context_control()
134 CONTEXT_CONTROL_SIZE(req->state_sz / in safexcel_context_control()
140 CONTEXT_CONTROL_SIZE(req->state_sz / in safexcel_context_control()
143 } else if (!req->processed) { in safexcel_context_control()
145 if (req->finish) in safexcel_context_control()
146 cdesc->control_data.control0 |= req->digest | in safexcel_context_control()
152 cdesc->control_data.control0 |= req->digest | in safexcel_context_control()
162 memcpy(ctx->base.ctxr->data, req->state, req->state_sz); in safexcel_context_control()
164 if (req->finish) { in safexcel_context_control()
166 if ((req->digest == CONTEXT_CONTROL_DIGEST_PRECOMPUTED) || in safexcel_context_control()
167 req->hmac_zlen || (req->processed != req->block_sz)) { in safexcel_context_control()
168 count = req->processed / EIP197_COUNTER_BLOCK_SIZE; in safexcel_context_control()
182 if ((req->digest == CONTEXT_CONTROL_DIGEST_PRECOMPUTED) || in safexcel_context_control()
184 req->hmac_zlen || in safexcel_context_control()
186 (req->processed != req->block_sz)) { in safexcel_context_control()
189 CONTEXT_CONTROL_SIZE((req->state_sz >> 2) + 1) | in safexcel_context_control()
193 if (req->hmac_zlen) in safexcel_context_control()
198 ctx->base.ctxr->data[req->state_sz >> 2] = in safexcel_context_control()
200 req->digest = CONTEXT_CONTROL_DIGEST_PRECOMPUTED; in safexcel_context_control()
203 req->hmac_zlen = false; in safexcel_context_control()
206 memcpy(ctx->base.ctxr->data + (req->state_sz >> 2), in safexcel_context_control()
207 &ctx->base.opad, req->state_sz); in safexcel_context_control()
211 CONTEXT_CONTROL_SIZE(req->state_sz >> 1) | in safexcel_context_control()
217 CONTEXT_CONTROL_SIZE(req->state_sz >> 2) | in safexcel_context_control()
315 struct safexcel_ahash_req *req = ahash_request_ctx(areq); in safexcel_ahash_send_req() local
325 queued = safexcel_queued_len(req); in safexcel_ahash_send_req()
331 if (!req->finish && !req->last_req) { in safexcel_ahash_send_req()
344 req->cache_next, extra, in safexcel_ahash_send_req()
358 if (unlikely(req->xcbcmac && req->processed > AES_BLOCK_SIZE)) { in safexcel_ahash_send_req()
371 req->cache + cache_len, in safexcel_ahash_send_req()
375 memset(req->cache + cache_len + skip, 0, extra); in safexcel_ahash_send_req()
378 req->cache[cache_len + skip] = 0x80; in safexcel_ahash_send_req()
381 u32 *cache = (void *)req->cache; in safexcel_ahash_send_req()
394 crypto_xor(req->cache, (const u8 *)req->state, AES_BLOCK_SIZE); in safexcel_ahash_send_req()
400 req->cache_dma = dma_map_single(priv->dev, req->cache, in safexcel_ahash_send_req()
402 if (dma_mapping_error(priv->dev, req->cache_dma)) in safexcel_ahash_send_req()
405 req->cache_sz = cache_len; in safexcel_ahash_send_req()
408 req->cache_dma, cache_len, in safexcel_ahash_send_req()
423 req->nents = dma_map_sg(priv->dev, areq->src, in safexcel_ahash_send_req()
427 if (!req->nents) { in safexcel_ahash_send_req()
432 for_each_sg(areq->src, sg, req->nents, i) { in safexcel_ahash_send_req()
467 safexcel_context_control(ctx, req, first_cdesc); in safexcel_ahash_send_req()
470 safexcel_hash_token(first_cdesc, len, req->digest_sz, ctx->cbcmac); in safexcel_ahash_send_req()
472 req->result_dma = dma_map_single(priv->dev, req->state, req->digest_sz, in safexcel_ahash_send_req()
474 if (dma_mapping_error(priv->dev, req->result_dma)) { in safexcel_ahash_send_req()
480 rdesc = safexcel_add_rdesc(priv, ring, 1, 1, req->result_dma, in safexcel_ahash_send_req()
481 req->digest_sz); in safexcel_ahash_send_req()
489 req->processed += len - extra; in safexcel_ahash_send_req()
496 dma_unmap_single(priv->dev, req->result_dma, req->digest_sz, in safexcel_ahash_send_req()
499 if (req->nents) { in safexcel_ahash_send_req()
500 dma_unmap_sg(priv->dev, areq->src, req->nents, DMA_TO_DEVICE); in safexcel_ahash_send_req()
501 req->nents = 0; in safexcel_ahash_send_req()
507 if (req->cache_dma) { in safexcel_ahash_send_req()
508 dma_unmap_single(priv->dev, req->cache_dma, req->cache_sz, in safexcel_ahash_send_req()
510 req->cache_dma = 0; in safexcel_ahash_send_req()
511 req->cache_sz = 0; in safexcel_ahash_send_req()
572 struct safexcel_ahash_req *req = ahash_request_ctx(areq); in safexcel_handle_result() local
575 BUG_ON(!(priv->flags & EIP197_TRC_CACHE) && req->needs_inv); in safexcel_handle_result()
577 if (req->needs_inv) { in safexcel_handle_result()
578 req->needs_inv = false; in safexcel_handle_result()
611 struct safexcel_ahash_req *req = ahash_request_ctx(areq); in safexcel_ahash_send() local
614 if (req->needs_inv) in safexcel_ahash_send()
626 EIP197_REQUEST_ON_STACK(req, ahash, EIP197_AHASH_REQ_SIZE); in safexcel_ahash_exit_inv()
627 struct safexcel_ahash_req *rctx = ahash_request_ctx(req); in safexcel_ahash_exit_inv()
631 memset(req, 0, EIP197_AHASH_REQ_SIZE); in safexcel_ahash_exit_inv()
635 ahash_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG, in safexcel_ahash_exit_inv()
638 ahash_request_set_tfm(req, __crypto_ahash_cast(tfm)); in safexcel_ahash_exit_inv()
639 ctx = crypto_tfm_ctx(req->base.tfm); in safexcel_ahash_exit_inv()
644 crypto_enqueue_request(&priv->ring[ring].queue, &req->base); in safexcel_ahash_exit_inv()
666 struct safexcel_ahash_req *req = ahash_request_ctx(areq); in safexcel_ahash_cache() local
672 cache_len = safexcel_queued_len(req); in safexcel_ahash_cache()
680 req->cache + cache_len, in safexcel_ahash_cache()
692 struct safexcel_ahash_req *req = ahash_request_ctx(areq); in safexcel_ahash_enqueue() local
696 req->needs_inv = false; in safexcel_ahash_enqueue()
701 ((req->not_first && !req->xcbcmac) || in safexcel_ahash_enqueue()
703 memcmp(ctx->base.ctxr->data, req->state, req->state_sz) || in safexcel_ahash_enqueue()
705 (req->finish && req->hmac && in safexcel_ahash_enqueue()
706 memcmp(ctx->base.ctxr->data + (req->state_sz>>2), in safexcel_ahash_enqueue()
707 &ctx->base.opad, req->state_sz)))) in safexcel_ahash_enqueue()
718 req->needs_inv = true; in safexcel_ahash_enqueue()
728 req->not_first = true; in safexcel_ahash_enqueue()
744 struct safexcel_ahash_req *req = ahash_request_ctx(areq); in safexcel_ahash_update() local
755 req->len += areq->nbytes; in safexcel_ahash_update()
761 if ((ret && !req->finish) || req->last_req) in safexcel_ahash_update()
769 struct safexcel_ahash_req *req = ahash_request_ctx(areq); in safexcel_ahash_final() local
772 req->finish = true; in safexcel_ahash_final()
774 if (unlikely(!req->len && !areq->nbytes)) { in safexcel_ahash_final()
804 } else if (unlikely(req->digest == CONTEXT_CONTROL_DIGEST_XCM && in safexcel_ahash_final()
806 req->len == sizeof(u32) && !areq->nbytes)) { in safexcel_ahash_final()
810 } else if (unlikely(ctx->cbcmac && req->len == AES_BLOCK_SIZE && in safexcel_ahash_final()
815 } else if (unlikely(req->xcbcmac && req->len == AES_BLOCK_SIZE && in safexcel_ahash_final()
829 } else if (unlikely(req->hmac && in safexcel_ahash_final()
830 (req->len == req->block_sz) && in safexcel_ahash_final()
840 memset(req->cache, 0, req->block_sz); in safexcel_ahash_final()
842 req->cache[0] = 0x80; in safexcel_ahash_final()
844 if (req->len_is_le) { in safexcel_ahash_final()
846 req->cache[req->block_sz-8] = (req->block_sz << 3) & in safexcel_ahash_final()
848 req->cache[req->block_sz-7] = (req->block_sz >> 5); in safexcel_ahash_final()
851 req->cache[req->block_sz-2] = (req->block_sz >> 5); in safexcel_ahash_final()
852 req->cache[req->block_sz-1] = (req->block_sz << 3) & in safexcel_ahash_final()
856 req->len += req->block_sz; /* plus 1 hash block */ in safexcel_ahash_final()
859 req->hmac_zlen = true; in safexcel_ahash_final()
862 req->digest = CONTEXT_CONTROL_DIGEST_HMAC; in safexcel_ahash_final()
863 } else if (req->hmac) { in safexcel_ahash_final()
865 req->digest = CONTEXT_CONTROL_DIGEST_HMAC; in safexcel_ahash_final()
873 struct safexcel_ahash_req *req = ahash_request_ctx(areq); in safexcel_ahash_finup() local
875 req->finish = true; in safexcel_ahash_finup()
883 struct safexcel_ahash_req *req = ahash_request_ctx(areq); in safexcel_ahash_export() local
886 export->len = req->len; in safexcel_ahash_export()
887 export->processed = req->processed; in safexcel_ahash_export()
889 export->digest = req->digest; in safexcel_ahash_export()
891 memcpy(export->state, req->state, req->state_sz); in safexcel_ahash_export()
892 memcpy(export->cache, req->cache, HASH_CACHE_SIZE); in safexcel_ahash_export()
899 struct safexcel_ahash_req *req = ahash_request_ctx(areq); in safexcel_ahash_import() local
907 req->len = export->len; in safexcel_ahash_import()
908 req->processed = export->processed; in safexcel_ahash_import()
910 req->digest = export->digest; in safexcel_ahash_import()
912 memcpy(req->cache, export->cache, HASH_CACHE_SIZE); in safexcel_ahash_import()
913 memcpy(req->state, export->state, req->state_sz); in safexcel_ahash_import()
938 struct safexcel_ahash_req *req = ahash_request_ctx(areq); in safexcel_sha1_init() local
940 memset(req, 0, sizeof(*req)); in safexcel_sha1_init()
943 req->digest = CONTEXT_CONTROL_DIGEST_PRECOMPUTED; in safexcel_sha1_init()
944 req->state_sz = SHA1_DIGEST_SIZE; in safexcel_sha1_init()
945 req->digest_sz = SHA1_DIGEST_SIZE; in safexcel_sha1_init()
946 req->block_sz = SHA1_BLOCK_SIZE; in safexcel_sha1_init()
1015 struct safexcel_ahash_req *req = ahash_request_ctx(areq); in safexcel_hmac_sha1_init() local
1017 memset(req, 0, sizeof(*req)); in safexcel_hmac_sha1_init()
1020 memcpy(req->state, &ctx->base.ipad, SHA1_DIGEST_SIZE); in safexcel_hmac_sha1_init()
1022 req->len = SHA1_BLOCK_SIZE; in safexcel_hmac_sha1_init()
1023 req->processed = SHA1_BLOCK_SIZE; in safexcel_hmac_sha1_init()
1026 req->digest = CONTEXT_CONTROL_DIGEST_PRECOMPUTED; in safexcel_hmac_sha1_init()
1027 req->state_sz = SHA1_DIGEST_SIZE; in safexcel_hmac_sha1_init()
1028 req->digest_sz = SHA1_DIGEST_SIZE; in safexcel_hmac_sha1_init()
1029 req->block_sz = SHA1_BLOCK_SIZE; in safexcel_hmac_sha1_init()
1030 req->hmac = true; in safexcel_hmac_sha1_init()
1050 static void safexcel_ahash_complete(struct crypto_async_request *req, int error) in safexcel_ahash_complete() argument
1052 struct safexcel_ahash_result *result = req->data; in safexcel_ahash_complete()
1113 struct safexcel_ahash_req *req; in safexcel_hmac_init_iv() local
1127 req = ahash_request_ctx(areq); in safexcel_hmac_init_iv()
1128 req->hmac = true; in safexcel_hmac_init_iv()
1129 req->last_req = true; in safexcel_hmac_init_iv()
1267 struct safexcel_ahash_req *req = ahash_request_ctx(areq); in safexcel_sha256_init() local
1269 memset(req, 0, sizeof(*req)); in safexcel_sha256_init()
1272 req->digest = CONTEXT_CONTROL_DIGEST_PRECOMPUTED; in safexcel_sha256_init()
1273 req->state_sz = SHA256_DIGEST_SIZE; in safexcel_sha256_init()
1274 req->digest_sz = SHA256_DIGEST_SIZE; in safexcel_sha256_init()
1275 req->block_sz = SHA256_BLOCK_SIZE; in safexcel_sha256_init()
1324 struct safexcel_ahash_req *req = ahash_request_ctx(areq); in safexcel_sha224_init() local
1326 memset(req, 0, sizeof(*req)); in safexcel_sha224_init()
1329 req->digest = CONTEXT_CONTROL_DIGEST_PRECOMPUTED; in safexcel_sha224_init()
1330 req->state_sz = SHA256_DIGEST_SIZE; in safexcel_sha224_init()
1331 req->digest_sz = SHA256_DIGEST_SIZE; in safexcel_sha224_init()
1332 req->block_sz = SHA256_BLOCK_SIZE; in safexcel_sha224_init()
1388 struct safexcel_ahash_req *req = ahash_request_ctx(areq); in safexcel_hmac_sha224_init() local
1390 memset(req, 0, sizeof(*req)); in safexcel_hmac_sha224_init()
1393 memcpy(req->state, &ctx->base.ipad, SHA256_DIGEST_SIZE); in safexcel_hmac_sha224_init()
1395 req->len = SHA256_BLOCK_SIZE; in safexcel_hmac_sha224_init()
1396 req->processed = SHA256_BLOCK_SIZE; in safexcel_hmac_sha224_init()
1399 req->digest = CONTEXT_CONTROL_DIGEST_PRECOMPUTED; in safexcel_hmac_sha224_init()
1400 req->state_sz = SHA256_DIGEST_SIZE; in safexcel_hmac_sha224_init()
1401 req->digest_sz = SHA256_DIGEST_SIZE; in safexcel_hmac_sha224_init()
1402 req->block_sz = SHA256_BLOCK_SIZE; in safexcel_hmac_sha224_init()
1403 req->hmac = true; in safexcel_hmac_sha224_init()
1460 struct safexcel_ahash_req *req = ahash_request_ctx(areq); in safexcel_hmac_sha256_init() local
1462 memset(req, 0, sizeof(*req)); in safexcel_hmac_sha256_init()
1465 memcpy(req->state, &ctx->base.ipad, SHA256_DIGEST_SIZE); in safexcel_hmac_sha256_init()
1467 req->len = SHA256_BLOCK_SIZE; in safexcel_hmac_sha256_init()
1468 req->processed = SHA256_BLOCK_SIZE; in safexcel_hmac_sha256_init()
1471 req->digest = CONTEXT_CONTROL_DIGEST_PRECOMPUTED; in safexcel_hmac_sha256_init()
1472 req->state_sz = SHA256_DIGEST_SIZE; in safexcel_hmac_sha256_init()
1473 req->digest_sz = SHA256_DIGEST_SIZE; in safexcel_hmac_sha256_init()
1474 req->block_sz = SHA256_BLOCK_SIZE; in safexcel_hmac_sha256_init()
1475 req->hmac = true; in safexcel_hmac_sha256_init()
1525 struct safexcel_ahash_req *req = ahash_request_ctx(areq); in safexcel_sha512_init() local
1527 memset(req, 0, sizeof(*req)); in safexcel_sha512_init()
1530 req->digest = CONTEXT_CONTROL_DIGEST_PRECOMPUTED; in safexcel_sha512_init()
1531 req->state_sz = SHA512_DIGEST_SIZE; in safexcel_sha512_init()
1532 req->digest_sz = SHA512_DIGEST_SIZE; in safexcel_sha512_init()
1533 req->block_sz = SHA512_BLOCK_SIZE; in safexcel_sha512_init()
1582 struct safexcel_ahash_req *req = ahash_request_ctx(areq); in safexcel_sha384_init() local
1584 memset(req, 0, sizeof(*req)); in safexcel_sha384_init()
1587 req->digest = CONTEXT_CONTROL_DIGEST_PRECOMPUTED; in safexcel_sha384_init()
1588 req->state_sz = SHA512_DIGEST_SIZE; in safexcel_sha384_init()
1589 req->digest_sz = SHA512_DIGEST_SIZE; in safexcel_sha384_init()
1590 req->block_sz = SHA512_BLOCK_SIZE; in safexcel_sha384_init()
1646 struct safexcel_ahash_req *req = ahash_request_ctx(areq); in safexcel_hmac_sha512_init() local
1648 memset(req, 0, sizeof(*req)); in safexcel_hmac_sha512_init()
1651 memcpy(req->state, &ctx->base.ipad, SHA512_DIGEST_SIZE); in safexcel_hmac_sha512_init()
1653 req->len = SHA512_BLOCK_SIZE; in safexcel_hmac_sha512_init()
1654 req->processed = SHA512_BLOCK_SIZE; in safexcel_hmac_sha512_init()
1657 req->digest = CONTEXT_CONTROL_DIGEST_PRECOMPUTED; in safexcel_hmac_sha512_init()
1658 req->state_sz = SHA512_DIGEST_SIZE; in safexcel_hmac_sha512_init()
1659 req->digest_sz = SHA512_DIGEST_SIZE; in safexcel_hmac_sha512_init()
1660 req->block_sz = SHA512_BLOCK_SIZE; in safexcel_hmac_sha512_init()
1661 req->hmac = true; in safexcel_hmac_sha512_init()
1718 struct safexcel_ahash_req *req = ahash_request_ctx(areq); in safexcel_hmac_sha384_init() local
1720 memset(req, 0, sizeof(*req)); in safexcel_hmac_sha384_init()
1723 memcpy(req->state, &ctx->base.ipad, SHA512_DIGEST_SIZE); in safexcel_hmac_sha384_init()
1725 req->len = SHA512_BLOCK_SIZE; in safexcel_hmac_sha384_init()
1726 req->processed = SHA512_BLOCK_SIZE; in safexcel_hmac_sha384_init()
1729 req->digest = CONTEXT_CONTROL_DIGEST_PRECOMPUTED; in safexcel_hmac_sha384_init()
1730 req->state_sz = SHA512_DIGEST_SIZE; in safexcel_hmac_sha384_init()
1731 req->digest_sz = SHA512_DIGEST_SIZE; in safexcel_hmac_sha384_init()
1732 req->block_sz = SHA512_BLOCK_SIZE; in safexcel_hmac_sha384_init()
1733 req->hmac = true; in safexcel_hmac_sha384_init()
1783 struct safexcel_ahash_req *req = ahash_request_ctx(areq); in safexcel_md5_init() local
1785 memset(req, 0, sizeof(*req)); in safexcel_md5_init()
1788 req->digest = CONTEXT_CONTROL_DIGEST_PRECOMPUTED; in safexcel_md5_init()
1789 req->state_sz = MD5_DIGEST_SIZE; in safexcel_md5_init()
1790 req->digest_sz = MD5_DIGEST_SIZE; in safexcel_md5_init()
1791 req->block_sz = MD5_HMAC_BLOCK_SIZE; in safexcel_md5_init()
1840 struct safexcel_ahash_req *req = ahash_request_ctx(areq); in safexcel_hmac_md5_init() local
1842 memset(req, 0, sizeof(*req)); in safexcel_hmac_md5_init()
1845 memcpy(req->state, &ctx->base.ipad, MD5_DIGEST_SIZE); in safexcel_hmac_md5_init()
1847 req->len = MD5_HMAC_BLOCK_SIZE; in safexcel_hmac_md5_init()
1848 req->processed = MD5_HMAC_BLOCK_SIZE; in safexcel_hmac_md5_init()
1851 req->digest = CONTEXT_CONTROL_DIGEST_PRECOMPUTED; in safexcel_hmac_md5_init()
1852 req->state_sz = MD5_DIGEST_SIZE; in safexcel_hmac_md5_init()
1853 req->digest_sz = MD5_DIGEST_SIZE; in safexcel_hmac_md5_init()
1854 req->block_sz = MD5_HMAC_BLOCK_SIZE; in safexcel_hmac_md5_init()
1855 req->len_is_le = true; /* MD5 is little endian! ... */ in safexcel_hmac_md5_init()
1856 req->hmac = true; in safexcel_hmac_md5_init()
1923 struct safexcel_ahash_req *req = ahash_request_ctx(areq); in safexcel_crc32_init() local
1925 memset(req, 0, sizeof(*req)); in safexcel_crc32_init()
1928 req->state[0] = cpu_to_le32(~ctx->base.ipad.word[0]); in safexcel_crc32_init()
1930 req->len = sizeof(u32); in safexcel_crc32_init()
1931 req->processed = sizeof(u32); in safexcel_crc32_init()
1934 req->digest = CONTEXT_CONTROL_DIGEST_XCM; in safexcel_crc32_init()
1935 req->state_sz = sizeof(u32); in safexcel_crc32_init()
1936 req->digest_sz = sizeof(u32); in safexcel_crc32_init()
1937 req->block_sz = sizeof(u32); in safexcel_crc32_init()
1995 struct safexcel_ahash_req *req = ahash_request_ctx(areq); in safexcel_cbcmac_init() local
1997 memset(req, 0, sizeof(*req)); in safexcel_cbcmac_init()
2000 memcpy(req->state, &ctx->base.ipad, ctx->key_sz); in safexcel_cbcmac_init()
2002 req->len = AES_BLOCK_SIZE; in safexcel_cbcmac_init()
2003 req->processed = AES_BLOCK_SIZE; in safexcel_cbcmac_init()
2005 req->digest = CONTEXT_CONTROL_DIGEST_XCM; in safexcel_cbcmac_init()
2006 req->state_sz = ctx->key_sz; in safexcel_cbcmac_init()
2007 req->digest_sz = AES_BLOCK_SIZE; in safexcel_cbcmac_init()
2008 req->block_sz = AES_BLOCK_SIZE; in safexcel_cbcmac_init()
2009 req->xcbcmac = true; in safexcel_cbcmac_init()
2276 struct safexcel_ahash_req *req = ahash_request_ctx(areq); in safexcel_sm3_init() local
2278 memset(req, 0, sizeof(*req)); in safexcel_sm3_init()
2281 req->digest = CONTEXT_CONTROL_DIGEST_PRECOMPUTED; in safexcel_sm3_init()
2282 req->state_sz = SM3_DIGEST_SIZE; in safexcel_sm3_init()
2283 req->digest_sz = SM3_DIGEST_SIZE; in safexcel_sm3_init()
2284 req->block_sz = SM3_BLOCK_SIZE; in safexcel_sm3_init()
2340 struct safexcel_ahash_req *req = ahash_request_ctx(areq); in safexcel_hmac_sm3_init() local
2342 memset(req, 0, sizeof(*req)); in safexcel_hmac_sm3_init()
2345 memcpy(req->state, &ctx->base.ipad, SM3_DIGEST_SIZE); in safexcel_hmac_sm3_init()
2347 req->len = SM3_BLOCK_SIZE; in safexcel_hmac_sm3_init()
2348 req->processed = SM3_BLOCK_SIZE; in safexcel_hmac_sm3_init()
2351 req->digest = CONTEXT_CONTROL_DIGEST_PRECOMPUTED; in safexcel_hmac_sm3_init()
2352 req->state_sz = SM3_DIGEST_SIZE; in safexcel_hmac_sm3_init()
2353 req->digest_sz = SM3_DIGEST_SIZE; in safexcel_hmac_sm3_init()
2354 req->block_sz = SM3_BLOCK_SIZE; in safexcel_hmac_sm3_init()
2355 req->hmac = true; in safexcel_hmac_sm3_init()
2406 struct safexcel_ahash_req *req = ahash_request_ctx(areq); in safexcel_sha3_224_init() local
2408 memset(req, 0, sizeof(*req)); in safexcel_sha3_224_init()
2411 req->digest = CONTEXT_CONTROL_DIGEST_INITIAL; in safexcel_sha3_224_init()
2412 req->state_sz = SHA3_224_DIGEST_SIZE; in safexcel_sha3_224_init()
2413 req->digest_sz = SHA3_224_DIGEST_SIZE; in safexcel_sha3_224_init()
2414 req->block_sz = SHA3_224_BLOCK_SIZE; in safexcel_sha3_224_init()
2420 static int safexcel_sha3_fbcheck(struct ahash_request *req) in safexcel_sha3_fbcheck() argument
2422 struct crypto_ahash *tfm = crypto_ahash_reqtfm(req); in safexcel_sha3_fbcheck()
2424 struct ahash_request *subreq = ahash_request_ctx(req); in safexcel_sha3_fbcheck()
2429 ahash_request_set_callback(subreq, req->base.flags, in safexcel_sha3_fbcheck()
2430 req->base.complete, req->base.data); in safexcel_sha3_fbcheck()
2431 ahash_request_set_crypt(subreq, req->src, req->result, in safexcel_sha3_fbcheck()
2432 req->nbytes); in safexcel_sha3_fbcheck()
2457 static int safexcel_sha3_update(struct ahash_request *req) in safexcel_sha3_update() argument
2459 struct crypto_ahash *tfm = crypto_ahash_reqtfm(req); in safexcel_sha3_update()
2461 struct ahash_request *subreq = ahash_request_ctx(req); in safexcel_sha3_update()
2464 return safexcel_sha3_fbcheck(req) ?: crypto_ahash_update(subreq); in safexcel_sha3_update()
2467 static int safexcel_sha3_final(struct ahash_request *req) in safexcel_sha3_final() argument
2469 struct crypto_ahash *tfm = crypto_ahash_reqtfm(req); in safexcel_sha3_final()
2471 struct ahash_request *subreq = ahash_request_ctx(req); in safexcel_sha3_final()
2474 return safexcel_sha3_fbcheck(req) ?: crypto_ahash_final(subreq); in safexcel_sha3_final()
2477 static int safexcel_sha3_finup(struct ahash_request *req) in safexcel_sha3_finup() argument
2479 struct crypto_ahash *tfm = crypto_ahash_reqtfm(req); in safexcel_sha3_finup()
2481 struct ahash_request *subreq = ahash_request_ctx(req); in safexcel_sha3_finup()
2483 ctx->do_fallback |= !req->nbytes; in safexcel_sha3_finup()
2486 return safexcel_sha3_fbcheck(req) ?: in safexcel_sha3_finup()
2489 return safexcel_ahash_finup(req); in safexcel_sha3_finup()
2492 static int safexcel_sha3_digest_fallback(struct ahash_request *req) in safexcel_sha3_digest_fallback() argument
2494 struct crypto_ahash *tfm = crypto_ahash_reqtfm(req); in safexcel_sha3_digest_fallback()
2496 struct ahash_request *subreq = ahash_request_ctx(req); in safexcel_sha3_digest_fallback()
2500 return safexcel_sha3_fbcheck(req) ?: crypto_ahash_finup(subreq); in safexcel_sha3_digest_fallback()
2503 static int safexcel_sha3_224_digest(struct ahash_request *req) in safexcel_sha3_224_digest() argument
2505 if (req->nbytes) in safexcel_sha3_224_digest()
2506 return safexcel_sha3_224_init(req) ?: safexcel_ahash_finup(req); in safexcel_sha3_224_digest()
2509 return safexcel_sha3_digest_fallback(req); in safexcel_sha3_224_digest()
2512 static int safexcel_sha3_export(struct ahash_request *req, void *out) in safexcel_sha3_export() argument
2514 struct crypto_ahash *tfm = crypto_ahash_reqtfm(req); in safexcel_sha3_export()
2516 struct ahash_request *subreq = ahash_request_ctx(req); in safexcel_sha3_export()
2519 return safexcel_sha3_fbcheck(req) ?: crypto_ahash_export(subreq, out); in safexcel_sha3_export()
2522 static int safexcel_sha3_import(struct ahash_request *req, const void *in) in safexcel_sha3_import() argument
2524 struct crypto_ahash *tfm = crypto_ahash_reqtfm(req); in safexcel_sha3_import()
2526 struct ahash_request *subreq = ahash_request_ctx(req); in safexcel_sha3_import()
2529 return safexcel_sha3_fbcheck(req) ?: crypto_ahash_import(subreq, in); in safexcel_sha3_import()
2599 struct safexcel_ahash_req *req = ahash_request_ctx(areq); in safexcel_sha3_256_init() local
2601 memset(req, 0, sizeof(*req)); in safexcel_sha3_256_init()
2604 req->digest = CONTEXT_CONTROL_DIGEST_INITIAL; in safexcel_sha3_256_init()
2605 req->state_sz = SHA3_256_DIGEST_SIZE; in safexcel_sha3_256_init()
2606 req->digest_sz = SHA3_256_DIGEST_SIZE; in safexcel_sha3_256_init()
2607 req->block_sz = SHA3_256_BLOCK_SIZE; in safexcel_sha3_256_init()
2613 static int safexcel_sha3_256_digest(struct ahash_request *req) in safexcel_sha3_256_digest() argument
2615 if (req->nbytes) in safexcel_sha3_256_digest()
2616 return safexcel_sha3_256_init(req) ?: safexcel_ahash_finup(req); in safexcel_sha3_256_digest()
2619 return safexcel_sha3_digest_fallback(req); in safexcel_sha3_256_digest()
2657 struct safexcel_ahash_req *req = ahash_request_ctx(areq); in safexcel_sha3_384_init() local
2659 memset(req, 0, sizeof(*req)); in safexcel_sha3_384_init()
2662 req->digest = CONTEXT_CONTROL_DIGEST_INITIAL; in safexcel_sha3_384_init()
2663 req->state_sz = SHA3_384_DIGEST_SIZE; in safexcel_sha3_384_init()
2664 req->digest_sz = SHA3_384_DIGEST_SIZE; in safexcel_sha3_384_init()
2665 req->block_sz = SHA3_384_BLOCK_SIZE; in safexcel_sha3_384_init()
2671 static int safexcel_sha3_384_digest(struct ahash_request *req) in safexcel_sha3_384_digest() argument
2673 if (req->nbytes) in safexcel_sha3_384_digest()
2674 return safexcel_sha3_384_init(req) ?: safexcel_ahash_finup(req); in safexcel_sha3_384_digest()
2677 return safexcel_sha3_digest_fallback(req); in safexcel_sha3_384_digest()
2715 struct safexcel_ahash_req *req = ahash_request_ctx(areq); in safexcel_sha3_512_init() local
2717 memset(req, 0, sizeof(*req)); in safexcel_sha3_512_init()
2720 req->digest = CONTEXT_CONTROL_DIGEST_INITIAL; in safexcel_sha3_512_init()
2721 req->state_sz = SHA3_512_DIGEST_SIZE; in safexcel_sha3_512_init()
2722 req->digest_sz = SHA3_512_DIGEST_SIZE; in safexcel_sha3_512_init()
2723 req->block_sz = SHA3_512_BLOCK_SIZE; in safexcel_sha3_512_init()
2729 static int safexcel_sha3_512_digest(struct ahash_request *req) in safexcel_sha3_512_digest() argument
2731 if (req->nbytes) in safexcel_sha3_512_digest()
2732 return safexcel_sha3_512_init(req) ?: safexcel_ahash_finup(req); in safexcel_sha3_512_digest()
2735 return safexcel_sha3_digest_fallback(req); in safexcel_sha3_512_digest()
2865 struct safexcel_ahash_req *req = ahash_request_ctx(areq); in safexcel_hmac_sha3_224_init() local
2867 memset(req, 0, sizeof(*req)); in safexcel_hmac_sha3_224_init()
2870 memcpy(req->state, &ctx->base.ipad, SHA3_224_BLOCK_SIZE / 2); in safexcel_hmac_sha3_224_init()
2872 req->len = SHA3_224_BLOCK_SIZE; in safexcel_hmac_sha3_224_init()
2873 req->processed = SHA3_224_BLOCK_SIZE; in safexcel_hmac_sha3_224_init()
2875 req->digest = CONTEXT_CONTROL_DIGEST_HMAC; in safexcel_hmac_sha3_224_init()
2876 req->state_sz = SHA3_224_BLOCK_SIZE / 2; in safexcel_hmac_sha3_224_init()
2877 req->digest_sz = SHA3_224_DIGEST_SIZE; in safexcel_hmac_sha3_224_init()
2878 req->block_sz = SHA3_224_BLOCK_SIZE; in safexcel_hmac_sha3_224_init()
2879 req->hmac = true; in safexcel_hmac_sha3_224_init()
2885 static int safexcel_hmac_sha3_224_digest(struct ahash_request *req) in safexcel_hmac_sha3_224_digest() argument
2887 if (req->nbytes) in safexcel_hmac_sha3_224_digest()
2888 return safexcel_hmac_sha3_224_init(req) ?: in safexcel_hmac_sha3_224_digest()
2889 safexcel_ahash_finup(req); in safexcel_hmac_sha3_224_digest()
2892 return safexcel_sha3_digest_fallback(req); in safexcel_hmac_sha3_224_digest()
2936 struct safexcel_ahash_req *req = ahash_request_ctx(areq); in safexcel_hmac_sha3_256_init() local
2938 memset(req, 0, sizeof(*req)); in safexcel_hmac_sha3_256_init()
2941 memcpy(req->state, &ctx->base.ipad, SHA3_256_BLOCK_SIZE / 2); in safexcel_hmac_sha3_256_init()
2943 req->len = SHA3_256_BLOCK_SIZE; in safexcel_hmac_sha3_256_init()
2944 req->processed = SHA3_256_BLOCK_SIZE; in safexcel_hmac_sha3_256_init()
2946 req->digest = CONTEXT_CONTROL_DIGEST_HMAC; in safexcel_hmac_sha3_256_init()
2947 req->state_sz = SHA3_256_BLOCK_SIZE / 2; in safexcel_hmac_sha3_256_init()
2948 req->digest_sz = SHA3_256_DIGEST_SIZE; in safexcel_hmac_sha3_256_init()
2949 req->block_sz = SHA3_256_BLOCK_SIZE; in safexcel_hmac_sha3_256_init()
2950 req->hmac = true; in safexcel_hmac_sha3_256_init()
2956 static int safexcel_hmac_sha3_256_digest(struct ahash_request *req) in safexcel_hmac_sha3_256_digest() argument
2958 if (req->nbytes) in safexcel_hmac_sha3_256_digest()
2959 return safexcel_hmac_sha3_256_init(req) ?: in safexcel_hmac_sha3_256_digest()
2960 safexcel_ahash_finup(req); in safexcel_hmac_sha3_256_digest()
2963 return safexcel_sha3_digest_fallback(req); in safexcel_hmac_sha3_256_digest()
3007 struct safexcel_ahash_req *req = ahash_request_ctx(areq); in safexcel_hmac_sha3_384_init() local
3009 memset(req, 0, sizeof(*req)); in safexcel_hmac_sha3_384_init()
3012 memcpy(req->state, &ctx->base.ipad, SHA3_384_BLOCK_SIZE / 2); in safexcel_hmac_sha3_384_init()
3014 req->len = SHA3_384_BLOCK_SIZE; in safexcel_hmac_sha3_384_init()
3015 req->processed = SHA3_384_BLOCK_SIZE; in safexcel_hmac_sha3_384_init()
3017 req->digest = CONTEXT_CONTROL_DIGEST_HMAC; in safexcel_hmac_sha3_384_init()
3018 req->state_sz = SHA3_384_BLOCK_SIZE / 2; in safexcel_hmac_sha3_384_init()
3019 req->digest_sz = SHA3_384_DIGEST_SIZE; in safexcel_hmac_sha3_384_init()
3020 req->block_sz = SHA3_384_BLOCK_SIZE; in safexcel_hmac_sha3_384_init()
3021 req->hmac = true; in safexcel_hmac_sha3_384_init()
3027 static int safexcel_hmac_sha3_384_digest(struct ahash_request *req) in safexcel_hmac_sha3_384_digest() argument
3029 if (req->nbytes) in safexcel_hmac_sha3_384_digest()
3030 return safexcel_hmac_sha3_384_init(req) ?: in safexcel_hmac_sha3_384_digest()
3031 safexcel_ahash_finup(req); in safexcel_hmac_sha3_384_digest()
3034 return safexcel_sha3_digest_fallback(req); in safexcel_hmac_sha3_384_digest()
3078 struct safexcel_ahash_req *req = ahash_request_ctx(areq); in safexcel_hmac_sha3_512_init() local
3080 memset(req, 0, sizeof(*req)); in safexcel_hmac_sha3_512_init()
3083 memcpy(req->state, &ctx->base.ipad, SHA3_512_BLOCK_SIZE / 2); in safexcel_hmac_sha3_512_init()
3085 req->len = SHA3_512_BLOCK_SIZE; in safexcel_hmac_sha3_512_init()
3086 req->processed = SHA3_512_BLOCK_SIZE; in safexcel_hmac_sha3_512_init()
3088 req->digest = CONTEXT_CONTROL_DIGEST_HMAC; in safexcel_hmac_sha3_512_init()
3089 req->state_sz = SHA3_512_BLOCK_SIZE / 2; in safexcel_hmac_sha3_512_init()
3090 req->digest_sz = SHA3_512_DIGEST_SIZE; in safexcel_hmac_sha3_512_init()
3091 req->block_sz = SHA3_512_BLOCK_SIZE; in safexcel_hmac_sha3_512_init()
3092 req->hmac = true; in safexcel_hmac_sha3_512_init()
3098 static int safexcel_hmac_sha3_512_digest(struct ahash_request *req) in safexcel_hmac_sha3_512_digest() argument
3100 if (req->nbytes) in safexcel_hmac_sha3_512_digest()
3101 return safexcel_hmac_sha3_512_init(req) ?: in safexcel_hmac_sha3_512_digest()
3102 safexcel_ahash_finup(req); in safexcel_hmac_sha3_512_digest()
3105 return safexcel_sha3_digest_fallback(req); in safexcel_hmac_sha3_512_digest()