diff options
author | Fabio Alessandrelli <fabio.alessandrelli@gmail.com> | 2020-06-06 16:09:28 +0200 |
---|---|---|
committer | Fabio Alessandrelli <fabio.alessandrelli@gmail.com> | 2020-06-18 15:29:39 +0200 |
commit | 8e3f9aa68104fefc959d2d6af7cba3c11bfde3fb (patch) | |
tree | 18fdcab640abab3175f557131d36b48e83463b38 /core | |
parent | dfcc11fa52622680fe427c19dfe0528563a0691e (diff) |
Implement RSA encryption/decryption.
Diffstat (limited to 'core')
-rw-r--r-- | core/crypto/crypto.cpp | 2 | ||||
-rw-r--r-- | core/crypto/crypto.h | 2 |
2 files changed, 4 insertions, 0 deletions
diff --git a/core/crypto/crypto.cpp b/core/crypto/crypto.cpp index f1d13b0633..29d02e11df 100644 --- a/core/crypto/crypto.cpp +++ b/core/crypto/crypto.cpp @@ -88,6 +88,8 @@ void Crypto::_bind_methods() { ClassDB::bind_method(D_METHOD("generate_self_signed_certificate", "key", "issuer_name", "not_before", "not_after"), &Crypto::generate_self_signed_certificate, DEFVAL("CN=myserver,O=myorganisation,C=IT"), DEFVAL("20140101000000"), DEFVAL("20340101000000")); ClassDB::bind_method(D_METHOD("sign", "hash_type", "hash", "key"), &Crypto::sign); ClassDB::bind_method(D_METHOD("verify", "hash_type", "hash", "signature", "key"), &Crypto::verify); + ClassDB::bind_method(D_METHOD("encrypt", "key", "plaintext"), &Crypto::encrypt); + ClassDB::bind_method(D_METHOD("decrypt", "key", "ciphertext"), &Crypto::decrypt); } /// Resource loader/saver diff --git a/core/crypto/crypto.h b/core/crypto/crypto.h index 472ad8ab9d..916f7798eb 100644 --- a/core/crypto/crypto.h +++ b/core/crypto/crypto.h @@ -85,6 +85,8 @@ public: virtual Vector<uint8_t> sign(HashingContext::HashType p_hash_type, Vector<uint8_t> p_hash, Ref<CryptoKey> p_key) = 0; virtual bool verify(HashingContext::HashType p_hash_type, Vector<uint8_t> p_hash, Vector<uint8_t> p_signature, Ref<CryptoKey> p_key) = 0; + virtual Vector<uint8_t> encrypt(Ref<CryptoKey> p_key, Vector<uint8_t> p_plaintext) = 0; + virtual Vector<uint8_t> decrypt(Ref<CryptoKey> p_key, Vector<uint8_t> p_ciphertext) = 0; Crypto() {} }; |