mirror of
https://git.wownero.com/wownero/onion-wownero-blockchain-explorer.git
synced 2024-08-15 00:33:12 +00:00
decrypt function updated and authentication enabled for key images raw data
This commit is contained in:
parent
e08b45e2b3
commit
827f7541c6
2 changed files with 18 additions and 19 deletions
17
src/page.h
17
src/page.h
|
@ -2027,11 +2027,15 @@ namespace xmreg {
|
|||
}
|
||||
|
||||
// decrypt key images data using private view key
|
||||
// dont use authentication (i.e., false), as we are
|
||||
// not interested if this key image data is properly signed
|
||||
decoded_raw_data = xmreg::decrypt(
|
||||
std::string(decoded_raw_data, magiclen),
|
||||
prv_view_key, false);
|
||||
prv_view_key, true);
|
||||
|
||||
if (decoded_raw_data.empty())
|
||||
{
|
||||
return string {"Failed to authenticate key images data. "
|
||||
"Maybe wrong viewkey was porvided?"};
|
||||
}
|
||||
|
||||
// header is public spend and keys
|
||||
const size_t header_lenght = 2 * sizeof(crypto::public_key);
|
||||
|
@ -2039,13 +2043,6 @@ namespace xmreg {
|
|||
const size_t record_lenght = key_img_size + sizeof(crypto::signature);
|
||||
const size_t chacha_length = sizeof(crypto::chacha8_key);
|
||||
|
||||
|
||||
// cout << header_lenght << endl;
|
||||
// cout << key_img_size << endl;
|
||||
// cout << record_lenght << endl;
|
||||
// cout << decoded_raw_data.size() - header_lenght << endl;
|
||||
// cout << (decoded_raw_data.size() - header_lenght) % record_lenght << endl;
|
||||
|
||||
if (decoded_raw_data.size() < header_lenght)
|
||||
{
|
||||
cerr << "Bad data size from submitted key images raw data" << endl;
|
||||
|
|
|
@ -793,16 +793,18 @@ namespace xmreg
|
|||
const crypto::secret_key &skey,
|
||||
bool authenticated)
|
||||
{
|
||||
|
||||
const size_t prefix_size = sizeof(chacha8_iv)
|
||||
+ (authenticated ? sizeof(crypto::signature) : 0);
|
||||
|
||||
crypto::chacha8_key key;
|
||||
|
||||
crypto::generate_chacha8_key(&skey, sizeof(skey), key);
|
||||
|
||||
const crypto::chacha8_iv &iv = *(const crypto::chacha8_iv*)&ciphertext[0];
|
||||
|
||||
std::string plaintext;
|
||||
|
||||
plaintext.resize(ciphertext.size() - sizeof(iv) -
|
||||
(authenticated ? sizeof(crypto::signature) : 0));
|
||||
plaintext.resize(ciphertext.size() - prefix_size);
|
||||
|
||||
if (authenticated)
|
||||
{
|
||||
|
@ -811,8 +813,9 @@ namespace xmreg
|
|||
crypto::public_key pkey;
|
||||
crypto::secret_key_to_public_key(skey, pkey);
|
||||
|
||||
const crypto::signature &signature
|
||||
= *(const crypto::signature*)&ciphertext[ciphertext.size() - sizeof(crypto::signature)];
|
||||
const crypto::signature &signature =
|
||||
*(const crypto::signature*)&ciphertext[ciphertext.size()
|
||||
- sizeof(crypto::signature)];
|
||||
|
||||
if (!crypto::check_signature(hash, pkey, signature))
|
||||
{
|
||||
|
@ -822,10 +825,9 @@ namespace xmreg
|
|||
|
||||
}
|
||||
|
||||
crypto::chacha8(
|
||||
ciphertext.data() + sizeof(iv),
|
||||
ciphertext.size() - sizeof(iv),
|
||||
key, iv, &plaintext[0]);
|
||||
crypto::chacha8(ciphertext.data() + sizeof(iv),
|
||||
ciphertext.size() - prefix_size,
|
||||
key, iv, &plaintext[0]);
|
||||
|
||||
return plaintext;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue