aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2020-02-14 09:18:48 -0500
committerJack Lloyd <[email protected]>2020-02-14 09:18:48 -0500
commit0477bd6b2d3eb66822ea36c76b853bc2fda9836c (patch)
tree0e41606b965f7a61c982461abca882d85624ae15 /src/lib
parente25bf12486ca6c791dba89055b1fc515a1044a4c (diff)
Small cleanups
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/pubkey/newhope/newhope.cpp5
-rw-r--r--src/lib/pubkey/newhope/newhope.h4
-rw-r--r--src/lib/utils/mem_ops.h9
3 files changed, 12 insertions, 6 deletions
diff --git a/src/lib/pubkey/newhope/newhope.cpp b/src/lib/pubkey/newhope/newhope.cpp
index 3a5069636..6a0440139 100644
--- a/src/lib/pubkey/newhope/newhope.cpp
+++ b/src/lib/pubkey/newhope/newhope.cpp
@@ -17,6 +17,11 @@
namespace Botan {
+newhope_poly::~newhope_poly()
+ {
+ secure_scrub_memory(coeffs, sizeof(coeffs));
+ }
+
typedef newhope_poly poly;
namespace {
diff --git a/src/lib/pubkey/newhope/newhope.h b/src/lib/pubkey/newhope/newhope.h
index 3b6df1c21..291c9e76b 100644
--- a/src/lib/pubkey/newhope/newhope.h
+++ b/src/lib/pubkey/newhope/newhope.h
@@ -12,7 +12,7 @@
#ifndef BOTAN_NEWHOPE_H_
#define BOTAN_NEWHOPE_H_
-#include <botan/mem_ops.h>
+#include <botan/types.h>
namespace Botan {
@@ -29,7 +29,7 @@ class newhope_poly final
{
public:
uint16_t coeffs[1024];
- ~newhope_poly() { secure_scrub_memory(coeffs, sizeof(coeffs)); }
+ ~newhope_poly();
};
enum Newhope_Params
diff --git a/src/lib/utils/mem_ops.h b/src/lib/utils/mem_ops.h
index ea811ee50..c1e451b48 100644
--- a/src/lib/utils/mem_ops.h
+++ b/src/lib/utils/mem_ops.h
@@ -87,7 +87,10 @@ inline bool constant_time_compare(const uint8_t x[],
}
/**
-* Zero out some bytes
+* Zero out some bytes. Warning: use secure_scrub_memory instead if the
+* memory is about to be freed or otherwise the compiler thinks it can
+* elide the writes.
+*
* @param ptr a pointer to memory to zero
* @param bytes the number of bytes to zero in ptr
*/
@@ -114,10 +117,8 @@ template<typename T> inline void clear_mem(T* ptr, size_t n)
clear_bytes(ptr, sizeof(T)*n);
}
-
-
// is_trivially_copyable is missing in g++ < 5.0
-#if !__clang__ && __GNUG__ && __GNUC__ < 5
+#if (BOTAN_GCC_VERSION > 0 && BOTAN_GCC_VERSION < 500)
#define BOTAN_IS_TRIVIALLY_COPYABLE(T) true
#else
#define BOTAN_IS_TRIVIALLY_COPYABLE(T) std::is_trivially_copyable<T>::value