mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-05-23 03:06:52 -04:00
strat: no longer materially constrained by sm session limit
This commit is contained in:
parent
997e4dd665
commit
2e1a93f1d1
37 changed files with 215 additions and 333 deletions
|
@ -19,29 +19,28 @@ namespace ams::crypto {
|
|||
|
||||
namespace {
|
||||
|
||||
bool g_initialized;
|
||||
os::Mutex g_lock(false);
|
||||
constinit bool g_initialized = false;
|
||||
constinit os::SdkMutex g_lock;
|
||||
|
||||
void InitializeCsrng() {
|
||||
AMS_ASSERT(!g_initialized);
|
||||
sm::DoWithSession([&]() {
|
||||
R_ABORT_UNLESS(::csrngInitialize());
|
||||
});
|
||||
R_ABORT_UNLESS(sm::Initialize());
|
||||
R_ABORT_UNLESS(::csrngInitialize());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void GenerateCryptographicallyRandomBytes(void *dst, size_t dst_size) {
|
||||
{
|
||||
if (AMS_UNLIKELY(!g_initialized)) {
|
||||
std::scoped_lock lk(g_lock);
|
||||
|
||||
if (AMS_UNLIKELY(!g_initialized)) {
|
||||
if (AMS_LIKELY(!g_initialized)) {
|
||||
InitializeCsrng();
|
||||
g_initialized = true;
|
||||
}
|
||||
}
|
||||
|
||||
R_ABORT_UNLESS(csrngGetRandomBytes(dst, dst_size));
|
||||
R_ABORT_UNLESS(::csrngGetRandomBytes(dst, dst_size));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue