diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2024-03-01 17:22:12 +0100 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2024-03-01 17:22:12 +0100 |
commit | 0e0f564cea6aef2bb9aa40dd34f670c732a42f9f (patch) | |
tree | 1ce42f6b2d078275a5f9151c8cf34aa6ead48150 /modules/mbedtls/tests/test_crypto_mbedtls.h | |
parent | 8c0511a69b49cfb584a773db7af404ed15de36ca (diff) | |
parent | e461496ecb89263d1df052b1876ad607b196b58d (diff) | |
download | redot-engine-0e0f564cea6aef2bb9aa40dd34f670c732a42f9f.tar.gz |
Merge pull request #89021 from wheatear-dev/test-crypto-key
Add unit tests for CryptoKey
Diffstat (limited to 'modules/mbedtls/tests/test_crypto_mbedtls.h')
-rw-r--r-- | modules/mbedtls/tests/test_crypto_mbedtls.h | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/modules/mbedtls/tests/test_crypto_mbedtls.h b/modules/mbedtls/tests/test_crypto_mbedtls.h index 0b24925d6b..5ec78d18a3 100644 --- a/modules/mbedtls/tests/test_crypto_mbedtls.h +++ b/modules/mbedtls/tests/test_crypto_mbedtls.h @@ -31,9 +31,11 @@ #ifndef TEST_CRYPTO_MBEDTLS_H #define TEST_CRYPTO_MBEDTLS_H +#include "core/crypto/crypto.h" #include "core/crypto/hashing_context.h" #include "tests/test_macros.h" +#include "tests/test_utils.h" namespace TestCryptoMbedTLS { @@ -56,6 +58,35 @@ TEST_CASE("[HMACContext] HMAC digest") { // SHA-1 hmac_context_digest_test(HashingContext::HashType::HASH_SHA1, "a0ac4cd68a2f4812c355983d94e8d025afe7dddf"); } + +void crypto_key_public_only_test(const String &p_key_path, bool public_only); + +TEST_CASE("[Crypto] CryptoKey is_public_only") { + crypto_key_public_only_test(TestUtils::get_data_path("crypto/in.key"), false); + crypto_key_public_only_test(TestUtils::get_data_path("crypto/in.pub"), true); +} + +void crypto_key_save_test(const String &p_in_path, const String &p_out_path, bool public_only); + +TEST_CASE("[Crypto] CryptoKey save") { + const String in_priv_path = TestUtils::get_data_path("crypto/in.key"); + const String out_priv_path = TestUtils::get_data_path("crypto/out.key"); + crypto_key_save_test(in_priv_path, out_priv_path, false); + + const String in_pub_path = TestUtils::get_data_path("crypto/in.pub"); + const String out_pub_path = TestUtils::get_data_path("crypto/out.pub"); + crypto_key_save_test(in_pub_path, out_pub_path, true); +} + +void crypto_key_save_public_only_test(const String &p_in_priv_path, const String &p_in_pub_path, const String &p_out_path); + +TEST_CASE("[Crypto] CryptoKey save public_only") { + const String in_priv_path = TestUtils::get_data_path("crypto/in.key"); + const String in_pub_path = TestUtils::get_data_path("crypto/in.pub"); + const String out_path = TestUtils::get_data_path("crypto/out_public_only.pub"); + crypto_key_save_public_only_test(in_priv_path, in_pub_path, out_path); +} + } // namespace TestCryptoMbedTLS #endif // TEST_CRYPTO_MBEDTLS_H |