Initial macOS support (x86_64 with Rosetta 2)

This commit is contained in:
2025-11-08 01:45:47 -07:00
parent f56bd8e2a7
commit cc0a887302
33 changed files with 1281 additions and 4186 deletions

View File

@@ -15,6 +15,9 @@ constexpr ULONG BCRYPT_RNG_USE_ENTROPY_IN_BUFFER = 0x00000001;
constexpr ULONG BCRYPT_USE_SYSTEM_PREFERRED_RNG = 0x00000002;
bool fillWithSystemRandom(PUCHAR buffer, size_t length) {
#ifdef __APPLE__
arc4random_buf(buffer, length);
#else
while (length > 0) {
ssize_t written = getrandom(buffer, length, 0);
if (written < 0) {
@@ -27,6 +30,7 @@ bool fillWithSystemRandom(PUCHAR buffer, size_t length) {
buffer += written;
length -= static_cast<size_t>(written);
}
#endif
return true;
}