Browse Source

[OSX] Codesign exporter now uses CryptoCore RNG.

Fabio Alessandrelli 3 years ago
parent
commit
f4a80f9ca7
2 changed files with 6 additions and 4 deletions
  1. 6 3
      platform/osx/export/codesign.cpp
  2. 0 1
      platform/osx/export/codesign.h

+ 6 - 3
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.
 	// Generate common signature structures.
 	if (id.is_empty()) {
 	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();
 	CharString uuid_str = id.utf8();
 	print_verbose(vformat("CodeSign: Used bundle ID: %s", id));
 	print_verbose(vformat("CodeSign: Used bundle ID: %s", id));

+ 0 - 1
platform/osx/export/codesign.h

@@ -41,7 +41,6 @@
 #ifndef CODESIGN_H
 #ifndef CODESIGN_H
 #define CODESIGN_H
 #define CODESIGN_H
 
 
-#include "core/crypto/crypto.h"
 #include "core/crypto/crypto_core.h"
 #include "core/crypto/crypto_core.h"
 #include "core/io/dir_access.h"
 #include "core/io/dir_access.h"
 #include "core/io/file_access.h"
 #include "core/io/file_access.h"