mirror of
https://git.h3cjp.net/H3cJP/yuzu.git
synced 2024-12-16 15:55:30 +00:00
key_manager: Eliminate indexed for loop
This commit is contained in:
parent
119ab308b5
commit
ccfd176382
|
@ -100,14 +100,21 @@ Loader::ResultStatus DeriveSDKeys(std::array<Key256, 2>& sd_keys, const KeyManag
|
||||||
keys.GetKey(S256KeyType::SDKeySource, static_cast<u64>(SDKeyType::NCA)),
|
keys.GetKey(S256KeyType::SDKeySource, static_cast<u64>(SDKeyType::NCA)),
|
||||||
};
|
};
|
||||||
|
|
||||||
AESCipher<Key128> cipher(sd_kek, Mode::ECB);
|
// Combine sources and seed
|
||||||
for (size_t i = 0; i < 2; ++i) {
|
for (auto& source : sd_key_sources) {
|
||||||
for (size_t j = 0; j < sd_key_sources[i].size(); ++j)
|
for (size_t i = 0; i < source.size(); ++i)
|
||||||
sd_key_sources[i][j] ^= sd_seed[j & 0xF];
|
source[i] ^= sd_seed[i & 0xF];
|
||||||
cipher.Transcode(sd_key_sources[i].data(), sd_key_sources[i].size(), sd_keys[i].data(),
|
|
||||||
Op::Decrypt);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AESCipher<Key128> cipher(sd_kek, Mode::ECB);
|
||||||
|
// The transform manipulates sd_keys as part of the Transcode, so the return/output is
|
||||||
|
// unnecessary. This does not alter sd_keys_sources.
|
||||||
|
std::transform(sd_key_sources.begin(), sd_key_sources.end(), sd_keys.begin(),
|
||||||
|
sd_key_sources.begin(), [&cipher](const Key256& source, Key256& out) {
|
||||||
|
cipher.Transcode(source.data(), source.size(), out.data(), Op::Decrypt);
|
||||||
|
return source; ///< Return unaltered source to satisfy output requirement.
|
||||||
|
});
|
||||||
|
|
||||||
return Loader::ResultStatus::Success;
|
return Loader::ResultStatus::Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue