Skip to content

Commit

Permalink
Merge pull request #53 from brave-intl/recovery_key_fix
Browse files Browse the repository at this point in the history
Fix:Recovery keys from muon are not working #40
  • Loading branch information
SergeyZhukovsky committed Aug 22, 2018
2 parents 7bb0719 + b600bb1 commit 5428f82
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/bat_helper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1326,8 +1326,10 @@ namespace braveledger_bat_helper {
std::vector<uint8_t> getHKDF(const std::vector<uint8_t>& seed) {
DCHECK(!seed.empty());
std::vector<uint8_t> out(SEED_LENGTH);

const uint8_t info[] = {0};
int hkdfRes = HKDF(&out.front(), SEED_LENGTH, EVP_sha512(), &seed.front(), seed.size(),
braveledger_ledger::g_hkdfSalt, SALT_LENGTH, nullptr, 0);
braveledger_ledger::g_hkdfSalt, SALT_LENGTH, info, sizeof(info) / sizeof(info[0]));

DCHECK(hkdfRes);
DCHECK(!seed.empty());
Expand Down Expand Up @@ -1553,14 +1555,19 @@ namespace braveledger_bat_helper {

if (succeded) {
out.resize(size);
int numDecBytes = EVP_DecodeBase64(&out.front(), &size, size, (const uint8_t*)in.c_str(), in.length());
size_t final_size = 0;
int numDecBytes = EVP_DecodeBase64(&out.front(), &final_size, size, (const uint8_t*)in.c_str(), in.length());
DCHECK(numDecBytes != 0);
LOG(ERROR) << "!!!decoded size == " << size;
LOG(ERROR) << "!!!decoded size == " << final_size;

if (0 == numDecBytes) {
succeded = false;
out.clear();
}
else if (final_size != size)
{
out.resize(final_size);
}
}
return succeded;
}
Expand Down

0 comments on commit 5428f82

Please sign in to comment.