wallet2: reject zero keys in json input

Because the user might do this for reasons unknown.
Values beyond l-1 will be reduced, so are accepted.

Reported by who-biz.
This commit is contained in:
moneromooo-monero 2020-01-16 19:56:47 +00:00
parent e49a055e89
commit 50e59cfada
No known key found for this signature in database
GPG Key ID: 686F07454D6CEFC3

View File

@ -591,6 +591,8 @@ std::pair<std::unique_ptr<tools::wallet2>, tools::password_container> generate_f
} }
viewkey = *reinterpret_cast<const crypto::secret_key*>(viewkey_data.data()); viewkey = *reinterpret_cast<const crypto::secret_key*>(viewkey_data.data());
crypto::public_key pkey; crypto::public_key pkey;
if (viewkey == crypto::null_skey)
THROW_WALLET_EXCEPTION(tools::error::wallet_internal_error, tools::wallet2::tr("view secret key may not be all zeroes"));
if (!crypto::secret_key_to_public_key(viewkey, pkey)) { if (!crypto::secret_key_to_public_key(viewkey, pkey)) {
THROW_WALLET_EXCEPTION(tools::error::wallet_internal_error, tools::wallet2::tr("failed to verify view key secret key")); THROW_WALLET_EXCEPTION(tools::error::wallet_internal_error, tools::wallet2::tr("failed to verify view key secret key"));
} }
@ -607,6 +609,8 @@ std::pair<std::unique_ptr<tools::wallet2>, tools::password_container> generate_f
} }
spendkey = *reinterpret_cast<const crypto::secret_key*>(spendkey_data.data()); spendkey = *reinterpret_cast<const crypto::secret_key*>(spendkey_data.data());
crypto::public_key pkey; crypto::public_key pkey;
if (spendkey == crypto::null_skey)
THROW_WALLET_EXCEPTION(tools::error::wallet_internal_error, tools::wallet2::tr("spend secret key may not be all zeroes"));
if (!crypto::secret_key_to_public_key(spendkey, pkey)) { if (!crypto::secret_key_to_public_key(spendkey, pkey)) {
THROW_WALLET_EXCEPTION(tools::error::wallet_internal_error, tools::wallet2::tr("failed to verify spend key secret key")); THROW_WALLET_EXCEPTION(tools::error::wallet_internal_error, tools::wallet2::tr("failed to verify spend key secret key"));
} }