wallet: allow adjusting number of rounds for the key derivation function

This commit is contained in:
stoffu 2018-07-06 15:42:08 +09:00
parent 0dddfeacc9
commit bcab579864
No known key found for this signature in database
GPG key ID: 41DAB8343A9EC012
14 changed files with 76 additions and 52 deletions

View file

@ -531,20 +531,20 @@ namespace hw {
return true;
}
bool device_ledger::generate_chacha_key(const cryptonote::account_keys &keys, crypto::chacha_key &key) {
bool device_ledger::generate_chacha_key(const cryptonote::account_keys &keys, crypto::chacha_key &key, uint64_t kdf_rounds) {
AUTO_LOCK_CMD();
#ifdef DEBUG_HWDEVICE
crypto::chacha_key key_x;
cryptonote::account_keys keys_x = hw::ledger::decrypt(keys);
this->controle_device->generate_chacha_key(keys_x, key_x);
this->controle_device->generate_chacha_key(keys_x, key_x, kdf_rounds);
#endif
send_simple(INS_GET_CHACHA8_PREKEY);
char prekey[200];
memmove(prekey, &this->buffer_recv[0], 200);
crypto::generate_chacha_key_prehashed(&prekey[0], sizeof(prekey), key);
crypto::generate_chacha_key_prehashed(&prekey[0], sizeof(prekey), key, kdf_rounds);
#ifdef DEBUG_HWDEVICE
hw::ledger::check32("generate_chacha_key_prehashed", "key", (char*)key_x.data(), (char*)key.data());