diff options
| author | 2018-10-13 09:13:19 -0400 | |
|---|---|---|
| committer | 2018-10-13 09:13:19 -0400 | |
| commit | 6da2ed4232d3b3ecde7a04621c554f66de558fab (patch) | |
| tree | 83184a61eecca6dcc5f543a5f69f93234eacdbc6 /src/core/crypto/key_manager.cpp | |
| parent | partition_data_manager: Dehardcode array bounds (diff) | |
| download | yuzu-6da2ed4232d3b3ecde7a04621c554f66de558fab.tar.gz yuzu-6da2ed4232d3b3ecde7a04621c554f66de558fab.tar.xz yuzu-6da2ed4232d3b3ecde7a04621c554f66de558fab.zip | |
key_manager/partition_data_manager: Silence truncation compiler warnings
Diffstat (limited to 'src/core/crypto/key_manager.cpp')
| -rw-r--r-- | src/core/crypto/key_manager.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/core/crypto/key_manager.cpp b/src/core/crypto/key_manager.cpp index d2ce4f5bf..fd0786068 100644 --- a/src/core/crypto/key_manager.cpp +++ b/src/core/crypto/key_manager.cpp | |||
| @@ -98,7 +98,7 @@ std::array<u8, 144> DecryptKeyblob(const std::array<u8, 176>& encrypted_keyblob, | |||
| 98 | return keyblob; | 98 | return keyblob; |
| 99 | } | 99 | } |
| 100 | 100 | ||
| 101 | void KeyManager::DeriveGeneralPurposeKeys(u8 crypto_revision) { | 101 | void KeyManager::DeriveGeneralPurposeKeys(std::size_t crypto_revision) { |
| 102 | const auto kek_generation_source = | 102 | const auto kek_generation_source = |
| 103 | GetKey(S128KeyType::Source, static_cast<u64>(SourceKeyType::AESKekGeneration)); | 103 | GetKey(S128KeyType::Source, static_cast<u64>(SourceKeyType::AESKekGeneration)); |
| 104 | const auto key_generation_source = | 104 | const auto key_generation_source = |
| @@ -270,6 +270,9 @@ static std::array<u8, size> operator^(const std::array<u8, size>& lhs, | |||
| 270 | 270 | ||
| 271 | template <size_t target_size, size_t in_size> | 271 | template <size_t target_size, size_t in_size> |
| 272 | static std::array<u8, target_size> MGF1(const std::array<u8, in_size>& seed) { | 272 | static std::array<u8, target_size> MGF1(const std::array<u8, in_size>& seed) { |
| 273 | // Avoids truncation overflow within the loop below. | ||
| 274 | static_assert(target_size <= 0xFF); | ||
| 275 | |||
| 273 | std::array<u8, in_size + 4> seed_exp{}; | 276 | std::array<u8, in_size + 4> seed_exp{}; |
| 274 | std::memcpy(seed_exp.data(), seed.data(), in_size); | 277 | std::memcpy(seed_exp.data(), seed.data(), in_size); |
| 275 | 278 | ||
| @@ -277,7 +280,7 @@ static std::array<u8, target_size> MGF1(const std::array<u8, in_size>& seed) { | |||
| 277 | size_t i = 0; | 280 | size_t i = 0; |
| 278 | while (out.size() < target_size) { | 281 | while (out.size() < target_size) { |
| 279 | out.resize(out.size() + 0x20); | 282 | out.resize(out.size() + 0x20); |
| 280 | seed_exp[in_size + 3] = i; | 283 | seed_exp[in_size + 3] = static_cast<u8>(i); |
| 281 | mbedtls_sha256(seed_exp.data(), seed_exp.size(), out.data() + out.size() - 0x20, 0); | 284 | mbedtls_sha256(seed_exp.data(), seed_exp.size(), out.data() + out.size() - 0x20, 0); |
| 282 | ++i; | 285 | ++i; |
| 283 | } | 286 | } |