aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorMark Haines <mark.haines@matrix.org>2015-03-03 15:08:56 +0000
committerMark Haines <mark.haines@matrix.org>2015-03-03 15:08:56 +0000
commit8123ce62094bf88a4107506d7acd3e8e2866bc1f (patch)
treee7c4284ffbe620deebefc6c1a2db7d77c880553a /include
parent2f2e0340ae46fb37421e13108fae71e710b5515b (diff)
Constant time comparison for mac
Diffstat (limited to 'include')
-rw-r--r--include/axolotl/memory.hh11
1 files changed, 9 insertions, 2 deletions
diff --git a/include/axolotl/memory.hh b/include/axolotl/memory.hh
index 7749c54..8313a19 100644
--- a/include/axolotl/memory.hh
+++ b/include/axolotl/memory.hh
@@ -1,17 +1,24 @@
#include <cstddef>
+#include <cstdint>
namespace axolotl {
/** Clear the memory held in the buffer */
void unset(
- volatile void * buffer, std::size_t buffer_length
+ void volatile * buffer, std::size_t buffer_length
);
/** Clear the memory backing an object */
template<typename T>
void unset(T & value) {
- unset(reinterpret_cast<volatile void *>(&value), sizeof(T));
+ unset(reinterpret_cast<void volatile *>(&value), sizeof(T));
}
+/** Check if two buffers are equal in constant time. */
+bool is_equal(
+ std::uint8_t const * buffer_a,
+ std::uint8_t const * buffer_b,
+ std::size_t length
+);
} // namespace axolotl