0.2.0-dev Download ZIP
125 lines ·4.3 KB Raw
| 1 | /**************************************************************************/ |
| 2 | /* godot_psa_config.h */ |
| 3 | /**************************************************************************/ |
| 4 | /* This file is part of: */ |
| 5 | /* GODOT ENGINE */ |
| 6 | /* https://godotengine.org */ |
| 7 | /**************************************************************************/ |
| 8 | /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ |
| 9 | /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ |
| 10 | /* */ |
| 11 | /* Permission is hereby granted, free of charge, to any person obtaining */ |
| 12 | /* a copy of this software and associated documentation files (the */ |
| 13 | /* "Software"), to deal in the Software without restriction, including */ |
| 14 | /* without limitation the rights to use, copy, modify, merge, publish, */ |
| 15 | /* distribute, sublicense, and/or sell copies of the Software, and to */ |
| 16 | /* permit persons to whom the Software is furnished to do so, subject to */ |
| 17 | /* the following conditions: */ |
| 18 | /* */ |
| 19 | /* The above copyright notice and this permission notice shall be */ |
| 20 | /* included in all copies or substantial portions of the Software. */ |
| 21 | /* */ |
| 22 | /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ |
| 23 | /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ |
| 24 | /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ |
| 25 | /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ |
| 26 | /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ |
| 27 | /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ |
| 28 | /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ |
| 29 | /**************************************************************************/ |
| 30 | |
| 31 | #pragma once |
| 32 | |
| 33 | #include "platform_config.h" |
| 34 | |
| 35 | #ifdef GODOT_PSA_INCLUDE_H |
| 36 | |
| 37 | // Allow platforms to customize the mbedTLS configuration. |
| 38 | #include GODOT_PSA_INCLUDE_H |
| 39 | |
| 40 | #else |
| 41 | |
| 42 | #if !defined(GODOT_MBEDTLS_LIGHT) |
| 43 | // Full module build (include default mbedTLS config). |
| 44 | #include <psa/crypto_config.h> |
| 45 | |
| 46 | #if !(defined(__linux__) && defined(__aarch64__)) |
| 47 | // ARMv8 hardware AES operations. Detection only possible on linux. |
| 48 | // May technically be supported on some ARM32 arches but doesn't seem |
| 49 | // to be in our current Linux SDK's neon-fp-armv8. |
| 50 | #undef MBEDTLS_AESCE_C |
| 51 | #endif |
| 52 | |
| 53 | #if defined(__has_feature) |
| 54 | #if __has_feature(memory_sanitizer) |
| 55 | // MemorySanitizer is incompatible with ASM. |
| 56 | #undef MBEDTLS_HAVE_ASM |
| 57 | #undef MBEDTLS_AESNI_C |
| 58 | #endif |
| 59 | #endif |
| 60 | |
| 61 | #else // GODOT_MBEDTLS_LIGHT |
| 62 | |
| 63 | // Light build for CryptoCore when module is disabled |
| 64 | #include <limits.h> |
| 65 | |
| 66 | // For AES |
| 67 | #define MBEDTLS_AES_C |
| 68 | #define MBEDTLS_BASE64_C |
| 69 | #define MBEDTLS_CTR_DRBG_C |
| 70 | #define MBEDTLS_ENTROPY_C |
| 71 | #define MBEDTLS_MD_C |
| 72 | #define MBEDTLS_MD5_C |
| 73 | #define MBEDTLS_SHA1_C |
| 74 | #define MBEDTLS_SHA256_C |
| 75 | #define MBEDTLS_PLATFORM_ZEROIZE_ALT |
| 76 | |
| 77 | #define MBEDTLS_PSA_CRYPTO_C |
| 78 | #define MBEDTLS_PSA_CRYPTO_CLIENT |
| 79 | |
| 80 | // Hashing |
| 81 | #define PSA_WANT_ALG_SHA_1 |
| 82 | #define PSA_WANT_ALG_SHA_256 |
| 83 | #define PSA_WANT_ALG_MD5 |
| 84 | |
| 85 | // Encryption |
| 86 | #define PSA_WANT_KEY_TYPE_AES |
| 87 | #define PSA_WANT_ALG_CBC_NO_PADDING |
| 88 | #define PSA_WANT_ALG_ECB_NO_PADDING |
| 89 | #define PSA_WANT_ALG_CFB |
| 90 | |
| 91 | // This is only to pass a check in the mbedtls check_config.h header, none of |
| 92 | // the files we include as part of the core build uses it anyway, we already |
| 93 | // define MBEDTLS_PLATFORM_ZEROIZE_ALT which is the only relevant function. |
| 94 | #if defined(__MINGW32__) |
| 95 | #define MBEDTLS_PLATFORM_C |
| 96 | #endif |
| 97 | |
| 98 | #endif |
| 99 | |
| 100 | // Disable deprecated |
| 101 | #define MBEDTLS_DEPRECATED_REMOVED |
| 102 | |
| 103 | // Godot mbedTLS platform implementation |
| 104 | #define GODOT_MBEDTLS_PLATFORM |
| 105 | |
| 106 | #ifdef MBEDTLS_PSA_BUILTIN_GET_ENTROPY |
| 107 | #undef MBEDTLS_PSA_BUILTIN_GET_ENTROPY |
| 108 | #endif |
| 109 | #define MBEDTLS_PSA_DRIVER_GET_ENTROPY |
| 110 | |
| 111 | #if defined(THREADS_ENABLED) |
| 112 | #define MBEDTLS_THREADING_C |
| 113 | #define MBEDTLS_THREADING_ALT |
| 114 | #endif |
| 115 | |
| 116 | #ifdef __cplusplus |
| 117 | extern "C" { |
| 118 | #endif |
| 119 | void godot_mbedtls_platform_init(); |
| 120 | void godot_mbedtls_platform_free(); |
| 121 | #ifdef __cplusplus |
| 122 | }; |
| 123 | #endif |
| 124 | |
| 125 | #endif // GODOT_PSA_INCLUDE_H |