Skip to content

Add AES-256-GCM decryption to the crypto module - #71

Merged
KGronek-Pubnub merged 9 commits into
masterfrom
CLEN-3846-GCM-Cryptor
Dec 3, 2026
Merged

KGronek-Pubnub merged 9 commits into
masterfrom
CLEN-3846-GCM-Cryptor

Conversation

@KGronek-Pubnub

Copy link
Copy Markdown
Contributor

feat(crypto): Decrypt AES-256-GCM messages

The crypto module now decrypts AES-256-GCM messages written with the same cipher key, including messages already in history. New messages are still encrypted with AES-CBC or the legacy cryptor.

@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 106 complexity · 2 duplication

Metric Results
Complexity 106
Duplication 2

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@jakub-grzesiowski jakub-grzesiowski left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment on lines +111 to +115
const int32 AdditionalLimit = bAddGcm ? MaxAdditionalCryptors - 1 : MaxAdditionalCryptors;
if (AdditionalCount > AdditionalLimit)
{
UE_LOG(PubnubLog, Error, TEXT("InitCryptoModule accepts at most %d additional cryptors, including the AES-GCM decryptor."), MaxAdditionalCryptors);
return false;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 High | Compatibility

Automatic GCM registration reduces the existing cryptor limit.

Existing calls with four nonempty AES/legacy fallbacks now return false because the automatic GCM cryptor reserves one of the four slots; a fresh module consequently cannot initialize a client. This limit change is undeclared under REVIEW.md’s Breaking changes rule. Preserve the previous capacity or declare the breaking change and migration requirement in the PR description.

/** Keep in sync with VersionName in PubnubLibrary.uplugin. Used by dependent plugins (e.g. PubnubChat) for version checks. Two digits per component (max 99 each). */
#define PUBNUB_LIBRARY_VERSION_MAJOR 3
#define PUBNUB_LIBRARY_VERSION_MINOR 0
#define PUBNUB_LIBRARY_VERSION_MINOR 1

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Minor | Release

Leave SDK release-version edits to the release pipeline.

This feature PR advances PUBNUB_LIBRARY_VERSION and .pubnub.yml to 3.1.0 while the plugin descriptor still advertises 3.0.0. REVIEW.md's Build and release integrity rule reserves these fields for release automation because the Chat SDK compile-depends on PUBNUB_LIBRARY_VERSION. Revert the SDK release-version edits and let the release pipeline update them together.

* @return true when the module is ready.
*/
UFUNCTION(BlueprintCallable, Category = "PubNub|Crypto")
bool InitLegacyCryptoModule(const FString& CipherKey, bool bUseRandomIV = true);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Minor | Docs

Add consumer snippets for the new legacy and GCM APIs.

Sample_Crypto.cpp demonstrates InitAesCbcCryptoModule, but neither InitLegacyCryptoModule nor UPubnubGcmCryptor has a consumer sample. REVIEW.md's Samples rule requires snippets for new public API; add self-contained examples in the crypto sample for legacy module initialization and GCM decryption.

@KGronek-Pubnub

Copy link
Copy Markdown
Contributor Author

@pubnub-release-bot release as 3.1.0

bool InitCryptoModule(const TScriptInterface<IPubnubCryptorInterface>& InDefaultCryptor, const TArray<TScriptInterface<IPubnubCryptorInterface>>& InAdditionalCryptors);

/**
* Prepares this module to encrypt with AES-256-CBC (identifier "ACRH").

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚪ Nitpick | Docs

Document both new initializers as local operations.

REVIEW.md's Public comments rule requires public methods to identify local work with Local:. Add that execution contract to both InitAesCbcCryptoModule and InitLegacyCryptoModule so their editor tooltips make clear that initialization performs no network request.

@KGronek-Pubnub
KGronek-Pubnub merged commit ee7e856 into master Dec 3, 2026
6 checks passed
@KGronek-Pubnub
KGronek-Pubnub deleted the CLEN-3846-GCM-Cryptor branch December 3, 2026 16:01
@pubnub-release-bot

Copy link
Copy Markdown

🚀 Release successfully completed 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants