summaryrefslogtreecommitdiff
path: root/core/crypto/crypto.h
diff options
context:
space:
mode:
Diffstat (limited to 'core/crypto/crypto.h')
-rw-r--r--core/crypto/crypto.h92
1 files changed, 63 insertions, 29 deletions
diff --git a/core/crypto/crypto.h b/core/crypto/crypto.h
index 10c9564ad9..999fe076d6 100644
--- a/core/crypto/crypto.h
+++ b/core/crypto/crypto.h
@@ -1,32 +1,32 @@
-/*************************************************************************/
-/* crypto.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
+/**************************************************************************/
+/* crypto.h */
+/**************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/**************************************************************************/
+/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
+/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/**************************************************************************/
#ifndef CRYPTO_H
#define CRYPTO_H
@@ -67,6 +67,40 @@ public:
virtual Error save(String p_path) = 0;
};
+class TLSOptions : public RefCounted {
+ GDCLASS(TLSOptions, RefCounted);
+
+public:
+ enum TLSVerifyMode {
+ TLS_VERIFY_NONE = 0,
+ TLS_VERIFY_CERT = 1,
+ TLS_VERIFY_FULL = 2,
+ };
+
+private:
+ bool server_mode = false;
+ String common_name;
+ TLSVerifyMode verify_mode = TLS_VERIFY_FULL;
+ Ref<X509Certificate> trusted_ca_chain;
+ Ref<X509Certificate> own_certificate;
+ Ref<CryptoKey> private_key;
+
+protected:
+ static void _bind_methods();
+
+public:
+ static Ref<TLSOptions> client(Ref<X509Certificate> p_trusted_chain = Ref<X509Certificate>(), const String &p_common_name_override = String());
+ static Ref<TLSOptions> client_unsafe(Ref<X509Certificate> p_trusted_chain);
+ static Ref<TLSOptions> server(Ref<CryptoKey> p_own_key, Ref<X509Certificate> p_own_certificate);
+
+ TLSVerifyMode get_verify_mode() const { return verify_mode; }
+ String get_common_name() const { return common_name; }
+ Ref<X509Certificate> get_trusted_ca_chain() const { return trusted_ca_chain; }
+ Ref<X509Certificate> get_own_certificate() const { return own_certificate; }
+ Ref<CryptoKey> get_private_key() const { return private_key; }
+ bool is_server() const { return server_mode; }
+};
+
class HMACContext : public RefCounted {
GDCLASS(HMACContext, RefCounted);