aboutsummaryrefslogtreecommitdiff
path: root/src/crypto
diff options
context:
space:
mode:
authorjeffro256 <jeffro256@tutanota.com>2024-08-23 12:15:17 -0500
committerjeffro256 <jeffro256@tutanota.com>2024-09-10 16:07:36 -0500
commit65568d3a884857ce08d1170f5801a6891a5c187c (patch)
treee0685979542aed3ec92b2fe828be15b4ead7564f /src/crypto
parentb089f9ee69924882c5d14dd1a6991deb05d9d1cd (diff)
downloadmonzero-core-65568d3a884857ce08d1170f5801a6891a5c187c.tar.gz
monzero-core-65568d3a884857ce08d1170f5801a6891a5c187c.tar.xz
monzero-core-65568d3a884857ce08d1170f5801a6891a5c187c.zip
build: fix build with Boost 1.85 and remove instances of viewkey logging [RELEASE]
1. Use std::is_standard_layout and std::is_trivially_copyable instead of std::is_pod for KV byte-wise serialization, which fixes compile issue for Boost UUIDs 2. Removed reimplementation of std::hash for boost::uuids::uuid 3. Removed << operator overload for crypto::secret_key 4. Removed instances in code where private view key was dumped to the log in plaintext Release version of #9450, containing C++14 modified assertions
Diffstat (limited to 'src/crypto')
-rw-r--r--src/crypto/crypto.h14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/crypto/crypto.h b/src/crypto/crypto.h
index d8cd6c6a0..ee1cac04a 100644
--- a/src/crypto/crypto.h
+++ b/src/crypto/crypto.h
@@ -171,7 +171,9 @@ namespace crypto {
/* Generate a value filled with random bytes.
*/
template<typename T>
- typename std::enable_if<std::is_pod<T>::value, T>::type rand() {
+ T rand() {
+ static_assert(std::is_standard_layout<T>(), "cannot write random bytes into non-standard layout type");
+ static_assert(std::is_trivially_copyable<T>(), "cannot write random bytes into non-trivially copyable type");
typename std::remove_cv<T>::type res;
generate_random_bytes_thread_safe(sizeof(T), (uint8_t*)&res);
return res;
@@ -314,8 +316,14 @@ namespace crypto {
inline std::ostream &operator <<(std::ostream &o, const crypto::public_key &v) {
epee::to_hex::formatted(o, epee::as_byte_span(v)); return o;
}
- inline std::ostream &operator <<(std::ostream &o, const crypto::secret_key &v) {
- epee::to_hex::formatted(o, epee::as_byte_span(v)); return o;
+ /* Do NOT overload the << operator for crypto::secret_key here. Use secret_key_explicit_print_ref
+ * instead to prevent accidental implicit dumping of secret key material to the logs (which has
+ * happened before). For the same reason, do not overload it for crypto::ec_scalar either since
+ * crypto::secret_key is a subclass. I'm not sorry that it's obtuse; that's the point, bozo.
+ */
+ struct secret_key_explicit_print_ref { const crypto::secret_key &sk; };
+ inline std::ostream &operator <<(std::ostream &o, const secret_key_explicit_print_ref v) {
+ epee::to_hex::formatted(o, epee::as_byte_span(unwrap(unwrap(v.sk)))); return o;
}
inline std::ostream &operator <<(std::ostream &o, const crypto::key_derivation &v) {
epee::to_hex::formatted(o, epee::as_byte_span(v)); return o;