summaryrefslogtreecommitdiffstats
path: root/include/crypto
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2016-01-22 23:17:58 +0800
committerHerbert Xu <herbert@gondor.apana.org.au>2016-01-25 22:42:11 +0800
commite67ffe0af4d450e95e5f9bb7d081500e30777857 (patch)
tree98409c608f62e24177d8ee1b92c76d3861fbf5dc /include/crypto
parentb3614763059b82c26bdd02ffcb1c016c1132aad0 (diff)
downloadlinux-e67ffe0af4d450e95e5f9bb7d081500e30777857.tar.bz2
crypto: hash - Add helpers to zero stack request/descriptor
As the size of an ahash_request or shash_desc is variable, it's awkward to zero them explicitly. This patch adds helpers to do that which should be used when they are created on the stack. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'include/crypto')
-rw-r--r--include/crypto/hash.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/include/crypto/hash.h b/include/crypto/hash.h
index 6361892ea737..aef819247fe8 100644
--- a/include/crypto/hash.h
+++ b/include/crypto/hash.h
@@ -14,6 +14,7 @@
#define _CRYPTO_HASH_H
#include <linux/crypto.h>
+#include <linux/string.h>
struct crypto_ahash;
@@ -550,6 +551,12 @@ static inline void ahash_request_free(struct ahash_request *req)
kzfree(req);
}
+static inline void ahash_request_zero(struct ahash_request *req)
+{
+ memzero_explicit(req, sizeof(*req) +
+ crypto_ahash_reqsize(crypto_ahash_reqtfm(req)));
+}
+
static inline struct ahash_request *ahash_request_cast(
struct crypto_async_request *req)
{
@@ -872,4 +879,10 @@ int crypto_shash_final(struct shash_desc *desc, u8 *out);
int crypto_shash_finup(struct shash_desc *desc, const u8 *data,
unsigned int len, u8 *out);
+static inline void shash_desc_zero(struct shash_desc *desc)
+{
+ memzero_explicit(desc,
+ sizeof(*desc) + crypto_shash_descsize(desc->tfm));
+}
+
#endif /* _CRYPTO_HASH_H */