Provide an entropy source to the Dart engine (flutter/engine#4161)
This is required by the _CryptoUtils class used by the recently repackaged Dart HTTP libraries
This commit is contained in:
@@ -14,4 +14,8 @@ source_set("io") {
|
||||
"//garnet/public/lib/fxl",
|
||||
"//topaz/lib/tonic/converter",
|
||||
]
|
||||
|
||||
configs += [
|
||||
"//dart/runtime:dart_config",
|
||||
]
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#include "flutter/lib/io/dart_io.h"
|
||||
|
||||
#include "dart/runtime/bin/crypto.h"
|
||||
#include "dart/runtime/bin/io_natives.h"
|
||||
#include "dart/runtime/include/dart_api.h"
|
||||
#include "lib/tonic/converter/dart_converter.h"
|
||||
@@ -18,4 +19,8 @@ void DartIO::InitForIsolate() {
|
||||
dart::bin::IONativeSymbol));
|
||||
}
|
||||
|
||||
bool DartIO::EntropySource(uint8_t* buffer, intptr_t length) {
|
||||
return dart::bin::Crypto::GetRandomBytes(length, buffer);
|
||||
}
|
||||
|
||||
} // namespace blink
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
#ifndef FLUTTER_LIB_IO_DART_IO_H_
|
||||
#define FLUTTER_LIB_IO_DART_IO_H_
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include "lib/fxl/macros.h"
|
||||
|
||||
namespace blink {
|
||||
@@ -12,6 +14,7 @@ namespace blink {
|
||||
class DartIO {
|
||||
public:
|
||||
static void InitForIsolate();
|
||||
static bool EntropySource(uint8_t* buffer, intptr_t length);
|
||||
|
||||
private:
|
||||
FXL_DISALLOW_IMPLICIT_CONSTRUCTORS(DartIO);
|
||||
|
||||
@@ -565,6 +565,7 @@ void InitDartVM(const uint8_t* vm_snapshot_data,
|
||||
params.shutdown = IsolateShutdownCallback;
|
||||
params.thread_exit = ThreadExitCallback;
|
||||
params.get_service_assets = GetVMServiceAssetsArchiveCallback;
|
||||
params.entropy_source = DartIO::EntropySource;
|
||||
char* init_error = Dart_Initialize(¶ms);
|
||||
if (init_error != nullptr)
|
||||
FXL_LOG(FATAL) << "Error while initializing the Dart VM: " << init_error;
|
||||
|
||||
Reference in New Issue
Block a user