aboutsummaryrefslogtreecommitdiff
path: root/src/ringct
diff options
context:
space:
mode:
authorluigi1111 <luigi1111w@gmail.com>2018-08-23 14:03:09 -0500
committerluigi1111 <luigi1111w@gmail.com>2018-08-23 14:03:09 -0500
commitfa7cdd642074adb5899362aefcced4505d75f681 (patch)
tree78381c86a73e46cc265d58dd9ff770fd56a1ec99 /src/ringct
parentMerge pull request #4249 (diff)
parentadd and use constant time 32 byte equality function (diff)
downloadmonero-fa7cdd642074adb5899362aefcced4505d75f681.tar.xz
Merge pull request #3999
d2e26c2 add and use constant time 32 byte equality function (moneromooo-monero)
Diffstat (limited to 'src/ringct')
-rw-r--r--src/ringct/rctTypes.h15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/ringct/rctTypes.h b/src/ringct/rctTypes.h
index a3ccf2e85..452a68eb2 100644
--- a/src/ringct/rctTypes.h
+++ b/src/ringct/rctTypes.h
@@ -36,6 +36,7 @@
#include <vector>
#include <iostream>
#include <cinttypes>
+#include <sodium/crypto_verify_32.h>
extern "C" {
#include "crypto/crypto-ops.h"
@@ -81,7 +82,7 @@ namespace rct {
unsigned char operator[](int i) const {
return bytes[i];
}
- bool operator==(const key &k) const { return !memcmp(bytes, k.bytes, sizeof(bytes)); }
+ bool operator==(const key &k) const { return !crypto_verify_32(bytes, k.bytes); }
unsigned char bytes[32];
};
typedef std::vector<key> keyV; //vector of keys
@@ -524,16 +525,16 @@ namespace rct {
static inline const crypto::secret_key rct2sk(const rct::key &k) { return (const crypto::secret_key&)k; }
static inline const crypto::key_image rct2ki(const rct::key &k) { return (const crypto::key_image&)k; }
static inline const crypto::hash rct2hash(const rct::key &k) { return (const crypto::hash&)k; }
- static inline bool operator==(const rct::key &k0, const crypto::public_key &k1) { return !memcmp(&k0, &k1, 32); }
- static inline bool operator!=(const rct::key &k0, const crypto::public_key &k1) { return memcmp(&k0, &k1, 32); }
+ static inline bool operator==(const rct::key &k0, const crypto::public_key &k1) { return !crypto_verify_32(k0.bytes, (const unsigned char*)&k1); }
+ static inline bool operator!=(const rct::key &k0, const crypto::public_key &k1) { return crypto_verify_32(k0.bytes, (const unsigned char*)&k1); }
}
namespace cryptonote {
- static inline bool operator==(const crypto::public_key &k0, const rct::key &k1) { return !memcmp(&k0, &k1, 32); }
- static inline bool operator!=(const crypto::public_key &k0, const rct::key &k1) { return memcmp(&k0, &k1, 32); }
- static inline bool operator==(const crypto::secret_key &k0, const rct::key &k1) { return !memcmp(&k0, &k1, 32); }
- static inline bool operator!=(const crypto::secret_key &k0, const rct::key &k1) { return memcmp(&k0, &k1, 32); }
+ static inline bool operator==(const crypto::public_key &k0, const rct::key &k1) { return !crypto_verify_32((const unsigned char*)&k0, k1.bytes); }
+ static inline bool operator!=(const crypto::public_key &k0, const rct::key &k1) { return crypto_verify_32((const unsigned char*)&k0, k1.bytes); }
+ static inline bool operator==(const crypto::secret_key &k0, const rct::key &k1) { return !crypto_verify_32((const unsigned char*)&k0, k1.bytes); }
+ static inline bool operator!=(const crypto::secret_key &k0, const rct::key &k1) { return crypto_verify_32((const unsigned char*)&k0, k1.bytes); }
}
namespace rct {