diff options
Diffstat (limited to 'platform')
-rw-r--r-- | platform/osx/export/codesign.cpp | 9 | ||||
-rw-r--r-- | platform/osx/export/codesign.h | 1 | ||||
-rw-r--r-- | platform/windows/os_windows.cpp | 7 | ||||
-rw-r--r-- | platform/windows/os_windows.h | 2 |
4 files changed, 15 insertions, 4 deletions
diff --git a/platform/osx/export/codesign.cpp b/platform/osx/export/codesign.cpp index 8ea6ff519d..8d1d147196 100644 --- a/platform/osx/export/codesign.cpp +++ b/platform/osx/export/codesign.cpp @@ -1359,9 +1359,12 @@ Error CodeSign::_codesign_file(bool p_use_hardened_runtime, bool p_force, const // Generate common signature structures. if (id.is_empty()) { - Ref<Crypto> crypto = Ref<Crypto>(Crypto::create()); - PackedByteArray uuid = crypto->generate_random_bytes(16); - id = (String("a-55554944") /*a-UUID*/ + String::hex_encode_buffer(uuid.ptr(), 16)); + CryptoCore::RandomGenerator rng; + ERR_FAIL_COND_V_MSG(rng.init(), FAILED, "Failed to initialize random number generator."); + uint8_t uuid[16]; + Error err = rng.get_random_bytes(uuid, 16); + ERR_FAIL_COND_V_MSG(err, err, "Failed to generate UUID."); + id = (String("a-55554944") /*a-UUID*/ + String::hex_encode_buffer(uuid, 16)); } CharString uuid_str = id.utf8(); print_verbose(vformat("CodeSign: Used bundle ID: %s", id)); diff --git a/platform/osx/export/codesign.h b/platform/osx/export/codesign.h index 927df79281..e5e9be5c28 100644 --- a/platform/osx/export/codesign.h +++ b/platform/osx/export/codesign.h @@ -41,7 +41,6 @@ #ifndef CODESIGN_H #define CODESIGN_H -#include "core/crypto/crypto.h" #include "core/crypto/crypto_core.h" #include "core/io/dir_access.h" #include "core/io/file_access.h" diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index d844531071..59f55b5dd2 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -46,6 +46,7 @@ #include "windows_terminal_logger.h" #include <avrt.h> +#include <bcrypt.h> #include <direct.h> #include <knownfolders.h> #include <process.h> @@ -192,6 +193,12 @@ void OS_Windows::finalize_core() { NetSocketPosix::cleanup(); } +Error OS_Windows::get_entropy(uint8_t *r_buffer, int p_bytes) { + NTSTATUS status = BCryptGenRandom(nullptr, r_buffer, p_bytes, BCRYPT_USE_SYSTEM_PREFERRED_RNG); + ERR_FAIL_COND_V(status, FAILED); + return OK; +} + Error OS_Windows::open_dynamic_library(const String p_path, void *&p_library_handle, bool p_also_set_library_path) { String path = p_path.replace("/", "\\"); diff --git a/platform/windows/os_windows.h b/platform/windows/os_windows.h index 0a11416b1b..bde663a27b 100644 --- a/platform/windows/os_windows.h +++ b/platform/windows/os_windows.h @@ -106,6 +106,8 @@ protected: public: virtual void alert(const String &p_alert, const String &p_title = "ALERT!") override; + virtual Error get_entropy(uint8_t *r_buffer, int p_bytes) override; + virtual Error open_dynamic_library(const String p_path, void *&p_library_handle, bool p_also_set_library_path = false) override; virtual Error close_dynamic_library(void *p_library_handle) override; virtual Error get_dynamic_library_symbol_handle(void *p_library_handle, const String p_name, void *&p_symbol_handle, bool p_optional = false) override; |