diff mbox series

[v2,5/6] crypto: ahash - Add HASH_REQUEST_ZERO

Message ID 5ace4b5c14b466dfe51b1b24cb6ed304dc2bf8e5.1746365585.git.herbert@gondor.apana.org.au
State New
Headers show
Series [v2,1/6] crypto: shash - Cap state size to HASH_MAX_STATESIZE | expand

Commit Message

Herbert Xu May 4, 2025, 1:33 p.m. UTC
Add a helper to zero hash stack requests that were never cloned
off the stack.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
---
 include/crypto/internal/hash.h | 4 ++++
 1 file changed, 4 insertions(+)
diff mbox series

Patch

diff --git a/include/crypto/internal/hash.h b/include/crypto/internal/hash.h
index e911f32f46dc..f2bbdb74e11a 100644
--- a/include/crypto/internal/hash.h
+++ b/include/crypto/internal/hash.h
@@ -301,5 +301,9 @@  static inline unsigned int crypto_shash_coresize(struct crypto_shash *tfm)
 	return crypto_shash_statesize(tfm) - crypto_shash_blocksize(tfm) - 1;
 }
 
+/* This can only be used if the request was never cloned. */
+#define HASH_REQUEST_ZERO(name) \
+	memzero_explicit(__##name##_req, sizeof(__##name##_req))
+
 #endif	/* _CRYPTO_INTERNAL_HASH_H */