Lines Matching full: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_dma(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_dma(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_dma(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_dma(req); in safexcel_ahash_exit_inv()
632 memset(req, 0, EIP197_AHASH_REQ_SIZE); in safexcel_ahash_exit_inv()
636 ahash_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG, in safexcel_ahash_exit_inv()
639 ahash_request_set_tfm(req, __crypto_ahash_cast(tfm)); in safexcel_ahash_exit_inv()
640 ctx = crypto_tfm_ctx(req->base.tfm); in safexcel_ahash_exit_inv()
645 crypto_enqueue_request(&priv->ring[ring].queue, &req->base); in safexcel_ahash_exit_inv()
666 struct safexcel_ahash_req *req = ahash_request_ctx_dma(areq); in safexcel_ahash_cache() local
670 * tot sz handled by update() - last req sz - tot sz handled by send() in safexcel_ahash_cache()
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_dma(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_dma(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_dma(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_dma(areq); in safexcel_ahash_finup() local
875 req->finish = true; in safexcel_ahash_finup()
883 struct safexcel_ahash_req *req = ahash_request_ctx_dma(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_dma(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_dma(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_dma(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()
1092 struct safexcel_ahash_req *req; in safexcel_hmac_init_iv() local
1106 req = ahash_request_ctx_dma(areq); in safexcel_hmac_init_iv()
1107 req->hmac = true; in safexcel_hmac_init_iv()
1108 req->last_req = true; in safexcel_hmac_init_iv()
1241 struct safexcel_ahash_req *req = ahash_request_ctx_dma(areq); in safexcel_sha256_init() local
1243 memset(req, 0, sizeof(*req)); in safexcel_sha256_init()
1246 req->digest = CONTEXT_CONTROL_DIGEST_PRECOMPUTED; in safexcel_sha256_init()
1247 req->state_sz = SHA256_DIGEST_SIZE; in safexcel_sha256_init()
1248 req->digest_sz = SHA256_DIGEST_SIZE; in safexcel_sha256_init()
1249 req->block_sz = SHA256_BLOCK_SIZE; in safexcel_sha256_init()
1298 struct safexcel_ahash_req *req = ahash_request_ctx_dma(areq); in safexcel_sha224_init() local
1300 memset(req, 0, sizeof(*req)); in safexcel_sha224_init()
1303 req->digest = CONTEXT_CONTROL_DIGEST_PRECOMPUTED; in safexcel_sha224_init()
1304 req->state_sz = SHA256_DIGEST_SIZE; in safexcel_sha224_init()
1305 req->digest_sz = SHA256_DIGEST_SIZE; in safexcel_sha224_init()
1306 req->block_sz = SHA256_BLOCK_SIZE; in safexcel_sha224_init()
1362 struct safexcel_ahash_req *req = ahash_request_ctx_dma(areq); in safexcel_hmac_sha224_init() local
1364 memset(req, 0, sizeof(*req)); in safexcel_hmac_sha224_init()
1367 memcpy(req->state, &ctx->base.ipad, SHA256_DIGEST_SIZE); in safexcel_hmac_sha224_init()
1369 req->len = SHA256_BLOCK_SIZE; in safexcel_hmac_sha224_init()
1370 req->processed = SHA256_BLOCK_SIZE; in safexcel_hmac_sha224_init()
1373 req->digest = CONTEXT_CONTROL_DIGEST_PRECOMPUTED; in safexcel_hmac_sha224_init()
1374 req->state_sz = SHA256_DIGEST_SIZE; in safexcel_hmac_sha224_init()
1375 req->digest_sz = SHA256_DIGEST_SIZE; in safexcel_hmac_sha224_init()
1376 req->block_sz = SHA256_BLOCK_SIZE; in safexcel_hmac_sha224_init()
1377 req->hmac = true; in safexcel_hmac_sha224_init()
1434 struct safexcel_ahash_req *req = ahash_request_ctx_dma(areq); in safexcel_hmac_sha256_init() local
1436 memset(req, 0, sizeof(*req)); in safexcel_hmac_sha256_init()
1439 memcpy(req->state, &ctx->base.ipad, SHA256_DIGEST_SIZE); in safexcel_hmac_sha256_init()
1441 req->len = SHA256_BLOCK_SIZE; in safexcel_hmac_sha256_init()
1442 req->processed = SHA256_BLOCK_SIZE; in safexcel_hmac_sha256_init()
1445 req->digest = CONTEXT_CONTROL_DIGEST_PRECOMPUTED; in safexcel_hmac_sha256_init()
1446 req->state_sz = SHA256_DIGEST_SIZE; in safexcel_hmac_sha256_init()
1447 req->digest_sz = SHA256_DIGEST_SIZE; in safexcel_hmac_sha256_init()
1448 req->block_sz = SHA256_BLOCK_SIZE; in safexcel_hmac_sha256_init()
1449 req->hmac = true; in safexcel_hmac_sha256_init()
1499 struct safexcel_ahash_req *req = ahash_request_ctx_dma(areq); in safexcel_sha512_init() local
1501 memset(req, 0, sizeof(*req)); in safexcel_sha512_init()
1504 req->digest = CONTEXT_CONTROL_DIGEST_PRECOMPUTED; in safexcel_sha512_init()
1505 req->state_sz = SHA512_DIGEST_SIZE; in safexcel_sha512_init()
1506 req->digest_sz = SHA512_DIGEST_SIZE; in safexcel_sha512_init()
1507 req->block_sz = SHA512_BLOCK_SIZE; in safexcel_sha512_init()
1556 struct safexcel_ahash_req *req = ahash_request_ctx_dma(areq); in safexcel_sha384_init() local
1558 memset(req, 0, sizeof(*req)); in safexcel_sha384_init()
1561 req->digest = CONTEXT_CONTROL_DIGEST_PRECOMPUTED; in safexcel_sha384_init()
1562 req->state_sz = SHA512_DIGEST_SIZE; in safexcel_sha384_init()
1563 req->digest_sz = SHA512_DIGEST_SIZE; in safexcel_sha384_init()
1564 req->block_sz = SHA512_BLOCK_SIZE; in safexcel_sha384_init()
1620 struct safexcel_ahash_req *req = ahash_request_ctx_dma(areq); in safexcel_hmac_sha512_init() local
1622 memset(req, 0, sizeof(*req)); in safexcel_hmac_sha512_init()
1625 memcpy(req->state, &ctx->base.ipad, SHA512_DIGEST_SIZE); in safexcel_hmac_sha512_init()
1627 req->len = SHA512_BLOCK_SIZE; in safexcel_hmac_sha512_init()
1628 req->processed = SHA512_BLOCK_SIZE; in safexcel_hmac_sha512_init()
1631 req->digest = CONTEXT_CONTROL_DIGEST_PRECOMPUTED; in safexcel_hmac_sha512_init()
1632 req->state_sz = SHA512_DIGEST_SIZE; in safexcel_hmac_sha512_init()
1633 req->digest_sz = SHA512_DIGEST_SIZE; in safexcel_hmac_sha512_init()
1634 req->block_sz = SHA512_BLOCK_SIZE; in safexcel_hmac_sha512_init()
1635 req->hmac = true; in safexcel_hmac_sha512_init()
1692 struct safexcel_ahash_req *req = ahash_request_ctx_dma(areq); in safexcel_hmac_sha384_init() local
1694 memset(req, 0, sizeof(*req)); in safexcel_hmac_sha384_init()
1697 memcpy(req->state, &ctx->base.ipad, SHA512_DIGEST_SIZE); in safexcel_hmac_sha384_init()
1699 req->len = SHA512_BLOCK_SIZE; in safexcel_hmac_sha384_init()
1700 req->processed = SHA512_BLOCK_SIZE; in safexcel_hmac_sha384_init()
1703 req->digest = CONTEXT_CONTROL_DIGEST_PRECOMPUTED; in safexcel_hmac_sha384_init()
1704 req->state_sz = SHA512_DIGEST_SIZE; in safexcel_hmac_sha384_init()
1705 req->digest_sz = SHA512_DIGEST_SIZE; in safexcel_hmac_sha384_init()
1706 req->block_sz = SHA512_BLOCK_SIZE; in safexcel_hmac_sha384_init()
1707 req->hmac = true; in safexcel_hmac_sha384_init()
1757 struct safexcel_ahash_req *req = ahash_request_ctx_dma(areq); in safexcel_md5_init() local
1759 memset(req, 0, sizeof(*req)); in safexcel_md5_init()
1762 req->digest = CONTEXT_CONTROL_DIGEST_PRECOMPUTED; in safexcel_md5_init()
1763 req->state_sz = MD5_DIGEST_SIZE; in safexcel_md5_init()
1764 req->digest_sz = MD5_DIGEST_SIZE; in safexcel_md5_init()
1765 req->block_sz = MD5_HMAC_BLOCK_SIZE; in safexcel_md5_init()
1814 struct safexcel_ahash_req *req = ahash_request_ctx_dma(areq); in safexcel_hmac_md5_init() local
1816 memset(req, 0, sizeof(*req)); in safexcel_hmac_md5_init()
1819 memcpy(req->state, &ctx->base.ipad, MD5_DIGEST_SIZE); in safexcel_hmac_md5_init()
1821 req->len = MD5_HMAC_BLOCK_SIZE; in safexcel_hmac_md5_init()
1822 req->processed = MD5_HMAC_BLOCK_SIZE; in safexcel_hmac_md5_init()
1825 req->digest = CONTEXT_CONTROL_DIGEST_PRECOMPUTED; in safexcel_hmac_md5_init()
1826 req->state_sz = MD5_DIGEST_SIZE; in safexcel_hmac_md5_init()
1827 req->digest_sz = MD5_DIGEST_SIZE; in safexcel_hmac_md5_init()
1828 req->block_sz = MD5_HMAC_BLOCK_SIZE; in safexcel_hmac_md5_init()
1829 req->len_is_le = true; /* MD5 is little endian! ... */ in safexcel_hmac_md5_init()
1830 req->hmac = true; in safexcel_hmac_md5_init()
1897 struct safexcel_ahash_req *req = ahash_request_ctx_dma(areq); in safexcel_crc32_init() local
1899 memset(req, 0, sizeof(*req)); in safexcel_crc32_init()
1902 req->state[0] = cpu_to_le32(~ctx->base.ipad.word[0]); in safexcel_crc32_init()
1904 req->len = sizeof(u32); in safexcel_crc32_init()
1905 req->processed = sizeof(u32); in safexcel_crc32_init()
1908 req->digest = CONTEXT_CONTROL_DIGEST_XCM; in safexcel_crc32_init()
1909 req->state_sz = sizeof(u32); in safexcel_crc32_init()
1910 req->digest_sz = sizeof(u32); in safexcel_crc32_init()
1911 req->block_sz = sizeof(u32); in safexcel_crc32_init()
1969 struct safexcel_ahash_req *req = ahash_request_ctx_dma(areq); in safexcel_cbcmac_init() local
1971 memset(req, 0, sizeof(*req)); in safexcel_cbcmac_init()
1974 memcpy(req->state, &ctx->base.ipad, ctx->key_sz); in safexcel_cbcmac_init()
1976 req->len = AES_BLOCK_SIZE; in safexcel_cbcmac_init()
1977 req->processed = AES_BLOCK_SIZE; in safexcel_cbcmac_init()
1979 req->digest = CONTEXT_CONTROL_DIGEST_XCM; in safexcel_cbcmac_init()
1980 req->state_sz = ctx->key_sz; in safexcel_cbcmac_init()
1981 req->digest_sz = AES_BLOCK_SIZE; in safexcel_cbcmac_init()
1982 req->block_sz = AES_BLOCK_SIZE; in safexcel_cbcmac_init()
1983 req->xcbcmac = true; in safexcel_cbcmac_init()
2229 struct safexcel_ahash_req *req = ahash_request_ctx_dma(areq); in safexcel_sm3_init() local
2231 memset(req, 0, sizeof(*req)); in safexcel_sm3_init()
2234 req->digest = CONTEXT_CONTROL_DIGEST_PRECOMPUTED; in safexcel_sm3_init()
2235 req->state_sz = SM3_DIGEST_SIZE; in safexcel_sm3_init()
2236 req->digest_sz = SM3_DIGEST_SIZE; in safexcel_sm3_init()
2237 req->block_sz = SM3_BLOCK_SIZE; in safexcel_sm3_init()
2293 struct safexcel_ahash_req *req = ahash_request_ctx_dma(areq); in safexcel_hmac_sm3_init() local
2295 memset(req, 0, sizeof(*req)); in safexcel_hmac_sm3_init()
2298 memcpy(req->state, &ctx->base.ipad, SM3_DIGEST_SIZE); in safexcel_hmac_sm3_init()
2300 req->len = SM3_BLOCK_SIZE; in safexcel_hmac_sm3_init()
2301 req->processed = SM3_BLOCK_SIZE; in safexcel_hmac_sm3_init()
2304 req->digest = CONTEXT_CONTROL_DIGEST_PRECOMPUTED; in safexcel_hmac_sm3_init()
2305 req->state_sz = SM3_DIGEST_SIZE; in safexcel_hmac_sm3_init()
2306 req->digest_sz = SM3_DIGEST_SIZE; in safexcel_hmac_sm3_init()
2307 req->block_sz = SM3_BLOCK_SIZE; in safexcel_hmac_sm3_init()
2308 req->hmac = true; in safexcel_hmac_sm3_init()
2359 struct safexcel_ahash_req *req = ahash_request_ctx_dma(areq); in safexcel_sha3_224_init() local
2361 memset(req, 0, sizeof(*req)); in safexcel_sha3_224_init()
2364 req->digest = CONTEXT_CONTROL_DIGEST_INITIAL; in safexcel_sha3_224_init()
2365 req->state_sz = SHA3_224_DIGEST_SIZE; in safexcel_sha3_224_init()
2366 req->digest_sz = SHA3_224_DIGEST_SIZE; in safexcel_sha3_224_init()
2367 req->block_sz = SHA3_224_BLOCK_SIZE; in safexcel_sha3_224_init()
2373 static int safexcel_sha3_fbcheck(struct ahash_request *req) in safexcel_sha3_fbcheck() argument
2375 struct crypto_ahash *tfm = crypto_ahash_reqtfm(req); in safexcel_sha3_fbcheck()
2377 struct ahash_request *subreq = ahash_request_ctx_dma(req); in safexcel_sha3_fbcheck()
2382 ahash_request_set_callback(subreq, req->base.flags, in safexcel_sha3_fbcheck()
2383 req->base.complete, req->base.data); in safexcel_sha3_fbcheck()
2384 ahash_request_set_crypt(subreq, req->src, req->result, in safexcel_sha3_fbcheck()
2385 req->nbytes); in safexcel_sha3_fbcheck()
2410 static int safexcel_sha3_update(struct ahash_request *req) in safexcel_sha3_update() argument
2412 struct crypto_ahash *tfm = crypto_ahash_reqtfm(req); in safexcel_sha3_update()
2414 struct ahash_request *subreq = ahash_request_ctx_dma(req); in safexcel_sha3_update()
2417 return safexcel_sha3_fbcheck(req) ?: crypto_ahash_update(subreq); in safexcel_sha3_update()
2420 static int safexcel_sha3_final(struct ahash_request *req) in safexcel_sha3_final() argument
2422 struct crypto_ahash *tfm = crypto_ahash_reqtfm(req); in safexcel_sha3_final()
2424 struct ahash_request *subreq = ahash_request_ctx_dma(req); in safexcel_sha3_final()
2427 return safexcel_sha3_fbcheck(req) ?: crypto_ahash_final(subreq); in safexcel_sha3_final()
2430 static int safexcel_sha3_finup(struct ahash_request *req) in safexcel_sha3_finup() argument
2432 struct crypto_ahash *tfm = crypto_ahash_reqtfm(req); in safexcel_sha3_finup()
2434 struct ahash_request *subreq = ahash_request_ctx_dma(req); in safexcel_sha3_finup()
2436 ctx->do_fallback |= !req->nbytes; in safexcel_sha3_finup()
2439 return safexcel_sha3_fbcheck(req) ?: in safexcel_sha3_finup()
2442 return safexcel_ahash_finup(req); in safexcel_sha3_finup()
2445 static int safexcel_sha3_digest_fallback(struct ahash_request *req) in safexcel_sha3_digest_fallback() argument
2447 struct crypto_ahash *tfm = crypto_ahash_reqtfm(req); in safexcel_sha3_digest_fallback()
2449 struct ahash_request *subreq = ahash_request_ctx_dma(req); in safexcel_sha3_digest_fallback()
2453 return safexcel_sha3_fbcheck(req) ?: crypto_ahash_finup(subreq); in safexcel_sha3_digest_fallback()
2456 static int safexcel_sha3_224_digest(struct ahash_request *req) in safexcel_sha3_224_digest() argument
2458 if (req->nbytes) in safexcel_sha3_224_digest()
2459 return safexcel_sha3_224_init(req) ?: safexcel_ahash_finup(req); in safexcel_sha3_224_digest()
2462 return safexcel_sha3_digest_fallback(req); in safexcel_sha3_224_digest()
2465 static int safexcel_sha3_export(struct ahash_request *req, void *out) in safexcel_sha3_export() argument
2467 struct crypto_ahash *tfm = crypto_ahash_reqtfm(req); in safexcel_sha3_export()
2469 struct ahash_request *subreq = ahash_request_ctx_dma(req); in safexcel_sha3_export()
2472 return safexcel_sha3_fbcheck(req) ?: crypto_ahash_export(subreq, out); in safexcel_sha3_export()
2475 static int safexcel_sha3_import(struct ahash_request *req, const void *in) in safexcel_sha3_import() argument
2477 struct crypto_ahash *tfm = crypto_ahash_reqtfm(req); in safexcel_sha3_import()
2479 struct ahash_request *subreq = ahash_request_ctx_dma(req); in safexcel_sha3_import()
2482 return safexcel_sha3_fbcheck(req) ?: crypto_ahash_import(subreq, in); in safexcel_sha3_import()
2483 // return safexcel_ahash_import(req, in); in safexcel_sha3_import()
2553 struct safexcel_ahash_req *req = ahash_request_ctx_dma(areq); in safexcel_sha3_256_init() local
2555 memset(req, 0, sizeof(*req)); in safexcel_sha3_256_init()
2558 req->digest = CONTEXT_CONTROL_DIGEST_INITIAL; in safexcel_sha3_256_init()
2559 req->state_sz = SHA3_256_DIGEST_SIZE; in safexcel_sha3_256_init()
2560 req->digest_sz = SHA3_256_DIGEST_SIZE; in safexcel_sha3_256_init()
2561 req->block_sz = SHA3_256_BLOCK_SIZE; in safexcel_sha3_256_init()
2567 static int safexcel_sha3_256_digest(struct ahash_request *req) in safexcel_sha3_256_digest() argument
2569 if (req->nbytes) in safexcel_sha3_256_digest()
2570 return safexcel_sha3_256_init(req) ?: safexcel_ahash_finup(req); in safexcel_sha3_256_digest()
2573 return safexcel_sha3_digest_fallback(req); in safexcel_sha3_256_digest()
2611 struct safexcel_ahash_req *req = ahash_request_ctx_dma(areq); in safexcel_sha3_384_init() local
2613 memset(req, 0, sizeof(*req)); in safexcel_sha3_384_init()
2616 req->digest = CONTEXT_CONTROL_DIGEST_INITIAL; in safexcel_sha3_384_init()
2617 req->state_sz = SHA3_384_DIGEST_SIZE; in safexcel_sha3_384_init()
2618 req->digest_sz = SHA3_384_DIGEST_SIZE; in safexcel_sha3_384_init()
2619 req->block_sz = SHA3_384_BLOCK_SIZE; in safexcel_sha3_384_init()
2625 static int safexcel_sha3_384_digest(struct ahash_request *req) in safexcel_sha3_384_digest() argument
2627 if (req->nbytes) in safexcel_sha3_384_digest()
2628 return safexcel_sha3_384_init(req) ?: safexcel_ahash_finup(req); in safexcel_sha3_384_digest()
2631 return safexcel_sha3_digest_fallback(req); in safexcel_sha3_384_digest()
2669 struct safexcel_ahash_req *req = ahash_request_ctx_dma(areq); in safexcel_sha3_512_init() local
2671 memset(req, 0, sizeof(*req)); in safexcel_sha3_512_init()
2674 req->digest = CONTEXT_CONTROL_DIGEST_INITIAL; in safexcel_sha3_512_init()
2675 req->state_sz = SHA3_512_DIGEST_SIZE; in safexcel_sha3_512_init()
2676 req->digest_sz = SHA3_512_DIGEST_SIZE; in safexcel_sha3_512_init()
2677 req->block_sz = SHA3_512_BLOCK_SIZE; in safexcel_sha3_512_init()
2683 static int safexcel_sha3_512_digest(struct ahash_request *req) in safexcel_sha3_512_digest() argument
2685 if (req->nbytes) in safexcel_sha3_512_digest()
2686 return safexcel_sha3_512_init(req) ?: safexcel_ahash_finup(req); in safexcel_sha3_512_digest()
2689 return safexcel_sha3_digest_fallback(req); in safexcel_sha3_512_digest()
2819 struct safexcel_ahash_req *req = ahash_request_ctx_dma(areq); in safexcel_hmac_sha3_224_init() local
2821 memset(req, 0, sizeof(*req)); in safexcel_hmac_sha3_224_init()
2824 memcpy(req->state, &ctx->base.ipad, SHA3_224_BLOCK_SIZE / 2); in safexcel_hmac_sha3_224_init()
2826 req->len = SHA3_224_BLOCK_SIZE; in safexcel_hmac_sha3_224_init()
2827 req->processed = SHA3_224_BLOCK_SIZE; in safexcel_hmac_sha3_224_init()
2829 req->digest = CONTEXT_CONTROL_DIGEST_HMAC; in safexcel_hmac_sha3_224_init()
2830 req->state_sz = SHA3_224_BLOCK_SIZE / 2; in safexcel_hmac_sha3_224_init()
2831 req->digest_sz = SHA3_224_DIGEST_SIZE; in safexcel_hmac_sha3_224_init()
2832 req->block_sz = SHA3_224_BLOCK_SIZE; in safexcel_hmac_sha3_224_init()
2833 req->hmac = true; in safexcel_hmac_sha3_224_init()
2839 static int safexcel_hmac_sha3_224_digest(struct ahash_request *req) in safexcel_hmac_sha3_224_digest() argument
2841 if (req->nbytes) in safexcel_hmac_sha3_224_digest()
2842 return safexcel_hmac_sha3_224_init(req) ?: in safexcel_hmac_sha3_224_digest()
2843 safexcel_ahash_finup(req); in safexcel_hmac_sha3_224_digest()
2846 return safexcel_sha3_digest_fallback(req); in safexcel_hmac_sha3_224_digest()
2890 struct safexcel_ahash_req *req = ahash_request_ctx_dma(areq); in safexcel_hmac_sha3_256_init() local
2892 memset(req, 0, sizeof(*req)); in safexcel_hmac_sha3_256_init()
2895 memcpy(req->state, &ctx->base.ipad, SHA3_256_BLOCK_SIZE / 2); in safexcel_hmac_sha3_256_init()
2897 req->len = SHA3_256_BLOCK_SIZE; in safexcel_hmac_sha3_256_init()
2898 req->processed = SHA3_256_BLOCK_SIZE; in safexcel_hmac_sha3_256_init()
2900 req->digest = CONTEXT_CONTROL_DIGEST_HMAC; in safexcel_hmac_sha3_256_init()
2901 req->state_sz = SHA3_256_BLOCK_SIZE / 2; in safexcel_hmac_sha3_256_init()
2902 req->digest_sz = SHA3_256_DIGEST_SIZE; in safexcel_hmac_sha3_256_init()
2903 req->block_sz = SHA3_256_BLOCK_SIZE; in safexcel_hmac_sha3_256_init()
2904 req->hmac = true; in safexcel_hmac_sha3_256_init()
2910 static int safexcel_hmac_sha3_256_digest(struct ahash_request *req) in safexcel_hmac_sha3_256_digest() argument
2912 if (req->nbytes) in safexcel_hmac_sha3_256_digest()
2913 return safexcel_hmac_sha3_256_init(req) ?: in safexcel_hmac_sha3_256_digest()
2914 safexcel_ahash_finup(req); in safexcel_hmac_sha3_256_digest()
2917 return safexcel_sha3_digest_fallback(req); in safexcel_hmac_sha3_256_digest()
2961 struct safexcel_ahash_req *req = ahash_request_ctx_dma(areq); in safexcel_hmac_sha3_384_init() local
2963 memset(req, 0, sizeof(*req)); in safexcel_hmac_sha3_384_init()
2966 memcpy(req->state, &ctx->base.ipad, SHA3_384_BLOCK_SIZE / 2); in safexcel_hmac_sha3_384_init()
2968 req->len = SHA3_384_BLOCK_SIZE; in safexcel_hmac_sha3_384_init()
2969 req->processed = SHA3_384_BLOCK_SIZE; in safexcel_hmac_sha3_384_init()
2971 req->digest = CONTEXT_CONTROL_DIGEST_HMAC; in safexcel_hmac_sha3_384_init()
2972 req->state_sz = SHA3_384_BLOCK_SIZE / 2; in safexcel_hmac_sha3_384_init()
2973 req->digest_sz = SHA3_384_DIGEST_SIZE; in safexcel_hmac_sha3_384_init()
2974 req->block_sz = SHA3_384_BLOCK_SIZE; in safexcel_hmac_sha3_384_init()
2975 req->hmac = true; in safexcel_hmac_sha3_384_init()
2981 static int safexcel_hmac_sha3_384_digest(struct ahash_request *req) in safexcel_hmac_sha3_384_digest() argument
2983 if (req->nbytes) in safexcel_hmac_sha3_384_digest()
2984 return safexcel_hmac_sha3_384_init(req) ?: in safexcel_hmac_sha3_384_digest()
2985 safexcel_ahash_finup(req); in safexcel_hmac_sha3_384_digest()
2988 return safexcel_sha3_digest_fallback(req); in safexcel_hmac_sha3_384_digest()
3032 struct safexcel_ahash_req *req = ahash_request_ctx_dma(areq); in safexcel_hmac_sha3_512_init() local
3034 memset(req, 0, sizeof(*req)); in safexcel_hmac_sha3_512_init()
3037 memcpy(req->state, &ctx->base.ipad, SHA3_512_BLOCK_SIZE / 2); in safexcel_hmac_sha3_512_init()
3039 req->len = SHA3_512_BLOCK_SIZE; in safexcel_hmac_sha3_512_init()
3040 req->processed = SHA3_512_BLOCK_SIZE; in safexcel_hmac_sha3_512_init()
3042 req->digest = CONTEXT_CONTROL_DIGEST_HMAC; in safexcel_hmac_sha3_512_init()
3043 req->state_sz = SHA3_512_BLOCK_SIZE / 2; in safexcel_hmac_sha3_512_init()
3044 req->digest_sz = SHA3_512_DIGEST_SIZE; in safexcel_hmac_sha3_512_init()
3045 req->block_sz = SHA3_512_BLOCK_SIZE; in safexcel_hmac_sha3_512_init()
3046 req->hmac = true; in safexcel_hmac_sha3_512_init()
3052 static int safexcel_hmac_sha3_512_digest(struct ahash_request *req) in safexcel_hmac_sha3_512_digest() argument
3054 if (req->nbytes) in safexcel_hmac_sha3_512_digest()
3055 return safexcel_hmac_sha3_512_init(req) ?: in safexcel_hmac_sha3_512_digest()
3056 safexcel_ahash_finup(req); in safexcel_hmac_sha3_512_digest()
3059 return safexcel_sha3_digest_fallback(req); in safexcel_hmac_sha3_512_digest()