Files
sdk/runtime/bin/crypto_macos.cc
Ryan Macnak 9bcd33c50b Reapply "[standalone] Use fewer syscalls to get entropy on Linux and Mac."
Use SecRandomCopyBytes on Mac/iOS.

TEST=ci, local engine build
Change-Id: I48e1fc0186e4a65419fd9bf02be4d91983f8d8d9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/453581
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2025-10-08 08:16:42 -07:00

23 lines
598 B
C++

// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
#include "platform/globals.h"
#if defined(DART_HOST_OS_MACOS)
#include <Security/Security.h>
#include "bin/crypto.h"
namespace dart {
namespace bin {
bool Crypto::GetRandomBytes(intptr_t count, uint8_t* buffer) {
return SecRandomCopyBytes(kSecRandomDefault, count, buffer) == errSecSuccess;
}
} // namespace bin
} // namespace dart
#endif // defined(DART_HOST_OS_MACOS)