From f5bd7f519703bd9695636e55abd2ba60f770f387 Mon Sep 17 00:00:00 2001 From: Xavrax Date: Fri, 6 Oct 2023 01:30:13 +0200 Subject: [PATCH] all wrappers --- core/pbcc_crypto.c | 3 +++ core/pbcc_crypto.h | 13 +++++++++++++ core/pubnub_crypto.c | 2 +- cpp/pubnub_common.hpp | 12 ++++++++++++ qt/pubnub_qt.h | 15 +++++++++++++++ 5 files changed, 44 insertions(+), 1 deletion(-) diff --git a/core/pbcc_crypto.c b/core/pbcc_crypto.c index 5f498e2e..16e69afb 100644 --- a/core/pbcc_crypto.c +++ b/core/pbcc_crypto.c @@ -280,3 +280,6 @@ pubnub_bymebl_t pbcc_base64_decode(const char* buffer) { return pbbase64_decode_alloc_std_str(buffer); } +void pbcc_set_crypto_module(struct pbcc_context *ctx, struct pubnub_crypto_provider_t *crypto_provider) { + ctx->crypto_module = crypto_provider; +} diff --git a/core/pbcc_crypto.h b/core/pbcc_crypto.h index 7aa985af..d7ee1f5c 100644 --- a/core/pbcc_crypto.h +++ b/core/pbcc_crypto.h @@ -1,5 +1,6 @@ /* -*- c-file-style:"stroustrup"; indent-tabs-mode: nil -*- */ +#include "pubnub_ccore_pubsub.h" #ifdef PUBNUB_CRYPTO_API #ifndef PBCC_CRYPTO_H #define PBCC_CRYPTO_H @@ -272,6 +273,18 @@ const char* pbcc_base64_encode(pubnub_bymebl_t buffer); @return The decoded string or NULL on error */ pubnub_bymebl_t pbcc_base64_decode(const char* buffer); + + +/** + Set the crypto module to be used by the pubnub context. + + This function sets the crypto module to be used by the pubnub context + for the encryption and decryption of the messages. + + @param pubnub Pointer to the pubnub context. + @param crypto_provider Pointer to the crypto provider to use. +*/ +void pbcc_set_crypto_module(struct pbcc_context *ctx, struct pubnub_crypto_provider_t *crypto_provider); #endif /* PBCC_CRYPTO_H */ #endif /* PUBNUB_CRYPTO_API */ diff --git a/core/pubnub_crypto.c b/core/pubnub_crypto.c index 12bb3feb..2ce3f847 100644 --- a/core/pubnub_crypto.c +++ b/core/pubnub_crypto.c @@ -857,6 +857,6 @@ static pubnub_bymebl_t provider_decrypt(struct pubnub_crypto_provider_t const* p } void pubnub_set_crypto_module(pubnub_t *pubnub, struct pubnub_crypto_provider_t *crypto_provider) { - pubnub->core.crypto_module = crypto_provider; + pbcc_set_crypto_module(&pubnub->core, crypto_provider); } diff --git a/cpp/pubnub_common.hpp b/cpp/pubnub_common.hpp index d292b5ac..d658fb59 100644 --- a/cpp/pubnub_common.hpp +++ b/cpp/pubnub_common.hpp @@ -1849,6 +1849,18 @@ class context { #endif } +#if PUBNUB_CRYPTO_API + /// Set the crypto module to be sued byt the context + /// + /// This function sets the crypto module to be used by the context + /// for encryption and decryption of messages. + /// @see pubnub_set_crypto_module() + void set_crypto_module(pubnub_crypto* crypto) + { + pubnub_set_crypto_module(d_pb, crypto); + } +#endif /* PUBNUB_CRYPTO_API */ + ~context() { if (d_pb) { diff --git a/qt/pubnub_qt.h b/qt/pubnub_qt.h index 34e4014f..cf54e2cf 100644 --- a/qt/pubnub_qt.h +++ b/qt/pubnub_qt.h @@ -1756,6 +1756,21 @@ class pubnub_qt : public QObject t.fromMSecsSinceStartOfDay(transaction_timeout_get()); } +#if PUBNUB_CRYPTO_API + /** + Set the crypto module to be used by the pubnub. + + This function sets the crypto module to be used by the pubnub context + for the encryption and decryption of the messages. + + @see pubnub_set_crypto_module() + */ + void set_crypto_module(pubnub_bymeblow_crypto* crypto) { + pbcc_set_crypto_module(crypto); + } +#endif /* PUBNUB_CRYPTO_API */ + + private slots: void httpFinished(); void transactionTimeout();