mirror of
https://git.suyu.dev/suyu/suyu.git
synced 2024-11-27 09:12:46 +01:00
telemetry_session: Use a std::array in GenerateTelemetryId()
We don't need to potentially heap-allocate a std::string instance here, given the data is known ahead of time. We can just place it within an array and pass this to the mbedtls functions.
This commit is contained in:
parent
561d79e034
commit
8723cc8798
1 changed files with 4 additions and 2 deletions
|
@ -2,6 +2,8 @@
|
|||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include <array>
|
||||
|
||||
#include "common/assert.h"
|
||||
#include "common/common_types.h"
|
||||
#include "common/file_util.h"
|
||||
|
@ -28,11 +30,11 @@ static u64 GenerateTelemetryId() {
|
|||
mbedtls_entropy_context entropy;
|
||||
mbedtls_entropy_init(&entropy);
|
||||
mbedtls_ctr_drbg_context ctr_drbg;
|
||||
std::string personalization = "yuzu Telemetry ID";
|
||||
constexpr std::array<char, 18> personalization{{"yuzu Telemetry ID"}};
|
||||
|
||||
mbedtls_ctr_drbg_init(&ctr_drbg);
|
||||
ASSERT(mbedtls_ctr_drbg_seed(&ctr_drbg, mbedtls_entropy_func, &entropy,
|
||||
reinterpret_cast<const unsigned char*>(personalization.c_str()),
|
||||
reinterpret_cast<const unsigned char*>(personalization.data()),
|
||||
personalization.size()) == 0);
|
||||
ASSERT(mbedtls_ctr_drbg_random(&ctr_drbg, reinterpret_cast<unsigned char*>(&telemetry_id),
|
||||
sizeof(u64)) == 0);
|
||||
|
|
Loading…
Reference in a new issue