Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marcinwasowicz/0a43950fb202f03b3c5b92fe17dd5272 to your computer and use it in GitHub Desktop.
Save marcinwasowicz/0a43950fb202f03b3c5b92fe17dd5272 to your computer and use it in GitHub Desktop.
NSE decrypt
diff --git a/native/ios/NotificationService/NotificationService.mm b/native/ios/NotificationService/NotificationService.mm
index 7a8474632..7d7111261 100644
--- a/native/ios/NotificationService/NotificationService.mm
+++ b/native/ios/NotificationService/NotificationService.mm
@@ -1,5 +1,6 @@
#import "NotificationService.h"
#import "Logger.h"
+#import "NotificationsCryptoModule.h"
#import "TemporaryMessageStorage.h"
NSString *const backgroundNotificationTypeKey = @"backgroundNotifType";
@@ -26,6 +27,34 @@ CFStringRef newMessageInfosDarwinNotification =
self.contentHandler = contentHandler;
self.bestAttemptContent = [request.content mutableCopy];
+ const std::string encryptedBody =
+ std::string([self.bestAttemptContent.body UTF8String]);
+ std::string decryptedBody =
+ comm::NotificationsCryptoModule::decrypt(encryptedBody, 1, "NSE");
+ self.bestAttemptContent.body =
+ [NSString stringWithUTF8String:decryptedBody.c_str()];
+
+ const std::string encryptedThreadID =
+ std::string([self.bestAttemptContent.threadIdentifier UTF8String]);
+ std::string decryptedThreadID =
+ comm::NotificationsCryptoModule::decrypt(encryptedThreadID, 1, "NSE");
+ self.bestAttemptContent.threadIdentifier =
+ [NSString stringWithUTF8String:decryptedThreadID.c_str()];
+
+ const std::string encryptedMessageInfos = std::string(
+ [self.bestAttemptContent.userInfo[@"messageInfos"] UTF8String]);
+ std::string decryptedMessageInfos =
+ comm::NotificationsCryptoModule::decrypt(encryptedMessageInfos, 1, "NSE");
+ NSMutableDictionary *mutableUserInfo =
+ [self.bestAttemptContent.userInfo mutableCopy];
+ mutableUserInfo[@"messageInfos"] =
+ [NSString stringWithUTF8String:decryptedMessageInfos.c_str()];
+ self.bestAttemptContent.userInfo = mutableUserInfo;
+
+ comm::Logger::log(encryptedBody);
+ comm::Logger::log(encryptedThreadID);
+ comm::Logger::log(encryptedMessageInfos);
+
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment