diff --git a/alethzero/Main.ui b/alethzero/Main.ui
index 8319e11ef..5e86ee59a 100644
--- a/alethzero/Main.ui
+++ b/alethzero/Main.ui
@@ -1756,7 +1756,7 @@ font-size: 14pt
- Import Key &File...
+ Claim Ether Presale &Wallet...
diff --git a/alethzero/MainWin.cpp b/alethzero/MainWin.cpp
index 114712f24..85c8ddb32 100644
--- a/alethzero/MainWin.cpp
+++ b/alethzero/MainWin.cpp
@@ -564,8 +564,7 @@ void Main::on_importKey_triggered()
if (std::find(m_myKeys.begin(), m_myKeys.end(), k) == m_myKeys.end())
{
m_myKeys.append(k);
- m_keysChanged = true;
- update();
+ keysChanged();
}
else
QMessageBox::warning(this, "Already Have Key", "Could not import the secret key: we already own this account.");
@@ -585,20 +584,29 @@ void Main::on_importKeyFile_triggered()
if (obj["encseed"].type() == js::str_type)
{
auto encseed = fromHex(obj["encseed"].get_str());
- KeyPair k = KeyPair::fromEncryptedSeed(&encseed, QInputDialog::getText(this, "Enter Password", "Enter the wallet's passphrase", QLineEdit::Password).toStdString());
- if (obj["ethaddr"].type() == js::str_type)
+ KeyPair k;
+ for (bool gotit = false; !gotit;)
{
- Address a(obj["ethaddr"].get_str());
- Address b = k.address();
- if (a != b && QMessageBox::warning(this, "Key File Invalid", "Could not import the secret key: it doesn't agree with the given address.\nWould you like to attempt to import anyway?", QMessageBox::Yes | QMessageBox::No) == QMessageBox::No)
- return;
+ gotit = true;
+ k = KeyPair::fromEncryptedSeed(&encseed, QInputDialog::getText(this, "Enter Password", "Enter the wallet's passphrase", QLineEdit::Password).toStdString());
+ if (obj["ethaddr"].type() == js::str_type)
+ {
+ Address a(obj["ethaddr"].get_str());
+ Address b = k.address();
+ if (a != b)
+ {
+ if (QMessageBox::warning(this, "Password Wrong", "Could not import the secret key: the password you gave appears to be wrong.", QMessageBox::Retry, QMessageBox::Cancel) == QMessageBox::Cancel)
+ return;
+ else
+ gotit = false;
+ }
+ }
}
if (std::find(m_myKeys.begin(), m_myKeys.end(), k) == m_myKeys.end())
{
m_myKeys.append(k);
- m_keysChanged = true;
- update();
+ keysChanged();
}
else
QMessageBox::warning(this, "Already Have Key", "Could not import the secret key: we already own this account.");
@@ -1587,6 +1595,11 @@ void Main::on_send_clicked()
statusBar()->showMessage("Couldn't make transaction: no single account contains at least the required amount.");
}
+void Main::keysChanged()
+{
+ onBalancesChange();
+}
+
void Main::on_debug_clicked()
{
debugFinished();
@@ -1623,7 +1636,7 @@ void Main::on_debug_clicked()
void Main::on_create_triggered()
{
m_myKeys.append(KeyPair::create());
- m_keysChanged = true;
+ keysChanged();
}
void Main::on_debugStep_triggered()
diff --git a/alethzero/MainWin.h b/alethzero/MainWin.h
index f79e9ace8..c83848cdd 100644
--- a/alethzero/MainWin.h
+++ b/alethzero/MainWin.h
@@ -184,6 +184,8 @@ private:
unsigned installWatch(dev::eth::MessageFilter const& _tf, std::function const& _f);
unsigned installWatch(dev::h256 _tf, std::function const& _f);
+ void keysChanged();
+
void onNewPending();
void onNewBlock();
void onNameRegChange();
@@ -221,7 +223,6 @@ private:
QStringList m_servers;
QList m_myKeys;
QString m_privateChain;
- bool m_keysChanged = false;
dev::bytes m_data;
dev::Address m_nameReg;
diff --git a/libdevcrypto/SHA3.cpp b/libdevcrypto/SHA3.cpp
index e1da1261e..4c5ee9fae 100644
--- a/libdevcrypto/SHA3.cpp
+++ b/libdevcrypto/SHA3.cpp
@@ -72,21 +72,25 @@ h256 sha3(bytesConstRef _input)
return ret;
}
-bytes aesDecrypt(bytesConstRef _cipher, std::string const& _password, unsigned _rounds, bytesConstRef _salt)
+bytes aesDecrypt(bytesConstRef _ivCipher, std::string const& _password, unsigned _rounds, bytesConstRef _salt)
{
bytes pw = asBytes(_password);
- bytes target(CryptoPP::AES::DEFAULT_KEYLENGTH);
+ if (!_salt.size())
+ _salt = &pw;
+
+ bytes target(64);
CryptoPP::PKCS5_PBKDF2_HMAC().DeriveKey(target.data(), target.size(), 0, pw.data(), pw.size(), _salt.data(), _salt.size(), _rounds);
try
{
- CryptoPP::AES::Decryption aesDecryption(target.data(), target.size());
- bytes iv(CryptoPP::AES::BLOCKSIZE);
+ CryptoPP::AES::Decryption aesDecryption(target.data(), 16);
+ auto cipher = _ivCipher.cropped(16);
+ auto iv = _ivCipher.cropped(0, 16);
CryptoPP::CBC_Mode_ExternalCipher::Decryption cbcDecryption(aesDecryption, iv.data());
std::string decrypted;
CryptoPP::StreamTransformationFilter stfDecryptor(cbcDecryption, new CryptoPP::StringSink(decrypted));
- stfDecryptor.Put(_cipher.data(), _cipher.size());
+ stfDecryptor.Put(cipher.data(), cipher.size());
stfDecryptor.MessageEnd();
return asBytes(decrypted);
}