Merge pull request #4137
63e342b
crypto: move null_pkey/null_skey to the cpp file (moneromooo-monero)0496c7c
crypto: do not use boost::value_initialized to init null skey/pkey (moneromooo-monero)
This commit is contained in:
commit
5295e4eb82
|
@ -70,6 +70,9 @@ namespace crypto {
|
||||||
#include "random.h"
|
#include "random.h"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const crypto::public_key null_pkey = crypto::public_key{};
|
||||||
|
const crypto::secret_key null_skey = crypto::secret_key{};
|
||||||
|
|
||||||
static inline unsigned char *operator &(ec_point &point) {
|
static inline unsigned char *operator &(ec_point &point) {
|
||||||
return &reinterpret_cast<unsigned char &>(point);
|
return &reinterpret_cast<unsigned char &>(point);
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,6 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <boost/thread/mutex.hpp>
|
#include <boost/thread/mutex.hpp>
|
||||||
#include <boost/thread/lock_guard.hpp>
|
#include <boost/thread/lock_guard.hpp>
|
||||||
#include <boost/utility/value_init.hpp>
|
|
||||||
#include <boost/optional.hpp>
|
#include <boost/optional.hpp>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
@ -278,8 +277,8 @@ namespace crypto {
|
||||||
epee::to_hex::formatted(o, epee::as_byte_span(v)); return o;
|
epee::to_hex::formatted(o, epee::as_byte_span(v)); return o;
|
||||||
}
|
}
|
||||||
|
|
||||||
const static crypto::public_key null_pkey = boost::value_initialized<crypto::public_key>();
|
const extern crypto::public_key null_pkey;
|
||||||
const static crypto::secret_key null_skey = boost::value_initialized<crypto::secret_key>();
|
const extern crypto::secret_key null_skey;
|
||||||
}
|
}
|
||||||
|
|
||||||
CRYPTO_MAKE_HASHABLE(public_key)
|
CRYPTO_MAKE_HASHABLE(public_key)
|
||||||
|
|
|
@ -73,3 +73,11 @@ TEST(Crypto, Ostream)
|
||||||
EXPECT_TRUE(is_formatted<crypto::key_derivation>());
|
EXPECT_TRUE(is_formatted<crypto::key_derivation>());
|
||||||
EXPECT_TRUE(is_formatted<crypto::key_image>());
|
EXPECT_TRUE(is_formatted<crypto::key_image>());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(Crypto, null_keys)
|
||||||
|
{
|
||||||
|
char zero[32];
|
||||||
|
memset(zero, 0, 32);
|
||||||
|
ASSERT_EQ(memcmp(crypto::null_skey.data, zero, 32), 0);
|
||||||
|
ASSERT_EQ(memcmp(crypto::null_pkey.data, zero, 32), 0);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue