162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * Cryptographic API.
462306a36Sopenharmony_ci *
562306a36Sopenharmony_ci * Copyright (c) 2023 Herbert Xu <herbert@gondor.apana.org.au>
662306a36Sopenharmony_ci */
762306a36Sopenharmony_ci#ifndef _LOCAL_CRYPTO_HASH_H
862306a36Sopenharmony_ci#define _LOCAL_CRYPTO_HASH_H
962306a36Sopenharmony_ci
1062306a36Sopenharmony_ci#include <crypto/internal/hash.h>
1162306a36Sopenharmony_ci#include <linux/cryptouser.h>
1262306a36Sopenharmony_ci
1362306a36Sopenharmony_ci#include "internal.h"
1462306a36Sopenharmony_ci
1562306a36Sopenharmony_cistatic inline int crypto_hash_report_stat(struct sk_buff *skb,
1662306a36Sopenharmony_ci					  struct crypto_alg *alg,
1762306a36Sopenharmony_ci					  const char *type)
1862306a36Sopenharmony_ci{
1962306a36Sopenharmony_ci	struct hash_alg_common *halg = __crypto_hash_alg_common(alg);
2062306a36Sopenharmony_ci	struct crypto_istat_hash *istat = hash_get_stat(halg);
2162306a36Sopenharmony_ci	struct crypto_stat_hash rhash;
2262306a36Sopenharmony_ci
2362306a36Sopenharmony_ci	memset(&rhash, 0, sizeof(rhash));
2462306a36Sopenharmony_ci
2562306a36Sopenharmony_ci	strscpy(rhash.type, type, sizeof(rhash.type));
2662306a36Sopenharmony_ci
2762306a36Sopenharmony_ci	rhash.stat_hash_cnt = atomic64_read(&istat->hash_cnt);
2862306a36Sopenharmony_ci	rhash.stat_hash_tlen = atomic64_read(&istat->hash_tlen);
2962306a36Sopenharmony_ci	rhash.stat_err_cnt = atomic64_read(&istat->err_cnt);
3062306a36Sopenharmony_ci
3162306a36Sopenharmony_ci	return nla_put(skb, CRYPTOCFGA_STAT_HASH, sizeof(rhash), &rhash);
3262306a36Sopenharmony_ci}
3362306a36Sopenharmony_ci
3462306a36Sopenharmony_ciint crypto_init_shash_ops_async(struct crypto_tfm *tfm);
3562306a36Sopenharmony_cistruct crypto_ahash *crypto_clone_shash_ops_async(struct crypto_ahash *nhash,
3662306a36Sopenharmony_ci						  struct crypto_ahash *hash);
3762306a36Sopenharmony_ci
3862306a36Sopenharmony_ciint hash_prepare_alg(struct hash_alg_common *alg);
3962306a36Sopenharmony_ci
4062306a36Sopenharmony_ci#endif	/* _LOCAL_CRYPTO_HASH_H */
41