summaryrefslogtreecommitdiffstats
path: root/crypto/md32_common.h
diff options
context:
space:
mode:
authorMatt Caswell <matt@openssl.org>2016-06-24 23:37:27 +0100
committerMatt Caswell <matt@openssl.org>2016-06-30 15:56:16 +0100
commitbeaa2c03e70b523f006003a489497a18b4d53e6c (patch)
treefcd0f3495784be1fca2e2ef6c5154886fcbacdc6 /crypto/md32_common.h
parent08327bfb261eea4a3c356d6ebff81d838f063d1b (diff)
Convert memset calls to OPENSSL_cleanse
Ensure things really do get cleared when we intend them to. Addresses an OCAP Audit issue. Reviewed-by: Andy Polyakov <appro@openssl.org> (cherry picked from commit cb5ebf961333896776fbce10ef88c2af7bec8aea)
Diffstat (limited to 'crypto/md32_common.h')
-rw-r--r--crypto/md32_common.h10
1 files changed, 9 insertions, 1 deletions
diff --git a/crypto/md32_common.h b/crypto/md32_common.h
index 1823833419..aac719139e 100644
--- a/crypto/md32_common.h
+++ b/crypto/md32_common.h
@@ -109,6 +109,8 @@
* <appro@fy.chalmers.se>
*/
+#include <openssl/crypto.h>
+
#if !defined(DATA_ORDER_IS_BIG_ENDIAN) && !defined(DATA_ORDER_IS_LITTLE_ENDIAN)
# error "DATA_ORDER must be defined!"
#endif
@@ -311,6 +313,12 @@ int HASH_UPDATE(HASH_CTX *c, const void *data_, size_t len)
data += n;
len -= n;
c->num = 0;
+ /*
+ * We use memset rather than OPENSSL_cleanse() here deliberately.
+ * Using OPENSSL_cleanse() here could be a performance issue. It
+ * will get properly cleansed on finalisation so this isn't a
+ * security problem.
+ */
memset(p, 0, HASH_CBLOCK); /* keep it zeroed */
} else {
memcpy(p + n, data, len);
@@ -366,7 +374,7 @@ int HASH_FINAL(unsigned char *md, HASH_CTX *c)
p -= HASH_CBLOCK;
HASH_BLOCK_DATA_ORDER(c, p, 1);
c->num = 0;
- memset(p, 0, HASH_CBLOCK);
+ OPENSSL_cleanse(p, HASH_CBLOCK);
#ifndef HASH_MAKE_STRING
# error "HASH_MAKE_STRING must be defined!"