summaryrefslogtreecommitdiffstats
path: root/core/os/os.h
diff options
context:
space:
mode:
authorFabio Alessandrelli <fabio.alessandrelli@gmail.com>2022-02-07 17:33:55 +0100
committerFabio Alessandrelli <fabio.alessandrelli@gmail.com>2022-02-14 10:45:50 +0100
commit6b5634b96aa90ab2db7357b353fc8f96ad4878c5 (patch)
tree79683c4d2e538e5702a74a5b431a0913777ee0ed /core/os/os.h
parent8317753c24f6a05d4fdc8541fecf1cd2ec189b41 (diff)
downloadredot-engine-6b5634b96aa90ab2db7357b353fc8f96ad4878c5.tar.gz
[OS/Crypto] Add get_entropy to OS.
Implemented via `BCryptGenRandom` on Windows. Implemented via `getentropy` syscall when available. Implemented via `/dev/urandom` device as a fallback. The `/dev/urandom` fallback can be disabled via the `NO_URANDOM` build flag. Note: The HTML5 version relies on emscripten file system urandom device which itself uses the Crypto API when available or the plain old not crypto-safe `Math.random()` otherwise. Restore get_entropy.
Diffstat (limited to 'core/os/os.h')
-rw-r--r--core/os/os.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/core/os/os.h b/core/os/os.h
index d3d2a868fa..188900a070 100644
--- a/core/os/os.h
+++ b/core/os/os.h
@@ -132,6 +132,8 @@ public:
virtual String get_stdin_string(bool p_block = true) = 0;
+ virtual Error get_entropy(uint8_t *r_buffer, int p_bytes) = 0; // Should return cryptographically-safe random bytes.
+
virtual PackedStringArray get_connected_midi_inputs();
virtual void open_midi_inputs();
virtual void close_midi_inputs();