feat: modules moved and engine moved to submodule
This commit is contained in:
parent
dfb5e645cd
commit
c33d2130cc
5136 changed files with 225275 additions and 64485 deletions
|
|
@ -120,7 +120,7 @@ if env["builtin_mbedtls"]:
|
|||
thirdparty_dir = "#thirdparty/mbedtls/library/"
|
||||
thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources]
|
||||
|
||||
env_mbed_tls.Prepend(CPPPATH=["#thirdparty/mbedtls/include/"])
|
||||
env_mbed_tls.Prepend(CPPEXTPATH=["#thirdparty/mbedtls/include/"])
|
||||
config_path = "thirdparty/mbedtls/include/godot_module_mbedtls_config.h"
|
||||
config_path = f"<{config_path}>" if env_mbed_tls["ninja"] and env_mbed_tls.msvc else f'\\"{config_path}\\"'
|
||||
env_mbed_tls.Append(CPPDEFINES=[("MBEDTLS_CONFIG_FILE", config_path)])
|
||||
|
|
|
|||
|
|
@ -212,7 +212,8 @@ String X509CertificateMbedTLS::save_to_string() {
|
|||
int ret = mbedtls_pem_write_buffer(PEM_BEGIN_CRT, PEM_END_CRT, cert.raw.p, cert.raw.len, w, sizeof(w), &wrote);
|
||||
ERR_FAIL_COND_V_MSG(ret != 0 || wrote == 0, String(), "Error saving the certificate.");
|
||||
|
||||
buffer += String((char *)w, wrote);
|
||||
// PEM is base64, aka ascii
|
||||
buffer += String::ascii(Span((char *)w, wrote));
|
||||
crt = crt->next;
|
||||
}
|
||||
if (buffer.length() <= PEM_MIN_SIZE) {
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef CRYPTO_MBEDTLS_H
|
||||
#define CRYPTO_MBEDTLS_H
|
||||
#pragma once
|
||||
|
||||
#include "core/crypto/crypto.h"
|
||||
|
||||
|
|
@ -40,6 +39,8 @@
|
|||
class CryptoMbedTLS;
|
||||
class TLSContextMbedTLS;
|
||||
class CryptoKeyMbedTLS : public CryptoKey {
|
||||
GDSOFTCLASS(CryptoKeyMbedTLS, CryptoKey);
|
||||
|
||||
private:
|
||||
mbedtls_pk_context pkey;
|
||||
int locks = 0;
|
||||
|
|
@ -52,17 +53,17 @@ public:
|
|||
static void make_default() { CryptoKey::_create = create; }
|
||||
static void finalize() { CryptoKey::_create = nullptr; }
|
||||
|
||||
virtual Error load(const String &p_path, bool p_public_only);
|
||||
virtual Error save(const String &p_path, bool p_public_only);
|
||||
virtual String save_to_string(bool p_public_only);
|
||||
virtual Error load_from_string(const String &p_string_key, bool p_public_only);
|
||||
virtual bool is_public_only() const { return public_only; }
|
||||
Error load(const String &p_path, bool p_public_only) override;
|
||||
Error save(const String &p_path, bool p_public_only) override;
|
||||
String save_to_string(bool p_public_only) override;
|
||||
Error load_from_string(const String &p_string_key, bool p_public_only) override;
|
||||
bool is_public_only() const override { return public_only; }
|
||||
|
||||
CryptoKeyMbedTLS() {
|
||||
mbedtls_pk_init(&pkey);
|
||||
locks = 0;
|
||||
}
|
||||
~CryptoKeyMbedTLS() {
|
||||
~CryptoKeyMbedTLS() override {
|
||||
mbedtls_pk_free(&pkey);
|
||||
}
|
||||
|
||||
|
|
@ -74,6 +75,8 @@ public:
|
|||
};
|
||||
|
||||
class X509CertificateMbedTLS : public X509Certificate {
|
||||
GDSOFTCLASS(X509CertificateMbedTLS, X509Certificate);
|
||||
|
||||
private:
|
||||
mbedtls_x509_crt cert;
|
||||
int locks;
|
||||
|
|
@ -83,17 +86,17 @@ public:
|
|||
static void make_default() { X509Certificate::_create = create; }
|
||||
static void finalize() { X509Certificate::_create = nullptr; }
|
||||
|
||||
virtual Error load(const String &p_path);
|
||||
virtual Error load_from_memory(const uint8_t *p_buffer, int p_len);
|
||||
virtual Error save(const String &p_path);
|
||||
virtual String save_to_string();
|
||||
virtual Error load_from_string(const String &p_string_key);
|
||||
Error load(const String &p_path) override;
|
||||
Error load_from_memory(const uint8_t *p_buffer, int p_len) override;
|
||||
Error save(const String &p_path) override;
|
||||
String save_to_string() override;
|
||||
Error load_from_string(const String &p_string_key) override;
|
||||
|
||||
X509CertificateMbedTLS() {
|
||||
mbedtls_x509_crt_init(&cert);
|
||||
locks = 0;
|
||||
}
|
||||
~X509CertificateMbedTLS() {
|
||||
~X509CertificateMbedTLS() override {
|
||||
mbedtls_x509_crt_free(&cert);
|
||||
}
|
||||
|
||||
|
|
@ -117,12 +120,12 @@ public:
|
|||
|
||||
static bool is_md_type_allowed(mbedtls_md_type_t p_md_type);
|
||||
|
||||
virtual Error start(HashingContext::HashType p_hash_type, const PackedByteArray &p_key);
|
||||
virtual Error update(const PackedByteArray &p_data);
|
||||
virtual PackedByteArray finish();
|
||||
Error start(HashingContext::HashType p_hash_type, const PackedByteArray &p_key) override;
|
||||
Error update(const PackedByteArray &p_data) override;
|
||||
PackedByteArray finish() override;
|
||||
|
||||
HMACContextMbedTLS() {}
|
||||
~HMACContextMbedTLS();
|
||||
~HMACContextMbedTLS() override;
|
||||
};
|
||||
|
||||
class CryptoMbedTLS : public Crypto {
|
||||
|
|
@ -139,16 +142,14 @@ public:
|
|||
static void load_default_certificates(const String &p_path);
|
||||
static mbedtls_md_type_t md_type_from_hashtype(HashingContext::HashType p_hash_type, int &r_size);
|
||||
|
||||
virtual PackedByteArray generate_random_bytes(int p_bytes);
|
||||
virtual Ref<CryptoKey> generate_rsa(int p_bytes);
|
||||
virtual Ref<X509Certificate> generate_self_signed_certificate(Ref<CryptoKey> p_key, const String &p_issuer_name, const String &p_not_before, const String &p_not_after);
|
||||
virtual Vector<uint8_t> sign(HashingContext::HashType p_hash_type, const Vector<uint8_t> &p_hash, Ref<CryptoKey> p_key);
|
||||
virtual bool verify(HashingContext::HashType p_hash_type, const Vector<uint8_t> &p_hash, const Vector<uint8_t> &p_signature, Ref<CryptoKey> p_key);
|
||||
virtual Vector<uint8_t> encrypt(Ref<CryptoKey> p_key, const Vector<uint8_t> &p_plaintext);
|
||||
virtual Vector<uint8_t> decrypt(Ref<CryptoKey> p_key, const Vector<uint8_t> &p_ciphertext);
|
||||
PackedByteArray generate_random_bytes(int p_bytes) override;
|
||||
Ref<CryptoKey> generate_rsa(int p_bytes) override;
|
||||
Ref<X509Certificate> generate_self_signed_certificate(Ref<CryptoKey> p_key, const String &p_issuer_name, const String &p_not_before, const String &p_not_after) override;
|
||||
Vector<uint8_t> sign(HashingContext::HashType p_hash_type, const Vector<uint8_t> &p_hash, Ref<CryptoKey> p_key) override;
|
||||
bool verify(HashingContext::HashType p_hash_type, const Vector<uint8_t> &p_hash, const Vector<uint8_t> &p_signature, Ref<CryptoKey> p_key) override;
|
||||
Vector<uint8_t> encrypt(Ref<CryptoKey> p_key, const Vector<uint8_t> &p_plaintext) override;
|
||||
Vector<uint8_t> decrypt(Ref<CryptoKey> p_key, const Vector<uint8_t> &p_ciphertext) override;
|
||||
|
||||
CryptoMbedTLS();
|
||||
~CryptoMbedTLS();
|
||||
~CryptoMbedTLS() override;
|
||||
};
|
||||
|
||||
#endif // CRYPTO_MBEDTLS_H
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef DTLS_SERVER_MBEDTLS_H
|
||||
#define DTLS_SERVER_MBEDTLS_H
|
||||
#pragma once
|
||||
|
||||
#include "tls_context_mbedtls.h"
|
||||
|
||||
|
|
@ -45,12 +44,10 @@ public:
|
|||
static void initialize();
|
||||
static void finalize();
|
||||
|
||||
virtual Error setup(Ref<TLSOptions> p_options);
|
||||
virtual void stop();
|
||||
virtual Ref<PacketPeerDTLS> take_connection(Ref<PacketPeerUDP> p_peer);
|
||||
Error setup(Ref<TLSOptions> p_options) override;
|
||||
void stop() override;
|
||||
Ref<PacketPeerDTLS> take_connection(Ref<PacketPeerUDP> p_peer) override;
|
||||
|
||||
DTLSServerMbedTLS();
|
||||
~DTLSServerMbedTLS();
|
||||
~DTLSServerMbedTLS() override;
|
||||
};
|
||||
|
||||
#endif // DTLS_SERVER_MBEDTLS_H
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef PACKET_PEER_MBED_DTLS_H
|
||||
#define PACKET_PEER_MBED_DTLS_H
|
||||
#pragma once
|
||||
|
||||
#include "tls_context_mbedtls.h"
|
||||
|
||||
|
|
@ -83,5 +82,3 @@ public:
|
|||
PacketPeerMbedDTLS();
|
||||
~PacketPeerMbedDTLS();
|
||||
};
|
||||
|
||||
#endif // PACKET_PEER_MBED_DTLS_H
|
||||
|
|
|
|||
|
|
@ -28,12 +28,9 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef MBEDTLS_REGISTER_TYPES_H
|
||||
#define MBEDTLS_REGISTER_TYPES_H
|
||||
#pragma once
|
||||
|
||||
#include "modules/register_module_types.h"
|
||||
|
||||
void initialize_mbedtls_module(ModuleInitializationLevel p_level);
|
||||
void uninitialize_mbedtls_module(ModuleInitializationLevel p_level);
|
||||
|
||||
#endif // MBEDTLS_REGISTER_TYPES_H
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef STREAM_PEER_MBEDTLS_H
|
||||
#define STREAM_PEER_MBEDTLS_H
|
||||
#pragma once
|
||||
|
||||
#include "tls_context_mbedtls.h"
|
||||
|
||||
|
|
@ -76,5 +75,3 @@ public:
|
|||
StreamPeerMbedTLS();
|
||||
~StreamPeerMbedTLS();
|
||||
};
|
||||
|
||||
#endif // STREAM_PEER_MBEDTLS_H
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef TEST_CRYPTO_MBEDTLS_H
|
||||
#define TEST_CRYPTO_MBEDTLS_H
|
||||
#pragma once
|
||||
|
||||
#include "core/crypto/crypto.h"
|
||||
#include "core/crypto/hashing_context.h"
|
||||
|
|
@ -88,5 +87,3 @@ TEST_CASE("[Crypto] CryptoKey save public_only") {
|
|||
}
|
||||
|
||||
} // namespace TestCryptoMbedTLS
|
||||
|
||||
#endif // TEST_CRYPTO_MBEDTLS_H
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef TLS_CONTEXT_MBEDTLS_H
|
||||
#define TLS_CONTEXT_MBEDTLS_H
|
||||
#pragma once
|
||||
|
||||
#include "crypto_mbedtls.h"
|
||||
|
||||
|
|
@ -57,7 +56,7 @@ public:
|
|||
void clear();
|
||||
|
||||
CookieContextMbedTLS();
|
||||
~CookieContextMbedTLS();
|
||||
~CookieContextMbedTLS() override;
|
||||
};
|
||||
|
||||
class TLSContextMbedTLS : public RefCounted {
|
||||
|
|
@ -84,7 +83,5 @@ public:
|
|||
mbedtls_ssl_context *get_context();
|
||||
|
||||
TLSContextMbedTLS();
|
||||
~TLSContextMbedTLS();
|
||||
~TLSContextMbedTLS() override;
|
||||
};
|
||||
|
||||
#endif // TLS_CONTEXT_MBEDTLS_H
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue