diff options
author | Fabio Alessandrelli <fabio.alessandrelli@gmail.com> | 2020-06-06 15:42:46 +0200 |
---|---|---|
committer | Fabio Alessandrelli <fabio.alessandrelli@gmail.com> | 2020-06-18 15:29:39 +0200 |
commit | dfcc11fa52622680fe427c19dfe0528563a0691e (patch) | |
tree | 11a69fcc6dda0aef7edabd80c98813ae94680cc1 /core | |
parent | 788f18086e01c67c817c1c095e88fd4cbbd3d345 (diff) |
Implement sign and verify in crypto.
Diffstat (limited to 'core')
-rw-r--r-- | core/crypto/crypto.cpp | 2 | ||||
-rw-r--r-- | core/crypto/crypto.h | 4 |
2 files changed, 6 insertions, 0 deletions
diff --git a/core/crypto/crypto.cpp b/core/crypto/crypto.cpp index a6b1fa9f03..f1d13b0633 100644 --- a/core/crypto/crypto.cpp +++ b/core/crypto/crypto.cpp @@ -86,6 +86,8 @@ void Crypto::_bind_methods() { ClassDB::bind_method(D_METHOD("generate_random_bytes", "size"), &Crypto::generate_random_bytes); ClassDB::bind_method(D_METHOD("generate_rsa", "size"), &Crypto::generate_rsa); 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); } /// Resource loader/saver diff --git a/core/crypto/crypto.h b/core/crypto/crypto.h index c1bc2024bb..472ad8ab9d 100644 --- a/core/crypto/crypto.h +++ b/core/crypto/crypto.h @@ -31,6 +31,7 @@ #ifndef CRYPTO_H #define CRYPTO_H +#include "core/crypto/hashing_context.h" #include "core/io/resource_loader.h" #include "core/io/resource_saver.h" #include "core/reference.h" @@ -82,6 +83,9 @@ public: virtual Ref<CryptoKey> generate_rsa(int p_bytes) = 0; virtual Ref<X509Certificate> generate_self_signed_certificate(Ref<CryptoKey> p_key, String p_issuer_name, String p_not_before, String p_not_after) = 0; + 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; + Crypto() {} }; |