1 /* SPDX-License-Identifier: GPL-2.0-or-later */
5 * Copyright (c) 2023 Herbert Xu <herbert@gondor.apana.org.au>
7 #ifndef _LOCAL_CRYPTO_HASH_H
8 #define _LOCAL_CRYPTO_HASH_H
10 #include <crypto/internal/hash.h>
11 #include <linux/cryptouser.h>
15 static inline struct crypto_istat_hash
*hash_get_stat(
16 struct hash_alg_common
*alg
)
18 #ifdef CONFIG_CRYPTO_STATS
25 static inline int crypto_hash_report_stat(struct sk_buff
*skb
,
26 struct crypto_alg
*alg
,
29 struct hash_alg_common
*halg
= __crypto_hash_alg_common(alg
);
30 struct crypto_istat_hash
*istat
= hash_get_stat(halg
);
31 struct crypto_stat_hash rhash
;
33 memset(&rhash
, 0, sizeof(rhash
));
35 strscpy(rhash
.type
, type
, sizeof(rhash
.type
));
37 rhash
.stat_hash_cnt
= atomic64_read(&istat
->hash_cnt
);
38 rhash
.stat_hash_tlen
= atomic64_read(&istat
->hash_tlen
);
39 rhash
.stat_err_cnt
= atomic64_read(&istat
->err_cnt
);
41 return nla_put(skb
, CRYPTOCFGA_STAT_HASH
, sizeof(rhash
), &rhash
);
44 extern const struct crypto_type crypto_shash_type
;
46 int hash_prepare_alg(struct hash_alg_common
*alg
);
48 #endif /* _LOCAL_CRYPTO_HASH_H */