xref: /openbmc/linux/crypto/hash.h (revision ed3630b8)
142808e5dSHerbert Xu /* SPDX-License-Identifier: GPL-2.0-or-later */
242808e5dSHerbert Xu /*
342808e5dSHerbert Xu  * Cryptographic API.
442808e5dSHerbert Xu  *
542808e5dSHerbert Xu  * Copyright (c) 2023 Herbert Xu <herbert@gondor.apana.org.au>
642808e5dSHerbert Xu  */
742808e5dSHerbert Xu #ifndef _LOCAL_CRYPTO_HASH_H
842808e5dSHerbert Xu #define _LOCAL_CRYPTO_HASH_H
942808e5dSHerbert Xu 
1042808e5dSHerbert Xu #include <crypto/internal/hash.h>
1142808e5dSHerbert Xu #include <linux/cryptouser.h>
1242808e5dSHerbert Xu 
1342808e5dSHerbert Xu #include "internal.h"
1442808e5dSHerbert Xu 
crypto_hash_report_stat(struct sk_buff * skb,struct crypto_alg * alg,const char * type)1542808e5dSHerbert Xu static inline int crypto_hash_report_stat(struct sk_buff *skb,
1642808e5dSHerbert Xu 					  struct crypto_alg *alg,
1742808e5dSHerbert Xu 					  const char *type)
1842808e5dSHerbert Xu {
1942808e5dSHerbert Xu 	struct hash_alg_common *halg = __crypto_hash_alg_common(alg);
2042808e5dSHerbert Xu 	struct crypto_istat_hash *istat = hash_get_stat(halg);
2142808e5dSHerbert Xu 	struct crypto_stat_hash rhash;
2242808e5dSHerbert Xu 
2342808e5dSHerbert Xu 	memset(&rhash, 0, sizeof(rhash));
2442808e5dSHerbert Xu 
2542808e5dSHerbert Xu 	strscpy(rhash.type, type, sizeof(rhash.type));
2642808e5dSHerbert Xu 
2742808e5dSHerbert Xu 	rhash.stat_hash_cnt = atomic64_read(&istat->hash_cnt);
2842808e5dSHerbert Xu 	rhash.stat_hash_tlen = atomic64_read(&istat->hash_tlen);
2942808e5dSHerbert Xu 	rhash.stat_err_cnt = atomic64_read(&istat->err_cnt);
3042808e5dSHerbert Xu 
3142808e5dSHerbert Xu 	return nla_put(skb, CRYPTOCFGA_STAT_HASH, sizeof(rhash), &rhash);
3242808e5dSHerbert Xu }
3342808e5dSHerbert Xu 
34*ed3630b8SHerbert Xu int crypto_init_shash_ops_async(struct crypto_tfm *tfm);
35*ed3630b8SHerbert Xu struct crypto_ahash *crypto_clone_shash_ops_async(struct crypto_ahash *nhash,
36*ed3630b8SHerbert Xu 						  struct crypto_ahash *hash);
37*ed3630b8SHerbert Xu 
3842808e5dSHerbert Xu int hash_prepare_alg(struct hash_alg_common *alg);
3942808e5dSHerbert Xu 
4042808e5dSHerbert Xu #endif	/* _LOCAL_CRYPTO_HASH_H */
41