summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorFabio Alessandrelli <fabio.alessandrelli@gmail.com>2019-07-02 03:06:52 +0200
committerFabio Alessandrelli <fabio.alessandrelli@gmail.com>2019-07-02 12:36:27 +0200
commit564d93ff10b19dd15df6ea049bd7c9a9c99680c6 (patch)
treeee6523844280ff5874e8d7aff7c95f498ae769e0 /platform
parent0268a4869ded42079d3f4c255406711c726e3df4 (diff)
CryptoCore class to access to base crypto utils.
Godot core needs MD5/SHA256/AES/Base64 which used to be provided by separate libraries. Since we bundle mbedtls in most cases, and we can easily only include the needed sources if we so desire, let's use it. To simplify library changes in the future, and better isolate header dependencies all functions have been wrapped around inside a class in `core/math/crypto_base.h`. If the mbedtls module is disabled, we only bundle the needed source files independently of the `builtin_mbedtls` option. If the module is enabled, the `builtin_mbedtls` option works as usual. Also remove some unused headers from StreamPeerMbedTLS which were causing build issues.
Diffstat (limited to 'platform')
-rw-r--r--platform/uwp/export/export.cpp14
1 files changed, 5 insertions, 9 deletions
diff --git a/platform/uwp/export/export.cpp b/platform/uwp/export/export.cpp
index ec43a4c26f..abb7b391d3 100644
--- a/platform/uwp/export/export.cpp
+++ b/platform/uwp/export/export.cpp
@@ -32,6 +32,7 @@
#include "core/bind/core_bind.h"
#include "core/io/marshalls.h"
#include "core/io/zip_io.h"
+#include "core/math/crypto_core.h"
#include "core/object.h"
#include "core/os/file_access.h"
#include "core/project_settings.h"
@@ -42,8 +43,6 @@
#include "thirdparty/minizip/unzip.h"
#include "thirdparty/minizip/zip.h"
-#include "thirdparty/misc/base64.h"
-#include "thirdparty/misc/sha256.h"
#include <zlib.h>
@@ -198,15 +197,12 @@ public:
String AppxPackager::hash_block(const uint8_t *p_block_data, size_t p_block_len) {
- char hash[32];
+ unsigned char hash[32];
char base64[45];
- sha256_context ctx;
- sha256_init(&ctx);
- sha256_hash(&ctx, (uint8_t *)p_block_data, p_block_len);
- sha256_done(&ctx, (uint8_t *)hash);
-
- base64_encode(base64, hash, 32);
+ CryptoCore::sha256(p_block_data, p_block_len, hash);
+ size_t len = 0;
+ CryptoCore::b64_encode((unsigned char *)base64, 45, &len, (unsigned char *)hash, 32);
base64[44] = '\0';
return String(base64);